]> granicus.if.org Git - postgresql/blob - src/pl/plpgsql/src/plpgsql.h
Add a CONTINUE statement to PL/PgSQL, which can be used to begin the
[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.64 2005/06/22 01:35:02 neilc 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         /* if expr is simple AND in use in current xact, these fields are set: */
204         ExprState  *expr_simple_state;
205         struct PLpgSQL_expr *expr_simple_next;
206         /* params to pass to expr */
207         int                     nparams;
208         int                     params[1];              /* VARIABLE SIZE ARRAY ... must be last */
209 } PLpgSQL_expr;
210
211
212 typedef struct
213 {                                                               /* Scalar variable */
214         int                     dtype;
215         int                     varno;
216         char       *refname;
217         int                     lineno;
218
219         PLpgSQL_type *datatype;
220         int                     isconst;
221         int                     notnull;
222         PLpgSQL_expr *default_val;
223         PLpgSQL_expr *cursor_explicit_expr;
224         int                     cursor_explicit_argrow;
225
226         Datum           value;
227         bool            isnull;
228         bool            freeval;
229 } PLpgSQL_var;
230
231
232 typedef struct
233 {                                                               /* Row variable */
234         int                     dtype;
235         int                     rowno;
236         char       *refname;
237         int                     lineno;
238
239         TupleDesc       rowtupdesc;
240
241         /*
242          * Note: TupleDesc is only set up for named rowtypes, else it is NULL.
243          *
244          * Note: if the underlying rowtype contains a dropped column, the
245          * corresponding fieldnames[] entry will be NULL, and there is no
246          * corresponding var (varnos[] will be -1).
247          */
248         int                     nfields;
249         char      **fieldnames;
250         int                *varnos;
251 } PLpgSQL_row;
252
253
254 typedef struct
255 {                                                               /* Record variable (non-fixed structure) */
256         int                     dtype;
257         int                     recno;
258         char       *refname;
259         int                     lineno;
260
261         HeapTuple       tup;
262         TupleDesc       tupdesc;
263         bool            freetup;
264         bool            freetupdesc;
265 } PLpgSQL_rec;
266
267
268 typedef struct
269 {                                                               /* Field in record */
270         int                     dtype;
271         int                     rfno;
272         char       *fieldname;
273         int                     recparentno;    /* dno of parent record */
274 } PLpgSQL_recfield;
275
276
277 typedef struct
278 {                                                               /* Element of array variable */
279         int                     dtype;
280         int                     dno;
281         PLpgSQL_expr *subscript;
282         int                     arrayparentno;  /* dno of parent array variable */
283 } PLpgSQL_arrayelem;
284
285
286 typedef struct
287 {                                                               /* Positional argument to trigger       */
288         int                     dtype;
289         int                     dno;
290         PLpgSQL_expr *argnum;
291 } PLpgSQL_trigarg;
292
293
294 typedef struct
295 {                                                               /* Item in the compilers namestack      */
296         int                     itemtype;
297         int                     itemno;
298         char            name[1];
299 } PLpgSQL_nsitem;
300
301
302 /* XXX: consider adapting this to use List */
303 typedef struct PLpgSQL_ns
304 {                                                               /* Compiler namestack level             */
305         int                     items_alloc;
306         int                     items_used;
307         PLpgSQL_nsitem **items;
308         struct PLpgSQL_ns *upper;
309 } PLpgSQL_ns;
310
311
312 typedef struct
313 {                                                               /* Generic execution node               */
314         int                     cmd_type;
315         int                     lineno;
316 } PLpgSQL_stmt;
317
318
319 typedef struct PLpgSQL_condition
320 {                                                               /* One EXCEPTION condition name */
321         int                     sqlerrstate;    /* SQLSTATE code */
322         char       *condname;           /* condition name (for debugging) */
323         struct PLpgSQL_condition *next;
324 } PLpgSQL_condition;
325
326 typedef struct
327 {
328         int                     sqlstate_varno;
329         int                     sqlerrm_varno;
330         List       *exc_list;           /* List of WHEN clauses */
331 } PLpgSQL_exception_block;
332
333 typedef struct
334 {                                                               /* One EXCEPTION ... WHEN clause */
335         int                     lineno;
336         PLpgSQL_condition *conditions;
337         List       *action;                     /* List of statements */
338 } PLpgSQL_exception;
339
340
341 typedef struct
342 {                                                               /* Block of statements                  */
343         int                     cmd_type;
344         int                     lineno;
345         char       *label;
346         List       *body;                       /* List of statements */
347         int                     n_initvars;
348         int                *initvarnos;
349         PLpgSQL_exception_block *exceptions;
350 } PLpgSQL_stmt_block;
351
352
353 typedef struct
354 {                                                               /* Assign statement                     */
355         int                     cmd_type;
356         int                     lineno;
357         int                     varno;
358         PLpgSQL_expr *expr;
359 } PLpgSQL_stmt_assign;
360
361 typedef struct
362 {                                                               /* PERFORM statement            */
363         int                     cmd_type;
364         int                     lineno;
365         PLpgSQL_expr *expr;
366 } PLpgSQL_stmt_perform;
367
368 typedef struct
369 {                                                               /* Get Diagnostics item         */
370         int                     kind;                   /* id for diagnostic value desired */
371         int                     target;                 /* where to assign it */
372 } PLpgSQL_diag_item;
373
374 typedef struct
375 {                                                               /* Get Diagnostics statement            */
376         int                     cmd_type;
377         int                     lineno;
378         List       *diag_items;         /* List of PLpgSQL_diag_item */
379 } PLpgSQL_stmt_getdiag;
380
381
382 typedef struct
383 {                                                               /* IF statement                         */
384         int                     cmd_type;
385         int                     lineno;
386         PLpgSQL_expr *cond;
387         List       *true_body;          /* List of statements */
388         List       *false_body;         /* List of statements */
389 } PLpgSQL_stmt_if;
390
391
392 typedef struct
393 {                                                               /* Unconditional LOOP statement         */
394         int                     cmd_type;
395         int                     lineno;
396         char       *label;
397         List       *body;                       /* List of statements */
398 } PLpgSQL_stmt_loop;
399
400
401 typedef struct
402 {                                                               /* WHILE cond LOOP statement            */
403         int                     cmd_type;
404         int                     lineno;
405         char       *label;
406         PLpgSQL_expr *cond;
407         List       *body;                       /* List of statements */
408 } PLpgSQL_stmt_while;
409
410
411 typedef struct
412 {                                                               /* FOR statement with integer loopvar   */
413         int                     cmd_type;
414         int                     lineno;
415         char       *label;
416         PLpgSQL_var *var;
417         PLpgSQL_expr *lower;
418         PLpgSQL_expr *upper;
419         int                     reverse;
420         List       *body;                       /* List of statements */
421 } PLpgSQL_stmt_fori;
422
423
424 typedef struct
425 {                                                               /* FOR statement running over SELECT    */
426         int                     cmd_type;
427         int                     lineno;
428         char       *label;
429         PLpgSQL_rec *rec;
430         PLpgSQL_row *row;
431         PLpgSQL_expr *query;
432         List       *body;                       /* List of statements */
433 } PLpgSQL_stmt_fors;
434
435
436 typedef struct
437 {                                                               /* FOR statement running over EXECUTE   */
438         int                     cmd_type;
439         int                     lineno;
440         char       *label;
441         PLpgSQL_rec *rec;
442         PLpgSQL_row *row;
443         PLpgSQL_expr *query;
444         List       *body;                       /* List of statements */
445 } PLpgSQL_stmt_dynfors;
446
447
448 typedef struct
449 {                                                               /* SELECT ... INTO statement            */
450         int                     cmd_type;
451         int                     lineno;
452         PLpgSQL_rec *rec;
453         PLpgSQL_row *row;
454         PLpgSQL_expr *query;
455 } PLpgSQL_stmt_select;
456
457
458 typedef struct
459 {                                                               /* OPEN a curvar                                        */
460         int                     cmd_type;
461         int                     lineno;
462         int                     curvar;
463         PLpgSQL_row *returntype;
464         PLpgSQL_expr *argquery;
465         PLpgSQL_expr *query;
466         PLpgSQL_expr *dynquery;
467 } PLpgSQL_stmt_open;
468
469
470 typedef struct
471 {                                                               /* FETCH curvar INTO statement          */
472         int                     cmd_type;
473         int                     lineno;
474         PLpgSQL_rec *rec;
475         PLpgSQL_row *row;
476         int                     curvar;
477 } PLpgSQL_stmt_fetch;
478
479
480 typedef struct
481 {                                                               /* CLOSE curvar                                         */
482         int                     cmd_type;
483         int                     lineno;
484         int                     curvar;
485 } PLpgSQL_stmt_close;
486
487
488 typedef struct
489 {                                                               /* EXIT or CONTINUE statement                   */
490         int                     cmd_type;
491         int                     lineno;
492         bool            is_exit;                /* Is this an exit or a continue? */
493         char       *label;
494         PLpgSQL_expr *cond;
495 } PLpgSQL_stmt_exit;
496
497
498 typedef struct
499 {                                                               /* RETURN statement                     */
500         int                     cmd_type;
501         int                     lineno;
502         PLpgSQL_expr *expr;
503         int                     retvarno;
504 } PLpgSQL_stmt_return;
505
506 typedef struct
507 {                                                               /* RETURN NEXT statement */
508         int                     cmd_type;
509         int                     lineno;
510         PLpgSQL_expr *expr;
511         int                     retvarno;
512 } PLpgSQL_stmt_return_next;
513
514 typedef struct
515 {                                                               /* RAISE statement                      */
516         int                     cmd_type;
517         int                     lineno;
518         int                     elog_level;
519         char       *message;
520         List       *params;                     /* list of expressions */
521 } PLpgSQL_stmt_raise;
522
523
524 typedef struct
525 {                                                               /* Generic SQL statement to execute */
526         int                     cmd_type;
527         int                     lineno;
528         PLpgSQL_expr *sqlstmt;
529 } PLpgSQL_stmt_execsql;
530
531
532 typedef struct
533 {                                                               /* Dynamic SQL string to execute */
534         int                     cmd_type;
535         int                     lineno;
536         PLpgSQL_rec *rec;                                       /* INTO record or row variable */
537         PLpgSQL_row *row;
538         PLpgSQL_expr *query;
539 } PLpgSQL_stmt_dynexecute;
540
541
542 typedef struct PLpgSQL_func_hashkey
543 {                                                               /* Hash lookup key for functions */
544         Oid                     funcOid;
545
546         /*
547          * For a trigger function, the OID of the relation triggered on is
548          * part of the hashkey --- we want to compile the trigger separately
549          * for each relation it is used with, in case the rowtype is
550          * different.  Zero if not called as a trigger.
551          */
552         Oid                     trigrelOid;
553
554         /*
555          * We include actual argument types in the hash key to support
556          * polymorphic PLpgSQL functions.  Be careful that extra positions are
557          * zeroed!
558          */
559         Oid                     argtypes[FUNC_MAX_ARGS];
560 } PLpgSQL_func_hashkey;
561
562
563 typedef struct PLpgSQL_function
564 {                                                               /* Complete compiled function     */
565         char       *fn_name;
566         Oid                     fn_oid;
567         TransactionId fn_xmin;
568         CommandId       fn_cmin;
569         int                     fn_functype;
570         PLpgSQL_func_hashkey *fn_hashkey;       /* back-link to hashtable key */
571         MemoryContext fn_cxt;
572
573         Oid                     fn_rettype;
574         int                     fn_rettyplen;
575         bool            fn_retbyval;
576         FmgrInfo        fn_retinput;
577         Oid                     fn_rettypioparam;
578         bool            fn_retistuple;
579         bool            fn_retset;
580         bool            fn_readonly;
581
582         int                     fn_nargs;
583         int                     fn_argvarnos[FUNC_MAX_ARGS];
584         int                     out_param_varno;
585         int                     found_varno;
586         int                     new_varno;
587         int                     old_varno;
588         int                     tg_name_varno;
589         int                     tg_when_varno;
590         int                     tg_level_varno;
591         int                     tg_op_varno;
592         int                     tg_relid_varno;
593         int                     tg_relname_varno;
594         int                     tg_nargs_varno;
595
596         int                     ndatums;
597         PLpgSQL_datum **datums;
598         PLpgSQL_stmt_block *action;
599 } PLpgSQL_function;
600
601
602 typedef struct
603 {                                                               /* Runtime execution data       */
604         Datum           retval;
605         bool            retisnull;
606         Oid                     rettype;                /* type of current retval */
607
608         Oid                     fn_rettype;             /* info about declared function rettype */
609         bool            retistuple;
610         bool            retisset;
611
612         bool            readonly_func;
613
614         TupleDesc       rettupdesc;
615         char       *exitlabel;          /* the "target" label of the current
616                                                                  * EXIT or CONTINUE stmt, if any */
617
618         Tuplestorestate *tuple_store;           /* SRFs accumulate results here */
619         MemoryContext tuple_store_cxt;
620         ReturnSetInfo *rsi;
621
622         int                     trig_nargs;
623         Datum      *trig_argv;
624
625         int                     found_varno;
626         int                     ndatums;
627         PLpgSQL_datum **datums;
628
629         /* temporary state for results from evaluation of query or expr */
630         SPITupleTable *eval_tuptable;
631         uint32          eval_processed;
632         Oid                     eval_lastoid;
633         ExprContext *eval_econtext;
634
635         /* status information for error context reporting */
636         PLpgSQL_function *err_func; /* current func */
637         PLpgSQL_stmt *err_stmt;         /* current stmt */
638         const char *err_text;           /* additional state info */
639 } PLpgSQL_execstate;
640
641
642 /**********************************************************************
643  * Global variable declarations
644  **********************************************************************/
645
646 extern bool     plpgsql_DumpExecTree;
647 extern bool     plpgsql_SpaceScanned;
648 extern int      plpgsql_nDatums;
649 extern PLpgSQL_datum **plpgsql_Datums;
650
651 extern int      plpgsql_error_lineno;
652 extern char *plpgsql_error_funcname;
653
654 /* linkage to the real yytext variable */
655 extern char *plpgsql_base_yytext;
656
657 #define plpgsql_yytext plpgsql_base_yytext
658
659 extern PLpgSQL_function *plpgsql_curr_compile;
660 extern bool             plpgsql_check_syntax;
661 extern MemoryContext compile_tmp_cxt;
662
663 /**********************************************************************
664  * Function declarations
665  **********************************************************************/
666
667 /* ----------
668  * Functions in pl_comp.c
669  * ----------
670  */
671 extern PLpgSQL_function *plpgsql_compile(FunctionCallInfo fcinfo,
672                                 bool forValidator);
673 extern int      plpgsql_parse_word(char *word);
674 extern int      plpgsql_parse_dblword(char *word);
675 extern int      plpgsql_parse_tripword(char *word);
676 extern int      plpgsql_parse_wordtype(char *word);
677 extern int      plpgsql_parse_dblwordtype(char *word);
678 extern int      plpgsql_parse_tripwordtype(char *word);
679 extern int      plpgsql_parse_wordrowtype(char *word);
680 extern int      plpgsql_parse_dblwordrowtype(char *word);
681 extern PLpgSQL_type *plpgsql_parse_datatype(const char *string);
682 extern PLpgSQL_type *plpgsql_build_datatype(Oid typeOid, int32 typmod);
683 extern PLpgSQL_variable *plpgsql_build_variable(const char *refname, int lineno,
684                                            PLpgSQL_type *dtype,
685                                            bool add2namespace);
686 extern PLpgSQL_condition *plpgsql_parse_err_condition(char *condname);
687 extern void plpgsql_adddatum(PLpgSQL_datum *new);
688 extern int      plpgsql_add_initdatums(int **varnos);
689 extern void plpgsql_HashTableInit(void);
690 extern void plpgsql_compile_error_callback(void *arg);
691
692 /* ----------
693  * Functions in pl_handler.c
694  * ----------
695  */
696 extern void plpgsql_init(void);
697 extern Datum plpgsql_call_handler(PG_FUNCTION_ARGS);
698 extern Datum plpgsql_validator(PG_FUNCTION_ARGS);
699
700 /* ----------
701  * Functions in pl_exec.c
702  * ----------
703  */
704 extern Datum plpgsql_exec_function(PLpgSQL_function *func,
705                                           FunctionCallInfo fcinfo);
706 extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function *func,
707                                          TriggerData *trigdata);
708 extern void plpgsql_xact_cb(XactEvent event, void *arg);
709
710 /* ----------
711  * Functions for the dynamic string handling in pl_funcs.c
712  * ----------
713  */
714 extern void plpgsql_dstring_init(PLpgSQL_dstring *ds);
715 extern void plpgsql_dstring_free(PLpgSQL_dstring *ds);
716 extern void plpgsql_dstring_append(PLpgSQL_dstring *ds, const char *str);
717 extern void plpgsql_dstring_append_char(PLpgSQL_dstring *ds, char c);
718 extern char *plpgsql_dstring_get(PLpgSQL_dstring *ds);
719
720 /* ----------
721  * Functions for the namestack handling in pl_funcs.c
722  * ----------
723  */
724 extern void plpgsql_ns_init(void);
725 extern bool plpgsql_ns_setlocal(bool flag);
726 extern void plpgsql_ns_push(char *label);
727 extern void plpgsql_ns_pop(void);
728 extern void plpgsql_ns_additem(int itemtype, int itemno, const char *name);
729 extern PLpgSQL_nsitem *plpgsql_ns_lookup(char *name, char *nsname);
730 extern void plpgsql_ns_rename(char *oldname, char *newname);
731
732 /* ----------
733  * Other functions in pl_funcs.c
734  * ----------
735  */
736 extern void plpgsql_convert_ident(const char *s, char **output, int numidents);
737 extern const char *plpgsql_stmt_typename(PLpgSQL_stmt *stmt);
738 extern void plpgsql_dumptree(PLpgSQL_function *func);
739
740 /* ----------
741  * Externs in gram.y and scan.l
742  * ----------
743  */
744 extern PLpgSQL_expr *plpgsql_read_expression(int until, const char *expected);
745 extern int      plpgsql_yyparse(void);
746 extern int      plpgsql_base_yylex(void);
747 extern int      plpgsql_yylex(void);
748 extern void plpgsql_push_back_token(int token);
749 extern void plpgsql_yyerror(const char *message);
750 extern int      plpgsql_scanner_lineno(void);
751 extern void plpgsql_scanner_init(const char *str, int functype);
752 extern void plpgsql_scanner_finish(void);
753 extern char *plpgsql_get_string_value(void);
754
755 #endif   /* PLPGSQL_H */