| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef PLPGSQL_H |
| | #define PLPGSQL_H |
| |
|
| | #include "access/xact.h" |
| | #include "commands/event_trigger.h" |
| | #include "commands/trigger.h" |
| | #include "executor/spi.h" |
| | #include "utils/expandedrecord.h" |
| | #include "utils/typcache.h" |
| |
|
| |
|
| | |
| | |
| | |
| |
|
| | |
| | #undef TEXTDOMAIN |
| | #define TEXTDOMAIN PG_TEXTDOMAIN("plpgsql") |
| |
|
| | #undef _ |
| | #define _(x) dgettext(TEXTDOMAIN, x) |
| |
|
| | |
| | |
| | |
| | typedef enum PLpgSQL_nsitem_type |
| | { |
| | PLPGSQL_NSTYPE_LABEL, |
| | PLPGSQL_NSTYPE_VAR, |
| | PLPGSQL_NSTYPE_REC, |
| | } PLpgSQL_nsitem_type; |
| |
|
| | |
| | |
| | |
| | typedef enum PLpgSQL_label_type |
| | { |
| | PLPGSQL_LABEL_BLOCK, |
| | PLPGSQL_LABEL_LOOP, |
| | PLPGSQL_LABEL_OTHER, |
| | } PLpgSQL_label_type; |
| |
|
| | |
| | |
| | |
| | typedef enum PLpgSQL_datum_type |
| | { |
| | PLPGSQL_DTYPE_VAR, |
| | PLPGSQL_DTYPE_ROW, |
| | PLPGSQL_DTYPE_REC, |
| | PLPGSQL_DTYPE_RECFIELD, |
| | PLPGSQL_DTYPE_PROMISE, |
| | } PLpgSQL_datum_type; |
| |
|
| | |
| | |
| | |
| | typedef enum PLpgSQL_promise_type |
| | { |
| | PLPGSQL_PROMISE_NONE = 0, |
| | PLPGSQL_PROMISE_TG_NAME, |
| | PLPGSQL_PROMISE_TG_WHEN, |
| | PLPGSQL_PROMISE_TG_LEVEL, |
| | PLPGSQL_PROMISE_TG_OP, |
| | PLPGSQL_PROMISE_TG_RELID, |
| | PLPGSQL_PROMISE_TG_TABLE_NAME, |
| | PLPGSQL_PROMISE_TG_TABLE_SCHEMA, |
| | PLPGSQL_PROMISE_TG_NARGS, |
| | PLPGSQL_PROMISE_TG_ARGV, |
| | PLPGSQL_PROMISE_TG_EVENT, |
| | PLPGSQL_PROMISE_TG_TAG, |
| | } PLpgSQL_promise_type; |
| |
|
| | |
| | |
| | |
| | typedef enum PLpgSQL_type_type |
| | { |
| | PLPGSQL_TTYPE_SCALAR, |
| | PLPGSQL_TTYPE_REC, |
| | PLPGSQL_TTYPE_PSEUDO, |
| | } PLpgSQL_type_type; |
| |
|
| | |
| | |
| | |
| | typedef enum PLpgSQL_stmt_type |
| | { |
| | PLPGSQL_STMT_BLOCK, |
| | PLPGSQL_STMT_ASSIGN, |
| | PLPGSQL_STMT_IF, |
| | PLPGSQL_STMT_CASE, |
| | PLPGSQL_STMT_LOOP, |
| | PLPGSQL_STMT_WHILE, |
| | PLPGSQL_STMT_FORI, |
| | PLPGSQL_STMT_FORS, |
| | PLPGSQL_STMT_FORC, |
| | PLPGSQL_STMT_FOREACH_A, |
| | PLPGSQL_STMT_EXIT, |
| | PLPGSQL_STMT_RETURN, |
| | PLPGSQL_STMT_RETURN_NEXT, |
| | PLPGSQL_STMT_RETURN_QUERY, |
| | PLPGSQL_STMT_RAISE, |
| | PLPGSQL_STMT_ASSERT, |
| | PLPGSQL_STMT_EXECSQL, |
| | PLPGSQL_STMT_DYNEXECUTE, |
| | PLPGSQL_STMT_DYNFORS, |
| | PLPGSQL_STMT_GETDIAG, |
| | PLPGSQL_STMT_OPEN, |
| | PLPGSQL_STMT_FETCH, |
| | PLPGSQL_STMT_CLOSE, |
| | PLPGSQL_STMT_PERFORM, |
| | PLPGSQL_STMT_CALL, |
| | PLPGSQL_STMT_COMMIT, |
| | PLPGSQL_STMT_ROLLBACK, |
| | } PLpgSQL_stmt_type; |
| |
|
| | |
| | |
| | |
| | enum |
| | { |
| | PLPGSQL_RC_OK, |
| | PLPGSQL_RC_EXIT, |
| | PLPGSQL_RC_RETURN, |
| | PLPGSQL_RC_CONTINUE, |
| | }; |
| |
|
| | |
| | |
| | |
| | typedef enum PLpgSQL_getdiag_kind |
| | { |
| | PLPGSQL_GETDIAG_ROW_COUNT, |
| | PLPGSQL_GETDIAG_ROUTINE_OID, |
| | PLPGSQL_GETDIAG_CONTEXT, |
| | PLPGSQL_GETDIAG_ERROR_CONTEXT, |
| | PLPGSQL_GETDIAG_ERROR_DETAIL, |
| | PLPGSQL_GETDIAG_ERROR_HINT, |
| | PLPGSQL_GETDIAG_RETURNED_SQLSTATE, |
| | PLPGSQL_GETDIAG_COLUMN_NAME, |
| | PLPGSQL_GETDIAG_CONSTRAINT_NAME, |
| | PLPGSQL_GETDIAG_DATATYPE_NAME, |
| | PLPGSQL_GETDIAG_MESSAGE_TEXT, |
| | PLPGSQL_GETDIAG_TABLE_NAME, |
| | PLPGSQL_GETDIAG_SCHEMA_NAME, |
| | } PLpgSQL_getdiag_kind; |
| |
|
| | |
| | |
| | |
| | typedef enum PLpgSQL_raise_option_type |
| | { |
| | PLPGSQL_RAISEOPTION_ERRCODE, |
| | PLPGSQL_RAISEOPTION_MESSAGE, |
| | PLPGSQL_RAISEOPTION_DETAIL, |
| | PLPGSQL_RAISEOPTION_HINT, |
| | PLPGSQL_RAISEOPTION_COLUMN, |
| | PLPGSQL_RAISEOPTION_CONSTRAINT, |
| | PLPGSQL_RAISEOPTION_DATATYPE, |
| | PLPGSQL_RAISEOPTION_TABLE, |
| | PLPGSQL_RAISEOPTION_SCHEMA, |
| | } PLpgSQL_raise_option_type; |
| |
|
| | |
| | |
| | |
| | typedef enum PLpgSQL_resolve_option |
| | { |
| | PLPGSQL_RESOLVE_ERROR, |
| | PLPGSQL_RESOLVE_VARIABLE, |
| | PLPGSQL_RESOLVE_COLUMN, |
| | } PLpgSQL_resolve_option; |
| |
|
| |
|
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_type |
| | { |
| | char *typname; |
| | Oid typoid; |
| | PLpgSQL_type_type ttype; |
| | int16 typlen; |
| | bool typbyval; |
| | char typtype; |
| | Oid collation; |
| | bool typisarray; |
| | int32 atttypmod; |
| | |
| | TypeName *origtypname; |
| | TypeCacheEntry *tcache; |
| | uint64 tupdesc_id; |
| | } PLpgSQL_type; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_expr |
| | { |
| | char *query; |
| | RawParseMode parseMode; |
| | SPIPlanPtr plan; |
| | Bitmapset *paramnos; |
| |
|
| | |
| | struct PLpgSQL_function *func; |
| |
|
| | |
| | struct PLpgSQL_nsitem *ns; |
| |
|
| | |
| | Expr *expr_simple_expr; |
| | Oid expr_simple_type; |
| | int32 expr_simple_typmod; |
| | bool expr_simple_mutable; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | int target_param; |
| | Param *expr_rw_param; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | CachedPlanSource *expr_simple_plansource; |
| | CachedPlan *expr_simple_plan; |
| | LocalTransactionId expr_simple_plan_lxid; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | ExprState *expr_simple_state; |
| | bool expr_simple_in_use; |
| | LocalTransactionId expr_simple_lxid; |
| | } PLpgSQL_expr; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef struct PLpgSQL_datum |
| | { |
| | PLpgSQL_datum_type dtype; |
| | int dno; |
| | } PLpgSQL_datum; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef struct PLpgSQL_variable |
| | { |
| | PLpgSQL_datum_type dtype; |
| | int dno; |
| | char *refname; |
| | int lineno; |
| | bool isconst; |
| | bool notnull; |
| | PLpgSQL_expr *default_val; |
| | } PLpgSQL_variable; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef struct PLpgSQL_var |
| | { |
| | PLpgSQL_datum_type dtype; |
| | int dno; |
| | char *refname; |
| | int lineno; |
| | bool isconst; |
| | bool notnull; |
| | PLpgSQL_expr *default_val; |
| | |
| |
|
| | PLpgSQL_type *datatype; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | PLpgSQL_expr *cursor_explicit_expr; |
| | int cursor_explicit_argrow; |
| | int cursor_options; |
| |
|
| | |
| |
|
| | Datum value; |
| | bool isnull; |
| | bool freeval; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | PLpgSQL_promise_type promise; |
| | } PLpgSQL_var; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef struct PLpgSQL_row |
| | { |
| | PLpgSQL_datum_type dtype; |
| | int dno; |
| | char *refname; |
| | int lineno; |
| | bool isconst; |
| | bool notnull; |
| | PLpgSQL_expr *default_val; |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | TupleDesc rowtupdesc; |
| |
|
| | int nfields; |
| | char **fieldnames; |
| | int *varnos; |
| | } PLpgSQL_row; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_rec |
| | { |
| | PLpgSQL_datum_type dtype; |
| | int dno; |
| | char *refname; |
| | int lineno; |
| | bool isconst; |
| | bool notnull; |
| | PLpgSQL_expr *default_val; |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| | PLpgSQL_type *datatype; |
| | Oid rectypeid; |
| | |
| | int firstfield; |
| |
|
| | |
| |
|
| | |
| | ExpandedRecordHeader *erh; |
| | } PLpgSQL_rec; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_recfield |
| | { |
| | PLpgSQL_datum_type dtype; |
| | int dno; |
| | |
| |
|
| | char *fieldname; |
| | int recparentno; |
| | int nextfield; |
| | uint64 rectupledescid; |
| | ExpandedRecordFieldInfo finfo; |
| | |
| | } PLpgSQL_recfield; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_nsitem |
| | { |
| | PLpgSQL_nsitem_type itemtype; |
| |
|
| | |
| | |
| | |
| | |
| | int itemno; |
| | struct PLpgSQL_nsitem *prev; |
| | char name[FLEXIBLE_ARRAY_MEMBER]; |
| | } PLpgSQL_nsitem; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | unsigned int stmtid; |
| | } PLpgSQL_stmt; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_condition |
| | { |
| | int sqlerrstate; |
| | char *condname; |
| | struct PLpgSQL_condition *next; |
| | } PLpgSQL_condition; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_exception_block |
| | { |
| | int sqlstate_varno; |
| | int sqlerrm_varno; |
| | List *exc_list; |
| | } PLpgSQL_exception_block; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_exception |
| | { |
| | int lineno; |
| | PLpgSQL_condition *conditions; |
| | List *action; |
| | } PLpgSQL_exception; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_block |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | char *label; |
| | List *body; |
| | int n_initvars; |
| | int *initvarnos; |
| | PLpgSQL_exception_block *exceptions; |
| | } PLpgSQL_stmt_block; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_assign |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | int varno; |
| | PLpgSQL_expr *expr; |
| | } PLpgSQL_stmt_assign; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_perform |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_expr *expr; |
| | } PLpgSQL_stmt_perform; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_call |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_expr *expr; |
| | bool is_call; |
| | PLpgSQL_variable *target; |
| | } PLpgSQL_stmt_call; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_commit |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | bool chain; |
| | } PLpgSQL_stmt_commit; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_rollback |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | bool chain; |
| | } PLpgSQL_stmt_rollback; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_diag_item |
| | { |
| | PLpgSQL_getdiag_kind kind; |
| | int target; |
| | } PLpgSQL_diag_item; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_getdiag |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | bool is_stacked; |
| | List *diag_items; |
| | } PLpgSQL_stmt_getdiag; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_if |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_expr *cond; |
| | List *then_body; |
| | List *elsif_list; |
| | List *else_body; |
| | } PLpgSQL_stmt_if; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_if_elsif |
| | { |
| | int lineno; |
| | PLpgSQL_expr *cond; |
| | List *stmts; |
| | } PLpgSQL_if_elsif; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_case |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_expr *t_expr; |
| | int t_varno; |
| | List *case_when_list; |
| | bool have_else; |
| | List *else_stmts; |
| | } PLpgSQL_stmt_case; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_case_when |
| | { |
| | int lineno; |
| | PLpgSQL_expr *expr; |
| | List *stmts; |
| | } PLpgSQL_case_when; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_loop |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | char *label; |
| | List *body; |
| | } PLpgSQL_stmt_loop; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_while |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | char *label; |
| | PLpgSQL_expr *cond; |
| | List *body; |
| | } PLpgSQL_stmt_while; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_fori |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | char *label; |
| | PLpgSQL_var *var; |
| | PLpgSQL_expr *lower; |
| | PLpgSQL_expr *upper; |
| | PLpgSQL_expr *step; |
| | int reverse; |
| | List *body; |
| | } PLpgSQL_stmt_fori; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_forq |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | char *label; |
| | PLpgSQL_variable *var; |
| | List *body; |
| | } PLpgSQL_stmt_forq; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_fors |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | char *label; |
| | PLpgSQL_variable *var; |
| | List *body; |
| | |
| | PLpgSQL_expr *query; |
| | } PLpgSQL_stmt_fors; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_forc |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | char *label; |
| | PLpgSQL_variable *var; |
| | List *body; |
| | |
| | int curvar; |
| | PLpgSQL_expr *argquery; |
| | } PLpgSQL_stmt_forc; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_dynfors |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | char *label; |
| | PLpgSQL_variable *var; |
| | List *body; |
| | |
| | PLpgSQL_expr *query; |
| | List *params; |
| | } PLpgSQL_stmt_dynfors; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_foreach_a |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | char *label; |
| | int varno; |
| | int slice; |
| | PLpgSQL_expr *expr; |
| | List *body; |
| | } PLpgSQL_stmt_foreach_a; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_open |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | int curvar; |
| | int cursor_options; |
| | PLpgSQL_expr *argquery; |
| | PLpgSQL_expr *query; |
| | PLpgSQL_expr *dynquery; |
| | List *params; |
| | } PLpgSQL_stmt_open; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_fetch |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_variable *target; |
| | int curvar; |
| | FetchDirection direction; |
| | long how_many; |
| | PLpgSQL_expr *expr; |
| | bool is_move; |
| | bool returns_multiple_rows; |
| | } PLpgSQL_stmt_fetch; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_close |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | int curvar; |
| | } PLpgSQL_stmt_close; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_exit |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | bool is_exit; |
| | char *label; |
| | PLpgSQL_expr *cond; |
| | } PLpgSQL_stmt_exit; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_return |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_expr *expr; |
| | int retvarno; |
| | } PLpgSQL_stmt_return; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_return_next |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_expr *expr; |
| | int retvarno; |
| | } PLpgSQL_stmt_return_next; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_return_query |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_expr *query; |
| | PLpgSQL_expr *dynquery; |
| | List *params; |
| | } PLpgSQL_stmt_return_query; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_raise |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | int elog_level; |
| | char *condname; |
| | char *message; |
| | List *params; |
| | List *options; |
| | } PLpgSQL_stmt_raise; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_raise_option |
| | { |
| | PLpgSQL_raise_option_type opt_type; |
| | PLpgSQL_expr *expr; |
| | } PLpgSQL_raise_option; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_assert |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_expr *cond; |
| | PLpgSQL_expr *message; |
| | } PLpgSQL_stmt_assert; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_execsql |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_expr *sqlstmt; |
| | bool mod_stmt; |
| | bool mod_stmt_set; |
| | bool into; |
| | bool strict; |
| | PLpgSQL_variable *target; |
| | } PLpgSQL_stmt_execsql; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_stmt_dynexecute |
| | { |
| | PLpgSQL_stmt_type cmd_type; |
| | int lineno; |
| | unsigned int stmtid; |
| | PLpgSQL_expr *query; |
| | bool into; |
| | bool strict; |
| | PLpgSQL_variable *target; |
| | List *params; |
| | } PLpgSQL_stmt_dynexecute; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_func_hashkey |
| | { |
| | Oid funcOid; |
| |
|
| | bool isTrigger; |
| | bool isEventTrigger; |
| |
|
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | Oid trigOid; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | Oid inputCollation; |
| |
|
| | |
| | |
| | |
| | |
| | Oid argtypes[FUNC_MAX_ARGS]; |
| | } PLpgSQL_func_hashkey; |
| |
|
| | |
| | |
| | |
| | typedef enum PLpgSQL_trigtype |
| | { |
| | PLPGSQL_DML_TRIGGER, |
| | PLPGSQL_EVENT_TRIGGER, |
| | PLPGSQL_NOT_TRIGGER, |
| | } PLpgSQL_trigtype; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_function |
| | { |
| | char *fn_signature; |
| | Oid fn_oid; |
| | TransactionId fn_xmin; |
| | ItemPointerData fn_tid; |
| | PLpgSQL_trigtype fn_is_trigger; |
| | Oid fn_input_collation; |
| | PLpgSQL_func_hashkey *fn_hashkey; |
| | MemoryContext fn_cxt; |
| |
|
| | Oid fn_rettype; |
| | int fn_rettyplen; |
| | bool fn_retbyval; |
| | bool fn_retistuple; |
| | bool fn_retisdomain; |
| | bool fn_retset; |
| | bool fn_readonly; |
| | char fn_prokind; |
| |
|
| | int fn_nargs; |
| | int fn_argvarnos[FUNC_MAX_ARGS]; |
| | int out_param_varno; |
| | int found_varno; |
| | int new_varno; |
| | int old_varno; |
| |
|
| | PLpgSQL_resolve_option resolve_option; |
| |
|
| | bool print_strict_params; |
| |
|
| | |
| | int extra_warnings; |
| | int extra_errors; |
| |
|
| | |
| | int ndatums; |
| | PLpgSQL_datum **datums; |
| | Size copiable_size; |
| |
|
| | |
| | PLpgSQL_stmt_block *action; |
| |
|
| | |
| | unsigned int nstatements; |
| | bool requires_procedure_resowner; |
| |
|
| | |
| | struct PLpgSQL_execstate *cur_estate; |
| | unsigned long use_count; |
| | } PLpgSQL_function; |
| |
|
| | |
| | |
| | |
| | typedef struct PLpgSQL_execstate |
| | { |
| | PLpgSQL_function *func; |
| |
|
| | TriggerData *trigdata; |
| | EventTriggerData *evtrigdata; |
| |
|
| | Datum retval; |
| | bool retisnull; |
| | Oid rettype; |
| |
|
| | Oid fn_rettype; |
| | bool retistuple; |
| | bool retisset; |
| |
|
| | bool readonly_func; |
| | bool atomic; |
| |
|
| | char *exitlabel; |
| | |
| | ErrorData *cur_error; |
| |
|
| | Tuplestorestate *tuple_store; |
| | TupleDesc tuple_store_desc; |
| | MemoryContext tuple_store_cxt; |
| | ResourceOwner tuple_store_owner; |
| | ReturnSetInfo *rsi; |
| |
|
| | int found_varno; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | int ndatums; |
| | PLpgSQL_datum **datums; |
| | |
| | MemoryContext datum_context; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | ParamListInfo paramLI; |
| |
|
| | |
| | EState *simple_eval_estate; |
| | ResourceOwner simple_eval_resowner; |
| |
|
| | |
| | ResourceOwner procedure_resowner; |
| |
|
| | |
| | HTAB *cast_hash; |
| |
|
| | |
| | MemoryContext stmt_mcontext; |
| | MemoryContext stmt_mcontext_parent; |
| |
|
| | |
| | SPITupleTable *eval_tuptable; |
| | uint64 eval_processed; |
| | ExprContext *eval_econtext; |
| |
|
| | |
| | PLpgSQL_stmt *err_stmt; |
| | PLpgSQL_variable *err_var; |
| | const char *err_text; |
| |
|
| | void *plugin_info; |
| | } PLpgSQL_execstate; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef struct PLpgSQL_plugin |
| | { |
| | |
| | void (*func_setup) (PLpgSQL_execstate *estate, PLpgSQL_function *func); |
| | void (*func_beg) (PLpgSQL_execstate *estate, PLpgSQL_function *func); |
| | void (*func_end) (PLpgSQL_execstate *estate, PLpgSQL_function *func); |
| | void (*stmt_beg) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt); |
| | void (*stmt_end) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt); |
| |
|
| | |
| | void (*error_callback) (void *arg); |
| | void (*assign_expr) (PLpgSQL_execstate *estate, |
| | PLpgSQL_datum *target, |
| | PLpgSQL_expr *expr); |
| | void (*assign_value) (PLpgSQL_execstate *estate, |
| | PLpgSQL_datum *target, |
| | Datum value, bool isNull, |
| | Oid valtype, int32 valtypmod); |
| | void (*eval_datum) (PLpgSQL_execstate *estate, PLpgSQL_datum *datum, |
| | Oid *typeId, int32 *typetypmod, |
| | Datum *value, bool *isnull); |
| | Datum (*cast_value) (PLpgSQL_execstate *estate, |
| | Datum value, bool *isnull, |
| | Oid valtype, int32 valtypmod, |
| | Oid reqtype, int32 reqtypmod); |
| | } PLpgSQL_plugin; |
| |
|
| | |
| | |
| | |
| |
|
| | typedef struct PLword |
| | { |
| | char *ident; |
| | bool quoted; |
| | } PLword; |
| |
|
| | typedef struct PLcword |
| | { |
| | List *idents; |
| | } PLcword; |
| |
|
| | typedef struct PLwdatum |
| | { |
| | PLpgSQL_datum *datum; |
| | char *ident; |
| | bool quoted; |
| | List *idents; |
| | } PLwdatum; |
| |
|
| | |
| | |
| | |
| |
|
| | typedef enum |
| | { |
| | IDENTIFIER_LOOKUP_NORMAL, |
| | IDENTIFIER_LOOKUP_DECLARE, |
| | IDENTIFIER_LOOKUP_EXPR, |
| | } IdentifierLookup; |
| |
|
| | extern IdentifierLookup plpgsql_IdentifierLookup; |
| |
|
| | extern int plpgsql_variable_conflict; |
| |
|
| | extern bool plpgsql_print_strict_params; |
| |
|
| | extern bool plpgsql_check_asserts; |
| |
|
| | |
| | #define PLPGSQL_XCHECK_NONE 0 |
| | #define PLPGSQL_XCHECK_SHADOWVAR (1 << 1) |
| | #define PLPGSQL_XCHECK_TOOMANYROWS (1 << 2) |
| | #define PLPGSQL_XCHECK_STRICTMULTIASSIGNMENT (1 << 3) |
| | #define PLPGSQL_XCHECK_ALL ((int) ~0) |
| |
|
| | extern int plpgsql_extra_warnings; |
| | extern int plpgsql_extra_errors; |
| |
|
| | extern bool plpgsql_check_syntax; |
| | extern bool plpgsql_DumpExecTree; |
| |
|
| | extern PLpgSQL_stmt_block *plpgsql_parse_result; |
| |
|
| | extern int plpgsql_nDatums; |
| | extern PLpgSQL_datum **plpgsql_Datums; |
| |
|
| | extern char *plpgsql_error_funcname; |
| |
|
| | extern PLpgSQL_function *plpgsql_curr_compile; |
| | extern MemoryContext plpgsql_compile_tmp_cxt; |
| |
|
| | extern PLpgSQL_plugin **plpgsql_plugin_ptr; |
| |
|
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | extern PGDLLEXPORT PLpgSQL_function *plpgsql_compile(FunctionCallInfo fcinfo, |
| | bool forValidator); |
| | extern PLpgSQL_function *plpgsql_compile_inline(char *proc_source); |
| | extern PGDLLEXPORT void plpgsql_parser_setup(struct ParseState *pstate, |
| | PLpgSQL_expr *expr); |
| | extern bool plpgsql_parse_word(char *word1, const char *yytxt, bool lookup, |
| | PLwdatum *wdatum, PLword *word); |
| | extern bool plpgsql_parse_dblword(char *word1, char *word2, |
| | PLwdatum *wdatum, PLcword *cword); |
| | extern bool plpgsql_parse_tripword(char *word1, char *word2, char *word3, |
| | PLwdatum *wdatum, PLcword *cword); |
| | extern PLpgSQL_type *plpgsql_parse_wordtype(char *ident); |
| | extern PLpgSQL_type *plpgsql_parse_cwordtype(List *idents); |
| | extern PLpgSQL_type *plpgsql_parse_wordrowtype(char *ident); |
| | extern PLpgSQL_type *plpgsql_parse_cwordrowtype(List *idents); |
| | extern PGDLLEXPORT PLpgSQL_type *plpgsql_build_datatype(Oid typeOid, int32 typmod, |
| | Oid collation, |
| | TypeName *origtypname); |
| | extern PLpgSQL_type *plpgsql_build_datatype_arrayof(PLpgSQL_type *dtype); |
| | extern PLpgSQL_variable *plpgsql_build_variable(const char *refname, int lineno, |
| | PLpgSQL_type *dtype, |
| | bool add2namespace); |
| | extern PLpgSQL_rec *plpgsql_build_record(const char *refname, int lineno, |
| | PLpgSQL_type *dtype, Oid rectypeid, |
| | bool add2namespace); |
| | extern PLpgSQL_recfield *plpgsql_build_recfield(PLpgSQL_rec *rec, |
| | const char *fldname); |
| | extern PGDLLEXPORT int plpgsql_recognize_err_condition(const char *condname, |
| | bool allow_sqlstate); |
| | extern PLpgSQL_condition *plpgsql_parse_err_condition(char *condname); |
| | extern void plpgsql_adddatum(PLpgSQL_datum *newdatum); |
| | extern int plpgsql_add_initdatums(int **varnos); |
| | extern void plpgsql_HashTableInit(void); |
| |
|
| | |
| | |
| | |
| | extern Datum plpgsql_exec_function(PLpgSQL_function *func, |
| | FunctionCallInfo fcinfo, |
| | EState *simple_eval_estate, |
| | ResourceOwner simple_eval_resowner, |
| | ResourceOwner procedure_resowner, |
| | bool atomic); |
| | extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function *func, |
| | TriggerData *trigdata); |
| | extern void plpgsql_exec_event_trigger(PLpgSQL_function *func, |
| | EventTriggerData *trigdata); |
| | extern void plpgsql_xact_cb(XactEvent event, void *arg); |
| | extern void plpgsql_subxact_cb(SubXactEvent event, SubTransactionId mySubid, |
| | SubTransactionId parentSubid, void *arg); |
| | extern PGDLLEXPORT Oid plpgsql_exec_get_datum_type(PLpgSQL_execstate *estate, |
| | PLpgSQL_datum *datum); |
| | extern void plpgsql_exec_get_datum_type_info(PLpgSQL_execstate *estate, |
| | PLpgSQL_datum *datum, |
| | Oid *typeId, int32 *typMod, |
| | Oid *collation); |
| |
|
| | |
| | |
| | |
| | extern void plpgsql_ns_init(void); |
| | extern void plpgsql_ns_push(const char *label, |
| | PLpgSQL_label_type label_type); |
| | extern void plpgsql_ns_pop(void); |
| | extern PLpgSQL_nsitem *plpgsql_ns_top(void); |
| | extern void plpgsql_ns_additem(PLpgSQL_nsitem_type itemtype, int itemno, const char *name); |
| | extern PGDLLEXPORT PLpgSQL_nsitem *plpgsql_ns_lookup(PLpgSQL_nsitem *ns_cur, bool localmode, |
| | const char *name1, const char *name2, |
| | const char *name3, int *names_used); |
| | extern PLpgSQL_nsitem *plpgsql_ns_lookup_label(PLpgSQL_nsitem *ns_cur, |
| | const char *name); |
| | extern PLpgSQL_nsitem *plpgsql_ns_find_nearest_loop(PLpgSQL_nsitem *ns_cur); |
| |
|
| | |
| | |
| | |
| | extern PGDLLEXPORT const char *plpgsql_stmt_typename(PLpgSQL_stmt *stmt); |
| | extern const char *plpgsql_getdiag_kindname(PLpgSQL_getdiag_kind kind); |
| | extern void plpgsql_free_function_memory(PLpgSQL_function *func); |
| | extern void plpgsql_dumptree(PLpgSQL_function *func); |
| |
|
| | |
| | |
| | |
| | extern int plpgsql_base_yylex(void); |
| | extern int plpgsql_yylex(void); |
| | extern int plpgsql_token_length(void); |
| | extern void plpgsql_push_back_token(int token); |
| | extern bool plpgsql_token_is_unreserved_keyword(int token); |
| | extern void plpgsql_append_source_text(StringInfo buf, |
| | int startlocation, int endlocation); |
| | extern int plpgsql_peek(void); |
| | extern void plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc, |
| | int *tok2_loc); |
| | extern int plpgsql_scanner_errposition(int location); |
| | extern void plpgsql_yyerror(const char *message) pg_attribute_noreturn(); |
| | extern int plpgsql_location_to_lineno(int location); |
| | extern int plpgsql_latest_lineno(void); |
| | extern void plpgsql_scanner_init(const char *str); |
| | extern void plpgsql_scanner_finish(void); |
| |
|
| | |
| | |
| | |
| | extern int plpgsql_yyparse(void); |
| |
|
| | #endif |
| |
|