@@ -65,7 +65,7 @@ typedef enum ParseExprKind
65
65
EXPR_KIND_EXECUTE_PARAMETER , /* parameter value in EXECUTE */
66
66
EXPR_KIND_TRIGGER_WHEN , /* WHEN condition in CREATE TRIGGER */
67
67
EXPR_KIND_POLICY , /* USING or WITH CHECK expr in policy */
68
- EXPR_KIND_PARTITION_EXPRESSION /* PARTITION BY expression */
68
+ EXPR_KIND_PARTITION_EXPRESSION /* PARTITION BY expression */
69
69
} ParseExprKind ;
70
70
71
71
@@ -123,11 +123,42 @@ typedef Node *(*CoerceParamHook) (ParseState *pstate, Param *param,
123
123
* p_parent_cte: CommonTableExpr that immediately contains the current query,
124
124
* if any.
125
125
*
126
+ * p_target_relation: target relation, if query is INSERT, UPDATE, or DELETE.
127
+ *
128
+ * p_target_rangetblentry: target relation's entry in the rtable list.
129
+ *
130
+ * p_is_insert: true to process assignment expressions like INSERT, false
131
+ * to process them like UPDATE. (Note this can change intra-statement, for
132
+ * cases like INSERT ON CONFLICT UPDATE.)
133
+ *
126
134
* p_windowdefs: list of WindowDefs representing WINDOW and OVER clauses.
127
135
* We collect these while transforming expressions and then transform them
128
136
* afterwards (so that any resjunk tlist items needed for the sort/group
129
137
* clauses end up at the end of the query tlist). A WindowDef's location in
130
138
* this list, counting from 1, is the winref number to use to reference it.
139
+ *
140
+ * p_expr_kind: kind of expression we're currently parsing, as per enum above;
141
+ * EXPR_KIND_NONE when not in an expression.
142
+ *
143
+ * p_next_resno: next TargetEntry.resno to assign, starting from 1.
144
+ *
145
+ * p_multiassign_exprs: partially-processed MultiAssignRef source expressions.
146
+ *
147
+ * p_locking_clause: query's FOR UPDATE/FOR SHARE clause, if any.
148
+ *
149
+ * p_locked_from_parent: true if parent query level applies FOR UPDATE/SHARE
150
+ * to this subquery as a whole.
151
+ *
152
+ * p_value_substitute: replacement for VALUE references, if we're parsing
153
+ * a domain CHECK constraint.
154
+ *
155
+ * p_hasAggs, p_hasWindowFuncs, etc: true if we've found any of the indicated
156
+ * constructs in the query.
157
+ *
158
+ * p_pre_columnref_hook, etc: optional parser hook functions for modifying the
159
+ * interpretation of ColumnRefs and ParamRefs.
160
+ *
161
+ * p_ref_hook_state: passthrough state for the parser hook functions.
131
162
*/
132
163
struct ParseState
133
164
{
@@ -143,21 +174,24 @@ struct ParseState
143
174
List * p_ctenamespace ; /* current namespace for common table exprs */
144
175
List * p_future_ctes ; /* common table exprs not yet in namespace */
145
176
CommonTableExpr * p_parent_cte ; /* this query's containing CTE */
177
+ Relation p_target_relation ; /* INSERT/UPDATE/DELETE target rel */
178
+ RangeTblEntry * p_target_rangetblentry ; /* target rel's RTE */
179
+ bool p_is_insert ; /* process assignment like INSERT not UPDATE */
146
180
List * p_windowdefs ; /* raw representations of window clauses */
147
181
ParseExprKind p_expr_kind ; /* what kind of expression we're parsing */
148
182
int p_next_resno ; /* next targetlist resno to assign */
149
183
List * p_multiassign_exprs ; /* junk tlist entries for multiassign */
150
184
List * p_locking_clause ; /* raw FOR UPDATE/FOR SHARE info */
185
+ bool p_locked_from_parent ; /* parent has marked this subquery
186
+ * with FOR UPDATE/FOR SHARE */
151
187
Node * p_value_substitute ; /* what to replace VALUE with, if any */
188
+
189
+ /* Flags telling about things found in the query: */
152
190
bool p_hasAggs ;
153
191
bool p_hasWindowFuncs ;
154
192
bool p_hasTargetSRFs ;
155
193
bool p_hasSubLinks ;
156
194
bool p_hasModifyingCTE ;
157
- bool p_is_insert ;
158
- bool p_locked_from_parent ;
159
- Relation p_target_relation ;
160
- RangeTblEntry * p_target_rangetblentry ;
161
195
162
196
/*
163
197
* Optional hook functions for parser callbacks. These are null unless
0 commit comments