]> granicus.if.org Git - postgresql/blob - src/pl/plpgsql/src/plpgsql.h
Combine cmin and cmax fields of HeapTupleHeaders into a single field, by
[postgresql] / src / pl / plpgsql / src / plpgsql.h
1 /*-------------------------------------------------------------------------
2  *
3  * plpgsql.h            - Definitions for the PL/pgSQL
4  *                        procedural language
5  *
6  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  *        $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.85 2007/02/09 03:35:34 tgl Exp $
12  *
13  *-------------------------------------------------------------------------
14  */
15
16 #ifndef PLPGSQL_H
17 #define PLPGSQL_H
18
19 #include "postgres.h"
20
21 #include "fmgr.h"
22 #include "miscadmin.h"
23 #include "commands/trigger.h"
24 #include "executor/spi.h"
25 #include "utils/tuplestore.h"
26
27 /**********************************************************************
28  * Definitions
29  **********************************************************************/
30
31 /* ----------
32  * Compiler's namestack item types
33  * ----------
34  */
35 enum
36 {
37         PLPGSQL_NSTYPE_LABEL,
38         PLPGSQL_NSTYPE_VAR,
39         PLPGSQL_NSTYPE_ROW,
40         PLPGSQL_NSTYPE_REC
41 };
42
43 /* ----------
44  * Datum array node types
45  * ----------
46  */
47 enum
48 {
49         PLPGSQL_DTYPE_VAR,
50         PLPGSQL_DTYPE_ROW,
51         PLPGSQL_DTYPE_REC,
52         PLPGSQL_DTYPE_RECFIELD,
53         PLPGSQL_DTYPE_ARRAYELEM,
54         PLPGSQL_DTYPE_EXPR,
55         PLPGSQL_DTYPE_TRIGARG
56 };
57
58 /* ----------
59  * Variants distinguished in PLpgSQL_type structs
60  * ----------
61  */
62 enum
63 {
64         PLPGSQL_TTYPE_SCALAR,           /* scalar types and domains */
65         PLPGSQL_TTYPE_ROW,                      /* composite types */
66         PLPGSQL_TTYPE_REC,                      /* RECORD pseudotype */
67         PLPGSQL_TTYPE_PSEUDO            /* other pseudotypes */
68 };
69
70 /* ----------
71  * Execution tree node types
72  * ----------
73  */
74 enum
75 {
76         PLPGSQL_STMT_BLOCK,
77         PLPGSQL_STMT_ASSIGN,
78         PLPGSQL_STMT_IF,
79         PLPGSQL_STMT_LOOP,
80         PLPGSQL_STMT_WHILE,
81         PLPGSQL_STMT_FORI,
82         PLPGSQL_STMT_FORS,
83         PLPGSQL_STMT_EXIT,
84         PLPGSQL_STMT_RETURN,
85         PLPGSQL_STMT_RETURN_NEXT,
86         PLPGSQL_STMT_RAISE,
87         PLPGSQL_STMT_EXECSQL,
88         PLPGSQL_STMT_DYNEXECUTE,
89         PLPGSQL_STMT_DYNFORS,
90         PLPGSQL_STMT_GETDIAG,
91         PLPGSQL_STMT_OPEN,
92         PLPGSQL_STMT_FETCH,
93         PLPGSQL_STMT_CLOSE,
94         PLPGSQL_STMT_PERFORM
95 };
96
97
98 /* ----------
99  * Execution node return codes
100  * ----------
101  */
102 enum
103 {
104         PLPGSQL_RC_OK,
105         PLPGSQL_RC_EXIT,
106         PLPGSQL_RC_RETURN,
107         PLPGSQL_RC_CONTINUE
108 };
109
110 /* ----------
111  * GET DIAGNOSTICS system attrs
112  * ----------
113  */
114 enum
115 {
116         PLPGSQL_GETDIAG_ROW_COUNT,
117         PLPGSQL_GETDIAG_RESULT_OID
118 };
119
120
121 /**********************************************************************
122  * Node and structure definitions
123  **********************************************************************/
124
125
126 typedef struct
127 {                                                               /* Dynamic string control structure */
128         int                     alloc;
129         int                     used;                   /* Including NUL terminator */
130         char       *value;
131 } PLpgSQL_dstring;
132
133
134 typedef struct
135 {                                                               /* Postgres data type */
136         char       *typname;            /* (simple) name of the type */
137         Oid                     typoid;                 /* OID of the data type */
138         int                     ttype;                  /* PLPGSQL_TTYPE_ code */
139         int16           typlen;                 /* stuff copied from its pg_type entry */
140         bool            typbyval;
141         Oid                     typrelid;
142         Oid                     typioparam;
143         FmgrInfo        typinput;               /* lookup info for typinput function */
144         int32           atttypmod;              /* typmod (taken from someplace else) */
145 } PLpgSQL_type;
146
147
148 /*
149  * PLpgSQL_datum is the common supertype for PLpgSQL_expr, PLpgSQL_var,
150  * PLpgSQL_row, PLpgSQL_rec, PLpgSQL_recfield, PLpgSQL_arrayelem, and
151  * PLpgSQL_trigarg
152  */
153 typedef struct
154 {                                                               /* Generic datum array item             */
155         int                     dtype;
156         int                     dno;
157 } PLpgSQL_datum;
158
159 /*
160  * The variants PLpgSQL_var, PLpgSQL_row, and PLpgSQL_rec share these
161  * fields
162  */
163 typedef struct
164 {                                                               /* Scalar or composite variable */
165         int                     dtype;
166         int                     dno;
167         char       *refname;
168         int                     lineno;
169 } PLpgSQL_variable;
170
171 typedef struct PLpgSQL_expr
172 {                                                               /* SQL Query to plan and execute        */
173         int                     dtype;
174         int                     exprno;
175         char       *query;
176         void       *plan;
177         Oid                *plan_argtypes;
178         /* fields for "simple expression" fast-path execution: */
179         Expr       *expr_simple_expr;           /* NULL means not a simple expr */
180         Oid                     expr_simple_type;
181
182         /*
183          * if expr is simple AND prepared in current eval_estate,
184          * expr_simple_state is valid.  Test validity by seeing if expr_simple_id
185          * matches eval_estate_simple_id.
186          */
187         ExprState  *expr_simple_state;
188         long int        expr_simple_id;
189
190         /* params to pass to expr */
191         int                     nparams;
192         int                     params[1];              /* VARIABLE SIZE ARRAY ... must be last */
193 } PLpgSQL_expr;
194
195
196 typedef struct
197 {                                                               /* Scalar variable */
198         int                     dtype;
199         int                     varno;
200         char       *refname;
201         int                     lineno;
202
203         PLpgSQL_type *datatype;
204         int                     isconst;
205         int                     notnull;
206         PLpgSQL_expr *default_val;
207         PLpgSQL_expr *cursor_explicit_expr;
208         int                     cursor_explicit_argrow;
209
210         Datum           value;
211         bool            isnull;
212         bool            freeval;
213 } PLpgSQL_var;
214
215
216 typedef struct
217 {                                                               /* Row variable */
218         int                     dtype;
219         int                     rowno;
220         char       *refname;
221         int                     lineno;
222
223         TupleDesc       rowtupdesc;
224
225         /*
226          * Note: TupleDesc is only set up for named rowtypes, else it is NULL.
227          *
228          * Note: if the underlying rowtype contains a dropped column, the
229          * corresponding fieldnames[] entry will be NULL, and there is no
230          * corresponding var (varnos[] will be -1).
231          */
232         int                     nfields;
233         char      **fieldnames;
234         int                *varnos;
235 } PLpgSQL_row;
236
237
238 typedef struct
239 {                                                               /* Record variable (non-fixed structure) */
240         int                     dtype;
241         int                     recno;
242         char       *refname;
243         int                     lineno;
244
245         HeapTuple       tup;
246         TupleDesc       tupdesc;
247         bool            freetup;
248         bool            freetupdesc;
249 } PLpgSQL_rec;
250
251
252 typedef struct
253 {                                                               /* Field in record */
254         int                     dtype;
255         int                     rfno;
256         char       *fieldname;
257         int                     recparentno;    /* dno of parent record */
258 } PLpgSQL_recfield;
259
260
261 typedef struct
262 {                                                               /* Element of array variable */
263         int                     dtype;
264         int                     dno;
265         PLpgSQL_expr *subscript;
266         int                     arrayparentno;  /* dno of parent array variable */
267 } PLpgSQL_arrayelem;
268
269
270 typedef struct
271 {                                                               /* Positional argument to trigger       */
272         int                     dtype;
273         int                     dno;
274         PLpgSQL_expr *argnum;
275 } PLpgSQL_trigarg;
276
277
278 typedef struct
279 {                                                               /* Item in the compilers namestack      */
280         int                     itemtype;
281         int                     itemno;
282         char            name[1];
283 } PLpgSQL_nsitem;
284
285
286 /* XXX: consider adapting this to use List */
287 typedef struct PLpgSQL_ns
288 {                                                               /* Compiler namestack level             */
289         int                     items_alloc;
290         int                     items_used;
291         PLpgSQL_nsitem **items;
292         struct PLpgSQL_ns *upper;
293 } PLpgSQL_ns;
294
295
296 typedef struct
297 {                                                               /* Generic execution node               */
298         int                     cmd_type;
299         int                     lineno;
300 } PLpgSQL_stmt;
301
302
303 typedef struct PLpgSQL_condition
304 {                                                               /* One EXCEPTION condition name */
305         int                     sqlerrstate;    /* SQLSTATE code */
306         char       *condname;           /* condition name (for debugging) */
307         struct PLpgSQL_condition *next;
308 } PLpgSQL_condition;
309
310 typedef struct
311 {
312         int                     sqlstate_varno;
313         int                     sqlerrm_varno;
314         List       *exc_list;           /* List of WHEN clauses */
315 } PLpgSQL_exception_block;
316
317 typedef struct
318 {                                                               /* One EXCEPTION ... WHEN clause */
319         int                     lineno;
320         PLpgSQL_condition *conditions;
321         List       *action;                     /* List of statements */
322 } PLpgSQL_exception;
323
324
325 typedef struct
326 {                                                               /* Block of statements                  */
327         int                     cmd_type;
328         int                     lineno;
329         char       *label;
330         List       *body;                       /* List of statements */
331         int                     n_initvars;
332         int                *initvarnos;
333         PLpgSQL_exception_block *exceptions;
334 } PLpgSQL_stmt_block;
335
336
337 typedef struct
338 {                                                               /* Assign statement                     */
339         int                     cmd_type;
340         int                     lineno;
341         int                     varno;
342         PLpgSQL_expr *expr;
343 } PLpgSQL_stmt_assign;
344
345 typedef struct
346 {                                                               /* PERFORM statement            */
347         int                     cmd_type;
348         int                     lineno;
349         PLpgSQL_expr *expr;
350 } PLpgSQL_stmt_perform;
351
352 typedef struct
353 {                                                               /* Get Diagnostics item         */
354         int                     kind;                   /* id for diagnostic value desired */
355         int                     target;                 /* where to assign it */
356 } PLpgSQL_diag_item;
357
358 typedef struct
359 {                                                               /* Get Diagnostics statement            */
360         int                     cmd_type;
361         int                     lineno;
362         List       *diag_items;         /* List of PLpgSQL_diag_item */
363 } PLpgSQL_stmt_getdiag;
364
365
366 typedef struct
367 {                                                               /* IF statement                         */
368         int                     cmd_type;
369         int                     lineno;
370         PLpgSQL_expr *cond;
371         List       *true_body;          /* List of statements */
372         List       *false_body;         /* List of statements */
373 } PLpgSQL_stmt_if;
374
375
376 typedef struct
377 {                                                               /* Unconditional LOOP statement         */
378         int                     cmd_type;
379         int                     lineno;
380         char       *label;
381         List       *body;                       /* List of statements */
382 } PLpgSQL_stmt_loop;
383
384
385 typedef struct
386 {                                                               /* WHILE cond LOOP statement            */
387         int                     cmd_type;
388         int                     lineno;
389         char       *label;
390         PLpgSQL_expr *cond;
391         List       *body;                       /* List of statements */
392 } PLpgSQL_stmt_while;
393
394
395 typedef struct
396 {                                                               /* FOR statement with integer loopvar   */
397         int                     cmd_type;
398         int                     lineno;
399         char       *label;
400         PLpgSQL_var *var;
401         PLpgSQL_expr *lower;
402         PLpgSQL_expr *upper;
403         PLpgSQL_expr *by;
404         int                     reverse;
405         List       *body;                       /* List of statements */
406 } PLpgSQL_stmt_fori;
407
408
409 typedef struct
410 {                                                               /* FOR statement running over SELECT    */
411         int                     cmd_type;
412         int                     lineno;
413         char       *label;
414         PLpgSQL_rec *rec;
415         PLpgSQL_row *row;
416         PLpgSQL_expr *query;
417         List       *body;                       /* List of statements */
418 } PLpgSQL_stmt_fors;
419
420
421 typedef struct
422 {                                                               /* FOR statement running over EXECUTE   */
423         int                     cmd_type;
424         int                     lineno;
425         char       *label;
426         PLpgSQL_rec *rec;
427         PLpgSQL_row *row;
428         PLpgSQL_expr *query;
429         List       *body;                       /* List of statements */
430 } PLpgSQL_stmt_dynfors;
431
432
433 typedef struct
434 {                                                               /* OPEN a curvar                                        */
435         int                     cmd_type;
436         int                     lineno;
437         int                     curvar;
438         PLpgSQL_row *returntype;
439         PLpgSQL_expr *argquery;
440         PLpgSQL_expr *query;
441         PLpgSQL_expr *dynquery;
442 } PLpgSQL_stmt_open;
443
444
445 typedef struct
446 {                                                               /* FETCH curvar INTO statement          */
447         int                     cmd_type;
448         int                     lineno;
449         PLpgSQL_rec *rec;
450         PLpgSQL_row *row;
451         int                     curvar;
452 } PLpgSQL_stmt_fetch;
453
454
455 typedef struct
456 {                                                               /* CLOSE curvar                                         */
457         int                     cmd_type;
458         int                     lineno;
459         int                     curvar;
460 } PLpgSQL_stmt_close;
461
462
463 typedef struct
464 {                                                               /* EXIT or CONTINUE statement                   */
465         int                     cmd_type;
466         int                     lineno;
467         bool            is_exit;                /* Is this an exit or a continue? */
468         char       *label;
469         PLpgSQL_expr *cond;
470 } PLpgSQL_stmt_exit;
471
472
473 typedef struct
474 {                                                               /* RETURN statement                     */
475         int                     cmd_type;
476         int                     lineno;
477         PLpgSQL_expr *expr;
478         int                     retvarno;
479 } PLpgSQL_stmt_return;
480
481 typedef struct
482 {                                                               /* RETURN NEXT statement */
483         int                     cmd_type;
484         int                     lineno;
485         PLpgSQL_expr *expr;
486         int                     retvarno;
487 } PLpgSQL_stmt_return_next;
488
489 typedef struct
490 {                                                               /* RAISE statement                      */
491         int                     cmd_type;
492         int                     lineno;
493         int                     elog_level;
494         char       *message;
495         List       *params;                     /* list of expressions */
496 } PLpgSQL_stmt_raise;
497
498
499 typedef struct
500 {                                                               /* Generic SQL statement to execute */
501         int                     cmd_type;
502         int                     lineno;
503         PLpgSQL_expr *sqlstmt;
504         bool            mod_stmt;               /* is the stmt INSERT/UPDATE/DELETE? */
505         /* note: mod_stmt is set when we plan the query */
506         bool            into;                   /* INTO supplied? */
507         bool            strict;                 /* INTO STRICT flag */
508         PLpgSQL_rec *rec;                       /* INTO target, if record */
509         PLpgSQL_row *row;                       /* INTO target, if row */
510 } PLpgSQL_stmt_execsql;
511
512
513 typedef struct
514 {                                                               /* Dynamic SQL string to execute */
515         int                     cmd_type;
516         int                     lineno;
517         PLpgSQL_expr *query;            /* string expression */
518         bool            into;                   /* INTO supplied? */
519         bool            strict;                 /* INTO STRICT flag */
520         PLpgSQL_rec *rec;                       /* INTO target, if record */
521         PLpgSQL_row *row;                       /* INTO target, if row */
522 } PLpgSQL_stmt_dynexecute;
523
524
525 typedef struct PLpgSQL_func_hashkey
526 {                                                               /* Hash lookup key for functions */
527         Oid                     funcOid;
528
529         /*
530          * For a trigger function, the OID of the relation triggered on is part of
531          * the hashkey --- we want to compile the trigger separately for each
532          * relation it is used with, in case the rowtype is different.  Zero if
533          * not called as a trigger.
534          */
535         Oid                     trigrelOid;
536
537         /*
538          * We include actual argument types in the hash key to support polymorphic
539          * PLpgSQL functions.  Be careful that extra positions are zeroed!
540          */
541         Oid                     argtypes[FUNC_MAX_ARGS];
542 } PLpgSQL_func_hashkey;
543
544
545 typedef struct PLpgSQL_function
546 {                                                               /* Complete compiled function     */
547         char       *fn_name;
548         Oid                     fn_oid;
549         TransactionId fn_xmin;
550         ItemPointerData fn_tid;
551         int                     fn_functype;
552         PLpgSQL_func_hashkey *fn_hashkey;       /* back-link to hashtable key */
553         MemoryContext fn_cxt;
554
555         Oid                     fn_rettype;
556         int                     fn_rettyplen;
557         bool            fn_retbyval;
558         FmgrInfo        fn_retinput;
559         Oid                     fn_rettypioparam;
560         bool            fn_retistuple;
561         bool            fn_retset;
562         bool            fn_readonly;
563
564         int                     fn_nargs;
565         int                     fn_argvarnos[FUNC_MAX_ARGS];
566         int                     out_param_varno;
567         int                     found_varno;
568         int                     new_varno;
569         int                     old_varno;
570         int                     tg_name_varno;
571         int                     tg_when_varno;
572         int                     tg_level_varno;
573         int                     tg_op_varno;
574         int                     tg_relid_varno;
575         int                     tg_relname_varno;
576         int                     tg_table_name_varno;
577         int                     tg_table_schema_varno;
578         int                     tg_nargs_varno;
579
580         int                     ndatums;
581         PLpgSQL_datum **datums;
582         PLpgSQL_stmt_block *action;
583
584         unsigned long use_count;
585 } PLpgSQL_function;
586
587
588 typedef struct
589 {                                                               /* Runtime execution data       */
590         Datum           retval;
591         bool            retisnull;
592         Oid                     rettype;                /* type of current retval */
593
594         Oid                     fn_rettype;             /* info about declared function rettype */
595         bool            retistuple;
596         bool            retisset;
597
598         bool            readonly_func;
599
600         TupleDesc       rettupdesc;
601         char       *exitlabel;          /* the "target" label of the current EXIT or
602                                                                  * CONTINUE stmt, if any */
603
604         Tuplestorestate *tuple_store;           /* SRFs accumulate results here */
605         MemoryContext tuple_store_cxt;
606         ReturnSetInfo *rsi;
607
608         int                     trig_nargs;
609         Datum      *trig_argv;
610
611         int                     found_varno;
612         int                     ndatums;
613         PLpgSQL_datum **datums;
614
615         /* temporary state for results from evaluation of query or expr */
616         SPITupleTable *eval_tuptable;
617         uint32          eval_processed;
618         Oid                     eval_lastoid;
619         ExprContext *eval_econtext;     /* for executing simple expressions */
620         EState     *eval_estate;        /* EState containing eval_econtext */
621         long int        eval_estate_simple_id;          /* ID for eval_estate */
622
623         /* status information for error context reporting */
624         PLpgSQL_function *err_func; /* current func */
625         PLpgSQL_stmt *err_stmt;         /* current stmt */
626         const char *err_text;           /* additional state info */
627         void       *plugin_info;        /* reserved for use by optional plugin */
628 } PLpgSQL_execstate;
629
630
631 /*
632  * A PLpgSQL_plugin structure represents an instrumentation plugin.
633  * To instrument PL/pgSQL, a plugin library must access the rendezvous
634  * variable "PLpgSQL_plugin" and set it to point to a PLpgSQL_plugin struct.
635  * Typically the struct could just be static data in the plugin library.
636  * We expect that a plugin would do this at library load time (_PG_init()).
637  * It must also be careful to set the rendezvous variable back to NULL
638  * if it is unloaded (_PG_fini()).
639  *
640  * This structure is basically a collection of function pointers --- at
641  * various interesting points in pl_exec.c, we call these functions
642  * (if the pointers are non-NULL) to give the plugin a chance to watch
643  * what we are doing.
644  *
645  *      func_setup is called when we start a function, before we've initialized
646  *      the local variables defined by the function.
647  *
648  *      func_beg is called when we start a function, after we've initialized
649  *      the local variables.
650  *
651  *      func_end is called at the end of a function.
652  *
653  *      stmt_beg and stmt_end are called before and after (respectively) each
654  *      statement.
655  *
656  * Also, immediately before any call to func_setup, PL/pgSQL fills in the
657  * error_callback and assign_expr fields with pointers to its own
658  * plpgsql_exec_error_callback and exec_assign_expr functions.  This is
659  * a somewhat ad-hoc expedient to simplify life for debugger plugins.
660  */
661
662 typedef struct
663 {
664         /* Function pointers set up by the plugin */
665         void            (*func_setup) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
666         void            (*func_beg) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
667         void            (*func_end) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
668         void            (*stmt_beg) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
669         void            (*stmt_end) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
670
671         /* Function pointers set by PL/pgSQL itself */
672         void            (*error_callback) (void *arg);
673         void            (*assign_expr) (PLpgSQL_execstate *estate, PLpgSQL_datum *target,
674                                                                                         PLpgSQL_expr *expr);
675 } PLpgSQL_plugin;
676
677
678 /**********************************************************************
679  * Global variable declarations
680  **********************************************************************/
681
682 extern bool plpgsql_DumpExecTree;
683 extern bool plpgsql_SpaceScanned;
684 extern int      plpgsql_nDatums;
685 extern PLpgSQL_datum **plpgsql_Datums;
686
687 extern int      plpgsql_error_lineno;
688 extern char *plpgsql_error_funcname;
689
690 /* linkage to the real yytext variable */
691 extern char *plpgsql_base_yytext;
692
693 #define yytext plpgsql_base_yytext
694
695 extern PLpgSQL_function *plpgsql_curr_compile;
696 extern bool plpgsql_check_syntax;
697 extern MemoryContext compile_tmp_cxt;
698
699 extern PLpgSQL_plugin **plugin_ptr;
700
701 /**********************************************************************
702  * Function declarations
703  **********************************************************************/
704
705 /* ----------
706  * Functions in pl_comp.c
707  * ----------
708  */
709 extern PLpgSQL_function *plpgsql_compile(FunctionCallInfo fcinfo,
710                                 bool forValidator);
711 extern int      plpgsql_parse_word(char *word);
712 extern int      plpgsql_parse_dblword(char *word);
713 extern int      plpgsql_parse_tripword(char *word);
714 extern int      plpgsql_parse_wordtype(char *word);
715 extern int      plpgsql_parse_dblwordtype(char *word);
716 extern int      plpgsql_parse_tripwordtype(char *word);
717 extern int      plpgsql_parse_wordrowtype(char *word);
718 extern int      plpgsql_parse_dblwordrowtype(char *word);
719 extern PLpgSQL_type *plpgsql_parse_datatype(const char *string);
720 extern PLpgSQL_type *plpgsql_build_datatype(Oid typeOid, int32 typmod);
721 extern PLpgSQL_variable *plpgsql_build_variable(const char *refname, int lineno,
722                                            PLpgSQL_type *dtype,
723                                            bool add2namespace);
724 extern PLpgSQL_condition *plpgsql_parse_err_condition(char *condname);
725 extern void plpgsql_adddatum(PLpgSQL_datum *new);
726 extern int      plpgsql_add_initdatums(int **varnos);
727 extern void plpgsql_HashTableInit(void);
728 extern void plpgsql_compile_error_callback(void *arg);
729
730 /* ----------
731  * Functions in pl_handler.c
732  * ----------
733  */
734 extern void _PG_init(void);
735 extern Datum plpgsql_call_handler(PG_FUNCTION_ARGS);
736 extern Datum plpgsql_validator(PG_FUNCTION_ARGS);
737
738 /* ----------
739  * Functions in pl_exec.c
740  * ----------
741  */
742 extern Datum plpgsql_exec_function(PLpgSQL_function *func,
743                                           FunctionCallInfo fcinfo);
744 extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function *func,
745                                          TriggerData *trigdata);
746 extern void plpgsql_xact_cb(XactEvent event, void *arg);
747 extern void plpgsql_subxact_cb(SubXactEvent event, SubTransactionId mySubid,
748                                                            SubTransactionId parentSubid, void *arg);
749
750 /* ----------
751  * Functions for the dynamic string handling in pl_funcs.c
752  * ----------
753  */
754 extern void plpgsql_dstring_init(PLpgSQL_dstring *ds);
755 extern void plpgsql_dstring_free(PLpgSQL_dstring *ds);
756 extern void plpgsql_dstring_append(PLpgSQL_dstring *ds, const char *str);
757 extern void plpgsql_dstring_append_char(PLpgSQL_dstring *ds, char c);
758 extern char *plpgsql_dstring_get(PLpgSQL_dstring *ds);
759
760 /* ----------
761  * Functions for the namestack handling in pl_funcs.c
762  * ----------
763  */
764 extern void plpgsql_ns_init(void);
765 extern bool plpgsql_ns_setlocal(bool flag);
766 extern void plpgsql_ns_push(char *label);
767 extern void plpgsql_ns_pop(void);
768 extern void plpgsql_ns_additem(int itemtype, int itemno, const char *name);
769 extern PLpgSQL_nsitem *plpgsql_ns_lookup(char *name, char *nsname);
770 extern void plpgsql_ns_rename(char *oldname, char *newname);
771
772 /* ----------
773  * Other functions in pl_funcs.c
774  * ----------
775  */
776 extern void plpgsql_convert_ident(const char *s, char **output, int numidents);
777 extern const char *plpgsql_stmt_typename(PLpgSQL_stmt *stmt);
778 extern void plpgsql_dumptree(PLpgSQL_function *func);
779
780 /* ----------
781  * Externs in gram.y and scan.l
782  * ----------
783  */
784 extern PLpgSQL_expr *plpgsql_read_expression(int until, const char *expected);
785 extern int      plpgsql_yyparse(void);
786 extern int      plpgsql_base_yylex(void);
787 extern int      plpgsql_yylex(void);
788 extern void plpgsql_push_back_token(int token);
789 extern void plpgsql_yyerror(const char *message);
790 extern int      plpgsql_scanner_lineno(void);
791 extern void plpgsql_scanner_init(const char *str, int functype);
792 extern void plpgsql_scanner_finish(void);
793 extern char *plpgsql_get_string_value(void);
794
795 #endif   /* PLPGSQL_H */