Redefine _() to dgettext() instead of gettext() so that it uses the plpgsql
[PostgreSQL.git] / src / pl / plpgsql / src / plpgsql.h
blobb2490aa44d70199ce1980a5d0640f90857eae2cd
1 /*-------------------------------------------------------------------------
3 * plpgsql.h - Definitions for the PL/pgSQL
4 * procedural language
6 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
10 * IDENTIFICATION
11 * $PostgreSQL$
13 *-------------------------------------------------------------------------
16 #ifndef PLPGSQL_H
17 #define PLPGSQL_H
19 #include "postgres.h"
21 #include "access/xact.h"
22 #include "fmgr.h"
23 #include "miscadmin.h"
24 #include "commands/trigger.h"
25 #include "executor/spi.h"
26 #include "utils/tuplestore.h"
28 /**********************************************************************
29 * Definitions
30 **********************************************************************/
32 /* define our text domain for translations */
33 #undef TEXTDOMAIN
34 #define TEXTDOMAIN PG_TEXTDOMAIN("plpgsql")
36 #undef _
37 #define _(x) dgettext(TEXTDOMAIN, x)
39 /* ----------
40 * Compiler's namestack item types
41 * ----------
43 enum
45 PLPGSQL_NSTYPE_LABEL,
46 PLPGSQL_NSTYPE_VAR,
47 PLPGSQL_NSTYPE_ROW,
48 PLPGSQL_NSTYPE_REC
51 /* ----------
52 * Datum array node types
53 * ----------
55 enum
57 PLPGSQL_DTYPE_VAR,
58 PLPGSQL_DTYPE_ROW,
59 PLPGSQL_DTYPE_REC,
60 PLPGSQL_DTYPE_RECFIELD,
61 PLPGSQL_DTYPE_ARRAYELEM,
62 PLPGSQL_DTYPE_EXPR,
63 PLPGSQL_DTYPE_TRIGARG
66 /* ----------
67 * Variants distinguished in PLpgSQL_type structs
68 * ----------
70 enum
72 PLPGSQL_TTYPE_SCALAR, /* scalar types and domains */
73 PLPGSQL_TTYPE_ROW, /* composite types */
74 PLPGSQL_TTYPE_REC, /* RECORD pseudotype */
75 PLPGSQL_TTYPE_PSEUDO /* other pseudotypes */
78 /* ----------
79 * Execution tree node types
80 * ----------
82 enum PLpgSQL_stmt_types
84 PLPGSQL_STMT_BLOCK,
85 PLPGSQL_STMT_ASSIGN,
86 PLPGSQL_STMT_IF,
87 PLPGSQL_STMT_CASE,
88 PLPGSQL_STMT_LOOP,
89 PLPGSQL_STMT_WHILE,
90 PLPGSQL_STMT_FORI,
91 PLPGSQL_STMT_FORS,
92 PLPGSQL_STMT_FORC,
93 PLPGSQL_STMT_EXIT,
94 PLPGSQL_STMT_RETURN,
95 PLPGSQL_STMT_RETURN_NEXT,
96 PLPGSQL_STMT_RETURN_QUERY,
97 PLPGSQL_STMT_RAISE,
98 PLPGSQL_STMT_EXECSQL,
99 PLPGSQL_STMT_DYNEXECUTE,
100 PLPGSQL_STMT_DYNFORS,
101 PLPGSQL_STMT_GETDIAG,
102 PLPGSQL_STMT_OPEN,
103 PLPGSQL_STMT_FETCH,
104 PLPGSQL_STMT_CLOSE,
105 PLPGSQL_STMT_PERFORM
109 /* ----------
110 * Execution node return codes
111 * ----------
113 enum
115 PLPGSQL_RC_OK,
116 PLPGSQL_RC_EXIT,
117 PLPGSQL_RC_RETURN,
118 PLPGSQL_RC_CONTINUE,
119 PLPGSQL_RC_RERAISE
122 /* ----------
123 * GET DIAGNOSTICS system attrs
124 * ----------
126 enum
128 PLPGSQL_GETDIAG_ROW_COUNT,
129 PLPGSQL_GETDIAG_RESULT_OID
132 /* --------
133 * RAISE statement options
134 * --------
136 enum
138 PLPGSQL_RAISEOPTION_ERRCODE,
139 PLPGSQL_RAISEOPTION_MESSAGE,
140 PLPGSQL_RAISEOPTION_DETAIL,
141 PLPGSQL_RAISEOPTION_HINT
145 /**********************************************************************
146 * Node and structure definitions
147 **********************************************************************/
150 typedef struct
151 { /* Dynamic string control structure */
152 int alloc;
153 int used; /* Including NUL terminator */
154 char *value;
155 } PLpgSQL_dstring;
158 typedef struct
159 { /* Postgres data type */
160 char *typname; /* (simple) name of the type */
161 Oid typoid; /* OID of the data type */
162 int ttype; /* PLPGSQL_TTYPE_ code */
163 int16 typlen; /* stuff copied from its pg_type entry */
164 bool typbyval;
165 Oid typrelid;
166 Oid typioparam;
167 FmgrInfo typinput; /* lookup info for typinput function */
168 int32 atttypmod; /* typmod (taken from someplace else) */
169 } PLpgSQL_type;
173 * PLpgSQL_datum is the common supertype for PLpgSQL_expr, PLpgSQL_var,
174 * PLpgSQL_row, PLpgSQL_rec, PLpgSQL_recfield, PLpgSQL_arrayelem, and
175 * PLpgSQL_trigarg
177 typedef struct
178 { /* Generic datum array item */
179 int dtype;
180 int dno;
181 } PLpgSQL_datum;
184 * The variants PLpgSQL_var, PLpgSQL_row, and PLpgSQL_rec share these
185 * fields
187 typedef struct
188 { /* Scalar or composite variable */
189 int dtype;
190 int dno;
191 char *refname;
192 int lineno;
193 } PLpgSQL_variable;
195 typedef struct PLpgSQL_expr
196 { /* SQL Query to plan and execute */
197 int dtype;
198 int dno;
199 char *query;
200 SPIPlanPtr plan;
201 Oid *plan_argtypes;
202 /* fields for "simple expression" fast-path execution: */
203 Expr *expr_simple_expr; /* NULL means not a simple expr */
204 int expr_simple_generation; /* plancache generation we checked */
205 Oid expr_simple_type; /* result type Oid, if simple */
208 * if expr is simple AND prepared in current eval_estate,
209 * expr_simple_state is valid. Test validity by seeing if expr_simple_id
210 * matches eval_estate_simple_id.
212 ExprState *expr_simple_state;
213 long int expr_simple_id;
215 /* params to pass to expr */
216 int nparams;
217 int params[1]; /* VARIABLE SIZE ARRAY ... must be last */
218 } PLpgSQL_expr;
221 typedef struct
222 { /* Scalar variable */
223 int dtype;
224 int dno;
225 char *refname;
226 int lineno;
228 PLpgSQL_type *datatype;
229 int isconst;
230 int notnull;
231 PLpgSQL_expr *default_val;
232 PLpgSQL_expr *cursor_explicit_expr;
233 int cursor_explicit_argrow;
234 int cursor_options;
236 Datum value;
237 bool isnull;
238 bool freeval;
239 } PLpgSQL_var;
242 typedef struct
243 { /* Row variable */
244 int dtype;
245 int dno;
246 char *refname;
247 int lineno;
249 TupleDesc rowtupdesc;
252 * Note: TupleDesc is only set up for named rowtypes, else it is NULL.
254 * Note: if the underlying rowtype contains a dropped column, the
255 * corresponding fieldnames[] entry will be NULL, and there is no
256 * corresponding var (varnos[] will be -1).
258 int nfields;
259 char **fieldnames;
260 int *varnos;
261 } PLpgSQL_row;
264 typedef struct
265 { /* Record variable (non-fixed structure) */
266 int dtype;
267 int dno;
268 char *refname;
269 int lineno;
271 HeapTuple tup;
272 TupleDesc tupdesc;
273 bool freetup;
274 bool freetupdesc;
275 } PLpgSQL_rec;
278 typedef struct
279 { /* Field in record */
280 int dtype;
281 int dno;
282 char *fieldname;
283 int recparentno; /* dno of parent record */
284 } PLpgSQL_recfield;
287 typedef struct
288 { /* Element of array variable */
289 int dtype;
290 int dno;
291 PLpgSQL_expr *subscript;
292 int arrayparentno; /* dno of parent array variable */
293 } PLpgSQL_arrayelem;
296 typedef struct
297 { /* Positional argument to trigger */
298 int dtype;
299 int dno;
300 PLpgSQL_expr *argnum;
301 } PLpgSQL_trigarg;
304 typedef struct
305 { /* Item in the compilers namestack */
306 int itemtype;
307 int itemno;
308 char name[1];
309 } PLpgSQL_nsitem;
312 /* XXX: consider adapting this to use List */
313 typedef struct PLpgSQL_ns
314 { /* Compiler namestack level */
315 int items_alloc;
316 int items_used;
317 PLpgSQL_nsitem **items;
318 struct PLpgSQL_ns *upper;
319 } PLpgSQL_ns;
322 typedef struct
323 { /* Generic execution node */
324 int cmd_type;
325 int lineno;
326 } PLpgSQL_stmt;
329 typedef struct PLpgSQL_condition
330 { /* One EXCEPTION condition name */
331 int sqlerrstate; /* SQLSTATE code */
332 char *condname; /* condition name (for debugging) */
333 struct PLpgSQL_condition *next;
334 } PLpgSQL_condition;
336 typedef struct
338 int sqlstate_varno;
339 int sqlerrm_varno;
340 List *exc_list; /* List of WHEN clauses */
341 } PLpgSQL_exception_block;
343 typedef struct
344 { /* One EXCEPTION ... WHEN clause */
345 int lineno;
346 PLpgSQL_condition *conditions;
347 List *action; /* List of statements */
348 } PLpgSQL_exception;
351 typedef struct
352 { /* Block of statements */
353 int cmd_type;
354 int lineno;
355 char *label;
356 List *body; /* List of statements */
357 int n_initvars;
358 int *initvarnos;
359 PLpgSQL_exception_block *exceptions;
360 } PLpgSQL_stmt_block;
363 typedef struct
364 { /* Assign statement */
365 int cmd_type;
366 int lineno;
367 int varno;
368 PLpgSQL_expr *expr;
369 } PLpgSQL_stmt_assign;
371 typedef struct
372 { /* PERFORM statement */
373 int cmd_type;
374 int lineno;
375 PLpgSQL_expr *expr;
376 } PLpgSQL_stmt_perform;
378 typedef struct
379 { /* Get Diagnostics item */
380 int kind; /* id for diagnostic value desired */
381 int target; /* where to assign it */
382 } PLpgSQL_diag_item;
384 typedef struct
385 { /* Get Diagnostics statement */
386 int cmd_type;
387 int lineno;
388 List *diag_items; /* List of PLpgSQL_diag_item */
389 } PLpgSQL_stmt_getdiag;
392 typedef struct
393 { /* IF statement */
394 int cmd_type;
395 int lineno;
396 PLpgSQL_expr *cond;
397 List *true_body; /* List of statements */
398 List *false_body; /* List of statements */
399 } PLpgSQL_stmt_if;
402 typedef struct /* CASE statement */
404 int cmd_type;
405 int lineno;
406 PLpgSQL_expr *t_expr; /* test expression, or NULL if none */
407 int t_varno; /* var to store test expression value into */
408 List *case_when_list; /* List of PLpgSQL_case_when structs */
409 bool have_else; /* flag needed because list could be empty */
410 List *else_stmts; /* List of statements */
411 } PLpgSQL_stmt_case;
413 typedef struct /* one arm of CASE statement */
415 int lineno;
416 PLpgSQL_expr *expr; /* boolean expression for this case */
417 List *stmts; /* List of statements */
418 } PLpgSQL_case_when;
421 typedef struct
422 { /* Unconditional LOOP statement */
423 int cmd_type;
424 int lineno;
425 char *label;
426 List *body; /* List of statements */
427 } PLpgSQL_stmt_loop;
430 typedef struct
431 { /* WHILE cond LOOP statement */
432 int cmd_type;
433 int lineno;
434 char *label;
435 PLpgSQL_expr *cond;
436 List *body; /* List of statements */
437 } PLpgSQL_stmt_while;
440 typedef struct
441 { /* FOR statement with integer loopvar */
442 int cmd_type;
443 int lineno;
444 char *label;
445 PLpgSQL_var *var;
446 PLpgSQL_expr *lower;
447 PLpgSQL_expr *upper;
448 PLpgSQL_expr *step; /* NULL means default (ie, BY 1) */
449 int reverse;
450 List *body; /* List of statements */
451 } PLpgSQL_stmt_fori;
455 * PLpgSQL_stmt_forq represents a FOR statement running over a SQL query.
456 * It is the common supertype of PLpgSQL_stmt_fors, PLpgSQL_stmt_forc
457 * and PLpgSQL_dynfors.
459 typedef struct
461 int cmd_type;
462 int lineno;
463 char *label;
464 PLpgSQL_rec *rec;
465 PLpgSQL_row *row;
466 List *body; /* List of statements */
467 } PLpgSQL_stmt_forq;
469 typedef struct
470 { /* FOR statement running over SELECT */
471 int cmd_type;
472 int lineno;
473 char *label;
474 PLpgSQL_rec *rec;
475 PLpgSQL_row *row;
476 List *body; /* List of statements */
477 /* end of fields that must match PLpgSQL_stmt_forq */
478 PLpgSQL_expr *query;
479 } PLpgSQL_stmt_fors;
481 typedef struct
482 { /* FOR statement running over cursor */
483 int cmd_type;
484 int lineno;
485 char *label;
486 PLpgSQL_rec *rec;
487 PLpgSQL_row *row;
488 List *body; /* List of statements */
489 /* end of fields that must match PLpgSQL_stmt_forq */
490 int curvar;
491 PLpgSQL_expr *argquery; /* cursor arguments if any */
492 } PLpgSQL_stmt_forc;
494 typedef struct
495 { /* FOR statement running over EXECUTE */
496 int cmd_type;
497 int lineno;
498 char *label;
499 PLpgSQL_rec *rec;
500 PLpgSQL_row *row;
501 List *body; /* List of statements */
502 /* end of fields that must match PLpgSQL_stmt_forq */
503 PLpgSQL_expr *query;
504 List *params; /* USING expressions */
505 } PLpgSQL_stmt_dynfors;
508 typedef struct
509 { /* OPEN a curvar */
510 int cmd_type;
511 int lineno;
512 int curvar;
513 int cursor_options;
514 PLpgSQL_row *returntype;
515 PLpgSQL_expr *argquery;
516 PLpgSQL_expr *query;
517 PLpgSQL_expr *dynquery;
518 } PLpgSQL_stmt_open;
521 typedef struct
522 { /* FETCH or MOVE statement */
523 int cmd_type;
524 int lineno;
525 PLpgSQL_rec *rec; /* target, as record or row */
526 PLpgSQL_row *row;
527 int curvar; /* cursor variable to fetch from */
528 FetchDirection direction; /* fetch direction */
529 int how_many; /* count, if constant (expr is NULL) */
530 PLpgSQL_expr *expr; /* count, if expression */
531 bool is_move; /* is this a fetch or move? */
532 } PLpgSQL_stmt_fetch;
535 typedef struct
536 { /* CLOSE curvar */
537 int cmd_type;
538 int lineno;
539 int curvar;
540 } PLpgSQL_stmt_close;
543 typedef struct
544 { /* EXIT or CONTINUE statement */
545 int cmd_type;
546 int lineno;
547 bool is_exit; /* Is this an exit or a continue? */
548 char *label; /* NULL if it's an unlabelled EXIT/CONTINUE */
549 PLpgSQL_expr *cond;
550 } PLpgSQL_stmt_exit;
553 typedef struct
554 { /* RETURN statement */
555 int cmd_type;
556 int lineno;
557 PLpgSQL_expr *expr;
558 int retvarno;
559 } PLpgSQL_stmt_return;
561 typedef struct
562 { /* RETURN NEXT statement */
563 int cmd_type;
564 int lineno;
565 PLpgSQL_expr *expr;
566 int retvarno;
567 } PLpgSQL_stmt_return_next;
569 typedef struct
570 { /* RETURN QUERY statement */
571 int cmd_type;
572 int lineno;
573 PLpgSQL_expr *query; /* if static query */
574 PLpgSQL_expr *dynquery; /* if dynamic query (RETURN QUERY EXECUTE) */
575 List *params; /* USING arguments for dynamic query */
576 } PLpgSQL_stmt_return_query;
578 typedef struct
579 { /* RAISE statement */
580 int cmd_type;
581 int lineno;
582 int elog_level;
583 char *condname; /* condition name, SQLSTATE, or NULL */
584 char *message; /* old-style message format literal, or NULL */
585 List *params; /* list of expressions for old-style message */
586 List *options; /* list of PLpgSQL_raise_option */
587 } PLpgSQL_stmt_raise;
589 typedef struct
590 { /* RAISE statement option */
591 int opt_type;
592 PLpgSQL_expr *expr;
593 } PLpgSQL_raise_option;
596 typedef struct
597 { /* Generic SQL statement to execute */
598 int cmd_type;
599 int lineno;
600 PLpgSQL_expr *sqlstmt;
601 bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE? */
602 /* note: mod_stmt is set when we plan the query */
603 bool into; /* INTO supplied? */
604 bool strict; /* INTO STRICT flag */
605 PLpgSQL_rec *rec; /* INTO target, if record */
606 PLpgSQL_row *row; /* INTO target, if row */
607 } PLpgSQL_stmt_execsql;
610 typedef struct
611 { /* Dynamic SQL string to execute */
612 int cmd_type;
613 int lineno;
614 PLpgSQL_expr *query; /* string expression */
615 bool into; /* INTO supplied? */
616 bool strict; /* INTO STRICT flag */
617 PLpgSQL_rec *rec; /* INTO target, if record */
618 PLpgSQL_row *row; /* INTO target, if row */
619 List *params; /* USING expressions */
620 } PLpgSQL_stmt_dynexecute;
623 typedef struct PLpgSQL_func_hashkey
624 { /* Hash lookup key for functions */
625 Oid funcOid;
627 bool isTrigger; /* true if called as a trigger */
629 /* be careful that pad bytes in this struct get zeroed! */
632 * For a trigger function, the OID of the relation triggered on is part of
633 * the hashkey --- we want to compile the trigger separately for each
634 * relation it is used with, in case the rowtype is different. Zero if
635 * not called as a trigger.
637 Oid trigrelOid;
640 * We include actual argument types in the hash key to support polymorphic
641 * PLpgSQL functions. Be careful that extra positions are zeroed!
643 Oid argtypes[FUNC_MAX_ARGS];
644 } PLpgSQL_func_hashkey;
647 typedef struct PLpgSQL_function
648 { /* Complete compiled function */
649 char *fn_name;
650 Oid fn_oid;
651 TransactionId fn_xmin;
652 ItemPointerData fn_tid;
653 int fn_functype;
654 PLpgSQL_func_hashkey *fn_hashkey; /* back-link to hashtable key */
655 MemoryContext fn_cxt;
657 Oid fn_rettype;
658 int fn_rettyplen;
659 bool fn_retbyval;
660 FmgrInfo fn_retinput;
661 Oid fn_rettypioparam;
662 bool fn_retistuple;
663 bool fn_retset;
664 bool fn_readonly;
666 int fn_nargs;
667 int fn_argvarnos[FUNC_MAX_ARGS];
668 int out_param_varno;
669 int found_varno;
670 int new_varno;
671 int old_varno;
672 int tg_name_varno;
673 int tg_when_varno;
674 int tg_level_varno;
675 int tg_op_varno;
676 int tg_relid_varno;
677 int tg_relname_varno;
678 int tg_table_name_varno;
679 int tg_table_schema_varno;
680 int tg_nargs_varno;
682 int ndatums;
683 PLpgSQL_datum **datums;
684 PLpgSQL_stmt_block *action;
686 unsigned long use_count;
687 } PLpgSQL_function;
690 typedef struct
691 { /* Runtime execution data */
692 Datum retval;
693 bool retisnull;
694 Oid rettype; /* type of current retval */
696 Oid fn_rettype; /* info about declared function rettype */
697 bool retistuple;
698 bool retisset;
700 bool readonly_func;
702 TupleDesc rettupdesc;
703 char *exitlabel; /* the "target" label of the current EXIT or
704 * CONTINUE stmt, if any */
706 Tuplestorestate *tuple_store; /* SRFs accumulate results here */
707 MemoryContext tuple_store_cxt;
708 ReturnSetInfo *rsi;
710 int trig_nargs;
711 Datum *trig_argv;
713 int found_varno;
714 int ndatums;
715 PLpgSQL_datum **datums;
717 /* temporary state for results from evaluation of query or expr */
718 SPITupleTable *eval_tuptable;
719 uint32 eval_processed;
720 Oid eval_lastoid;
721 ExprContext *eval_econtext; /* for executing simple expressions */
722 EState *eval_estate; /* EState containing eval_econtext */
723 long int eval_estate_simple_id; /* ID for eval_estate */
725 /* status information for error context reporting */
726 PLpgSQL_function *err_func; /* current func */
727 PLpgSQL_stmt *err_stmt; /* current stmt */
728 const char *err_text; /* additional state info */
729 void *plugin_info; /* reserved for use by optional plugin */
730 } PLpgSQL_execstate;
734 * A PLpgSQL_plugin structure represents an instrumentation plugin.
735 * To instrument PL/pgSQL, a plugin library must access the rendezvous
736 * variable "PLpgSQL_plugin" and set it to point to a PLpgSQL_plugin struct.
737 * Typically the struct could just be static data in the plugin library.
738 * We expect that a plugin would do this at library load time (_PG_init()).
739 * It must also be careful to set the rendezvous variable back to NULL
740 * if it is unloaded (_PG_fini()).
742 * This structure is basically a collection of function pointers --- at
743 * various interesting points in pl_exec.c, we call these functions
744 * (if the pointers are non-NULL) to give the plugin a chance to watch
745 * what we are doing.
747 * func_setup is called when we start a function, before we've initialized
748 * the local variables defined by the function.
750 * func_beg is called when we start a function, after we've initialized
751 * the local variables.
753 * func_end is called at the end of a function.
755 * stmt_beg and stmt_end are called before and after (respectively) each
756 * statement.
758 * Also, immediately before any call to func_setup, PL/pgSQL fills in the
759 * error_callback and assign_expr fields with pointers to its own
760 * plpgsql_exec_error_callback and exec_assign_expr functions. This is
761 * a somewhat ad-hoc expedient to simplify life for debugger plugins.
764 typedef struct
766 /* Function pointers set up by the plugin */
767 void (*func_setup) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
768 void (*func_beg) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
769 void (*func_end) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
770 void (*stmt_beg) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
771 void (*stmt_end) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
773 /* Function pointers set by PL/pgSQL itself */
774 void (*error_callback) (void *arg);
775 void (*assign_expr) (PLpgSQL_execstate *estate, PLpgSQL_datum *target,
776 PLpgSQL_expr *expr);
777 } PLpgSQL_plugin;
780 /**********************************************************************
781 * Global variable declarations
782 **********************************************************************/
784 extern bool plpgsql_DumpExecTree;
785 extern bool plpgsql_SpaceScanned;
786 extern int plpgsql_nDatums;
787 extern PLpgSQL_datum **plpgsql_Datums;
789 extern int plpgsql_error_lineno;
790 extern char *plpgsql_error_funcname;
792 /* linkage to the real yytext variable */
793 extern char *plpgsql_base_yytext;
795 #define yytext plpgsql_base_yytext
797 extern PLpgSQL_function *plpgsql_curr_compile;
798 extern bool plpgsql_check_syntax;
799 extern MemoryContext compile_tmp_cxt;
801 extern PLpgSQL_plugin **plugin_ptr;
803 /**********************************************************************
804 * Function declarations
805 **********************************************************************/
807 /* ----------
808 * Functions in pl_comp.c
809 * ----------
811 extern PLpgSQL_function *plpgsql_compile(FunctionCallInfo fcinfo,
812 bool forValidator);
813 extern int plpgsql_parse_word(const char *word);
814 extern int plpgsql_parse_dblword(const char *word);
815 extern int plpgsql_parse_tripword(const char *word);
816 extern int plpgsql_parse_wordtype(char *word);
817 extern int plpgsql_parse_dblwordtype(char *word);
818 extern int plpgsql_parse_tripwordtype(char *word);
819 extern int plpgsql_parse_wordrowtype(char *word);
820 extern int plpgsql_parse_dblwordrowtype(char *word);
821 extern PLpgSQL_type *plpgsql_parse_datatype(const char *string);
822 extern PLpgSQL_type *plpgsql_build_datatype(Oid typeOid, int32 typmod);
823 extern PLpgSQL_variable *plpgsql_build_variable(const char *refname, int lineno,
824 PLpgSQL_type *dtype,
825 bool add2namespace);
826 extern PLpgSQL_rec *plpgsql_build_record(const char *refname, int lineno,
827 bool add2namespace);
828 extern int plpgsql_recognize_err_condition(const char *condname,
829 bool allow_sqlstate);
830 extern PLpgSQL_condition *plpgsql_parse_err_condition(char *condname);
831 extern void plpgsql_adddatum(PLpgSQL_datum *new);
832 extern int plpgsql_add_initdatums(int **varnos);
833 extern void plpgsql_HashTableInit(void);
834 extern void plpgsql_compile_error_callback(void *arg);
836 /* ----------
837 * Functions in pl_handler.c
838 * ----------
840 extern void _PG_init(void);
841 extern Datum plpgsql_call_handler(PG_FUNCTION_ARGS);
842 extern Datum plpgsql_validator(PG_FUNCTION_ARGS);
844 /* ----------
845 * Functions in pl_exec.c
846 * ----------
848 extern Datum plpgsql_exec_function(PLpgSQL_function *func,
849 FunctionCallInfo fcinfo);
850 extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function *func,
851 TriggerData *trigdata);
852 extern void plpgsql_xact_cb(XactEvent event, void *arg);
853 extern void plpgsql_subxact_cb(SubXactEvent event, SubTransactionId mySubid,
854 SubTransactionId parentSubid, void *arg);
856 /* ----------
857 * Functions for the dynamic string handling in pl_funcs.c
858 * ----------
860 extern void plpgsql_dstring_init(PLpgSQL_dstring *ds);
861 extern void plpgsql_dstring_free(PLpgSQL_dstring *ds);
862 extern void plpgsql_dstring_append(PLpgSQL_dstring *ds, const char *str);
863 extern void plpgsql_dstring_append_char(PLpgSQL_dstring *ds, char c);
864 extern char *plpgsql_dstring_get(PLpgSQL_dstring *ds);
866 /* ----------
867 * Functions for namestack handling in pl_funcs.c
868 * ----------
870 extern void plpgsql_ns_init(void);
871 extern bool plpgsql_ns_setlocal(bool flag);
872 extern void plpgsql_ns_push(const char *label);
873 extern void plpgsql_ns_pop(void);
874 extern void plpgsql_ns_additem(int itemtype, int itemno, const char *name);
875 extern PLpgSQL_nsitem *plpgsql_ns_lookup(const char *name1, const char *name2,
876 const char *name3, int *names_used);
877 extern PLpgSQL_nsitem *plpgsql_ns_lookup_label(const char *name);
878 extern void plpgsql_ns_rename(char *oldname, char *newname);
880 /* ----------
881 * Other functions in pl_funcs.c
882 * ----------
884 extern void plpgsql_convert_ident(const char *s, char **output, int numidents);
885 extern const char *plpgsql_stmt_typename(PLpgSQL_stmt *stmt);
886 extern void plpgsql_dumptree(PLpgSQL_function *func);
888 /* ----------
889 * Externs in gram.y and scan.l
890 * ----------
892 extern PLpgSQL_expr *plpgsql_read_expression(int until, const char *expected);
893 extern int plpgsql_yyparse(void);
894 extern int plpgsql_base_yylex(void);
895 extern int plpgsql_yylex(void);
896 extern void plpgsql_push_back_token(int token);
897 extern void plpgsql_yyerror(const char *message);
898 extern int plpgsql_scanner_lineno(void);
899 extern void plpgsql_scanner_init(const char *str, int functype);
900 extern void plpgsql_scanner_finish(void);
901 extern char *plpgsql_get_string_value(void);
903 #endif /* PLPGSQL_H */