]> granicus.if.org Git - postgresql/commitdiff
Zero-label enums:
authorBruce Momjian <bruce@momjian.us>
Sat, 26 Dec 2009 16:55:21 +0000 (16:55 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 26 Dec 2009 16:55:21 +0000 (16:55 +0000)
Allow enums to be created with zero labels, for use during binary upgrade.

doc/src/sgml/ref/create_type.sgml
src/backend/parser/gram.y
src/bin/pg_dump/pg_dump.c

index 78b11b8a80ebf69d131132386c25e23d738572e5..cb264127c26c91339a8bce38b60e61fb577735d5 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.79 2008/11/30 19:01:29 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.80 2009/12/26 16:55:21 momjian Exp $
 PostgreSQL documentation
 -->
 
@@ -25,7 +25,7 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> AS
     ( <replaceable class="PARAMETER">attribute_name</replaceable> <replaceable class="PARAMETER">data_type</replaceable> [, ... ] )
 
 CREATE TYPE <replaceable class="parameter">name</replaceable> AS ENUM
-    ( '<replaceable class="parameter">label</replaceable>' [, ... ] )
+    ( [ '<replaceable class="parameter">label</replaceable>' [, ... ] ] )
 
 CREATE TYPE <replaceable class="parameter">name</replaceable> (
     INPUT = <replaceable class="parameter">input_function</replaceable>,
index 30663d578ea7b537cf28926f6f2260f9fc2db05c..333b65bb9e8c7b76182996c69f9bc4da3272c253 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.699 2009/12/23 17:41:43 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.700 2009/12/26 16:55:21 momjian Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -297,7 +297,7 @@ static TypeName *TableFuncTypeName(List *columns);
                                TableFuncElementList opt_type_modifiers
                                prep_type_clause
                                execute_param_clause using_clause returning_clause
-                               enum_val_list table_func_column_list
+                               opt_enum_val_list enum_val_list table_func_column_list
                                create_generic_options alter_generic_options
                                relation_expr_list dostmt_opt_list
 
@@ -3623,7 +3623,7 @@ DefineStmt:
                                        n->coldeflist = $6;
                                        $$ = (Node *)n;
                                }
-                       | CREATE TYPE_P any_name AS ENUM_P '(' enum_val_list ')'
+                       | CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')'
                                {
                                        CreateEnumStmt *n = makeNode(CreateEnumStmt);
                                        n->typeName = $3;
@@ -3715,6 +3715,11 @@ old_aggr_elem:  IDENT '=' def_arg
                                }
                ;
 
+opt_enum_val_list:
+               enum_val_list                                                   { $$ = $1; }
+               | /*EMPTY*/                                                             { $$ = NIL; }
+               ;
+
 enum_val_list: Sconst
                                { $$ = list_make1(makeString($1)); }
                        | enum_val_list ',' Sconst
index 47d2c4fcf404b99b70cdce7f194cda4fac713c0f..037c7045e50940384da13fcac47c13de159e38b6 100644 (file)
@@ -12,7 +12,7 @@
  *     by PostgreSQL
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.561 2009/12/24 22:09:23 momjian Exp $
+ *       $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.562 2009/12/26 16:55:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -6542,12 +6542,6 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo)
        check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
 
        num = PQntuples(res);
-       /* should be at least 1 value */
-       if (num == 0)
-       {
-               write_msg(NULL, "no label definitions found for enum ID %u\n", tyinfo->dobj.catId.oid);
-               exit_nicely();
-       }
 
        /*
         * DROP must be fully qualified in case same name appears in pg_catalog.