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