mirror of
https://github.com/hanzoai/postgres.git
synced 2026-10-30 18:33:07 +00:00
It turns out that our main regression test suite queries tables upon which concurrent DDL is occurring, which can, rarely, cause test_plan_advice failures. We're not quite ready to fix that problem just yet, because we want to gather some more information about how often it actually happens first. But, our plan is going to require test_plan_advice to access a few bits of pg_plan_advice that have been considered internal up until now, so this commit rejiggers things to expose those bits. First, test_plan_advice is going to need to be able to interpret the PGPA_TE_* constants which have been declared in pgpa_trove.h. The "TE" stands for "trove entry" but that's kind of a silly name; change the naming to "FB" (for "feedback") and move the declarations to pg_plan_advice.h, which is a header file that's already installed. This has the side benefit of making these constants available to any other extensions that may want to examine plan advice feedback. Second, test_plan_advice is going to call pgpa_planner_feedback_warning, so make that function non-static and mark it PGDLLEXPORT. Discussion: http://postgr.es/m/CA+TgmobOOmmXSJz3e+cjTY-bA1+W0dqVDqzxUBEvGtW62whYGg@mail.gmail.com
83 lines
2.9 KiB
C
83 lines
2.9 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* pgpa_planner.h
|
|
* planner integration for pg_plan_advice
|
|
*
|
|
* Copyright (c) 2016-2026, PostgreSQL Global Development Group
|
|
*
|
|
* contrib/pg_plan_advice/pgpa_planner.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef PGPA_PLANNER_H
|
|
#define PGPA_PLANNER_H
|
|
|
|
#include "pgpa_identifier.h"
|
|
|
|
extern void pgpa_planner_install_hooks(void);
|
|
|
|
/*
|
|
* Per-PlannerInfo information that we gather during query planning.
|
|
*/
|
|
typedef struct pgpa_planner_info
|
|
{
|
|
/* Plan name taken from the corresponding PlannerInfo; NULL at top level. */
|
|
char *plan_name;
|
|
|
|
/*
|
|
* If the corresponding PlannerInfo has an alternative_root, then this is
|
|
* the plan name from that PlannerInfo; otherwise, it is the same as
|
|
* plan_name.
|
|
*
|
|
* is_alternative_plan is set to true for every pgpa_planner_info that
|
|
* shares an alternative_plan_name with at least one other, and to false
|
|
* otherwise.
|
|
*/
|
|
char *alternative_plan_name;
|
|
bool is_alternative_plan;
|
|
|
|
/* Relation identifiers computed for baserels at this query level. */
|
|
pgpa_identifier *rid_array;
|
|
int rid_array_size;
|
|
|
|
/*
|
|
* If has_rtoffset is true, then rtoffset is the offset required to align
|
|
* RTIs for this query level with RTIs from the final, flattened
|
|
* rangetable. If has_rtoffset is false, then this subquery's range table
|
|
* wasn't copied, or was only partially copied, into the final range
|
|
* table. (Note that we can't determine the rtoffset values until the
|
|
* final range table actually exists; before that time, has_rtoffset will
|
|
* be false everywhere except at the top level.)
|
|
*/
|
|
bool has_rtoffset;
|
|
Index rtoffset;
|
|
|
|
/*
|
|
* List of Bitmapset objects. Each represents the relid set of a relation
|
|
* that the planner considers making unique during semijoin planning.
|
|
*
|
|
* When generating advice, we should emit either SEMIJOIN_UNIQUE advice or
|
|
* SEMIJOIN_NON_UNIQUE advice for each semijoin depending on whether we
|
|
* chose to implement it as a semijoin or whether we instead chose to make
|
|
* the nullable side unique and then perform an inner join. When the
|
|
* make-unique strategy is not chosen, it's not easy to tell from the
|
|
* final plan tree whether it was considered. That's awkward, because we
|
|
* don't want to emit useless SEMIJOIN_NON_UNIQUE advice when there was no
|
|
* decision to be made. This list lets the plan tree walker know in which
|
|
* cases that approach was considered, so that it doesn't have to guess.
|
|
*/
|
|
List *sj_unique_rels;
|
|
} pgpa_planner_info;
|
|
|
|
/*
|
|
* When set to a value greater than zero, indicates that advice should be
|
|
* generated during query planning even in the absence of obvious reasons to
|
|
* do so. See pg_plan_advice_request_advice_generation().
|
|
*/
|
|
extern int pgpa_planner_generate_advice;
|
|
|
|
/* Must be exported for use by test_plan_advice */
|
|
extern PGDLLEXPORT void pgpa_planner_feedback_warning(List *feedback);
|
|
|
|
#endif
|