PostgreSQL Source Code
git master
parsenodes.h
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* parsenodes.h
4
* definitions for parse tree nodes
5
*
6
* Many of the node types used in parsetrees include a "location" field.
7
* This is a byte (not character) offset in the original source text, to be
8
* used for positioning an error cursor when there is an error related to
9
* the node. Access to the original source text is needed to make use of
10
* the location. At the topmost (statement) level, we also provide a
11
* statement length, likewise measured in bytes, for convenience in
12
* identifying statement boundaries in multi-statement source strings.
13
*
14
*
15
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
16
* Portions Copyright (c) 1994, Regents of the University of California
17
*
18
* src/include/nodes/parsenodes.h
19
*
20
*-------------------------------------------------------------------------
21
*/
22
#ifndef PARSENODES_H
23
#define PARSENODES_H
24
25
#include "
common/relpath.h
"
26
#include "
nodes/bitmapset.h
"
27
#include "
nodes/lockoptions.h
"
28
#include "
nodes/primnodes.h
"
29
#include "
nodes/value.h
"
30
#include "
partitioning/partdefs.h
"
31
32
33
/* Possible sources of a Query */
34
typedef
enum
QuerySource
35
{
36
QSRC_ORIGINAL
,
/* original parsetree (explicit query) */
37
QSRC_PARSER
,
/* added by parse analysis (now unused) */
38
QSRC_INSTEAD_RULE
,
/* added by unconditional INSTEAD rule */
39
QSRC_QUAL_INSTEAD_RULE
,
/* added by conditional INSTEAD rule */
40
QSRC_NON_INSTEAD_RULE
,
/* added by non-INSTEAD rule */
41
}
QuerySource
;
42
43
/* Sort ordering options for ORDER BY and CREATE INDEX */
44
typedef
enum
SortByDir
45
{
46
SORTBY_DEFAULT
,
47
SORTBY_ASC
,
48
SORTBY_DESC
,
49
SORTBY_USING
,
/* not allowed in CREATE INDEX ... */
50
}
SortByDir
;
51
52
typedef
enum
SortByNulls
53
{
54
SORTBY_NULLS_DEFAULT
,
55
SORTBY_NULLS_FIRST
,
56
SORTBY_NULLS_LAST
,
57
}
SortByNulls
;
58
59
/* Options for [ ALL | DISTINCT ] */
60
typedef
enum
SetQuantifier
61
{
62
SET_QUANTIFIER_DEFAULT
,
63
SET_QUANTIFIER_ALL
,
64
SET_QUANTIFIER_DISTINCT
,
65
}
SetQuantifier
;
66
67
/*
68
* Grantable rights are encoded so that we can OR them together in a bitmask.
69
* The present representation of AclItem limits us to 32 distinct rights,
70
* even though AclMode is defined as uint64. See utils/acl.h.
71
*
72
* Caution: changing these codes breaks stored ACLs, hence forces initdb.
73
*/
74
typedef
uint64
AclMode
;
/* a bitmask of privilege bits */
75
76
#define ACL_INSERT (1<<0)
/* for relations */
77
#define ACL_SELECT (1<<1)
78
#define ACL_UPDATE (1<<2)
79
#define ACL_DELETE (1<<3)
80
#define ACL_TRUNCATE (1<<4)
81
#define ACL_REFERENCES (1<<5)
82
#define ACL_TRIGGER (1<<6)
83
#define ACL_EXECUTE (1<<7)
/* for functions */
84
#define ACL_USAGE (1<<8)
/* for various object types */
85
#define ACL_CREATE (1<<9)
/* for namespaces and databases */
86
#define ACL_CREATE_TEMP (1<<10)
/* for databases */
87
#define ACL_CONNECT (1<<11)
/* for databases */
88
#define ACL_SET (1<<12)
/* for configuration parameters */
89
#define ACL_ALTER_SYSTEM (1<<13)
/* for configuration parameters */
90
#define ACL_MAINTAIN (1<<14)
/* for relations */
91
#define N_ACL_RIGHTS 15
/* 1 plus the last 1<<x */
92
#define ACL_NO_RIGHTS 0
93
/* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */
94
#define ACL_SELECT_FOR_UPDATE ACL_UPDATE
95
96
97
/*****************************************************************************
98
* Query Tree
99
*****************************************************************************/
100
101
/*
102
* Query -
103
* Parse analysis turns all statements into a Query tree
104
* for further processing by the rewriter and planner.
105
*
106
* Utility statements (i.e. non-optimizable statements) have the
107
* utilityStmt field set, and the rest of the Query is mostly dummy.
108
*
109
* Planning converts a Query tree into a Plan tree headed by a PlannedStmt
110
* node --- the Query structure is not used by the executor.
111
*
112
* All the fields ignored for the query jumbling are not semantically
113
* significant (such as alias names), as is ignored anything that can
114
* be deduced from child nodes (else we'd just be double-hashing that
115
* piece of information).
116
*/
117
typedef
struct
Query
118
{
119
NodeTag
type
;
120
121
CmdType
commandType
;
/* select|insert|update|delete|merge|utility */
122
123
/* where did I come from? */
124
QuerySource
querySource
pg_node_attr
(query_jumble_ignore);
125
126
/*
127
* query identifier (can be set by plugins); ignored for equal, as it
128
* might not be set; also not stored. This is the result of the query
129
* jumble, hence ignored.
130
*/
131
uint64
queryId
pg_node_attr
(equal_ignore, query_jumble_ignore, read_write_ignore, read_as(0));
132
133
/* do I set the command result tag? */
134
bool
canSetTag
pg_node_attr
(query_jumble_ignore);
135
136
Node
*
utilityStmt
;
/* non-null if commandType == CMD_UTILITY */
137
138
/*
139
* rtable index of target relation for INSERT/UPDATE/DELETE/MERGE; 0 for
140
* SELECT. This is ignored in the query jumble as unrelated to the
141
* compilation of the query ID.
142
*/
143
int
resultRelation
pg_node_attr
(query_jumble_ignore);
144
145
/* has aggregates in tlist or havingQual */
146
bool
hasAggs
pg_node_attr
(query_jumble_ignore);
147
/* has window functions in tlist */
148
bool
hasWindowFuncs
pg_node_attr
(query_jumble_ignore);
149
/* has set-returning functions in tlist */
150
bool
hasTargetSRFs
pg_node_attr
(query_jumble_ignore);
151
/* has subquery SubLink */
152
bool
hasSubLinks
pg_node_attr
(query_jumble_ignore);
153
/* distinctClause is from DISTINCT ON */
154
bool
hasDistinctOn
pg_node_attr
(query_jumble_ignore);
155
/* WITH RECURSIVE was specified */
156
bool
hasRecursive
pg_node_attr
(query_jumble_ignore);
157
/* has INSERT/UPDATE/DELETE/MERGE in WITH */
158
bool
hasModifyingCTE
pg_node_attr
(query_jumble_ignore);
159
/* FOR [KEY] UPDATE/SHARE was specified */
160
bool
hasForUpdate
pg_node_attr
(query_jumble_ignore);
161
/* rewriter has applied some RLS policy */
162
bool
hasRowSecurity
pg_node_attr
(query_jumble_ignore);
163
/* parser has added an RTE_GROUP RTE */
164
bool
hasGroupRTE
pg_node_attr
(query_jumble_ignore);
165
/* is a RETURN statement */
166
bool
isReturn
pg_node_attr
(query_jumble_ignore);
167
168
List
*
cteList
;
/* WITH list (of CommonTableExpr's) */
169
170
List
*
rtable
;
/* list of range table entries */
171
172
/*
173
* list of RTEPermissionInfo nodes for the rtable entries having
174
* perminfoindex > 0
175
*/
176
List
*rteperminfos
pg_node_attr
(query_jumble_ignore);
177
FromExpr
*
jointree
;
/* table join tree (FROM and WHERE clauses);
178
* also USING clause for MERGE */
179
180
List
*
mergeActionList
;
/* list of actions for MERGE (only) */
181
182
/*
183
* rtable index of target relation for MERGE to pull data. Initially, this
184
* is the same as resultRelation, but after query rewriting, if the target
185
* relation is a trigger-updatable view, this is the index of the expanded
186
* view subquery, whereas resultRelation is the index of the target view.
187
*/
188
int
mergeTargetRelation
pg_node_attr
(query_jumble_ignore);
189
190
/* join condition between source and target for MERGE */
191
Node
*
mergeJoinCondition
;
192
193
List
*
targetList
;
/* target list (of TargetEntry) */
194
195
/* OVERRIDING clause */
196
OverridingKind
override
pg_node_attr
(query_jumble_ignore);
197
198
OnConflictExpr
*
onConflict
;
/* ON CONFLICT DO [NOTHING | UPDATE] */
199
200
/*
201
* The following three fields describe the contents of the RETURNING list
202
* for INSERT/UPDATE/DELETE/MERGE. returningOldAlias and returningNewAlias
203
* are the alias names for OLD and NEW, which may be user-supplied values,
204
* the defaults "old" and "new", or NULL (if the default "old"/"new" is
205
* already in use as the alias for some other relation).
206
*/
207
char
*returningOldAlias
pg_node_attr
(query_jumble_ignore);
208
char
*returningNewAlias
pg_node_attr
(query_jumble_ignore);
209
List
*
returningList
;
/* return-values list (of TargetEntry) */
210
211
List
*
groupClause
;
/* a list of SortGroupClause's */
212
bool
groupDistinct
;
/* is the group by clause distinct? */
213
214
List
*
groupingSets
;
/* a list of GroupingSet's if present */
215
216
Node
*
havingQual
;
/* qualifications applied to groups */
217
218
List
*
windowClause
;
/* a list of WindowClause's */
219
220
List
*
distinctClause
;
/* a list of SortGroupClause's */
221
222
List
*
sortClause
;
/* a list of SortGroupClause's */
223
224
Node
*
limitOffset
;
/* # of result tuples to skip (int8 expr) */
225
Node
*
limitCount
;
/* # of result tuples to return (int8 expr) */
226
LimitOption
limitOption
;
/* limit type */
227
228
List
*
rowMarks
;
/* a list of RowMarkClause's */
229
230
Node
*
setOperations
;
/* set-operation tree if this is top level of
231
* a UNION/INTERSECT/EXCEPT query */
232
233
/*
234
* A list of pg_constraint OIDs that the query depends on to be
235
* semantically valid
236
*/
237
List
*constraintDeps
pg_node_attr
(query_jumble_ignore);
238
239
/* a list of WithCheckOption's (added during rewrite) */
240
List
*withCheckOptions
pg_node_attr
(query_jumble_ignore);
241
242
/*
243
* The following two fields identify the portion of the source text string
244
* containing this query. They are typically only populated in top-level
245
* Queries, not in sub-queries. When not set, they might both be zero, or
246
* both be -1 meaning "unknown".
247
*/
248
/* start location, or -1 if unknown */
249
ParseLoc
stmt_location
;
250
/* length in bytes; 0 means "rest of string" */
251
ParseLoc
stmt_len
pg_node_attr
(query_jumble_ignore);
252
}
Query
;
253
254
255
/****************************************************************************
256
* Supporting data structures for Parse Trees
257
*
258
* Most of these node types appear in raw parsetrees output by the grammar,
259
* and get transformed to something else by the analyzer. A few of them
260
* are used as-is in transformed querytrees.
261
****************************************************************************/
262
263
/*
264
* TypeName - specifies a type in definitions
265
*
266
* For TypeName structures generated internally, it is often easier to
267
* specify the type by OID than by name. If "names" is NIL then the
268
* actual type OID is given by typeOid, otherwise typeOid is unused.
269
* Similarly, if "typmods" is NIL then the actual typmod is expected to
270
* be prespecified in typemod, otherwise typemod is unused.
271
*
272
* If pct_type is true, then names is actually a field name and we look up
273
* the type of that field. Otherwise (the normal case), names is a type
274
* name possibly qualified with schema and database name.
275
*/
276
typedef
struct
TypeName
277
{
278
NodeTag
type
;
279
List
*
names
;
/* qualified name (list of String nodes) */
280
Oid
typeOid
;
/* type identified by OID */
281
bool
setof
;
/* is a set? */
282
bool
pct_type
;
/* %TYPE specified? */
283
List
*
typmods
;
/* type modifier expression(s) */
284
int32
typemod
;
/* prespecified type modifier */
285
List
*
arrayBounds
;
/* array bounds */
286
ParseLoc
location
;
/* token location, or -1 if unknown */
287
}
TypeName
;
288
289
/*
290
* ColumnRef - specifies a reference to a column, or possibly a whole tuple
291
*
292
* The "fields" list must be nonempty. It can contain String nodes
293
* (representing names) and A_Star nodes (representing occurrence of a '*').
294
* Currently, A_Star must appear only as the last list element --- the grammar
295
* is responsible for enforcing this!
296
*
297
* Note: any container subscripting or selection of fields from composite columns
298
* is represented by an A_Indirection node above the ColumnRef. However,
299
* for simplicity in the normal case, initial field selection from a table
300
* name is represented within ColumnRef and not by adding A_Indirection.
301
*/
302
typedef
struct
ColumnRef
303
{
304
NodeTag
type
;
305
List
*
fields
;
/* field names (String nodes) or A_Star */
306
ParseLoc
location
;
/* token location, or -1 if unknown */
307
}
ColumnRef
;
308
309
/*
310
* ParamRef - specifies a $n parameter reference
311
*/
312
typedef
struct
ParamRef
313
{
314
NodeTag
type
;
315
int
number
;
/* the number of the parameter */
316
ParseLoc
location
;
/* token location, or -1 if unknown */
317
}
ParamRef
;
318
319
/*
320
* A_Expr - infix, prefix, and postfix expressions
321
*/
322
typedef
enum
A_Expr_Kind
323
{
324
AEXPR_OP
,
/* normal operator */
325
AEXPR_OP_ANY
,
/* scalar op ANY (array) */
326
AEXPR_OP_ALL
,
/* scalar op ALL (array) */
327
AEXPR_DISTINCT
,
/* IS DISTINCT FROM - name must be "=" */
328
AEXPR_NOT_DISTINCT
,
/* IS NOT DISTINCT FROM - name must be "=" */
329
AEXPR_NULLIF
,
/* NULLIF - name must be "=" */
330
AEXPR_IN
,
/* [NOT] IN - name must be "=" or "<>" */
331
AEXPR_LIKE
,
/* [NOT] LIKE - name must be "~~" or "!~~" */
332
AEXPR_ILIKE
,
/* [NOT] ILIKE - name must be "~~*" or "!~~*" */
333
AEXPR_SIMILAR
,
/* [NOT] SIMILAR - name must be "~" or "!~" */
334
AEXPR_BETWEEN
,
/* name must be "BETWEEN" */
335
AEXPR_NOT_BETWEEN
,
/* name must be "NOT BETWEEN" */
336
AEXPR_BETWEEN_SYM
,
/* name must be "BETWEEN SYMMETRIC" */
337
AEXPR_NOT_BETWEEN_SYM
,
/* name must be "NOT BETWEEN SYMMETRIC" */
338
}
A_Expr_Kind
;
339
340
typedef
struct
A_Expr
341
{
342
pg_node_attr
(custom_read_write)
343
344
NodeTag
type
;
345
A_Expr_Kind
kind
;
/* see above */
346
List
*
name
;
/* possibly-qualified name of operator */
347
Node
*
lexpr
;
/* left argument, or NULL if none */
348
Node
*
rexpr
;
/* right argument, or NULL if none */
349
ParseLoc
location
;
/* token location, or -1 if unknown */
350
}
A_Expr
;
351
352
/*
353
* A_Const - a literal constant
354
*
355
* Value nodes are inline for performance. You can treat 'val' as a node,
356
* as in IsA(&val, Integer). 'val' is not valid if isnull is true.
357
*/
358
union
ValUnion
359
{
360
Node
node
;
361
Integer
ival
;
362
Float
fval
;
363
Boolean
boolval
;
364
String
sval
;
365
BitString
bsval
;
366
};
367
368
typedef
struct
A_Const
369
{
370
pg_node_attr
(custom_copy_equal, custom_read_write, custom_query_jumble)
371
372
NodeTag
type
;
373
union
ValUnion
val
;
374
bool
isnull
;
/* SQL NULL constant */
375
ParseLoc
location
;
/* token location, or -1 if unknown */
376
}
A_Const
;
377
378
/*
379
* TypeCast - a CAST expression
380
*/
381
typedef
struct
TypeCast
382
{
383
NodeTag
type
;
384
Node
*
arg
;
/* the expression being casted */
385
TypeName
*
typeName
;
/* the target type */
386
ParseLoc
location
;
/* token location, or -1 if unknown */
387
}
TypeCast
;
388
389
/*
390
* CollateClause - a COLLATE expression
391
*/
392
typedef
struct
CollateClause
393
{
394
NodeTag
type
;
395
Node
*
arg
;
/* input expression */
396
List
*
collname
;
/* possibly-qualified collation name */
397
ParseLoc
location
;
/* token location, or -1 if unknown */
398
}
CollateClause
;
399
400
/*
401
* RoleSpec - a role name or one of a few special values.
402
*/
403
typedef
enum
RoleSpecType
404
{
405
ROLESPEC_CSTRING
,
/* role name is stored as a C string */
406
ROLESPEC_CURRENT_ROLE
,
/* role spec is CURRENT_ROLE */
407
ROLESPEC_CURRENT_USER
,
/* role spec is CURRENT_USER */
408
ROLESPEC_SESSION_USER
,
/* role spec is SESSION_USER */
409
ROLESPEC_PUBLIC
,
/* role name is "public" */
410
}
RoleSpecType
;
411
412
typedef
struct
RoleSpec
413
{
414
NodeTag
type
;
415
RoleSpecType
roletype
;
/* Type of this rolespec */
416
char
*
rolename
;
/* filled only for ROLESPEC_CSTRING */
417
ParseLoc
location
;
/* token location, or -1 if unknown */
418
}
RoleSpec
;
419
420
/*
421
* FuncCall - a function or aggregate invocation
422
*
423
* agg_order (if not NIL) indicates we saw 'foo(... ORDER BY ...)', or if
424
* agg_within_group is true, it was 'foo(...) WITHIN GROUP (ORDER BY ...)'.
425
* agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
426
* indicates we saw 'foo(DISTINCT ...)'. In any of these cases, the
427
* construct *must* be an aggregate call. Otherwise, it might be either an
428
* aggregate or some other kind of function. However, if FILTER or OVER is
429
* present it had better be an aggregate or window function.
430
*
431
* Normally, you'd initialize this via makeFuncCall() and then only change the
432
* parts of the struct its defaults don't match afterwards, as needed.
433
*/
434
typedef
struct
FuncCall
435
{
436
NodeTag
type
;
437
List
*
funcname
;
/* qualified name of function */
438
List
*
args
;
/* the arguments (list of exprs) */
439
List
*
agg_order
;
/* ORDER BY (list of SortBy) */
440
Node
*
agg_filter
;
/* FILTER clause, if any */
441
struct
WindowDef
*
over
;
/* OVER clause, if any */
442
bool
agg_within_group
;
/* ORDER BY appeared in WITHIN GROUP */
443
bool
agg_star
;
/* argument was really '*' */
444
bool
agg_distinct
;
/* arguments were labeled DISTINCT */
445
bool
func_variadic
;
/* last argument was labeled VARIADIC */
446
CoercionForm
funcformat
;
/* how to display this node */
447
ParseLoc
location
;
/* token location, or -1 if unknown */
448
}
FuncCall
;
449
450
/*
451
* A_Star - '*' representing all columns of a table or compound field
452
*
453
* This can appear within ColumnRef.fields, A_Indirection.indirection, and
454
* ResTarget.indirection lists.
455
*/
456
typedef
struct
A_Star
457
{
458
NodeTag
type
;
459
}
A_Star
;
460
461
/*
462
* A_Indices - array subscript or slice bounds ([idx] or [lidx:uidx])
463
*
464
* In slice case, either or both of lidx and uidx can be NULL (omitted).
465
* In non-slice case, uidx holds the single subscript and lidx is always NULL.
466
*/
467
typedef
struct
A_Indices
468
{
469
NodeTag
type
;
470
bool
is_slice
;
/* true if slice (i.e., colon present) */
471
Node
*
lidx
;
/* slice lower bound, if any */
472
Node
*
uidx
;
/* subscript, or slice upper bound if any */
473
}
A_Indices
;
474
475
/*
476
* A_Indirection - select a field and/or array element from an expression
477
*
478
* The indirection list can contain A_Indices nodes (representing
479
* subscripting), String nodes (representing field selection --- the
480
* string value is the name of the field to select), and A_Star nodes
481
* (representing selection of all fields of a composite type).
482
* For example, a complex selection operation like
483
* (foo).field1[42][7].field2
484
* would be represented with a single A_Indirection node having a 4-element
485
* indirection list.
486
*
487
* Currently, A_Star must appear only as the last list element --- the grammar
488
* is responsible for enforcing this!
489
*/
490
typedef
struct
A_Indirection
491
{
492
NodeTag
type
;
493
Node
*
arg
;
/* the thing being selected from */
494
List
*
indirection
;
/* subscripts and/or field names and/or * */
495
}
A_Indirection
;
496
497
/*
498
* A_ArrayExpr - an ARRAY[] construct
499
*/
500
typedef
struct
A_ArrayExpr
501
{
502
NodeTag
type
;
503
List
*
elements
;
/* array element expressions */
504
ParseLoc
location
;
/* token location, or -1 if unknown */
505
}
A_ArrayExpr
;
506
507
/*
508
* ResTarget -
509
* result target (used in target list of pre-transformed parse trees)
510
*
511
* In a SELECT target list, 'name' is the column label from an
512
* 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
513
* value expression itself. The 'indirection' field is not used.
514
*
515
* INSERT uses ResTarget in its target-column-names list. Here, 'name' is
516
* the name of the destination column, 'indirection' stores any subscripts
517
* attached to the destination, and 'val' is not used.
518
*
519
* In an UPDATE target list, 'name' is the name of the destination column,
520
* 'indirection' stores any subscripts attached to the destination, and
521
* 'val' is the expression to assign.
522
*
523
* See A_Indirection for more info about what can appear in 'indirection'.
524
*/
525
typedef
struct
ResTarget
526
{
527
NodeTag
type
;
528
char
*
name
;
/* column name or NULL */
529
List
*
indirection
;
/* subscripts, field names, and '*', or NIL */
530
Node
*
val
;
/* the value expression to compute or assign */
531
ParseLoc
location
;
/* token location, or -1 if unknown */
532
}
ResTarget
;
533
534
/*
535
* MultiAssignRef - element of a row source expression for UPDATE
536
*
537
* In an UPDATE target list, when we have SET (a,b,c) = row-valued-expression,
538
* we generate separate ResTarget items for each of a,b,c. Their "val" trees
539
* are MultiAssignRef nodes numbered 1..n, linking to a common copy of the
540
* row-valued-expression (which parse analysis will process only once, when
541
* handling the MultiAssignRef with colno=1).
542
*/
543
typedef
struct
MultiAssignRef
544
{
545
NodeTag
type
;
546
Node
*
source
;
/* the row-valued expression */
547
int
colno
;
/* column number for this target (1..n) */
548
int
ncolumns
;
/* number of targets in the construct */
549
}
MultiAssignRef
;
550
551
/*
552
* SortBy - for ORDER BY clause
553
*/
554
typedef
struct
SortBy
555
{
556
NodeTag
type
;
557
Node
*
node
;
/* expression to sort on */
558
SortByDir
sortby_dir
;
/* ASC/DESC/USING/default */
559
SortByNulls
sortby_nulls
;
/* NULLS FIRST/LAST */
560
List
*
useOp
;
/* name of op to use, if SORTBY_USING */
561
ParseLoc
location
;
/* operator location, or -1 if none/unknown */
562
}
SortBy
;
563
564
/*
565
* WindowDef - raw representation of WINDOW and OVER clauses
566
*
567
* For entries in a WINDOW list, "name" is the window name being defined.
568
* For OVER clauses, we use "name" for the "OVER window" syntax, or "refname"
569
* for the "OVER (window)" syntax, which is subtly different --- the latter
570
* implies overriding the window frame clause.
571
*/
572
typedef
struct
WindowDef
573
{
574
NodeTag
type
;
575
char
*
name
;
/* window's own name */
576
char
*
refname
;
/* referenced window name, if any */
577
List
*
partitionClause
;
/* PARTITION BY expression list */
578
List
*
orderClause
;
/* ORDER BY (list of SortBy) */
579
int
frameOptions
;
/* frame_clause options, see below */
580
Node
*
startOffset
;
/* expression for starting bound, if any */
581
Node
*
endOffset
;
/* expression for ending bound, if any */
582
ParseLoc
location
;
/* parse location, or -1 if none/unknown */
583
}
WindowDef
;
584
585
/*
586
* frameOptions is an OR of these bits. The NONDEFAULT and BETWEEN bits are
587
* used so that ruleutils.c can tell which properties were specified and
588
* which were defaulted; the correct behavioral bits must be set either way.
589
* The START_foo and END_foo options must come in pairs of adjacent bits for
590
* the convenience of gram.y, even though some of them are useless/invalid.
591
*/
592
#define FRAMEOPTION_NONDEFAULT 0x00001
/* any specified? */
593
#define FRAMEOPTION_RANGE 0x00002
/* RANGE behavior */
594
#define FRAMEOPTION_ROWS 0x00004
/* ROWS behavior */
595
#define FRAMEOPTION_GROUPS 0x00008
/* GROUPS behavior */
596
#define FRAMEOPTION_BETWEEN 0x00010
/* BETWEEN given? */
597
#define FRAMEOPTION_START_UNBOUNDED_PRECEDING 0x00020
/* start is U. P. */
598
#define FRAMEOPTION_END_UNBOUNDED_PRECEDING 0x00040
/* (disallowed) */
599
#define FRAMEOPTION_START_UNBOUNDED_FOLLOWING 0x00080
/* (disallowed) */
600
#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING 0x00100
/* end is U. F. */
601
#define FRAMEOPTION_START_CURRENT_ROW 0x00200
/* start is C. R. */
602
#define FRAMEOPTION_END_CURRENT_ROW 0x00400
/* end is C. R. */
603
#define FRAMEOPTION_START_OFFSET_PRECEDING 0x00800
/* start is O. P. */
604
#define FRAMEOPTION_END_OFFSET_PRECEDING 0x01000
/* end is O. P. */
605
#define FRAMEOPTION_START_OFFSET_FOLLOWING 0x02000
/* start is O. F. */
606
#define FRAMEOPTION_END_OFFSET_FOLLOWING 0x04000
/* end is O. F. */
607
#define FRAMEOPTION_EXCLUDE_CURRENT_ROW 0x08000
/* omit C.R. */
608
#define FRAMEOPTION_EXCLUDE_GROUP 0x10000
/* omit C.R. & peers */
609
#define FRAMEOPTION_EXCLUDE_TIES 0x20000
/* omit C.R.'s peers */
610
611
#define FRAMEOPTION_START_OFFSET \
612
(FRAMEOPTION_START_OFFSET_PRECEDING | FRAMEOPTION_START_OFFSET_FOLLOWING)
613
#define FRAMEOPTION_END_OFFSET \
614
(FRAMEOPTION_END_OFFSET_PRECEDING | FRAMEOPTION_END_OFFSET_FOLLOWING)
615
#define FRAMEOPTION_EXCLUSION \
616
(FRAMEOPTION_EXCLUDE_CURRENT_ROW | FRAMEOPTION_EXCLUDE_GROUP | \
617
FRAMEOPTION_EXCLUDE_TIES)
618
619
#define FRAMEOPTION_DEFAULTS \
620
(FRAMEOPTION_RANGE | FRAMEOPTION_START_UNBOUNDED_PRECEDING | \
621
FRAMEOPTION_END_CURRENT_ROW)
622
623
/*
624
* RangeSubselect - subquery appearing in a FROM clause
625
*/
626
typedef
struct
RangeSubselect
627
{
628
NodeTag
type
;
629
bool
lateral
;
/* does it have LATERAL prefix? */
630
Node
*
subquery
;
/* the untransformed sub-select clause */
631
Alias
*
alias
;
/* table alias & optional column aliases */
632
}
RangeSubselect
;
633
634
/*
635
* RangeFunction - function call appearing in a FROM clause
636
*
637
* functions is a List because we use this to represent the construct
638
* ROWS FROM(func1(...), func2(...), ...). Each element of this list is a
639
* two-element sublist, the first element being the untransformed function
640
* call tree, and the second element being a possibly-empty list of ColumnDef
641
* nodes representing any columndef list attached to that function within the
642
* ROWS FROM() syntax.
643
*
644
* alias and coldeflist represent any alias and/or columndef list attached
645
* at the top level. (We disallow coldeflist appearing both here and
646
* per-function, but that's checked in parse analysis, not by the grammar.)
647
*/
648
typedef
struct
RangeFunction
649
{
650
NodeTag
type
;
651
bool
lateral
;
/* does it have LATERAL prefix? */
652
bool
ordinality
;
/* does it have WITH ORDINALITY suffix? */
653
bool
is_rowsfrom
;
/* is result of ROWS FROM() syntax? */
654
List
*
functions
;
/* per-function information, see above */
655
Alias
*
alias
;
/* table alias & optional column aliases */
656
List
*
coldeflist
;
/* list of ColumnDef nodes to describe result
657
* of function returning RECORD */
658
}
RangeFunction
;
659
660
/*
661
* RangeTableFunc - raw form of "table functions" such as XMLTABLE
662
*
663
* Note: JSON_TABLE is also a "table function", but it uses JsonTable node,
664
* not RangeTableFunc.
665
*/
666
typedef
struct
RangeTableFunc
667
{
668
NodeTag
type
;
669
bool
lateral
;
/* does it have LATERAL prefix? */
670
Node
*
docexpr
;
/* document expression */
671
Node
*
rowexpr
;
/* row generator expression */
672
List
*
namespaces
;
/* list of namespaces as ResTarget */
673
List
*
columns
;
/* list of RangeTableFuncCol */
674
Alias
*
alias
;
/* table alias & optional column aliases */
675
ParseLoc
location
;
/* token location, or -1 if unknown */
676
}
RangeTableFunc
;
677
678
/*
679
* RangeTableFuncCol - one column in a RangeTableFunc->columns
680
*
681
* If for_ordinality is true (FOR ORDINALITY), then the column is an int4
682
* column and the rest of the fields are ignored.
683
*/
684
typedef
struct
RangeTableFuncCol
685
{
686
NodeTag
type
;
687
char
*
colname
;
/* name of generated column */
688
TypeName
*
typeName
;
/* type of generated column */
689
bool
for_ordinality
;
/* does it have FOR ORDINALITY? */
690
bool
is_not_null
;
/* does it have NOT NULL? */
691
Node
*
colexpr
;
/* column filter expression */
692
Node
*
coldefexpr
;
/* column default value expression */
693
ParseLoc
location
;
/* token location, or -1 if unknown */
694
}
RangeTableFuncCol
;
695
696
/*
697
* RangeTableSample - TABLESAMPLE appearing in a raw FROM clause
698
*
699
* This node, appearing only in raw parse trees, represents
700
* <relation> TABLESAMPLE <method> (<params>) REPEATABLE (<num>)
701
* Currently, the <relation> can only be a RangeVar, but we might in future
702
* allow RangeSubselect and other options. Note that the RangeTableSample
703
* is wrapped around the node representing the <relation>, rather than being
704
* a subfield of it.
705
*/
706
typedef
struct
RangeTableSample
707
{
708
NodeTag
type
;
709
Node
*
relation
;
/* relation to be sampled */
710
List
*
method
;
/* sampling method name (possibly qualified) */
711
List
*
args
;
/* argument(s) for sampling method */
712
Node
*
repeatable
;
/* REPEATABLE expression, or NULL if none */
713
ParseLoc
location
;
/* method name location, or -1 if unknown */
714
}
RangeTableSample
;
715
716
/*
717
* ColumnDef - column definition (used in various creates)
718
*
719
* If the column has a default value, we may have the value expression
720
* in either "raw" form (an untransformed parse tree) or "cooked" form
721
* (a post-parse-analysis, executable expression tree), depending on
722
* how this ColumnDef node was created (by parsing, or by inheritance
723
* from an existing relation). We should never have both in the same node!
724
*
725
* Similarly, we may have a COLLATE specification in either raw form
726
* (represented as a CollateClause with arg==NULL) or cooked form
727
* (the collation's OID).
728
*
729
* The constraints list may contain a CONSTR_DEFAULT item in a raw
730
* parsetree produced by gram.y, but transformCreateStmt will remove
731
* the item and set raw_default instead. CONSTR_DEFAULT items
732
* should not appear in any subsequent processing.
733
*/
734
typedef
struct
ColumnDef
735
{
736
NodeTag
type
;
737
char
*
colname
;
/* name of column */
738
TypeName
*
typeName
;
/* type of column */
739
char
*
compression
;
/* compression method for column */
740
int16
inhcount
;
/* number of times column is inherited */
741
bool
is_local
;
/* column has local (non-inherited) def'n */
742
bool
is_not_null
;
/* NOT NULL constraint specified? */
743
bool
is_from_type
;
/* column definition came from table type */
744
char
storage
;
/* attstorage setting, or 0 for default */
745
char
*
storage_name
;
/* attstorage setting name or NULL for default */
746
Node
*
raw_default
;
/* default value (untransformed parse tree) */
747
Node
*
cooked_default
;
/* default value (transformed expr tree) */
748
char
identity
;
/* attidentity setting */
749
RangeVar
*
identitySequence
;
/* to store identity sequence name for
750
* ALTER TABLE ... ADD COLUMN */
751
char
generated
;
/* attgenerated setting */
752
CollateClause
*
collClause
;
/* untransformed COLLATE spec, if any */
753
Oid
collOid
;
/* collation OID (InvalidOid if not set) */
754
List
*
constraints
;
/* other constraints on column */
755
List
*
fdwoptions
;
/* per-column FDW options */
756
ParseLoc
location
;
/* parse location, or -1 if none/unknown */
757
}
ColumnDef
;
758
759
/*
760
* TableLikeClause - CREATE TABLE ( ... LIKE ... ) clause
761
*/
762
typedef
struct
TableLikeClause
763
{
764
NodeTag
type
;
765
RangeVar
*
relation
;
766
bits32
options
;
/* OR of TableLikeOption flags */
767
Oid
relationOid
;
/* If table has been looked up, its OID */
768
}
TableLikeClause
;
769
770
typedef
enum
TableLikeOption
771
{
772
CREATE_TABLE_LIKE_COMMENTS
= 1 << 0,
773
CREATE_TABLE_LIKE_COMPRESSION
= 1 << 1,
774
CREATE_TABLE_LIKE_CONSTRAINTS
= 1 << 2,
775
CREATE_TABLE_LIKE_DEFAULTS
= 1 << 3,
776
CREATE_TABLE_LIKE_GENERATED
= 1 << 4,
777
CREATE_TABLE_LIKE_IDENTITY
= 1 << 5,
778
CREATE_TABLE_LIKE_INDEXES
= 1 << 6,
779
CREATE_TABLE_LIKE_STATISTICS
= 1 << 7,
780
CREATE_TABLE_LIKE_STORAGE
= 1 << 8,
781
CREATE_TABLE_LIKE_ALL
=
PG_INT32_MAX
782
}
TableLikeOption
;
783
784
/*
785
* IndexElem - index parameters (used in CREATE INDEX, and in ON CONFLICT)
786
*
787
* For a plain index attribute, 'name' is the name of the table column to
788
* index, and 'expr' is NULL. For an index expression, 'name' is NULL and
789
* 'expr' is the expression tree.
790
*/
791
typedef
struct
IndexElem
792
{
793
NodeTag
type
;
794
char
*
name
;
/* name of attribute to index, or NULL */
795
Node
*
expr
;
/* expression to index, or NULL */
796
char
*
indexcolname
;
/* name for index column; NULL = default */
797
List
*
collation
;
/* name of collation; NIL = default */
798
List
*
opclass
;
/* name of desired opclass; NIL = default */
799
List
*
opclassopts
;
/* opclass-specific options, or NIL */
800
SortByDir
ordering
;
/* ASC/DESC/default */
801
SortByNulls
nulls_ordering
;
/* FIRST/LAST/default */
802
}
IndexElem
;
803
804
/*
805
* DefElem - a generic "name = value" option definition
806
*
807
* In some contexts the name can be qualified. Also, certain SQL commands
808
* allow a SET/ADD/DROP action to be attached to option settings, so it's
809
* convenient to carry a field for that too. (Note: currently, it is our
810
* practice that the grammar allows namespace and action only in statements
811
* where they are relevant; C code can just ignore those fields in other
812
* statements.)
813
*/
814
typedef
enum
DefElemAction
815
{
816
DEFELEM_UNSPEC
,
/* no action given */
817
DEFELEM_SET
,
818
DEFELEM_ADD
,
819
DEFELEM_DROP
,
820
}
DefElemAction
;
821
822
typedef
struct
DefElem
823
{
824
NodeTag
type
;
825
char
*
defnamespace
;
/* NULL if unqualified name */
826
char
*
defname
;
827
Node
*
arg
;
/* typically Integer, Float, String, or
828
* TypeName */
829
DefElemAction
defaction
;
/* unspecified action, or SET/ADD/DROP */
830
ParseLoc
location
;
/* token location, or -1 if unknown */
831
}
DefElem
;
832
833
/*
834
* LockingClause - raw representation of FOR [NO KEY] UPDATE/[KEY] SHARE
835
* options
836
*
837
* Note: lockedRels == NIL means "all relations in query". Otherwise it
838
* is a list of RangeVar nodes. (We use RangeVar mainly because it carries
839
* a location field --- currently, parse analysis insists on unqualified
840
* names in LockingClause.)
841
*/
842
typedef
struct
LockingClause
843
{
844
NodeTag
type
;
845
List
*
lockedRels
;
/* FOR [KEY] UPDATE/SHARE relations */
846
LockClauseStrength
strength
;
847
LockWaitPolicy
waitPolicy
;
/* NOWAIT and SKIP LOCKED */
848
}
LockingClause
;
849
850
/*
851
* XMLSERIALIZE (in raw parse tree only)
852
*/
853
typedef
struct
XmlSerialize
854
{
855
NodeTag
type
;
856
XmlOptionType
xmloption
;
/* DOCUMENT or CONTENT */
857
Node
*
expr
;
858
TypeName
*
typeName
;
859
bool
indent
;
/* [NO] INDENT */
860
ParseLoc
location
;
/* token location, or -1 if unknown */
861
}
XmlSerialize
;
862
863
/* Partitioning related definitions */
864
865
/*
866
* PartitionElem - parse-time representation of a single partition key
867
*
868
* expr can be either a raw expression tree or a parse-analyzed expression.
869
* We don't store these on-disk, though.
870
*/
871
typedef
struct
PartitionElem
872
{
873
NodeTag
type
;
874
char
*
name
;
/* name of column to partition on, or NULL */
875
Node
*
expr
;
/* expression to partition on, or NULL */
876
List
*
collation
;
/* name of collation; NIL = default */
877
List
*
opclass
;
/* name of desired opclass; NIL = default */
878
ParseLoc
location
;
/* token location, or -1 if unknown */
879
}
PartitionElem
;
880
881
typedef
enum
PartitionStrategy
882
{
883
PARTITION_STRATEGY_LIST
=
'l'
,
884
PARTITION_STRATEGY_RANGE
=
'r'
,
885
PARTITION_STRATEGY_HASH
=
'h'
,
886
}
PartitionStrategy
;
887
888
/*
889
* PartitionSpec - parse-time representation of a partition key specification
890
*
891
* This represents the key space we will be partitioning on.
892
*/
893
typedef
struct
PartitionSpec
894
{
895
NodeTag
type
;
896
PartitionStrategy
strategy
;
897
List
*
partParams
;
/* List of PartitionElems */
898
ParseLoc
location
;
/* token location, or -1 if unknown */
899
}
PartitionSpec
;
900
901
/*
902
* PartitionBoundSpec - a partition bound specification
903
*
904
* This represents the portion of the partition key space assigned to a
905
* particular partition. These are stored on disk in pg_class.relpartbound.
906
*/
907
struct
PartitionBoundSpec
908
{
909
NodeTag
type
;
910
911
char
strategy
;
/* see PARTITION_STRATEGY codes above */
912
bool
is_default
;
/* is it a default partition bound? */
913
914
/* Partitioning info for HASH strategy: */
915
int
modulus
;
916
int
remainder
;
917
918
/* Partitioning info for LIST strategy: */
919
List
*
listdatums
;
/* List of Consts (or A_Consts in raw tree) */
920
921
/* Partitioning info for RANGE strategy: */
922
List
*
lowerdatums
;
/* List of PartitionRangeDatums */
923
List
*
upperdatums
;
/* List of PartitionRangeDatums */
924
925
ParseLoc
location
;
/* token location, or -1 if unknown */
926
};
927
928
/*
929
* PartitionRangeDatum - one of the values in a range partition bound
930
*
931
* This can be MINVALUE, MAXVALUE or a specific bounded value.
932
*/
933
typedef
enum
PartitionRangeDatumKind
934
{
935
PARTITION_RANGE_DATUM_MINVALUE
= -1,
/* less than any other value */
936
PARTITION_RANGE_DATUM_VALUE
= 0,
/* a specific (bounded) value */
937
PARTITION_RANGE_DATUM_MAXVALUE
= 1,
/* greater than any other value */
938
}
PartitionRangeDatumKind
;
939
940
typedef
struct
PartitionRangeDatum
941
{
942
NodeTag
type
;
943
944
PartitionRangeDatumKind
kind
;
945
Node
*
value
;
/* Const (or A_Const in raw tree), if kind is
946
* PARTITION_RANGE_DATUM_VALUE, else NULL */
947
948
ParseLoc
location
;
/* token location, or -1 if unknown */
949
}
PartitionRangeDatum
;
950
951
/*
952
* PartitionCmd - info for ALTER TABLE/INDEX ATTACH/DETACH PARTITION commands
953
*/
954
typedef
struct
PartitionCmd
955
{
956
NodeTag
type
;
957
RangeVar
*
name
;
/* name of partition to attach/detach */
958
PartitionBoundSpec
*
bound
;
/* FOR VALUES, if attaching */
959
bool
concurrent
;
960
}
PartitionCmd
;
961
962
/****************************************************************************
963
* Nodes for a Query tree
964
****************************************************************************/
965
966
/*--------------------
967
* RangeTblEntry -
968
* A range table is a List of RangeTblEntry nodes.
969
*
970
* A range table entry may represent a plain relation, a sub-select in
971
* FROM, or the result of a JOIN clause. (Only explicit JOIN syntax
972
* produces an RTE, not the implicit join resulting from multiple FROM
973
* items. This is because we only need the RTE to deal with SQL features
974
* like outer joins and join-output-column aliasing.) Other special
975
* RTE types also exist, as indicated by RTEKind.
976
*
977
* Note that we consider RTE_RELATION to cover anything that has a pg_class
978
* entry. relkind distinguishes the sub-cases.
979
*
980
* alias is an Alias node representing the AS alias-clause attached to the
981
* FROM expression, or NULL if no clause.
982
*
983
* eref is the table reference name and column reference names (either
984
* real or aliases). Note that system columns (OID etc) are not included
985
* in the column list.
986
* eref->aliasname is required to be present, and should generally be used
987
* to identify the RTE for error messages etc.
988
*
989
* In RELATION RTEs, the colnames in both alias and eref are indexed by
990
* physical attribute number; this means there must be colname entries for
991
* dropped columns. When building an RTE we insert empty strings ("") for
992
* dropped columns. Note however that a stored rule may have nonempty
993
* colnames for columns dropped since the rule was created (and for that
994
* matter the colnames might be out of date due to column renamings).
995
* The same comments apply to FUNCTION RTEs when a function's return type
996
* is a named composite type.
997
*
998
* In JOIN RTEs, the colnames in both alias and eref are one-to-one with
999
* joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
1000
* those columns are known to be dropped at parse time. Again, however,
1001
* a stored rule might contain entries for columns dropped since the rule
1002
* was created. (This is only possible for columns not actually referenced
1003
* in the rule.) When loading a stored rule, we replace the joinaliasvars
1004
* items for any such columns with null pointers. (We can't simply delete
1005
* them from the joinaliasvars list, because that would affect the attnums
1006
* of Vars referencing the rest of the list.)
1007
*
1008
* inFromCl marks those range variables that are listed in the FROM clause.
1009
* It's false for RTEs that are added to a query behind the scenes, such
1010
* as the NEW and OLD variables for a rule, or the subqueries of a UNION.
1011
* This flag is not used during parsing (except in transformLockingClause,
1012
* q.v.); the parser now uses a separate "namespace" data structure to
1013
* control visibility. But it is needed by ruleutils.c to determine
1014
* whether RTEs should be shown in decompiled queries.
1015
*
1016
* securityQuals is a list of security barrier quals (boolean expressions),
1017
* to be tested in the listed order before returning a row from the
1018
* relation. It is always NIL in parser output. Entries are added by the
1019
* rewriter to implement security-barrier views and/or row-level security.
1020
* Note that the planner turns each boolean expression into an implicitly
1021
* AND'ed sublist, as is its usual habit with qualification expressions.
1022
*--------------------
1023
*/
1024
typedef
enum
RTEKind
1025
{
1026
RTE_RELATION
,
/* ordinary relation reference */
1027
RTE_SUBQUERY
,
/* subquery in FROM */
1028
RTE_JOIN
,
/* join */
1029
RTE_FUNCTION
,
/* function in FROM */
1030
RTE_TABLEFUNC
,
/* TableFunc(.., column list) */
1031
RTE_VALUES
,
/* VALUES (<exprlist>), (<exprlist>), ... */
1032
RTE_CTE
,
/* common table expr (WITH list element) */
1033
RTE_NAMEDTUPLESTORE
,
/* tuplestore, e.g. for AFTER triggers */
1034
RTE_RESULT
,
/* RTE represents an empty FROM clause; such
1035
* RTEs are added by the planner, they're not
1036
* present during parsing or rewriting */
1037
RTE_GROUP
,
/* the grouping step */
1038
}
RTEKind
;
1039
1040
typedef
struct
RangeTblEntry
1041
{
1042
pg_node_attr
(custom_read_write)
1043
1044
NodeTag
type
;
1045
1046
/*
1047
* Fields valid in all RTEs:
1048
*
1049
* put alias + eref first to make dump more legible
1050
*/
1051
/* user-written alias clause, if any */
1052
Alias
*alias
pg_node_attr
(query_jumble_ignore);
1053
/* expanded reference names */
1054
Alias
*eref
pg_node_attr
(query_jumble_ignore);
1055
1056
RTEKind
rtekind
;
/* see above */
1057
1058
/*
1059
* Fields valid for a plain relation RTE (else zero):
1060
*
1061
* inh is true for relation references that should be expanded to include
1062
* inheritance children, if the rel has any. In the parser, this will
1063
* only be true for RTE_RELATION entries. The planner also uses this
1064
* field to mark RTE_SUBQUERY entries that contain UNION ALL queries that
1065
* it has flattened into pulled-up subqueries (creating a structure much
1066
* like the effects of inheritance).
1067
*
1068
* rellockmode is really LOCKMODE, but it's declared int to avoid having
1069
* to include lock-related headers here. It must be RowExclusiveLock if
1070
* the RTE is an INSERT/UPDATE/DELETE/MERGE target, else RowShareLock if
1071
* the RTE is a SELECT FOR UPDATE/FOR SHARE target, else AccessShareLock.
1072
*
1073
* Note: in some cases, rule expansion may result in RTEs that are marked
1074
* with RowExclusiveLock even though they are not the target of the
1075
* current query; this happens if a DO ALSO rule simply scans the original
1076
* target table. We leave such RTEs with their original lockmode so as to
1077
* avoid getting an additional, lesser lock.
1078
*
1079
* perminfoindex is 1-based index of the RTEPermissionInfo belonging to
1080
* this RTE in the containing struct's list of same; 0 if permissions need
1081
* not be checked for this RTE.
1082
*
1083
* As a special case, relid, relkind, rellockmode, and perminfoindex can
1084
* also be set (nonzero) in an RTE_SUBQUERY RTE. This occurs when we
1085
* convert an RTE_RELATION RTE naming a view into an RTE_SUBQUERY
1086
* containing the view's query. We still need to perform run-time locking
1087
* and permission checks on the view, even though it's not directly used
1088
* in the query anymore, and the most expedient way to do that is to
1089
* retain these fields from the old state of the RTE.
1090
*
1091
* As a special case, RTE_NAMEDTUPLESTORE can also set relid to indicate
1092
* that the tuple format of the tuplestore is the same as the referenced
1093
* relation. This allows plans referencing AFTER trigger transition
1094
* tables to be invalidated if the underlying table is altered.
1095
*/
1096
/* OID of the relation */
1097
Oid
relid
;
1098
/* inheritance requested? */
1099
bool
inh
;
1100
/* relation kind (see pg_class.relkind) */
1101
char
relkind
pg_node_attr
(query_jumble_ignore);
1102
/* lock level that query requires on the rel */
1103
int
rellockmode
pg_node_attr
(query_jumble_ignore);
1104
/* index of RTEPermissionInfo entry, or 0 */
1105
Index
perminfoindex
pg_node_attr
(query_jumble_ignore);
1106
/* sampling info, or NULL */
1107
struct
TableSampleClause
*
tablesample
;
1108
1109
/*
1110
* Fields valid for a subquery RTE (else NULL):
1111
*/
1112
/* the sub-query */
1113
Query
*
subquery
;
1114
/* is from security_barrier view? */
1115
bool
security_barrier
pg_node_attr
(query_jumble_ignore);
1116
1117
/*
1118
* Fields valid for a join RTE (else NULL/zero):
1119
*
1120
* joinaliasvars is a list of (usually) Vars corresponding to the columns
1121
* of the join result. An alias Var referencing column K of the join
1122
* result can be replaced by the K'th element of joinaliasvars --- but to
1123
* simplify the task of reverse-listing aliases correctly, we do not do
1124
* that until planning time. In detail: an element of joinaliasvars can
1125
* be a Var of one of the join's input relations, or such a Var with an
1126
* implicit coercion to the join's output column type, or a COALESCE
1127
* expression containing the two input column Vars (possibly coerced).
1128
* Elements beyond the first joinmergedcols entries are always just Vars,
1129
* and are never referenced from elsewhere in the query (that is, join
1130
* alias Vars are generated only for merged columns). We keep these
1131
* entries only because they're needed in expandRTE() and similar code.
1132
*
1133
* Vars appearing within joinaliasvars are marked with varnullingrels sets
1134
* that describe the nulling effects of this join and lower ones. This is
1135
* essential for FULL JOIN cases, because the COALESCE expression only
1136
* describes the semantics correctly if its inputs have been nulled by the
1137
* join. For other cases, it allows expandRTE() to generate a valid
1138
* representation of the join's output without consulting additional
1139
* parser state.
1140
*
1141
* Within a Query loaded from a stored rule, it is possible for non-merged
1142
* joinaliasvars items to be null pointers, which are placeholders for
1143
* (necessarily unreferenced) columns dropped since the rule was made.
1144
* Also, once planning begins, joinaliasvars items can be almost anything,
1145
* as a result of subquery-flattening substitutions.
1146
*
1147
* joinleftcols is an integer list of physical column numbers of the left
1148
* join input rel that are included in the join; likewise joinrighttcols
1149
* for the right join input rel. (Which rels those are can be determined
1150
* from the associated JoinExpr.) If the join is USING/NATURAL, then the
1151
* first joinmergedcols entries in each list identify the merged columns.
1152
* The merged columns come first in the join output, then remaining
1153
* columns of the left input, then remaining columns of the right.
1154
*
1155
* Note that input columns could have been dropped after creation of a
1156
* stored rule, if they are not referenced in the query (in particular,
1157
* merged columns could not be dropped); this is not accounted for in
1158
* joinleftcols/joinrighttcols.
1159
*/
1160
JoinType
jointype
;
1161
/* number of merged (JOIN USING) columns */
1162
int
joinmergedcols
pg_node_attr
(query_jumble_ignore);
1163
/* list of alias-var expansions */
1164
List
*joinaliasvars
pg_node_attr
(query_jumble_ignore);
1165
/* left-side input column numbers */
1166
List
*joinleftcols
pg_node_attr
(query_jumble_ignore);
1167
/* right-side input column numbers */
1168
List
*joinrightcols
pg_node_attr
(query_jumble_ignore);
1169
1170
/*
1171
* join_using_alias is an alias clause attached directly to JOIN/USING. It
1172
* is different from the alias field (below) in that it does not hide the
1173
* range variables of the tables being joined.
1174
*/
1175
Alias
*join_using_alias
pg_node_attr
(query_jumble_ignore);
1176
1177
/*
1178
* Fields valid for a function RTE (else NIL/zero):
1179
*
1180
* When funcordinality is true, the eref->colnames list includes an alias
1181
* for the ordinality column. The ordinality column is otherwise
1182
* implicit, and must be accounted for "by hand" in places such as
1183
* expandRTE().
1184
*/
1185
/* list of RangeTblFunction nodes */
1186
List
*
functions
;
1187
/* is this called WITH ORDINALITY? */
1188
bool
funcordinality
;
1189
1190
/*
1191
* Fields valid for a TableFunc RTE (else NULL):
1192
*/
1193
TableFunc
*
tablefunc
;
1194
1195
/*
1196
* Fields valid for a values RTE (else NIL):
1197
*/
1198
/* list of expression lists */
1199
List
*
values_lists
;
1200
1201
/*
1202
* Fields valid for a CTE RTE (else NULL/zero):
1203
*/
1204
/* name of the WITH list item */
1205
char
*
ctename
;
1206
/* number of query levels up */
1207
Index
ctelevelsup
;
1208
/* is this a recursive self-reference? */
1209
bool
self_reference
pg_node_attr
(query_jumble_ignore);
1210
1211
/*
1212
* Fields valid for CTE, VALUES, ENR, and TableFunc RTEs (else NIL):
1213
*
1214
* We need these for CTE RTEs so that the types of self-referential
1215
* columns are well-defined. For VALUES RTEs, storing these explicitly
1216
* saves having to re-determine the info by scanning the values_lists. For
1217
* ENRs, we store the types explicitly here (we could get the information
1218
* from the catalogs if 'relid' was supplied, but we'd still need these
1219
* for TupleDesc-based ENRs, so we might as well always store the type
1220
* info here). For TableFuncs, these fields are redundant with data in
1221
* the TableFunc node, but keeping them here allows some code sharing with
1222
* the other cases.
1223
*
1224
* For ENRs only, we have to consider the possibility of dropped columns.
1225
* A dropped column is included in these lists, but it will have zeroes in
1226
* all three lists (as well as an empty-string entry in eref). Testing
1227
* for zero coltype is the standard way to detect a dropped column.
1228
*/
1229
/* OID list of column type OIDs */
1230
List
*coltypes
pg_node_attr
(query_jumble_ignore);
1231
/* integer list of column typmods */
1232
List
*coltypmods
pg_node_attr
(query_jumble_ignore);
1233
/* OID list of column collation OIDs */
1234
List
*colcollations
pg_node_attr
(query_jumble_ignore);
1235
1236
/*
1237
* Fields valid for ENR RTEs (else NULL/zero):
1238
*/
1239
/* name of ephemeral named relation */
1240
char
*
enrname
;
1241
/* estimated or actual from caller */
1242
Cardinality
enrtuples
pg_node_attr
(query_jumble_ignore);
1243
1244
/*
1245
* Fields valid for a GROUP RTE (else NIL):
1246
*/
1247
/* list of grouping expressions */
1248
List
*groupexprs
pg_node_attr
(query_jumble_ignore);
1249
1250
/*
1251
* Fields valid in all RTEs:
1252
*/
1253
/* was LATERAL specified? */
1254
bool
lateral
pg_node_attr
(query_jumble_ignore);
1255
/* present in FROM clause? */
1256
bool
inFromCl
pg_node_attr
(query_jumble_ignore);
1257
/* security barrier quals to apply, if any */
1258
List
*securityQuals
pg_node_attr
(query_jumble_ignore);
1259
}
RangeTblEntry
;
1260
1261
/*
1262
* RTEPermissionInfo
1263
* Per-relation information for permission checking. Added to the Query
1264
* node by the parser when adding the corresponding RTE to the query
1265
* range table and subsequently editorialized on by the rewriter if
1266
* needed after rule expansion.
1267
*
1268
* Only the relations directly mentioned in the query are checked for
1269
* access permissions by the core executor, so only their RTEPermissionInfos
1270
* are present in the Query. However, extensions may want to check inheritance
1271
* children too, depending on the value of rte->inh, so it's copied in 'inh'
1272
* for their perusal.
1273
*
1274
* requiredPerms and checkAsUser specify run-time access permissions checks
1275
* to be performed at query startup. The user must have *all* of the
1276
* permissions that are OR'd together in requiredPerms (never 0!). If
1277
* checkAsUser is not zero, then do the permissions checks using the access
1278
* rights of that user, not the current effective user ID. (This allows rules
1279
* to act as setuid gateways.)
1280
*
1281
* For SELECT/INSERT/UPDATE permissions, if the user doesn't have table-wide
1282
* permissions then it is sufficient to have the permissions on all columns
1283
* identified in selectedCols (for SELECT) and/or insertedCols and/or
1284
* updatedCols (INSERT with ON CONFLICT DO UPDATE may have all 3).
1285
* selectedCols, insertedCols and updatedCols are bitmapsets, which cannot have
1286
* negative integer members, so we subtract FirstLowInvalidHeapAttributeNumber
1287
* from column numbers before storing them in these fields. A whole-row Var
1288
* reference is represented by setting the bit for InvalidAttrNumber.
1289
*
1290
* updatedCols is also used in some other places, for example, to determine
1291
* which triggers to fire and in FDWs to know which changed columns they need
1292
* to ship off.
1293
*/
1294
typedef
struct
RTEPermissionInfo
1295
{
1296
NodeTag
type
;
1297
1298
Oid
relid
;
/* relation OID */
1299
bool
inh
;
/* separately check inheritance children? */
1300
AclMode
requiredPerms
;
/* bitmask of required access permissions */
1301
Oid
checkAsUser
;
/* if valid, check access as this role */
1302
Bitmapset
*
selectedCols
;
/* columns needing SELECT permission */
1303
Bitmapset
*
insertedCols
;
/* columns needing INSERT permission */
1304
Bitmapset
*
updatedCols
;
/* columns needing UPDATE permission */
1305
}
RTEPermissionInfo
;
1306
1307
/*
1308
* RangeTblFunction -
1309
* RangeTblEntry subsidiary data for one function in a FUNCTION RTE.
1310
*
1311
* If the function had a column definition list (required for an
1312
* otherwise-unspecified RECORD result), funccolnames lists the names given
1313
* in the definition list, funccoltypes lists their declared column types,
1314
* funccoltypmods lists their typmods, funccolcollations their collations.
1315
* Otherwise, those fields are NIL.
1316
*
1317
* Notice we don't attempt to store info about the results of functions
1318
* returning named composite types, because those can change from time to
1319
* time. We do however remember how many columns we thought the type had
1320
* (including dropped columns!), so that we can successfully ignore any
1321
* columns added after the query was parsed.
1322
*
1323
* The query jumbling only needs to track the function expression.
1324
*/
1325
typedef
struct
RangeTblFunction
1326
{
1327
NodeTag
type
;
1328
1329
Node
*
funcexpr
;
/* expression tree for func call */
1330
/* number of columns it contributes to RTE */
1331
int
funccolcount
pg_node_attr
(query_jumble_ignore);
1332
/* These fields record the contents of a column definition list, if any: */
1333
/* column names (list of String) */
1334
List
*funccolnames
pg_node_attr
(query_jumble_ignore);
1335
/* OID list of column type OIDs */
1336
List
*funccoltypes
pg_node_attr
(query_jumble_ignore);
1337
/* integer list of column typmods */
1338
List
*funccoltypmods
pg_node_attr
(query_jumble_ignore);
1339
/* OID list of column collation OIDs */
1340
List
*funccolcollations
pg_node_attr
(query_jumble_ignore);
1341
1342
/* This is set during planning for use by the executor: */
1343
/* PARAM_EXEC Param IDs affecting this func */
1344
Bitmapset
*funcparams
pg_node_attr
(query_jumble_ignore);
1345
}
RangeTblFunction
;
1346
1347
/*
1348
* TableSampleClause - TABLESAMPLE appearing in a transformed FROM clause
1349
*
1350
* Unlike RangeTableSample, this is a subnode of the relevant RangeTblEntry.
1351
*/
1352
typedef
struct
TableSampleClause
1353
{
1354
NodeTag
type
;
1355
Oid
tsmhandler
;
/* OID of the tablesample handler function */
1356
List
*
args
;
/* tablesample argument expression(s) */
1357
Expr
*
repeatable
;
/* REPEATABLE expression, or NULL if none */
1358
}
TableSampleClause
;
1359
1360
/*
1361
* WithCheckOption -
1362
* representation of WITH CHECK OPTION checks to be applied to new tuples
1363
* when inserting/updating an auto-updatable view, or RLS WITH CHECK
1364
* policies to be applied when inserting/updating a relation with RLS.
1365
*/
1366
typedef
enum
WCOKind
1367
{
1368
WCO_VIEW_CHECK
,
/* WCO on an auto-updatable view */
1369
WCO_RLS_INSERT_CHECK
,
/* RLS INSERT WITH CHECK policy */
1370
WCO_RLS_UPDATE_CHECK
,
/* RLS UPDATE WITH CHECK policy */
1371
WCO_RLS_CONFLICT_CHECK
,
/* RLS ON CONFLICT DO UPDATE USING policy */
1372
WCO_RLS_MERGE_UPDATE_CHECK
,
/* RLS MERGE UPDATE USING policy */
1373
WCO_RLS_MERGE_DELETE_CHECK
,
/* RLS MERGE DELETE USING policy */
1374
}
WCOKind
;
1375
1376
typedef
struct
WithCheckOption
1377
{
1378
NodeTag
type
;
1379
WCOKind
kind
;
/* kind of WCO */
1380
char
*
relname
;
/* name of relation that specified the WCO */
1381
char
*
polname
;
/* name of RLS policy being checked */
1382
Node
*
qual
;
/* constraint qual to check */
1383
bool
cascaded
;
/* true for a cascaded WCO on a view */
1384
}
WithCheckOption
;
1385
1386
/*
1387
* SortGroupClause -
1388
* representation of ORDER BY, GROUP BY, PARTITION BY,
1389
* DISTINCT, DISTINCT ON items
1390
*
1391
* You might think that ORDER BY is only interested in defining ordering,
1392
* and GROUP/DISTINCT are only interested in defining equality. However,
1393
* one way to implement grouping is to sort and then apply a "uniq"-like
1394
* filter. So it's also interesting to keep track of possible sort operators
1395
* for GROUP/DISTINCT, and in particular to try to sort for the grouping
1396
* in a way that will also yield a requested ORDER BY ordering. So we need
1397
* to be able to compare ORDER BY and GROUP/DISTINCT lists, which motivates
1398
* the decision to give them the same representation.
1399
*
1400
* tleSortGroupRef must match ressortgroupref of exactly one entry of the
1401
* query's targetlist; that is the expression to be sorted or grouped by.
1402
* eqop is the OID of the equality operator.
1403
* sortop is the OID of the ordering operator (a "<" or ">" operator),
1404
* or InvalidOid if not available.
1405
* nulls_first means about what you'd expect. If sortop is InvalidOid
1406
* then nulls_first is meaningless and should be set to false.
1407
* hashable is true if eqop is hashable (note this condition also depends
1408
* on the datatype of the input expression).
1409
*
1410
* In an ORDER BY item, all fields must be valid. (The eqop isn't essential
1411
* here, but it's cheap to get it along with the sortop, and requiring it
1412
* to be valid eases comparisons to grouping items.) Note that this isn't
1413
* actually enough information to determine an ordering: if the sortop is
1414
* collation-sensitive, a collation OID is needed too. We don't store the
1415
* collation in SortGroupClause because it's not available at the time the
1416
* parser builds the SortGroupClause; instead, consult the exposed collation
1417
* of the referenced targetlist expression to find out what it is.
1418
*
1419
* In a grouping item, eqop must be valid. If the eqop is a btree equality
1420
* operator, then sortop should be set to a compatible ordering operator.
1421
* We prefer to set eqop/sortop/nulls_first to match any ORDER BY item that
1422
* the query presents for the same tlist item. If there is none, we just
1423
* use the default ordering op for the datatype.
1424
*
1425
* If the tlist item's type has a hash opclass but no btree opclass, then
1426
* we will set eqop to the hash equality operator, sortop to InvalidOid,
1427
* and nulls_first to false. A grouping item of this kind can only be
1428
* implemented by hashing, and of course it'll never match an ORDER BY item.
1429
*
1430
* The hashable flag is provided since we generally have the requisite
1431
* information readily available when the SortGroupClause is constructed,
1432
* and it's relatively expensive to get it again later. Note there is no
1433
* need for a "sortable" flag since OidIsValid(sortop) serves the purpose.
1434
*
1435
* A query might have both ORDER BY and DISTINCT (or DISTINCT ON) clauses.
1436
* In SELECT DISTINCT, the distinctClause list is as long or longer than the
1437
* sortClause list, while in SELECT DISTINCT ON it's typically shorter.
1438
* The two lists must match up to the end of the shorter one --- the parser
1439
* rearranges the distinctClause if necessary to make this true. (This
1440
* restriction ensures that only one sort step is needed to both satisfy the
1441
* ORDER BY and set up for the Unique step. This is semantically necessary
1442
* for DISTINCT ON, and presents no real drawback for DISTINCT.)
1443
*/
1444
typedef
struct
SortGroupClause
1445
{
1446
NodeTag
type
;
1447
Index
tleSortGroupRef
;
/* reference into targetlist */
1448
Oid
eqop
;
/* the equality operator ('=' op) */
1449
Oid
sortop
;
/* the ordering operator ('<' op), or 0 */
1450
bool
reverse_sort
;
/* is sortop a "greater than" operator? */
1451
bool
nulls_first
;
/* do NULLs come before normal values? */
1452
/* can eqop be implemented by hashing? */
1453
bool
hashable
pg_node_attr
(query_jumble_ignore);
1454
}
SortGroupClause
;
1455
1456
/*
1457
* GroupingSet -
1458
* representation of CUBE, ROLLUP and GROUPING SETS clauses
1459
*
1460
* In a Query with grouping sets, the groupClause contains a flat list of
1461
* SortGroupClause nodes for each distinct expression used. The actual
1462
* structure of the GROUP BY clause is given by the groupingSets tree.
1463
*
1464
* In the raw parser output, GroupingSet nodes (of all types except SIMPLE
1465
* which is not used) are potentially mixed in with the expressions in the
1466
* groupClause of the SelectStmt. (An expression can't contain a GroupingSet,
1467
* but a list may mix GroupingSet and expression nodes.) At this stage, the
1468
* content of each node is a list of expressions, some of which may be RowExprs
1469
* which represent sublists rather than actual row constructors, and nested
1470
* GroupingSet nodes where legal in the grammar. The structure directly
1471
* reflects the query syntax.
1472
*
1473
* In parse analysis, the transformed expressions are used to build the tlist
1474
* and groupClause list (of SortGroupClause nodes), and the groupingSets tree
1475
* is eventually reduced to a fixed format:
1476
*
1477
* EMPTY nodes represent (), and obviously have no content
1478
*
1479
* SIMPLE nodes represent a list of one or more expressions to be treated as an
1480
* atom by the enclosing structure; the content is an integer list of
1481
* ressortgroupref values (see SortGroupClause)
1482
*
1483
* CUBE and ROLLUP nodes contain a list of one or more SIMPLE nodes.
1484
*
1485
* SETS nodes contain a list of EMPTY, SIMPLE, CUBE or ROLLUP nodes, but after
1486
* parse analysis they cannot contain more SETS nodes; enough of the syntactic
1487
* transforms of the spec have been applied that we no longer have arbitrarily
1488
* deep nesting (though we still preserve the use of cube/rollup).
1489
*
1490
* Note that if the groupingSets tree contains no SIMPLE nodes (only EMPTY
1491
* nodes at the leaves), then the groupClause will be empty, but this is still
1492
* an aggregation query (similar to using aggs or HAVING without GROUP BY).
1493
*
1494
* As an example, the following clause:
1495
*
1496
* GROUP BY GROUPING SETS ((a,b), CUBE(c,(d,e)))
1497
*
1498
* looks like this after raw parsing:
1499
*
1500
* SETS( RowExpr(a,b) , CUBE( c, RowExpr(d,e) ) )
1501
*
1502
* and parse analysis converts it to:
1503
*
1504
* SETS( SIMPLE(1,2), CUBE( SIMPLE(3), SIMPLE(4,5) ) )
1505
*/
1506
typedef
enum
GroupingSetKind
1507
{
1508
GROUPING_SET_EMPTY
,
1509
GROUPING_SET_SIMPLE
,
1510
GROUPING_SET_ROLLUP
,
1511
GROUPING_SET_CUBE
,
1512
GROUPING_SET_SETS
,
1513
}
GroupingSetKind
;
1514
1515
typedef
struct
GroupingSet
1516
{
1517
NodeTag
type
;
1518
GroupingSetKind
kind
pg_node_attr
(query_jumble_ignore);
1519
List
*
content
;
1520
ParseLoc
location
;
1521
}
GroupingSet
;
1522
1523
/*
1524
* WindowClause -
1525
* transformed representation of WINDOW and OVER clauses
1526
*
1527
* A parsed Query's windowClause list contains these structs. "name" is set
1528
* if the clause originally came from WINDOW, and is NULL if it originally
1529
* was an OVER clause (but note that we collapse out duplicate OVERs).
1530
* partitionClause and orderClause are lists of SortGroupClause structs.
1531
* partitionClause is sanitized by the query planner to remove any columns or
1532
* expressions belonging to redundant PathKeys.
1533
* If we have RANGE with offset PRECEDING/FOLLOWING, the semantics of that are
1534
* specified by startInRangeFunc/inRangeColl/inRangeAsc/inRangeNullsFirst
1535
* for the start offset, or endInRangeFunc/inRange* for the end offset.
1536
* winref is an ID number referenced by WindowFunc nodes; it must be unique
1537
* among the members of a Query's windowClause list.
1538
* When refname isn't null, the partitionClause is always copied from there;
1539
* the orderClause might or might not be copied (see copiedOrder); the framing
1540
* options are never copied, per spec.
1541
*
1542
* The information relevant for the query jumbling is the partition clause
1543
* type and its bounds.
1544
*/
1545
typedef
struct
WindowClause
1546
{
1547
NodeTag
type
;
1548
/* window name (NULL in an OVER clause) */
1549
char
*
name
pg_node_attr
(query_jumble_ignore);
1550
/* referenced window name, if any */
1551
char
*refname
pg_node_attr
(query_jumble_ignore);
1552
List
*
partitionClause
;
/* PARTITION BY list */
1553
/* ORDER BY list */
1554
List
*
orderClause
;
1555
int
frameOptions
;
/* frame_clause options, see WindowDef */
1556
Node
*
startOffset
;
/* expression for starting bound, if any */
1557
Node
*
endOffset
;
/* expression for ending bound, if any */
1558
/* in_range function for startOffset */
1559
Oid
startInRangeFunc
pg_node_attr
(query_jumble_ignore);
1560
/* in_range function for endOffset */
1561
Oid
endInRangeFunc
pg_node_attr
(query_jumble_ignore);
1562
/* collation for in_range tests */
1563
Oid
inRangeColl
pg_node_attr
(query_jumble_ignore);
1564
/* use ASC sort order for in_range tests? */
1565
bool
inRangeAsc
pg_node_attr
(query_jumble_ignore);
1566
/* nulls sort first for in_range tests? */
1567
bool
inRangeNullsFirst
pg_node_attr
(query_jumble_ignore);
1568
Index
winref
;
/* ID referenced by window functions */
1569
/* did we copy orderClause from refname? */
1570
bool
copiedOrder
pg_node_attr
(query_jumble_ignore);
1571
}
WindowClause
;
1572
1573
/*
1574
* RowMarkClause -
1575
* parser output representation of FOR [KEY] UPDATE/SHARE clauses
1576
*
1577
* Query.rowMarks contains a separate RowMarkClause node for each relation
1578
* identified as a FOR [KEY] UPDATE/SHARE target. If one of these clauses
1579
* is applied to a subquery, we generate RowMarkClauses for all normal and
1580
* subquery rels in the subquery, but they are marked pushedDown = true to
1581
* distinguish them from clauses that were explicitly written at this query
1582
* level. Also, Query.hasForUpdate tells whether there were explicit FOR
1583
* UPDATE/SHARE/KEY SHARE clauses in the current query level.
1584
*/
1585
typedef
struct
RowMarkClause
1586
{
1587
NodeTag
type
;
1588
Index
rti
;
/* range table index of target relation */
1589
LockClauseStrength
strength
;
1590
LockWaitPolicy
waitPolicy
;
/* NOWAIT and SKIP LOCKED */
1591
bool
pushedDown
;
/* pushed down from higher query level? */
1592
}
RowMarkClause
;
1593
1594
/*
1595
* WithClause -
1596
* representation of WITH clause
1597
*
1598
* Note: WithClause does not propagate into the Query representation;
1599
* but CommonTableExpr does.
1600
*/
1601
typedef
struct
WithClause
1602
{
1603
NodeTag
type
;
1604
List
*
ctes
;
/* list of CommonTableExprs */
1605
bool
recursive
;
/* true = WITH RECURSIVE */
1606
ParseLoc
location
;
/* token location, or -1 if unknown */
1607
}
WithClause
;
1608
1609
/*
1610
* InferClause -
1611
* ON CONFLICT unique index inference clause
1612
*
1613
* Note: InferClause does not propagate into the Query representation.
1614
*/
1615
typedef
struct
InferClause
1616
{
1617
NodeTag
type
;
1618
List
*
indexElems
;
/* IndexElems to infer unique index */
1619
Node
*
whereClause
;
/* qualification (partial-index predicate) */
1620
char
*
conname
;
/* Constraint name, or NULL if unnamed */
1621
ParseLoc
location
;
/* token location, or -1 if unknown */
1622
}
InferClause
;
1623
1624
/*
1625
* OnConflictClause -
1626
* representation of ON CONFLICT clause
1627
*
1628
* Note: OnConflictClause does not propagate into the Query representation.
1629
*/
1630
typedef
struct
OnConflictClause
1631
{
1632
NodeTag
type
;
1633
OnConflictAction
action
;
/* DO NOTHING or UPDATE? */
1634
InferClause
*
infer
;
/* Optional index inference clause */
1635
List
*
targetList
;
/* the target list (of ResTarget) */
1636
Node
*
whereClause
;
/* qualifications */
1637
ParseLoc
location
;
/* token location, or -1 if unknown */
1638
}
OnConflictClause
;
1639
1640
/*
1641
* CommonTableExpr -
1642
* representation of WITH list element
1643
*/
1644
1645
typedef
enum
CTEMaterialize
1646
{
1647
CTEMaterializeDefault
,
/* no option specified */
1648
CTEMaterializeAlways
,
/* MATERIALIZED */
1649
CTEMaterializeNever
,
/* NOT MATERIALIZED */
1650
}
CTEMaterialize
;
1651
1652
typedef
struct
CTESearchClause
1653
{
1654
NodeTag
type
;
1655
List
*
search_col_list
;
1656
bool
search_breadth_first
;
1657
char
*
search_seq_column
;
1658
ParseLoc
location
;
1659
}
CTESearchClause
;
1660
1661
typedef
struct
CTECycleClause
1662
{
1663
NodeTag
type
;
1664
List
*
cycle_col_list
;
1665
char
*
cycle_mark_column
;
1666
Node
*
cycle_mark_value
;
1667
Node
*
cycle_mark_default
;
1668
char
*
cycle_path_column
;
1669
ParseLoc
location
;
1670
/* These fields are set during parse analysis: */
1671
Oid
cycle_mark_type
;
/* common type of _value and _default */
1672
int
cycle_mark_typmod
;
1673
Oid
cycle_mark_collation
;
1674
Oid
cycle_mark_neop
;
/* <> operator for type */
1675
}
CTECycleClause
;
1676
1677
typedef
struct
CommonTableExpr
1678
{
1679
NodeTag
type
;
1680
1681
/*
1682
* Query name (never qualified). The string name is included in the query
1683
* jumbling because RTE_CTE RTEs need it.
1684
*/
1685
char
*
ctename
;
1686
/* optional list of column names */
1687
List
*aliascolnames
pg_node_attr
(query_jumble_ignore);
1688
CTEMaterialize
ctematerialized
;
/* is this an optimization fence? */
1689
/* SelectStmt/InsertStmt/etc before parse analysis, Query afterwards: */
1690
Node
*
ctequery
;
/* the CTE's subquery */
1691
CTESearchClause
*search_clause
pg_node_attr
(query_jumble_ignore);
1692
CTECycleClause
*cycle_clause
pg_node_attr
(query_jumble_ignore);
1693
ParseLoc
location
;
/* token location, or -1 if unknown */
1694
/* These fields are set during parse analysis: */
1695
/* is this CTE actually recursive? */
1696
bool
cterecursive
pg_node_attr
(query_jumble_ignore);
1697
1698
/*
1699
* Number of RTEs referencing this CTE (excluding internal
1700
* self-references), irrelevant for query jumbling.
1701
*/
1702
int
cterefcount
pg_node_attr
(query_jumble_ignore);
1703
/* list of output column names */
1704
List
*ctecolnames
pg_node_attr
(query_jumble_ignore);
1705
/* OID list of output column type OIDs */
1706
List
*ctecoltypes
pg_node_attr
(query_jumble_ignore);
1707
/* integer list of output column typmods */
1708
List
*ctecoltypmods
pg_node_attr
(query_jumble_ignore);
1709
/* OID list of column collation OIDs */
1710
List
*ctecolcollations
pg_node_attr
(query_jumble_ignore);
1711
}
CommonTableExpr
;
1712
1713
/* Convenience macro to get the output tlist of a CTE's query */
1714
#define GetCTETargetList(cte) \
1715
(AssertMacro(IsA((cte)->ctequery, Query)), \
1716
((Query *) (cte)->ctequery)->commandType == CMD_SELECT ? \
1717
((Query *) (cte)->ctequery)->targetList : \
1718
((Query *) (cte)->ctequery)->returningList)
1719
1720
/*
1721
* MergeWhenClause -
1722
* raw parser representation of a WHEN clause in a MERGE statement
1723
*
1724
* This is transformed into MergeAction by parse analysis
1725
*/
1726
typedef
struct
MergeWhenClause
1727
{
1728
NodeTag
type
;
1729
MergeMatchKind
matchKind
;
/* MATCHED/NOT MATCHED BY SOURCE/TARGET */
1730
CmdType
commandType
;
/* INSERT/UPDATE/DELETE/DO NOTHING */
1731
OverridingKind
override
;
/* OVERRIDING clause */
1732
Node
*
condition
;
/* WHEN conditions (raw parser) */
1733
List
*
targetList
;
/* INSERT/UPDATE targetlist */
1734
/* the following members are only used in INSERT actions */
1735
List
*
values
;
/* VALUES to INSERT, or NULL */
1736
}
MergeWhenClause
;
1737
1738
/*
1739
* ReturningOptionKind -
1740
* Possible kinds of option in RETURNING WITH(...) list
1741
*
1742
* Currently, this is used only for specifying OLD/NEW aliases.
1743
*/
1744
typedef
enum
ReturningOptionKind
1745
{
1746
RETURNING_OPTION_OLD
,
/* specify alias for OLD in RETURNING */
1747
RETURNING_OPTION_NEW
,
/* specify alias for NEW in RETURNING */
1748
}
ReturningOptionKind
;
1749
1750
/*
1751
* ReturningOption -
1752
* An individual option in the RETURNING WITH(...) list
1753
*/
1754
typedef
struct
ReturningOption
1755
{
1756
NodeTag
type
;
1757
ReturningOptionKind
option
;
/* specified option */
1758
char
*
value
;
/* option's value */
1759
ParseLoc
location
;
/* token location, or -1 if unknown */
1760
}
ReturningOption
;
1761
1762
/*
1763
* ReturningClause -
1764
* List of RETURNING expressions, together with any WITH(...) options
1765
*/
1766
typedef
struct
ReturningClause
1767
{
1768
NodeTag
type
;
1769
List
*
options
;
/* list of ReturningOption elements */
1770
List
*
exprs
;
/* list of expressions to return */
1771
}
ReturningClause
;
1772
1773
/*
1774
* TriggerTransition -
1775
* representation of transition row or table naming clause
1776
*
1777
* Only transition tables are initially supported in the syntax, and only for
1778
* AFTER triggers, but other permutations are accepted by the parser so we can
1779
* give a meaningful message from C code.
1780
*/
1781
typedef
struct
TriggerTransition
1782
{
1783
NodeTag
type
;
1784
char
*
name
;
1785
bool
isNew
;
1786
bool
isTable
;
1787
}
TriggerTransition
;
1788
1789
/* Nodes for SQL/JSON support */
1790
1791
/*
1792
* JsonOutput -
1793
* representation of JSON output clause (RETURNING type [FORMAT format])
1794
*/
1795
typedef
struct
JsonOutput
1796
{
1797
NodeTag
type
;
1798
TypeName
*
typeName
;
/* RETURNING type name, if specified */
1799
JsonReturning
*
returning
;
/* RETURNING FORMAT clause and type Oids */
1800
}
JsonOutput
;
1801
1802
/*
1803
* JsonArgument -
1804
* representation of argument from JSON PASSING clause
1805
*/
1806
typedef
struct
JsonArgument
1807
{
1808
NodeTag
type
;
1809
JsonValueExpr
*
val
;
/* argument value expression */
1810
char
*
name
;
/* argument name */
1811
}
JsonArgument
;
1812
1813
/*
1814
* JsonQuotes -
1815
* representation of [KEEP|OMIT] QUOTES clause for JSON_QUERY()
1816
*/
1817
typedef
enum
JsonQuotes
1818
{
1819
JS_QUOTES_UNSPEC
,
/* unspecified */
1820
JS_QUOTES_KEEP
,
/* KEEP QUOTES */
1821
JS_QUOTES_OMIT
,
/* OMIT QUOTES */
1822
}
JsonQuotes
;
1823
1824
/*
1825
* JsonFuncExpr -
1826
* untransformed representation of function expressions for
1827
* SQL/JSON query functions
1828
*/
1829
typedef
struct
JsonFuncExpr
1830
{
1831
NodeTag
type
;
1832
JsonExprOp
op
;
/* expression type */
1833
char
*
column_name
;
/* JSON_TABLE() column name or NULL if this is
1834
* not for a JSON_TABLE() */
1835
JsonValueExpr
*
context_item
;
/* context item expression */
1836
Node
*
pathspec
;
/* JSON path specification expression */
1837
List
*
passing
;
/* list of PASSING clause arguments, if any */
1838
JsonOutput
*
output
;
/* output clause, if specified */
1839
JsonBehavior
*
on_empty
;
/* ON EMPTY behavior */
1840
JsonBehavior
*
on_error
;
/* ON ERROR behavior */
1841
JsonWrapper
wrapper
;
/* array wrapper behavior (JSON_QUERY only) */
1842
JsonQuotes
quotes
;
/* omit or keep quotes? (JSON_QUERY only) */
1843
ParseLoc
location
;
/* token location, or -1 if unknown */
1844
}
JsonFuncExpr
;
1845
1846
/*
1847
* JsonTablePathSpec
1848
* untransformed specification of JSON path expression with an optional
1849
* name
1850
*/
1851
typedef
struct
JsonTablePathSpec
1852
{
1853
NodeTag
type
;
1854
1855
Node
*
string
;
1856
char
*
name
;
1857
ParseLoc
name_location
;
1858
ParseLoc
location
;
/* location of 'string' */
1859
}
JsonTablePathSpec
;
1860
1861
/*
1862
* JsonTable -
1863
* untransformed representation of JSON_TABLE
1864
*/
1865
typedef
struct
JsonTable
1866
{
1867
NodeTag
type
;
1868
JsonValueExpr
*
context_item
;
/* context item expression */
1869
JsonTablePathSpec
*
pathspec
;
/* JSON path specification */
1870
List
*
passing
;
/* list of PASSING clause arguments, if any */
1871
List
*
columns
;
/* list of JsonTableColumn */
1872
JsonBehavior
*
on_error
;
/* ON ERROR behavior */
1873
Alias
*
alias
;
/* table alias in FROM clause */
1874
bool
lateral
;
/* does it have LATERAL prefix? */
1875
ParseLoc
location
;
/* token location, or -1 if unknown */
1876
}
JsonTable
;
1877
1878
/*
1879
* JsonTableColumnType -
1880
* enumeration of JSON_TABLE column types
1881
*/
1882
typedef
enum
JsonTableColumnType
1883
{
1884
JTC_FOR_ORDINALITY
,
1885
JTC_REGULAR
,
1886
JTC_EXISTS
,
1887
JTC_FORMATTED
,
1888
JTC_NESTED
,
1889
}
JsonTableColumnType
;
1890
1891
/*
1892
* JsonTableColumn -
1893
* untransformed representation of JSON_TABLE column
1894
*/
1895
typedef
struct
JsonTableColumn
1896
{
1897
NodeTag
type
;
1898
JsonTableColumnType
coltype
;
/* column type */
1899
char
*
name
;
/* column name */
1900
TypeName
*
typeName
;
/* column type name */
1901
JsonTablePathSpec
*
pathspec
;
/* JSON path specification */
1902
JsonFormat
*
format
;
/* JSON format clause, if specified */
1903
JsonWrapper
wrapper
;
/* WRAPPER behavior for formatted columns */
1904
JsonQuotes
quotes
;
/* omit or keep quotes on scalar strings? */
1905
List
*
columns
;
/* nested columns */
1906
JsonBehavior
*
on_empty
;
/* ON EMPTY behavior */
1907
JsonBehavior
*
on_error
;
/* ON ERROR behavior */
1908
ParseLoc
location
;
/* token location, or -1 if unknown */
1909
}
JsonTableColumn
;
1910
1911
/*
1912
* JsonKeyValue -
1913
* untransformed representation of JSON object key-value pair for
1914
* JSON_OBJECT() and JSON_OBJECTAGG()
1915
*/
1916
typedef
struct
JsonKeyValue
1917
{
1918
NodeTag
type
;
1919
Expr
*
key
;
/* key expression */
1920
JsonValueExpr
*
value
;
/* JSON value expression */
1921
}
JsonKeyValue
;
1922
1923
/*
1924
* JsonParseExpr -
1925
* untransformed representation of JSON()
1926
*/
1927
typedef
struct
JsonParseExpr
1928
{
1929
NodeTag
type
;
1930
JsonValueExpr
*
expr
;
/* string expression */
1931
JsonOutput
*
output
;
/* RETURNING clause, if specified */
1932
bool
unique_keys
;
/* WITH UNIQUE KEYS? */
1933
ParseLoc
location
;
/* token location, or -1 if unknown */
1934
}
JsonParseExpr
;
1935
1936
/*
1937
* JsonScalarExpr -
1938
* untransformed representation of JSON_SCALAR()
1939
*/
1940
typedef
struct
JsonScalarExpr
1941
{
1942
NodeTag
type
;
1943
Expr
*
expr
;
/* scalar expression */
1944
JsonOutput
*
output
;
/* RETURNING clause, if specified */
1945
ParseLoc
location
;
/* token location, or -1 if unknown */
1946
}
JsonScalarExpr
;
1947
1948
/*
1949
* JsonSerializeExpr -
1950
* untransformed representation of JSON_SERIALIZE() function
1951
*/
1952
typedef
struct
JsonSerializeExpr
1953
{
1954
NodeTag
type
;
1955
JsonValueExpr
*
expr
;
/* json value expression */
1956
JsonOutput
*
output
;
/* RETURNING clause, if specified */
1957
ParseLoc
location
;
/* token location, or -1 if unknown */
1958
}
JsonSerializeExpr
;
1959
1960
/*
1961
* JsonObjectConstructor -
1962
* untransformed representation of JSON_OBJECT() constructor
1963
*/
1964
typedef
struct
JsonObjectConstructor
1965
{
1966
NodeTag
type
;
1967
List
*
exprs
;
/* list of JsonKeyValue pairs */
1968
JsonOutput
*
output
;
/* RETURNING clause, if specified */
1969
bool
absent_on_null
;
/* skip NULL values? */
1970
bool
unique
;
/* check key uniqueness? */
1971
ParseLoc
location
;
/* token location, or -1 if unknown */
1972
}
JsonObjectConstructor
;
1973
1974
/*
1975
* JsonArrayConstructor -
1976
* untransformed representation of JSON_ARRAY(element,...) constructor
1977
*/
1978
typedef
struct
JsonArrayConstructor
1979
{
1980
NodeTag
type
;
1981
List
*
exprs
;
/* list of JsonValueExpr elements */
1982
JsonOutput
*
output
;
/* RETURNING clause, if specified */
1983
bool
absent_on_null
;
/* skip NULL elements? */
1984
ParseLoc
location
;
/* token location, or -1 if unknown */
1985
}
JsonArrayConstructor
;
1986
1987
/*
1988
* JsonArrayQueryConstructor -
1989
* untransformed representation of JSON_ARRAY(subquery) constructor
1990
*/
1991
typedef
struct
JsonArrayQueryConstructor
1992
{
1993
NodeTag
type
;
1994
Node
*
query
;
/* subquery */
1995
JsonOutput
*
output
;
/* RETURNING clause, if specified */
1996
JsonFormat
*
format
;
/* FORMAT clause for subquery, if specified */
1997
bool
absent_on_null
;
/* skip NULL elements? */
1998
ParseLoc
location
;
/* token location, or -1 if unknown */
1999
}
JsonArrayQueryConstructor
;
2000
2001
/*
2002
* JsonAggConstructor -
2003
* common fields of untransformed representation of
2004
* JSON_ARRAYAGG() and JSON_OBJECTAGG()
2005
*/
2006
typedef
struct
JsonAggConstructor
2007
{
2008
NodeTag
type
;
2009
JsonOutput
*
output
;
/* RETURNING clause, if any */
2010
Node
*
agg_filter
;
/* FILTER clause, if any */
2011
List
*
agg_order
;
/* ORDER BY clause, if any */
2012
struct
WindowDef
*
over
;
/* OVER clause, if any */
2013
ParseLoc
location
;
/* token location, or -1 if unknown */
2014
}
JsonAggConstructor
;
2015
2016
/*
2017
* JsonObjectAgg -
2018
* untransformed representation of JSON_OBJECTAGG()
2019
*/
2020
typedef
struct
JsonObjectAgg
2021
{
2022
NodeTag
type
;
2023
JsonAggConstructor
*
constructor
;
/* common fields */
2024
JsonKeyValue
*
arg
;
/* object key-value pair */
2025
bool
absent_on_null
;
/* skip NULL values? */
2026
bool
unique
;
/* check key uniqueness? */
2027
}
JsonObjectAgg
;
2028
2029
/*
2030
* JsonArrayAgg -
2031
* untransformed representation of JSON_ARRAYAGG()
2032
*/
2033
typedef
struct
JsonArrayAgg
2034
{
2035
NodeTag
type
;
2036
JsonAggConstructor
*
constructor
;
/* common fields */
2037
JsonValueExpr
*
arg
;
/* array element expression */
2038
bool
absent_on_null
;
/* skip NULL elements? */
2039
}
JsonArrayAgg
;
2040
2041
2042
/*****************************************************************************
2043
* Raw Grammar Output Statements
2044
*****************************************************************************/
2045
2046
/*
2047
* RawStmt --- container for any one statement's raw parse tree
2048
*
2049
* Parse analysis converts a raw parse tree headed by a RawStmt node into
2050
* an analyzed statement headed by a Query node. For optimizable statements,
2051
* the conversion is complex. For utility statements, the parser usually just
2052
* transfers the raw parse tree (sans RawStmt) into the utilityStmt field of
2053
* the Query node, and all the useful work happens at execution time.
2054
*
2055
* stmt_location/stmt_len identify the portion of the source text string
2056
* containing this raw statement (useful for multi-statement strings).
2057
*
2058
* This is irrelevant for query jumbling, as this is not used in parsed
2059
* queries.
2060
*/
2061
typedef
struct
RawStmt
2062
{
2063
pg_node_attr
(no_query_jumble)
2064
2065
NodeTag
type
;
2066
Node
*
stmt
;
/* raw parse tree */
2067
ParseLoc
stmt_location
;
/* start location, or -1 if unknown */
2068
ParseLoc
stmt_len
;
/* length in bytes; 0 means "rest of string" */
2069
}
RawStmt
;
2070
2071
/*****************************************************************************
2072
* Optimizable Statements
2073
*****************************************************************************/
2074
2075
/* ----------------------
2076
* Insert Statement
2077
*
2078
* The source expression is represented by SelectStmt for both the
2079
* SELECT and VALUES cases. If selectStmt is NULL, then the query
2080
* is INSERT ... DEFAULT VALUES.
2081
* ----------------------
2082
*/
2083
typedef
struct
InsertStmt
2084
{
2085
NodeTag
type
;
2086
RangeVar
*
relation
;
/* relation to insert into */
2087
List
*
cols
;
/* optional: names of the target columns */
2088
Node
*
selectStmt
;
/* the source SELECT/VALUES, or NULL */
2089
OnConflictClause
*
onConflictClause
;
/* ON CONFLICT clause */
2090
ReturningClause
*
returningClause
;
/* RETURNING clause */
2091
WithClause
*
withClause
;
/* WITH clause */
2092
OverridingKind
override
;
/* OVERRIDING clause */
2093
ParseLoc
stmt_location
;
/* start location, or -1 if unknown */
2094
ParseLoc
stmt_len
;
/* length in bytes; 0 means "rest of string" */
2095
}
InsertStmt
;
2096
2097
/* ----------------------
2098
* Delete Statement
2099
* ----------------------
2100
*/
2101
typedef
struct
DeleteStmt
2102
{
2103
NodeTag
type
;
2104
RangeVar
*
relation
;
/* relation to delete from */
2105
List
*
usingClause
;
/* optional using clause for more tables */
2106
Node
*
whereClause
;
/* qualifications */
2107
ReturningClause
*
returningClause
;
/* RETURNING clause */
2108
WithClause
*
withClause
;
/* WITH clause */
2109
ParseLoc
stmt_location
;
/* start location, or -1 if unknown */
2110
ParseLoc
stmt_len
;
/* length in bytes; 0 means "rest of string" */
2111
}
DeleteStmt
;
2112
2113
/* ----------------------
2114
* Update Statement
2115
* ----------------------
2116
*/
2117
typedef
struct
UpdateStmt
2118
{
2119
NodeTag
type
;
2120
RangeVar
*
relation
;
/* relation to update */
2121
List
*
targetList
;
/* the target list (of ResTarget) */
2122
Node
*
whereClause
;
/* qualifications */
2123
List
*
fromClause
;
/* optional from clause for more tables */
2124
ReturningClause
*
returningClause
;
/* RETURNING clause */
2125
WithClause
*
withClause
;
/* WITH clause */
2126
ParseLoc
stmt_location
;
/* start location, or -1 if unknown */
2127
ParseLoc
stmt_len
;
/* length in bytes; 0 means "rest of string" */
2128
}
UpdateStmt
;
2129
2130
/* ----------------------
2131
* Merge Statement
2132
* ----------------------
2133
*/
2134
typedef
struct
MergeStmt
2135
{
2136
NodeTag
type
;
2137
RangeVar
*
relation
;
/* target relation to merge into */
2138
Node
*
sourceRelation
;
/* source relation */
2139
Node
*
joinCondition
;
/* join condition between source and target */
2140
List
*
mergeWhenClauses
;
/* list of MergeWhenClause(es) */
2141
ReturningClause
*
returningClause
;
/* RETURNING clause */
2142
WithClause
*
withClause
;
/* WITH clause */
2143
ParseLoc
stmt_location
;
/* start location, or -1 if unknown */
2144
ParseLoc
stmt_len
;
/* length in bytes; 0 means "rest of string" */
2145
}
MergeStmt
;
2146
2147
/* ----------------------
2148
* Select Statement
2149
*
2150
* A "simple" SELECT is represented in the output of gram.y by a single
2151
* SelectStmt node; so is a VALUES construct. A query containing set
2152
* operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt
2153
* nodes, in which the leaf nodes are component SELECTs and the internal nodes
2154
* represent UNION, INTERSECT, or EXCEPT operators. Using the same node
2155
* type for both leaf and internal nodes allows gram.y to stick ORDER BY,
2156
* LIMIT, etc, clause values into a SELECT statement without worrying
2157
* whether it is a simple or compound SELECT.
2158
* ----------------------
2159
*/
2160
typedef
enum
SetOperation
2161
{
2162
SETOP_NONE
= 0,
2163
SETOP_UNION
,
2164
SETOP_INTERSECT
,
2165
SETOP_EXCEPT
,
2166
}
SetOperation
;
2167
2168
typedef
struct
SelectStmt
2169
{
2170
NodeTag
type
;
2171
2172
/*
2173
* These fields are used only in "leaf" SelectStmts.
2174
*/
2175
List
*
distinctClause
;
/* NULL, list of DISTINCT ON exprs, or
2176
* lcons(NIL,NIL) for all (SELECT DISTINCT) */
2177
IntoClause
*
intoClause
;
/* target for SELECT INTO */
2178
List
*
targetList
;
/* the target list (of ResTarget) */
2179
List
*
fromClause
;
/* the FROM clause */
2180
Node
*
whereClause
;
/* WHERE qualification */
2181
List
*
groupClause
;
/* GROUP BY clauses */
2182
bool
groupDistinct
;
/* Is this GROUP BY DISTINCT? */
2183
Node
*
havingClause
;
/* HAVING conditional-expression */
2184
List
*
windowClause
;
/* WINDOW window_name AS (...), ... */
2185
2186
/*
2187
* In a "leaf" node representing a VALUES list, the above fields are all
2188
* null, and instead this field is set. Note that the elements of the
2189
* sublists are just expressions, without ResTarget decoration. Also note
2190
* that a list element can be DEFAULT (represented as a SetToDefault
2191
* node), regardless of the context of the VALUES list. It's up to parse
2192
* analysis to reject that where not valid.
2193
*/
2194
List
*
valuesLists
;
/* untransformed list of expression lists */
2195
2196
/*
2197
* These fields are used in both "leaf" SelectStmts and upper-level
2198
* SelectStmts.
2199
*/
2200
List
*
sortClause
;
/* sort clause (a list of SortBy's) */
2201
Node
*
limitOffset
;
/* # of result tuples to skip */
2202
Node
*
limitCount
;
/* # of result tuples to return */
2203
LimitOption
limitOption
;
/* limit type */
2204
List
*
lockingClause
;
/* FOR UPDATE (list of LockingClause's) */
2205
WithClause
*
withClause
;
/* WITH clause */
2206
2207
/*
2208
* These fields are used only in upper-level SelectStmts.
2209
*/
2210
SetOperation
op
;
/* type of set op */
2211
bool
all
;
/* ALL specified? */
2212
struct
SelectStmt
*
larg
;
/* left child */
2213
struct
SelectStmt
*
rarg
;
/* right child */
2214
ParseLoc
stmt_location
;
/* start location, or -1 if unknown */
2215
ParseLoc
stmt_len
;
/* length in bytes; 0 means "rest of string" */
2216
/* Eventually add fields for CORRESPONDING spec here */
2217
}
SelectStmt
;
2218
2219
2220
/* ----------------------
2221
* Set Operation node for post-analysis query trees
2222
*
2223
* After parse analysis, a SELECT with set operations is represented by a
2224
* top-level Query node containing the leaf SELECTs as subqueries in its
2225
* range table. Its setOperations field shows the tree of set operations,
2226
* with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
2227
* nodes replaced by SetOperationStmt nodes. Information about the output
2228
* column types is added, too. (Note that the child nodes do not necessarily
2229
* produce these types directly, but we've checked that their output types
2230
* can be coerced to the output column type.) Also, if it's not UNION ALL,
2231
* information about the types' sort/group semantics is provided in the form
2232
* of a SortGroupClause list (same representation as, eg, DISTINCT).
2233
* The resolved common column collations are provided too; but note that if
2234
* it's not UNION ALL, it's okay for a column to not have a common collation,
2235
* so a member of the colCollations list could be InvalidOid even though the
2236
* column has a collatable type.
2237
* ----------------------
2238
*/
2239
typedef
struct
SetOperationStmt
2240
{
2241
NodeTag
type
;
2242
SetOperation
op
;
/* type of set op */
2243
bool
all
;
/* ALL specified? */
2244
Node
*
larg
;
/* left child */
2245
Node
*
rarg
;
/* right child */
2246
/* Eventually add fields for CORRESPONDING spec here */
2247
2248
/* Fields derived during parse analysis (irrelevant for query jumbling): */
2249
/* OID list of output column type OIDs */
2250
List
*colTypes
pg_node_attr
(query_jumble_ignore);
2251
/* integer list of output column typmods */
2252
List
*colTypmods
pg_node_attr
(query_jumble_ignore);
2253
/* OID list of output column collation OIDs */
2254
List
*colCollations
pg_node_attr
(query_jumble_ignore);
2255
/* a list of SortGroupClause's */
2256
List
*groupClauses
pg_node_attr
(query_jumble_ignore);
2257
/* groupClauses is NIL if UNION ALL, but must be set otherwise */
2258
}
SetOperationStmt
;
2259
2260
2261
/*
2262
* RETURN statement (inside SQL function body)
2263
*/
2264
typedef
struct
ReturnStmt
2265
{
2266
NodeTag
type
;
2267
Node
*
returnval
;
2268
}
ReturnStmt
;
2269
2270
2271
/* ----------------------
2272
* PL/pgSQL Assignment Statement
2273
*
2274
* Like SelectStmt, this is transformed into a SELECT Query.
2275
* However, the targetlist of the result looks more like an UPDATE.
2276
* ----------------------
2277
*/
2278
typedef
struct
PLAssignStmt
2279
{
2280
NodeTag
type
;
2281
2282
char
*
name
;
/* initial column name */
2283
List
*
indirection
;
/* subscripts and field names, if any */
2284
int
nnames
;
/* number of names to use in ColumnRef */
2285
SelectStmt
*
val
;
/* the PL/pgSQL expression to assign */
2286
ParseLoc
location
;
/* name's token location, or -1 if unknown */
2287
}
PLAssignStmt
;
2288
2289
2290
/*****************************************************************************
2291
* Other Statements (no optimizations required)
2292
*
2293
* These are not touched by parser/analyze.c except to put them into
2294
* the utilityStmt field of a Query. This is eventually passed to
2295
* ProcessUtility (by-passing rewriting and planning). Some of the
2296
* statements do need attention from parse analysis, and this is
2297
* done by routines in parser/parse_utilcmd.c after ProcessUtility
2298
* receives the command for execution.
2299
* DECLARE CURSOR, EXPLAIN, and CREATE TABLE AS are special cases:
2300
* they contain optimizable statements, which get processed normally
2301
* by parser/analyze.c.
2302
*****************************************************************************/
2303
2304
/*
2305
* When a command can act on several kinds of objects with only one
2306
* parse structure required, use these constants to designate the
2307
* object type. Note that commands typically don't support all the types.
2308
*/
2309
2310
typedef
enum
ObjectType
2311
{
2312
OBJECT_ACCESS_METHOD
,
2313
OBJECT_AGGREGATE
,
2314
OBJECT_AMOP
,
2315
OBJECT_AMPROC
,
2316
OBJECT_ATTRIBUTE
,
/* type's attribute, when distinct from column */
2317
OBJECT_CAST
,
2318
OBJECT_COLUMN
,
2319
OBJECT_COLLATION
,
2320
OBJECT_CONVERSION
,
2321
OBJECT_DATABASE
,
2322
OBJECT_DEFAULT
,
2323
OBJECT_DEFACL
,
2324
OBJECT_DOMAIN
,
2325
OBJECT_DOMCONSTRAINT
,
2326
OBJECT_EVENT_TRIGGER
,
2327
OBJECT_EXTENSION
,
2328
OBJECT_FDW
,
2329
OBJECT_FOREIGN_SERVER
,
2330
OBJECT_FOREIGN_TABLE
,
2331
OBJECT_FUNCTION
,
2332
OBJECT_INDEX
,
2333
OBJECT_LANGUAGE
,
2334
OBJECT_LARGEOBJECT
,
2335
OBJECT_MATVIEW
,
2336
OBJECT_OPCLASS
,
2337
OBJECT_OPERATOR
,
2338
OBJECT_OPFAMILY
,
2339
OBJECT_PARAMETER_ACL
,
2340
OBJECT_POLICY
,
2341
OBJECT_PROCEDURE
,
2342
OBJECT_PUBLICATION
,
2343
OBJECT_PUBLICATION_NAMESPACE
,
2344
OBJECT_PUBLICATION_REL
,
2345
OBJECT_ROLE
,
2346
OBJECT_ROUTINE
,
2347
OBJECT_RULE
,
2348
OBJECT_SCHEMA
,
2349
OBJECT_SEQUENCE
,
2350
OBJECT_SUBSCRIPTION
,
2351
OBJECT_STATISTIC_EXT
,
2352
OBJECT_TABCONSTRAINT
,
2353
OBJECT_TABLE
,
2354
OBJECT_TABLESPACE
,
2355
OBJECT_TRANSFORM
,
2356
OBJECT_TRIGGER
,
2357
OBJECT_TSCONFIGURATION
,
2358
OBJECT_TSDICTIONARY
,
2359
OBJECT_TSPARSER
,
2360
OBJECT_TSTEMPLATE
,
2361
OBJECT_TYPE
,
2362
OBJECT_USER_MAPPING
,
2363
OBJECT_VIEW
,
2364
}
ObjectType
;
2365
2366
/* ----------------------
2367
* Create Schema Statement
2368
*
2369
* NOTE: the schemaElts list contains raw parsetrees for component statements
2370
* of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and
2371
* executed after the schema itself is created.
2372
* ----------------------
2373
*/
2374
typedef
struct
CreateSchemaStmt
2375
{
2376
NodeTag
type
;
2377
char
*
schemaname
;
/* the name of the schema to create */
2378
RoleSpec
*
authrole
;
/* the owner of the created schema */
2379
List
*
schemaElts
;
/* schema components (list of parsenodes) */
2380
bool
if_not_exists
;
/* just do nothing if schema already exists? */
2381
}
CreateSchemaStmt
;
2382
2383
typedef
enum
DropBehavior
2384
{
2385
DROP_RESTRICT
,
/* drop fails if any dependent objects */
2386
DROP_CASCADE
,
/* remove dependent objects too */
2387
}
DropBehavior
;
2388
2389
/* ----------------------
2390
* Alter Table
2391
* ----------------------
2392
*/
2393
typedef
struct
AlterTableStmt
2394
{
2395
NodeTag
type
;
2396
RangeVar
*
relation
;
/* table to work on */
2397
List
*
cmds
;
/* list of subcommands */
2398
ObjectType
objtype
;
/* type of object */
2399
bool
missing_ok
;
/* skip error if table missing */
2400
}
AlterTableStmt
;
2401
2402
typedef
enum
AlterTableType
2403
{
2404
AT_AddColumn
,
/* add column */
2405
AT_AddColumnToView
,
/* implicitly via CREATE OR REPLACE VIEW */
2406
AT_ColumnDefault
,
/* alter column default */
2407
AT_CookedColumnDefault
,
/* add a pre-cooked column default */
2408
AT_DropNotNull
,
/* alter column drop not null */
2409
AT_SetNotNull
,
/* alter column set not null */
2410
AT_SetExpression
,
/* alter column set expression */
2411
AT_DropExpression
,
/* alter column drop expression */
2412
AT_SetStatistics
,
/* alter column set statistics */
2413
AT_SetOptions
,
/* alter column set ( options ) */
2414
AT_ResetOptions
,
/* alter column reset ( options ) */
2415
AT_SetStorage
,
/* alter column set storage */
2416
AT_SetCompression
,
/* alter column set compression */
2417
AT_DropColumn
,
/* drop column */
2418
AT_AddIndex
,
/* add index */
2419
AT_ReAddIndex
,
/* internal to commands/tablecmds.c */
2420
AT_AddConstraint
,
/* add constraint */
2421
AT_ReAddConstraint
,
/* internal to commands/tablecmds.c */
2422
AT_ReAddDomainConstraint
,
/* internal to commands/tablecmds.c */
2423
AT_AlterConstraint
,
/* alter constraint */
2424
AT_ValidateConstraint
,
/* validate constraint */
2425
AT_AddIndexConstraint
,
/* add constraint using existing index */
2426
AT_DropConstraint
,
/* drop constraint */
2427
AT_ReAddComment
,
/* internal to commands/tablecmds.c */
2428
AT_AlterColumnType
,
/* alter column type */
2429
AT_AlterColumnGenericOptions
,
/* alter column OPTIONS (...) */
2430
AT_ChangeOwner
,
/* change owner */
2431
AT_ClusterOn
,
/* CLUSTER ON */
2432
AT_DropCluster
,
/* SET WITHOUT CLUSTER */
2433
AT_SetLogged
,
/* SET LOGGED */
2434
AT_SetUnLogged
,
/* SET UNLOGGED */
2435
AT_DropOids
,
/* SET WITHOUT OIDS */
2436
AT_SetAccessMethod
,
/* SET ACCESS METHOD */
2437
AT_SetTableSpace
,
/* SET TABLESPACE */
2438
AT_SetRelOptions
,
/* SET (...) -- AM specific parameters */
2439
AT_ResetRelOptions
,
/* RESET (...) -- AM specific parameters */
2440
AT_ReplaceRelOptions
,
/* replace reloption list in its entirety */
2441
AT_EnableTrig
,
/* ENABLE TRIGGER name */
2442
AT_EnableAlwaysTrig
,
/* ENABLE ALWAYS TRIGGER name */
2443
AT_EnableReplicaTrig
,
/* ENABLE REPLICA TRIGGER name */
2444
AT_DisableTrig
,
/* DISABLE TRIGGER name */
2445
AT_EnableTrigAll
,
/* ENABLE TRIGGER ALL */
2446
AT_DisableTrigAll
,
/* DISABLE TRIGGER ALL */
2447
AT_EnableTrigUser
,
/* ENABLE TRIGGER USER */
2448
AT_DisableTrigUser
,
/* DISABLE TRIGGER USER */
2449
AT_EnableRule
,
/* ENABLE RULE name */
2450
AT_EnableAlwaysRule
,
/* ENABLE ALWAYS RULE name */
2451
AT_EnableReplicaRule
,
/* ENABLE REPLICA RULE name */
2452
AT_DisableRule
,
/* DISABLE RULE name */
2453
AT_AddInherit
,
/* INHERIT parent */
2454
AT_DropInherit
,
/* NO INHERIT parent */
2455
AT_AddOf
,
/* OF <type_name> */
2456
AT_DropOf
,
/* NOT OF */
2457
AT_ReplicaIdentity
,
/* REPLICA IDENTITY */
2458
AT_EnableRowSecurity
,
/* ENABLE ROW SECURITY */
2459
AT_DisableRowSecurity
,
/* DISABLE ROW SECURITY */
2460
AT_ForceRowSecurity
,
/* FORCE ROW SECURITY */
2461
AT_NoForceRowSecurity
,
/* NO FORCE ROW SECURITY */
2462
AT_GenericOptions
,
/* OPTIONS (...) */
2463
AT_AttachPartition
,
/* ATTACH PARTITION */
2464
AT_DetachPartition
,
/* DETACH PARTITION */
2465
AT_DetachPartitionFinalize
,
/* DETACH PARTITION FINALIZE */
2466
AT_AddIdentity
,
/* ADD IDENTITY */
2467
AT_SetIdentity
,
/* SET identity column options */
2468
AT_DropIdentity
,
/* DROP IDENTITY */
2469
AT_ReAddStatistics
,
/* internal to commands/tablecmds.c */
2470
}
AlterTableType
;
2471
2472
typedef
struct
ReplicaIdentityStmt
2473
{
2474
NodeTag
type
;
2475
char
identity_type
;
2476
char
*
name
;
2477
}
ReplicaIdentityStmt
;
2478
2479
typedef
struct
AlterTableCmd
/* one subcommand of an ALTER TABLE */
2480
{
2481
NodeTag
type
;
2482
AlterTableType
subtype
;
/* Type of table alteration to apply */
2483
char
*
name
;
/* column, constraint, or trigger to act on,
2484
* or tablespace, access method */
2485
int16
num
;
/* attribute number for columns referenced by
2486
* number */
2487
RoleSpec
*
newowner
;
2488
Node
*
def
;
/* definition of new column, index,
2489
* constraint, or parent table */
2490
DropBehavior
behavior
;
/* RESTRICT or CASCADE for DROP cases */
2491
bool
missing_ok
;
/* skip error if missing? */
2492
bool
recurse
;
/* exec-time recursion */
2493
}
AlterTableCmd
;
2494
2495
2496
/* ----------------------
2497
* Alter Collation
2498
* ----------------------
2499
*/
2500
typedef
struct
AlterCollationStmt
2501
{
2502
NodeTag
type
;
2503
List
*
collname
;
2504
}
AlterCollationStmt
;
2505
2506
2507
/* ----------------------
2508
* Alter Domain
2509
*
2510
* The fields are used in different ways by the different variants of
2511
* this command.
2512
* ----------------------
2513
*/
2514
typedef
struct
AlterDomainStmt
2515
{
2516
NodeTag
type
;
2517
char
subtype
;
/*------------
2518
* T = alter column default
2519
* N = alter column drop not null
2520
* O = alter column set not null
2521
* C = add constraint
2522
* X = drop constraint
2523
*------------
2524
*/
2525
List
*
typeName
;
/* domain to work on */
2526
char
*
name
;
/* column or constraint name to act on */
2527
Node
*
def
;
/* definition of default or constraint */
2528
DropBehavior
behavior
;
/* RESTRICT or CASCADE for DROP cases */
2529
bool
missing_ok
;
/* skip error if missing? */
2530
}
AlterDomainStmt
;
2531
2532
2533
/* ----------------------
2534
* Grant|Revoke Statement
2535
* ----------------------
2536
*/
2537
typedef
enum
GrantTargetType
2538
{
2539
ACL_TARGET_OBJECT
,
/* grant on specific named object(s) */
2540
ACL_TARGET_ALL_IN_SCHEMA
,
/* grant on all objects in given schema(s) */
2541
ACL_TARGET_DEFAULTS
,
/* ALTER DEFAULT PRIVILEGES */
2542
}
GrantTargetType
;
2543
2544
typedef
struct
GrantStmt
2545
{
2546
NodeTag
type
;
2547
bool
is_grant
;
/* true = GRANT, false = REVOKE */
2548
GrantTargetType
targtype
;
/* type of the grant target */
2549
ObjectType
objtype
;
/* kind of object being operated on */
2550
List
*
objects
;
/* list of RangeVar nodes, ObjectWithArgs
2551
* nodes, or plain names (as String values) */
2552
List
*
privileges
;
/* list of AccessPriv nodes */
2553
/* privileges == NIL denotes ALL PRIVILEGES */
2554
List
*
grantees
;
/* list of RoleSpec nodes */
2555
bool
grant_option
;
/* grant or revoke grant option */
2556
RoleSpec
*
grantor
;
2557
DropBehavior
behavior
;
/* drop behavior (for REVOKE) */
2558
}
GrantStmt
;
2559
2560
/*
2561
* ObjectWithArgs represents a function/procedure/operator name plus parameter
2562
* identification.
2563
*
2564
* objargs includes only the types of the input parameters of the object.
2565
* In some contexts, that will be all we have, and it's enough to look up
2566
* objects according to the traditional Postgres rules (i.e., when only input
2567
* arguments matter).
2568
*
2569
* objfuncargs, if not NIL, carries the full specification of the parameter
2570
* list, including parameter mode annotations.
2571
*
2572
* Some grammar productions can set args_unspecified = true instead of
2573
* providing parameter info. In this case, lookup will succeed only if
2574
* the object name is unique. Note that otherwise, NIL parameter lists
2575
* mean zero arguments.
2576
*/
2577
typedef
struct
ObjectWithArgs
2578
{
2579
NodeTag
type
;
2580
List
*
objname
;
/* qualified name of function/operator */
2581
List
*
objargs
;
/* list of Typename nodes (input args only) */
2582
List
*
objfuncargs
;
/* list of FunctionParameter nodes */
2583
bool
args_unspecified
;
/* argument list was omitted? */
2584
}
ObjectWithArgs
;
2585
2586
/*
2587
* An access privilege, with optional list of column names
2588
* priv_name == NULL denotes ALL PRIVILEGES (only used with a column list)
2589
* cols == NIL denotes "all columns"
2590
* Note that simple "ALL PRIVILEGES" is represented as a NIL list, not
2591
* an AccessPriv with both fields null.
2592
*/
2593
typedef
struct
AccessPriv
2594
{
2595
NodeTag
type
;
2596
char
*
priv_name
;
/* string name of privilege */
2597
List
*
cols
;
/* list of String */
2598
}
AccessPriv
;
2599
2600
/* ----------------------
2601
* Grant/Revoke Role Statement
2602
*
2603
* Note: because of the parsing ambiguity with the GRANT <privileges>
2604
* statement, granted_roles is a list of AccessPriv; the execution code
2605
* should complain if any column lists appear. grantee_roles is a list
2606
* of role names, as String values.
2607
* ----------------------
2608
*/
2609
typedef
struct
GrantRoleStmt
2610
{
2611
NodeTag
type
;
2612
List
*
granted_roles
;
/* list of roles to be granted/revoked */
2613
List
*
grantee_roles
;
/* list of member roles to add/delete */
2614
bool
is_grant
;
/* true = GRANT, false = REVOKE */
2615
List
*
opt
;
/* options e.g. WITH GRANT OPTION */
2616
RoleSpec
*
grantor
;
/* set grantor to other than current role */
2617
DropBehavior
behavior
;
/* drop behavior (for REVOKE) */
2618
}
GrantRoleStmt
;
2619
2620
/* ----------------------
2621
* Alter Default Privileges Statement
2622
* ----------------------
2623
*/
2624
typedef
struct
AlterDefaultPrivilegesStmt
2625
{
2626
NodeTag
type
;
2627
List
*
options
;
/* list of DefElem */
2628
GrantStmt
*
action
;
/* GRANT/REVOKE action (with objects=NIL) */
2629
}
AlterDefaultPrivilegesStmt
;
2630
2631
/* ----------------------
2632
* Copy Statement
2633
*
2634
* We support "COPY relation FROM file", "COPY relation TO file", and
2635
* "COPY (query) TO file". In any given CopyStmt, exactly one of "relation"
2636
* and "query" must be non-NULL.
2637
* ----------------------
2638
*/
2639
typedef
struct
CopyStmt
2640
{
2641
NodeTag
type
;
2642
RangeVar
*
relation
;
/* the relation to copy */
2643
Node
*
query
;
/* the query (SELECT or DML statement with
2644
* RETURNING) to copy, as a raw parse tree */
2645
List
*
attlist
;
/* List of column names (as Strings), or NIL
2646
* for all columns */
2647
bool
is_from
;
/* TO or FROM */
2648
bool
is_program
;
/* is 'filename' a program to popen? */
2649
char
*
filename
;
/* filename, or NULL for STDIN/STDOUT */
2650
List
*
options
;
/* List of DefElem nodes */
2651
Node
*
whereClause
;
/* WHERE condition (or NULL) */
2652
}
CopyStmt
;
2653
2654
/* ----------------------
2655
* SET Statement (includes RESET)
2656
*
2657
* "SET var TO DEFAULT" and "RESET var" are semantically equivalent, but we
2658
* preserve the distinction in VariableSetKind for CreateCommandTag().
2659
* ----------------------
2660
*/
2661
typedef
enum
VariableSetKind
2662
{
2663
VAR_SET_VALUE
,
/* SET var = value */
2664
VAR_SET_DEFAULT
,
/* SET var TO DEFAULT */
2665
VAR_SET_CURRENT
,
/* SET var FROM CURRENT */
2666
VAR_SET_MULTI
,
/* special case for SET TRANSACTION ... */
2667
VAR_RESET
,
/* RESET var */
2668
VAR_RESET_ALL
,
/* RESET ALL */
2669
}
VariableSetKind
;
2670
2671
typedef
struct
VariableSetStmt
2672
{
2673
pg_node_attr
(custom_query_jumble)
2674
2675
NodeTag
type
;
2676
VariableSetKind
kind
;
2677
/* variable to be set */
2678
char
*
name
;
2679
/* List of A_Const nodes */
2680
List
*
args
;
2681
2682
/*
2683
* True if arguments should be accounted for in query jumbling. We use a
2684
* separate flag rather than query_jumble_ignore on "args" as several
2685
* grammar flavors of SET rely on a list of values that are parsed
2686
* directly from the grammar's keywords.
2687
*/
2688
bool
jumble_args
;
2689
/* SET LOCAL? */
2690
bool
is_local
;
2691
/* token location, or -1 if unknown */
2692
ParseLoc
location
pg_node_attr
(query_jumble_location);
2693
}
VariableSetStmt
;
2694
2695
/* ----------------------
2696
* Show Statement
2697
* ----------------------
2698
*/
2699
typedef
struct
VariableShowStmt
2700
{
2701
NodeTag
type
;
2702
char
*
name
;
2703
}
VariableShowStmt
;
2704
2705
/* ----------------------
2706
* Create Table Statement
2707
*
2708
* NOTE: in the raw gram.y output, ColumnDef and Constraint nodes are
2709
* intermixed in tableElts, and constraints and nnconstraints are NIL. After
2710
* parse analysis, tableElts contains just ColumnDefs, nnconstraints contains
2711
* Constraint nodes of CONSTR_NOTNULL type from various sources, and
2712
* constraints contains just CONSTR_CHECK Constraint nodes.
2713
* ----------------------
2714
*/
2715
2716
typedef
struct
CreateStmt
2717
{
2718
NodeTag
type
;
2719
RangeVar
*
relation
;
/* relation to create */
2720
List
*
tableElts
;
/* column definitions (list of ColumnDef) */
2721
List
*
inhRelations
;
/* relations to inherit from (list of
2722
* RangeVar) */
2723
PartitionBoundSpec
*
partbound
;
/* FOR VALUES clause */
2724
PartitionSpec
*
partspec
;
/* PARTITION BY clause */
2725
TypeName
*
ofTypename
;
/* OF typename */
2726
List
*
constraints
;
/* constraints (list of Constraint nodes) */
2727
List
*
nnconstraints
;
/* NOT NULL constraints (ditto) */
2728
List
*
options
;
/* options from WITH clause */
2729
OnCommitAction
oncommit
;
/* what do we do at COMMIT? */
2730
char
*
tablespacename
;
/* table space to use, or NULL */
2731
char
*
accessMethod
;
/* table access method */
2732
bool
if_not_exists
;
/* just do nothing if it already exists? */
2733
}
CreateStmt
;
2734
2735
/* ----------
2736
* Definitions for constraints in CreateStmt
2737
*
2738
* Note that column defaults are treated as a type of constraint,
2739
* even though that's a bit odd semantically.
2740
*
2741
* For constraints that use expressions (CONSTR_CHECK, CONSTR_DEFAULT)
2742
* we may have the expression in either "raw" form (an untransformed
2743
* parse tree) or "cooked" form (the nodeToString representation of
2744
* an executable expression tree), depending on how this Constraint
2745
* node was created (by parsing, or by inheritance from an existing
2746
* relation). We should never have both in the same node!
2747
*
2748
* FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
2749
* and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
2750
* stored into pg_constraint.confmatchtype. Changing the code values may
2751
* require an initdb!
2752
*
2753
* If skip_validation is true then we skip checking that the existing rows
2754
* in the table satisfy the constraint, and just install the catalog entries
2755
* for the constraint. A new FK constraint is marked as valid iff
2756
* initially_valid is true. (Usually skip_validation and initially_valid
2757
* are inverses, but we can set both true if the table is known empty.)
2758
*
2759
* Constraint attributes (DEFERRABLE etc) are initially represented as
2760
* separate Constraint nodes for simplicity of parsing. parse_utilcmd.c makes
2761
* a pass through the constraints list to insert the info into the appropriate
2762
* Constraint node.
2763
* ----------
2764
*/
2765
2766
typedef
enum
ConstrType
/* types of constraints */
2767
{
2768
CONSTR_NULL
,
/* not standard SQL, but a lot of people
2769
* expect it */
2770
CONSTR_NOTNULL
,
2771
CONSTR_DEFAULT
,
2772
CONSTR_IDENTITY
,
2773
CONSTR_GENERATED
,
2774
CONSTR_CHECK
,
2775
CONSTR_PRIMARY
,
2776
CONSTR_UNIQUE
,
2777
CONSTR_EXCLUSION
,
2778
CONSTR_FOREIGN
,
2779
CONSTR_ATTR_DEFERRABLE
,
/* attributes for previous constraint node */
2780
CONSTR_ATTR_NOT_DEFERRABLE
,
2781
CONSTR_ATTR_DEFERRED
,
2782
CONSTR_ATTR_IMMEDIATE
,
2783
CONSTR_ATTR_ENFORCED
,
2784
CONSTR_ATTR_NOT_ENFORCED
,
2785
}
ConstrType
;
2786
2787
/* Foreign key action codes */
2788
#define FKCONSTR_ACTION_NOACTION 'a'
2789
#define FKCONSTR_ACTION_RESTRICT 'r'
2790
#define FKCONSTR_ACTION_CASCADE 'c'
2791
#define FKCONSTR_ACTION_SETNULL 'n'
2792
#define FKCONSTR_ACTION_SETDEFAULT 'd'
2793
2794
/* Foreign key matchtype codes */
2795
#define FKCONSTR_MATCH_FULL 'f'
2796
#define FKCONSTR_MATCH_PARTIAL 'p'
2797
#define FKCONSTR_MATCH_SIMPLE 's'
2798
2799
typedef
struct
Constraint
2800
{
2801
NodeTag
type
;
2802
ConstrType
contype
;
/* see above */
2803
char
*
conname
;
/* Constraint name, or NULL if unnamed */
2804
bool
deferrable
;
/* DEFERRABLE? */
2805
bool
initdeferred
;
/* INITIALLY DEFERRED? */
2806
bool
is_enforced
;
/* enforced constraint? */
2807
bool
skip_validation
;
/* skip validation of existing rows? */
2808
bool
initially_valid
;
/* mark the new constraint as valid? */
2809
bool
is_no_inherit
;
/* is constraint non-inheritable? */
2810
Node
*
raw_expr
;
/* CHECK or DEFAULT expression, as
2811
* untransformed parse tree */
2812
char
*
cooked_expr
;
/* CHECK or DEFAULT expression, as
2813
* nodeToString representation */
2814
char
generated_when
;
/* ALWAYS or BY DEFAULT */
2815
bool
nulls_not_distinct
;
/* null treatment for UNIQUE constraints */
2816
List
*
keys
;
/* String nodes naming referenced key
2817
* column(s); for UNIQUE/PK/NOT NULL */
2818
bool
without_overlaps
;
/* WITHOUT OVERLAPS specified */
2819
List
*
including
;
/* String nodes naming referenced nonkey
2820
* column(s); for UNIQUE/PK */
2821
List
*
exclusions
;
/* list of (IndexElem, operator name) pairs;
2822
* for exclusion constraints */
2823
List
*
options
;
/* options from WITH clause */
2824
char
*
indexname
;
/* existing index to use; otherwise NULL */
2825
char
*
indexspace
;
/* index tablespace; NULL for default */
2826
bool
reset_default_tblspc
;
/* reset default_tablespace prior to
2827
* creating the index */
2828
char
*
access_method
;
/* index access method; NULL for default */
2829
Node
*
where_clause
;
/* partial index predicate */
2830
2831
/* Fields used for FOREIGN KEY constraints: */
2832
RangeVar
*
pktable
;
/* Primary key table */
2833
List
*
fk_attrs
;
/* Attributes of foreign key */
2834
List
*
pk_attrs
;
/* Corresponding attrs in PK table */
2835
bool
fk_with_period
;
/* Last attribute of FK uses PERIOD */
2836
bool
pk_with_period
;
/* Last attribute of PK uses PERIOD */
2837
char
fk_matchtype
;
/* FULL, PARTIAL, SIMPLE */
2838
char
fk_upd_action
;
/* ON UPDATE action */
2839
char
fk_del_action
;
/* ON DELETE action */
2840
List
*
fk_del_set_cols
;
/* ON DELETE SET NULL/DEFAULT (col1, col2) */
2841
List
*
old_conpfeqop
;
/* pg_constraint.conpfeqop of my former self */
2842
Oid
old_pktable_oid
;
/* pg_constraint.confrelid of my former
2843
* self */
2844
2845
ParseLoc
location
;
/* token location, or -1 if unknown */
2846
}
Constraint
;
2847
2848
/* ----------------------
2849
* Create/Drop Table Space Statements
2850
* ----------------------
2851
*/
2852
2853
typedef
struct
CreateTableSpaceStmt
2854
{
2855
NodeTag
type
;
2856
char
*
tablespacename
;
2857
RoleSpec
*
owner
;
2858
char
*
location
;
2859
List
*
options
;
2860
}
CreateTableSpaceStmt
;
2861
2862
typedef
struct
DropTableSpaceStmt
2863
{
2864
NodeTag
type
;
2865
char
*
tablespacename
;
2866
bool
missing_ok
;
/* skip error if missing? */
2867
}
DropTableSpaceStmt
;
2868
2869
typedef
struct
AlterTableSpaceOptionsStmt
2870
{
2871
NodeTag
type
;
2872
char
*
tablespacename
;
2873
List
*
options
;
2874
bool
isReset
;
2875
}
AlterTableSpaceOptionsStmt
;
2876
2877
typedef
struct
AlterTableMoveAllStmt
2878
{
2879
NodeTag
type
;
2880
char
*
orig_tablespacename
;
2881
ObjectType
objtype
;
/* Object type to move */
2882
List
*
roles
;
/* List of roles to move objects of */
2883
char
*
new_tablespacename
;
2884
bool
nowait
;
2885
}
AlterTableMoveAllStmt
;
2886
2887
/* ----------------------
2888
* Create/Alter Extension Statements
2889
* ----------------------
2890
*/
2891
2892
typedef
struct
CreateExtensionStmt
2893
{
2894
NodeTag
type
;
2895
char
*
extname
;
2896
bool
if_not_exists
;
/* just do nothing if it already exists? */
2897
List
*
options
;
/* List of DefElem nodes */
2898
}
CreateExtensionStmt
;
2899
2900
/* Only used for ALTER EXTENSION UPDATE; later might need an action field */
2901
typedef
struct
AlterExtensionStmt
2902
{
2903
NodeTag
type
;
2904
char
*
extname
;
2905
List
*
options
;
/* List of DefElem nodes */
2906
}
AlterExtensionStmt
;
2907
2908
typedef
struct
AlterExtensionContentsStmt
2909
{
2910
NodeTag
type
;
2911
char
*
extname
;
/* Extension's name */
2912
int
action
;
/* +1 = add object, -1 = drop object */
2913
ObjectType
objtype
;
/* Object's type */
2914
Node
*
object
;
/* Qualified name of the object */
2915
}
AlterExtensionContentsStmt
;
2916
2917
/* ----------------------
2918
* Create/Alter FOREIGN DATA WRAPPER Statements
2919
* ----------------------
2920
*/
2921
2922
typedef
struct
CreateFdwStmt
2923
{
2924
NodeTag
type
;
2925
char
*
fdwname
;
/* foreign-data wrapper name */
2926
List
*
func_options
;
/* HANDLER/VALIDATOR options */
2927
List
*
options
;
/* generic options to FDW */
2928
}
CreateFdwStmt
;
2929
2930
typedef
struct
AlterFdwStmt
2931
{
2932
NodeTag
type
;
2933
char
*
fdwname
;
/* foreign-data wrapper name */
2934
List
*
func_options
;
/* HANDLER/VALIDATOR options */
2935
List
*
options
;
/* generic options to FDW */
2936
}
AlterFdwStmt
;
2937
2938
/* ----------------------
2939
* Create/Alter FOREIGN SERVER Statements
2940
* ----------------------
2941
*/
2942
2943
typedef
struct
CreateForeignServerStmt
2944
{
2945
NodeTag
type
;
2946
char
*
servername
;
/* server name */
2947
char
*
servertype
;
/* optional server type */
2948
char
*
version
;
/* optional server version */
2949
char
*
fdwname
;
/* FDW name */
2950
bool
if_not_exists
;
/* just do nothing if it already exists? */
2951
List
*
options
;
/* generic options to server */
2952
}
CreateForeignServerStmt
;
2953
2954
typedef
struct
AlterForeignServerStmt
2955
{
2956
NodeTag
type
;
2957
char
*
servername
;
/* server name */
2958
char
*
version
;
/* optional server version */
2959
List
*
options
;
/* generic options to server */
2960
bool
has_version
;
/* version specified */
2961
}
AlterForeignServerStmt
;
2962
2963
/* ----------------------
2964
* Create FOREIGN TABLE Statement
2965
* ----------------------
2966
*/
2967
2968
typedef
struct
CreateForeignTableStmt
2969
{
2970
CreateStmt
base
;
2971
char
*
servername
;
2972
List
*
options
;
2973
}
CreateForeignTableStmt
;
2974
2975
/* ----------------------
2976
* Create/Drop USER MAPPING Statements
2977
* ----------------------
2978
*/
2979
2980
typedef
struct
CreateUserMappingStmt
2981
{
2982
NodeTag
type
;
2983
RoleSpec
*
user
;
/* user role */
2984
char
*
servername
;
/* server name */
2985
bool
if_not_exists
;
/* just do nothing if it already exists? */
2986
List
*
options
;
/* generic options to server */
2987
}
CreateUserMappingStmt
;
2988
2989
typedef
struct
AlterUserMappingStmt
2990
{
2991
NodeTag
type
;
2992
RoleSpec
*
user
;
/* user role */
2993
char
*
servername
;
/* server name */
2994
List
*
options
;
/* generic options to server */
2995
}
AlterUserMappingStmt
;
2996
2997
typedef
struct
DropUserMappingStmt
2998
{
2999
NodeTag
type
;
3000
RoleSpec
*
user
;
/* user role */
3001
char
*
servername
;
/* server name */
3002
bool
missing_ok
;
/* ignore missing mappings */
3003
}
DropUserMappingStmt
;
3004
3005
/* ----------------------
3006
* Import Foreign Schema Statement
3007
* ----------------------
3008
*/
3009
3010
typedef
enum
ImportForeignSchemaType
3011
{
3012
FDW_IMPORT_SCHEMA_ALL
,
/* all relations wanted */
3013
FDW_IMPORT_SCHEMA_LIMIT_TO
,
/* include only listed tables in import */
3014
FDW_IMPORT_SCHEMA_EXCEPT
,
/* exclude listed tables from import */
3015
}
ImportForeignSchemaType
;
3016
3017
typedef
struct
ImportForeignSchemaStmt
3018
{
3019
NodeTag
type
;
3020
char
*
server_name
;
/* FDW server name */
3021
char
*
remote_schema
;
/* remote schema name to query */
3022
char
*
local_schema
;
/* local schema to create objects in */
3023
ImportForeignSchemaType
list_type
;
/* type of table list */
3024
List
*
table_list
;
/* List of RangeVar */
3025
List
*
options
;
/* list of options to pass to FDW */
3026
}
ImportForeignSchemaStmt
;
3027
3028
/*----------------------
3029
* Create POLICY Statement
3030
*----------------------
3031
*/
3032
typedef
struct
CreatePolicyStmt
3033
{
3034
NodeTag
type
;
3035
char
*
policy_name
;
/* Policy's name */
3036
RangeVar
*
table
;
/* the table name the policy applies to */
3037
char
*
cmd_name
;
/* the command name the policy applies to */
3038
bool
permissive
;
/* restrictive or permissive policy */
3039
List
*
roles
;
/* the roles associated with the policy */
3040
Node
*
qual
;
/* the policy's condition */
3041
Node
*
with_check
;
/* the policy's WITH CHECK condition. */
3042
}
CreatePolicyStmt
;
3043
3044
/*----------------------
3045
* Alter POLICY Statement
3046
*----------------------
3047
*/
3048
typedef
struct
AlterPolicyStmt
3049
{
3050
NodeTag
type
;
3051
char
*
policy_name
;
/* Policy's name */
3052
RangeVar
*
table
;
/* the table name the policy applies to */
3053
List
*
roles
;
/* the roles associated with the policy */
3054
Node
*
qual
;
/* the policy's condition */
3055
Node
*
with_check
;
/* the policy's WITH CHECK condition. */
3056
}
AlterPolicyStmt
;
3057
3058
/*----------------------
3059
* Create ACCESS METHOD Statement
3060
*----------------------
3061
*/
3062
typedef
struct
CreateAmStmt
3063
{
3064
NodeTag
type
;
3065
char
*
amname
;
/* access method name */
3066
List
*
handler_name
;
/* handler function name */
3067
char
amtype
;
/* type of access method */
3068
}
CreateAmStmt
;
3069
3070
/* ----------------------
3071
* Create TRIGGER Statement
3072
* ----------------------
3073
*/
3074
typedef
struct
CreateTrigStmt
3075
{
3076
NodeTag
type
;
3077
bool
replace
;
/* replace trigger if already exists */
3078
bool
isconstraint
;
/* This is a constraint trigger */
3079
char
*
trigname
;
/* TRIGGER's name */
3080
RangeVar
*
relation
;
/* relation trigger is on */
3081
List
*
funcname
;
/* qual. name of function to call */
3082
List
*
args
;
/* list of String or NIL */
3083
bool
row
;
/* ROW/STATEMENT */
3084
/* timing uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
3085
int16
timing
;
/* BEFORE, AFTER, or INSTEAD */
3086
/* events uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
3087
int16
events
;
/* "OR" of INSERT/UPDATE/DELETE/TRUNCATE */
3088
List
*
columns
;
/* column names, or NIL for all columns */
3089
Node
*
whenClause
;
/* qual expression, or NULL if none */
3090
/* explicitly named transition data */
3091
List
*
transitionRels
;
/* TriggerTransition nodes, or NIL if none */
3092
/* The remaining fields are only used for constraint triggers */
3093
bool
deferrable
;
/* [NOT] DEFERRABLE */
3094
bool
initdeferred
;
/* INITIALLY {DEFERRED|IMMEDIATE} */
3095
RangeVar
*
constrrel
;
/* opposite relation, if RI trigger */
3096
}
CreateTrigStmt
;
3097
3098
/* ----------------------
3099
* Create EVENT TRIGGER Statement
3100
* ----------------------
3101
*/
3102
typedef
struct
CreateEventTrigStmt
3103
{
3104
NodeTag
type
;
3105
char
*
trigname
;
/* TRIGGER's name */
3106
char
*
eventname
;
/* event's identifier */
3107
List
*
whenclause
;
/* list of DefElems indicating filtering */
3108
List
*
funcname
;
/* qual. name of function to call */
3109
}
CreateEventTrigStmt
;
3110
3111
/* ----------------------
3112
* Alter EVENT TRIGGER Statement
3113
* ----------------------
3114
*/
3115
typedef
struct
AlterEventTrigStmt
3116
{
3117
NodeTag
type
;
3118
char
*
trigname
;
/* TRIGGER's name */
3119
char
tgenabled
;
/* trigger's firing configuration WRT
3120
* session_replication_role */
3121
}
AlterEventTrigStmt
;
3122
3123
/* ----------------------
3124
* Create LANGUAGE Statements
3125
* ----------------------
3126
*/
3127
typedef
struct
CreatePLangStmt
3128
{
3129
NodeTag
type
;
3130
bool
replace
;
/* T => replace if already exists */
3131
char
*
plname
;
/* PL name */
3132
List
*
plhandler
;
/* PL call handler function (qual. name) */
3133
List
*
plinline
;
/* optional inline function (qual. name) */
3134
List
*
plvalidator
;
/* optional validator function (qual. name) */
3135
bool
pltrusted
;
/* PL is trusted */
3136
}
CreatePLangStmt
;
3137
3138
/* ----------------------
3139
* Create/Alter/Drop Role Statements
3140
*
3141
* Note: these node types are also used for the backwards-compatible
3142
* Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
3143
* there's really no need to distinguish what the original spelling was,
3144
* but for CREATE we mark the type because the defaults vary.
3145
* ----------------------
3146
*/
3147
typedef
enum
RoleStmtType
3148
{
3149
ROLESTMT_ROLE
,
3150
ROLESTMT_USER
,
3151
ROLESTMT_GROUP
,
3152
}
RoleStmtType
;
3153
3154
typedef
struct
CreateRoleStmt
3155
{
3156
NodeTag
type
;
3157
RoleStmtType
stmt_type
;
/* ROLE/USER/GROUP */
3158
char
*
role
;
/* role name */
3159
List
*
options
;
/* List of DefElem nodes */
3160
}
CreateRoleStmt
;
3161
3162
typedef
struct
AlterRoleStmt
3163
{
3164
NodeTag
type
;
3165
RoleSpec
*
role
;
/* role */
3166
List
*
options
;
/* List of DefElem nodes */
3167
int
action
;
/* +1 = add members, -1 = drop members */
3168
}
AlterRoleStmt
;
3169
3170
typedef
struct
AlterRoleSetStmt
3171
{
3172
NodeTag
type
;
3173
RoleSpec
*
role
;
/* role */
3174
char
*
database
;
/* database name, or NULL */
3175
VariableSetStmt
*
setstmt
;
/* SET or RESET subcommand */
3176
}
AlterRoleSetStmt
;
3177
3178
typedef
struct
DropRoleStmt
3179
{
3180
NodeTag
type
;
3181
List
*
roles
;
/* List of roles to remove */
3182
bool
missing_ok
;
/* skip error if a role is missing? */
3183
}
DropRoleStmt
;
3184
3185
/* ----------------------
3186
* {Create|Alter} SEQUENCE Statement
3187
* ----------------------
3188
*/
3189
3190
typedef
struct
CreateSeqStmt
3191
{
3192
NodeTag
type
;
3193
RangeVar
*
sequence
;
/* the sequence to create */
3194
List
*
options
;
3195
Oid
ownerId
;
/* ID of owner, or InvalidOid for default */
3196
bool
for_identity
;
3197
bool
if_not_exists
;
/* just do nothing if it already exists? */
3198
}
CreateSeqStmt
;
3199
3200
typedef
struct
AlterSeqStmt
3201
{
3202
NodeTag
type
;
3203
RangeVar
*
sequence
;
/* the sequence to alter */
3204
List
*
options
;
3205
bool
for_identity
;
3206
bool
missing_ok
;
/* skip error if a role is missing? */
3207
}
AlterSeqStmt
;
3208
3209
/* ----------------------
3210
* Create {Aggregate|Operator|Type} Statement
3211
* ----------------------
3212
*/
3213
typedef
struct
DefineStmt
3214
{
3215
NodeTag
type
;
3216
ObjectType
kind
;
/* aggregate, operator, type */
3217
bool
oldstyle
;
/* hack to signal old CREATE AGG syntax */
3218
List
*
defnames
;
/* qualified name (list of String) */
3219
List
*
args
;
/* a list of TypeName (if needed) */
3220
List
*
definition
;
/* a list of DefElem */
3221
bool
if_not_exists
;
/* just do nothing if it already exists? */
3222
bool
replace
;
/* replace if already exists? */
3223
}
DefineStmt
;
3224
3225
/* ----------------------
3226
* Create Domain Statement
3227
* ----------------------
3228
*/
3229
typedef
struct
CreateDomainStmt
3230
{
3231
NodeTag
type
;
3232
List
*
domainname
;
/* qualified name (list of String) */
3233
TypeName
*
typeName
;
/* the base type */
3234
CollateClause
*
collClause
;
/* untransformed COLLATE spec, if any */
3235
List
*
constraints
;
/* constraints (list of Constraint nodes) */
3236
}
CreateDomainStmt
;
3237
3238
/* ----------------------
3239
* Create Operator Class Statement
3240
* ----------------------
3241
*/
3242
typedef
struct
CreateOpClassStmt
3243
{
3244
NodeTag
type
;
3245
List
*
opclassname
;
/* qualified name (list of String) */
3246
List
*
opfamilyname
;
/* qualified name (ditto); NIL if omitted */
3247
char
*
amname
;
/* name of index AM opclass is for */
3248
TypeName
*
datatype
;
/* datatype of indexed column */
3249
List
*
items
;
/* List of CreateOpClassItem nodes */
3250
bool
isDefault
;
/* Should be marked as default for type? */
3251
}
CreateOpClassStmt
;
3252
3253
#define OPCLASS_ITEM_OPERATOR 1
3254
#define OPCLASS_ITEM_FUNCTION 2
3255
#define OPCLASS_ITEM_STORAGETYPE 3
3256
3257
typedef
struct
CreateOpClassItem
3258
{
3259
NodeTag
type
;
3260
int
itemtype
;
/* see codes above */
3261
ObjectWithArgs
*
name
;
/* operator or function name and args */
3262
int
number
;
/* strategy num or support proc num */
3263
List
*
order_family
;
/* only used for ordering operators */
3264
List
*
class_args
;
/* amproclefttype/amprocrighttype or
3265
* amoplefttype/amoprighttype */
3266
/* fields used for a storagetype item: */
3267
TypeName
*
storedtype
;
/* datatype stored in index */
3268
}
CreateOpClassItem
;
3269
3270
/* ----------------------
3271
* Create Operator Family Statement
3272
* ----------------------
3273
*/
3274
typedef
struct
CreateOpFamilyStmt
3275
{
3276
NodeTag
type
;
3277
List
*
opfamilyname
;
/* qualified name (list of String) */
3278
char
*
amname
;
/* name of index AM opfamily is for */
3279
}
CreateOpFamilyStmt
;
3280
3281
/* ----------------------
3282
* Alter Operator Family Statement
3283
* ----------------------
3284
*/
3285
typedef
struct
AlterOpFamilyStmt
3286
{
3287
NodeTag
type
;
3288
List
*
opfamilyname
;
/* qualified name (list of String) */
3289
char
*
amname
;
/* name of index AM opfamily is for */
3290
bool
isDrop
;
/* ADD or DROP the items? */
3291
List
*
items
;
/* List of CreateOpClassItem nodes */
3292
}
AlterOpFamilyStmt
;
3293
3294
/* ----------------------
3295
* Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
3296
* ----------------------
3297
*/
3298
3299
typedef
struct
DropStmt
3300
{
3301
NodeTag
type
;
3302
List
*
objects
;
/* list of names */
3303
ObjectType
removeType
;
/* object type */
3304
DropBehavior
behavior
;
/* RESTRICT or CASCADE behavior */
3305
bool
missing_ok
;
/* skip error if object is missing? */
3306
bool
concurrent
;
/* drop index concurrently? */
3307
}
DropStmt
;
3308
3309
/* ----------------------
3310
* Truncate Table Statement
3311
* ----------------------
3312
*/
3313
typedef
struct
TruncateStmt
3314
{
3315
NodeTag
type
;
3316
List
*
relations
;
/* relations (RangeVars) to be truncated */
3317
bool
restart_seqs
;
/* restart owned sequences? */
3318
DropBehavior
behavior
;
/* RESTRICT or CASCADE behavior */
3319
}
TruncateStmt
;
3320
3321
/* ----------------------
3322
* Comment On Statement
3323
* ----------------------
3324
*/
3325
typedef
struct
CommentStmt
3326
{
3327
NodeTag
type
;
3328
ObjectType
objtype
;
/* Object's type */
3329
Node
*
object
;
/* Qualified name of the object */
3330
char
*
comment
;
/* Comment to insert, or NULL to remove */
3331
}
CommentStmt
;
3332
3333
/* ----------------------
3334
* SECURITY LABEL Statement
3335
* ----------------------
3336
*/
3337
typedef
struct
SecLabelStmt
3338
{
3339
NodeTag
type
;
3340
ObjectType
objtype
;
/* Object's type */
3341
Node
*
object
;
/* Qualified name of the object */
3342
char
*
provider
;
/* Label provider (or NULL) */
3343
char
*
label
;
/* New security label to be assigned */
3344
}
SecLabelStmt
;
3345
3346
/* ----------------------
3347
* Declare Cursor Statement
3348
*
3349
* The "query" field is initially a raw parse tree, and is converted to a
3350
* Query node during parse analysis. Note that rewriting and planning
3351
* of the query are always postponed until execution.
3352
* ----------------------
3353
*/
3354
#define CURSOR_OPT_BINARY 0x0001
/* BINARY */
3355
#define CURSOR_OPT_SCROLL 0x0002
/* SCROLL explicitly given */
3356
#define CURSOR_OPT_NO_SCROLL 0x0004
/* NO SCROLL explicitly given */
3357
#define CURSOR_OPT_INSENSITIVE 0x0008
/* INSENSITIVE */
3358
#define CURSOR_OPT_ASENSITIVE 0x0010
/* ASENSITIVE */
3359
#define CURSOR_OPT_HOLD 0x0020
/* WITH HOLD */
3360
/* these planner-control flags do not correspond to any SQL grammar: */
3361
#define CURSOR_OPT_FAST_PLAN 0x0100
/* prefer fast-start plan */
3362
#define CURSOR_OPT_GENERIC_PLAN 0x0200
/* force use of generic plan */
3363
#define CURSOR_OPT_CUSTOM_PLAN 0x0400
/* force use of custom plan */
3364
#define CURSOR_OPT_PARALLEL_OK 0x0800
/* parallel mode OK */
3365
3366
typedef
struct
DeclareCursorStmt
3367
{
3368
NodeTag
type
;
3369
char
*
portalname
;
/* name of the portal (cursor) */
3370
int
options
;
/* bitmask of options (see above) */
3371
Node
*
query
;
/* the query (see comments above) */
3372
}
DeclareCursorStmt
;
3373
3374
/* ----------------------
3375
* Close Portal Statement
3376
* ----------------------
3377
*/
3378
typedef
struct
ClosePortalStmt
3379
{
3380
NodeTag
type
;
3381
char
*
portalname
;
/* name of the portal (cursor) */
3382
/* NULL means CLOSE ALL */
3383
}
ClosePortalStmt
;
3384
3385
/* ----------------------
3386
* Fetch Statement (also Move)
3387
* ----------------------
3388
*/
3389
typedef
enum
FetchDirection
3390
{
3391
/* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
3392
FETCH_FORWARD
,
3393
FETCH_BACKWARD
,
3394
/* for these, howMany indicates a position; only one row is fetched */
3395
FETCH_ABSOLUTE
,
3396
FETCH_RELATIVE
,
3397
}
FetchDirection
;
3398
3399
#define FETCH_ALL LONG_MAX
3400
3401
typedef
struct
FetchStmt
3402
{
3403
NodeTag
type
;
3404
FetchDirection
direction
;
/* see above */
3405
long
howMany
;
/* number of rows, or position argument */
3406
char
*
portalname
;
/* name of portal (cursor) */
3407
bool
ismove
;
/* true if MOVE */
3408
}
FetchStmt
;
3409
3410
/* ----------------------
3411
* Create Index Statement
3412
*
3413
* This represents creation of an index and/or an associated constraint.
3414
* If isconstraint is true, we should create a pg_constraint entry along
3415
* with the index. But if indexOid isn't InvalidOid, we are not creating an
3416
* index, just a UNIQUE/PKEY constraint using an existing index. isconstraint
3417
* must always be true in this case, and the fields describing the index
3418
* properties are empty.
3419
* ----------------------
3420
*/
3421
typedef
struct
IndexStmt
3422
{
3423
NodeTag
type
;
3424
char
*
idxname
;
/* name of new index, or NULL for default */
3425
RangeVar
*
relation
;
/* relation to build index on */
3426
char
*
accessMethod
;
/* name of access method (eg. btree) */
3427
char
*
tableSpace
;
/* tablespace, or NULL for default */
3428
List
*
indexParams
;
/* columns to index: a list of IndexElem */
3429
List
*
indexIncludingParams
;
/* additional columns to index: a list
3430
* of IndexElem */
3431
List
*
options
;
/* WITH clause options: a list of DefElem */
3432
Node
*
whereClause
;
/* qualification (partial-index predicate) */
3433
List
*
excludeOpNames
;
/* exclusion operator names, or NIL if none */
3434
char
*
idxcomment
;
/* comment to apply to index, or NULL */
3435
Oid
indexOid
;
/* OID of an existing index, if any */
3436
RelFileNumber
oldNumber
;
/* relfilenumber of existing storage, if any */
3437
SubTransactionId
oldCreateSubid
;
/* rd_createSubid of oldNumber */
3438
SubTransactionId
oldFirstRelfilelocatorSubid
;
/* rd_firstRelfilelocatorSubid
3439
* of oldNumber */
3440
bool
unique
;
/* is index unique? */
3441
bool
nulls_not_distinct
;
/* null treatment for UNIQUE constraints */
3442
bool
primary
;
/* is index a primary key? */
3443
bool
isconstraint
;
/* is it for a pkey/unique constraint? */
3444
bool
iswithoutoverlaps
;
/* is the constraint WITHOUT OVERLAPS? */
3445
bool
deferrable
;
/* is the constraint DEFERRABLE? */
3446
bool
initdeferred
;
/* is the constraint INITIALLY DEFERRED? */
3447
bool
transformed
;
/* true when transformIndexStmt is finished */
3448
bool
concurrent
;
/* should this be a concurrent index build? */
3449
bool
if_not_exists
;
/* just do nothing if index already exists? */
3450
bool
reset_default_tblspc
;
/* reset default_tablespace prior to
3451
* executing */
3452
}
IndexStmt
;
3453
3454
/* ----------------------
3455
* Create Statistics Statement
3456
* ----------------------
3457
*/
3458
typedef
struct
CreateStatsStmt
3459
{
3460
NodeTag
type
;
3461
List
*
defnames
;
/* qualified name (list of String) */
3462
List
*
stat_types
;
/* stat types (list of String) */
3463
List
*
exprs
;
/* expressions to build statistics on */
3464
List
*
relations
;
/* rels to build stats on (list of RangeVar) */
3465
char
*
stxcomment
;
/* comment to apply to stats, or NULL */
3466
bool
transformed
;
/* true when transformStatsStmt is finished */
3467
bool
if_not_exists
;
/* do nothing if stats name already exists */
3468
}
CreateStatsStmt
;
3469
3470
/*
3471
* StatsElem - statistics parameters (used in CREATE STATISTICS)
3472
*
3473
* For a plain attribute, 'name' is the name of the referenced table column
3474
* and 'expr' is NULL. For an expression, 'name' is NULL and 'expr' is the
3475
* expression tree.
3476
*/
3477
typedef
struct
StatsElem
3478
{
3479
NodeTag
type
;
3480
char
*
name
;
/* name of attribute to index, or NULL */
3481
Node
*
expr
;
/* expression to index, or NULL */
3482
}
StatsElem
;
3483
3484
3485
/* ----------------------
3486
* Alter Statistics Statement
3487
* ----------------------
3488
*/
3489
typedef
struct
AlterStatsStmt
3490
{
3491
NodeTag
type
;
3492
List
*
defnames
;
/* qualified name (list of String) */
3493
Node
*
stxstattarget
;
/* statistics target */
3494
bool
missing_ok
;
/* skip error if statistics object is missing */
3495
}
AlterStatsStmt
;
3496
3497
/* ----------------------
3498
* Create Function Statement
3499
* ----------------------
3500
*/
3501
typedef
struct
CreateFunctionStmt
3502
{
3503
NodeTag
type
;
3504
bool
is_procedure
;
/* it's really CREATE PROCEDURE */
3505
bool
replace
;
/* T => replace if already exists */
3506
List
*
funcname
;
/* qualified name of function to create */
3507
List
*
parameters
;
/* a list of FunctionParameter */
3508
TypeName
*
returnType
;
/* the return type */
3509
List
*
options
;
/* a list of DefElem */
3510
Node
*
sql_body
;
3511
}
CreateFunctionStmt
;
3512
3513
typedef
enum
FunctionParameterMode
3514
{
3515
/* the assigned enum values appear in pg_proc, don't change 'em! */
3516
FUNC_PARAM_IN
=
'i'
,
/* input only */
3517
FUNC_PARAM_OUT
=
'o'
,
/* output only */
3518
FUNC_PARAM_INOUT
=
'b'
,
/* both */
3519
FUNC_PARAM_VARIADIC
=
'v'
,
/* variadic (always input) */
3520
FUNC_PARAM_TABLE
=
't'
,
/* table function output column */
3521
/* this is not used in pg_proc: */
3522
FUNC_PARAM_DEFAULT
=
'd'
,
/* default; effectively same as IN */
3523
}
FunctionParameterMode
;
3524
3525
typedef
struct
FunctionParameter
3526
{
3527
NodeTag
type
;
3528
char
*
name
;
/* parameter name, or NULL if not given */
3529
TypeName
*
argType
;
/* TypeName for parameter type */
3530
FunctionParameterMode
mode
;
/* IN/OUT/etc */
3531
Node
*
defexpr
;
/* raw default expr, or NULL if not given */
3532
ParseLoc
location
;
/* token location, or -1 if unknown */
3533
}
FunctionParameter
;
3534
3535
typedef
struct
AlterFunctionStmt
3536
{
3537
NodeTag
type
;
3538
ObjectType
objtype
;
3539
ObjectWithArgs
*
func
;
/* name and args of function */
3540
List
*
actions
;
/* list of DefElem */
3541
}
AlterFunctionStmt
;
3542
3543
/* ----------------------
3544
* DO Statement
3545
*
3546
* DoStmt is the raw parser output, InlineCodeBlock is the execution-time API
3547
* ----------------------
3548
*/
3549
typedef
struct
DoStmt
3550
{
3551
NodeTag
type
;
3552
List
*
args
;
/* List of DefElem nodes */
3553
}
DoStmt
;
3554
3555
typedef
struct
InlineCodeBlock
3556
{
3557
pg_node_attr
(nodetag_only)
/* this is not a member of parse trees */
3558
3559
NodeTag
type
;
3560
char
*
source_text
;
/* source text of anonymous code block */
3561
Oid
langOid
;
/* OID of selected language */
3562
bool
langIsTrusted
;
/* trusted property of the language */
3563
bool
atomic
;
/* atomic execution context */
3564
}
InlineCodeBlock
;
3565
3566
/* ----------------------
3567
* CALL statement
3568
*
3569
* OUT-mode arguments are removed from the transformed funcexpr. The outargs
3570
* list contains copies of the expressions for all output arguments, in the
3571
* order of the procedure's declared arguments. (outargs is never evaluated,
3572
* but is useful to the caller as a reference for what to assign to.)
3573
* The transformed call state is not relevant in the query jumbling, only the
3574
* function call is.
3575
* ----------------------
3576
*/
3577
typedef
struct
CallStmt
3578
{
3579
NodeTag
type
;
3580
/* from the parser */
3581
FuncCall
*funccall
pg_node_attr
(query_jumble_ignore);
3582
/* transformed call, with only input args */
3583
FuncExpr
*
funcexpr
;
3584
/* transformed output-argument expressions */
3585
List
*
outargs
;
3586
}
CallStmt
;
3587
3588
typedef
struct
CallContext
3589
{
3590
pg_node_attr
(nodetag_only)
/* this is not a member of parse trees */
3591
3592
NodeTag
type
;
3593
bool
atomic
;
3594
}
CallContext
;
3595
3596
/* ----------------------
3597
* Alter Object Rename Statement
3598
* ----------------------
3599
*/
3600
typedef
struct
RenameStmt
3601
{
3602
NodeTag
type
;
3603
ObjectType
renameType
;
/* OBJECT_TABLE, OBJECT_COLUMN, etc */
3604
ObjectType
relationType
;
/* if column name, associated relation type */
3605
RangeVar
*
relation
;
/* in case it's a table */
3606
Node
*
object
;
/* in case it's some other object */
3607
char
*
subname
;
/* name of contained object (column, rule,
3608
* trigger, etc) */
3609
char
*
newname
;
/* the new name */
3610
DropBehavior
behavior
;
/* RESTRICT or CASCADE behavior */
3611
bool
missing_ok
;
/* skip error if missing? */
3612
}
RenameStmt
;
3613
3614
/* ----------------------
3615
* ALTER object DEPENDS ON EXTENSION extname
3616
* ----------------------
3617
*/
3618
typedef
struct
AlterObjectDependsStmt
3619
{
3620
NodeTag
type
;
3621
ObjectType
objectType
;
/* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */
3622
RangeVar
*
relation
;
/* in case a table is involved */
3623
Node
*
object
;
/* name of the object */
3624
String
*
extname
;
/* extension name */
3625
bool
remove
;
/* set true to remove dep rather than add */
3626
}
AlterObjectDependsStmt
;
3627
3628
/* ----------------------
3629
* ALTER object SET SCHEMA Statement
3630
* ----------------------
3631
*/
3632
typedef
struct
AlterObjectSchemaStmt
3633
{
3634
NodeTag
type
;
3635
ObjectType
objectType
;
/* OBJECT_TABLE, OBJECT_TYPE, etc */
3636
RangeVar
*
relation
;
/* in case it's a table */
3637
Node
*
object
;
/* in case it's some other object */
3638
char
*
newschema
;
/* the new schema */
3639
bool
missing_ok
;
/* skip error if missing? */
3640
}
AlterObjectSchemaStmt
;
3641
3642
/* ----------------------
3643
* Alter Object Owner Statement
3644
* ----------------------
3645
*/
3646
typedef
struct
AlterOwnerStmt
3647
{
3648
NodeTag
type
;
3649
ObjectType
objectType
;
/* OBJECT_TABLE, OBJECT_TYPE, etc */
3650
RangeVar
*
relation
;
/* in case it's a table */
3651
Node
*
object
;
/* in case it's some other object */
3652
RoleSpec
*
newowner
;
/* the new owner */
3653
}
AlterOwnerStmt
;
3654
3655
/* ----------------------
3656
* Alter Operator Set ( this-n-that )
3657
* ----------------------
3658
*/
3659
typedef
struct
AlterOperatorStmt
3660
{
3661
NodeTag
type
;
3662
ObjectWithArgs
*
opername
;
/* operator name and argument types */
3663
List
*
options
;
/* List of DefElem nodes */
3664
}
AlterOperatorStmt
;
3665
3666
/* ------------------------
3667
* Alter Type Set ( this-n-that )
3668
* ------------------------
3669
*/
3670
typedef
struct
AlterTypeStmt
3671
{
3672
NodeTag
type
;
3673
List
*
typeName
;
/* type name (possibly qualified) */
3674
List
*
options
;
/* List of DefElem nodes */
3675
}
AlterTypeStmt
;
3676
3677
/* ----------------------
3678
* Create Rule Statement
3679
* ----------------------
3680
*/
3681
typedef
struct
RuleStmt
3682
{
3683
NodeTag
type
;
3684
RangeVar
*
relation
;
/* relation the rule is for */
3685
char
*
rulename
;
/* name of the rule */
3686
Node
*
whereClause
;
/* qualifications */
3687
CmdType
event
;
/* SELECT, INSERT, etc */
3688
bool
instead
;
/* is a 'do instead'? */
3689
List
*
actions
;
/* the action statements */
3690
bool
replace
;
/* OR REPLACE */
3691
}
RuleStmt
;
3692
3693
/* ----------------------
3694
* Notify Statement
3695
* ----------------------
3696
*/
3697
typedef
struct
NotifyStmt
3698
{
3699
NodeTag
type
;
3700
char
*
conditionname
;
/* condition name to notify */
3701
char
*
payload
;
/* the payload string, or NULL if none */
3702
}
NotifyStmt
;
3703
3704
/* ----------------------
3705
* Listen Statement
3706
* ----------------------
3707
*/
3708
typedef
struct
ListenStmt
3709
{
3710
NodeTag
type
;
3711
char
*
conditionname
;
/* condition name to listen on */
3712
}
ListenStmt
;
3713
3714
/* ----------------------
3715
* Unlisten Statement
3716
* ----------------------
3717
*/
3718
typedef
struct
UnlistenStmt
3719
{
3720
NodeTag
type
;
3721
char
*
conditionname
;
/* name to unlisten on, or NULL for all */
3722
}
UnlistenStmt
;
3723
3724
/* ----------------------
3725
* {Begin|Commit|Rollback} Transaction Statement
3726
* ----------------------
3727
*/
3728
typedef
enum
TransactionStmtKind
3729
{
3730
TRANS_STMT_BEGIN
,
3731
TRANS_STMT_START
,
/* semantically identical to BEGIN */
3732
TRANS_STMT_COMMIT
,
3733
TRANS_STMT_ROLLBACK
,
3734
TRANS_STMT_SAVEPOINT
,
3735
TRANS_STMT_RELEASE
,
3736
TRANS_STMT_ROLLBACK_TO
,
3737
TRANS_STMT_PREPARE
,
3738
TRANS_STMT_COMMIT_PREPARED
,
3739
TRANS_STMT_ROLLBACK_PREPARED
,
3740
}
TransactionStmtKind
;
3741
3742
typedef
struct
TransactionStmt
3743
{
3744
NodeTag
type
;
3745
TransactionStmtKind
kind
;
/* see above */
3746
List
*
options
;
/* for BEGIN/START commands */
3747
/* for savepoint commands */
3748
char
*savepoint_name
pg_node_attr
(query_jumble_ignore);
3749
/* for two-phase-commit related commands */
3750
char
*gid
pg_node_attr
(query_jumble_ignore);
3751
bool
chain
;
/* AND CHAIN option */
3752
/* token location, or -1 if unknown */
3753
ParseLoc
location
pg_node_attr
(query_jumble_location);
3754
}
TransactionStmt
;
3755
3756
/* ----------------------
3757
* Create Type Statement, composite types
3758
* ----------------------
3759
*/
3760
typedef
struct
CompositeTypeStmt
3761
{
3762
NodeTag
type
;
3763
RangeVar
*
typevar
;
/* the composite type to be created */
3764
List
*
coldeflist
;
/* list of ColumnDef nodes */
3765
}
CompositeTypeStmt
;
3766
3767
/* ----------------------
3768
* Create Type Statement, enum types
3769
* ----------------------
3770
*/
3771
typedef
struct
CreateEnumStmt
3772
{
3773
NodeTag
type
;
3774
List
*
typeName
;
/* qualified name (list of String) */
3775
List
*
vals
;
/* enum values (list of String) */
3776
}
CreateEnumStmt
;
3777
3778
/* ----------------------
3779
* Create Type Statement, range types
3780
* ----------------------
3781
*/
3782
typedef
struct
CreateRangeStmt
3783
{
3784
NodeTag
type
;
3785
List
*
typeName
;
/* qualified name (list of String) */
3786
List
*
params
;
/* range parameters (list of DefElem) */
3787
}
CreateRangeStmt
;
3788
3789
/* ----------------------
3790
* Alter Type Statement, enum types
3791
* ----------------------
3792
*/
3793
typedef
struct
AlterEnumStmt
3794
{
3795
NodeTag
type
;
3796
List
*
typeName
;
/* qualified name (list of String) */
3797
char
*
oldVal
;
/* old enum value's name, if renaming */
3798
char
*
newVal
;
/* new enum value's name */
3799
char
*
newValNeighbor
;
/* neighboring enum value, if specified */
3800
bool
newValIsAfter
;
/* place new enum value after neighbor? */
3801
bool
skipIfNewValExists
;
/* no error if new already exists? */
3802
}
AlterEnumStmt
;
3803
3804
/* ----------------------
3805
* Create View Statement
3806
* ----------------------
3807
*/
3808
typedef
enum
ViewCheckOption
3809
{
3810
NO_CHECK_OPTION
,
3811
LOCAL_CHECK_OPTION
,
3812
CASCADED_CHECK_OPTION
,
3813
}
ViewCheckOption
;
3814
3815
typedef
struct
ViewStmt
3816
{
3817
NodeTag
type
;
3818
RangeVar
*
view
;
/* the view to be created */
3819
List
*
aliases
;
/* target column names */
3820
Node
*
query
;
/* the SELECT query (as a raw parse tree) */
3821
bool
replace
;
/* replace an existing view? */
3822
List
*
options
;
/* options from WITH clause */
3823
ViewCheckOption
withCheckOption
;
/* WITH CHECK OPTION */
3824
}
ViewStmt
;
3825
3826
/* ----------------------
3827
* Load Statement
3828
* ----------------------
3829
*/
3830
typedef
struct
LoadStmt
3831
{
3832
NodeTag
type
;
3833
char
*
filename
;
/* file to load */
3834
}
LoadStmt
;
3835
3836
/* ----------------------
3837
* Createdb Statement
3838
* ----------------------
3839
*/
3840
typedef
struct
CreatedbStmt
3841
{
3842
NodeTag
type
;
3843
char
*
dbname
;
/* name of database to create */
3844
List
*
options
;
/* List of DefElem nodes */
3845
}
CreatedbStmt
;
3846
3847
/* ----------------------
3848
* Alter Database
3849
* ----------------------
3850
*/
3851
typedef
struct
AlterDatabaseStmt
3852
{
3853
NodeTag
type
;
3854
char
*
dbname
;
/* name of database to alter */
3855
List
*
options
;
/* List of DefElem nodes */
3856
}
AlterDatabaseStmt
;
3857
3858
typedef
struct
AlterDatabaseRefreshCollStmt
3859
{
3860
NodeTag
type
;
3861
char
*
dbname
;
3862
}
AlterDatabaseRefreshCollStmt
;
3863
3864
typedef
struct
AlterDatabaseSetStmt
3865
{
3866
NodeTag
type
;
3867
char
*
dbname
;
/* database name */
3868
VariableSetStmt
*
setstmt
;
/* SET or RESET subcommand */
3869
}
AlterDatabaseSetStmt
;
3870
3871
/* ----------------------
3872
* Dropdb Statement
3873
* ----------------------
3874
*/
3875
typedef
struct
DropdbStmt
3876
{
3877
NodeTag
type
;
3878
char
*
dbname
;
/* database to drop */
3879
bool
missing_ok
;
/* skip error if db is missing? */
3880
List
*
options
;
/* currently only FORCE is supported */
3881
}
DropdbStmt
;
3882
3883
/* ----------------------
3884
* Alter System Statement
3885
* ----------------------
3886
*/
3887
typedef
struct
AlterSystemStmt
3888
{
3889
NodeTag
type
;
3890
VariableSetStmt
*
setstmt
;
/* SET subcommand */
3891
}
AlterSystemStmt
;
3892
3893
/* ----------------------
3894
* Cluster Statement (support pbrown's cluster index implementation)
3895
* ----------------------
3896
*/
3897
typedef
struct
ClusterStmt
3898
{
3899
NodeTag
type
;
3900
RangeVar
*
relation
;
/* relation being indexed, or NULL if all */
3901
char
*
indexname
;
/* original index defined */
3902
List
*
params
;
/* list of DefElem nodes */
3903
}
ClusterStmt
;
3904
3905
/* ----------------------
3906
* Vacuum and Analyze Statements
3907
*
3908
* Even though these are nominally two statements, it's convenient to use
3909
* just one node type for both.
3910
* ----------------------
3911
*/
3912
typedef
struct
VacuumStmt
3913
{
3914
NodeTag
type
;
3915
List
*
options
;
/* list of DefElem nodes */
3916
List
*
rels
;
/* list of VacuumRelation, or NIL for all */
3917
bool
is_vacuumcmd
;
/* true for VACUUM, false for ANALYZE */
3918
}
VacuumStmt
;
3919
3920
/*
3921
* Info about a single target table of VACUUM/ANALYZE.
3922
*
3923
* If the OID field is set, it always identifies the table to process.
3924
* Then the relation field can be NULL; if it isn't, it's used only to report
3925
* failure to open/lock the relation.
3926
*/
3927
typedef
struct
VacuumRelation
3928
{
3929
NodeTag
type
;
3930
RangeVar
*
relation
;
/* table name to process, or NULL */
3931
Oid
oid
;
/* table's OID; InvalidOid if not looked up */
3932
List
*
va_cols
;
/* list of column names, or NIL for all */
3933
}
VacuumRelation
;
3934
3935
/* ----------------------
3936
* Explain Statement
3937
*
3938
* The "query" field is initially a raw parse tree, and is converted to a
3939
* Query node during parse analysis. Note that rewriting and planning
3940
* of the query are always postponed until execution.
3941
* ----------------------
3942
*/
3943
typedef
struct
ExplainStmt
3944
{
3945
NodeTag
type
;
3946
Node
*
query
;
/* the query (see comments above) */
3947
List
*
options
;
/* list of DefElem nodes */
3948
}
ExplainStmt
;
3949
3950
/* ----------------------
3951
* CREATE TABLE AS Statement (a/k/a SELECT INTO)
3952
*
3953
* A query written as CREATE TABLE AS will produce this node type natively.
3954
* A query written as SELECT ... INTO will be transformed to this form during
3955
* parse analysis.
3956
* A query written as CREATE MATERIALIZED view will produce this node type,
3957
* during parse analysis, since it needs all the same data.
3958
*
3959
* The "query" field is handled similarly to EXPLAIN, though note that it
3960
* can be a SELECT or an EXECUTE, but not other DML statements.
3961
* ----------------------
3962
*/
3963
typedef
struct
CreateTableAsStmt
3964
{
3965
NodeTag
type
;
3966
Node
*
query
;
/* the query (see comments above) */
3967
IntoClause
*
into
;
/* destination table */
3968
ObjectType
objtype
;
/* OBJECT_TABLE or OBJECT_MATVIEW */
3969
bool
is_select_into
;
/* it was written as SELECT INTO */
3970
bool
if_not_exists
;
/* just do nothing if it already exists? */
3971
}
CreateTableAsStmt
;
3972
3973
/* ----------------------
3974
* REFRESH MATERIALIZED VIEW Statement
3975
* ----------------------
3976
*/
3977
typedef
struct
RefreshMatViewStmt
3978
{
3979
NodeTag
type
;
3980
bool
concurrent
;
/* allow concurrent access? */
3981
bool
skipData
;
/* true for WITH NO DATA */
3982
RangeVar
*
relation
;
/* relation to insert into */
3983
}
RefreshMatViewStmt
;
3984
3985
/* ----------------------
3986
* Checkpoint Statement
3987
* ----------------------
3988
*/
3989
typedef
struct
CheckPointStmt
3990
{
3991
NodeTag
type
;
3992
}
CheckPointStmt
;
3993
3994
/* ----------------------
3995
* Discard Statement
3996
* ----------------------
3997
*/
3998
3999
typedef
enum
DiscardMode
4000
{
4001
DISCARD_ALL
,
4002
DISCARD_PLANS
,
4003
DISCARD_SEQUENCES
,
4004
DISCARD_TEMP
,
4005
}
DiscardMode
;
4006
4007
typedef
struct
DiscardStmt
4008
{
4009
NodeTag
type
;
4010
DiscardMode
target
;
4011
}
DiscardStmt
;
4012
4013
/* ----------------------
4014
* LOCK Statement
4015
* ----------------------
4016
*/
4017
typedef
struct
LockStmt
4018
{
4019
NodeTag
type
;
4020
List
*
relations
;
/* relations to lock */
4021
int
mode
;
/* lock mode */
4022
bool
nowait
;
/* no wait mode */
4023
}
LockStmt
;
4024
4025
/* ----------------------
4026
* SET CONSTRAINTS Statement
4027
* ----------------------
4028
*/
4029
typedef
struct
ConstraintsSetStmt
4030
{
4031
NodeTag
type
;
4032
List
*
constraints
;
/* List of names as RangeVars */
4033
bool
deferred
;
4034
}
ConstraintsSetStmt
;
4035
4036
/* ----------------------
4037
* REINDEX Statement
4038
* ----------------------
4039
*/
4040
typedef
enum
ReindexObjectType
4041
{
4042
REINDEX_OBJECT_INDEX
,
/* index */
4043
REINDEX_OBJECT_TABLE
,
/* table or materialized view */
4044
REINDEX_OBJECT_SCHEMA
,
/* schema */
4045
REINDEX_OBJECT_SYSTEM
,
/* system catalogs */
4046
REINDEX_OBJECT_DATABASE
,
/* database */
4047
}
ReindexObjectType
;
4048
4049
typedef
struct
ReindexStmt
4050
{
4051
NodeTag
type
;
4052
ReindexObjectType
kind
;
/* REINDEX_OBJECT_INDEX, REINDEX_OBJECT_TABLE,
4053
* etc. */
4054
RangeVar
*
relation
;
/* Table or index to reindex */
4055
const
char
*
name
;
/* name of database to reindex */
4056
List
*
params
;
/* list of DefElem nodes */
4057
}
ReindexStmt
;
4058
4059
/* ----------------------
4060
* CREATE CONVERSION Statement
4061
* ----------------------
4062
*/
4063
typedef
struct
CreateConversionStmt
4064
{
4065
NodeTag
type
;
4066
List
*
conversion_name
;
/* Name of the conversion */
4067
char
*
for_encoding_name
;
/* source encoding name */
4068
char
*
to_encoding_name
;
/* destination encoding name */
4069
List
*
func_name
;
/* qualified conversion function name */
4070
bool
def
;
/* is this a default conversion? */
4071
}
CreateConversionStmt
;
4072
4073
/* ----------------------
4074
* CREATE CAST Statement
4075
* ----------------------
4076
*/
4077
typedef
struct
CreateCastStmt
4078
{
4079
NodeTag
type
;
4080
TypeName
*
sourcetype
;
4081
TypeName
*
targettype
;
4082
ObjectWithArgs
*
func
;
4083
CoercionContext
context
;
4084
bool
inout
;
4085
}
CreateCastStmt
;
4086
4087
/* ----------------------
4088
* CREATE TRANSFORM Statement
4089
* ----------------------
4090
*/
4091
typedef
struct
CreateTransformStmt
4092
{
4093
NodeTag
type
;
4094
bool
replace
;
4095
TypeName
*
type_name
;
4096
char
*
lang
;
4097
ObjectWithArgs
*
fromsql
;
4098
ObjectWithArgs
*
tosql
;
4099
}
CreateTransformStmt
;
4100
4101
/* ----------------------
4102
* PREPARE Statement
4103
* ----------------------
4104
*/
4105
typedef
struct
PrepareStmt
4106
{
4107
NodeTag
type
;
4108
char
*
name
;
/* Name of plan, arbitrary */
4109
List
*
argtypes
;
/* Types of parameters (List of TypeName) */
4110
Node
*
query
;
/* The query itself (as a raw parsetree) */
4111
}
PrepareStmt
;
4112
4113
4114
/* ----------------------
4115
* EXECUTE Statement
4116
* ----------------------
4117
*/
4118
4119
typedef
struct
ExecuteStmt
4120
{
4121
NodeTag
type
;
4122
char
*
name
;
/* The name of the plan to execute */
4123
List
*
params
;
/* Values to assign to parameters */
4124
}
ExecuteStmt
;
4125
4126
4127
/* ----------------------
4128
* DEALLOCATE Statement
4129
* ----------------------
4130
*/
4131
typedef
struct
DeallocateStmt
4132
{
4133
NodeTag
type
;
4134
/* The name of the plan to remove, NULL if DEALLOCATE ALL */
4135
char
*
name
pg_node_attr
(query_jumble_ignore);
4136
4137
/*
4138
* True if DEALLOCATE ALL. This is redundant with "name == NULL", but we
4139
* make it a separate field so that exactly this condition (and not the
4140
* precise name) will be accounted for in query jumbling.
4141
*/
4142
bool
isall
;
4143
/* token location, or -1 if unknown */
4144
ParseLoc
location
pg_node_attr
(query_jumble_location);
4145
}
DeallocateStmt
;
4146
4147
/*
4148
* DROP OWNED statement
4149
*/
4150
typedef
struct
DropOwnedStmt
4151
{
4152
NodeTag
type
;
4153
List
*
roles
;
4154
DropBehavior
behavior
;