Re: Removing pg_migrator limitations - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Removing pg_migrator limitations
Date
Msg-id 200912261655.nBQGtjo25362@momjian.us
Whole thread Raw
In response to Re: Removing pg_migrator limitations  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Bruce Momjian wrote:
> 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.

Applied, with pg_dump support too; updated patch attached.

--
  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    26 Dec 2009 16:50:35 -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    26 Dec 2009 16:50:35 -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
Index: src/bin/pg_dump/pg_dump.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v
retrieving revision 1.561
diff -c -c -r1.561 pg_dump.c
*** src/bin/pg_dump/pg_dump.c    24 Dec 2009 22:09:23 -0000    1.561
--- src/bin/pg_dump/pg_dump.c    26 Dec 2009 16:50:35 -0000
***************
*** 6542,6553 ****
      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.
--- 6542,6547 ----

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: parse_oper cache
Next
From: Andres Freund
Date:
Subject: Re: join ordering via Simulated Annealing