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