Commit e0013deb authored by Peter Eisentraut's avatar Peter Eisentraut

Make better use of existing enums in plpgsql

plpgsql.h defines a number of enums, but most of the code passes them
around as ints.  Update structs and function prototypes to take enum
types instead.  This clarifies the struct definitions in plpgsql.h in
particular.
Reviewed-by: default avatarPavel Stehule <pavel.stehule@gmail.com>
parent 967a7b0f
...@@ -93,7 +93,7 @@ static PLpgSQL_function *do_compile(FunctionCallInfo fcinfo, ...@@ -93,7 +93,7 @@ static PLpgSQL_function *do_compile(FunctionCallInfo fcinfo,
PLpgSQL_func_hashkey *hashkey, PLpgSQL_func_hashkey *hashkey,
bool forValidator); bool forValidator);
static void plpgsql_compile_error_callback(void *arg); static void plpgsql_compile_error_callback(void *arg);
static void add_parameter_name(int itemtype, int itemno, const char *name); static void add_parameter_name(PLpgSQL_nsitem_type itemtype, int itemno, const char *name);
static void add_dummy_return(PLpgSQL_function *function); static void add_dummy_return(PLpgSQL_function *function);
static Node *plpgsql_pre_column_ref(ParseState *pstate, ColumnRef *cref); static Node *plpgsql_pre_column_ref(ParseState *pstate, ColumnRef *cref);
static Node *plpgsql_post_column_ref(ParseState *pstate, ColumnRef *cref, Node *var); static Node *plpgsql_post_column_ref(ParseState *pstate, ColumnRef *cref, Node *var);
...@@ -410,7 +410,7 @@ do_compile(FunctionCallInfo fcinfo, ...@@ -410,7 +410,7 @@ do_compile(FunctionCallInfo fcinfo,
char argmode = argmodes ? argmodes[i] : PROARGMODE_IN; char argmode = argmodes ? argmodes[i] : PROARGMODE_IN;
PLpgSQL_type *argdtype; PLpgSQL_type *argdtype;
PLpgSQL_variable *argvariable; PLpgSQL_variable *argvariable;
int argitemtype; PLpgSQL_nsitem_type argitemtype;
/* Create $n name for variable */ /* Create $n name for variable */
snprintf(buf, sizeof(buf), "$%d", i + 1); snprintf(buf, sizeof(buf), "$%d", i + 1);
...@@ -946,7 +946,7 @@ plpgsql_compile_error_callback(void *arg) ...@@ -946,7 +946,7 @@ plpgsql_compile_error_callback(void *arg)
* Add a name for a function parameter to the function's namespace * Add a name for a function parameter to the function's namespace
*/ */
static void static void
add_parameter_name(int itemtype, int itemno, const char *name) add_parameter_name(PLpgSQL_nsitem_type itemtype, int itemno, const char *name)
{ {
/* /*
* Before adding the name, check for duplicates. We need this even though * Before adding the name, check for duplicates. We need this even though
......
...@@ -1557,7 +1557,7 @@ exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt) ...@@ -1557,7 +1557,7 @@ exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
CHECK_FOR_INTERRUPTS(); CHECK_FOR_INTERRUPTS();
switch ((enum PLpgSQL_stmt_types) stmt->cmd_type) switch (stmt->cmd_type)
{ {
case PLPGSQL_STMT_BLOCK: case PLPGSQL_STMT_BLOCK:
rc = exec_stmt_block(estate, (PLpgSQL_stmt_block *) stmt); rc = exec_stmt_block(estate, (PLpgSQL_stmt_block *) stmt);
......
...@@ -51,7 +51,7 @@ plpgsql_ns_init(void) ...@@ -51,7 +51,7 @@ plpgsql_ns_init(void)
* ---------- * ----------
*/ */
void void
plpgsql_ns_push(const char *label, enum PLpgSQL_label_types label_type) plpgsql_ns_push(const char *label, PLpgSQL_label_type label_type)
{ {
if (label == NULL) if (label == NULL)
label = ""; label = "";
...@@ -89,7 +89,7 @@ plpgsql_ns_top(void) ...@@ -89,7 +89,7 @@ plpgsql_ns_top(void)
* ---------- * ----------
*/ */
void void
plpgsql_ns_additem(int itemtype, int itemno, const char *name) plpgsql_ns_additem(PLpgSQL_nsitem_type itemtype, int itemno, const char *name)
{ {
PLpgSQL_nsitem *nse; PLpgSQL_nsitem *nse;
...@@ -231,7 +231,7 @@ plpgsql_ns_find_nearest_loop(PLpgSQL_nsitem *ns_cur) ...@@ -231,7 +231,7 @@ plpgsql_ns_find_nearest_loop(PLpgSQL_nsitem *ns_cur)
const char * const char *
plpgsql_stmt_typename(PLpgSQL_stmt *stmt) plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
{ {
switch ((enum PLpgSQL_stmt_types) stmt->cmd_type) switch (stmt->cmd_type)
{ {
case PLPGSQL_STMT_BLOCK: case PLPGSQL_STMT_BLOCK:
return _("statement block"); return _("statement block");
...@@ -291,7 +291,7 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt) ...@@ -291,7 +291,7 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
* GET DIAGNOSTICS item name as a string, for use in error messages etc. * GET DIAGNOSTICS item name as a string, for use in error messages etc.
*/ */
const char * const char *
plpgsql_getdiag_kindname(int kind) plpgsql_getdiag_kindname(PLpgSQL_getdiag_kind kind)
{ {
switch (kind) switch (kind)
{ {
...@@ -367,7 +367,7 @@ static void free_expr(PLpgSQL_expr *expr); ...@@ -367,7 +367,7 @@ static void free_expr(PLpgSQL_expr *expr);
static void static void
free_stmt(PLpgSQL_stmt *stmt) free_stmt(PLpgSQL_stmt *stmt)
{ {
switch ((enum PLpgSQL_stmt_types) stmt->cmd_type) switch (stmt->cmd_type)
{ {
case PLPGSQL_STMT_BLOCK: case PLPGSQL_STMT_BLOCK:
free_block((PLpgSQL_stmt_block *) stmt); free_block((PLpgSQL_stmt_block *) stmt);
...@@ -791,7 +791,7 @@ static void ...@@ -791,7 +791,7 @@ static void
dump_stmt(PLpgSQL_stmt *stmt) dump_stmt(PLpgSQL_stmt *stmt)
{ {
printf("%3d:", stmt->lineno); printf("%3d:", stmt->lineno);
switch ((enum PLpgSQL_stmt_types) stmt->cmd_type) switch (stmt->cmd_type)
{ {
case PLPGSQL_STMT_BLOCK: case PLPGSQL_STMT_BLOCK:
dump_block((PLpgSQL_stmt_block *) stmt); dump_block((PLpgSQL_stmt_block *) stmt);
......
...@@ -37,28 +37,28 @@ ...@@ -37,28 +37,28 @@
/* /*
* Compiler's namespace item types * Compiler's namespace item types
*/ */
enum typedef enum PLpgSQL_nsitem_type
{ {
PLPGSQL_NSTYPE_LABEL, PLPGSQL_NSTYPE_LABEL,
PLPGSQL_NSTYPE_VAR, PLPGSQL_NSTYPE_VAR,
PLPGSQL_NSTYPE_ROW, PLPGSQL_NSTYPE_ROW,
PLPGSQL_NSTYPE_REC PLPGSQL_NSTYPE_REC
}; } PLpgSQL_nsitem_type;
/* /*
* A PLPGSQL_NSTYPE_LABEL stack entry must be one of these types * A PLPGSQL_NSTYPE_LABEL stack entry must be one of these types
*/ */
enum PLpgSQL_label_types typedef enum PLpgSQL_label_type
{ {
PLPGSQL_LABEL_BLOCK, /* DECLARE/BEGIN block */ PLPGSQL_LABEL_BLOCK, /* DECLARE/BEGIN block */
PLPGSQL_LABEL_LOOP, /* looping construct */ PLPGSQL_LABEL_LOOP, /* looping construct */
PLPGSQL_LABEL_OTHER /* anything else */ PLPGSQL_LABEL_OTHER /* anything else */
}; } PLpgSQL_label_type;
/* /*
* Datum array node types * Datum array node types
*/ */
enum typedef enum PLpgSQL_datum_type
{ {
PLPGSQL_DTYPE_VAR, PLPGSQL_DTYPE_VAR,
PLPGSQL_DTYPE_ROW, PLPGSQL_DTYPE_ROW,
...@@ -66,23 +66,23 @@ enum ...@@ -66,23 +66,23 @@ enum
PLPGSQL_DTYPE_RECFIELD, PLPGSQL_DTYPE_RECFIELD,
PLPGSQL_DTYPE_ARRAYELEM, PLPGSQL_DTYPE_ARRAYELEM,
PLPGSQL_DTYPE_EXPR PLPGSQL_DTYPE_EXPR
}; } PLpgSQL_datum_type;
/* /*
* Variants distinguished in PLpgSQL_type structs * Variants distinguished in PLpgSQL_type structs
*/ */
enum typedef enum PLpgSQL_type_type
{ {
PLPGSQL_TTYPE_SCALAR, /* scalar types and domains */ PLPGSQL_TTYPE_SCALAR, /* scalar types and domains */
PLPGSQL_TTYPE_ROW, /* composite types */ PLPGSQL_TTYPE_ROW, /* composite types */
PLPGSQL_TTYPE_REC, /* RECORD pseudotype */ PLPGSQL_TTYPE_REC, /* RECORD pseudotype */
PLPGSQL_TTYPE_PSEUDO /* other pseudotypes */ PLPGSQL_TTYPE_PSEUDO /* other pseudotypes */
}; } PLpgSQL_type_type;
/* /*
* Execution tree node types * Execution tree node types
*/ */
enum PLpgSQL_stmt_types typedef enum PLpgSQL_stmt_type
{ {
PLPGSQL_STMT_BLOCK, PLPGSQL_STMT_BLOCK,
PLPGSQL_STMT_ASSIGN, PLPGSQL_STMT_ASSIGN,
...@@ -108,7 +108,7 @@ enum PLpgSQL_stmt_types ...@@ -108,7 +108,7 @@ enum PLpgSQL_stmt_types
PLPGSQL_STMT_FETCH, PLPGSQL_STMT_FETCH,
PLPGSQL_STMT_CLOSE, PLPGSQL_STMT_CLOSE,
PLPGSQL_STMT_PERFORM PLPGSQL_STMT_PERFORM
}; } PLpgSQL_stmt_type;
/* /*
* Execution node return codes * Execution node return codes
...@@ -124,7 +124,7 @@ enum ...@@ -124,7 +124,7 @@ enum
/* /*
* GET DIAGNOSTICS information items * GET DIAGNOSTICS information items
*/ */
enum typedef enum PLpgSQL_getdiag_kind
{ {
PLPGSQL_GETDIAG_ROW_COUNT, PLPGSQL_GETDIAG_ROW_COUNT,
PLPGSQL_GETDIAG_RESULT_OID, PLPGSQL_GETDIAG_RESULT_OID,
...@@ -139,12 +139,12 @@ enum ...@@ -139,12 +139,12 @@ enum
PLPGSQL_GETDIAG_MESSAGE_TEXT, PLPGSQL_GETDIAG_MESSAGE_TEXT,
PLPGSQL_GETDIAG_TABLE_NAME, PLPGSQL_GETDIAG_TABLE_NAME,
PLPGSQL_GETDIAG_SCHEMA_NAME PLPGSQL_GETDIAG_SCHEMA_NAME
}; } PLpgSQL_getdiag_kind;
/* /*
* RAISE statement options * RAISE statement options
*/ */
enum typedef enum PLpgSQL_raise_option_type
{ {
PLPGSQL_RAISEOPTION_ERRCODE, PLPGSQL_RAISEOPTION_ERRCODE,
PLPGSQL_RAISEOPTION_MESSAGE, PLPGSQL_RAISEOPTION_MESSAGE,
...@@ -155,12 +155,12 @@ enum ...@@ -155,12 +155,12 @@ enum
PLPGSQL_RAISEOPTION_DATATYPE, PLPGSQL_RAISEOPTION_DATATYPE,
PLPGSQL_RAISEOPTION_TABLE, PLPGSQL_RAISEOPTION_TABLE,
PLPGSQL_RAISEOPTION_SCHEMA PLPGSQL_RAISEOPTION_SCHEMA
}; } PLpgSQL_raise_option_type;
/* /*
* Behavioral modes for plpgsql variable resolution * Behavioral modes for plpgsql variable resolution
*/ */
typedef enum typedef enum PLpgSQL_resolve_option
{ {
PLPGSQL_RESOLVE_ERROR, /* throw error if ambiguous */ PLPGSQL_RESOLVE_ERROR, /* throw error if ambiguous */
PLPGSQL_RESOLVE_VARIABLE, /* prefer plpgsql var to table column */ PLPGSQL_RESOLVE_VARIABLE, /* prefer plpgsql var to table column */
...@@ -179,7 +179,7 @@ typedef struct PLpgSQL_type ...@@ -179,7 +179,7 @@ typedef struct PLpgSQL_type
{ {
char *typname; /* (simple) name of the type */ char *typname; /* (simple) name of the type */
Oid typoid; /* OID of the data type */ Oid typoid; /* OID of the data type */
int ttype; /* PLPGSQL_TTYPE_ code */ PLpgSQL_type_type ttype; /* PLPGSQL_TTYPE_ code */
int16 typlen; /* stuff copied from its pg_type entry */ int16 typlen; /* stuff copied from its pg_type entry */
bool typbyval; bool typbyval;
char typtype; char typtype;
...@@ -197,7 +197,7 @@ typedef struct PLpgSQL_type ...@@ -197,7 +197,7 @@ typedef struct PLpgSQL_type
*/ */
typedef struct PLpgSQL_datum typedef struct PLpgSQL_datum
{ {
int dtype; PLpgSQL_datum_type dtype;
int dno; int dno;
} PLpgSQL_datum; } PLpgSQL_datum;
...@@ -209,7 +209,7 @@ typedef struct PLpgSQL_datum ...@@ -209,7 +209,7 @@ typedef struct PLpgSQL_datum
*/ */
typedef struct PLpgSQL_variable typedef struct PLpgSQL_variable
{ {
int dtype; PLpgSQL_datum_type dtype;
int dno; int dno;
char *refname; char *refname;
int lineno; int lineno;
...@@ -220,7 +220,7 @@ typedef struct PLpgSQL_variable ...@@ -220,7 +220,7 @@ typedef struct PLpgSQL_variable
*/ */
typedef struct PLpgSQL_expr typedef struct PLpgSQL_expr
{ {
int dtype; PLpgSQL_datum_type dtype;
int dno; int dno;
char *query; char *query;
SPIPlanPtr plan; SPIPlanPtr plan;
...@@ -255,7 +255,7 @@ typedef struct PLpgSQL_expr ...@@ -255,7 +255,7 @@ typedef struct PLpgSQL_expr
*/ */
typedef struct PLpgSQL_var typedef struct PLpgSQL_var
{ {
int dtype; PLpgSQL_datum_type dtype;
int dno; int dno;
char *refname; char *refname;
int lineno; int lineno;
...@@ -278,7 +278,7 @@ typedef struct PLpgSQL_var ...@@ -278,7 +278,7 @@ typedef struct PLpgSQL_var
*/ */
typedef struct PLpgSQL_row typedef struct PLpgSQL_row
{ {
int dtype; PLpgSQL_datum_type dtype;
int dno; int dno;
char *refname; char *refname;
int lineno; int lineno;
...@@ -301,7 +301,7 @@ typedef struct PLpgSQL_row ...@@ -301,7 +301,7 @@ typedef struct PLpgSQL_row
*/ */
typedef struct PLpgSQL_rec typedef struct PLpgSQL_rec
{ {
int dtype; PLpgSQL_datum_type dtype;
int dno; int dno;
char *refname; char *refname;
int lineno; int lineno;
...@@ -317,7 +317,7 @@ typedef struct PLpgSQL_rec ...@@ -317,7 +317,7 @@ typedef struct PLpgSQL_rec
*/ */
typedef struct PLpgSQL_recfield typedef struct PLpgSQL_recfield
{ {
int dtype; PLpgSQL_datum_type dtype;
int dno; int dno;
char *fieldname; char *fieldname;
int recparentno; /* dno of parent record */ int recparentno; /* dno of parent record */
...@@ -328,7 +328,7 @@ typedef struct PLpgSQL_recfield ...@@ -328,7 +328,7 @@ typedef struct PLpgSQL_recfield
*/ */
typedef struct PLpgSQL_arrayelem typedef struct PLpgSQL_arrayelem
{ {
int dtype; PLpgSQL_datum_type dtype;
int dno; int dno;
PLpgSQL_expr *subscript; PLpgSQL_expr *subscript;
int arrayparentno; /* dno of parent array variable */ int arrayparentno; /* dno of parent array variable */
...@@ -350,9 +350,9 @@ typedef struct PLpgSQL_arrayelem ...@@ -350,9 +350,9 @@ typedef struct PLpgSQL_arrayelem
*/ */
typedef struct PLpgSQL_nsitem typedef struct PLpgSQL_nsitem
{ {
int itemtype; PLpgSQL_nsitem_type itemtype;
/* /*
* For labels, itemno is a value of enum PLpgSQL_label_types. For other * For labels, itemno is a value of enum PLpgSQL_label_type. For other
* itemtypes, itemno is the associated PLpgSQL_datum's dno. * itemtypes, itemno is the associated PLpgSQL_datum's dno.
*/ */
int itemno; int itemno;
...@@ -365,7 +365,7 @@ typedef struct PLpgSQL_nsitem ...@@ -365,7 +365,7 @@ typedef struct PLpgSQL_nsitem
*/ */
typedef struct PLpgSQL_stmt typedef struct PLpgSQL_stmt
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
} PLpgSQL_stmt; } PLpgSQL_stmt;
...@@ -404,7 +404,7 @@ typedef struct PLpgSQL_exception ...@@ -404,7 +404,7 @@ typedef struct PLpgSQL_exception
*/ */
typedef struct PLpgSQL_stmt_block typedef struct PLpgSQL_stmt_block
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
char *label; char *label;
List *body; /* List of statements */ List *body; /* List of statements */
...@@ -418,7 +418,7 @@ typedef struct PLpgSQL_stmt_block ...@@ -418,7 +418,7 @@ typedef struct PLpgSQL_stmt_block
*/ */
typedef struct PLpgSQL_stmt_assign typedef struct PLpgSQL_stmt_assign
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
int varno; int varno;
PLpgSQL_expr *expr; PLpgSQL_expr *expr;
...@@ -429,7 +429,7 @@ typedef struct PLpgSQL_stmt_assign ...@@ -429,7 +429,7 @@ typedef struct PLpgSQL_stmt_assign
*/ */
typedef struct PLpgSQL_stmt_perform typedef struct PLpgSQL_stmt_perform
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
PLpgSQL_expr *expr; PLpgSQL_expr *expr;
} PLpgSQL_stmt_perform; } PLpgSQL_stmt_perform;
...@@ -439,7 +439,7 @@ typedef struct PLpgSQL_stmt_perform ...@@ -439,7 +439,7 @@ typedef struct PLpgSQL_stmt_perform
*/ */
typedef struct PLpgSQL_diag_item typedef struct PLpgSQL_diag_item
{ {
int kind; /* id for diagnostic value desired */ PLpgSQL_getdiag_kind kind; /* id for diagnostic value desired */
int target; /* where to assign it */ int target; /* where to assign it */
} PLpgSQL_diag_item; } PLpgSQL_diag_item;
...@@ -448,7 +448,7 @@ typedef struct PLpgSQL_diag_item ...@@ -448,7 +448,7 @@ typedef struct PLpgSQL_diag_item
*/ */
typedef struct PLpgSQL_stmt_getdiag typedef struct PLpgSQL_stmt_getdiag
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
bool is_stacked; /* STACKED or CURRENT diagnostics area? */ bool is_stacked; /* STACKED or CURRENT diagnostics area? */
List *diag_items; /* List of PLpgSQL_diag_item */ List *diag_items; /* List of PLpgSQL_diag_item */
...@@ -459,7 +459,7 @@ typedef struct PLpgSQL_stmt_getdiag ...@@ -459,7 +459,7 @@ typedef struct PLpgSQL_stmt_getdiag
*/ */
typedef struct PLpgSQL_stmt_if typedef struct PLpgSQL_stmt_if
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
PLpgSQL_expr *cond; /* boolean expression for THEN */ PLpgSQL_expr *cond; /* boolean expression for THEN */
List *then_body; /* List of statements */ List *then_body; /* List of statements */
...@@ -482,7 +482,7 @@ typedef struct PLpgSQL_if_elsif ...@@ -482,7 +482,7 @@ typedef struct PLpgSQL_if_elsif
*/ */
typedef struct PLpgSQL_stmt_case typedef struct PLpgSQL_stmt_case
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
PLpgSQL_expr *t_expr; /* test expression, or NULL if none */ PLpgSQL_expr *t_expr; /* test expression, or NULL if none */
int t_varno; /* var to store test expression value into */ int t_varno; /* var to store test expression value into */
...@@ -506,7 +506,7 @@ typedef struct PLpgSQL_case_when ...@@ -506,7 +506,7 @@ typedef struct PLpgSQL_case_when
*/ */
typedef struct PLpgSQL_stmt_loop typedef struct PLpgSQL_stmt_loop
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
char *label; char *label;
List *body; /* List of statements */ List *body; /* List of statements */
...@@ -517,7 +517,7 @@ typedef struct PLpgSQL_stmt_loop ...@@ -517,7 +517,7 @@ typedef struct PLpgSQL_stmt_loop
*/ */
typedef struct PLpgSQL_stmt_while typedef struct PLpgSQL_stmt_while
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
char *label; char *label;
PLpgSQL_expr *cond; PLpgSQL_expr *cond;
...@@ -529,7 +529,7 @@ typedef struct PLpgSQL_stmt_while ...@@ -529,7 +529,7 @@ typedef struct PLpgSQL_stmt_while
*/ */
typedef struct PLpgSQL_stmt_fori typedef struct PLpgSQL_stmt_fori
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
char *label; char *label;
PLpgSQL_var *var; PLpgSQL_var *var;
...@@ -547,7 +547,7 @@ typedef struct PLpgSQL_stmt_fori ...@@ -547,7 +547,7 @@ typedef struct PLpgSQL_stmt_fori
*/ */
typedef struct PLpgSQL_stmt_forq typedef struct PLpgSQL_stmt_forq
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
char *label; char *label;
PLpgSQL_rec *rec; PLpgSQL_rec *rec;
...@@ -560,7 +560,7 @@ typedef struct PLpgSQL_stmt_forq ...@@ -560,7 +560,7 @@ typedef struct PLpgSQL_stmt_forq
*/ */
typedef struct PLpgSQL_stmt_fors typedef struct PLpgSQL_stmt_fors
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
char *label; char *label;
PLpgSQL_rec *rec; PLpgSQL_rec *rec;
...@@ -575,7 +575,7 @@ typedef struct PLpgSQL_stmt_fors ...@@ -575,7 +575,7 @@ typedef struct PLpgSQL_stmt_fors
*/ */
typedef struct PLpgSQL_stmt_forc typedef struct PLpgSQL_stmt_forc
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
char *label; char *label;
PLpgSQL_rec *rec; PLpgSQL_rec *rec;
...@@ -591,7 +591,7 @@ typedef struct PLpgSQL_stmt_forc ...@@ -591,7 +591,7 @@ typedef struct PLpgSQL_stmt_forc
*/ */
typedef struct PLpgSQL_stmt_dynfors typedef struct PLpgSQL_stmt_dynfors
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
char *label; char *label;
PLpgSQL_rec *rec; PLpgSQL_rec *rec;
...@@ -607,7 +607,7 @@ typedef struct PLpgSQL_stmt_dynfors ...@@ -607,7 +607,7 @@ typedef struct PLpgSQL_stmt_dynfors
*/ */
typedef struct PLpgSQL_stmt_foreach_a typedef struct PLpgSQL_stmt_foreach_a
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
char *label; char *label;
int varno; /* loop target variable */ int varno; /* loop target variable */
...@@ -621,7 +621,7 @@ typedef struct PLpgSQL_stmt_foreach_a ...@@ -621,7 +621,7 @@ typedef struct PLpgSQL_stmt_foreach_a
*/ */
typedef struct PLpgSQL_stmt_open typedef struct PLpgSQL_stmt_open
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
int curvar; int curvar;
int cursor_options; int cursor_options;
...@@ -637,7 +637,7 @@ typedef struct PLpgSQL_stmt_open ...@@ -637,7 +637,7 @@ typedef struct PLpgSQL_stmt_open
*/ */
typedef struct PLpgSQL_stmt_fetch typedef struct PLpgSQL_stmt_fetch
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
PLpgSQL_rec *rec; /* target, as record or row */ PLpgSQL_rec *rec; /* target, as record or row */
PLpgSQL_row *row; PLpgSQL_row *row;
...@@ -654,7 +654,7 @@ typedef struct PLpgSQL_stmt_fetch ...@@ -654,7 +654,7 @@ typedef struct PLpgSQL_stmt_fetch
*/ */
typedef struct PLpgSQL_stmt_close typedef struct PLpgSQL_stmt_close
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
int curvar; int curvar;
} PLpgSQL_stmt_close; } PLpgSQL_stmt_close;
...@@ -664,7 +664,7 @@ typedef struct PLpgSQL_stmt_close ...@@ -664,7 +664,7 @@ typedef struct PLpgSQL_stmt_close
*/ */
typedef struct PLpgSQL_stmt_exit typedef struct PLpgSQL_stmt_exit
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
bool is_exit; /* Is this an exit or a continue? */ bool is_exit; /* Is this an exit or a continue? */
char *label; /* NULL if it's an unlabelled EXIT/CONTINUE */ char *label; /* NULL if it's an unlabelled EXIT/CONTINUE */
...@@ -676,7 +676,7 @@ typedef struct PLpgSQL_stmt_exit ...@@ -676,7 +676,7 @@ typedef struct PLpgSQL_stmt_exit
*/ */
typedef struct PLpgSQL_stmt_return typedef struct PLpgSQL_stmt_return
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
PLpgSQL_expr *expr; PLpgSQL_expr *expr;
int retvarno; int retvarno;
...@@ -687,7 +687,7 @@ typedef struct PLpgSQL_stmt_return ...@@ -687,7 +687,7 @@ typedef struct PLpgSQL_stmt_return
*/ */
typedef struct PLpgSQL_stmt_return_next typedef struct PLpgSQL_stmt_return_next
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
PLpgSQL_expr *expr; PLpgSQL_expr *expr;
int retvarno; int retvarno;
...@@ -698,7 +698,7 @@ typedef struct PLpgSQL_stmt_return_next ...@@ -698,7 +698,7 @@ typedef struct PLpgSQL_stmt_return_next
*/ */
typedef struct PLpgSQL_stmt_return_query typedef struct PLpgSQL_stmt_return_query
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
PLpgSQL_expr *query; /* if static query */ PLpgSQL_expr *query; /* if static query */
PLpgSQL_expr *dynquery; /* if dynamic query (RETURN QUERY EXECUTE) */ PLpgSQL_expr *dynquery; /* if dynamic query (RETURN QUERY EXECUTE) */
...@@ -710,7 +710,7 @@ typedef struct PLpgSQL_stmt_return_query ...@@ -710,7 +710,7 @@ typedef struct PLpgSQL_stmt_return_query
*/ */
typedef struct PLpgSQL_stmt_raise typedef struct PLpgSQL_stmt_raise
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
int elog_level; int elog_level;
char *condname; /* condition name, SQLSTATE, or NULL */ char *condname; /* condition name, SQLSTATE, or NULL */
...@@ -724,7 +724,7 @@ typedef struct PLpgSQL_stmt_raise ...@@ -724,7 +724,7 @@ typedef struct PLpgSQL_stmt_raise
*/ */
typedef struct PLpgSQL_raise_option typedef struct PLpgSQL_raise_option
{ {
int opt_type; PLpgSQL_raise_option_type opt_type;
PLpgSQL_expr *expr; PLpgSQL_expr *expr;
} PLpgSQL_raise_option; } PLpgSQL_raise_option;
...@@ -733,7 +733,7 @@ typedef struct PLpgSQL_raise_option ...@@ -733,7 +733,7 @@ typedef struct PLpgSQL_raise_option
*/ */
typedef struct PLpgSQL_stmt_assert typedef struct PLpgSQL_stmt_assert
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
PLpgSQL_expr *cond; PLpgSQL_expr *cond;
PLpgSQL_expr *message; PLpgSQL_expr *message;
...@@ -744,7 +744,7 @@ typedef struct PLpgSQL_stmt_assert ...@@ -744,7 +744,7 @@ typedef struct PLpgSQL_stmt_assert
*/ */
typedef struct PLpgSQL_stmt_execsql typedef struct PLpgSQL_stmt_execsql
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
PLpgSQL_expr *sqlstmt; PLpgSQL_expr *sqlstmt;
bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE? Note: bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE? Note:
...@@ -760,7 +760,7 @@ typedef struct PLpgSQL_stmt_execsql ...@@ -760,7 +760,7 @@ typedef struct PLpgSQL_stmt_execsql
*/ */
typedef struct PLpgSQL_stmt_dynexecute typedef struct PLpgSQL_stmt_dynexecute
{ {
int cmd_type; PLpgSQL_stmt_type cmd_type;
int lineno; int lineno;
PLpgSQL_expr *query; /* string expression */ PLpgSQL_expr *query; /* string expression */
bool into; /* INTO supplied? */ bool into; /* INTO supplied? */
...@@ -1111,10 +1111,10 @@ extern void plpgsql_exec_get_datum_type_info(PLpgSQL_execstate *estate, ...@@ -1111,10 +1111,10 @@ extern void plpgsql_exec_get_datum_type_info(PLpgSQL_execstate *estate,
*/ */
extern void plpgsql_ns_init(void); extern void plpgsql_ns_init(void);
extern void plpgsql_ns_push(const char *label, extern void plpgsql_ns_push(const char *label,
enum PLpgSQL_label_types label_type); PLpgSQL_label_type label_type);
extern void plpgsql_ns_pop(void); extern void plpgsql_ns_pop(void);
extern PLpgSQL_nsitem *plpgsql_ns_top(void); extern PLpgSQL_nsitem *plpgsql_ns_top(void);
extern void plpgsql_ns_additem(int itemtype, int itemno, const char *name); extern void plpgsql_ns_additem(PLpgSQL_nsitem_type itemtype, int itemno, const char *name);
extern PLpgSQL_nsitem *plpgsql_ns_lookup(PLpgSQL_nsitem *ns_cur, bool localmode, extern PLpgSQL_nsitem *plpgsql_ns_lookup(PLpgSQL_nsitem *ns_cur, bool localmode,
const char *name1, const char *name2, const char *name1, const char *name2,
const char *name3, int *names_used); const char *name3, int *names_used);
...@@ -1126,7 +1126,7 @@ extern PLpgSQL_nsitem *plpgsql_ns_find_nearest_loop(PLpgSQL_nsitem *ns_cur); ...@@ -1126,7 +1126,7 @@ extern PLpgSQL_nsitem *plpgsql_ns_find_nearest_loop(PLpgSQL_nsitem *ns_cur);
* Other functions in pl_funcs.c * Other functions in pl_funcs.c
*/ */
extern const char *plpgsql_stmt_typename(PLpgSQL_stmt *stmt); extern const char *plpgsql_stmt_typename(PLpgSQL_stmt *stmt);
extern const char *plpgsql_getdiag_kindname(int kind); extern const char *plpgsql_getdiag_kindname(PLpgSQL_getdiag_kind kind);
extern void plpgsql_free_function_memory(PLpgSQL_function *func); extern void plpgsql_free_function_memory(PLpgSQL_function *func);
extern void plpgsql_dumptree(PLpgSQL_function *func); extern void plpgsql_dumptree(PLpgSQL_function *func);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment