PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2025, 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"
21#include "commands/trigger.h"
22#include "executor/spi.h"
24#include "utils/funccache.h"
25#include "utils/typcache.h"
26
27
28/**********************************************************************
29 * Definitions
30 **********************************************************************/
31
32/* define our text domain for translations */
33#undef TEXTDOMAIN
34#define TEXTDOMAIN PG_TEXTDOMAIN("plpgsql")
35
36#undef _
37#define _(x) dgettext(TEXTDOMAIN, x)
38
39/*
40 * Compiler's namespace item types
41 */
43{
44 PLPGSQL_NSTYPE_LABEL, /* block label */
45 PLPGSQL_NSTYPE_VAR, /* scalar variable */
46 PLPGSQL_NSTYPE_REC, /* composite variable */
48
49/*
50 * A PLPGSQL_NSTYPE_LABEL stack entry must be one of these types
51 */
53{
54 PLPGSQL_LABEL_BLOCK, /* DECLARE/BEGIN block */
55 PLPGSQL_LABEL_LOOP, /* looping construct */
56 PLPGSQL_LABEL_OTHER, /* anything else */
58
59/*
60 * Datum array node types
61 */
63{
70
71/*
72 * DTYPE_PROMISE datums have these possible ways of computing the promise
73 */
75{
76 PLPGSQL_PROMISE_NONE = 0, /* not a promise, or promise satisfied */
89
90/*
91 * Variants distinguished in PLpgSQL_type structs
92 */
94{
95 PLPGSQL_TTYPE_SCALAR, /* scalar types and domains */
96 PLPGSQL_TTYPE_REC, /* composite types, including RECORD */
97 PLPGSQL_TTYPE_PSEUDO, /* pseudotypes */
99
100/*
101 * Execution tree node types
102 */
104{
133
134/*
135 * Execution node return codes
136 */
137enum
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 * Status of optimization of assignment to a read/write expanded object
193 */
194typedef enum PLpgSQL_rwopt
195{
196 PLPGSQL_RWOPT_UNKNOWN = 0, /* applicability not determined yet */
197 PLPGSQL_RWOPT_NOPE, /* cannot do any optimization */
198 PLPGSQL_RWOPT_TRANSFER, /* transfer the old value into expr state */
199 PLPGSQL_RWOPT_INPLACE, /* pass value as R/W to top-level function */
201
202
203/**********************************************************************
204 * Node and structure definitions
205 **********************************************************************/
206
207/*
208 * Postgres data type
209 */
210typedef struct PLpgSQL_type
211{
212 char *typname; /* (simple) name of the type */
213 Oid typoid; /* OID of the data type */
214 PLpgSQL_type_type ttype; /* PLPGSQL_TTYPE_ code */
215 int16 typlen; /* stuff copied from its pg_type entry */
218 Oid collation; /* from pg_type, but can be overridden */
219 bool typisarray; /* is "true" array, or domain over one */
220 int32 atttypmod; /* typmod (taken from someplace else) */
221 /* Remaining fields are used only for named composite types (not RECORD) */
222 TypeName *origtypname; /* type name as written by user */
223 TypeCacheEntry *tcache; /* typcache entry for composite type */
224 uint64 tupdesc_id; /* last-seen tupdesc identifier */
226
227/*
228 * SQL Query to plan and execute
229 */
230typedef struct PLpgSQL_expr
231{
232 char *query; /* query string, verbatim from function body */
233 RawParseMode parseMode; /* raw_parser() mode to use */
234 struct PLpgSQL_function *func; /* function containing this expr */
235 struct PLpgSQL_nsitem *ns; /* namespace chain visible to this expr */
236
237 /*
238 * These fields are used to help optimize assignments to expanded-datum
239 * variables. If this expression is the source of an assignment to a
240 * simple variable, target_param holds that variable's dno (else it's -1),
241 * and target_is_local indicates whether the target is declared inside the
242 * closest exception block containing the assignment.
243 */
244 int target_param; /* dno of assign target, or -1 if none */
245 bool target_is_local; /* is it within nearest exception block? */
246
247 /*
248 * Fields above are set during plpgsql parsing. Remaining fields are left
249 * as zeroes/NULLs until we first parse/plan the query.
250 */
251 SPIPlanPtr plan; /* plan, or NULL if not made yet */
252 Bitmapset *paramnos; /* all dnos referenced by this query */
253
254 /* fields for "simple expression" fast-path execution: */
255 Expr *expr_simple_expr; /* NULL means not a simple expr */
256 Oid expr_simple_type; /* result type Oid, if simple */
257 int32 expr_simple_typmod; /* result typmod, if simple */
258 bool expr_simple_mutable; /* true if simple expr is mutable */
259
260 /*
261 * expr_rwopt tracks whether we have determined that assignment to a
262 * read/write expanded object (stored in the target_param datum) can be
263 * optimized by passing it to the expr as a read/write expanded-object
264 * pointer. If so, expr_rw_param identifies the specific Param that
265 * should emit a read/write pointer; any others will emit read-only
266 * pointers.
267 */
268 PLpgSQL_rwopt expr_rwopt; /* can we apply R/W optimization? */
269 Param *expr_rw_param; /* read/write Param within expr, if any */
270
271 /*
272 * If the expression was ever determined to be simple, we remember its
273 * CachedPlanSource and CachedPlan here. If expr_simple_plan_lxid matches
274 * current LXID, then we hold a refcount on expr_simple_plan in the
275 * current transaction. Otherwise we need to get one before re-using it.
276 */
277 CachedPlanSource *expr_simple_plansource; /* extracted from "plan" */
278 CachedPlan *expr_simple_plan; /* extracted from "plan" */
280
281 /*
282 * if expr is simple AND prepared in current transaction,
283 * expr_simple_state and expr_simple_in_use are valid. Test validity by
284 * seeing if expr_simple_lxid matches current LXID. (If not,
285 * expr_simple_state probably points at garbage!)
286 */
287 ExprState *expr_simple_state; /* eval tree for expr_simple_expr */
288 bool expr_simple_in_use; /* true if eval tree is active */
291
292/*
293 * Generic datum array item
294 *
295 * PLpgSQL_datum is the common supertype for PLpgSQL_var, PLpgSQL_row,
296 * PLpgSQL_rec, and PLpgSQL_recfield.
297 */
298typedef struct PLpgSQL_datum
299{
301 int dno;
303
304/*
305 * Scalar or composite variable
306 *
307 * The variants PLpgSQL_var, PLpgSQL_row, and PLpgSQL_rec share these
308 * fields.
309 */
310typedef struct PLpgSQL_variable
311{
313 int dno;
314 char *refname;
320
321/*
322 * Scalar variable
323 *
324 * DTYPE_VAR and DTYPE_PROMISE datums both use this struct type.
325 * A PROMISE datum works exactly like a VAR datum for most purposes,
326 * but if it is read without having previously been assigned to, then
327 * a special "promised" value is computed and assigned to the datum
328 * before the read is performed. This technique avoids the overhead of
329 * computing the variable's value in cases where we expect that many
330 * functions will never read it.
331 */
332typedef struct PLpgSQL_var
333{
335 int dno;
336 char *refname;
341 /* end of PLpgSQL_variable fields */
342
344
345 /*
346 * Variables declared as CURSOR FOR <query> are mostly like ordinary
347 * scalar variables of type refcursor, but they have these additional
348 * properties:
349 */
353
354 /* Fields below here can change at runtime */
355
357 bool isnull;
359
360 /*
361 * The promise field records which "promised" value to assign if the
362 * promise must be honored. If it's a normal variable, or the promise has
363 * been fulfilled, this is PLPGSQL_PROMISE_NONE.
364 */
367
368/*
369 * Row variable - this represents one or more variables that are listed in an
370 * INTO clause, FOR-loop targetlist, cursor argument list, etc. We also use
371 * a row to represent a function's OUT parameters when there's more than one.
372 *
373 * Note that there's no way to name the row as such from PL/pgSQL code,
374 * so many functions don't need to support these.
375 *
376 * That also means that there's no real name for the row variable, so we
377 * conventionally set refname to "(unnamed row)". We could leave it NULL,
378 * but it's too convenient to be able to assume that refname is valid in
379 * all variants of PLpgSQL_variable.
380 *
381 * isconst, notnull, and default_val are unsupported (and hence
382 * always zero/null) for a row. The member variables of a row should have
383 * been checked to be writable at compile time, so isconst is correctly set
384 * to false. notnull and default_val aren't applicable.
385 */
386typedef struct PLpgSQL_row
387{
389 int dno;
390 char *refname;
395 /* end of PLpgSQL_variable fields */
396
397 /*
398 * rowtupdesc is only set up if we might need to convert the row into a
399 * composite datum, which currently only happens for OUT parameters.
400 * Otherwise it is NULL.
401 */
403
406 int *varnos;
408
409/*
410 * Record variable (any composite type, including RECORD)
411 */
412typedef struct PLpgSQL_rec
413{
415 int dno;
416 char *refname;
421 /* end of PLpgSQL_variable fields */
422
423 /*
424 * Note: for non-RECORD cases, we may from time to time re-look-up the
425 * composite type, using datatype->origtypname. That can result in
426 * changing rectypeid.
427 */
428
429 PLpgSQL_type *datatype; /* can be NULL, if rectypeid is RECORDOID */
430 Oid rectypeid; /* declared type of variable */
431 /* RECFIELDs for this record are chained together for easy access */
432 int firstfield; /* dno of first RECFIELD, or -1 if none */
433
434 /* Fields below here can change at runtime */
435
436 /* We always store record variables as "expanded" records */
439
440/*
441 * Field in record
442 */
443typedef struct PLpgSQL_recfield
444{
446 int dno;
447 /* end of PLpgSQL_datum fields */
448
449 char *fieldname; /* name of field */
450 int recparentno; /* dno of parent record */
451 int nextfield; /* dno of next child, or -1 if none */
452 uint64 rectupledescid; /* record's tupledesc ID as of last lookup */
453 ExpandedRecordFieldInfo finfo; /* field's attnum and type info */
454 /* if rectupledescid == INVALID_TUPLEDESC_IDENTIFIER, finfo isn't valid */
456
457/*
458 * Item in the compilers namespace tree
459 */
460typedef struct PLpgSQL_nsitem
461{
463
464 /*
465 * For labels, itemno is a value of enum PLpgSQL_label_type. For other
466 * itemtypes, itemno is the associated PLpgSQL_datum's dno.
467 */
470 char name[FLEXIBLE_ARRAY_MEMBER]; /* nul-terminated string */
472
473/*
474 * Generic execution node
475 */
476typedef struct PLpgSQL_stmt
477{
480
481 /*
482 * Unique statement ID in this function (starting at 1; 0 is invalid/not
483 * set). This can be used by a profiler as the index for an array of
484 * per-statement metrics.
485 */
486 unsigned int stmtid;
488
489/*
490 * One EXCEPTION condition name
491 */
492typedef struct PLpgSQL_condition
493{
494 int sqlerrstate; /* SQLSTATE code, or PLPGSQL_OTHERS */
495 char *condname; /* condition name (for debugging) */
498
499/* This value mustn't match any possible output of MAKE_SQLSTATE() */
500#define PLPGSQL_OTHERS (-1)
501
502/*
503 * EXCEPTION block
504 */
506{
509 List *exc_list; /* List of WHEN clauses */
511
512/*
513 * One EXCEPTION ... WHEN clause
514 */
515typedef struct PLpgSQL_exception
516{
519 List *action; /* List of statements */
521
522/*
523 * Block of statements
524 */
525typedef struct PLpgSQL_stmt_block
526{
529 unsigned int stmtid;
530 char *label;
531 List *body; /* List of statements */
532 int n_initvars; /* Length of initvarnos[] */
533 int *initvarnos; /* dnos of variables declared in this block */
536
537/*
538 * Assign statement
539 */
541{
544 unsigned int stmtid;
545 int varno;
548
549/*
550 * PERFORM statement
551 */
553{
556 unsigned int stmtid;
559
560/*
561 * CALL statement
562 */
563typedef struct PLpgSQL_stmt_call
564{
567 unsigned int stmtid;
572
573/*
574 * COMMIT statement
575 */
577{
580 unsigned int stmtid;
581 bool chain;
583
584/*
585 * ROLLBACK statement
586 */
588{
591 unsigned int stmtid;
592 bool chain;
594
595/*
596 * GET DIAGNOSTICS item
597 */
598typedef struct PLpgSQL_diag_item
599{
600 PLpgSQL_getdiag_kind kind; /* id for diagnostic value desired */
601 int target; /* where to assign it */
603
604/*
605 * GET DIAGNOSTICS statement
606 */
608{
611 unsigned int stmtid;
612 bool is_stacked; /* STACKED or CURRENT diagnostics area? */
613 List *diag_items; /* List of PLpgSQL_diag_item */
615
616/*
617 * IF statement
618 */
619typedef struct PLpgSQL_stmt_if
620{
623 unsigned int stmtid;
624 PLpgSQL_expr *cond; /* boolean expression for THEN */
625 List *then_body; /* List of statements */
626 List *elsif_list; /* List of PLpgSQL_if_elsif structs */
627 List *else_body; /* List of statements */
629
630/*
631 * one ELSIF arm of IF statement
632 */
633typedef struct PLpgSQL_if_elsif
634{
636 PLpgSQL_expr *cond; /* boolean expression for this case */
637 List *stmts; /* List of statements */
639
640/*
641 * CASE statement
642 */
643typedef struct PLpgSQL_stmt_case
644{
647 unsigned int stmtid;
648 PLpgSQL_expr *t_expr; /* test expression, or NULL if none */
649 int t_varno; /* var to store test expression value into */
650 List *case_when_list; /* List of PLpgSQL_case_when structs */
651 bool have_else; /* flag needed because list could be empty */
652 List *else_stmts; /* List of statements */
654
655/*
656 * one arm of CASE statement
657 */
658typedef struct PLpgSQL_case_when
659{
661 PLpgSQL_expr *expr; /* boolean expression for this case */
662 List *stmts; /* List of statements */
664
665/*
666 * Unconditional LOOP statement
667 */
668typedef struct PLpgSQL_stmt_loop
669{
672 unsigned int stmtid;
673 char *label;
674 List *body; /* List of statements */
676
677/*
678 * WHILE cond LOOP statement
679 */
680typedef struct PLpgSQL_stmt_while
681{
684 unsigned int stmtid;
685 char *label;
687 List *body; /* List of statements */
689
690/*
691 * FOR statement with integer loopvar
692 */
693typedef struct PLpgSQL_stmt_fori
694{
697 unsigned int stmtid;
698 char *label;
702 PLpgSQL_expr *step; /* NULL means default (ie, BY 1) */
704 List *body; /* List of statements */
706
707/*
708 * PLpgSQL_stmt_forq represents a FOR statement running over a SQL query.
709 * It is the common supertype of PLpgSQL_stmt_fors, PLpgSQL_stmt_forc
710 * and PLpgSQL_stmt_dynfors.
711 */
712typedef struct PLpgSQL_stmt_forq
713{
716 unsigned int stmtid;
717 char *label;
718 PLpgSQL_variable *var; /* Loop variable (record or row) */
719 List *body; /* List of statements */
721
722/*
723 * FOR statement running over SELECT
724 */
725typedef struct PLpgSQL_stmt_fors
726{
729 unsigned int stmtid;
730 char *label;
731 PLpgSQL_variable *var; /* Loop variable (record or row) */
732 List *body; /* List of statements */
733 /* end of fields that must match PLpgSQL_stmt_forq */
736
737/*
738 * FOR statement running over cursor
739 */
740typedef struct PLpgSQL_stmt_forc
741{
744 unsigned int stmtid;
745 char *label;
746 PLpgSQL_variable *var; /* Loop variable (record or row) */
747 List *body; /* List of statements */
748 /* end of fields that must match PLpgSQL_stmt_forq */
750 PLpgSQL_expr *argquery; /* cursor arguments if any */
752
753/*
754 * FOR statement running over EXECUTE
755 */
757{
760 unsigned int stmtid;
761 char *label;
762 PLpgSQL_variable *var; /* Loop variable (record or row) */
763 List *body; /* List of statements */
764 /* end of fields that must match PLpgSQL_stmt_forq */
766 List *params; /* USING expressions */
768
769/*
770 * FOREACH item in array loop
771 */
773{
776 unsigned int stmtid;
777 char *label;
778 int varno; /* loop target variable */
779 int slice; /* slice dimension, or 0 */
780 PLpgSQL_expr *expr; /* array expression */
781 List *body; /* List of statements */
783
784/*
785 * OPEN a curvar
786 */
787typedef struct PLpgSQL_stmt_open
788{
791 unsigned int stmtid;
797 List *params; /* USING expressions */
799
800/*
801 * FETCH or MOVE statement
802 */
803typedef struct PLpgSQL_stmt_fetch
804{
807 unsigned int stmtid;
808 PLpgSQL_variable *target; /* target (record or row) */
809 int curvar; /* cursor variable to fetch from */
810 FetchDirection direction; /* fetch direction */
811 long how_many; /* count, if constant (expr is NULL) */
812 PLpgSQL_expr *expr; /* count, if expression */
813 bool is_move; /* is this a fetch or move? */
814 bool returns_multiple_rows; /* can return more than one row? */
816
817/*
818 * CLOSE curvar
819 */
820typedef struct PLpgSQL_stmt_close
821{
824 unsigned int stmtid;
827
828/*
829 * EXIT or CONTINUE statement
830 */
831typedef struct PLpgSQL_stmt_exit
832{
835 unsigned int stmtid;
836 bool is_exit; /* Is this an exit or a continue? */
837 char *label; /* NULL if it's an unlabeled EXIT/CONTINUE */
840
841/*
842 * RETURN statement
843 */
845{
848 unsigned int stmtid;
852
853/*
854 * RETURN NEXT statement
855 */
857{
860 unsigned int stmtid;
864
865/*
866 * RETURN QUERY statement
867 */
869{
872 unsigned int stmtid;
873 PLpgSQL_expr *query; /* if static query */
874 PLpgSQL_expr *dynquery; /* if dynamic query (RETURN QUERY EXECUTE) */
875 List *params; /* USING arguments for dynamic query */
877
878/*
879 * RAISE statement
880 */
881typedef struct PLpgSQL_stmt_raise
882{
885 unsigned int stmtid;
887 char *condname; /* condition name, SQLSTATE, or NULL */
888 char *message; /* old-style message format literal, or NULL */
889 List *params; /* list of expressions for old-style message */
890 List *options; /* list of PLpgSQL_raise_option */
892
893/*
894 * RAISE statement option
895 */
897{
901
902/*
903 * ASSERT statement
904 */
906{
909 unsigned int stmtid;
913
914/*
915 * Generic SQL statement to execute
916 */
918{
921 unsigned int stmtid;
923 bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE/MERGE? */
924 bool mod_stmt_set; /* is mod_stmt valid yet? */
925 bool into; /* INTO supplied? */
926 bool strict; /* INTO STRICT flag */
927 PLpgSQL_variable *target; /* INTO target (record or row) */
929
930/*
931 * Dynamic SQL string to execute
932 */
934{
937 unsigned int stmtid;
938 PLpgSQL_expr *query; /* string expression */
939 bool into; /* INTO supplied? */
940 bool strict; /* INTO STRICT flag */
941 PLpgSQL_variable *target; /* INTO target (record or row) */
942 List *params; /* USING expressions */
944
945/*
946 * Trigger type
947 */
949{
954
955/*
956 * Complete compiled function
957 */
958typedef struct PLpgSQL_function
959{
960 CachedFunction cfunc; /* fields managed by funccache.c */
961
967
976
983
985
987
988 /* extra checks */
991
992 /* the datums representing the function's local variables */
995 Size copiable_size; /* space for locally instantiated datums */
996
997 /* function body parsetree */
999
1000 /* data derived while parsing body */
1001 unsigned int nstatements; /* counter for assigning stmtids */
1002 bool requires_procedure_resowner; /* contains CALL or DO? */
1003 bool has_exception_block; /* contains BEGIN...EXCEPTION? */
1004
1005 /* this field changes when the function is used */
1008
1009/*
1010 * Runtime execution data
1011 */
1012typedef struct PLpgSQL_execstate
1013{
1014 PLpgSQL_function *func; /* function being executed */
1015
1016 TriggerData *trigdata; /* if regular trigger, data about firing */
1017 EventTriggerData *evtrigdata; /* if event trigger, data about firing */
1018
1021 Oid rettype; /* type of current retval */
1022
1023 Oid fn_rettype; /* info about declared function rettype */
1026
1029
1030 char *exitlabel; /* the "target" label of the current EXIT or
1031 * CONTINUE stmt, if any */
1032 ErrorData *cur_error; /* current exception handler's error */
1033
1034 Tuplestorestate *tuple_store; /* SRFs accumulate results here */
1035 TupleDesc tuple_store_desc; /* descriptor for tuples in tuple_store */
1039
1041
1042 /*
1043 * The datums representing the function's local variables. Some of these
1044 * are local storage in this execstate, but some just point to the shared
1045 * copy belonging to the PLpgSQL_function, depending on whether or not we
1046 * need any per-execution state for the datum's dtype.
1047 */
1050 /* context containing variable values (same as func's SPI_proc context) */
1052
1053 /*
1054 * paramLI is what we use to pass local variable values to the executor.
1055 * It does not have a ParamExternData array; we just dynamically
1056 * instantiate parameter data as needed. By convention, PARAM_EXTERN
1057 * Params have paramid equal to the dno of the referenced local variable.
1058 */
1060
1061 /* EState and resowner to use for "simple" expression evaluation */
1064
1065 /* if running nonatomic procedure or DO block, resowner to use for CALL */
1067
1068 /* lookup table to use for executing type casts */
1070
1071 /* memory context for statement-lifespan temporary values */
1072 MemoryContext stmt_mcontext; /* current stmt context, or NULL if none */
1073 MemoryContext stmt_mcontext_parent; /* parent of current context */
1074
1075 /* temporary state for results from evaluation of query or expr */
1078 ExprContext *eval_econtext; /* for executing simple expressions */
1079
1080 /* status information for error context reporting */
1081 PLpgSQL_stmt *err_stmt; /* current stmt */
1082 PLpgSQL_variable *err_var; /* current variable, if in a DECLARE section */
1083 const char *err_text; /* additional state info */
1084
1085 void *plugin_info; /* reserved for use by optional plugin */
1087
1088/*
1089 * A PLpgSQL_plugin structure represents an instrumentation plugin.
1090 * To instrument PL/pgSQL, a plugin library must access the rendezvous
1091 * variable "PLpgSQL_plugin" and set it to point to a PLpgSQL_plugin struct.
1092 * Typically the struct could just be static data in the plugin library.
1093 * We expect that a plugin would do this at library load time (_PG_init()).
1094 *
1095 * This structure is basically a collection of function pointers --- at
1096 * various interesting points in pl_exec.c, we call these functions
1097 * (if the pointers are non-NULL) to give the plugin a chance to watch
1098 * what we are doing.
1099 *
1100 * func_setup is called when we start a function, before we've initialized
1101 * the local variables defined by the function.
1102 *
1103 * func_beg is called when we start a function, after we've initialized
1104 * the local variables.
1105 *
1106 * func_end is called at the end of a function.
1107 *
1108 * stmt_beg and stmt_end are called before and after (respectively) each
1109 * statement.
1110 *
1111 * Also, immediately before any call to func_setup, PL/pgSQL fills in the
1112 * remaining fields with pointers to some of its own functions, allowing the
1113 * plugin to invoke those functions conveniently. The exposed functions are:
1114 * plpgsql_exec_error_callback
1115 * exec_assign_expr
1116 * exec_assign_value
1117 * exec_eval_datum
1118 * exec_cast_value
1119 * (plpgsql_exec_error_callback is not actually meant to be called by the
1120 * plugin, but rather to allow it to identify PL/pgSQL error context stack
1121 * frames. The others are useful for debugger-like plugins to examine and
1122 * set variables.)
1123 */
1124typedef struct PLpgSQL_plugin
1125{
1126 /* Function pointers set up by the plugin */
1132
1133 /* Function pointers set by PL/pgSQL itself */
1134 void (*error_callback) (void *arg);
1136 PLpgSQL_datum *target,
1137 PLpgSQL_expr *expr);
1139 PLpgSQL_datum *target,
1140 Datum value, bool isNull,
1141 Oid valtype, int32 valtypmod);
1143 Oid *typeId, int32 *typetypmod,
1144 Datum *value, bool *isnull);
1146 Datum value, bool *isnull,
1147 Oid valtype, int32 valtypmod,
1148 Oid reqtype, int32 reqtypmod);
1150
1151/*
1152 * Struct types used during parsing
1153 */
1154
1155typedef struct PLword
1156{
1157 char *ident; /* palloc'd converted identifier */
1158 bool quoted; /* Was it double-quoted? */
1160
1161typedef struct PLcword
1162{
1163 List *idents; /* composite identifiers (list of String) */
1165
1166typedef struct PLwdatum
1167{
1168 PLpgSQL_datum *datum; /* referenced variable */
1169 char *ident; /* valid if simple name */
1171 List *idents; /* valid if composite name */
1173
1174/**********************************************************************
1175 * Global variable declarations
1176 **********************************************************************/
1177
1178typedef enum
1179{
1180 IDENTIFIER_LOOKUP_NORMAL, /* normal processing of var names */
1181 IDENTIFIER_LOOKUP_DECLARE, /* In DECLARE --- don't look up names */
1182 IDENTIFIER_LOOKUP_EXPR, /* In SQL expression --- special case */
1184
1186
1187extern int plpgsql_variable_conflict;
1188
1189extern bool plpgsql_print_strict_params;
1190
1191extern bool plpgsql_check_asserts;
1192
1193/* extra compile-time and run-time checks */
1194#define PLPGSQL_XCHECK_NONE 0
1195#define PLPGSQL_XCHECK_SHADOWVAR (1 << 1)
1196#define PLPGSQL_XCHECK_TOOMANYROWS (1 << 2)
1197#define PLPGSQL_XCHECK_STRICTMULTIASSIGNMENT (1 << 3)
1198#define PLPGSQL_XCHECK_ALL ((int) ~0)
1199
1200extern int plpgsql_extra_warnings;
1201extern int plpgsql_extra_errors;
1202
1203extern bool plpgsql_check_syntax;
1204extern bool plpgsql_DumpExecTree;
1205
1206extern int plpgsql_nDatums;
1208
1209extern char *plpgsql_error_funcname;
1210
1213
1215
1216/**********************************************************************
1217 * Function declarations
1218 **********************************************************************/
1219
1220/*
1221 * Functions in pl_comp.c
1222 */
1224 bool forValidator);
1225extern PLpgSQL_function *plpgsql_compile_inline(char *proc_source);
1226extern PGDLLEXPORT void plpgsql_parser_setup(struct ParseState *pstate,
1227 PLpgSQL_expr *expr);
1228extern bool plpgsql_parse_word(char *word1, const char *yytxt, bool lookup,
1229 PLwdatum *wdatum, PLword *word);
1230extern bool plpgsql_parse_dblword(char *word1, char *word2,
1231 PLwdatum *wdatum, PLcword *cword);
1232extern bool plpgsql_parse_tripword(char *word1, char *word2, char *word3,
1233 PLwdatum *wdatum, PLcword *cword);
1239 Oid collation,
1240 TypeName *origtypname);
1242extern PLpgSQL_variable *plpgsql_build_variable(const char *refname, int lineno,
1243 PLpgSQL_type *dtype,
1244 bool add2namespace);
1245extern PLpgSQL_rec *plpgsql_build_record(const char *refname, int lineno,
1246 PLpgSQL_type *dtype, Oid rectypeid,
1247 bool add2namespace);
1249 const char *fldname);
1250extern PGDLLEXPORT int plpgsql_recognize_err_condition(const char *condname,
1251 bool allow_sqlstate);
1252extern PLpgSQL_condition *plpgsql_parse_err_condition(char *condname);
1253extern void plpgsql_adddatum(PLpgSQL_datum *newdatum);
1254extern int plpgsql_add_initdatums(int **varnos);
1255
1256/*
1257 * Functions in pl_exec.c
1258 */
1260 FunctionCallInfo fcinfo,
1261 EState *simple_eval_estate,
1262 ResourceOwner simple_eval_resowner,
1263 ResourceOwner procedure_resowner,
1264 bool atomic);
1266 TriggerData *trigdata);
1268 EventTriggerData *trigdata);
1269extern void plpgsql_xact_cb(XactEvent event, void *arg);
1270extern void plpgsql_subxact_cb(SubXactEvent event, SubTransactionId mySubid,
1271 SubTransactionId parentSubid, void *arg);
1273 PLpgSQL_datum *datum);
1275 PLpgSQL_datum *datum,
1276 Oid *typeId, int32 *typMod,
1277 Oid *collation);
1278
1279/*
1280 * Functions for namespace handling in pl_funcs.c
1281 */
1282extern void plpgsql_ns_init(void);
1283extern void plpgsql_ns_push(const char *label,
1284 PLpgSQL_label_type label_type);
1285extern void plpgsql_ns_pop(void);
1286extern PLpgSQL_nsitem *plpgsql_ns_top(void);
1287extern void plpgsql_ns_additem(PLpgSQL_nsitem_type itemtype, int itemno, const char *name);
1288extern PGDLLEXPORT PLpgSQL_nsitem *plpgsql_ns_lookup(PLpgSQL_nsitem *ns_cur, bool localmode,
1289 const char *name1, const char *name2,
1290 const char *name3, int *names_used);
1292 const char *name);
1294
1295/*
1296 * Other functions in pl_funcs.c
1297 */
1299extern const char *plpgsql_getdiag_kindname(PLpgSQL_getdiag_kind kind);
1302extern void plpgsql_delete_callback(CachedFunction *cfunc);
1303extern void plpgsql_dumptree(PLpgSQL_function *func);
1304
1305/*
1306 * Scanner functions in pl_scanner.c
1307 */
1308union YYSTYPE;
1309#define YYLTYPE int
1310#ifndef YY_TYPEDEF_YY_SCANNER_T
1311#define YY_TYPEDEF_YY_SCANNER_T
1312typedef void *yyscan_t;
1313#endif
1314extern int plpgsql_yylex(union YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
1315extern int plpgsql_token_length(yyscan_t yyscanner);
1316extern void plpgsql_push_back_token(int token, union YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
1319 int startlocation, int endlocation,
1320 yyscan_t yyscanner);
1321extern int plpgsql_peek(yyscan_t yyscanner);
1322extern void plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc,
1323 int *tok2_loc, yyscan_t yyscanner);
1324extern int plpgsql_scanner_errposition(int location, yyscan_t yyscanner);
1325pg_noreturn extern void plpgsql_yyerror(YYLTYPE *yyllocp, PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner, const char *message);
1326extern int plpgsql_location_to_lineno(int location, yyscan_t yyscanner);
1327extern int plpgsql_latest_lineno(yyscan_t yyscanner);
1328extern yyscan_t plpgsql_scanner_init(const char *str);
1329extern void plpgsql_scanner_finish(yyscan_t yyscanner);
1330
1331/*
1332 * Externs in pl_gram.y
1333 */
1334extern int plpgsql_yyparse(PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner);
1335
1336#endif /* PLPGSQL_H */
uint32 SubTransactionId
Definition: c.h:627
#define pg_noreturn
Definition: c.h:165
#define PGDLLEXPORT
Definition: c.h:1306
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:434
int16_t int16
Definition: c.h:497
int32_t int32
Definition: c.h:498
uint64_t uint64
Definition: c.h:503
uint32 LocalTransactionId
Definition: c.h:625
size_t Size
Definition: c.h:576
void * yyscan_t
Definition: cubedata.h:67
const char * str
#define stmt
Definition: indent_codes.h:59
#define ident
Definition: indent_codes.h:47
static struct @165 value
FetchDirection
Definition: parsenodes.h:3411
RawParseMode
Definition: parser.h:38
void * arg
static char * label
#define FUNC_MAX_ARGS
static char * buf
Definition: pg_test_fsync.c:72
struct PLpgSQL_stmt_dynexecute PLpgSQL_stmt_dynexecute
void plpgsql_ns_pop(void)
Definition: pl_funcs.c:67
struct PLpgSQL_type PLpgSQL_type
int plpgsql_variable_conflict
Definition: pl_handler.c:47
struct PLpgSQL_stmt_while PLpgSQL_stmt_while
struct PLpgSQL_function PLpgSQL_function
@ PLPGSQL_RC_RETURN
Definition: plpgsql.h:141
@ PLPGSQL_RC_EXIT
Definition: plpgsql.h:140
@ PLPGSQL_RC_OK
Definition: plpgsql.h:139
@ PLPGSQL_RC_CONTINUE
Definition: plpgsql.h:142
bool plpgsql_check_asserts
Definition: pl_handler.c:51
struct PLpgSQL_stmt_assert PLpgSQL_stmt_assert
void * yyscan_t
Definition: plpgsql.h:1312
PLpgSQL_condition * plpgsql_parse_err_condition(char *condname)
Definition: pl_comp.c:2143
PLpgSQL_resolve_option
Definition: plpgsql.h:185
@ PLPGSQL_RESOLVE_COLUMN
Definition: plpgsql.h:188
@ PLPGSQL_RESOLVE_ERROR
Definition: plpgsql.h:186
@ PLPGSQL_RESOLVE_VARIABLE
Definition: plpgsql.h:187
struct PLpgSQL_stmt_open PLpgSQL_stmt_open
int plpgsql_extra_warnings
Definition: pl_handler.c:55
PLpgSQL_trigtype
Definition: plpgsql.h:949
@ PLPGSQL_DML_TRIGGER
Definition: plpgsql.h:950
@ PLPGSQL_NOT_TRIGGER
Definition: plpgsql.h:952
@ PLPGSQL_EVENT_TRIGGER
Definition: plpgsql.h:951
struct PLpgSQL_stmt_fetch PLpgSQL_stmt_fetch
struct PLpgSQL_raise_option PLpgSQL_raise_option
PLpgSQL_recfield * plpgsql_build_recfield(PLpgSQL_rec *rec, const char *fldname)
Definition: pl_comp.c:1895
int plpgsql_add_initdatums(int **varnos)
Definition: pl_comp.c:2268
MemoryContext plpgsql_compile_tmp_cxt
Definition: pl_comp.c:53
struct PLpgSQL_variable PLpgSQL_variable
struct PLpgSQL_nsitem PLpgSQL_nsitem
struct PLpgSQL_stmt_getdiag PLpgSQL_stmt_getdiag
struct PLpgSQL_stmt_return_next PLpgSQL_stmt_return_next
PLpgSQL_stmt_type
Definition: plpgsql.h:104
@ PLPGSQL_STMT_DYNFORS
Definition: plpgsql.h:123
@ PLPGSQL_STMT_FORI
Definition: plpgsql.h:111
@ PLPGSQL_STMT_FETCH
Definition: plpgsql.h:126
@ PLPGSQL_STMT_CASE
Definition: plpgsql.h:108
@ PLPGSQL_STMT_OPEN
Definition: plpgsql.h:125
@ PLPGSQL_STMT_ROLLBACK
Definition: plpgsql.h:131
@ PLPGSQL_STMT_COMMIT
Definition: plpgsql.h:130
@ PLPGSQL_STMT_RETURN_QUERY
Definition: plpgsql.h:118
@ PLPGSQL_STMT_RETURN
Definition: plpgsql.h:116
@ PLPGSQL_STMT_CLOSE
Definition: plpgsql.h:127
@ PLPGSQL_STMT_WHILE
Definition: plpgsql.h:110
@ PLPGSQL_STMT_BLOCK
Definition: plpgsql.h:105
@ PLPGSQL_STMT_FORS
Definition: plpgsql.h:112
@ PLPGSQL_STMT_FORC
Definition: plpgsql.h:113
@ PLPGSQL_STMT_IF
Definition: plpgsql.h:107
@ PLPGSQL_STMT_PERFORM
Definition: plpgsql.h:128
@ PLPGSQL_STMT_LOOP
Definition: plpgsql.h:109
@ PLPGSQL_STMT_ASSERT
Definition: plpgsql.h:120
@ PLPGSQL_STMT_FOREACH_A
Definition: plpgsql.h:114
@ PLPGSQL_STMT_GETDIAG
Definition: plpgsql.h:124
@ PLPGSQL_STMT_RETURN_NEXT
Definition: plpgsql.h:117
@ PLPGSQL_STMT_ASSIGN
Definition: plpgsql.h:106
@ PLPGSQL_STMT_EXIT
Definition: plpgsql.h:115
@ PLPGSQL_STMT_EXECSQL
Definition: plpgsql.h:121
@ PLPGSQL_STMT_RAISE
Definition: plpgsql.h:119
@ PLPGSQL_STMT_CALL
Definition: plpgsql.h:129
@ PLPGSQL_STMT_DYNEXECUTE
Definition: plpgsql.h:122
PLpgSQL_type_type
Definition: plpgsql.h:94
@ PLPGSQL_TTYPE_PSEUDO
Definition: plpgsql.h:97
@ PLPGSQL_TTYPE_REC
Definition: plpgsql.h:96
@ PLPGSQL_TTYPE_SCALAR
Definition: plpgsql.h:95
pg_noreturn void plpgsql_yyerror(YYLTYPE *yyllocp, PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner, const char *message)
Definition: pl_scanner.c:534
struct PLpgSQL_if_elsif PLpgSQL_if_elsif
void plpgsql_append_source_text(StringInfo buf, int startlocation, int endlocation, yyscan_t yyscanner)
Definition: pl_scanner.c:435
void plpgsql_ns_init(void)
Definition: pl_funcs.c:43
PGDLLEXPORT void plpgsql_parser_setup(struct ParseState *pstate, PLpgSQL_expr *expr)
Definition: pl_comp.c:975
struct PLpgSQL_stmt_dynfors PLpgSQL_stmt_dynfors
struct PLpgSQL_stmt PLpgSQL_stmt
struct PLpgSQL_stmt_call PLpgSQL_stmt_call
struct PLpgSQL_stmt_fors PLpgSQL_stmt_fors
Datum plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo, EState *simple_eval_estate, ResourceOwner simple_eval_resowner, ResourceOwner procedure_resowner, bool atomic)
Definition: pl_exec.c:493
struct PLcword PLcword
PLpgSQL_type * plpgsql_parse_cwordrowtype(List *idents)
Definition: pl_comp.c:1694
struct PLpgSQL_stmt_perform PLpgSQL_stmt_perform
void plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc, int *tok2_loc, yyscan_t yyscanner)
Definition: pl_scanner.c:471
struct PLpgSQL_diag_item PLpgSQL_diag_item
PLpgSQL_nsitem * plpgsql_ns_find_nearest_loop(PLpgSQL_nsitem *ns_cur)
Definition: pl_funcs.c:214
struct PLpgSQL_row PLpgSQL_row
PLpgSQL_nsitem * plpgsql_ns_lookup_label(PLpgSQL_nsitem *ns_cur, const char *name)
Definition: pl_funcs.c:195
IdentifierLookup
Definition: plpgsql.h:1179
@ IDENTIFIER_LOOKUP_DECLARE
Definition: plpgsql.h:1181
@ IDENTIFIER_LOOKUP_NORMAL
Definition: plpgsql.h:1180
@ IDENTIFIER_LOOKUP_EXPR
Definition: plpgsql.h:1182
int plpgsql_token_length(yyscan_t yyscanner)
Definition: pl_scanner.c:327
struct PLpgSQL_var PLpgSQL_var
void plpgsql_exec_get_datum_type_info(PLpgSQL_execstate *estate, PLpgSQL_datum *datum, Oid *typeId, int32 *typMod, Oid *collation)
Definition: pl_exec.c:5538
PGDLLEXPORT Oid plpgsql_exec_get_datum_type(PLpgSQL_execstate *estate, PLpgSQL_datum *datum)
Definition: pl_exec.c:5453
void plpgsql_delete_callback(CachedFunction *cfunc)
Definition: pl_funcs.c:772
PGDLLEXPORT PLpgSQL_nsitem * plpgsql_ns_lookup(PLpgSQL_nsitem *ns_cur, bool localmode, const char *name1, const char *name2, const char *name3, int *names_used)
Definition: pl_funcs.c:130
IdentifierLookup plpgsql_IdentifierLookup
Definition: pl_scanner.c:26
struct PLpgSQL_stmt_raise PLpgSQL_stmt_raise
void plpgsql_scanner_finish(yyscan_t yyscanner)
Definition: pl_scanner.c:653
void plpgsql_dumptree(PLpgSQL_function *func)
Definition: pl_funcs.c:1601
char * plpgsql_error_funcname
Definition: pl_comp.c:46
PLpgSQL_raise_option_type
Definition: plpgsql.h:169
@ PLPGSQL_RAISEOPTION_COLUMN
Definition: plpgsql.h:174
@ PLPGSQL_RAISEOPTION_TABLE
Definition: plpgsql.h:177
@ PLPGSQL_RAISEOPTION_SCHEMA
Definition: plpgsql.h:178
@ PLPGSQL_RAISEOPTION_CONSTRAINT
Definition: plpgsql.h:175
@ PLPGSQL_RAISEOPTION_DETAIL
Definition: plpgsql.h:172
@ PLPGSQL_RAISEOPTION_MESSAGE
Definition: plpgsql.h:171
@ PLPGSQL_RAISEOPTION_HINT
Definition: plpgsql.h:173
@ PLPGSQL_RAISEOPTION_ERRCODE
Definition: plpgsql.h:170
@ PLPGSQL_RAISEOPTION_DATATYPE
Definition: plpgsql.h:176
PGDLLEXPORT PLpgSQL_type * plpgsql_build_datatype(Oid typeOid, int32 typmod, Oid collation, TypeName *origtypname)
Definition: pl_comp.c:1942
bool plpgsql_print_strict_params
Definition: pl_handler.c:49
bool plpgsql_check_syntax
Definition: pl_comp.c:48
void plpgsql_push_back_token(int token, union YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
Definition: pl_scanner.c:401
struct PLpgSQL_stmt_return PLpgSQL_stmt_return
bool plpgsql_token_is_unreserved_keyword(int token)
Definition: pl_scanner.c:418
struct PLwdatum PLwdatum
struct PLpgSQL_stmt_exit PLpgSQL_stmt_exit
struct PLpgSQL_stmt_block PLpgSQL_stmt_block
struct PLpgSQL_rec PLpgSQL_rec
struct PLpgSQL_stmt_loop PLpgSQL_stmt_loop
PLpgSQL_promise_type
Definition: plpgsql.h:75
@ PLPGSQL_PROMISE_TG_RELID
Definition: plpgsql.h:81
@ PLPGSQL_PROMISE_NONE
Definition: plpgsql.h:76
@ PLPGSQL_PROMISE_TG_WHEN
Definition: plpgsql.h:78
@ PLPGSQL_PROMISE_TG_ARGV
Definition: plpgsql.h:85
@ PLPGSQL_PROMISE_TG_TABLE_SCHEMA
Definition: plpgsql.h:83
@ PLPGSQL_PROMISE_TG_EVENT
Definition: plpgsql.h:86
@ PLPGSQL_PROMISE_TG_TABLE_NAME
Definition: plpgsql.h:82
@ PLPGSQL_PROMISE_TG_TAG
Definition: plpgsql.h:87
@ PLPGSQL_PROMISE_TG_OP
Definition: plpgsql.h:80
@ PLPGSQL_PROMISE_TG_LEVEL
Definition: plpgsql.h:79
@ PLPGSQL_PROMISE_TG_NARGS
Definition: plpgsql.h:84
@ PLPGSQL_PROMISE_TG_NAME
Definition: plpgsql.h:77
struct PLpgSQL_stmt_forc PLpgSQL_stmt_forc
struct PLpgSQL_stmt_return_query PLpgSQL_stmt_return_query
PLpgSQL_plugin ** plpgsql_plugin_ptr
Definition: pl_handler.c:59
struct PLpgSQL_stmt_case PLpgSQL_stmt_case
struct PLpgSQL_stmt_foreach_a PLpgSQL_stmt_foreach_a
PLpgSQL_rwopt
Definition: plpgsql.h:195
@ PLPGSQL_RWOPT_INPLACE
Definition: plpgsql.h:199
@ PLPGSQL_RWOPT_UNKNOWN
Definition: plpgsql.h:196
@ PLPGSQL_RWOPT_TRANSFER
Definition: plpgsql.h:198
@ PLPGSQL_RWOPT_NOPE
Definition: plpgsql.h:197
void plpgsql_free_function_memory(PLpgSQL_function *func)
Definition: pl_funcs.c:716
void plpgsql_mark_local_assignment_targets(PLpgSQL_function *func)
Definition: pl_funcs.c:673
struct PLpgSQL_expr PLpgSQL_expr
struct PLpgSQL_stmt_close PLpgSQL_stmt_close
struct PLpgSQL_plugin PLpgSQL_plugin
PLpgSQL_type * plpgsql_build_datatype_arrayof(PLpgSQL_type *dtype)
Definition: pl_comp.c:2076
void plpgsql_ns_additem(PLpgSQL_nsitem_type itemtype, int itemno, const char *name)
Definition: pl_funcs.c:92
PLpgSQL_function * plpgsql_curr_compile
Definition: pl_comp.c:50
bool plpgsql_parse_dblword(char *word1, char *word2, PLwdatum *wdatum, PLcword *cword)
Definition: pl_comp.c:1339
struct PLpgSQL_stmt_commit PLpgSQL_stmt_commit
PLpgSQL_type * plpgsql_parse_wordtype(char *ident)
Definition: pl_comp.c:1504
struct PLpgSQL_datum PLpgSQL_datum
struct PLpgSQL_case_when PLpgSQL_case_when
void plpgsql_adddatum(PLpgSQL_datum *newdatum)
Definition: pl_comp.c:2207
struct PLpgSQL_exception_block PLpgSQL_exception_block
PLpgSQL_datum ** plpgsql_Datums
Definition: pl_comp.c:43
PLpgSQL_label_type
Definition: plpgsql.h:53
@ PLPGSQL_LABEL_LOOP
Definition: plpgsql.h:55
@ PLPGSQL_LABEL_OTHER
Definition: plpgsql.h:56
@ PLPGSQL_LABEL_BLOCK
Definition: plpgsql.h:54
yyscan_t plpgsql_scanner_init(const char *str)
Definition: pl_scanner.c:621
struct PLpgSQL_stmt_execsql PLpgSQL_stmt_execsql
bool plpgsql_parse_word(char *word1, const char *yytxt, bool lookup, PLwdatum *wdatum, PLword *word)
Definition: pl_comp.c:1284
bool plpgsql_DumpExecTree
Definition: pl_comp.c:47
PLpgSQL_type * plpgsql_parse_cwordtype(List *idents)
Definition: pl_comp.c:1545
PLpgSQL_rec * plpgsql_build_record(const char *refname, int lineno, PLpgSQL_type *dtype, Oid rectypeid, bool add2namespace)
Definition: pl_comp.c:1801
HeapTuple plpgsql_exec_trigger(PLpgSQL_function *func, TriggerData *trigdata)
Definition: pl_exec.c:935
PGDLLEXPORT PLpgSQL_function * plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator)
Definition: pl_comp.c:106
PGDLLEXPORT const char * plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
Definition: pl_funcs.c:232
int plpgsql_extra_errors
Definition: pl_handler.c:56
int plpgsql_yyparse(PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner)
int plpgsql_scanner_errposition(int location, yyscan_t yyscanner)
Definition: pl_scanner.c:504
struct PLpgSQL_stmt_rollback PLpgSQL_stmt_rollback
struct PLpgSQL_execstate PLpgSQL_execstate
void plpgsql_subxact_cb(SubXactEvent event, SubTransactionId mySubid, SubTransactionId parentSubid, void *arg)
Definition: pl_exec.c:8753
void plpgsql_ns_push(const char *label, PLpgSQL_label_type label_type)
Definition: pl_funcs.c:54
void plpgsql_exec_event_trigger(PLpgSQL_function *func, EventTriggerData *trigdata)
Definition: pl_exec.c:1175
bool plpgsql_parse_tripword(char *word1, char *word2, char *word3, PLwdatum *wdatum, PLcword *cword)
Definition: pl_comp.c:1420
struct PLpgSQL_exception PLpgSQL_exception
PLpgSQL_type * plpgsql_parse_wordrowtype(char *ident)
Definition: pl_comp.c:1657
struct PLpgSQL_condition PLpgSQL_condition
struct PLpgSQL_recfield PLpgSQL_recfield
PLpgSQL_nsitem * plpgsql_ns_top(void)
Definition: pl_funcs.c:81
PLpgSQL_datum_type
Definition: plpgsql.h:63
@ PLPGSQL_DTYPE_ROW
Definition: plpgsql.h:65
@ PLPGSQL_DTYPE_PROMISE
Definition: plpgsql.h:68
@ PLPGSQL_DTYPE_RECFIELD
Definition: plpgsql.h:67
@ PLPGSQL_DTYPE_REC
Definition: plpgsql.h:66
@ PLPGSQL_DTYPE_VAR
Definition: plpgsql.h:64
int plpgsql_peek(yyscan_t yyscanner)
Definition: pl_scanner.c:452
struct PLpgSQL_stmt_forq PLpgSQL_stmt_forq
int plpgsql_location_to_lineno(int location, yyscan_t yyscanner)
Definition: pl_scanner.c:573
PGDLLEXPORT int plpgsql_recognize_err_condition(const char *condname, bool allow_sqlstate)
Definition: pl_comp.c:2107
PLpgSQL_nsitem_type
Definition: plpgsql.h:43
@ PLPGSQL_NSTYPE_VAR
Definition: plpgsql.h:45
@ PLPGSQL_NSTYPE_REC
Definition: plpgsql.h:46
@ PLPGSQL_NSTYPE_LABEL
Definition: plpgsql.h:44
PLpgSQL_variable * plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type *dtype, bool add2namespace)
Definition: pl_comp.c:1738
struct PLword PLword
const char * plpgsql_getdiag_kindname(PLpgSQL_getdiag_kind kind)
Definition: pl_funcs.c:300
struct PLpgSQL_stmt_if PLpgSQL_stmt_if
struct PLpgSQL_stmt_fori PLpgSQL_stmt_fori
PLpgSQL_function * plpgsql_compile_inline(char *proc_source)
Definition: pl_comp.c:729
int plpgsql_nDatums
Definition: pl_comp.c:42
void plpgsql_xact_cb(XactEvent event, void *arg)
Definition: pl_exec.c:8711
PLpgSQL_getdiag_kind
Definition: plpgsql.h:149
@ PLPGSQL_GETDIAG_ERROR_DETAIL
Definition: plpgsql.h:154
@ PLPGSQL_GETDIAG_SCHEMA_NAME
Definition: plpgsql.h:162
@ PLPGSQL_GETDIAG_MESSAGE_TEXT
Definition: plpgsql.h:160
@ PLPGSQL_GETDIAG_DATATYPE_NAME
Definition: plpgsql.h:159
@ PLPGSQL_GETDIAG_TABLE_NAME
Definition: plpgsql.h:161
@ PLPGSQL_GETDIAG_CONSTRAINT_NAME
Definition: plpgsql.h:158
@ PLPGSQL_GETDIAG_COLUMN_NAME
Definition: plpgsql.h:157
@ PLPGSQL_GETDIAG_ROW_COUNT
Definition: plpgsql.h:150
@ PLPGSQL_GETDIAG_RETURNED_SQLSTATE
Definition: plpgsql.h:156
@ PLPGSQL_GETDIAG_CONTEXT
Definition: plpgsql.h:152
@ PLPGSQL_GETDIAG_ERROR_HINT
Definition: plpgsql.h:155
@ PLPGSQL_GETDIAG_ERROR_CONTEXT
Definition: plpgsql.h:153
@ PLPGSQL_GETDIAG_ROUTINE_OID
Definition: plpgsql.h:151
int plpgsql_yylex(union YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
Definition: pl_scanner.c:160
int plpgsql_latest_lineno(yyscan_t yyscanner)
Definition: pl_scanner.c:607
struct PLpgSQL_stmt_assign PLpgSQL_stmt_assign
uintptr_t Datum
Definition: postgres.h:69
unsigned int Oid
Definition: postgres_ext.h:30
const char * YYLTYPE
int YYSTYPE
Definition: psqlscanslash.l:39
static void word(struct vars *v, int dir, struct state *lp, struct state *rp)
Definition: regcomp.c:1476
Definition: dynahash.c:220
Definition: pg_list.h:54
List * idents
Definition: plpgsql.h:1163
PLpgSQL_expr * expr
Definition: plpgsql.h:661
char * condname
Definition: plpgsql.h:495
struct PLpgSQL_condition * next
Definition: plpgsql.h:496
PLpgSQL_datum_type dtype
Definition: plpgsql.h:300
PLpgSQL_getdiag_kind kind
Definition: plpgsql.h:600
PLpgSQL_condition * conditions
Definition: plpgsql.h:518
EState * simple_eval_estate
Definition: plpgsql.h:1062
TriggerData * trigdata
Definition: plpgsql.h:1016
PLpgSQL_datum ** datums
Definition: plpgsql.h:1049
ParamListInfo paramLI
Definition: plpgsql.h:1059
char * exitlabel
Definition: plpgsql.h:1030
ResourceOwner simple_eval_resowner
Definition: plpgsql.h:1063
ExprContext * eval_econtext
Definition: plpgsql.h:1078
ResourceOwner procedure_resowner
Definition: plpgsql.h:1066
PLpgSQL_function * func
Definition: plpgsql.h:1014
HTAB * cast_hash
Definition: plpgsql.h:1069
Tuplestorestate * tuple_store
Definition: plpgsql.h:1034
PLpgSQL_variable * err_var
Definition: plpgsql.h:1082
MemoryContext tuple_store_cxt
Definition: plpgsql.h:1036
TupleDesc tuple_store_desc
Definition: plpgsql.h:1035
MemoryContext datum_context
Definition: plpgsql.h:1051
ReturnSetInfo * rsi
Definition: plpgsql.h:1038
MemoryContext stmt_mcontext
Definition: plpgsql.h:1072
PLpgSQL_stmt * err_stmt
Definition: plpgsql.h:1081
const char * err_text
Definition: plpgsql.h:1083
SPITupleTable * eval_tuptable
Definition: plpgsql.h:1076
EventTriggerData * evtrigdata
Definition: plpgsql.h:1017
ErrorData * cur_error
Definition: plpgsql.h:1032
ResourceOwner tuple_store_owner
Definition: plpgsql.h:1037
MemoryContext stmt_mcontext_parent
Definition: plpgsql.h:1073
void * plugin_info
Definition: plpgsql.h:1085
uint64 eval_processed
Definition: plpgsql.h:1077
CachedPlanSource * expr_simple_plansource
Definition: plpgsql.h:277
CachedPlan * expr_simple_plan
Definition: plpgsql.h:278
Oid expr_simple_type
Definition: plpgsql.h:256
int target_param
Definition: plpgsql.h:244
Expr * expr_simple_expr
Definition: plpgsql.h:255
SPIPlanPtr plan
Definition: plpgsql.h:251
struct PLpgSQL_nsitem * ns
Definition: plpgsql.h:235
bool target_is_local
Definition: plpgsql.h:245
ExprState * expr_simple_state
Definition: plpgsql.h:287
RawParseMode parseMode
Definition: plpgsql.h:233
PLpgSQL_rwopt expr_rwopt
Definition: plpgsql.h:268
struct PLpgSQL_function * func
Definition: plpgsql.h:234
bool expr_simple_mutable
Definition: plpgsql.h:258
bool expr_simple_in_use
Definition: plpgsql.h:288
Bitmapset * paramnos
Definition: plpgsql.h:252
Param * expr_rw_param
Definition: plpgsql.h:269
LocalTransactionId expr_simple_plan_lxid
Definition: plpgsql.h:279
LocalTransactionId expr_simple_lxid
Definition: plpgsql.h:289
char * query
Definition: plpgsql.h:232
int32 expr_simple_typmod
Definition: plpgsql.h:257
bool print_strict_params
Definition: plpgsql.h:986
bool requires_procedure_resowner
Definition: plpgsql.h:1002
bool has_exception_block
Definition: plpgsql.h:1003
PLpgSQL_trigtype fn_is_trigger
Definition: plpgsql.h:964
Oid fn_input_collation
Definition: plpgsql.h:965
bool fn_retbyval
Definition: plpgsql.h:970
CachedFunction cfunc
Definition: plpgsql.h:960
bool fn_retisdomain
Definition: plpgsql.h:972
MemoryContext fn_cxt
Definition: plpgsql.h:966
int fn_argvarnos[FUNC_MAX_ARGS]
Definition: plpgsql.h:978
PLpgSQL_stmt_block * action
Definition: plpgsql.h:998
Size copiable_size
Definition: plpgsql.h:995
unsigned int nstatements
Definition: plpgsql.h:1001
bool fn_readonly
Definition: plpgsql.h:974
bool fn_retistuple
Definition: plpgsql.h:971
struct PLpgSQL_execstate * cur_estate
Definition: plpgsql.h:1006
int out_param_varno
Definition: plpgsql.h:979
PLpgSQL_resolve_option resolve_option
Definition: plpgsql.h:984
int extra_warnings
Definition: plpgsql.h:989
PLpgSQL_datum ** datums
Definition: plpgsql.h:994
char * fn_signature
Definition: plpgsql.h:962
PLpgSQL_expr * cond
Definition: plpgsql.h:636
List * stmts
Definition: plpgsql.h:637
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: plpgsql.h:470
struct PLpgSQL_nsitem * prev
Definition: plpgsql.h:469
PLpgSQL_nsitem_type itemtype
Definition: plpgsql.h:462
void(* stmt_end)(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
Definition: plpgsql.h:1131
void(* func_beg)(PLpgSQL_execstate *estate, PLpgSQL_function *func)
Definition: plpgsql.h:1128
Datum(* cast_value)(PLpgSQL_execstate *estate, Datum value, bool *isnull, Oid valtype, int32 valtypmod, Oid reqtype, int32 reqtypmod)
Definition: plpgsql.h:1145
void(* error_callback)(void *arg)
Definition: plpgsql.h:1134
void(* func_end)(PLpgSQL_execstate *estate, PLpgSQL_function *func)
Definition: plpgsql.h:1129
void(* assign_expr)(PLpgSQL_execstate *estate, PLpgSQL_datum *target, PLpgSQL_expr *expr)
Definition: plpgsql.h:1135
void(* func_setup)(PLpgSQL_execstate *estate, PLpgSQL_function *func)
Definition: plpgsql.h:1127
void(* assign_value)(PLpgSQL_execstate *estate, PLpgSQL_datum *target, Datum value, bool isNull, Oid valtype, int32 valtypmod)
Definition: plpgsql.h:1138
void(* eval_datum)(PLpgSQL_execstate *estate, PLpgSQL_datum *datum, Oid *typeId, int32 *typetypmod, Datum *value, bool *isnull)
Definition: plpgsql.h:1142
void(* stmt_beg)(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
Definition: plpgsql.h:1130
PLpgSQL_raise_option_type opt_type
Definition: plpgsql.h:898
PLpgSQL_expr * expr
Definition: plpgsql.h:899
ExpandedRecordHeader * erh
Definition: plpgsql.h:437
PLpgSQL_type * datatype
Definition: plpgsql.h:429
bool notnull
Definition: plpgsql.h:419
PLpgSQL_datum_type dtype
Definition: plpgsql.h:414
int firstfield
Definition: plpgsql.h:432
Oid rectypeid
Definition: plpgsql.h:430
bool isconst
Definition: plpgsql.h:418
int lineno
Definition: plpgsql.h:417
char * refname
Definition: plpgsql.h:416
PLpgSQL_expr * default_val
Definition: plpgsql.h:420
uint64 rectupledescid
Definition: plpgsql.h:452
PLpgSQL_datum_type dtype
Definition: plpgsql.h:445
char * fieldname
Definition: plpgsql.h:449
ExpandedRecordFieldInfo finfo
Definition: plpgsql.h:453
TupleDesc rowtupdesc
Definition: plpgsql.h:402
PLpgSQL_expr * default_val
Definition: plpgsql.h:394
bool isconst
Definition: plpgsql.h:392
int lineno
Definition: plpgsql.h:391
PLpgSQL_datum_type dtype
Definition: plpgsql.h:388
bool notnull
Definition: plpgsql.h:393
int * varnos
Definition: plpgsql.h:406
char * refname
Definition: plpgsql.h:390
char ** fieldnames
Definition: plpgsql.h:405
int nfields
Definition: plpgsql.h:404
unsigned int stmtid
Definition: plpgsql.h:909
PLpgSQL_expr * cond
Definition: plpgsql.h:910
PLpgSQL_expr * message
Definition: plpgsql.h:911
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:907
PLpgSQL_expr * expr
Definition: plpgsql.h:546
unsigned int stmtid
Definition: plpgsql.h:544
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:542
PLpgSQL_exception_block * exceptions
Definition: plpgsql.h:534
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:527
unsigned int stmtid
Definition: plpgsql.h:529
PLpgSQL_variable * target
Definition: plpgsql.h:570
PLpgSQL_expr * expr
Definition: plpgsql.h:568
unsigned int stmtid
Definition: plpgsql.h:567
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:565
List * case_when_list
Definition: plpgsql.h:650
List * else_stmts
Definition: plpgsql.h:652
PLpgSQL_expr * t_expr
Definition: plpgsql.h:648
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:645
unsigned int stmtid
Definition: plpgsql.h:647
unsigned int stmtid
Definition: plpgsql.h:824
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:822
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:578
unsigned int stmtid
Definition: plpgsql.h:580
PLpgSQL_expr * query
Definition: plpgsql.h:938
unsigned int stmtid
Definition: plpgsql.h:937
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:935
PLpgSQL_variable * target
Definition: plpgsql.h:941
unsigned int stmtid
Definition: plpgsql.h:760
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:758
PLpgSQL_variable * var
Definition: plpgsql.h:762
PLpgSQL_expr * query
Definition: plpgsql.h:765
PLpgSQL_variable * target
Definition: plpgsql.h:927
PLpgSQL_expr * sqlstmt
Definition: plpgsql.h:922
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:919
unsigned int stmtid
Definition: plpgsql.h:921
unsigned int stmtid
Definition: plpgsql.h:835
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:833
PLpgSQL_expr * cond
Definition: plpgsql.h:838
FetchDirection direction
Definition: plpgsql.h:810
bool returns_multiple_rows
Definition: plpgsql.h:814
PLpgSQL_variable * target
Definition: plpgsql.h:808
unsigned int stmtid
Definition: plpgsql.h:807
PLpgSQL_expr * expr
Definition: plpgsql.h:812
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:805
unsigned int stmtid
Definition: plpgsql.h:744
PLpgSQL_variable * var
Definition: plpgsql.h:746
PLpgSQL_expr * argquery
Definition: plpgsql.h:750
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:742
unsigned int stmtid
Definition: plpgsql.h:776
PLpgSQL_expr * expr
Definition: plpgsql.h:780
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:774
unsigned int stmtid
Definition: plpgsql.h:697
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:695
PLpgSQL_expr * upper
Definition: plpgsql.h:701
PLpgSQL_expr * lower
Definition: plpgsql.h:700
PLpgSQL_expr * step
Definition: plpgsql.h:702
PLpgSQL_var * var
Definition: plpgsql.h:699
unsigned int stmtid
Definition: plpgsql.h:716
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:714
PLpgSQL_variable * var
Definition: plpgsql.h:718
PLpgSQL_variable * var
Definition: plpgsql.h:731
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:727
PLpgSQL_expr * query
Definition: plpgsql.h:734
unsigned int stmtid
Definition: plpgsql.h:729
unsigned int stmtid
Definition: plpgsql.h:611
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:609
PLpgSQL_expr * cond
Definition: plpgsql.h:624
List * elsif_list
Definition: plpgsql.h:626
List * else_body
Definition: plpgsql.h:627
List * then_body
Definition: plpgsql.h:625
unsigned int stmtid
Definition: plpgsql.h:623
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:621
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:670
unsigned int stmtid
Definition: plpgsql.h:672
unsigned int stmtid
Definition: plpgsql.h:791
PLpgSQL_expr * argquery
Definition: plpgsql.h:794
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:789
PLpgSQL_expr * dynquery
Definition: plpgsql.h:796
PLpgSQL_expr * query
Definition: plpgsql.h:795
PLpgSQL_expr * expr
Definition: plpgsql.h:557
unsigned int stmtid
Definition: plpgsql.h:556
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:554
unsigned int stmtid
Definition: plpgsql.h:885
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:883
PLpgSQL_expr * expr
Definition: plpgsql.h:861
unsigned int stmtid
Definition: plpgsql.h:860
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:858
PLpgSQL_expr * dynquery
Definition: plpgsql.h:874
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:870
unsigned int stmtid
Definition: plpgsql.h:872
PLpgSQL_expr * query
Definition: plpgsql.h:873
unsigned int stmtid
Definition: plpgsql.h:848
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:846
PLpgSQL_expr * expr
Definition: plpgsql.h:849
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:589
unsigned int stmtid
Definition: plpgsql.h:591
unsigned int stmtid
Definition: plpgsql.h:684
PLpgSQL_expr * cond
Definition: plpgsql.h:686
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:682
int lineno
Definition: plpgsql.h:479
PLpgSQL_stmt_type cmd_type
Definition: plpgsql.h:478
unsigned int stmtid
Definition: plpgsql.h:486
char typtype
Definition: plpgsql.h:217
TypeName * origtypname
Definition: plpgsql.h:222
bool typisarray
Definition: plpgsql.h:219
TypeCacheEntry * tcache
Definition: plpgsql.h:223
uint64 tupdesc_id
Definition: plpgsql.h:224
Oid collation
Definition: plpgsql.h:218
PLpgSQL_type_type ttype
Definition: plpgsql.h:214
Oid typoid
Definition: plpgsql.h:213
char * typname
Definition: plpgsql.h:212
int16 typlen
Definition: plpgsql.h:215
int32 atttypmod
Definition: plpgsql.h:220
bool typbyval
Definition: plpgsql.h:216
int lineno
Definition: plpgsql.h:337
PLpgSQL_promise_type promise
Definition: plpgsql.h:365
PLpgSQL_datum_type dtype
Definition: plpgsql.h:334
bool freeval
Definition: plpgsql.h:358
int cursor_explicit_argrow
Definition: plpgsql.h:351
int cursor_options
Definition: plpgsql.h:352
bool notnull
Definition: plpgsql.h:339
bool isconst
Definition: plpgsql.h:338
PLpgSQL_expr * cursor_explicit_expr
Definition: plpgsql.h:350
bool isnull
Definition: plpgsql.h:357
PLpgSQL_type * datatype
Definition: plpgsql.h:343
PLpgSQL_expr * default_val
Definition: plpgsql.h:340
char * refname
Definition: plpgsql.h:336
Datum value
Definition: plpgsql.h:356
PLpgSQL_expr * default_val
Definition: plpgsql.h:318
PLpgSQL_datum_type dtype
Definition: plpgsql.h:312
char * refname
Definition: plpgsql.h:314
List * idents
Definition: plpgsql.h:1171
char * ident
Definition: plpgsql.h:1169
PLpgSQL_datum * datum
Definition: plpgsql.h:1168
bool quoted
Definition: plpgsql.h:1170
char * ident
Definition: plpgsql.h:1157
bool quoted
Definition: plpgsql.h:1158
Definition: zic.c:304
const char * name
SubXactEvent
Definition: xact.h:141
XactEvent
Definition: xact.h:127