PostgreSQL Source Code  git master
plpgsql.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * plpgsql.h - Definitions for the PL/pgSQL
4  * procedural language
5  *
6  * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/pl/plpgsql/src/plpgsql.h
12  *
13  *-------------------------------------------------------------------------
14  */
15 
16 #ifndef PLPGSQL_H
17 #define PLPGSQL_H
18 
19 #include "access/xact.h"
20 #include "commands/event_trigger.h"
21 #include "commands/trigger.h"
22 #include "executor/spi.h"
23 #include "utils/expandedrecord.h"
24 #include "utils/typcache.h"
25 
26 
27 /**********************************************************************
28  * Definitions
29  **********************************************************************/
30 
31 /* define our text domain for translations */
32 #undef TEXTDOMAIN
33 #define TEXTDOMAIN PG_TEXTDOMAIN("plpgsql")
34 
35 #undef _
36 #define _(x) dgettext(TEXTDOMAIN, x)
37 
38 /*
39  * Compiler's namespace item types
40  */
41 typedef enum PLpgSQL_nsitem_type
42 {
43  PLPGSQL_NSTYPE_LABEL, /* block label */
44  PLPGSQL_NSTYPE_VAR, /* scalar variable */
45  PLPGSQL_NSTYPE_REC /* composite variable */
47 
48 /*
49  * A PLPGSQL_NSTYPE_LABEL stack entry must be one of these types
50  */
51 typedef enum PLpgSQL_label_type
52 {
53  PLPGSQL_LABEL_BLOCK, /* DECLARE/BEGIN block */
54  PLPGSQL_LABEL_LOOP, /* looping construct */
55  PLPGSQL_LABEL_OTHER /* anything else */
57 
58 /*
59  * Datum array node types
60  */
61 typedef enum PLpgSQL_datum_type
62 {
69 
70 /*
71  * DTYPE_PROMISE datums have these possible ways of computing the promise
72  */
74 {
75  PLPGSQL_PROMISE_NONE = 0, /* not a promise, or promise satisfied */
88 
89 /*
90  * Variants distinguished in PLpgSQL_type structs
91  */
92 typedef enum PLpgSQL_type_type
93 {
94  PLPGSQL_TTYPE_SCALAR, /* scalar types and domains */
95  PLPGSQL_TTYPE_REC, /* composite types, including RECORD */
96  PLPGSQL_TTYPE_PSEUDO /* pseudotypes */
98 
99 /*
100  * Execution tree node types
101  */
102 typedef enum PLpgSQL_stmt_type
103 {
133 
134 /*
135  * Execution node return codes
136  */
137 enum
138 {
143 };
144 
145 /*
146  * GET DIAGNOSTICS information items
147  */
149 {
163 
164 /*
165  * RAISE statement options
166  */
168 {
179 
180 /*
181  * Behavioral modes for plpgsql variable resolution
182  */
184 {
185  PLPGSQL_RESOLVE_ERROR, /* throw error if ambiguous */
186  PLPGSQL_RESOLVE_VARIABLE, /* prefer plpgsql var to table column */
187  PLPGSQL_RESOLVE_COLUMN /* prefer table column to plpgsql var */
189 
190 
191 /**********************************************************************
192  * Node and structure definitions
193  **********************************************************************/
194 
195 /*
196  * Postgres data type
197  */
198 typedef struct PLpgSQL_type
199 {
200  char *typname; /* (simple) name of the type */
201  Oid typoid; /* OID of the data type */
202  PLpgSQL_type_type ttype; /* PLPGSQL_TTYPE_ code */
203  int16 typlen; /* stuff copied from its pg_type entry */
204  bool typbyval;
205  char typtype;
206  Oid collation; /* from pg_type, but can be overridden */
207  bool typisarray; /* is "true" array, or domain over one */
208  int32 atttypmod; /* typmod (taken from someplace else) */
209  /* Remaining fields are used only for named composite types (not RECORD) */
210  TypeName *origtypname; /* type name as written by user */
211  TypeCacheEntry *tcache; /* typcache entry for composite type */
212  uint64 tupdesc_id; /* last-seen tupdesc identifier */
213 } PLpgSQL_type;
214 
215 /*
216  * SQL Query to plan and execute
217  */
218 typedef struct PLpgSQL_expr
219 {
220  char *query; /* query string, verbatim from function body */
221  RawParseMode parseMode; /* raw_parser() mode to use */
222  SPIPlanPtr plan; /* plan, or NULL if not made yet */
223  Bitmapset *paramnos; /* all dnos referenced by this query */
224 
225  /* function containing this expr (not set until we first parse query) */
227 
228  /* namespace chain visible to this expr */
230 
231  /* fields for "simple expression" fast-path execution: */
232  Expr *expr_simple_expr; /* NULL means not a simple expr */
233  Oid expr_simple_type; /* result type Oid, if simple */
234  int32 expr_simple_typmod; /* result typmod, if simple */
235  bool expr_simple_mutable; /* true if simple expr is mutable */
236 
237  /*
238  * These fields are used to optimize assignments to expanded-datum
239  * variables. If this expression is the source of an assignment to a
240  * simple variable, target_param holds that variable's dno; else it's -1.
241  * If we match a Param within expr_simple_expr to such a variable, that
242  * Param's address is stored in expr_rw_param; then expression code
243  * generation will allow the value for that Param to be passed read/write.
244  */
245  int target_param; /* dno of assign target, or -1 if none */
246  Param *expr_rw_param; /* read/write Param within expr, if any */
247 
248  /*
249  * If the expression was ever determined to be simple, we remember its
250  * CachedPlanSource and CachedPlan here. If expr_simple_plan_lxid matches
251  * current LXID, then we hold a refcount on expr_simple_plan in the
252  * current transaction. Otherwise we need to get one before re-using it.
253  */
254  CachedPlanSource *expr_simple_plansource; /* extracted from "plan" */
255  CachedPlan *expr_simple_plan; /* extracted from "plan" */
257 
258  /*
259  * if expr is simple AND prepared in current transaction,
260  * expr_simple_state and expr_simple_in_use are valid. Test validity by
261  * seeing if expr_simple_lxid matches current LXID. (If not,
262  * expr_simple_state probably points at garbage!)
263  */
264  ExprState *expr_simple_state; /* eval tree for expr_simple_expr */
265  bool expr_simple_in_use; /* true if eval tree is active */
267 } PLpgSQL_expr;
268 
269 /*
270  * Generic datum array item
271  *
272  * PLpgSQL_datum is the common supertype for PLpgSQL_var, PLpgSQL_row,
273  * PLpgSQL_rec, and PLpgSQL_recfield.
274  */
275 typedef struct PLpgSQL_datum
276 {
278  int dno;
279 } PLpgSQL_datum;
280 
281 /*
282  * Scalar or composite variable
283  *
284  * The variants PLpgSQL_var, PLpgSQL_row, and PLpgSQL_rec share these
285  * fields.
286  */
287 typedef struct PLpgSQL_variable
288 {
290  int dno;
291  char *refname;
292  int lineno;
293  bool isconst;
294  bool notnull;
297 
298 /*
299  * Scalar variable
300  *
301  * DTYPE_VAR and DTYPE_PROMISE datums both use this struct type.
302  * A PROMISE datum works exactly like a VAR datum for most purposes,
303  * but if it is read without having previously been assigned to, then
304  * a special "promised" value is computed and assigned to the datum
305  * before the read is performed. This technique avoids the overhead of
306  * computing the variable's value in cases where we expect that many
307  * functions will never read it.
308  */
309 typedef struct PLpgSQL_var
310 {
312  int dno;
313  char *refname;
314  int lineno;
315  bool isconst;
316  bool notnull;
318  /* end of PLpgSQL_variable fields */
319 
321 
322  /*
323  * Variables declared as CURSOR FOR <query> are mostly like ordinary
324  * scalar variables of type refcursor, but they have these additional
325  * properties:
326  */
330 
331  /* Fields below here can change at runtime */
332 
334  bool isnull;
335  bool freeval;
336 
337  /*
338  * The promise field records which "promised" value to assign if the
339  * promise must be honored. If it's a normal variable, or the promise has
340  * been fulfilled, this is PLPGSQL_PROMISE_NONE.
341  */
343 } PLpgSQL_var;
344 
345 /*
346  * Row variable - this represents one or more variables that are listed in an
347  * INTO clause, FOR-loop targetlist, cursor argument list, etc. We also use
348  * a row to represent a function's OUT parameters when there's more than one.
349  *
350  * Note that there's no way to name the row as such from PL/pgSQL code,
351  * so many functions don't need to support these.
352  *
353  * That also means that there's no real name for the row variable, so we
354  * conventionally set refname to "(unnamed row)". We could leave it NULL,
355  * but it's too convenient to be able to assume that refname is valid in
356  * all variants of PLpgSQL_variable.
357  *
358  * isconst, notnull, and default_val are unsupported (and hence
359  * always zero/null) for a row. The member variables of a row should have
360  * been checked to be writable at compile time, so isconst is correctly set
361  * to false. notnull and default_val aren't applicable.
362  */
363 typedef struct PLpgSQL_row
364 {
366  int dno;
367  char *refname;
368  int lineno;
369  bool isconst;
370  bool notnull;
372  /* end of PLpgSQL_variable fields */
373 
374  /*
375  * rowtupdesc is only set up if we might need to convert the row into a
376  * composite datum, which currently only happens for OUT parameters.
377  * Otherwise it is NULL.
378  */
380 
381  int nfields;
382  char **fieldnames;
383  int *varnos;
384 } PLpgSQL_row;
385 
386 /*
387  * Record variable (any composite type, including RECORD)
388  */
389 typedef struct PLpgSQL_rec
390 {
392  int dno;
393  char *refname;
394  int lineno;
395  bool isconst;
396  bool notnull;
398  /* end of PLpgSQL_variable fields */
399 
400  /*
401  * Note: for non-RECORD cases, we may from time to time re-look-up the
402  * composite type, using datatype->origtypname. That can result in
403  * changing rectypeid.
404  */
405 
406  PLpgSQL_type *datatype; /* can be NULL, if rectypeid is RECORDOID */
407  Oid rectypeid; /* declared type of variable */
408  /* RECFIELDs for this record are chained together for easy access */
409  int firstfield; /* dno of first RECFIELD, or -1 if none */
410 
411  /* Fields below here can change at runtime */
412 
413  /* We always store record variables as "expanded" records */
415 } PLpgSQL_rec;
416 
417 /*
418  * Field in record
419  */
420 typedef struct PLpgSQL_recfield
421 {
423  int dno;
424  /* end of PLpgSQL_datum fields */
425 
426  char *fieldname; /* name of field */
427  int recparentno; /* dno of parent record */
428  int nextfield; /* dno of next child, or -1 if none */
429  uint64 rectupledescid; /* record's tupledesc ID as of last lookup */
430  ExpandedRecordFieldInfo finfo; /* field's attnum and type info */
431  /* if rectupledescid == INVALID_TUPLEDESC_IDENTIFIER, finfo isn't valid */
433 
434 /*
435  * Item in the compilers namespace tree
436  */
437 typedef struct PLpgSQL_nsitem
438 {
440 
441  /*
442  * For labels, itemno is a value of enum PLpgSQL_label_type. For other
443  * itemtypes, itemno is the associated PLpgSQL_datum's dno.
444  */
445  int itemno;
447  char name[FLEXIBLE_ARRAY_MEMBER]; /* nul-terminated string */
449 
450 /*
451  * Generic execution node
452  */
453 typedef struct PLpgSQL_stmt
454 {
456  int lineno;
457 
458  /*
459  * Unique statement ID in this function (starting at 1; 0 is invalid/not
460  * set). This can be used by a profiler as the index for an array of
461  * per-statement metrics.
462  */
463  unsigned int stmtid;
464 } PLpgSQL_stmt;
465 
466 /*
467  * One EXCEPTION condition name
468  */
469 typedef struct PLpgSQL_condition
470 {
471  int sqlerrstate; /* SQLSTATE code */
472  char *condname; /* condition name (for debugging) */
475 
476 /*
477  * EXCEPTION block
478  */
480 {
483  List *exc_list; /* List of WHEN clauses */
485 
486 /*
487  * One EXCEPTION ... WHEN clause
488  */
489 typedef struct PLpgSQL_exception
490 {
491  int lineno;
493  List *action; /* List of statements */
495 
496 /*
497  * Block of statements
498  */
499 typedef struct PLpgSQL_stmt_block
500 {
502  int lineno;
503  unsigned int stmtid;
504  char *label;
505  List *body; /* List of statements */
506  int n_initvars; /* Length of initvarnos[] */
507  int *initvarnos; /* dnos of variables declared in this block */
510 
511 /*
512  * Assign statement
513  */
514 typedef struct PLpgSQL_stmt_assign
515 {
517  int lineno;
518  unsigned int stmtid;
519  int varno;
522 
523 /*
524  * PERFORM statement
525  */
526 typedef struct PLpgSQL_stmt_perform
527 {
529  int lineno;
530  unsigned int stmtid;
533 
534 /*
535  * CALL statement
536  */
537 typedef struct PLpgSQL_stmt_call
538 {
540  int lineno;
541  unsigned int stmtid;
543  bool is_call;
546 
547 /*
548  * COMMIT statement
549  */
550 typedef struct PLpgSQL_stmt_commit
551 {
553  int lineno;
554  unsigned int stmtid;
555  bool chain;
557 
558 /*
559  * ROLLBACK statement
560  */
561 typedef struct PLpgSQL_stmt_rollback
562 {
564  int lineno;
565  unsigned int stmtid;
566  bool chain;
568 
569 /*
570  * SET statement
571  */
572 typedef struct PLpgSQL_stmt_set
573 {
575  int lineno;
576  unsigned int stmtid;
579 
580 /*
581  * GET DIAGNOSTICS item
582  */
583 typedef struct PLpgSQL_diag_item
584 {
585  PLpgSQL_getdiag_kind kind; /* id for diagnostic value desired */
586  int target; /* where to assign it */
588 
589 /*
590  * GET DIAGNOSTICS statement
591  */
592 typedef struct PLpgSQL_stmt_getdiag
593 {
595  int lineno;
596  unsigned int stmtid;
597  bool is_stacked; /* STACKED or CURRENT diagnostics area? */
598  List *diag_items; /* List of PLpgSQL_diag_item */
600 
601 /*
602  * IF statement
603  */
604 typedef struct PLpgSQL_stmt_if
605 {
607  int lineno;
608  unsigned int stmtid;
609  PLpgSQL_expr *cond; /* boolean expression for THEN */
610  List *then_body; /* List of statements */
611  List *elsif_list; /* List of PLpgSQL_if_elsif structs */
612  List *else_body; /* List of statements */
614 
615 /*
616  * one ELSIF arm of IF statement
617  */
618 typedef struct PLpgSQL_if_elsif
619 {
620  int lineno;
621  PLpgSQL_expr *cond; /* boolean expression for this case */
622  List *stmts; /* List of statements */
624 
625 /*
626  * CASE statement
627  */
628 typedef struct PLpgSQL_stmt_case
629 {
631  int lineno;
632  unsigned int stmtid;
633  PLpgSQL_expr *t_expr; /* test expression, or NULL if none */
634  int t_varno; /* var to store test expression value into */
635  List *case_when_list; /* List of PLpgSQL_case_when structs */
636  bool have_else; /* flag needed because list could be empty */
637  List *else_stmts; /* List of statements */
639 
640 /*
641  * one arm of CASE statement
642  */
643 typedef struct PLpgSQL_case_when
644 {
645  int lineno;
646  PLpgSQL_expr *expr; /* boolean expression for this case */
647  List *stmts; /* List of statements */
649 
650 /*
651  * Unconditional LOOP statement
652  */
653 typedef struct PLpgSQL_stmt_loop
654 {
656  int lineno;
657  unsigned int stmtid;
658  char *label;
659  List *body; /* List of statements */
661 
662 /*
663  * WHILE cond LOOP statement
664  */
665 typedef struct PLpgSQL_stmt_while
666 {
668  int lineno;
669  unsigned int stmtid;
670  char *label;
672  List *body; /* List of statements */
674 
675 /*
676  * FOR statement with integer loopvar
677  */
678 typedef struct PLpgSQL_stmt_fori
679 {
681  int lineno;
682  unsigned int stmtid;
683  char *label;
687  PLpgSQL_expr *step; /* NULL means default (ie, BY 1) */
688  int reverse;
689  List *body; /* List of statements */
691 
692 /*
693  * PLpgSQL_stmt_forq represents a FOR statement running over a SQL query.
694  * It is the common supertype of PLpgSQL_stmt_fors, PLpgSQL_stmt_forc
695  * and PLpgSQL_stmt_dynfors.
696  */
697 typedef struct PLpgSQL_stmt_forq
698 {
700  int lineno;
701  unsigned int stmtid;
702  char *label;
703  PLpgSQL_variable *var; /* Loop variable (record or row) */
704  List *body; /* List of statements */
706 
707 /*
708  * FOR statement running over SELECT
709  */
710 typedef struct PLpgSQL_stmt_fors
711 {
713  int lineno;
714  unsigned int stmtid;
715  char *label;
716  PLpgSQL_variable *var; /* Loop variable (record or row) */
717  List *body; /* List of statements */
718  /* end of fields that must match PLpgSQL_stmt_forq */
721 
722 /*
723  * FOR statement running over cursor
724  */
725 typedef struct PLpgSQL_stmt_forc
726 {
728  int lineno;
729  unsigned int stmtid;
730  char *label;
731  PLpgSQL_variable *var; /* Loop variable (record or row) */
732  List *body; /* List of statements */
733  /* end of fields that must match PLpgSQL_stmt_forq */
734  int curvar;
735  PLpgSQL_expr *argquery; /* cursor arguments if any */
737 
738 /*
739  * FOR statement running over EXECUTE
740  */
741 typedef struct PLpgSQL_stmt_dynfors
742 {
744  int lineno;
745  unsigned int stmtid;
746  char *label;
747  PLpgSQL_variable *var; /* Loop variable (record or row) */
748  List *body; /* List of statements */
749  /* end of fields that must match PLpgSQL_stmt_forq */
751  List *params; /* USING expressions */
753 
754 /*
755  * FOREACH item in array loop
756  */
758 {
760  int lineno;
761  unsigned int stmtid;
762  char *label;
763  int varno; /* loop target variable */
764  int slice; /* slice dimension, or 0 */
765  PLpgSQL_expr *expr; /* array expression */
766  List *body; /* List of statements */
768 
769 /*
770  * OPEN a curvar
771  */
772 typedef struct PLpgSQL_stmt_open
773 {
775  int lineno;
776  unsigned int stmtid;
777  int curvar;
782  List *params; /* USING expressions */
784 
785 /*
786  * FETCH or MOVE statement
787  */
788 typedef struct PLpgSQL_stmt_fetch
789 {
791  int lineno;
792  unsigned int stmtid;
793  PLpgSQL_variable *target; /* target (record or row) */
794  int curvar; /* cursor variable to fetch from */
795  FetchDirection direction; /* fetch direction */
796  long how_many; /* count, if constant (expr is NULL) */
797  PLpgSQL_expr *expr; /* count, if expression */
798  bool is_move; /* is this a fetch or move? */
799  bool returns_multiple_rows; /* can return more than one row? */
801 
802 /*
803  * CLOSE curvar
804  */
805 typedef struct PLpgSQL_stmt_close
806 {
808  int lineno;
809  unsigned int stmtid;
810  int curvar;
812 
813 /*
814  * EXIT or CONTINUE statement
815  */
816 typedef struct PLpgSQL_stmt_exit
817 {
819  int lineno;
820  unsigned int stmtid;
821  bool is_exit; /* Is this an exit or a continue? */
822  char *label; /* NULL if it's an unlabeled EXIT/CONTINUE */
825 
826 /*
827  * RETURN statement
828  */
829 typedef struct PLpgSQL_stmt_return
830 {
832  int lineno;
833  unsigned int stmtid;
835  int retvarno;
837 
838 /*
839  * RETURN NEXT statement
840  */
842 {
844  int lineno;
845  unsigned int stmtid;
847  int retvarno;
849 
850 /*
851  * RETURN QUERY statement
852  */
854 {
856  int lineno;
857  unsigned int stmtid;
858  PLpgSQL_expr *query; /* if static query */
859  PLpgSQL_expr *dynquery; /* if dynamic query (RETURN QUERY EXECUTE) */
860  List *params; /* USING arguments for dynamic query */
862 
863 /*
864  * RAISE statement
865  */
866 typedef struct PLpgSQL_stmt_raise
867 {
869  int lineno;
870  unsigned int stmtid;
872  char *condname; /* condition name, SQLSTATE, or NULL */
873  char *message; /* old-style message format literal, or NULL */
874  List *params; /* list of expressions for old-style message */
875  List *options; /* list of PLpgSQL_raise_option */
877 
878 /*
879  * RAISE statement option
880  */
881 typedef struct PLpgSQL_raise_option
882 {
886 
887 /*
888  * ASSERT statement
889  */
890 typedef struct PLpgSQL_stmt_assert
891 {
893  int lineno;
894  unsigned int stmtid;
898 
899 /*
900  * Generic SQL statement to execute
901  */
902 typedef struct PLpgSQL_stmt_execsql
903 {
905  int lineno;
906  unsigned int stmtid;
908  bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE? Note:
909  * mod_stmt is set when we plan the query */
910  bool into; /* INTO supplied? */
911  bool strict; /* INTO STRICT flag */
912  PLpgSQL_variable *target; /* INTO target (record or row) */
914 
915 /*
916  * Dynamic SQL string to execute
917  */
919 {
921  int lineno;
922  unsigned int stmtid;
923  PLpgSQL_expr *query; /* string expression */
924  bool into; /* INTO supplied? */
925  bool strict; /* INTO STRICT flag */
926  PLpgSQL_variable *target; /* INTO target (record or row) */
927  List *params; /* USING expressions */
929 
930 /*
931  * Hash lookup key for functions
932  */
933 typedef struct PLpgSQL_func_hashkey
934 {
936 
937  bool isTrigger; /* true if called as a DML trigger */
938  bool isEventTrigger; /* true if called as an event trigger */
939 
940  /* be careful that pad bytes in this struct get zeroed! */
941 
942  /*
943  * For a trigger function, the OID of the trigger is part of the hash key
944  * --- we want to compile the trigger function separately for each trigger
945  * it is used with, in case the rowtype or transition table names are
946  * different. Zero if not called as a DML trigger.
947  */
949 
950  /*
951  * We must include the input collation as part of the hash key too,
952  * because we have to generate different plans (with different Param
953  * collations) for different collation settings.
954  */
956 
957  /*
958  * We include actual argument types in the hash key to support polymorphic
959  * PLpgSQL functions. Be careful that extra positions are zeroed!
960  */
961  Oid argtypes[FUNC_MAX_ARGS];
963 
964 /*
965  * Trigger type
966  */
967 typedef enum PLpgSQL_trigtype
968 {
973 
974 /*
975  * Complete compiled function
976  */
977 typedef struct PLpgSQL_function
978 {
985  PLpgSQL_func_hashkey *fn_hashkey; /* back-link to hashtable key */
987 
993  bool fn_retset;
996 
997  int fn_nargs;
998  int fn_argvarnos[FUNC_MAX_ARGS];
1003 
1005 
1007 
1008  /* extra checks */
1011 
1012  /* count of statements inside function */
1013  unsigned int nstatements;
1014 
1015  /* the datums representing the function's local variables */
1016  int ndatums;
1018  Size copiable_size; /* space for locally instantiated datums */
1019 
1020  /* function body parsetree */
1022 
1023  /* these fields change when the function is used */
1025  unsigned long use_count;
1027 
1028 /*
1029  * Runtime execution data
1030  */
1031 typedef struct PLpgSQL_execstate
1032 {
1033  PLpgSQL_function *func; /* function being executed */
1034 
1035  TriggerData *trigdata; /* if regular trigger, data about firing */
1036  EventTriggerData *evtrigdata; /* if event trigger, data about firing */
1037 
1040  Oid rettype; /* type of current retval */
1041 
1042  Oid fn_rettype; /* info about declared function rettype */
1044  bool retisset;
1045 
1047  bool atomic;
1048 
1049  char *exitlabel; /* the "target" label of the current EXIT or
1050  * CONTINUE stmt, if any */
1051  ErrorData *cur_error; /* current exception handler's error */
1052 
1053  Tuplestorestate *tuple_store; /* SRFs accumulate results here */
1054  TupleDesc tuple_store_desc; /* descriptor for tuples in tuple_store */
1058 
1060 
1061  /*
1062  * The datums representing the function's local variables. Some of these
1063  * are local storage in this execstate, but some just point to the shared
1064  * copy belonging to the PLpgSQL_function, depending on whether or not we
1065  * need any per-execution state for the datum's dtype.
1066  */
1067  int ndatums;
1069  /* context containing variable values (same as func's SPI_proc context) */
1071 
1072  /*
1073  * paramLI is what we use to pass local variable values to the executor.
1074  * It does not have a ParamExternData array; we just dynamically
1075  * instantiate parameter data as needed. By convention, PARAM_EXTERN
1076  * Params have paramid equal to the dno of the referenced local variable.
1077  */
1079 
1080  /* EState and resowner to use for "simple" expression evaluation */
1083 
1084  /* lookup table to use for executing type casts */
1087 
1088  /* memory context for statement-lifespan temporary values */
1089  MemoryContext stmt_mcontext; /* current stmt context, or NULL if none */
1090  MemoryContext stmt_mcontext_parent; /* parent of current context */
1091 
1092  /* temporary state for results from evaluation of query or expr */
1095  ExprContext *eval_econtext; /* for executing simple expressions */
1096 
1097  /* status information for error context reporting */
1098  PLpgSQL_stmt *err_stmt; /* current stmt */
1099  const char *err_text; /* additional state info */
1100 
1101  void *plugin_info; /* reserved for use by optional plugin */
1103 
1104 /*
1105  * A PLpgSQL_plugin structure represents an instrumentation plugin.
1106  * To instrument PL/pgSQL, a plugin library must access the rendezvous
1107  * variable "PLpgSQL_plugin" and set it to point to a PLpgSQL_plugin struct.
1108  * Typically the struct could just be static data in the plugin library.
1109  * We expect that a plugin would do this at library load time (_PG_init()).
1110  * It must also be careful to set the rendezvous variable back to NULL
1111  * if it is unloaded (_PG_fini()).
1112  *
1113  * This structure is basically a collection of function pointers --- at
1114  * various interesting points in pl_exec.c, we call these functions
1115  * (if the pointers are non-NULL) to give the plugin a chance to watch
1116  * what we are doing.
1117  *
1118  * func_setup is called when we start a function, before we've initialized
1119  * the local variables defined by the function.
1120  *
1121  * func_beg is called when we start a function, after we've initialized
1122  * the local variables.
1123  *
1124  * func_end is called at the end of a function.
1125  *
1126  * stmt_beg and stmt_end are called before and after (respectively) each
1127  * statement.
1128  *
1129  * Also, immediately before any call to func_setup, PL/pgSQL fills in the
1130  * error_callback and assign_expr fields with pointers to its own
1131  * plpgsql_exec_error_callback and exec_assign_expr functions. This is
1132  * a somewhat ad-hoc expedient to simplify life for debugger plugins.
1133  */
1134 typedef struct PLpgSQL_plugin
1135 {
1136  /* Function pointers set up by the plugin */
1137  void (*func_setup) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
1138  void (*func_beg) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
1139  void (*func_end) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
1140  void (*stmt_beg) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
1141  void (*stmt_end) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
1142 
1143  /* Function pointers set by PL/pgSQL itself */
1144  void (*error_callback) (void *arg);
1145  void (*assign_expr) (PLpgSQL_execstate *estate, PLpgSQL_datum *target,
1146  PLpgSQL_expr *expr);
1147 } PLpgSQL_plugin;
1148 
1149 /*
1150  * Struct types used during parsing
1151  */
1152 
1153 typedef struct PLword
1154 {
1155  char *ident; /* palloc'd converted identifier */
1156  bool quoted; /* Was it double-quoted? */
1157 } PLword;
1158 
1159 typedef struct PLcword
1160 {
1161  List *idents; /* composite identifiers (list of String) */
1162 } PLcword;
1163 
1164 typedef struct PLwdatum
1165 {
1166  PLpgSQL_datum *datum; /* referenced variable */
1167  char *ident; /* valid if simple name */
1168  bool quoted;
1169  List *idents; /* valid if composite name */
1170 } PLwdatum;
1171 
1172 /**********************************************************************
1173  * Global variable declarations
1174  **********************************************************************/
1175 
1176 typedef enum
1177 {
1178  IDENTIFIER_LOOKUP_NORMAL, /* normal processing of var names */
1179  IDENTIFIER_LOOKUP_DECLARE, /* In DECLARE --- don't look up names */
1180  IDENTIFIER_LOOKUP_EXPR /* In SQL expression --- special case */
1182 
1184 
1185 extern int plpgsql_variable_conflict;
1186 
1187 extern bool plpgsql_print_strict_params;
1188 
1189 extern bool plpgsql_check_asserts;
1190 
1191 /* extra compile-time and run-time checks */
1192 #define PLPGSQL_XCHECK_NONE 0
1193 #define PLPGSQL_XCHECK_SHADOWVAR (1 << 1)
1194 #define PLPGSQL_XCHECK_TOOMANYROWS (1 << 2)
1195 #define PLPGSQL_XCHECK_STRICTMULTIASSIGNMENT (1 << 3)
1196 #define PLPGSQL_XCHECK_ALL ((int) ~0)
1197 
1198 extern int plpgsql_extra_warnings;
1199 extern int plpgsql_extra_errors;
1200 
1201 extern bool plpgsql_check_syntax;
1202 extern bool plpgsql_DumpExecTree;
1203 
1205 
1206 extern int plpgsql_nDatums;
1207 extern PLpgSQL_datum **plpgsql_Datums;
1208 
1209 extern char *plpgsql_error_funcname;
1210 
1213 
1215 
1216 /**********************************************************************
1217  * Function declarations
1218  **********************************************************************/
1219 
1220 /*
1221  * Functions in pl_comp.c
1222  */
1224  bool forValidator);
1225 extern PLpgSQL_function *plpgsql_compile_inline(char *proc_source);
1226 extern void plpgsql_parser_setup(struct ParseState *pstate,
1227  PLpgSQL_expr *expr);
1228 extern bool plpgsql_parse_word(char *word1, const char *yytxt, bool lookup,
1229  PLwdatum *wdatum, PLword *word);
1230 extern bool plpgsql_parse_dblword(char *word1, char *word2,
1231  PLwdatum *wdatum, PLcword *cword);
1232 extern bool plpgsql_parse_tripword(char *word1, char *word2, char *word3,
1233  PLwdatum *wdatum, PLcword *cword);
1234 extern PLpgSQL_type *plpgsql_parse_wordtype(char *ident);
1235 extern PLpgSQL_type *plpgsql_parse_cwordtype(List *idents);
1236 extern PLpgSQL_type *plpgsql_parse_wordrowtype(char *ident);
1238 extern PLpgSQL_type *plpgsql_build_datatype(Oid typeOid, int32 typmod,
1239  Oid collation,
1241 extern PLpgSQL_variable *plpgsql_build_variable(const char *refname, int lineno,
1242  PLpgSQL_type *dtype,
1243  bool add2namespace);
1244 extern PLpgSQL_rec *plpgsql_build_record(const char *refname, int lineno,
1245  PLpgSQL_type *dtype, Oid rectypeid,
1246  bool add2namespace);
1248  const char *fldname);
1249 extern int plpgsql_recognize_err_condition(const char *condname,
1250  bool allow_sqlstate);
1251 extern PLpgSQL_condition *plpgsql_parse_err_condition(char *condname);
1252 extern void plpgsql_adddatum(PLpgSQL_datum *newdatum);
1253 extern int plpgsql_add_initdatums(int **varnos);
1254 extern void plpgsql_HashTableInit(void);
1255 
1256 /*
1257  * Functions in pl_handler.c
1258  */
1259 extern void _PG_init(void);
1260 
1261 /*
1262  * Functions in pl_exec.c
1263  */
1265  FunctionCallInfo fcinfo,
1266  EState *simple_eval_estate,
1267  ResourceOwner simple_eval_resowner,
1268  bool atomic);
1270  TriggerData *trigdata);
1272  EventTriggerData *trigdata);
1273 extern void plpgsql_xact_cb(XactEvent event, void *arg);
1274 extern void plpgsql_subxact_cb(SubXactEvent event, SubTransactionId mySubid,
1275  SubTransactionId parentSubid, void *arg);
1277  PLpgSQL_datum *datum);
1279  PLpgSQL_datum *datum,
1280  Oid *typeId, int32 *typMod,
1281  Oid *collation);
1282 
1283 /*
1284  * Functions for namespace handling in pl_funcs.c
1285  */
1286 extern void plpgsql_ns_init(void);
1287 extern void plpgsql_ns_push(const char *label,
1288  PLpgSQL_label_type label_type);
1289 extern void plpgsql_ns_pop(void);
1290 extern PLpgSQL_nsitem *plpgsql_ns_top(void);
1291 extern void plpgsql_ns_additem(PLpgSQL_nsitem_type itemtype, int itemno, const char *name);
1292 extern PLpgSQL_nsitem *plpgsql_ns_lookup(PLpgSQL_nsitem *ns_cur, bool localmode,
1293  const char *name1, const char *name2,
1294  const char *name3, int *names_used);
1296  const char *name);
1298 
1299 /*
1300  * Other functions in pl_funcs.c
1301  */
1302 extern const char *plpgsql_stmt_typename(PLpgSQL_stmt *stmt);
1303 extern const char *plpgsql_getdiag_kindname(PLpgSQL_getdiag_kind kind);
1305 extern void plpgsql_dumptree(PLpgSQL_function *func);
1306 
1307 /*
1308  * Scanner functions in pl_scanner.c
1309  */
1310 extern int plpgsql_base_yylex(void);
1311 extern int plpgsql_yylex(void);
1312 extern void plpgsql_push_back_token(int token);
1313 extern bool plpgsql_token_is_unreserved_keyword(int token);
1315  int startlocation, int endlocation);
1316 extern int plpgsql_peek(void);
1317 extern void plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc,
1318  int *tok2_loc);
1319 extern int plpgsql_scanner_errposition(int location);
1320 extern void plpgsql_yyerror(const char *message) pg_attribute_noreturn();
1321 extern int plpgsql_location_to_lineno(int location);
1322 extern int plpgsql_latest_lineno(void);
1323 extern void plpgsql_scanner_init(const char *str);
1324 extern void plpgsql_scanner_finish(void);
1325 
1326 /*
1327  * Externs in gram.y
1328  */
1329 extern int plpgsql_yyparse(void);
1330 
1331 #endif /* PLPGSQL_H */
int plpgsql_nDatums
Definition: pl_comp.c:45
PLpgSQL_promise_type promise
Definition: plpgsql.h:342
PLpgSQL_nsitem * plpgsql_ns_top(void)
Definition: pl_funcs.c:81
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:774
signed short int16
Definition: c.h:416
bool fn_retbyval
Definition: plpgsql.h:990
int plpgsql_yyparse(void)
PLpgSQL_datum_type dtype
Definition: plpgsql.h:391
PLpgSQL_raise_option_type
Definition: plpgsql.h:167
int plpgsql_extra_warnings
Definition: pl_handler.c:52
HTAB * cast_hash
Definition: plpgsql.h:1085
unsigned int stmtid
Definition: plpgsql.h:792
XactEvent
Definition: xact.h:113
#define pg_attribute_noreturn()
Definition: c.h:167
struct PLpgSQL_stmt_dynexecute PLpgSQL_stmt_dynexecute
PLpgSQL_expr * query
Definition: plpgsql.h:923
struct PLpgSQL_stmt_forq PLpgSQL_stmt_forq
bool print_strict_params
Definition: plpgsql.h:1006
PLpgSQL_datum ** datums
Definition: plpgsql.h:1017
struct PLpgSQL_stmt_block PLpgSQL_stmt_block
PLpgSQL_expr * cond
Definition: plpgsql.h:609
unsigned int stmtid
Definition: plpgsql.h:518
PLpgSQL_expr * cond
Definition: plpgsql.h:671
unsigned int stmtid
Definition: plpgsql.h:565
PLpgSQL_nsitem * plpgsql_ns_find_nearest_loop(PLpgSQL_nsitem *ns_cur)
Definition: pl_funcs.c:214
struct PLpgSQL_stmt_return_query PLpgSQL_stmt_return_query
List * then_body
Definition: plpgsql.h:610
PLpgSQL_expr * expr
Definition: plpgsql.h:765
PLpgSQL_func_hashkey * fn_hashkey
Definition: plpgsql.h:985
char * refname
Definition: plpgsql.h:367
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:680
ItemPointerData fn_tid
Definition: plpgsql.h:982
unsigned int nstatements
Definition: plpgsql.h:1013
TypeCacheEntry * tcache
Definition: plpgsql.h:211
struct PLpgSQL_stmt_raise PLpgSQL_stmt_raise
char * query
Definition: plpgsql.h:220
unsigned int stmtid
Definition: plpgsql.h:714
struct PLpgSQL_stmt_fori PLpgSQL_stmt_fori
SPITupleTable * eval_tuptable
Definition: plpgsql.h:1093
FetchDirection direction
Definition: plpgsql.h:795
struct PLpgSQL_stmt_getdiag PLpgSQL_stmt_getdiag
FetchDirection
Definition: parsenodes.h:2757
int lineno
Definition: plpgsql.h:456
PLpgSQL_function * plpgsql_compile_inline(char *proc_source)
Definition: pl_comp.c:847
unsigned int stmtid
Definition: plpgsql.h:745
PLpgSQL_plugin ** plpgsql_plugin_ptr
Definition: pl_handler.c:56
char * refname
Definition: plpgsql.h:313
struct PLpgSQL_execstate PLpgSQL_execstate
Param * expr_rw_param
Definition: plpgsql.h:246
ResourceOwner simple_eval_resowner
Definition: plpgsql.h:1082
struct PLpgSQL_stmt_call PLpgSQL_stmt_call
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:727
uint64 eval_processed
Definition: plpgsql.h:1094
struct PLpgSQL_stmt_commit PLpgSQL_stmt_commit
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:606
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:516
uint32 TransactionId
Definition: c.h:575
unsigned int stmtid
Definition: plpgsql.h:833
PLpgSQL_expr * expr
Definition: plpgsql.h:834
List * elsif_list
Definition: plpgsql.h:611
PLpgSQL_type * datatype
Definition: plpgsql.h:406
PLpgSQL_stmt * err_stmt
Definition: plpgsql.h:1098
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:699
PLpgSQL_datum_type dtype
Definition: plpgsql.h:311
int plpgsql_recognize_err_condition(const char *condname, bool allow_sqlstate)
Definition: pl_comp.c:2226
unsigned int stmtid
Definition: plpgsql.h:682
TypeName * origtypname
Definition: plpgsql.h:210
PLpgSQL_stmt_block * action
Definition: plpgsql.h:1021
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:552
PLpgSQL_type * plpgsql_parse_cwordtype(List *idents)
Definition: pl_comp.c:1679
void plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc, int *tok2_loc)
Definition: pl_scanner.c:439
TriggerData * trigdata
Definition: plpgsql.h:1035
void plpgsql_append_source_text(StringInfo buf, int startlocation, int endlocation)
Definition: pl_scanner.c:404
PLpgSQL_expr * default_val
Definition: plpgsql.h:295
unsigned int stmtid
Definition: plpgsql.h:845
PLpgSQL_expr * cursor_explicit_expr
Definition: plpgsql.h:327
List * stmts
Definition: plpgsql.h:622
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:539
PLpgSQL_variable * var
Definition: plpgsql.h:731
ResourceOwner tuple_store_owner
Definition: plpgsql.h:1056
IdentifierLookup
Definition: plpgsql.h:1176
PLpgSQL_rec * plpgsql_build_record(const char *refname, int lineno, PLpgSQL_type *dtype, Oid rectypeid, bool add2namespace)
Definition: pl_comp.c:1947
unsigned int stmtid
Definition: plpgsql.h:906
struct PLpgSQL_plugin PLpgSQL_plugin
struct PLpgSQL_stmt PLpgSQL_stmt
int plpgsql_base_yylex(void)
PLpgSQL_datum ** plpgsql_Datums
Definition: pl_comp.c:46
char * condname
Definition: plpgsql.h:472
PLpgSQL_type * datatype
Definition: plpgsql.h:320
PLpgSQL_datum_type
Definition: plpgsql.h:61
PLpgSQL_type * plpgsql_parse_wordtype(char *ident)
Definition: pl_comp.c:1613
struct PLpgSQL_stmt_exit PLpgSQL_stmt_exit
void plpgsql_subxact_cb(SubXactEvent event, SubTransactionId mySubid, SubTransactionId parentSubid, void *arg)
Definition: pl_exec.c:8399
PLpgSQL_type_type ttype
Definition: plpgsql.h:202
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:904
struct PLpgSQL_variable PLpgSQL_variable
bool isconst
Definition: plpgsql.h:315
TransactionId fn_xmin
Definition: plpgsql.h:981
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:338
MemoryContext cast_hash_context
Definition: plpgsql.h:1086
ExpandedRecordHeader * erh
Definition: plpgsql.h:414
PLpgSQL_expr * sqlstmt
Definition: plpgsql.h:907
struct PLpgSQL_condition * next
Definition: plpgsql.h:473
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:594
bool plpgsql_check_asserts
Definition: pl_handler.c:48
PLpgSQL_type * plpgsql_parse_wordrowtype(char *ident)
Definition: pl_comp.c:1799
uint64 tupdesc_id
Definition: plpgsql.h:212
struct PLpgSQL_stmt_dynfors PLpgSQL_stmt_dynfors
struct PLpgSQL_stmt_set PLpgSQL_stmt_set
PLpgSQL_expr * dynquery
Definition: plpgsql.h:781
PLpgSQL_recfield * plpgsql_build_recfield(PLpgSQL_rec *rec, const char *fldname)
Definition: pl_comp.c:2041
uint32 SubTransactionId
Definition: c.h:579
unsigned int stmtid
Definition: plpgsql.h:729
struct PLpgSQL_exception PLpgSQL_exception
void * plugin_info
Definition: plpgsql.h:1101
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:563
PLpgSQL_function * func
Definition: plpgsql.h:1033
PLpgSQL_expr * expr
Definition: plpgsql.h:531
PLpgSQL_expr * cond
Definition: plpgsql.h:621
unsigned int stmtid
Definition: plpgsql.h:809
char * ident
Definition: plpgsql.h:1155
unsigned int Oid
Definition: postgres_ext.h:31
void plpgsql_ns_additem(PLpgSQL_nsitem_type itemtype, int itemno, const char *name)
Definition: pl_funcs.c:92
int plpgsql_scanner_errposition(int location)
Definition: pl_scanner.c:472
unsigned int stmtid
Definition: plpgsql.h:669
RawParseMode
Definition: parser.h:37
struct PLpgSQL_type PLpgSQL_type
List * else_stmts
Definition: plpgsql.h:637
PLpgSQL_datum_type dtype
Definition: plpgsql.h:277
struct PLpgSQL_var PLpgSQL_var
char * refname
Definition: plpgsql.h:393
PLpgSQL_expr * lower
Definition: plpgsql.h:685
IdentifierLookup plpgsql_IdentifierLookup
Definition: pl_scanner.c:26
bool plpgsql_print_strict_params
Definition: pl_handler.c:46
int plpgsql_latest_lineno(void)
Definition: pl_scanner.c:572
PLpgSQL_getdiag_kind kind
Definition: plpgsql.h:585
SPIPlanPtr plan
Definition: plpgsql.h:222
unsigned int stmtid
Definition: plpgsql.h:657
signed int int32
Definition: c.h:417
PLpgSQL_raise_option_type opt_type
Definition: plpgsql.h:883
PLpgSQL_datum ** datums
Definition: plpgsql.h:1068
unsigned int stmtid
Definition: plpgsql.h:857
PLpgSQL_resolve_option resolve_option
Definition: plpgsql.h:1004
struct PLpgSQL_stmt_close PLpgSQL_stmt_close
PLpgSQL_expr * query
Definition: plpgsql.h:858
#define FUNC_MAX_ARGS
Datum plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo, EState *simple_eval_estate, ResourceOwner simple_eval_resowner, bool atomic)
Definition: pl_exec.c:466
struct PLpgSQL_stmt_fors PLpgSQL_stmt_fors
bool notnull
Definition: plpgsql.h:316
struct PLpgSQL_stmt_forc PLpgSQL_stmt_forc
void plpgsql_parser_setup(struct ParseState *pstate, PLpgSQL_expr *expr)
Definition: pl_comp.c:1078
void plpgsql_free_function_memory(PLpgSQL_function *func)
Definition: pl_funcs.c:737
int out_param_varno
Definition: plpgsql.h:999
Definition: dynahash.c:219
char * plpgsql_error_funcname
Definition: pl_comp.c:49
int cursor_explicit_argrow
Definition: plpgsql.h:328
Bitmapset * paramnos
Definition: plpgsql.h:223
TupleDesc tuple_store_desc
Definition: plpgsql.h:1054
PLpgSQL_expr * expr
Definition: plpgsql.h:577
unsigned int stmtid
Definition: plpgsql.h:632
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:667
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:920
ParamListInfo paramLI
Definition: plpgsql.h:1078
PLpgSQL_expr * expr
Definition: plpgsql.h:846
Oid plpgsql_exec_get_datum_type(PLpgSQL_execstate *estate, PLpgSQL_datum *datum)
Definition: pl_exec.c:5460
void plpgsql_scanner_init(const char *str)
Definition: pl_scanner.c:586
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:868
CachedPlanSource * expr_simple_plansource
Definition: plpgsql.h:254
MemoryContext tuple_store_cxt
Definition: plpgsql.h:1055
unsigned int stmtid
Definition: plpgsql.h:503
const char * plpgsql_getdiag_kindname(PLpgSQL_getdiag_kind kind)
Definition: pl_funcs.c:302
PLpgSQL_promise_type
Definition: plpgsql.h:73
PLpgSQL_var * var
Definition: plpgsql.h:684
char ** fieldnames
Definition: plpgsql.h:382
struct PLpgSQL_execstate * cur_estate
Definition: plpgsql.h:1024
EState * simple_eval_estate
Definition: plpgsql.h:1081
bool plpgsql_parse_word(char *word1, const char *yytxt, bool lookup, PLwdatum *wdatum, PLword *word)
Definition: pl_comp.c:1393
struct PLpgSQL_func_hashkey PLpgSQL_func_hashkey
void _PG_init(void)
Definition: auth_delay.c:56
struct PLpgSQL_stmt_while PLpgSQL_stmt_while
PLpgSQL_expr * message
Definition: plpgsql.h:896
PLpgSQL_variable * target
Definition: plpgsql.h:912
PLpgSQL_label_type
Definition: plpgsql.h:51
PLpgSQL_expr * default_val
Definition: plpgsql.h:317
unsigned long use_count
Definition: plpgsql.h:1025
int plpgsql_yylex(void)
Definition: pl_scanner.c:146
List * idents
Definition: plpgsql.h:1161
void plpgsql_exec_get_datum_type_info(PLpgSQL_execstate *estate, PLpgSQL_datum *datum, Oid *typeId, int32 *typMod, Oid *collation)
Definition: pl_exec.c:5545
struct PLpgSQL_nsitem * ns
Definition: plpgsql.h:229
bool fn_readonly
Definition: plpgsql.h:994
struct PLpgSQL_stmt_foreach_a PLpgSQL_stmt_foreach_a
static char * buf
Definition: pg_test_fsync.c:68
struct PLword PLword
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:892
void plpgsql_adddatum(PLpgSQL_datum *newdatum)
Definition: pl_comp.c:2330
PLpgSQL_variable * var
Definition: plpgsql.h:716
int cursor_options
Definition: plpgsql.h:329
struct PLpgSQL_stmt_return PLpgSQL_stmt_return
void plpgsql_push_back_token(int token)
Definition: pl_scanner.c:370
struct PLpgSQL_stmt_fetch PLpgSQL_stmt_fetch
Definition: zic.c:301
ReturnSetInfo * rsi
Definition: plpgsql.h:1057
Expr * expr_simple_expr
Definition: plpgsql.h:232
uint32 LocalTransactionId
Definition: c.h:577
MemoryContext fn_cxt
Definition: plpgsql.h:986
struct PLpgSQL_case_when PLpgSQL_case_when
List * idents
Definition: plpgsql.h:1169
PLpgSQL_expr * expr
Definition: plpgsql.h:646
List * case_when_list
Definition: plpgsql.h:635
PLpgSQL_function * plpgsql_curr_compile
Definition: pl_comp.c:53
bool freeval
Definition: plpgsql.h:335
Tuplestorestate * tuple_store
Definition: plpgsql.h:1053
PLpgSQL_expr * query
Definition: plpgsql.h:750
void plpgsql_yyerror(const char *message) pg_attribute_noreturn()
Definition: pl_scanner.c:499
unsigned int stmtid
Definition: plpgsql.h:608
int * varnos
Definition: plpgsql.h:383
bool fn_retisdomain
Definition: plpgsql.h:992
uint64 rectupledescid
Definition: plpgsql.h:429
Oid fn_input_collation
Definition: plpgsql.h:984
const char * plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:232
bool typbyval
Definition: plpgsql.h:204
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:843
struct PLpgSQL_datum PLpgSQL_datum
Oid collation
Definition: plpgsql.h:206
unsigned int stmtid
Definition: plpgsql.h:894
PLpgSQL_expr * expr
Definition: plpgsql.h:542
unsigned int stmtid
Definition: plpgsql.h:576
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:818
ErrorData * cur_error
Definition: plpgsql.h:1051
SubXactEvent
Definition: xact.h:127
ExprState * expr_simple_state
Definition: plpgsql.h:264
void plpgsql_HashTableInit(void)
Definition: pl_comp.c:2586
bool expr_simple_mutable
Definition: plpgsql.h:235
MemoryContext stmt_mcontext_parent
Definition: plpgsql.h:1090
bool typisarray
Definition: plpgsql.h:207
int target_param
Definition: plpgsql.h:245
PLpgSQL_stmt_type
Definition: plpgsql.h:102
struct PLpgSQL_exception_block PLpgSQL_exception_block
CachedPlan * expr_simple_plan
Definition: plpgsql.h:255
struct PLpgSQL_function PLpgSQL_function
uintptr_t Datum
Definition: postgres.h:367
struct PLpgSQL_rec PLpgSQL_rec
bool quoted
Definition: plpgsql.h:1156
PLpgSQL_getdiag_kind
Definition: plpgsql.h:148
ExpandedRecordFieldInfo finfo
Definition: plpgsql.h:430
static char * label
PLpgSQL_nsitem * plpgsql_ns_lookup(PLpgSQL_nsitem *ns_cur, bool localmode, const char *name1, const char *name2, const char *name3, int *names_used)
Definition: pl_funcs.c:130
PLpgSQL_datum_type dtype
Definition: plpgsql.h:422
EventTriggerData * evtrigdata
Definition: plpgsql.h:1036
PLpgSQL_expr * cond
Definition: plpgsql.h:823
LocalTransactionId expr_simple_lxid
Definition: plpgsql.h:266
const char * err_text
Definition: plpgsql.h:1099
struct PLpgSQL_recfield PLpgSQL_recfield
unsigned int stmtid
Definition: plpgsql.h:922
PLpgSQL_expr * query
Definition: plpgsql.h:780
struct PLpgSQL_stmt_if PLpgSQL_stmt_if
Datum value
Definition: plpgsql.h:333
unsigned int stmtid
Definition: plpgsql.h:870
bool isconst
Definition: plpgsql.h:395
struct PLpgSQL_function * func
Definition: plpgsql.h:226
PLpgSQL_variable * var
Definition: plpgsql.h:747
PLpgSQL_condition * conditions
Definition: plpgsql.h:492
PLpgSQL_trigtype fn_is_trigger
Definition: plpgsql.h:983
struct PLpgSQL_nsitem * prev
Definition: plpgsql.h:446
unsigned int stmtid
Definition: plpgsql.h:530
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:528
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:807
unsigned int stmtid
Definition: plpgsql.h:541
struct PLpgSQL_row PLpgSQL_row
int nfields
Definition: plpgsql.h:381
int lineno
Definition: plpgsql.h:314
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:501
void plpgsql_ns_init(void)
Definition: pl_funcs.c:43
bool plpgsql_parse_dblword(char *word1, char *word2, PLwdatum *wdatum, PLcword *cword)
Definition: pl_comp.c:1448
PLpgSQL_exception_block * exceptions
Definition: plpgsql.h:508
bool isconst
Definition: plpgsql.h:369
struct PLpgSQL_stmt_case PLpgSQL_stmt_case
struct PLpgSQL_stmt_perform PLpgSQL_stmt_perform
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:574
ExprContext * eval_econtext
Definition: plpgsql.h:1095
size_t Size
Definition: c.h:528
char * fn_signature
Definition: plpgsql.h:979
List * else_body
Definition: plpgsql.h:612
PLpgSQL_type_type
Definition: plpgsql.h:92
PLpgSQL_datum * datum
Definition: plpgsql.h:1166
char * typname
Definition: plpgsql.h:200
unsigned int stmtid
Definition: plpgsql.h:761
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:743
PLpgSQL_expr * step
Definition: plpgsql.h:687
PLpgSQL_expr * t_expr
Definition: plpgsql.h:633
char * refname
Definition: plpgsql.h:291
unsigned int stmtid
Definition: plpgsql.h:820
PLpgSQL_expr * dynquery
Definition: plpgsql.h:859
PLpgSQL_datum_type dtype
Definition: plpgsql.h:289
PLpgSQL_variable * var
Definition: plpgsql.h:703
PLpgSQL_expr * expr
Definition: plpgsql.h:797
bool plpgsql_DumpExecTree
Definition: pl_comp.c:50
const char * name
Definition: encode.c:515
unsigned int stmtid
Definition: plpgsql.h:554
PLpgSQL_expr * expr
Definition: plpgsql.h:520
static void word(struct vars *, int, struct state *, struct state *)
Definition: regcomp.c:1246
struct PLpgSQL_condition PLpgSQL_condition
PLpgSQL_expr * expr
Definition: plpgsql.h:884
MemoryContext datum_context
Definition: plpgsql.h:1070
char typtype
Definition: plpgsql.h:205
bool plpgsql_parse_tripword(char *word1, char *word2, char *word3, PLwdatum *wdatum, PLcword *cword)
Definition: pl_comp.c:1529
bool plpgsql_check_syntax
Definition: pl_comp.c:51
struct PLpgSQL_nsitem PLpgSQL_nsitem
struct PLpgSQL_raise_option PLpgSQL_raise_option
PLpgSQL_variable * plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type *dtype, bool add2namespace)
Definition: pl_comp.c:1884
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:655
PLpgSQL_type * plpgsql_build_datatype(Oid typeOid, int32 typmod, Oid collation, TypeName *origtypname)
Definition: pl_comp.c:2088
PLpgSQL_variable * target
Definition: plpgsql.h:544
bool quoted
Definition: plpgsql.h:1168
int32 expr_simple_typmod
Definition: plpgsql.h:234
char * ident
Definition: plpgsql.h:1167
PLpgSQL_nsitem * plpgsql_ns_lookup_label(PLpgSQL_nsitem *ns_cur, const char *name)
Definition: pl_funcs.c:195
struct PLpgSQL_stmt_assign PLpgSQL_stmt_assign
int32 atttypmod
Definition: plpgsql.h:208
unsigned int stmtid
Definition: plpgsql.h:776
RawParseMode parseMode
Definition: plpgsql.h:221
PLpgSQL_expr * argquery
Definition: plpgsql.h:779
PLpgSQL_type * plpgsql_parse_cwordrowtype(List *idents)
Definition: pl_comp.c:1836
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:439
struct PLpgSQL_stmt_execsql PLpgSQL_stmt_execsql
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:712
struct PLpgSQL_diag_item PLpgSQL_diag_item
TupleDesc rowtupdesc
Definition: plpgsql.h:379
unsigned int stmtid
Definition: plpgsql.h:701
bool fn_retistuple
Definition: plpgsql.h:991
PLpgSQL_expr * argquery
Definition: plpgsql.h:735
void plpgsql_ns_push(const char *label, PLpgSQL_label_type label_type)
Definition: pl_funcs.c:54
void * arg
MemoryContext stmt_mcontext
Definition: plpgsql.h:1089
PLpgSQL_trigtype
Definition: plpgsql.h:967
void plpgsql_exec_event_trigger(PLpgSQL_function *func, EventTriggerData *trigdata)
Definition: pl_exec.c:1140
PLpgSQL_expr * upper
Definition: plpgsql.h:686
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:455
PLpgSQL_resolve_option
Definition: plpgsql.h:183
struct PLwdatum PLwdatum
int plpgsql_location_to_lineno(int location)
Definition: pl_scanner.c:538
Size copiable_size
Definition: plpgsql.h:1018
struct PLpgSQL_stmt_assert PLpgSQL_stmt_assert
LocalTransactionId expr_simple_plan_lxid
Definition: plpgsql.h:256
bool expr_simple_in_use
Definition: plpgsql.h:265
struct PLpgSQL_if_elsif PLpgSQL_if_elsif
struct PLpgSQL_stmt_return_next PLpgSQL_stmt_return_next
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:630
PLpgSQL_expr * query
Definition: plpgsql.h:719
int16 typlen
Definition: plpgsql.h:203
void plpgsql_xact_cb(XactEvent event, void *arg)
Definition: pl_exec.c:8357
char * exitlabel
Definition: plpgsql.h:1049
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:855
PLpgSQL_variable * target
Definition: plpgsql.h:793
PLpgSQL_expr * cond
Definition: plpgsql.h:895
PLpgSQL_variable * target
Definition: plpgsql.h:926
int plpgsql_peek(void)
Definition: pl_scanner.c:420
struct PLpgSQL_stmt_loop PLpgSQL_stmt_loop
Oid rectypeid
Definition: plpgsql.h:407
bool plpgsql_token_is_unreserved_keyword(int token)
Definition: pl_scanner.c:387
struct PLpgSQL_stmt_rollback PLpgSQL_stmt_rollback
unsigned int stmtid
Definition: plpgsql.h:463
MemoryContext plpgsql_compile_tmp_cxt
Definition: pl_comp.c:56
int plpgsql_add_initdatums(int **varnos)
Definition: pl_comp.c:2391
PLpgSQL_expr * default_val
Definition: plpgsql.h:397
bool notnull
Definition: plpgsql.h:396
int plpgsql_extra_errors
Definition: pl_handler.c:53
PLpgSQL_condition * plpgsql_parse_err_condition(char *condname)
Definition: pl_comp.c:2262
Definition: pg_list.h:50
int plpgsql_variable_conflict
Definition: pl_handler.c:44
char * fieldname
Definition: plpgsql.h:426
int lineno
Definition: plpgsql.h:394
PLpgSQL_function * plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator)
Definition: pl_comp.c:136
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:831
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:790
void plpgsql_dumptree(PLpgSQL_function *func)
Definition: pl_funcs.c:1621
void plpgsql_ns_pop(void)
Definition: pl_funcs.c:67
PLpgSQL_datum_type dtype
Definition: plpgsql.h:365
PLpgSQL_stmt_block * plpgsql_parse_result
Definition: pl_comp.c:42
PLpgSQL_expr * default_val
Definition: plpgsql.h:371
void plpgsql_scanner_finish(void)
Definition: pl_scanner.c:613
struct PLpgSQL_expr PLpgSQL_expr
Oid expr_simple_type
Definition: plpgsql.h:233
int firstfield
Definition: plpgsql.h:409
HeapTuple plpgsql_exec_trigger(PLpgSQL_function *func, TriggerData *trigdata)
Definition: pl_exec.c:900
PLpgSQL_nsitem_type
Definition: plpgsql.h:41
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:759
int lineno
Definition: plpgsql.h:368
bool isnull
Definition: plpgsql.h:334
unsigned int stmtid
Definition: plpgsql.h:596
struct PLcword PLcword
bool returns_multiple_rows
Definition: plpgsql.h:799
bool notnull
Definition: plpgsql.h:370
Oid typoid
Definition: plpgsql.h:201
struct PLpgSQL_stmt_open PLpgSQL_stmt_open