Skip to content

Commit 1fd9883

Browse files
committed
Zero-label enums:
Allow enums to be created with zero labels, for use during binary upgrade.
1 parent f9845ac commit 1fd9883

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

doc/src/sgml/ref/create_type.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.79 2008/11/30 19:01:29 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.80 2009/12/26 16:55:21 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -25,7 +25,7 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> AS
2525
( <replaceable class="PARAMETER">attribute_name</replaceable> <replaceable class="PARAMETER">data_type</replaceable> [, ... ] )
2626

2727
CREATE TYPE <replaceable class="parameter">name</replaceable> AS ENUM
28-
( '<replaceable class="parameter">label</replaceable>' [, ... ] )
28+
( [ '<replaceable class="parameter">label</replaceable>' [, ... ] ] )
2929

3030
CREATE TYPE <replaceable class="parameter">name</replaceable> (
3131
INPUT = <replaceable class="parameter">input_function</replaceable>,

src/backend/parser/gram.y

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.699 2009/12/23 17:41:43 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.700 2009/12/26 16:55:21 momjian Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -297,7 +297,7 @@ static TypeName *TableFuncTypeName(List *columns);
297297
TableFuncElementList opt_type_modifiers
298298
prep_type_clause
299299
execute_param_clause using_clause returning_clause
300-
enum_val_list table_func_column_list
300+
opt_enum_val_list enum_val_list table_func_column_list
301301
create_generic_options alter_generic_options
302302
relation_expr_list dostmt_opt_list
303303

@@ -3623,7 +3623,7 @@ DefineStmt:
36233623
n->coldeflist = $6;
36243624
$$ = (Node *)n;
36253625
}
3626-
| CREATE TYPE_P any_name AS ENUM_P '(' enum_val_list ')'
3626+
| CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')'
36273627
{
36283628
CreateEnumStmt *n = makeNode(CreateEnumStmt);
36293629
n->typeName = $3;
@@ -3715,6 +3715,11 @@ old_aggr_elem: IDENT '=' def_arg
37153715
}
37163716
;
37173717

3718+
opt_enum_val_list:
3719+
enum_val_list { $$ = $1; }
3720+
| /*EMPTY*/ { $$ = NIL; }
3721+
;
3722+
37183723
enum_val_list: Sconst
37193724
{ $$ = list_make1(makeString($1)); }
37203725
| enum_val_list ',' Sconst

src/bin/pg_dump/pg_dump.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.561 2009/12/24 22:09:23 momjian Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.562 2009/12/26 16:55:21 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -6542,12 +6542,6 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo)
65426542
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
65436543

65446544
num = PQntuples(res);
6545-
/* should be at least 1 value */
6546-
if (num == 0)
6547-
{
6548-
write_msg(NULL, "no label definitions found for enum ID %u\n", tyinfo->dobj.catId.oid);
6549-
exit_nicely();
6550-
}
65516545

65526546
/*
65536547
* DROP must be fully qualified in case same name appears in pg_catalog.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy