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