47 Index *childRTindex_p);
49 List *translated_vars);
86 bool old_isParent =
false;
87 int old_allMarkTypes = 0;
99 parentOID = rte->
relid;
132 if (oldrelation->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
144 oldrelation, oldrc, lockmode);
185 if (childOID != parentOID)
188 newrelation = oldrelation;
205 &childrte, &childRTindex);
211 if (childOID != parentOID)
248 newvars =
lappend(newvars, var);
266 newvars =
lappend(newvars, var);
321 if (partdesc->
nparts == 0)
334 if (num_live_parts > 0)
369 elog(
ERROR,
"temporary relation from another session found as partition");
373 parentrel, top_parentrc, childrel,
374 &childrte, &childRTindex);
383 if (childrel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
385 childrte, childRTindex,
386 childrel, top_parentrc, lockmode);
418 Index *childRTindex_p)
427 List *parent_colnames;
428 List *child_colnames;
448 childrte->
relid = childOID;
451 if (childrte->
relkind == RELKIND_PARTITIONED_TABLE)
453 Assert(childOID != parentOID);
454 childrte->
inh =
true;
457 childrte->
inh =
false;
464 *childrte_p = childrte;
465 *childRTindex_p = childRTindex;
471 parentRTindex, childRTindex);
487 child_colnames =
NIL;
488 for (
int cattno = 0; cattno < child_tupdesc->
natts; cattno++)
493 if (att->attisdropped)
508 attname =
NameStr(att->attname);
530 if (childOID != parentOID)
553 Assert(childRTindex < root->simple_rel_array_size);
566 childrc->
rti = childRTindex;
567 childrc->
prti = top_parentrc->
rti;
603 List *translated_vars)
625 foreach(lc, translated_vars)
669 Assert(childRTindex < root->simple_rel_array_size);
698 Index cq_min_security;
710 cq_min_security = UINT_MAX;
723 if (childqual &&
IsA(childqual,
Const))
725 if (((
Const *) childqual)->constisnull ||
750 childquals =
lappend(childquals,
775 Index security_level = 0;
782 foreach(lc2, qualset)
787 childquals =
lappend(childquals,
792 cq_min_security =
Min(cq_min_security, security_level);
796 Assert(security_level <= root->qual_security_level);
static Bitmapset * translate_col_privs(const Bitmapset *parent_privs, List *translated_vars)
Value * makeString(char *str)
#define IsA(nodeptr, _type_)
void table_close(Relation relation, LOCKMODE lockmode)
Bitmapset * bms_copy(const Bitmapset *a)
RestrictInfo * make_restrictinfo(Expr *clause, bool is_pushed_down, bool outerjoin_delayed, bool pseudoconstant, Index security_level, Relids required_relids, Relids outer_relids, Relids nullable_relids)
#define RelationGetDescr(relation)
AttrNumber * parent_colnos
#define TupleDescAttr(tupdesc, i)
RowMarkType select_rowmark_type(RangeTblEntry *rte, LockClauseStrength strength)
char * pstrdup(const char *in)
int bms_next_member(const Bitmapset *a, int prevbit)
Var * makeWholeRowVar(RangeTblEntry *rte, Index varno, Index varlevelsup, bool allowScalar)
Node * eval_const_expressions(PlannerInfo *root, Node *node)
#define FirstLowInvalidHeapAttributeNumber
Index baserestrict_min_security
bool contain_volatile_functions(Node *clause)
static void expand_appendrel_subquery(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte, Index rti)
LockWaitPolicy waitPolicy
void add_vars_to_targetlist(PlannerInfo *root, List *vars, Relids where_needed, bool create_new_ph)
Alias * makeAlias(const char *aliasname, List *colnames)
bool apply_child_basequals(PlannerInfo *root, RelOptInfo *parentrel, RelOptInfo *childrel, RangeTblEntry *childRTE, AppendRelInfo *appinfo)
Bitmapset * extraUpdatedCols
static void expand_single_inheritance_child(PlannerInfo *root, RangeTblEntry *parentrte, Index parentRTindex, Relation parentrel, PlanRowMark *top_parentrc, Relation childrel, RangeTblEntry **childrte_p, Index *childRTindex_p)
static void * list_nth(const List *list, int n)
#define planner_rt_fetch(rti, root)
#define lfirst_node(type, lc)
int bms_num_members(const Bitmapset *a)
bool has_partition_attrs(Relation rel, Bitmapset *attnums, bool *used_in_expr)
Bitmapset * bms_make_singleton(int x)
void check_stack_depth(void)
FormData_pg_attribute * Form_pg_attribute
#define TableOidAttributeNumber
RelOptInfo * build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
Var * makeVar(Index varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
List * lappend(List *list, void *datum)
RangeTblEntry ** simple_rte_array
void * palloc0(Size size)
struct AppendRelInfo ** append_rel_array
List * make_ands_implicit(Expr *clause)
bool hasPseudoConstantQuals
void expand_inherited_rtentry(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte, Index rti)
#define Assert(condition)
#define RELATION_IS_OTHER_TEMP(relation)
bool contain_vars_of_level(Node *node, int levelsup)
LockClauseStrength strength
struct RelOptInfo ** part_rels
static int list_length(const List *l)
static void expand_partitioned_rtentry(PlannerInfo *root, RelOptInfo *relinfo, RangeTblEntry *parentrte, Index parentRTindex, Relation parentrel, PlanRowMark *top_parentrc, LOCKMODE lockmode)
Bitmapset * bms_add_member(Bitmapset *a, int x)
#define InvalidAttrNumber
Bitmapset * prune_append_rel_partitions(RelOptInfo *rel)
List * find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents)
void expand_planner_arrays(PlannerInfo *root, int add_size)
PlanRowMark * get_plan_rowmark(List *rowmarks, Index rtindex)
PartitionDesc PartitionDirectoryLookup(PartitionDirectory pdir, Relation rel)
PartitionDirectory partition_directory
Relation table_open(Oid relationId, LOCKMODE lockmode)
bool bms_is_member(int x, const Bitmapset *a)
struct TableSampleClause * tablesample
#define RelationGetRelid(relation)
AppendRelInfo * make_append_rel_info(Relation parentrel, Relation childrel, Index parentRTindex, Index childRTindex)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
static struct subre * parse(struct vars *, int, int, struct state *, struct state *)
Node * adjust_appendrel_attrs(PlannerInfo *root, Node *node, int nappinfos, AppendRelInfo **appinfos)