Rework the options syntax for logical replication commands
authorPeter Eisentraut
Fri, 12 May 2017 12:57:01 +0000 (08:57 -0400)
committerPeter Eisentraut
Fri, 12 May 2017 12:57:49 +0000 (08:57 -0400)
For CREATE/ALTER PUBLICATION/SUBSCRIPTION, use similar option style as
other statements that use a WITH clause for options.

Author: Petr Jelinek 

24 files changed:
doc/src/sgml/logical-replication.sgml
doc/src/sgml/ref/alter_publication.sgml
doc/src/sgml/ref/alter_subscription.sgml
doc/src/sgml/ref/create_publication.sgml
doc/src/sgml/ref/create_subscription.sgml
src/backend/commands/publicationcmds.c
src/backend/commands/subscriptioncmds.c
src/backend/parser/gram.y
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/t/002_pg_dump.pl
src/bin/psql/tab-complete.c
src/include/parser/kwlist.h
src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
src/test/regress/expected/object_address.out
src/test/regress/expected/publication.out
src/test/regress/expected/subscription.out
src/test/regress/sql/object_address.sql
src/test/regress/sql/publication.sql
src/test/regress/sql/subscription.sql
src/test/subscription/t/001_rep_changes.pl
src/test/subscription/t/002_types.pl
src/test/subscription/t/003_constraints.pl
src/test/subscription/t/004_sync.pl

index e87e3dcd36dfe300dbbda0df350ec82cb5815fe4..36c157c43f991418002134c6200c4cba485e7cbe 100644 (file)
      
       
        When creating a subscription, the replication slot already exists.  In
-       that case, the subscription can be created using the NOCREATE
-       SLOT option to associate with the existing slot.
+       that case, the subscription can be created using
+       the create_slot = false option to associate with the
+       existing slot.
       
      
 
       
        When creating a subscription, the remote host is not reachable or in an
        unclear state.  In that case, the subscription can be created using
-       the NOCONNECT option.  The remote host will then not
+       the connect = false option.  The remote host will then not
        be contacted at all.  This is what pg_dump
        uses.  The remote replication slot will then have to be created
        manually before the subscription can be activated.
index 05bd57d9cab77c5ec71bfb3f18ce2f180ab84ab6..7b8f114f54146c32eec285f3a10108f3b3780ff9 100644 (file)
@@ -21,17 +21,10 @@ PostgreSQL documentation
 
  
 
-ALTER PUBLICATION name WITH ( option [, ... ] )
-
-where option can be:
-
-      PUBLISH INSERT | NOPUBLISH INSERT
-    | PUBLISH UPDATE | NOPUBLISH UPDATE
-    | PUBLISH DELETE | NOPUBLISH DELETE
-
 ALTER PUBLICATION name ADD TABLE [ ONLY ] table_name [ * ] [, ...]
 ALTER PUBLICATION name SET TABLE [ ONLY ] table_name [ * ] [, ...]
 ALTER PUBLICATION name DROP TABLE [ ONLY ] table_name [ * ] [, ...]
+ALTER PUBLICATION name SET ( publication_parameter [= value] [, ... ] )
 ALTER PUBLICATION name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
 ALTER PUBLICATION name RENAME TO new_name
 
@@ -44,8 +37,7 @@ ALTER PUBLICATION name RENAME TO 
    The first variant of this command listed in the synopsis can change
    all of the publication properties specified in
    .  Properties not mentioned in the
-   command retain their previous settings.  Database superusers can change any
-   of these settings for any role.
+   command retain their previous settings.
   
 
   
@@ -80,29 +72,24 @@ ALTER PUBLICATION name RENAME TO 
    
 
    
-    PUBLISH INSERT
-    NOPUBLISH INSERT
-    PUBLISH UPDATE
-    NOPUBLISH UPDATE
-    PUBLISH DELETE
-    NOPUBLISH DELETE
+    table_name
     
      
-      These clauses alter properties originally set by
-      .  See there for more information.
+      Name of an existing table.  If ONLY is specified before the
+      table name, only that table is affected.  If ONLY is not
+      specified, the table and all its descendant tables (if any) are
+      affected.  Optionally, * can be specified after the table
+      name to explicitly indicate that descendant tables are included.
      
     
    
 
    
-    <replaceable class="parameter">table_name>
+    <literal>SET ( publication_parameter [= value] [, ... ] )>
     
      
-      Name of an existing table.  If ONLY is specified before the
-      table name, only that table is affected.  If ONLY is not
-      specified, the table and all its descendant tables (if any) are
-      affected.  Optionally, * can be specified after the table
-      name to explicitly indicate that descendant tables are included.
+      This clause alters publication parameters originally set by
+      .  See there for more information.
      
     
    
@@ -131,9 +118,9 @@ ALTER PUBLICATION name RENAME TO 
   Examples
 
   
-   Change the publication to not publish inserts:
+   Change the publication to publish only deletes and updates:
 
-ALTER PUBLICATION noinsert WITH (NOPUBLISH INSERT);
+ALTER PUBLICATION noinsert SET (publish = 'update, delete');
 
   
 
index 5dae4aebd635c23e5992c24498e9787563da5e3f..6320de06edd45d48ed6a290499aef851cc8d3428 100644 (file)
@@ -21,23 +21,12 @@ PostgreSQL documentation
 
  
 
-ALTER SUBSCRIPTION name WITH ( suboption [, ... ] )
-
-where suboption can be:
-
-    SLOT NAME = slot_name
-    | SYNCHRONOUS_COMMIT = synchronous_commit
-
-ALTER SUBSCRIPTION name SET PUBLICATION publication_name [, ...] { REFRESH WITH ( puboption [, ... ] ) | NOREFRESH }
-ALTER SUBSCRIPTION name REFRESH PUBLICATION [ WITH ( puboption [, ... ] ) ]
-
-where puboption can be:
-
-    COPY DATA | NOCOPY DATA
-
 ALTER SUBSCRIPTION name CONNECTION 'conninfo'
+ALTER SUBSCRIPTION name SET PUBLICATION publication_name [, ...] { REFRESH [ WITH ( refresh_option value [, ... ] ) ] | SKIP REFRESH }
+ALTER SUBSCRIPTION name REFRESH PUBLICATION [ WITH ( refresh_option value [, ... ] ) ]
 ALTER SUBSCRIPTION name ENABLE
 ALTER SUBSCRIPTION name DISABLE
+ALTER SUBSCRIPTION name SET ( subscription_parameter [= value] [, ... ] )
 ALTER SUBSCRIPTION name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
 ALTER SUBSCRIPTION name RENAME TO new_name
 
@@ -73,11 +62,9 @@ ALTER SUBSCRIPTION name RENAME TO <
 
    
     CONNECTION 'conninfo'
-    SLOT NAME = slot_name
-    SYNCHRONOUS_COMMIT = synchronous_commit
     
      
-      These clauses alter properties originally set by
+      This clause alters the connection property originally set by
       .  See there for more
       information.
      
@@ -91,11 +78,17 @@ ALTER SUBSCRIPTION name RENAME TO <
       Changes list of subscribed publications. See
        for more information.
      
+
      
-      When REFRESH is specified, this command will also
-      act like REFRESH PUBLICATION. When
-      NOREFRESH is specified, the comamnd will not try to
-      refresh table information.
+      When REFRESH is specified, this command will also act
+      like REFRESH
+      PUBLICATION.  refresh_option specifies
+      additional options for the refresh operation, as described
+      under REFRESH PUBLICATION.  When
+      SKIP REFRESH is specified, the command will not try
+      to refresh table information.  Note that
+      either REFRESH or SKIP REFRESH
+      must be specified.
      
     
    
