Re: Removing pg_migrator limitations - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Removing pg_migrator limitations
Date
Msg-id 200912250617.nBP6HZM13399@momjian.us
Whole thread Raw
In response to Re: Removing pg_migrator limitations  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Removing pg_migrator limitations  (Bruce Momjian <bruce@momjian.us>)
Re: Removing pg_migrator limitations  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Bruce Momjian wrote:
> > Well, we might eventually allow addition of values to enums too; the
> > fact that it's not implemented outside pg_migrator right now doesn't
> > mean we won't ever think of a solution.  In any case I'm not persuaded
> > that a zero-element enum is totally without value.  Think of it like a
> > domain with a "must be null" constraint.
>
> OK, but that is going to expand the my patch.  I will probably implement
> zero-element enums first and then go ahead and do the binary upgrade
> part.  Zero-element enums will simplify the pg_dump code.

I have implemented the zero-value option to CREATE TYPE ENUM with the
attached patch.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/ref/create_type.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v
retrieving revision 1.79
diff -c -c -r1.79 create_type.sgml
*** doc/src/sgml/ref/create_type.sgml    30 Nov 2008 19:01:29 -0000    1.79
--- doc/src/sgml/ref/create_type.sgml    25 Dec 2009 06:15:56 -0000
***************
*** 25,31 ****
      ( <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>' [, ... ] )

  CREATE TYPE <replaceable class="parameter">name</replaceable> (
      INPUT = <replaceable class="parameter">input_function</replaceable>,
--- 25,31 ----
      ( <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>' [, ... ] ] )

  CREATE TYPE <replaceable class="parameter">name</replaceable> (
      INPUT = <replaceable class="parameter">input_function</replaceable>,
Index: src/backend/parser/gram.y
===================================================================
RCS file: /cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.699
diff -c -c -r2.699 gram.y
*** src/backend/parser/gram.y    23 Dec 2009 17:41:43 -0000    2.699
--- src/backend/parser/gram.y    25 Dec 2009 06:15:56 -0000
***************
*** 297,303 ****
                  TableFuncElementList opt_type_modifiers
                  prep_type_clause
                  execute_param_clause using_clause returning_clause
!                 enum_val_list table_func_column_list
                  create_generic_options alter_generic_options
                  relation_expr_list dostmt_opt_list

--- 297,303 ----
                  TableFuncElementList opt_type_modifiers
                  prep_type_clause
                  execute_param_clause using_clause returning_clause
!                 opt_enum_val_list enum_val_list table_func_column_list
                  create_generic_options alter_generic_options
                  relation_expr_list dostmt_opt_list

***************
*** 3623,3629 ****
                      n->coldeflist = $6;
                      $$ = (Node *)n;
                  }
!             | CREATE TYPE_P any_name AS ENUM_P '(' enum_val_list ')'
                  {
                      CreateEnumStmt *n = makeNode(CreateEnumStmt);
                      n->typeName = $3;
--- 3623,3629 ----
                      n->coldeflist = $6;
                      $$ = (Node *)n;
                  }
!             | CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')'
                  {
                      CreateEnumStmt *n = makeNode(CreateEnumStmt);
                      n->typeName = $3;
***************
*** 3715,3720 ****
--- 3715,3725 ----
                  }
          ;

+ opt_enum_val_list:
+         enum_val_list                            { $$ = $1; }
+         | /*EMPTY*/                                { $$ = NIL; }
+         ;
+
  enum_val_list:    Sconst
                  { $$ = list_make1(makeString($1)); }
              | enum_val_list ',' Sconst

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: Streaming Rep - 2-phase backups and reducing time to full replication
Next
From: Pavel Stehule
Date:
Subject: Re: info about patch: using parametrised query in psql