67 bool *returning_flag);
78 const char *attrName);
82 Relation target_relation,
bool force_nulls,
88 int varno,
Query *parsetree,
bool *hasUpdate);
141 bool forUpdatePushedDown)
153 foreach(l, parsetree->
rtable)
179 else if (forUpdatePushedDown)
217 Var *aliasvar = aliasitem;
229 if (aliasvar &&
IsA(aliasvar,
Var))
241 if (aliasvar->
varno != curinputvarno)
243 curinputvarno = aliasvar->
varno;
244 if (curinputvarno >= rt_index)
245 elog(
ERROR,
"unexpected varno %d in JOIN RTE %d",
246 curinputvarno, rt_index);
247 curinputrte =
rt_fetch(curinputvarno,
257 newaliasvars =
lappend(newaliasvars, aliasitem);
270 (forUpdatePushedDown ||
347 bool *returning_flag)
353 Query **sub_action_ptr;
371 current_varno = rt_index;
432 foreach(lc, parsetree->
rtable)
497 if (newjointree !=
NIL)
507 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
508 errmsg(
"conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
542 foreach(lc, parsetree->
cteList)
547 foreach(lc2, sub_action->
cteList)
553 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
554 errmsg(
"WITH query name \"%s\" appears in both a rule action and the query being rewritten",
580 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
581 errmsg(
"INSERT...SELECT rule actions are not supported for queries having data-modifying statements in WITH")));
589 AddQual(sub_action, rule_qual);
604 sub_action = (
Query *)
616 *sub_action_ptr = sub_action;
618 rule_action = sub_action;
633 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
634 errmsg(
"cannot have RETURNING lists in multiple rules")));
635 *returning_flag =
true;
675 foreach(l, newjointree)
735 int values_rte_index,
759 next_junk_attrno = numattrs + 1;
761 foreach(temp, targetList)
768 attrno = old_tle->
resno;
769 if (attrno < 1 || attrno > numattrs)
770 elog(
ERROR,
"bogus resno %d in targetlist", attrno);
774 if (att_tup->attisdropped)
778 new_tles[attrno - 1] =
780 new_tles[attrno - 1],
795 if (old_tle->
resno != next_junk_attrno)
798 old_tle->
resno = next_junk_attrno;
800 junk_tlist =
lappend(junk_tlist, old_tle);
805 for (attrno = 1; attrno <= numattrs; attrno++)
813 if (att_tup->attisdropped)
821 apply_default = ((new_tle == NULL && commandType ==
CMD_INSERT) ||
826 int values_attrno = 0;
829 if (values_rte && new_tle &&
IsA(new_tle->
expr,
Var))
833 if (var->
varno == values_rte_index)
842 if (att_tup->attidentity == ATTRIBUTE_IDENTITY_ALWAYS && !apply_default)
845 apply_default =
true;
854 if (values_attrno != 0)
856 if (default_only_cols == NULL)
860 apply_default =
true;
865 (
errcode(ERRCODE_GENERATED_ALWAYS),
866 errmsg(
"cannot insert a non-DEFAULT value into column \"%s\"",
868 errdetail(
"Column \"%s\" is an identity column defined as GENERATED ALWAYS.",
870 errhint(
"Use OVERRIDING SYSTEM VALUE to override.")));
879 if (att_tup->attidentity == ATTRIBUTE_IDENTITY_BY_DEFAULT &&
881 apply_default =
true;
887 if (att_tup->attgenerated && !apply_default)
893 if (values_attrno != 0)
895 if (default_only_cols == NULL)
899 apply_default =
true;
904 (
errcode(ERRCODE_GENERATED_ALWAYS),
905 errmsg(
"cannot insert a non-DEFAULT value into column \"%s\"",
907 errdetail(
"Column \"%s\" is a generated column.",
916 if (values_attrno != 0 && apply_default && unused_values_attrnos)
928 if (att_tup->attidentity == ATTRIBUTE_IDENTITY_ALWAYS &&
929 new_tle && !apply_default)
931 (
errcode(ERRCODE_GENERATED_ALWAYS),
932 errmsg(
"column \"%s\" can only be updated to DEFAULT",
934 errdetail(
"Column \"%s\" is an identity column defined as GENERATED ALWAYS.",
937 if (att_tup->attgenerated && new_tle && !apply_default)
939 (
errcode(ERRCODE_GENERATED_ALWAYS),
940 errmsg(
"column \"%s\" can only be updated to DEFAULT",
942 errdetail(
"Column \"%s\" is a generated column.",
946 if (att_tup->attgenerated)
953 else if (apply_default)
974 att_tup->attcollation,
998 new_tlist =
lappend(new_tlist, new_tle);
1016 const char *attrName)
1027 if (prior_tle == NULL)
1067 prior_expr = (
Node *) prior_tle->
expr;
1082 if (src_input == NULL ||
1083 prior_input == NULL ||
1086 (
errcode(ERRCODE_SYNTAX_ERROR),
1087 errmsg(
"multiple assignments to same column \"%s\"",
1093 priorbottom = prior_input;
1098 if (newbottom == NULL)
1100 priorbottom = newbottom;
1102 if (!
equal(priorbottom, src_input))
1104 (
errcode(ERRCODE_SYNTAX_ERROR),
1105 errmsg(
"multiple assignments to same column \"%s\"",
1118 memcpy(fstore, prior_expr,
sizeof(
FieldStore));
1129 memcpy(fstore, src_expr,
sizeof(
FieldStore));
1130 fstore->
arg = (
Expr *) prior_expr;
1132 newexpr = (
Node *) fstore;
1140 newexpr = (
Node *) sbsref;
1154 newcoerce->
arg = (
Expr *) newexpr;
1155 newexpr = (
Node *) newcoerce;
1200 Oid atttype = att_tup->atttypid;
1201 int32 atttypmod = att_tup->atttypmod;
1205 if (att_tup->attidentity)
1210 nve->
typeId = att_tup->atttypid;
1212 return (
Node *) nve;
1218 if (att_tup->atthasdef)
1227 if (attrno == defval[ndef].adnum)
1236 elog(
ERROR,
"default expression not found for attribute %d of relation \"%s\"",
1244 if (expr == NULL && !att_tup->attgenerated)
1267 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1268 errmsg(
"column \"%s\" is of type %s"
1269 " but default expression is of type %s",
1273 errhint(
"You will need to rewrite or cast the expression.")));
1290 foreach(lc2, sublist)
1318 if (default_only_cols == NULL)
1322 foreach(lc2, sublist)
1335 foreach(lc2, sublist)
1353 return default_only_cols;
1407 Relation target_relation,
bool force_nulls,
1412 bool isAutoUpdatableView;
1436 attrnos = (
int *)
palloc0(numattrs *
sizeof(
int));
1450 Assert(attrno >= 1 && attrno <= numattrs);
1451 attrnos[attrno - 1] = tle->
resno;
1462 isAutoUpdatableView =
false;
1464 target_relation->
rd_rel->relkind == RELKIND_VIEW &&
1482 rule_lock->
qual == NULL)
1495 isAutoUpdatableView =
true;
1510 foreach(lc2, sublist)
1513 int attrno = attrnos[
i++];
1537 elog(
ERROR,
"cannot set value in column %d to DEFAULT",
i);
1540 if (!force_nulls && !att_tup->attisdropped)
1552 if (isAutoUpdatableView)
1555 newList =
lappend(newList, col);
1556 allReplaced =
false;
1562 att_tup->attcollation,
1576 newList =
lappend(newList, new_expr);
1579 newList =
lappend(newList, col);
1581 newValues =
lappend(newValues, newList);
1643 if (rulelocks == NULL)
1658 for (
i = 0;
i < nlocks;
i++)
1687 if (oneLock->
event == event)
1691 matching_locks =
lappend(matching_locks, oneLock);
1695 return matching_locks;
1715 elog(
ERROR,
"expected just one rule action");
1716 if (
rule->qual != NULL)
1717 elog(
ERROR,
"cannot handle qualified ON SELECT rule");
1794 elog(
ERROR,
"unrecognized commandType: %d",
1908 strength, waitPolicy,
true);
1928 elog(
ERROR,
"unrecognized node type: %d",
1966 (
void *) activeRIRs);
1990 foreach(lc, parsetree->
cteList)
2046 if (rte->
relkind == RELKIND_MATVIEW)
2075 if (rt_index == parsetree->resultRelation &&
2076 rt_index != origResultRelation)
2092 for (
i = 0;
i <
rules->numLocks;
i++)
2110 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2111 errmsg(
"infinite recursion detected in rules for relation \"%s\"",
2134 foreach(lc, parsetree->
cteList)
2157 foreach(lc, parsetree->
rtable)
2161 List *securityQuals;
2162 List *withCheckOptions;
2163 bool hasRowSecurity;
2170 (rte->
relkind != RELKIND_RELATION &&
2171 rte->
relkind != RELKIND_PARTITIONED_TABLE))
2180 &securityQuals, &withCheckOptions,
2181 &hasRowSecurity, &hasSubLinks);
2183 if (securityQuals !=
NIL || withCheckOptions !=
NIL)
2195 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2196 errmsg(
"infinite recursion detected in policy for relation \"%s\"",
2345 bool *returning_flag,
2346 Query **qual_product)
2354 Node *event_qual = rule_lock->
qual;
2362 if (event_qual != NULL)
2367 *instead_flag =
true;
2389 if (*qual_product == NULL)
2407 event_qual, rt_index, event,
2413 results =
lappend(results, rule_action);
2445 elog(
ERROR,
"invalid _RETURN rule action specification");
2451 elog(
ERROR,
"failed to find _RETURN rule for view");
2483 elog(
ERROR,
"unrecognized CmdType: %d", (
int) event);
2516 return gettext_noop(
"Junk view columns are not updatable.");
2521 return gettext_noop(
"View columns that are not columns of their base relation are not updatable.");
2524 return gettext_noop(
"View columns that refer to system columns are not updatable.");
2527 return gettext_noop(
"View columns that return whole-row references are not updatable.");
2588 return gettext_noop(
"Views containing DISTINCT are not automatically updatable.");
2591 return gettext_noop(
"Views containing GROUP BY are not automatically updatable.");
2594 return gettext_noop(
"Views containing HAVING are not automatically updatable.");
2597 return gettext_noop(
"Views containing UNION, INTERSECT, or EXCEPT are not automatically updatable.");
2600 return gettext_noop(
"Views containing WITH are not automatically updatable.");
2603 return gettext_noop(
"Views containing LIMIT or OFFSET are not automatically updatable.");
2615 return gettext_noop(
"Views that return aggregate functions are not automatically updatable.");
2618 return gettext_noop(
"Views that return window functions are not automatically updatable.");
2621 return gettext_noop(
"Views that return set-returning functions are not automatically updatable.");
2628 return gettext_noop(
"Views that do not select from a single table or view are not automatically updatable.");
2632 return gettext_noop(
"Views that do not select from a single table or view are not automatically updatable.");
2636 (base_rte->
relkind != RELKIND_RELATION &&
2637 base_rte->
relkind != RELKIND_FOREIGN_TABLE &&
2638 base_rte->
relkind != RELKIND_VIEW &&
2639 base_rte->
relkind != RELKIND_PARTITIONED_TABLE))
2640 return gettext_noop(
"Views that do not select from a single table or view are not automatically updatable.");
2643 return gettext_noop(
"Views containing TABLESAMPLE are not automatically updatable.");
2667 return gettext_noop(
"Views that have no updatable columns are not automatically updatable.");
2701 char **non_updatable_col)
2715 if (updatable_cols != NULL)
2716 *updatable_cols = NULL;
2717 if (non_updatable_col != NULL)
2718 *non_updatable_col = NULL;
2725 const char *col_update_detail;
2730 if (col_update_detail == NULL)
2733 if (updatable_cols != NULL)
2739 if (non_updatable_col != NULL)
2740 *non_updatable_col = tle->
resname;
2741 return col_update_detail;
2782 List *outer_reloids,
2783 bool include_triggers,
2790 #define ALL_EVENTS ((1 << CMD_INSERT) | (1 << CMD_UPDATE) | (1 << CMD_DELETE))
2814 if (rel->
rd_rel->relkind == RELKIND_RELATION ||
2815 rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
2823 if (rulelocks != NULL)
2845 if (include_triggers)
2868 if (rel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
2890 if (rel->
rd_rel->relkind == RELKIND_VIEW)
2909 &updatable_cols, NULL);
2911 if (include_cols != NULL)
2929 if (base_rte->
relkind != RELKIND_RELATION &&
2930 base_rte->
relkind != RELKIND_PARTITIONED_TABLE)
2932 baseoid = base_rte->
relid;
2943 events |= auto_events;
2984 foreach(lc, targetlist)
3013 elog(
ERROR,
"attribute number %d not found in view targetlist",
3035 const char *auto_update_detail;
3043 List *view_targetlist;
3056 auto_update_detail =
3060 if (auto_update_detail)
3067 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3068 errmsg(
"cannot insert into view \"%s\"",
3071 errhint(
"To enable inserting into the view, provide an INSTEAD OF INSERT trigger or an unconditional ON INSERT DO INSTEAD rule.")));
3075 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3076 errmsg(
"cannot update view \"%s\"",
3079 errhint(
"To enable updating the view, provide an INSTEAD OF UPDATE trigger or an unconditional ON UPDATE DO INSTEAD rule.")));
3083 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3084 errmsg(
"cannot delete from view \"%s\"",
3087 errhint(
"To enable deleting from the view, provide an INSTEAD OF DELETE trigger or an unconditional ON DELETE DO INSTEAD rule.")));
3106 char *non_updatable_col;
3132 &non_updatable_col);
3133 if (auto_update_detail)
3143 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3144 errmsg(
"cannot insert into column \"%s\" of view \"%s\"",
3151 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3152 errmsg(
"cannot update column \"%s\" of view \"%s\"",
3231 new_rte->
inh =
false;
3313 parsetree = (
Query *)
3358 elog(
ERROR,
"attribute number %d not found in view targetlist",
3370 Index old_exclRelIndex,
3393 elog(
ERROR,
"attribute number %d not found in view targetlist",
3412 new_exclRte = new_exclNSItem->
p_rte;
3413 new_exclRte->
relkind = RELKIND_COMPOSITE_TYPE;
3439 new_exclRelIndex, 0);
3546 if (has_wco && (cascaded || viewquery->
jointree->
quals != NULL))
3596 bool instead =
false;
3597 bool returning =
false;
3598 bool updatableview =
false;
3599 Query *qual_product = NULL;
3608 foreach(lc1, parsetree->
cteList)
3638 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3639 errmsg(
"DO INSTEAD NOTIFY rules are not supported for data-modifying statements in WITH")));
3646 else if (newstuff ==
NIL)
3649 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3650 errmsg(
"DO INSTEAD NOTHING rules are not supported for data-modifying statements in WITH")));
3657 foreach(lc2, newstuff)
3663 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3664 errmsg(
"conditional DO INSTEAD rules are not supported for data-modifying statements in WITH")));
3667 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3668 errmsg(
"DO ALSO rules are not supported for data-modifying statements in WITH")));
3672 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3673 errmsg(
"multi-statement DO INSTEAD rules are not supported for data-modifying statements in WITH")));
3687 int result_relation;
3691 List *product_queries;
3692 bool hasUpdate =
false;
3693 int values_rte_index = 0;
3694 bool defaults_remaining =
false;
3697 Assert(result_relation != 0);
3730 values_rte_index = rtr->
rtindex;
3737 Bitmapset *unused_values_attrnos = NULL;
3746 &unused_values_attrnos);
3749 rt_entry_relation,
false,
3750 unused_values_attrnos))
3751 defaults_remaining =
true;
3799 switch (
action->commandType)
3825 elog(
ERROR,
"unrecognized commandType: %d", (
int) event);
3831 result_relation, parsetree, &hasUpdate);
3849 if (defaults_remaining && product_queries !=
NIL)
3857 foreach(n, product_queries)
3885 rt_entry_relation->
rd_rel->relkind == RELKIND_VIEW &&
3897 if (qual_product != NULL)
3903 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3904 errmsg(
"cannot insert into view \"%s\"",
3906 errdetail(
"Views with conditional DO INSTEAD rules are not automatically updatable."),
3907 errhint(
"To enable inserting into the view, provide an INSTEAD OF INSERT trigger or an unconditional ON INSERT DO INSTEAD rule.")));
3911 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3912 errmsg(
"cannot update view \"%s\"",
3914 errdetail(
"Views with conditional DO INSTEAD rules are not automatically updatable."),
3915 errhint(
"To enable updating the view, provide an INSTEAD OF UPDATE trigger or an unconditional ON UPDATE DO INSTEAD rule.")));
3919 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3920 errmsg(
"cannot delete from view \"%s\"",
3922 errdetail(
"Views with conditional DO INSTEAD rules are not automatically updatable."),
3923 errhint(
"To enable deleting from the view, provide an INSTEAD OF DELETE trigger or an unconditional ON DELETE DO INSTEAD rule.")));
3946 product_queries =
lcons(parsetree, product_queries);
3948 product_queries =
lappend(product_queries, parsetree);
3959 updatableview =
true;
3966 if (product_queries !=
NIL)
3971 foreach(n, rewrite_events)
3975 rev->
event == event)
3977 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3978 errmsg(
"infinite recursion detected in rules for relation \"%s\"",
3985 rewrite_events =
lappend(rewrite_events, rev);
3987 foreach(n, product_queries)
4006 if ((instead || qual_product != NULL) &&
4014 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4015 errmsg(
"cannot perform INSERT RETURNING on relation \"%s\"",
4017 errhint(
"You need an unconditional ON INSERT DO INSTEAD rule with a RETURNING clause.")));
4021 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4022 errmsg(
"cannot perform UPDATE RETURNING on relation \"%s\"",
4024 errhint(
"You need an unconditional ON UPDATE DO INSTEAD rule with a RETURNING clause.")));
4028 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4029 errmsg(
"cannot perform DELETE RETURNING on relation \"%s\"",
4031 errhint(
"You need an unconditional ON DELETE DO INSTEAD rule with a RETURNING clause.")));
4034 elog(
ERROR,
"unrecognized commandType: %d",
4045 (product_queries !=
NIL || hasUpdate) &&
4048 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4049 errmsg(
"INSERT with ON CONFLICT clause cannot be used with table that has INSERT or UPDATE rules")));
4070 if (qual_product != NULL)
4071 rewritten =
lcons(qual_product, rewritten);
4073 rewritten =
lcons(parsetree, rewritten);
4077 if (qual_product != NULL)
4078 rewritten =
lappend(rewritten, qual_product);
4080 rewritten =
lappend(rewritten, parsetree);
4096 foreach(lc1, rewritten)
4105 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4106 errmsg(
"WITH cannot be used in a query that is rewritten by rules into multiple queries")));
4125 uint64 input_query_id = parsetree->
queryId;
4130 bool foundOriginalQuery;
4154 foreach(l, querylist)
4160 query->
queryId = input_query_id;
4162 results =
lappend(results, query);
4182 foundOriginalQuery =
false;
4192 Assert(!foundOriginalQuery);
4193 foundOriginalQuery =
true;
4194 #ifndef USE_ASSERT_CHECKING
4204 lastInstead = query;
4208 if (!foundOriginalQuery && lastInstead != NULL)
#define InvalidAttrNumber
int bms_next_member(const Bitmapset *a, int prevbit)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_int_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_del_member(Bitmapset *a, int x)
bool bms_is_empty(const Bitmapset *a)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
int errdetail_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
FdwRoutine * GetFdwRoutineForRelation(Relation relation, bool makecopy)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
List * lappend_oid(List *list, Oid datum)
bool list_member_oid(const List *list, Oid datum)
List * list_concat(List *list1, const List *list2)
List * lcons(void *datum, List *list)
List * list_concat_copy(const List *list1, const List *list2)
List * list_delete_last(List *list)
Node * get_typdefault(Oid typid)
Alias * makeAlias(const char *aliasname, List *colnames)
Var * makeWholeRowVar(RangeTblEntry *rte, int varno, Index varlevelsup, bool allowScalar)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
TargetEntry * flatCopyTargetEntry(TargetEntry *src_tle)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
bool query_tree_walker(Query *query, bool(*walker)(), void *context, int flags)
Oid exprType(const Node *expr)
bool expression_tree_walker(Node *node, bool(*walker)(), void *context)
Node * strip_implicit_coercions(Node *node)
#define QTW_IGNORE_RC_SUBQUERIES
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
Node * coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod, Oid typeId, CoercionContext ccontext, CoercionForm cformat, int location, bool hideInputCoercion)
Node * coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, Oid targettype, int32 targettypmod, CoercionContext ccontext, CoercionForm cformat, int location)
ParseState * make_parsestate(ParseState *parentParseState)
RowMarkClause * get_parse_rowmark(Query *qry, Index rtindex)
ParseNamespaceItem * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, int lockmode, Alias *alias, bool inh, bool inFromCl)
bool get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
#define ACL_SELECT_FOR_UPDATE
@ OVERRIDING_SYSTEM_VALUE
void applyLockingClause(Query *qry, Index rtindex, LockClauseStrength strength, LockWaitPolicy waitPolicy, bool pushedDown)
List * BuildOnConflictExcludedTargetlist(Relation targetrel, Index exclRelIndex)
#define rt_fetch(rangetable_index, rangetable)
FormData_pg_attribute * Form_pg_attribute
Oid getIdentitySequence(Oid relid, AttrNumber attnum, bool missing_ok)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
#define foreach_delete_current(lst, cell)
void check_stack_depth(void)
void * stringToNode(const char *str)
#define RelationGetRelid(relation)
#define RelationHasCheckOption(relation)
#define RelationHasSecurityInvoker(relation)
#define RelationGetDescr(relation)
#define RelationGetNumberOfAttributes(relation)
#define RelationGetRelationName(relation)
#define RelationHasCascadedCheckOption(relation)
#define RelationIsSecurityView(relation)
#define RULE_FIRES_ON_ORIGIN
#define RULE_FIRES_ON_REPLICA
static void markQueryForLocking(Query *qry, Node *jtnode, LockClauseStrength strength, LockWaitPolicy waitPolicy, bool pushedDown)
static Query * rewriteRuleAction(Query *parsetree, Query *rule_action, Node *rule_qual, int rt_index, CmdType event, bool *returning_flag)
static List * fireRules(Query *parsetree, int rt_index, CmdType event, List *locks, bool *instead_flag, bool *returning_flag, Query **qual_product)
static TargetEntry * process_matched_tle(TargetEntry *src_tle, TargetEntry *prior_tle, const char *attrName)
static List * adjustJoinTreeList(Query *parsetree, bool removert, int rt_index)
void fill_extraUpdatedCols(RangeTblEntry *target_rte, Relation target_relation)
void AcquireRewriteLocks(Query *parsetree, bool forExecute, bool forUpdatePushedDown)
const char * view_query_is_auto_updatable(Query *viewquery, bool check_cols)
int relation_is_updatable(Oid reloid, List *outer_reloids, bool include_triggers, Bitmapset *include_cols)
static Query * CopyAndAddInvertedQual(Query *parsetree, Node *rule_qual, int rt_index, CmdType event)
List * QueryRewrite(Query *parsetree)
static List * RewriteQuery(Query *parsetree, List *rewrite_events)
static bool acquireLocksOnSubLinks(Node *node, acquireLocksOnSubLinks_context *context)
static Node * get_assignment_input(Node *node)
static Bitmapset * adjust_view_column_set(Bitmapset *cols, List *targetlist)
struct acquireLocksOnSubLinks_context acquireLocksOnSubLinks_context
static bool fireRIRonSubLink(Node *node, List *activeRIRs)
static bool searchForDefault(RangeTblEntry *rte)
struct rewrite_event rewrite_event
static Query * fireRIRrules(Query *parsetree, List *activeRIRs)
static const char * view_cols_are_auto_updatable(Query *viewquery, Bitmapset *required_cols, Bitmapset **updatable_cols, char **non_updatable_col)
static bool rewriteValuesRTE(Query *parsetree, RangeTblEntry *rte, int rti, Relation target_relation, bool force_nulls, Bitmapset *unused_cols)
static Bitmapset * findDefaultOnlyColumns(RangeTblEntry *rte)
Query * get_view_query(Relation view)
static Query * ApplyRetrieveRule(Query *parsetree, RewriteRule *rule, int rt_index, Relation relation, List *activeRIRs)
static List * matchLocks(CmdType event, RuleLock *rulelocks, int varno, Query *parsetree, bool *hasUpdate)
static List * rewriteTargetListIU(List *targetList, CmdType commandType, OverridingKind override, Relation target_relation, RangeTblEntry *values_rte, int values_rte_index, Bitmapset **unused_values_attrnos)
static Query * rewriteTargetView(Query *parsetree, Relation view)
static const char * view_col_is_auto_updatable(RangeTblRef *rtr, TargetEntry *tle)
Node * build_column_default(Relation rel, int attrno)
static bool view_has_instead_trigger(Relation view, CmdType event)
Node * ReplaceVarsFromTargetList(Node *node, int target_varno, int sublevels_up, RangeTblEntry *target_rte, List *targetlist, ReplaceVarsNoMatchOption nomatch_option, int nomatch_varno, bool *outer_hasSubLinks)
void ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up)
void OffsetVarNodes(Node *node, int offset, int sublevels_up)
bool checkExprHasSubLink(Node *node)
Query * getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
void AddQual(Query *parsetree, Node *qual)
bool rangeTableEntry_used(Node *node, int rt_index, int sublevels_up)
void AddInvertedQual(Query *parsetree, Node *qual)
@ REPLACEVARS_SUBSTITUTE_NULL
@ REPLACEVARS_CHANGE_VARNO
@ REPLACEVARS_REPORT_ERROR
CommonTableExpr * rewriteSearchAndCycle(CommonTableExpr *cte)
void get_row_security_policies(Query *root, RangeTblEntry *rte, int rt_index, List **securityQuals, List **withCheckOptions, bool *hasRowSecurity, bool *hasSubLinks)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation try_relation_open(Oid relationId, LOCKMODE lockmode)
CTECycleClause * cycle_clause
CTESearchClause * search_clause
ExecForeignInsert_function ExecForeignInsert
ExecForeignUpdate_function ExecForeignUpdate
ExecForeignDelete_function ExecForeignDelete
IsForeignRelUpdatable_function IsForeignRelUpdatable
OnConflictExpr * onConflict
Bitmapset * extraUpdatedCols
struct TableSampleClause * tablesample
LockClauseStrength strength
LockWaitPolicy waitPolicy
bool trig_update_instead_row
bool trig_delete_instead_row
bool trig_insert_instead_row
bool has_generated_stored
#define FirstLowInvalidHeapAttributeNumber
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
int SessionReplicationRole
#define SESSION_REPLICATION_ROLE_REPLICA
#define TupleDescAttr(tupdesc, i)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
static struct rule * rules