@@ -104,16 +97,28 @@ ALTER SUBSCRIPTION name RENAME TO <
     REFRESH PUBLICATION
     
      
-      Fetch missing table information from publisher. This will start
+      Fetch missing table information from publisher.  This will start
       replication of tables that were added to the subscribed-to publications
       since the last invocation of REFRESH PUBLICATION or
       since CREATE SUBSCRIPTION.
      
+
      
-      The COPY DATA and NOCOPY DATA
-      options specify if the existing data in the publications that are being
-      subscribed to should be copied. COPY DATA is the
-      default.
+      refresh_option specifies additional options for the
+      refresh operation.  The supported options are:
+
+      
+       
+        copy_data (boolean)
+        
+         
+          Specifies whether the existing data in the publications that are
+          being subscribed to should be copied once the replication starts.
+          The default is true.
+         
+        
+       
+      
      
     
    
@@ -138,6 +143,18 @@ ALTER SUBSCRIPTION name RENAME TO <
     
    
 
+   
+    SET ( subscription_parameter [= value] [, ... ] )
+    
+     
+      This clause alters parameters originally set by
+      .  See there for more
+      information.  The allowed options are slot_name and
+      synchronous_commit
+     
+    
+   
+
    
     new_owner
     
@@ -165,7 +182,7 @@ ALTER SUBSCRIPTION name RENAME TO <
    Change the publication subscribed by a subscription to
    insert_only:
 
-ALTER SUBSCRIPTION mysub SET PUBLICATION insert_only;
+ALTER SUBSCRIPTION mysub SET PUBLICATION insert_only REFRESH;
 
   
 
index 521376ef4ba984a8074722db2f8a7c59edb2dab1..48be4763747db90436e5ca8915c76d5fbdbb89cc 100644 (file)
@@ -24,13 +24,8 @@ PostgreSQL documentation
 CREATE PUBLICATION name
     [ FOR TABLE [ ONLY ] table_name [ * ] [, ...]
       | FOR ALL TABLES ]
-    [ WITH ( option [, ... ] ) ]
+    [ WITH ( publication_parameter [= value] [, ... ] ) ]
 
-where option can be:
-
-      PUBLISH INSERT | NOPUBLISH INSERT
-    | PUBLISH UPDATE | NOPUBLISH UPDATE
-    | PUBLISH DELETE | NOPUBLISH DELETE
 
  
 
@@ -97,37 +92,29 @@ CREATE PUBLICATION name
    
 
    
-    PUBLISH INSERT
-    NOPUBLISH INSERT
-    
-     
-      These clauses determine whether the new publication will send
-      the INSERT operations to the subscribers.
-      PUBLISH INSERT is the default.
-     
-    
-   
-
-   
-    PUBLISH UPDATE
-    NOPUBLISH UPDATE
+    WITH ( publication_parameter [= value] [, ... ] )
     
      
-      These clauses determine whether the new publication will send
-      the UPDATE operations to the subscribers.
-      PUBLISH UPDATE is the default.
-     
-    
-   
+      This clause specifies optional parameters for a publication.  The
+      following parameters are supported:
+
+      
+       
+        publish (string)
+        
+         
+          This parameter determines which DML operations will be published by
+          the new publication to the subscribers.  The value is
+          comma-separated list of operations.  The allowed operations are
+          insertupdate, and
+          delete.  The default is to publish all actions,
+          and so the default value for this option is
+          'insert, update, delete'.
+         
+        
+       
+      
 
-   
-    PUBLISH DELETE
-    NOPUBLISH DELETE
-    
-     
-      These clauses determine whether the new publication will send
-      the DELETE operations to the subscribers.
-      PUBLISH DELETE is the default.
      
     
    
@@ -203,7 +190,7 @@ CREATE PUBLICATION alltables FOR ALL TABLES;
    operations in one table:
 
 CREATE PUBLICATION insert_only FOR TABLE mydata
-    WITH (NOPUBLISH UPDATE, NOPUBLISH DELETE);
+    WITH (publish = 'insert');
 
   
  
index 63824684031df6ecd3e49acd90155c50e9104dfc..f2da662499c0b73a453ee47179d8b9e88e6d4f09 100644 (file)
@@ -23,17 +23,8 @@ PostgreSQL documentation
 
 CREATE SUBSCRIPTION subscription_name
     CONNECTION 'conninfo'
-    PUBLICATION { publication_name [, ...] }
-    [ WITH ( option [, ... ] ) ]
-
-where option can be:
-
-    | ENABLED | DISABLED
-    | CREATE SLOT | NOCREATE SLOT
-    | SLOT NAME = slot_name
-    | COPY DATA | NOCOPY DATA
-    | SYNCHRONOUS_COMMIT = synchronous_commit
-    | NOCONNECT
+    PUBLICATION publication_name [, ...]
+    [ WITH ( subscription_parameter [= value] [, ... ] ) ]
 
  
 
@@ -59,7 +50,7 @@ CREATE SUBSCRIPTION subscription_name
 
   
    CREATE SUBSCRIPTION cannot be executed inside a
-   transaction block when CREATE SLOT is specified.
+   transaction block when the parameter create_slot is specified.
   
 
   
@@ -97,116 +88,129 @@ CREATE SUBSCRIPTION subscription_name
     PUBLICATION publication_name
     
      
-      Name(s) of the publications on the publisher to subscribe to.
-     
-    
-   
-
-   
-    ENABLED
-    DISABLED
-    
-     
-      Specifies whether the subscription should be actively replicating or
-      if it should be just setup but not started yet.  Note that the
-      replication slot as described above is created in either case.
-      ENABLED is the default.
-     
-    
-   
-
-   
-    CREATE SLOT
-    NOCREATE SLOT
-    
-     
-      Specifies whether the command should create the replication slot on the
-      publisher. CREATE SLOT is the default.
-     
-    
-   
-
-   
-    SLOT NAME = slot_name
-    
-     
-      Name of the replication slot to use. The default behavior is to use
-      subscription_name for slot name.
-     
-
-     
-      When SLOT NAME is set to
-      NONE, there will be no replication slot associated
-      with the subscription.  This can be used if the replication slot will be
-      created later manually.  Such subscriptions must also have both
-      ENABLED and CREATE SLOT set
-      to false.
-     
-    
-   
-
-   
-    COPY DATA
-    NOCOPY DATA
-    
-     
-      Specifies if the existing data in the publications that are being
-      subscribed to should be copied once the replication starts.
-      COPY DATA is the default.
+      Names of the publications on the publisher to subscribe to.
      
     
    
 
    
-    SYNCHRONOUS_COMMIT = synchronous_commit
+    WITH ( subscription_parameter [= value] [, ... ] )
     
      
-      The value of this parameter overrides the
-       setting.  The default value is
-      off.
-     
-
-     
-      It is safe to use off for logical replication: If the
-      subscriber loses transactions because of missing synchronization, the
-      data will be resent from the publisher.
-     
-
-     
-      A different setting might be appropriate when doing synchronous logical
-      replication.  The logical replication workers report the positions of
-      writes and flushes to the publisher, and when using synchronous
-      replication, the publisher will wait for the actual flush.  This means
-      that setting SYNCHRONOUS_COMMIT for the subscriber
-      to off when the subscription is used for synchronous
-      replication might increase the latency for COMMIT on
-      the publisher.  In this scenario, it can be advantageous to set
-      SYNCHRONOUS_COMMIT to local or
-      higher.
-     
-    
-   
-
-   
-    NOCONNECT
-    
-     
-      Instructs CREATE SUBSCRIPTION to skip the initial
-      connection to the provider. This will change default values of other
-      options to DISABLED,
-      NOCREATE SLOT, and NOCOPY DATA.
-     
-     
-      It's not allowed to combine NOCONNECT and
-      ENABLEDCREATE SLOT, or
-      COPY DATA.
-     
-     
-      Since no connection is made when this option is specified, the tables
-      are not subscribed, so after you enable the subscription nothing will
-      be replicated. It is required to run
-      ALTER SUBSCRIPTION ... REFRESH PUBLICATION in order for
-      tables to be subscribed.
+      This clause specifies optional parameters for a subscription.  The
+      following parameters are supported:
+
+      
+       
+        copy_data (boolean)
+        
+         
+          Specifies whether the existing data in the publications that are
+          being subscribed to should be copied once the replication starts.
+          The default is true.
+         
+        
+       
+
+       
+        create_slot (boolean)
+        
+         
+          Specifies whether the command should create the replication slot on
+          the publisher.  The default is true.
+         
+        
+       
+
+       
+        enabled (boolean)
+        
+         
+          Specifies whether the subscription should be actively replicating,
+          or whether it should be just setup but not started yet.  The default
+          is true.
+         
+        
+       
+
+       
+        slot_name (string)
+        
+         
+          Name of the replication slot to use.  The default behavior is to
+          use the name of the subscription for the slot name.
+         
+
+         
+          When slot_name is set to
+          NONE, there will be no replication slot
+          associated with the subscription.  This can be used if the
+          replication slot will be created later manually.  Such
+          subscriptions must also have both enabled and
+          create_slot set to false.
+         
+        
+       
+
+       
+        synchronous_commit (enum)
+        
+         
+          The value of this parameter overrides the
+           setting.  The default
+          value is off.
+         
+
+         
+          It is safe to use off for logical replication:
+          If the subscriber loses transactions because of missing
+          synchronization, the data will be resent from the publisher.
+         
+
+         
+          A different setting might be appropriate when doing synchronous
+          logical replication.  The logical replication workers report the
+          positions of writes and flushes to the publisher, and when using
+          synchronous replication, the publisher will wait for the actual
+          flush.  This means that setting
+          synchronous_commit for the subscriber to
+          off when the subscription is used for
+          synchronous replication might increase the latency for
+          COMMIT on the publisher.  In this scenario, it
+          can be advantageous to set synchronous_commit
+          to local or higher.
+         
+        
+       
+
+       
+        connect (boolean)
+        
+         
+          Specifies whether the CREATE SUBSCRIPTION
+          should connect to the publisher at all.  Setting this to
+          false will change default values of
+          enabledcreate_slot and
+          copy_data to false.
+         
+
+         
+          It is not allowed to combine connect set to
+          false and enabled,
+          create_slot, or copy_data
+          set to true.
+         
+
+         
+          Since no connection is made when this option is specified, the
+          tables are not subscribed, and so after you enable the subscription
+          nothing will be replicated.  It is required to run
+          ALTER SUBSCRIPTION ... REFRESH PUBLICATION in order
+          for tables to be subscribed.
+         
+        
+       
+      
      
     
    
@@ -246,7 +250,7 @@ CREATE SUBSCRIPTION mysub
 CREATE SUBSCRIPTION mysub
          CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb'
         PUBLICATION insert_only
-               WITH (DISABLED);
+               WITH (enabled = false);
 
   
  
index 541da7ee12cc8770ca7c2ac9b0892cfe57826de1..14c2f68d59f36661b5864570ba85407a8fe0d91b 100644 (file)
@@ -46,6 +46,7 @@
 #include "utils/lsyscache.h"
 #include "utils/rel.h"
 #include "utils/syscache.h"
+#include "utils/varlena.h"
 
 /* Same as MAXNUMMESSAGES in sinvaladt.c */
 #define MAX_RELCACHE_INVAL_MSGS 4096
@@ -58,18 +59,14 @@ static void PublicationDropTables(Oid pubid, List *rels, bool missing_ok);
 
 static void
 parse_publication_options(List *options,
-                         bool *publish_insert_given,
+                         bool *publish_given,
                          bool *publish_insert,
-                         bool *publish_update_given,
                          bool *publish_update,
-                         bool *publish_delete_given,
                          bool *publish_delete)
 {
    ListCell   *lc;
 
-   *publish_insert_given = false;
-   *publish_update_given = false;
-   *publish_delete_given = false;
+   *publish_given = false;
 
    /* Defaults are true */
    *publish_insert = true;
@@ -81,68 +78,54 @@ parse_publication_options(List *options,
    {
        DefElem    *defel = (DefElem *) lfirst(lc);
 
-       if (strcmp(defel->defname, "publish insert") == 0)
+       if (strcmp(defel->defname, "publish") == 0)
        {
-           if (*publish_insert_given)
-               ereport(ERROR,
-                       (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("conflicting or redundant options")));
+           char       *publish;
+           List       *publish_list;
+           ListCell   *lc;
 
-           *publish_insert_given = true;
-           *publish_insert = defGetBoolean(defel);
-       }
-       else if (strcmp(defel->defname, "nopublish insert") == 0)
-       {
-           if (*publish_insert_given)
+           if (*publish_given)
                ereport(ERROR,
                        (errcode(ERRCODE_SYNTAX_ERROR),
                         errmsg("conflicting or redundant options")));
 
-           *publish_insert_given = true;
-           *publish_insert = !defGetBoolean(defel);
-       }
-       else if (strcmp(defel->defname, "publish update") == 0)
-       {
-           if (*publish_update_given)
-               ereport(ERROR,
-                       (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("conflicting or redundant options")));
+           /*
+            * If publish option was given only the explicitly listed actions
+            * should be published.
+            */
+           *publish_insert = false;
+           *publish_update = false;
+           *publish_delete = false;
 
-           *publish_update_given = true;
-           *publish_update = defGetBoolean(defel);
-       }
-       else if (strcmp(defel->defname, "nopublish update") == 0)
-       {
-           if (*publish_update_given)
-               ereport(ERROR,
-                       (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("conflicting or redundant options")));
+           *publish_given = true;
+           publish = defGetString(defel);
 
-           *publish_update_given = true;
-           *publish_update = !defGetBoolean(defel);
-       }
-       else if (strcmp(defel->defname, "publish delete") == 0)
-       {
-           if (*publish_delete_given)
+           if (!SplitIdentifierString(publish, ',', &publish_list))
                ereport(ERROR,
                        (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("conflicting or redundant options")));
-
-           *publish_delete_given = true;
-           *publish_delete = defGetBoolean(defel);
-       }
-       else if (strcmp(defel->defname, "nopublish delete") == 0)
-       {
-           if (*publish_delete_given)
-               ereport(ERROR,
-                       (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("conflicting or redundant options")));
+                        errmsg("invalid publish list")));
 
-           *publish_delete_given = true;
-           *publish_delete = !defGetBoolean(defel);
+           /* Process the option list. */
+           foreach (lc, publish_list)
+           {
+               char *publish_opt = (char *)lfirst(lc);
+
+               if (strcmp(publish_opt, "insert") == 0)
+                   *publish_insert = true;
+               else if (strcmp(publish_opt, "update") == 0)
+                   *publish_update = true;
+               else if (strcmp(publish_opt, "delete") == 0)
+                   *publish_delete = true;
+               else
+                   ereport(ERROR,
+                           (errcode(ERRCODE_SYNTAX_ERROR),
+                            errmsg("unrecognized \"publish\" value: \"%s\"", publish_opt)));
+           }
        }
        else
-           elog(ERROR, "unrecognized option: %s", defel->defname);
+           ereport(ERROR,
+                   (errcode(ERRCODE_SYNTAX_ERROR),
+                    errmsg("unrecognized publication parameter: %s", defel->defname)));
    }
 }
 
