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