/*
  * Compiler's namespace item types
  */
-enum
+typedef enum PLpgSQL_nsitem_type
 {
        PLPGSQL_NSTYPE_LABEL,
        PLPGSQL_NSTYPE_VAR,
        PLPGSQL_NSTYPE_ROW,
        PLPGSQL_NSTYPE_REC
-};
+} PLpgSQL_nsitem_type;
 
 /*
  * 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_LOOP,                     /* looping construct */
        PLPGSQL_LABEL_OTHER                     /* anything else */
-};
+} PLpgSQL_label_type;
 
 /*
  * Datum array node types
  */
-enum
+typedef enum PLpgSQL_datum_type
 {
        PLPGSQL_DTYPE_VAR,
        PLPGSQL_DTYPE_ROW,
        PLPGSQL_DTYPE_RECFIELD,
        PLPGSQL_DTYPE_ARRAYELEM,
        PLPGSQL_DTYPE_EXPR
-};
+} PLpgSQL_datum_type;
 
 /*
  * Variants distinguished in PLpgSQL_type structs
  */
-enum
+typedef enum PLpgSQL_type_type
 {
        PLPGSQL_TTYPE_SCALAR,           /* scalar types and domains */
        PLPGSQL_TTYPE_ROW,                      /* composite types */
        PLPGSQL_TTYPE_REC,                      /* RECORD pseudotype */
        PLPGSQL_TTYPE_PSEUDO            /* other pseudotypes */
-};
+} PLpgSQL_type_type;
 
 /*
  * Execution tree node types
  */
-enum PLpgSQL_stmt_types
+typedef enum PLpgSQL_stmt_type
 {
        PLPGSQL_STMT_BLOCK,
        PLPGSQL_STMT_ASSIGN,
        PLPGSQL_STMT_FETCH,
        PLPGSQL_STMT_CLOSE,
        PLPGSQL_STMT_PERFORM
-};
+} PLpgSQL_stmt_type;
 
 /*
  * Execution node return codes
 /*
  * GET DIAGNOSTICS information items
  */
-enum
+typedef enum PLpgSQL_getdiag_kind
 {
        PLPGSQL_GETDIAG_ROW_COUNT,
        PLPGSQL_GETDIAG_RESULT_OID,
        PLPGSQL_GETDIAG_MESSAGE_TEXT,
        PLPGSQL_GETDIAG_TABLE_NAME,
        PLPGSQL_GETDIAG_SCHEMA_NAME
-};
+} PLpgSQL_getdiag_kind;
 
 /*
  * RAISE statement options
  */
-enum
+typedef enum PLpgSQL_raise_option_type
 {
        PLPGSQL_RAISEOPTION_ERRCODE,
        PLPGSQL_RAISEOPTION_MESSAGE,
        PLPGSQL_RAISEOPTION_DATATYPE,
        PLPGSQL_RAISEOPTION_TABLE,
        PLPGSQL_RAISEOPTION_SCHEMA
-};
+} PLpgSQL_raise_option_type;
 
 /*
  * Behavioral modes for plpgsql variable resolution
  */
