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,
PLpgSQL_func_hashkey *hashkey,
bool forValidator);
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 Node *plpgsql_pre_column_ref(ParseState *pstate, ColumnRef *cref);
static Node *plpgsql_post_column_ref(ParseState *pstate, ColumnRef *cref, Node *var);
......@@ -410,7 +410,7 @@ do_compile(FunctionCallInfo fcinfo,
char argmode = argmodes ? argmodes[i] : PROARGMODE_IN;
PLpgSQL_type *argdtype;
PLpgSQL_variable *argvariable;
int argitemtype;
PLpgSQL_nsitem_type argitemtype;
/* Create $n name for variable */
snprintf(buf, sizeof(buf), "$%d", i + 1);
......@@ -946,7 +946,7 @@ plpgsql_compile_error_callback(void *arg)
* Add a name for a function parameter to the function's namespace
*/
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
......
......@@ -1557,7 +1557,7 @@ exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
CHECK_FOR_INTERRUPTS();
switch ((enum PLpgSQL_stmt_types) stmt->cmd_type)
switch (stmt->cmd_type)
{
case PLPGSQL_STMT_BLOCK:
rc = exec_stmt_block(estate, (PLpgSQL_stmt_block *) stmt);
......
......@@ -51,7 +51,7 @@ plpgsql_ns_init(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)
label = "";
......@@ -89,7 +89,7 @@ plpgsql_ns_top(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;
......@@ -231,7 +231,7 @@ plpgsql_ns_find_nearest_loop(PLpgSQL_nsitem *ns_cur)
const char *
plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
{
switch ((enum PLpgSQL_stmt_types) stmt->cmd_type)
switch (stmt->cmd_type)
{
case PLPGSQL_STMT_BLOCK:
return _("statement block");
......@@ -291,7 +291,7 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
* GET DIAGNOSTICS item name as a string, for use in error messages etc.
*/
const char *
plpgsql_getdiag_kindname(int kind)
plpgsql_getdiag_kindname(PLpgSQL_getdiag_kind kind)
{
switch (kind)
{
......@@ -367,7 +367,7 @@ static void free_expr(PLpgSQL_expr *expr);
static void
free_stmt(PLpgSQL_stmt *stmt)
{
switch ((enum PLpgSQL_stmt_types) stmt->cmd_type)
switch (stmt->cmd_type)
{
case PLPGSQL_STMT_BLOCK:
free_block((PLpgSQL_stmt_block *) stmt);
......@@ -791,7 +791,7 @@ static void
dump_stmt(PLpgSQL_stmt *stmt)
{
printf("%3d:", stmt->lineno);
switch ((enum PLpgSQL_stmt_types) stmt->cmd_type)
switch (stmt->cmd_type)
{
case PLPGSQL_STMT_BLOCK:
dump_block((PLpgSQL_stmt_block *) stmt);
......
This diff is collapsed.
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