@@ -158,9 +141,7 @@ CreatePublication(CreatePublicationStmt *stmt)
    bool        nulls[Natts_pg_publication];
    Datum       values[Natts_pg_publication];
    HeapTuple   tup;
-   bool        publish_insert_given;
-   bool        publish_update_given;
-   bool        publish_delete_given;
+   bool        publish_given;
    bool        publish_insert;
    bool        publish_update;
    bool        publish_delete;
@@ -199,9 +180,8 @@ CreatePublication(CreatePublicationStmt *stmt)
    values[Anum_pg_publication_pubowner - 1] = ObjectIdGetDatum(GetUserId());
 
    parse_publication_options(stmt->options,
-                             &publish_insert_given, &publish_insert,
-                             &publish_update_given, &publish_update,
-                             &publish_delete_given, &publish_delete);
+                             &publish_given, &publish_insert,
+                             &publish_update, &publish_delete);
 
    values[Anum_pg_publication_puballtables - 1] =
        BoolGetDatum(stmt->for_all_tables);
@@ -253,40 +233,30 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
    bool        nulls[Natts_pg_publication];
    bool        replaces[Natts_pg_publication];
    Datum       values[Natts_pg_publication];
-   bool        publish_insert_given;
-   bool        publish_update_given;
-   bool        publish_delete_given;
+   bool        publish_given;
    bool        publish_insert;
    bool        publish_update;
    bool        publish_delete;
    ObjectAddress       obj;
 
    parse_publication_options(stmt->options,
-                             &publish_insert_given, &publish_insert,
-                             &publish_update_given, &publish_update,
-                             &publish_delete_given, &publish_delete);
+                             &publish_given, &publish_insert,
+                             &publish_update, &publish_delete);
 
    /* Everything ok, form a new tuple. */
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
    memset(replaces, false, sizeof(replaces));
 
-   if (publish_insert_given)
+   if (publish_given)
    {
-       values[Anum_pg_publication_pubinsert - 1] =
-           BoolGetDatum(publish_insert);
+       values[Anum_pg_publication_pubinsert - 1] = BoolGetDatum(publish_insert);
        replaces[Anum_pg_publication_pubinsert - 1] = true;
-   }
-   if (publish_update_given)
-   {
-       values[Anum_pg_publication_pubupdate - 1] =
-           BoolGetDatum(publish_update);
+
+       values[Anum_pg_publication_pubupdate - 1] = BoolGetDatum(publish_update);
        replaces[Anum_pg_publication_pubupdate - 1] = true;
-   }
-   if (publish_delete_given)
-   {
-       values[Anum_pg_publication_pubdelete - 1] =
-           BoolGetDatum(publish_delete);
+
+       values[Anum_pg_publication_pubdelete - 1] = BoolGetDatum(publish_delete);
        replaces[Anum_pg_publication_pubdelete - 1] = true;
    }
 
index b76cdc553842658d2a5d2b54dd7258d9c3cc9efd..21ef15fa0fa70f1bff24ddb31380ab08eb47766e 100644 (file)
@@ -93,7 +93,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
    {
        DefElem    *defel = (DefElem *) lfirst(lc);
 
-       if (strcmp(defel->defname, "noconnect") == 0 && connect)
+       if (strcmp(defel->defname, "connect") == 0 && connect)
        {
            if (connect_given)
                ereport(ERROR,
@@ -101,7 +101,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
                         errmsg("conflicting or redundant options")));
 
            connect_given = true;
-           *connect = !defGetBoolean(defel);
+           *connect = defGetBoolean(defel);
        }
        else if (strcmp(defel->defname, "enabled") == 0 && enabled)
        {
@@ -113,17 +113,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
            *enabled_given = true;
            *enabled = defGetBoolean(defel);
        }