-typedef enum
+typedef enum PLpgSQL_resolve_option
 {
        PLPGSQL_RESOLVE_ERROR,          /* throw error if ambiguous */
        PLPGSQL_RESOLVE_VARIABLE,       /* prefer plpgsql var to table column */
 {
        char       *typname;            /* (simple) name of the 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 */
        bool            typbyval;
        char            typtype;
  */
 typedef struct PLpgSQL_datum
 {
-       int                     dtype;
+       PLpgSQL_datum_type dtype;
        int                     dno;
 } PLpgSQL_datum;
 
  */
 typedef struct PLpgSQL_variable
 {
-       int                     dtype;
+       PLpgSQL_datum_type dtype;
        int                     dno;
        char       *refname;
        int                     lineno;
  */
 typedef struct PLpgSQL_expr
 {
-       int                     dtype;
+       PLpgSQL_datum_type dtype;
        int                     dno;
        char       *query;
        SPIPlanPtr      plan;
  */
 typedef struct PLpgSQL_var
 {
-       int                     dtype;
+       PLpgSQL_datum_type dtype;
        int                     dno;
        char       *refname;
        int                     lineno;
  */
 typedef struct PLpgSQL_row
 {
-       int                     dtype;
+       PLpgSQL_datum_type dtype;
        int                     dno;
        char       *refname;
        int                     lineno;
  */
 typedef struct PLpgSQL_rec
 {
-       int                     dtype;
+       PLpgSQL_datum_type dtype;
        int                     dno;
        char       *refname;
        int                     lineno;
  */
 typedef struct PLpgSQL_recfield
 {
-       int                     dtype;
+       PLpgSQL_datum_type dtype;
        int                     dno;
        char       *fieldname;
        int                     recparentno;    /* dno of parent record */
  */
 typedef struct PLpgSQL_arrayelem
 {
-       int                     dtype;
+       PLpgSQL_datum_type dtype;
        int                     dno;
        PLpgSQL_expr *subscript;
        int                     arrayparentno;  /* dno of parent array variable */
  */
 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.
         */
        int                     itemno;
  */
 typedef struct PLpgSQL_stmt
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
 } PLpgSQL_stmt;
 
  */
 typedef struct PLpgSQL_stmt_block
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        char       *label;
        List       *body;                       /* List of statements */
  */
 typedef struct PLpgSQL_stmt_assign
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        int                     varno;
        PLpgSQL_expr *expr;
  */
 typedef struct PLpgSQL_stmt_perform
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        PLpgSQL_expr *expr;
 } PLpgSQL_stmt_perform;
  */
 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 */
 } PLpgSQL_diag_item;
 
  */
 typedef struct PLpgSQL_stmt_getdiag
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        bool            is_stacked;             /* STACKED or CURRENT diagnostics area? */
        List       *diag_items;         /* List of PLpgSQL_diag_item */
  */
 typedef struct PLpgSQL_stmt_if
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        PLpgSQL_expr *cond;                     /* boolean expression for THEN */
        List       *then_body;          /* List of statements */
  */
 typedef struct PLpgSQL_stmt_case
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        PLpgSQL_expr *t_expr;           /* test expression, or NULL if none */
        int                     t_varno;                /* var to store test expression value into */
  */
 typedef struct PLpgSQL_stmt_loop
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        char       *label;
        List       *body;                       /* List of statements */
  */
 typedef struct PLpgSQL_stmt_while
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        char       *label;
        PLpgSQL_expr *cond;
  */
 typedef struct PLpgSQL_stmt_fori
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        char       *label;
        PLpgSQL_var *var;
  */
 typedef struct PLpgSQL_stmt_forq
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        char       *label;
        PLpgSQL_rec *rec;
  */
 typedef struct PLpgSQL_stmt_fors
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        char       *label;
        PLpgSQL_rec *rec;
  */
 typedef struct PLpgSQL_stmt_forc
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        char       *label;
        PLpgSQL_rec *rec;
  */
 typedef struct PLpgSQL_stmt_dynfors
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        char       *label;
        PLpgSQL_rec *rec;
  */
 typedef struct PLpgSQL_stmt_foreach_a
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        char       *label;
        int                     varno;                  /* loop target variable */
  */
 typedef struct PLpgSQL_stmt_open
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        int                     curvar;
        int                     cursor_options;
  */
 typedef struct PLpgSQL_stmt_fetch
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        PLpgSQL_rec *rec;                       /* target, as record or row */
        PLpgSQL_row *row;
  */
 typedef struct PLpgSQL_stmt_close
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        int                     curvar;
 } PLpgSQL_stmt_close;
  */
 typedef struct PLpgSQL_stmt_exit
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        bool            is_exit;                /* Is this an exit or a continue? */
        char       *label;                      /* NULL if it's an unlabelled EXIT/CONTINUE */
  */
 typedef struct PLpgSQL_stmt_return
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        PLpgSQL_expr *expr;
        int                     retvarno;
  */
 typedef struct PLpgSQL_stmt_return_next
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        PLpgSQL_expr *expr;
        int                     retvarno;
  */
 typedef struct PLpgSQL_stmt_return_query
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        PLpgSQL_expr *query;            /* if static query */
        PLpgSQL_expr *dynquery;         /* if dynamic query (RETURN QUERY EXECUTE) */
  */
 typedef struct PLpgSQL_stmt_raise
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        int                     elog_level;
        char       *condname;           /* condition name, SQLSTATE, or NULL */
  */
 typedef struct PLpgSQL_raise_option
 {
-       int                     opt_type;
+       PLpgSQL_raise_option_type opt_type;
        PLpgSQL_expr *expr;
 } PLpgSQL_raise_option;
 
  */
 typedef struct PLpgSQL_stmt_assert
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        PLpgSQL_expr *cond;
        PLpgSQL_expr *message;
  */
 typedef struct PLpgSQL_stmt_execsql
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        PLpgSQL_expr *sqlstmt;
        bool            mod_stmt;               /* is the stmt INSERT/UPDATE/DELETE?  Note:
  */
 typedef struct PLpgSQL_stmt_dynexecute
 {
-       int                     cmd_type;
+       PLpgSQL_stmt_type cmd_type;
        int                     lineno;
        PLpgSQL_expr *query;            /* string expression */
        bool            into;                   /* INTO supplied? */
  */
 extern void plpgsql_ns_init(void);
 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 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,
                                  const char *name1, const char *name2,
                                  const char *name3, int *names_used);
  * Other functions in pl_funcs.c
  */
 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_dumptree(PLpgSQL_function *func);