mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
Zero-label enums:
Allow enums to be created with zero labels, for use during binary upgrade.
This commit is contained in:
parent
f9845aca2b
commit
1fd9883ff4
@ -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>,
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user