-       else if (strcmp(defel->defname, "disabled") == 0 && enabled)
-       {
-           if (*enabled_given)
-               ereport(ERROR,
-                       (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("conflicting or redundant options")));
-
-           *enabled_given = true;
-           *enabled = !defGetBoolean(defel);
-       }
-       else if (strcmp(defel->defname, "create slot") == 0 && create_slot)
+       else if (strcmp(defel->defname, "create_slot") == 0 && create_slot)
        {
            if (create_slot_given)
                ereport(ERROR,
@@ -133,17 +123,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
            create_slot_given = true;
            *create_slot = defGetBoolean(defel);
        }
-       else if (strcmp(defel->defname, "nocreate slot") == 0 && create_slot)
-       {
-           if (create_slot_given)
-               ereport(ERROR,
-                       (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("conflicting or redundant options")));
-
-           create_slot_given = true;
-           *create_slot = !defGetBoolean(defel);
-       }
-       else if (strcmp(defel->defname, "slot name") == 0 && slot_name)
+       else if (strcmp(defel->defname, "slot_name") == 0 && slot_name)
        {
            if (*slot_name_given)
                ereport(ERROR,
@@ -157,7 +137,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
            if (strcmp(*slot_name, "none") == 0)
                *slot_name = NULL;
        }
-       else if (strcmp(defel->defname, "copy data") == 0 && copy_data)
+       else if (strcmp(defel->defname, "copy_data") == 0 && copy_data)
        {
            if (copy_data_given)
                ereport(ERROR,
@@ -167,16 +147,6 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
            copy_data_given = true;
            *copy_data = defGetBoolean(defel);
        }
-       else if (strcmp(defel->defname, "nocopy data") == 0 && copy_data)
-       {
-           if (copy_data_given)
-               ereport(ERROR,
-                       (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("conflicting or redundant options")));
-
-           copy_data_given = true;
-           *copy_data = !defGetBoolean(defel);
-       }
        else if (strcmp(defel->defname, "synchronous_commit") == 0 &&
                 synchronous_commit)
        {
@@ -336,7 +306,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
     * replication slot.
     */
    if (create_slot)
-       PreventTransactionChain(isTopLevel, "CREATE SUBSCRIPTION ... CREATE SLOT");
+       PreventTransactionChain(isTopLevel, "CREATE SUBSCRIPTION ... WITH (create_slot = true)");
 
    if (!superuser())
        ereport(ERROR,
index 65c004c509614b150da271511cdd91a8165047ed..d04bb7ea3eba098b602624ab84307f78c6a2dac6 100644 (file)
@@ -338,7 +338,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
                database_name access_method_clause access_method attr_name
                name cursor_name file_name
                index_name opt_index_name cluster_index_specification
-               def_key
 
 %type    func_name handler_name qual_Op qual_all_Op subquery_Op
                opt_class opt_inline_handler opt_validator validator_clause
@@ -652,7 +651,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
    MAPPING MATCH MATERIALIZED MAXVALUE METHOD MINUTE_P MINVALUE MODE MONTH_P MOVE
 
    NAME_P NAMES NATIONAL NATURAL NCHAR NEW NEXT NO NONE
-   NOREFRESH NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
+   NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
    NULLS_P NUMERIC
 
    OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OPTIONS OR
@@ -5673,21 +5672,16 @@ def_list:   def_elem                                { $$ = list_make1($1); }
            | def_list ',' def_elem                 { $$ = lappend($1, $3); }
        ;
 
-def_elem:  def_key '=' def_arg
+def_elem:  ColLabel '=' def_arg
                {
                    $$ = makeDefElem($1, (Node *) $3, @1);
                }
-           | def_key
+           | ColLabel
                {
                    $$ = makeDefElem($1, NULL, @1);
                }
        ;
 
-def_key:
-           ColLabel                        { $$ = $1; }
-           | ColLabel ColLabel             { $$ = psprintf("%s %s", $1, $2); }
-       ;
-
 /* Note: any simple identifier will be returned as a type name! */
 def_arg:   func_type                       { $$ = (Node *)$1; }
            | reserved_keyword              { $$ = (Node *)makeString(pstrdup($1)); }
@@ -9173,9 +9167,10 @@ publication_for_tables:
                }
        ;
 
+
 /*****************************************************************************
  *
- * ALTER PUBLICATION name [ WITH ] options
+ * ALTER PUBLICATION name SET ( options )
  *
  * ALTER PUBLICATION name ADD TABLE table [, table2]
  *
@@ -9186,7 +9181,7 @@ publication_for_tables:
  *****************************************************************************/
 
 AlterPublicationStmt:
-           ALTER PUBLICATION name WITH definition
+           ALTER PUBLICATION name SET definition
                {
                    AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
                    n->pubname = $3;
@@ -9254,12 +9249,12 @@ publication_name_item:
 
 /*****************************************************************************
  *
- * ALTER SUBSCRIPTION name [ WITH ] options
+ * ALTER SUBSCRIPTION name ...
  *
  *****************************************************************************/
 
 AlterSubscriptionStmt:
-           ALTER SUBSCRIPTION name WITH definition
+           ALTER SUBSCRIPTION name SET definition
                {
                    AlterSubscriptionStmt *n =
                        makeNode(AlterSubscriptionStmt);
@@ -9296,7 +9291,7 @@ AlterSubscriptionStmt:
                    n->options = $8;
                    $$ = (Node *)n;
                }
-           | ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list NOREFRESH
+           | ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list SKIP REFRESH
                {
                    AlterSubscriptionStmt *n =
                        makeNode(AlterSubscriptionStmt);
@@ -14758,7 +14753,6 @@ unreserved_keyword:
            | NEW
            | NEXT
            | NO
-           | NOREFRESH
            | NOTHING
            | NOTIFY
            | NOWAIT
index d724b1193540cb8c310d808e4eb02e83014c873d..05e1d4e9a915b079fa84bc2be76664589dc5edaa 100644 (file)
@@ -3460,6 +3460,7 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
    PQExpBuffer delq;
    PQExpBuffer query;
    PQExpBuffer labelq;
+   bool        first = true;
 
    if (!(pubinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
        return;
@@ -3479,23 +3480,32 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
    if (pubinfo->puballtables)
        appendPQExpBufferStr(query, " FOR ALL TABLES");
 
-   appendPQExpBufferStr(query, " WITH (");
+   appendPQExpBufferStr(query, " WITH (publish = '");
    if (pubinfo->pubinsert)
-       appendPQExpBufferStr(query, "PUBLISH INSERT");
-   else
-       appendPQExpBufferStr(query, "NOPUBLISH INSERT");
+   {
+       appendPQExpBufferStr(query, "insert");
+       first = false;
+   }
+
+   if (!first)
+       appendPQExpBufferStr(query, ", ");
 
    if (pubinfo->pubupdate)
-       appendPQExpBufferStr(query, ", PUBLISH UPDATE");
-   else
-       appendPQExpBufferStr(query, ", NOPUBLISH UPDATE");
+   {
+       appendPQExpBufferStr(query, "update");
+       first = false;
+   }
+
+   if (!first)
+       appendPQExpBufferStr(query, ", ");
 
    if (pubinfo->pubdelete)
-       appendPQExpBufferStr(query, ", PUBLISH DELETE");
-   else
-       appendPQExpBufferStr(query, ", NOPUBLISH DELETE");
+   {
+       appendPQExpBufferStr(query, "delete");
+       first = false;
+   }
 
-   appendPQExpBufferStr(query, ");\n");
+   appendPQExpBufferStr(query, "');\n");
 
    ArchiveEntry(fout, pubinfo->dobj.catId, pubinfo->dobj.dumpId,
                 pubinfo->dobj.name,
@@ -3817,11 +3827,11 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
        appendPQExpBufferStr(publications, fmtId(pubnames[i]));
    }
 
-   appendPQExpBuffer(query, " PUBLICATION %s WITH (NOCONNECT, SLOT NAME = ", publications->data);
+   appendPQExpBuffer(query, " PUBLICATION %s WITH (connect = false, slot_name = ", publications->data);
    appendStringLiteralAH(query, subinfo->subslotname, fout);
 
    if (strcmp(subinfo->subsynccommit, "off") != 0)
-       appendPQExpBuffer(query, ", SYNCHRONOUS_COMMIT = %s", fmtId(subinfo->subsynccommit));
+       appendPQExpBuffer(query, ", synchronous_commit = %s", fmtId(subinfo->subsynccommit));
 
    appendPQExpBufferStr(query, ");\n");
 
index ce0c9ef54d7e0cc954da875a7e97f73ad8af4f89..b62299929f478c383029c15c0df3a7cb4f22b3ed 100644 (file)
@@ -4351,7 +4351,7 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
        create_order => 50,
        create_sql   => 'CREATE PUBLICATION pub1;',
        regexp       => qr/^
-           \QCREATE PUBLICATION pub1 WITH (PUBLISH INSERT, PUBLISH UPDATE, PUBLISH DELETE);\E
+           \QCREATE PUBLICATION pub1 WITH (publish = 'insert, update, delete');\E
            /xm,
        like => {
            binary_upgrade           => 1,
@@ -4384,11 +4384,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
        create_order => 50,
        create_sql   => 'CREATE PUBLICATION pub2
                         FOR ALL TABLES
-                        WITH (NOPUBLISH INSERT,
-                              NOPUBLISH UPDATE,
-                              NOPUBLISH DELETE);',
+                        WITH (publish = \'\');',
        regexp       => qr/^
-           \QCREATE PUBLICATION pub2 FOR ALL TABLES WITH (NOPUBLISH INSERT, NOPUBLISH UPDATE, NOPUBLISH DELETE);\E
+           \QCREATE PUBLICATION pub2 FOR ALL TABLES WITH (publish = '');\E
            /xm,
        like => {
            binary_upgrade           => 1,
@@ -4421,9 +4419,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
        create_order => 50,
        create_sql   => 'CREATE SUBSCRIPTION sub1
                         CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1
-                        WITH (NOCONNECT);',
+                        WITH (connect = false);',
        regexp       => qr/^
-           \QCREATE SUBSCRIPTION sub1 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (NOCONNECT, SLOT NAME = 'sub1');\E
+           \QCREATE SUBSCRIPTION sub1 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub1');\E
            /xm,
        like => {
            binary_upgrade           => 1,
index 3bd527700ea07a2a17a0a433ecec51a123d4b03f..92abcc3ac3822183dfcad63c7f7b542392170694 100644 (file)
@@ -1504,28 +1504,27 @@ psql_completion(const char *text, int start, int end)
        COMPLETE_WITH_LIST6("WITH (", "ADD TABLE", "SET TABLE", "DROP TABLE",
                            "OWNER TO", "RENAME TO");
    }
-   /* ALTER PUBLICATION  .. WITH ( ... */
-   else if (HeadMatches3("ALTER", "PUBLICATION",MatchAny) && TailMatches2("WITH", "("))
+   /* ALTER PUBLICATION  .. SET ( ... */
+   else if (HeadMatches3("ALTER", "PUBLICATION",MatchAny) && TailMatches2("SET", "("))
    {
-       COMPLETE_WITH_LIST6("PUBLISH INSERT", "NOPUBLISH INSERT", "PUBLISH UPDATE",
-                           "NOPUBLISH UPDATE", "PUBLISH DELETE", "NOPUBLISH DELETE");
+       COMPLETE_WITH_CONST("publish");
    }
    /* ALTER SUBSCRIPTION  ... */
    else if (Matches3("ALTER","SUBSCRIPTION",MatchAny))
    {
-       COMPLETE_WITH_LIST8("WITH (", "CONNECTION", "SET PUBLICATION", "ENABLE",
+       COMPLETE_WITH_LIST8("SET (", "CONNECTION", "SET PUBLICATION", "ENABLE",
                            "DISABLE", "OWNER TO", "RENAME TO", "REFRESH PUBLICATION WITH (");
    }
    /* ALTER SUBSCRIPTION  REFRESH PUBLICATION WITH ( ... */
    else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) &&
             TailMatches4("REFRESH", "PUBLICATION", "WITH", "("))
    {
-       COMPLETE_WITH_LIST2("COPY DATA", "NOCOPY DATA");
+       COMPLETE_WITH_CONST("copy_data");
    }
-   /* ALTER SUBSCRIPTION  .. WITH ( ... */
-   else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches2("WITH", "("))
+   /* ALTER SUBSCRIPTION  .. SET ( ... */
+   else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches2("SET", "("))
    {
-       COMPLETE_WITH_CONST("SLOT NAME");
+       COMPLETE_WITH_CONST("slot_name");
    }
    /* ALTER SCHEMA  */
    else if (Matches3("ALTER", "SCHEMA", MatchAny))
@@ -2349,9 +2348,7 @@ psql_completion(const char *text, int start, int end)
        COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
    /* Complete "CREATE PUBLICATION  [...] WITH" */
    else if (HeadMatches2("CREATE", "PUBLICATION") && TailMatches2("WITH", "("))
-       COMPLETE_WITH_LIST2("PUBLISH", "NOPUBLISH");
-   else if (HeadMatches2("CREATE", "PUBLICATION") && TailMatches3("WITH", "(", MatchAny))
-       COMPLETE_WITH_LIST3("INSERT", "UPDATE", "DELETE");
+       COMPLETE_WITH_CONST("publish");
 
 /* CREATE RULE */
    /* Complete "CREATE RULE " with "AS ON" */
@@ -2427,9 +2424,8 @@ psql_completion(const char *text, int start, int end)
        COMPLETE_WITH_CONST("WITH (");
    /* Complete "CREATE SUBSCRIPTION  ...  WITH ( " */
    else if (HeadMatches2("CREATE", "SUBSCRIPTION") && TailMatches2("WITH", "("))
-       COMPLETE_WITH_LIST8("ENABLED", "DISABLED", "CREATE SLOT",
-                           "NOCREATE SLOT", "SLOT NAME", "COPY DATA", "NOCOPY DATA",
-                           "NOCONNECT");
+       COMPLETE_WITH_LIST5("enabled", "create_slot", "slot_name",
+                           "copy_data", "connect");
 
 /* CREATE TRIGGER --- is allowed inside CREATE SCHEMA, so use TailMatches */
    /* complete CREATE TRIGGER  with BEFORE,AFTER,INSTEAD OF */
index 1ef03cfe525fc819a27f4707b8642b56e632a117..f50e45e886da8d3a120eecfb6dc3739b0a6bed1e 100644 (file)
@@ -259,7 +259,6 @@ PG_KEYWORD("new", NEW, UNRESERVED_KEYWORD)
 PG_KEYWORD("next", NEXT, UNRESERVED_KEYWORD)
 PG_KEYWORD("no", NO, UNRESERVED_KEYWORD)
 PG_KEYWORD("none", NONE, COL_NAME_KEYWORD)
-PG_KEYWORD("norefresh", NOREFRESH, UNRESERVED_KEYWORD)
 PG_KEYWORD("not", NOT, RESERVED_KEYWORD)
 PG_KEYWORD("nothing", NOTHING, UNRESERVED_KEYWORD)
 PG_KEYWORD("notify", NOTIFY, UNRESERVED_KEYWORD)
index 5f3768137c29a6ba4a82b04cdfb8dd06668197dd..77bdc9345d1f493baa6ce494e205ef2429a88de6 100644 (file)
@@ -69,7 +69,7 @@ CREATE SCHEMA dummy_seclabel_test;
 SECURITY LABEL ON SCHEMA dummy_seclabel_test IS 'unclassified';        -- OK
 SET client_min_messages = error;
 CREATE PUBLICATION dummy_pub;
-CREATE SUBSCRIPTION dummy_sub CONNECTION '' PUBLICATION foo WITH (NOCONNECT, SLOT NAME = NONE);
+CREATE SUBSCRIPTION dummy_sub CONNECTION '' PUBLICATION foo WITH (connect = false, slot_name = NONE);
 RESET client_min_messages;
 SECURITY LABEL ON PUBLICATION dummy_pub IS 'classified';
 SECURITY LABEL ON SUBSCRIPTION dummy_sub IS 'classified';
index 97311c79711a951e7c779e000bb740fd6781fb5e..8c347b6a68b9b8bf5506ae1cb3e2703b9ae9c33d 100644 (file)
@@ -73,7 +73,7 @@ SECURITY LABEL ON SCHEMA dummy_seclabel_test IS 'unclassified';       -- OK
 
 SET client_min_messages = error;
 CREATE PUBLICATION dummy_pub;
-CREATE SUBSCRIPTION dummy_sub CONNECTION '' PUBLICATION foo WITH (NOCONNECT, SLOT NAME = NONE);
+CREATE SUBSCRIPTION dummy_sub CONNECTION '' PUBLICATION foo WITH (connect = false, slot_name = NONE);
 RESET client_min_messages;
 SECURITY LABEL ON PUBLICATION dummy_pub IS 'classified';
 SECURITY LABEL ON SUBSCRIPTION dummy_sub IS 'classified';
index 40eeeed3d2502eb5fa674a24ce9da3b53232c55d..700f26182716abdcc46b9db29104ae26e21faaed 100644 (file)
@@ -37,7 +37,7 @@ CREATE TRANSFORM FOR int LANGUAGE SQL (
    FROM SQL WITH FUNCTION varchar_transform(internal),
    TO SQL WITH FUNCTION int4recv(internal));
 CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable;
-CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (NOCONNECT, SLOT NAME = NONE);
+CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (connect = false, slot_name = NONE);
 WARNING:  tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables
 CREATE STATISTICS addr_nsp.gentable_stat ON (a,b) FROM addr_nsp.gentable;
 -- test some error cases
index f3a348d368ce4aca84324f2072461aa50ab6aafd..e81919fd8cbf55c0fc35e69aadf9046ce9291e98 100644 (file)
@@ -13,8 +13,13 @@ SELECT obj_description(p.oid, 'pg_publication') FROM pg_publication p;
  test publication
 (1 row)
 
-CREATE PUBLICATION testpib_ins_trunct WITH (nopublish delete, nopublish update);
-ALTER PUBLICATION testpub_default WITH (nopublish insert, nopublish delete);
+CREATE PUBLICATION testpib_ins_trunct WITH (publish = insert);
+ALTER PUBLICATION testpub_default SET (publish = update);
+-- error cases
+CREATE PUBLICATION testpub_xxx WITH (foo);
+ERROR:  unrecognized publication parameter: foo
+CREATE PUBLICATION testpub_xxx WITH (publish = 'cluster, vacuum');
+ERROR:  unrecognized "publish" value: "cluster"
 \dRp
                             List of publications
         Name        |          Owner           | Inserts | Updates | Deletes 
@@ -23,7 +28,7 @@ ALTER PUBLICATION testpub_default WITH (nopublish insert, nopublish delete);
  testpub_default    | regress_publication_user | f       | t       | f
 (2 rows)
 
-ALTER PUBLICATION testpub_default WITH (publish insert, publish delete);
+ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete');
 \dRp
                             List of publications
         Name        |          Owner           | Inserts | Updates | Deletes 
@@ -38,8 +43,8 @@ CREATE TABLE testpub_tbl1 (id serial primary key, data text);
 CREATE TABLE pub_test.testpub_nopk (foo int, bar int);
 CREATE VIEW testpub_view AS SELECT 1;
 CREATE TABLE testpub_parted (a int) PARTITION BY LIST (a);
-CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (nopublish delete, nopublish update);
-ALTER PUBLICATION testpub_foralltables WITH (publish update);
+CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (publish = 'insert');
+ALTER PUBLICATION testpub_foralltables SET (publish = 'insert, update');
 CREATE TABLE testpub_tbl2 (id serial primary key, data text);
 -- fail - can't add to for all tables publication
 ALTER PUBLICATION testpub_foralltables ADD TABLE testpub_tbl2;
index 56f826ba5c0fc9e21c6d054bd433b09a1ff62f3b..10c3644e51db85c526a9d9452e4949b5bd12d396 100644 (file)
@@ -17,18 +17,18 @@ LINE 1: CREATE SUBSCRIPTION testsub PUBLICATION foo;
                                     ^
 -- fail - cannot do CREATE SUBSCRIPTION CREATE SLOT inside transaction block
 BEGIN;
-CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub WITH (CREATE SLOT);
-ERROR:  CREATE SUBSCRIPTION ... CREATE SLOT cannot run inside a transaction block
+CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub WITH (create_slot);
+ERROR:  CREATE SUBSCRIPTION ... WITH (create_slot = true) cannot run inside a transaction block
 COMMIT;
 -- fail - invalid connection string
 CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub;
 ERROR:  invalid connection string syntax: missing "=" after "testconn" in connection info string
 
 -- fail - duplicate publications
-CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION foo, testpub, foo WITH (NOCONNECT);
+CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION foo, testpub, foo WITH (connect = false);
 ERROR:  publication name "foo" used more than once
 -- ok
-CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (NOCONNECT);
+CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false);
 WARNING:  tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables
 COMMENT ON SUBSCRIPTION testsub IS 'test subscription';
 SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
@@ -38,11 +38,11 @@ SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
 (1 row)
 
 -- fail - name already exists
-CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (NOCONNECT);
+CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false);
 ERROR:  subscription "testsub" already exists
 -- fail - must be superuser
 SET SESSION AUTHORIZATION 'regress_subscription_user2';
-CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
+CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (connect = false);
 ERROR:  must be superuser to create subscriptions
 SET SESSION AUTHORIZATION 'regress_subscription_user';
 -- fail - invalid connection string
@@ -56,9 +56,9 @@ ERROR:  invalid connection string syntax: missing "=" after "foobar" in connecti
  testsub | regress_subscription_user | f       | {testpub}   | off                | dbname=doesnotexist
 (1 row)
 
-ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 NOREFRESH;
+ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 SKIP REFRESH;
 ALTER SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist2';
-ALTER SUBSCRIPTION testsub WITH (SLOT NAME = 'newname');
+ALTER SUBSCRIPTION testsub SET (slot_name = 'newname');
 -- fail
 ALTER SUBSCRIPTION doesnotexist CONNECTION 'dbname=doesnotexist2';
 ERROR:  subscription "doesnotexist" does not exist
@@ -93,8 +93,8 @@ ALTER SUBSCRIPTION testsub RENAME TO testsub_dummy;
 ERROR:  must be owner of subscription testsub
 RESET ROLE;
 ALTER SUBSCRIPTION testsub RENAME TO testsub_foo;
-ALTER SUBSCRIPTION testsub_foo WITH (SYNCHRONOUS_COMMIT = local);
-ALTER SUBSCRIPTION testsub_foo WITH (SYNCHRONOUS_COMMIT = foobar);
+ALTER SUBSCRIPTION testsub_foo SET (synchronous_commit = local);
+ALTER SUBSCRIPTION testsub_foo SET (synchronous_commit = foobar);
 ERROR:  invalid value for parameter "synchronous_commit": "foobar"
 HINT:  Available values: local, remote_write, remote_apply, on, off.
 \dRs+
@@ -118,7 +118,7 @@ BEGIN;
 DROP SUBSCRIPTION testsub;
 ERROR:  DROP SUBSCRIPTION cannot run inside a transaction block
 COMMIT;
-ALTER SUBSCRIPTION testsub WITH (SLOT NAME = NONE);
+ALTER SUBSCRIPTION testsub SET (slot_name = NONE);
 -- now it works
 BEGIN;
 DROP SUBSCRIPTION testsub;
index 6940392c018d1b8882357905935316c953b1d874..8a738e20d68ba3f8766c612047cc7596014f266c 100644 (file)
@@ -40,7 +40,7 @@ CREATE TRANSFORM FOR int LANGUAGE SQL (
    FROM SQL WITH FUNCTION varchar_transform(internal),
    TO SQL WITH FUNCTION int4recv(internal));
 CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable;
-CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (NOCONNECT, SLOT NAME = NONE);
+CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (connect = false, slot_name = NONE);
 CREATE STATISTICS addr_nsp.gentable_stat ON (a,b) FROM addr_nsp.gentable;
 
 -- test some error cases
index 7d1cba5db3eeaac4d452bbe49ed33a718801c0f3..cc1f33e72cd2aba1fac8a0f53f0d2cf097cf53d1 100644 (file)
@@ -11,13 +11,17 @@ CREATE PUBLICATION testpub_default;
 COMMENT ON PUBLICATION testpub_default IS 'test publication';
 SELECT obj_description(p.oid, 'pg_publication') FROM pg_publication p;
 
-CREATE PUBLICATION testpib_ins_trunct WITH (nopublish delete, nopublish update);
+CREATE PUBLICATION testpib_ins_trunct WITH (publish = insert);
 
-ALTER PUBLICATION testpub_default WITH (nopublish insert, nopublish delete);
+ALTER PUBLICATION testpub_default SET (publish = update);
+
+-- error cases
+CREATE PUBLICATION testpub_xxx WITH (foo);
+CREATE PUBLICATION testpub_xxx WITH (publish = 'cluster, vacuum');
 
 \dRp
 
-ALTER PUBLICATION testpub_default WITH (publish insert, publish delete);
+ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete');
 
 \dRp
 
@@ -28,8 +32,8 @@ CREATE TABLE pub_test.testpub_nopk (foo int, bar int);
 CREATE VIEW testpub_view AS SELECT 1;
 CREATE TABLE testpub_parted (a int) PARTITION BY LIST (a);
 
-CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (nopublish delete, nopublish update);
-ALTER PUBLICATION testpub_foralltables WITH (publish update);
+CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (publish = 'insert');
+ALTER PUBLICATION testpub_foralltables SET (publish = 'insert, update');
 
 CREATE TABLE testpub_tbl2 (id serial primary key, data text);
 -- fail - can't add to for all tables publication
index b9204460a44917e76ee2914d0fe00813ace69225..798bb0dbd31fa2b0cdc882836c63afee20b76d37 100644 (file)
@@ -15,27 +15,27 @@ CREATE SUBSCRIPTION testsub PUBLICATION foo;
 
 -- fail - cannot do CREATE SUBSCRIPTION CREATE SLOT inside transaction block
 BEGIN;
-CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub WITH (CREATE SLOT);
+CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub WITH (create_slot);
 COMMIT;
 
 -- fail - invalid connection string
 CREATE SUBSCRIPTION testsub CONNECTION 'testconn' PUBLICATION testpub;
 
 -- fail - duplicate publications
-CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION foo, testpub, foo WITH (NOCONNECT);
+CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION foo, testpub, foo WITH (connect = false);
 
 -- ok
-CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (NOCONNECT);
+CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false);
 
 COMMENT ON SUBSCRIPTION testsub IS 'test subscription';
 SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
 
 -- fail - name already exists
-CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (NOCONNECT);
+CREATE SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist' PUBLICATION testpub WITH (connect = false);
 
 -- fail - must be superuser
 SET SESSION AUTHORIZATION 'regress_subscription_user2';
-CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (NOCONNECT);
+CREATE SUBSCRIPTION testsub2 CONNECTION 'dbname=doesnotexist' PUBLICATION foo WITH (connect = false);
 SET SESSION AUTHORIZATION 'regress_subscription_user';
 
 -- fail - invalid connection string
@@ -43,9 +43,9 @@ ALTER SUBSCRIPTION testsub CONNECTION 'foobar';
 
 \dRs+
 
-ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 NOREFRESH;
+ALTER SUBSCRIPTION testsub SET PUBLICATION testpub2, testpub3 SKIP REFRESH;
 ALTER SUBSCRIPTION testsub CONNECTION 'dbname=doesnotexist2';
-ALTER SUBSCRIPTION testsub WITH (SLOT NAME = 'newname');
+ALTER SUBSCRIPTION testsub SET (slot_name = 'newname');
 
 -- fail
 ALTER SUBSCRIPTION doesnotexist CONNECTION 'dbname=doesnotexist2';
@@ -69,8 +69,8 @@ ALTER SUBSCRIPTION testsub RENAME TO testsub_dummy;
 RESET ROLE;
 
 ALTER SUBSCRIPTION testsub RENAME TO testsub_foo;
-ALTER SUBSCRIPTION testsub_foo WITH (SYNCHRONOUS_COMMIT = local);
-ALTER SUBSCRIPTION testsub_foo WITH (SYNCHRONOUS_COMMIT = foobar);
+ALTER SUBSCRIPTION testsub_foo SET (synchronous_commit = local);
+ALTER SUBSCRIPTION testsub_foo SET (synchronous_commit = foobar);
 
 \dRs+
 
@@ -88,7 +88,7 @@ BEGIN;
 DROP SUBSCRIPTION testsub;
 COMMIT;
 
-ALTER SUBSCRIPTION testsub WITH (SLOT NAME = NONE);
+ALTER SUBSCRIPTION testsub SET (slot_name = NONE);
 
 -- now it works
 BEGIN;
index ea99f84534c1baea4c5febbf20f9834eac7c3e3b..1545a5c54aacb4e2233ce74e561c3e5fc2413fdf 100644 (file)
@@ -40,7 +40,7 @@ my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
 $node_publisher->safe_psql('postgres',
    "CREATE PUBLICATION tap_pub");
 $node_publisher->safe_psql('postgres',
-   "CREATE PUBLICATION tap_pub_ins_only WITH (nopublish delete, nopublish update)");
+   "CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)");
 $node_publisher->safe_psql('postgres',
    "ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full");
 $node_publisher->safe_psql('postgres',
@@ -136,7 +136,7 @@ $node_publisher->poll_query_until('postgres',
 $oldpid = $node_publisher->safe_psql('postgres',
    "SELECT pid FROM pg_stat_replication WHERE application_name = '$appname';");
 $node_subscriber->safe_psql('postgres',
-   "ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only REFRESH WITH (NOCOPY DATA)");
+   "ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only REFRESH WITH (copy_data = false)");
 $node_publisher->poll_query_until('postgres',
    "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = '$appname';")
   or die "Timed out while waiting for apply to restart";
@@ -159,13 +159,13 @@ is($result, qq(20|-20|-1), 'check changes skipped after subscription publication
 
 # check alter publication (relcache invalidation etc)
 $node_publisher->safe_psql('postgres',
-   "ALTER PUBLICATION tap_pub_ins_only WITH (publish delete)");
+   "ALTER PUBLICATION tap_pub_ins_only SET (publish = 'insert, delete')");
 $node_publisher->safe_psql('postgres',
    "ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_full");
 $node_publisher->safe_psql('postgres',
    "DELETE FROM tab_ins WHERE a > 0");
 $node_subscriber->safe_psql('postgres',
-   "ALTER SUBSCRIPTION tap_sub REFRESH PUBLICATION WITH (NOCOPY DATA)");
+   "ALTER SUBSCRIPTION tap_sub REFRESH PUBLICATION WITH (copy_data = false)");
 $node_publisher->safe_psql('postgres',
    "INSERT INTO tab_full VALUES(0)");
 
index 16e8b4788552d591767944625526a3e1cd460ed7..a9fa4af9205a5a3df8938d6ef39565d185c83bb9 100644 (file)
@@ -103,7 +103,7 @@ $node_publisher->safe_psql('postgres',
 
 my $appname = 'tap_sub';
 $node_subscriber->safe_psql('postgres',
-   "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (SLOT NAME = tap_sub_slot)");
+   "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (slot_name = tap_sub_slot)");
 
 # Wait for subscriber to finish initialization
 my $caughtup_query =
index 074fdb1a30cf37f88d2690dcd94e970f4bf0eb2c..b8282af217148ff7bf26407ffdd49491a9b4b9b1 100644 (file)
@@ -34,7 +34,7 @@ $node_publisher->safe_psql('postgres',
 
 my $appname = 'tap_sub';
 $node_subscriber->safe_psql('postgres',
-   "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (NOCOPY DATA)");
+   "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (copy_data = false)");
 
 # Wait for subscriber to finish initialization
 my $caughtup_query =
index ceeb7a3b5d082e755ad5e0c752ea702319e6bcea..fbc49e3a2ae54a51acb50c95b3dbc95a60593cdc 100644 (file)
@@ -82,7 +82,7 @@ is($result, qq(20), 'initial data synced for second sub');
 
 # now check another subscription for the same node pair
 $node_subscriber->safe_psql('postgres',
-   "CREATE SUBSCRIPTION tap_sub2 CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (NOCOPY DATA)");
+   "CREATE SUBSCRIPTION tap_sub2 CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (copy_data = false)");
 
 # wait for it to start
 $node_subscriber->poll_query_until('postgres', "SELECT pid IS NOT NULL FROM pg_stat_subscription WHERE subname = 'tap_sub2' AND relid IS NULL")