Document that ONLY can be specified in publication commands
authorPeter Eisentraut
Mon, 17 Apr 2017 13:14:22 +0000 (09:14 -0400)
committerPeter Eisentraut
Mon, 17 Apr 2017 13:51:52 +0000 (09:51 -0400)
Author: Amit Langote 

doc/src/sgml/ref/alter_publication.sgml
doc/src/sgml/ref/create_publication.sgml
src/test/regress/expected/publication.out
src/test/regress/sql/publication.sql

index 0a965b3bbf8c3c0f4adf0e7891baaed744106361..858231fbcbfb16fa86bde9f6e8063dec4f30f51e 100644 (file)
@@ -31,9 +31,9 @@ ALTER PUBLICATION name WITH ( 
 
 ALTER PUBLICATION name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
 ALTER PUBLICATION name RENAME TO new_name
-ALTER PUBLICATION name ADD TABLE table_name [, ...]
-ALTER PUBLICATION name SET TABLE table_name [, ...]
-ALTER PUBLICATION name DROP TABLE table_name [, ...]
+ALTER PUBLICATION name ADD TABLE [ ONLY ] table_name [ * ] [, ...]
+ALTER PUBLICATION name SET TABLE [ ONLY ] table_name [ * ] [, ...]
+ALTER PUBLICATION name DROP TABLE [ ONLY ] table_name [ * ] [, ...]
 
  
 
@@ -116,7 +116,11 @@ ALTER PUBLICATION name DROP TABLE <
     table_name
     
      
-      Name of an existing table.
+      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.
      
     
    
index 3cdde801fa1f6f35fa222ee0017b2fcaec8a117c..0369b579c5c386741fa64c1587c0899d82a68b6f 100644 (file)
@@ -22,7 +22,7 @@ PostgreSQL documentation
  
 
 CREATE PUBLICATION name
-    [ FOR TABLE table_name [, ...]
+    [ FOR TABLE [ ONLY ] table_name [ * ] [, ...]
       | FOR ALL TABLES ]
     [ WITH ( option [, ... ] ) ]
 
@@ -68,7 +68,12 @@ CREATE PUBLICATION name
     FOR TABLE
     
      
-      Specifies a list of tables to add to the publication.
+      Specifies a list of tables to add to the publication.  If
+      ONLY is specified before the table name, only
+      that table is added to the publication.  If ONLY is not
+      specified, the table and all its descendant tables (if any) are added.
+      Optionally, * can be specified after the table name to
+      explicitly indicate that descendant tables are included.
      
     
    
index 0964718a60e0e2f412c43b168aa4747635c029f0..5b7fb674dad6b2819a7478cafedc2a24f071a755 100644 (file)
@@ -71,6 +71,29 @@ Publications:
 
 DROP TABLE testpub_tbl2;
 DROP PUBLICATION testpub_foralltables;
+CREATE TABLE testpub_tbl3 (a int);
+CREATE TABLE testpub_tbl3a (b text) INHERITS (testpub_tbl3);
+CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3;
+CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3;
+\dRp+ testpub3
+    Publication testpub3
+ Inserts | Updates | Deletes 
+---------+---------+---------
+ t       | t       | t
+Tables:
+    "public.testpub_tbl3"
+    "public.testpub_tbl3a"
+
+\dRp+ testpub4
+    Publication testpub4
+ Inserts | Updates | Deletes 
+---------+---------+---------
+ t       | t       | t
+Tables:
+    "public.testpub_tbl3"
+
+DROP TABLE testpub_tbl3, testpub_tbl3a;
+DROP PUBLICATION testpub3, testpub4;
 -- fail - view
 CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_view;
 ERROR:  "testpub_view" is not a table
index 85530bec0e72f912e22800e17b8267b040959fa9..b118bc9906f3fd7c435a60987db5dc422be9e5e6 100644 (file)
@@ -44,6 +44,16 @@ SELECT pubname, puballtables FROM pg_publication WHERE pubname = 'testpub_forall
 DROP TABLE testpub_tbl2;
 DROP PUBLICATION testpub_foralltables;
 
+CREATE TABLE testpub_tbl3 (a int);
+CREATE TABLE testpub_tbl3a (b text) INHERITS (testpub_tbl3);
+CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3;
+CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3;
+\dRp+ testpub3
+\dRp+ testpub4
+
+DROP TABLE testpub_tbl3, testpub_tbl3a;
+DROP PUBLICATION testpub3, testpub4;
+
 -- fail - view
 CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_view;
 CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1, pub_test.testpub_nopk;