Allow enums to be created with zero labels, for use during binary upgrade.
<!--
-$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
-->
( <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>,
*
*
* 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
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
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;
}
;
+opt_enum_val_list:
+ enum_val_list { $$ = $1; }
+ | /*EMPTY*/ { $$ = NIL; }
+ ;
+
enum_val_list: Sconst
{ $$ = list_make1(makeString($1)); }
| enum_val_list ',' Sconst
* 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 $
*
*-------------------------------------------------------------------------
*/
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.