mirror of
https://github.com/postgres/postgres.git
synced 2025-10-15 05:46:52 +03:00
Add "ALL SEQUENCES" support to publications.
This patch adds support for the ALL SEQUENCES clause in publications, enabling synchronization/replication of all sequences that is useful for upgrades. Publications can now include all sequences via FOR ALL SEQUENCES. psql enhancements: \d shows publications for a given sequence. \dRp indicates if a publication includes all sequences. ALL SEQUENCES can be combined with ALL TABLES, but not with other options like TABLE or TABLES IN SCHEMA. We can extend support for more granular clauses in future. The view pg_publication_sequences provides information about the mapping between publications and sequences. This patch enables publishing of sequences; subscriber-side support will be added in upcoming patches. Author: vignesh C <vignesh21@gmail.com> Author: Tomas Vondra <tomas@vondra.me> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com> Reviewed-by: Peter Smith <smithpb2250@gmail.com> Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/CAA4eK1LC+KJiAkSrpE_NwvNdidw9F2os7GERUeSxSKv71gXysQ@mail.gmail.com
This commit is contained in:
@@ -6374,6 +6374,16 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l
|
|||||||
</para></entry>
|
</para></entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
|
<structfield>puballsequences</structfield> <type>bool</type>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
If true, this publication automatically includes all sequences
|
||||||
|
in the database, including any that will be created in the future.
|
||||||
|
</para></entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry role="catalog_table_entry"><para role="column_definition">
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
<structfield>pubinsert</structfield> <type>bool</type>
|
<structfield>pubinsert</structfield> <type>bool</type>
|
||||||
|
@@ -102,16 +102,18 @@
|
|||||||
A <firstterm>publication</firstterm> can be defined on any physical
|
A <firstterm>publication</firstterm> can be defined on any physical
|
||||||
replication primary. The node where a publication is defined is referred to
|
replication primary. The node where a publication is defined is referred to
|
||||||
as <firstterm>publisher</firstterm>. A publication is a set of changes
|
as <firstterm>publisher</firstterm>. A publication is a set of changes
|
||||||
generated from a table or a group of tables, and might also be described as
|
generated from a table, a group of tables or the current state of all
|
||||||
a change set or replication set. Each publication exists in only one database.
|
sequences, and might also be described as a change set or replication set.
|
||||||
|
Each publication exists in only one database.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Publications are different from schemas and do not affect how the table is
|
Publications are different from schemas and do not affect how the table is
|
||||||
accessed. Each table can be added to multiple publications if needed.
|
accessed. Each table can be added to multiple publications if needed.
|
||||||
Publications may currently only contain tables and all tables in schema.
|
Publications may currently only contain tables or sequences. Objects must be
|
||||||
Objects must be added explicitly, except when a publication is created for
|
added explicitly, except when a publication is created using
|
||||||
<literal>ALL TABLES</literal>.
|
<literal>FOR TABLES IN SCHEMA</literal>, <literal>FOR ALL TABLES</literal>,
|
||||||
|
or <literal>FOR ALL SEQUENCES</literal>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -1049,24 +1051,24 @@ HINT: To initiate replication, you must manually create the replication slot, e
|
|||||||
<programlisting><![CDATA[
|
<programlisting><![CDATA[
|
||||||
/* pub # */ \dRp+
|
/* pub # */ \dRp+
|
||||||
Publication p1
|
Publication p1
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
----------+------------+---------+---------+---------+-----------+-------------------+----------
|
----------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
postgres | f | t | t | t | t | none | f
|
postgres | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.t1" WHERE ((a > 5) AND (c = 'NSW'::text))
|
"public.t1" WHERE ((a > 5) AND (c = 'NSW'::text))
|
||||||
|
|
||||||
Publication p2
|
Publication p2
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
----------+------------+---------+---------+---------+-----------+-------------------+----------
|
----------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
postgres | f | t | t | t | t | none | f
|
postgres | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.t1"
|
"public.t1"
|
||||||
"public.t2" WHERE (e = 99)
|
"public.t2" WHERE (e = 99)
|
||||||
|
|
||||||
Publication p3
|
Publication p3
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
----------+------------+---------+---------+---------+-----------+-------------------+----------
|
----------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
postgres | f | t | t | t | t | none | f
|
postgres | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.t2" WHERE (d = 10)
|
"public.t2" WHERE (d = 10)
|
||||||
"public.t3" WHERE (g = 10)
|
"public.t3" WHERE (g = 10)
|
||||||
@@ -1491,10 +1493,10 @@ Publications:
|
|||||||
for each publication.
|
for each publication.
|
||||||
<programlisting>
|
<programlisting>
|
||||||
/* pub # */ \dRp+
|
/* pub # */ \dRp+
|
||||||
Publication p1
|
Publication p1
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
----------+------------+---------+---------+---------+-----------+-------------------+----------
|
----------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
postgres | f | t | t | t | t | none | f
|
postgres | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.t1" (id, a, b, d)
|
"public.t1" (id, a, b, d)
|
||||||
</programlisting></para>
|
</programlisting></para>
|
||||||
|
@@ -82,8 +82,9 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r
|
|||||||
new owning role, and that role must have <literal>CREATE</literal>
|
new owning role, and that role must have <literal>CREATE</literal>
|
||||||
privilege on the database.
|
privilege on the database.
|
||||||
Also, the new owner of a
|
Also, the new owner of a
|
||||||
<link linkend="sql-createpublication-params-for-all-tables"><literal>FOR ALL TABLES</literal></link>
|
<link linkend="sql-createpublication-params-for-tables-in-schema"><literal>FOR TABLES IN SCHEMA</literal></link>
|
||||||
or <link linkend="sql-createpublication-params-for-tables-in-schema"><literal>FOR TABLES IN SCHEMA</literal></link>
|
or <link linkend="sql-createpublication-params-for-all-tables"><literal>FOR ALL TABLES</literal></link>
|
||||||
|
or <link linkend="sql-createpublication-params-for-all-sequences"><literal>FOR ALL SEQUENCES</literal></link>
|
||||||
publication must be a superuser. However, a superuser can
|
publication must be a superuser. However, a superuser can
|
||||||
change the ownership of a publication regardless of these restrictions.
|
change the ownership of a publication regardless of these restrictions.
|
||||||
</para>
|
</para>
|
||||||
@@ -153,6 +154,7 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r
|
|||||||
<para>
|
<para>
|
||||||
This clause alters publication parameters originally set by
|
This clause alters publication parameters originally set by
|
||||||
<xref linkend="sql-createpublication"/>. See there for more information.
|
<xref linkend="sql-createpublication"/>. See there for more information.
|
||||||
|
This clause is not applicable to sequences.
|
||||||
</para>
|
</para>
|
||||||
<caution>
|
<caution>
|
||||||
<para>
|
<para>
|
||||||
|
@@ -22,14 +22,18 @@ PostgreSQL documentation
|
|||||||
<refsynopsisdiv>
|
<refsynopsisdiv>
|
||||||
<synopsis>
|
<synopsis>
|
||||||
CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
||||||
[ FOR ALL TABLES
|
[ FOR { <replaceable class="parameter">publication_object</replaceable> [, ... ] | <replaceable class="parameter">all_publication_object</replaceable> [, ... ] } ]
|
||||||
| FOR <replaceable class="parameter">publication_object</replaceable> [, ... ] ]
|
|
||||||
[ WITH ( <replaceable class="parameter">publication_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
[ WITH ( <replaceable class="parameter">publication_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
||||||
|
|
||||||
<phrase>where <replaceable class="parameter">publication_object</replaceable> is one of:</phrase>
|
<phrase>where <replaceable class="parameter">publication_object</replaceable> is one of:</phrase>
|
||||||
|
|
||||||
TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] [ ( <replaceable class="parameter">column_name</replaceable> [, ... ] ) ] [ WHERE ( <replaceable class="parameter">expression</replaceable> ) ] [, ... ]
|
TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] [ ( <replaceable class="parameter">column_name</replaceable> [, ... ] ) ] [ WHERE ( <replaceable class="parameter">expression</replaceable> ) ] [, ... ]
|
||||||
TABLES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
|
TABLES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
|
||||||
|
|
||||||
|
<phrase>where <replaceable class="parameter">all_publication_object</replaceable> is one of:</phrase>
|
||||||
|
|
||||||
|
ALL TABLES
|
||||||
|
ALL SEQUENCES
|
||||||
</synopsis>
|
</synopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
@@ -120,16 +124,6 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry id="sql-createpublication-params-for-all-tables">
|
|
||||||
<term><literal>FOR ALL TABLES</literal></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Marks the publication as one that replicates changes for all tables in
|
|
||||||
the database, including tables created in the future.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry id="sql-createpublication-params-for-tables-in-schema">
|
<varlistentry id="sql-createpublication-params-for-tables-in-schema">
|
||||||
<term><literal>FOR TABLES IN SCHEMA</literal></term>
|
<term><literal>FOR TABLES IN SCHEMA</literal></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
@@ -161,11 +155,37 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry id="sql-createpublication-params-for-all-tables">
|
||||||
|
<term><literal>FOR ALL TABLES</literal></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Marks the publication as one that replicates changes for all tables in
|
||||||
|
the database, including tables created in the future.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry id="sql-createpublication-params-for-all-sequences">
|
||||||
|
<term><literal>FOR ALL SEQUENCES</literal></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Marks the publication as one that synchronizes changes for all sequences
|
||||||
|
in the database, including sequences created in the future.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Only persistent sequences are included in the publication. Temporary
|
||||||
|
sequences and unlogged sequences are excluded from the publication.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry id="sql-createpublication-params-with">
|
<varlistentry id="sql-createpublication-params-with">
|
||||||
<term><literal>WITH ( <replaceable class="parameter">publication_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] )</literal></term>
|
<term><literal>WITH ( <replaceable class="parameter">publication_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] )</literal></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
This clause specifies optional parameters for a publication. The
|
This clause specifies optional parameters for a publication when
|
||||||
|
publishing tables. This clause is not applicable to sequences. The
|
||||||
following parameters are supported:
|
following parameters are supported:
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
@@ -279,10 +299,10 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
|||||||
<title>Notes</title>
|
<title>Notes</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
If <literal>FOR TABLE</literal>, <literal>FOR ALL TABLES</literal> or
|
If <literal>FOR TABLE</literal>, <literal>FOR TABLES IN SCHEMA</literal>,
|
||||||
<literal>FOR TABLES IN SCHEMA</literal> are not specified, then the
|
<literal>FOR ALL TABLES</literal> or <literal>FOR ALL SEQUENCES</literal>
|
||||||
publication starts out with an empty set of tables. That is useful if
|
are not specified, then the publication starts out with an empty set of
|
||||||
tables or schemas are to be added later.
|
tables. That is useful if tables or schemas are to be added later.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -298,8 +318,9 @@ CREATE PUBLICATION <replaceable class="parameter">name</replaceable>
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
To add a table to a publication, the invoking user must have ownership
|
To add a table to a publication, the invoking user must have ownership
|
||||||
rights on the table. The <command>FOR ALL TABLES</command> and
|
rights on the table. The <literal>FOR TABLES IN SCHEMA</literal>,
|
||||||
<command>FOR TABLES IN SCHEMA</command> clauses require the invoking
|
<literal>FOR ALL TABLES</literal> and
|
||||||
|
<literal>FOR ALL SEQUENCES</literal> clauses require the invoking
|
||||||
user to be a superuser.
|
user to be a superuser.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@@ -449,6 +470,21 @@ CREATE PUBLICATION sales_publication FOR TABLES IN SCHEMA marketing, sales;
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE PUBLICATION users_filtered FOR TABLE users (user_id, firstname);
|
CREATE PUBLICATION users_filtered FOR TABLE users (user_id, firstname);
|
||||||
</programlisting></para>
|
</programlisting></para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Create a publication that publishes all sequences for synchronization:
|
||||||
|
<programlisting>
|
||||||
|
CREATE PUBLICATION all_sequences FOR ALL SEQUENCES;
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Create a publication that publishes all changes in all tables, and
|
||||||
|
all sequences for synchronization:
|
||||||
|
<programlisting>
|
||||||
|
CREATE PUBLICATION all_tables_sequences FOR ALL TABLES, ALL SEQUENCES;
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
|
@@ -136,6 +136,11 @@
|
|||||||
<entry>prepared transactions</entry>
|
<entry>prepared transactions</entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry><link linkend="view-pg-publication-sequences"><structname>pg_publication_sequences</structname></link></entry>
|
||||||
|
<entry>publications and information of their associated sequences</entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry><link linkend="view-pg-publication-tables"><structname>pg_publication_tables</structname></link></entry>
|
<entry><link linkend="view-pg-publication-tables"><structname>pg_publication_tables</structname></link></entry>
|
||||||
<entry>publications and information of their associated tables</entry>
|
<entry>publications and information of their associated tables</entry>
|
||||||
@@ -2549,6 +2554,67 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
|
|||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
<sect1 id="view-pg-publication-sequences">
|
||||||
|
<title><structname>pg_publication_sequences</structname></title>
|
||||||
|
|
||||||
|
<indexterm zone="view-pg-publication-sequences">
|
||||||
|
<primary>pg_publication_sequences</primary>
|
||||||
|
</indexterm>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The view <structname>pg_publication_sequences</structname> provides
|
||||||
|
information about the mapping between publications and sequences.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<title><structname>pg_publication_sequences</structname> Columns</title>
|
||||||
|
<tgroup cols="1">
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
|
Column Type
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Description
|
||||||
|
</para></entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
|
<structfield>pubname</structfield> <type>name</type>
|
||||||
|
(references <link linkend="catalog-pg-publication"><structname>pg_publication</structname></link>.<structfield>pubname</structfield>)
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Name of publication
|
||||||
|
</para></entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
|
<structfield>schemaname</structfield> <type>name</type>
|
||||||
|
(references <link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.<structfield>nspname</structfield>)
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Name of schema containing sequence
|
||||||
|
</para></entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
|
<structfield>sequencename</structfield> <type>name</type>
|
||||||
|
(references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>relname</structfield>)
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Name of sequence
|
||||||
|
</para></entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="view-pg-publication-tables">
|
<sect1 id="view-pg-publication-tables">
|
||||||
<title><structname>pg_publication_tables</structname></title>
|
<title><structname>pg_publication_tables</structname></title>
|
||||||
|
|
||||||
|
@@ -115,8 +115,10 @@ check_publication_add_schema(Oid schemaid)
|
|||||||
* Returns if relation represented by oid and Form_pg_class entry
|
* Returns if relation represented by oid and Form_pg_class entry
|
||||||
* is publishable.
|
* is publishable.
|
||||||
*
|
*
|
||||||
* Does same checks as check_publication_add_relation() above, but does not
|
* Does same checks as check_publication_add_relation() above except for
|
||||||
* need relation to be opened and also does not throw errors.
|
* RELKIND_SEQUENCE, but does not need relation to be opened and also does
|
||||||
|
* not throw errors. Here, the additional check is to support ALL SEQUENCES
|
||||||
|
* publication.
|
||||||
*
|
*
|
||||||
* XXX This also excludes all tables with relid < FirstNormalObjectId,
|
* XXX This also excludes all tables with relid < FirstNormalObjectId,
|
||||||
* ie all tables created during initdb. This mainly affects the preinstalled
|
* ie all tables created during initdb. This mainly affects the preinstalled
|
||||||
@@ -134,7 +136,8 @@ static bool
|
|||||||
is_publishable_class(Oid relid, Form_pg_class reltuple)
|
is_publishable_class(Oid relid, Form_pg_class reltuple)
|
||||||
{
|
{
|
||||||
return (reltuple->relkind == RELKIND_RELATION ||
|
return (reltuple->relkind == RELKIND_RELATION ||
|
||||||
reltuple->relkind == RELKIND_PARTITIONED_TABLE) &&
|
reltuple->relkind == RELKIND_PARTITIONED_TABLE ||
|
||||||
|
reltuple->relkind == RELKIND_SEQUENCE) &&
|
||||||
!IsCatalogRelationOid(relid) &&
|
!IsCatalogRelationOid(relid) &&
|
||||||
reltuple->relpersistence == RELPERSISTENCE_PERMANENT &&
|
reltuple->relpersistence == RELPERSISTENCE_PERMANENT &&
|
||||||
relid >= FirstNormalObjectId;
|
relid >= FirstNormalObjectId;
|
||||||
@@ -773,8 +776,8 @@ GetRelationPublications(Oid relid)
|
|||||||
/*
|
/*
|
||||||
* Gets list of relation oids for a publication.
|
* Gets list of relation oids for a publication.
|
||||||
*
|
*
|
||||||
* This should only be used FOR TABLE publications, the FOR ALL TABLES
|
* This should only be used FOR TABLE publications, the FOR ALL TABLES/SEQUENCES
|
||||||
* should use GetAllTablesPublicationRelations().
|
* should use GetAllPublicationRelations().
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
|
GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
|
||||||
@@ -854,14 +857,16 @@ GetAllTablesPublications(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets list of all relation published by FOR ALL TABLES publication(s).
|
* Gets list of all relations published by FOR ALL TABLES/SEQUENCES
|
||||||
|
* publication(s).
|
||||||
*
|
*
|
||||||
* If the publication publishes partition changes via their respective root
|
* If the publication publishes partition changes via their respective root
|
||||||
* partitioned tables, we must exclude partitions in favor of including the
|
* partitioned tables, we must exclude partitions in favor of including the
|
||||||
* root partitioned tables.
|
* root partitioned tables. This is not applicable to FOR ALL SEQUENCES
|
||||||
|
* publication.
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
GetAllTablesPublicationRelations(bool pubviaroot)
|
GetAllPublicationRelations(char relkind, bool pubviaroot)
|
||||||
{
|
{
|
||||||
Relation classRel;
|
Relation classRel;
|
||||||
ScanKeyData key[1];
|
ScanKeyData key[1];
|
||||||
@@ -869,12 +874,14 @@ GetAllTablesPublicationRelations(bool pubviaroot)
|
|||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
List *result = NIL;
|
List *result = NIL;
|
||||||
|
|
||||||
|
Assert(!(relkind == RELKIND_SEQUENCE && pubviaroot));
|
||||||
|
|
||||||
classRel = table_open(RelationRelationId, AccessShareLock);
|
classRel = table_open(RelationRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
Anum_pg_class_relkind,
|
Anum_pg_class_relkind,
|
||||||
BTEqualStrategyNumber, F_CHAREQ,
|
BTEqualStrategyNumber, F_CHAREQ,
|
||||||
CharGetDatum(RELKIND_RELATION));
|
CharGetDatum(relkind));
|
||||||
|
|
||||||
scan = table_beginscan_catalog(classRel, 1, key);
|
scan = table_beginscan_catalog(classRel, 1, key);
|
||||||
|
|
||||||
@@ -1083,6 +1090,7 @@ GetPublication(Oid pubid)
|
|||||||
pub->oid = pubid;
|
pub->oid = pubid;
|
||||||
pub->name = pstrdup(NameStr(pubform->pubname));
|
pub->name = pstrdup(NameStr(pubform->pubname));
|
||||||
pub->alltables = pubform->puballtables;
|
pub->alltables = pubform->puballtables;
|
||||||
|
pub->allsequences = pubform->puballsequences;
|
||||||
pub->pubactions.pubinsert = pubform->pubinsert;
|
pub->pubactions.pubinsert = pubform->pubinsert;
|
||||||
pub->pubactions.pubupdate = pubform->pubupdate;
|
pub->pubactions.pubupdate = pubform->pubupdate;
|
||||||
pub->pubactions.pubdelete = pubform->pubdelete;
|
pub->pubactions.pubdelete = pubform->pubdelete;
|
||||||
@@ -1160,7 +1168,8 @@ pg_get_publication_tables(PG_FUNCTION_ARGS)
|
|||||||
* those. Otherwise, get the partitioned table itself.
|
* those. Otherwise, get the partitioned table itself.
|
||||||
*/
|
*/
|
||||||
if (pub_elem->alltables)
|
if (pub_elem->alltables)
|
||||||
pub_elem_tables = GetAllTablesPublicationRelations(pub_elem->pubviaroot);
|
pub_elem_tables = GetAllPublicationRelations(RELKIND_RELATION,
|
||||||
|
pub_elem->pubviaroot);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List *relids,
|
List *relids,
|
||||||
@@ -1332,3 +1341,49 @@ pg_get_publication_tables(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
SRF_RETURN_DONE(funcctx);
|
SRF_RETURN_DONE(funcctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns Oids of sequences in a publication.
|
||||||
|
*/
|
||||||
|
Datum
|
||||||
|
pg_get_publication_sequences(PG_FUNCTION_ARGS)
|
||||||
|
{
|
||||||
|
FuncCallContext *funcctx;
|
||||||
|
List *sequences = NIL;
|
||||||
|
|
||||||
|
/* stuff done only on the first call of the function */
|
||||||
|
if (SRF_IS_FIRSTCALL())
|
||||||
|
{
|
||||||
|
char *pubname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
|
Publication *publication;
|
||||||
|
MemoryContext oldcontext;
|
||||||
|
|
||||||
|
/* create a function context for cross-call persistence */
|
||||||
|
funcctx = SRF_FIRSTCALL_INIT();
|
||||||
|
|
||||||
|
/* switch to memory context appropriate for multiple function calls */
|
||||||
|
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
||||||
|
|
||||||
|
publication = GetPublicationByName(pubname, false);
|
||||||
|
|
||||||
|
if (publication->allsequences)
|
||||||
|
sequences = GetAllPublicationRelations(RELKIND_SEQUENCE, false);
|
||||||
|
|
||||||
|
funcctx->user_fctx = (void *) sequences;
|
||||||
|
|
||||||
|
MemoryContextSwitchTo(oldcontext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* stuff done on every call of the function */
|
||||||
|
funcctx = SRF_PERCALL_SETUP();
|
||||||
|
sequences = (List *) funcctx->user_fctx;
|
||||||
|
|
||||||
|
if (funcctx->call_cntr < list_length(sequences))
|
||||||
|
{
|
||||||
|
Oid relid = list_nth_oid(sequences, funcctx->call_cntr);
|
||||||
|
|
||||||
|
SRF_RETURN_NEXT(funcctx, ObjectIdGetDatum(relid));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRF_RETURN_DONE(funcctx);
|
||||||
|
}
|
||||||
|
@@ -394,6 +394,16 @@ CREATE VIEW pg_publication_tables AS
|
|||||||
pg_class C JOIN pg_namespace N ON (N.oid = C.relnamespace)
|
pg_class C JOIN pg_namespace N ON (N.oid = C.relnamespace)
|
||||||
WHERE C.oid = GPT.relid;
|
WHERE C.oid = GPT.relid;
|
||||||
|
|
||||||
|
CREATE VIEW pg_publication_sequences AS
|
||||||
|
SELECT
|
||||||
|
P.pubname AS pubname,
|
||||||
|
N.nspname AS schemaname,
|
||||||
|
C.relname AS sequencename
|
||||||
|
FROM pg_publication P,
|
||||||
|
LATERAL pg_get_publication_sequences(P.pubname) GPS,
|
||||||
|
pg_class C JOIN pg_namespace N ON (N.oid = C.relnamespace)
|
||||||
|
WHERE C.oid = GPS.relid;
|
||||||
|
|
||||||
CREATE VIEW pg_locks AS
|
CREATE VIEW pg_locks AS
|
||||||
SELECT * FROM pg_lock_status() AS L;
|
SELECT * FROM pg_lock_status() AS L;
|
||||||
|
|
||||||
|
@@ -847,11 +847,14 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
|
|||||||
aclcheck_error(aclresult, OBJECT_DATABASE,
|
aclcheck_error(aclresult, OBJECT_DATABASE,
|
||||||
get_database_name(MyDatabaseId));
|
get_database_name(MyDatabaseId));
|
||||||
|
|
||||||
/* FOR ALL TABLES requires superuser */
|
/* FOR ALL TABLES and FOR ALL SEQUENCES requires superuser */
|
||||||
if (stmt->for_all_tables && !superuser())
|
if (!superuser())
|
||||||
ereport(ERROR,
|
{
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
if (stmt->for_all_tables || stmt->for_all_sequences)
|
||||||
errmsg("must be superuser to create FOR ALL TABLES publication")));
|
ereport(ERROR,
|
||||||
|
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
|
errmsg("must be superuser to create a FOR ALL TABLES or ALL SEQUENCES publication"));
|
||||||
|
}
|
||||||
|
|
||||||
rel = table_open(PublicationRelationId, RowExclusiveLock);
|
rel = table_open(PublicationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
@@ -880,11 +883,20 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
|
|||||||
&publish_generated_columns_given,
|
&publish_generated_columns_given,
|
||||||
&publish_generated_columns);
|
&publish_generated_columns);
|
||||||
|
|
||||||
|
if (stmt->for_all_sequences &&
|
||||||
|
(publish_given || publish_via_partition_root_given ||
|
||||||
|
publish_generated_columns_given))
|
||||||
|
ereport(NOTICE,
|
||||||
|
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
|
errmsg("publication parameters are not applicable to sequence synchronization and will be ignored for sequences"));
|
||||||
|
|
||||||
puboid = GetNewOidWithIndex(rel, PublicationObjectIndexId,
|
puboid = GetNewOidWithIndex(rel, PublicationObjectIndexId,
|
||||||
Anum_pg_publication_oid);
|
Anum_pg_publication_oid);
|
||||||
values[Anum_pg_publication_oid - 1] = ObjectIdGetDatum(puboid);
|
values[Anum_pg_publication_oid - 1] = ObjectIdGetDatum(puboid);
|
||||||
values[Anum_pg_publication_puballtables - 1] =
|
values[Anum_pg_publication_puballtables - 1] =
|
||||||
BoolGetDatum(stmt->for_all_tables);
|
BoolGetDatum(stmt->for_all_tables);
|
||||||
|
values[Anum_pg_publication_puballsequences - 1] =
|
||||||
|
BoolGetDatum(stmt->for_all_sequences);
|
||||||
values[Anum_pg_publication_pubinsert - 1] =
|
values[Anum_pg_publication_pubinsert - 1] =
|
||||||
BoolGetDatum(pubactions.pubinsert);
|
BoolGetDatum(pubactions.pubinsert);
|
||||||
values[Anum_pg_publication_pubupdate - 1] =
|
values[Anum_pg_publication_pubupdate - 1] =
|
||||||
@@ -914,10 +926,14 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
|
|||||||
/* Associate objects with the publication. */
|
/* Associate objects with the publication. */
|
||||||
if (stmt->for_all_tables)
|
if (stmt->for_all_tables)
|
||||||
{
|
{
|
||||||
/* Invalidate relcache so that publication info is rebuilt. */
|
/*
|
||||||
|
* Invalidate relcache so that publication info is rebuilt. Sequences
|
||||||
|
* publication doesn't require invalidation, as replica identity
|
||||||
|
* checks don't apply to them.
|
||||||
|
*/
|
||||||
CacheInvalidateRelcacheAll();
|
CacheInvalidateRelcacheAll();
|
||||||
}
|
}
|
||||||
else
|
else if (!stmt->for_all_sequences)
|
||||||
{
|
{
|
||||||
ObjectsInPublicationToOids(stmt->pubobjects, pstate, &relations,
|
ObjectsInPublicationToOids(stmt->pubobjects, pstate, &relations,
|
||||||
&schemaidlist);
|
&schemaidlist);
|
||||||
@@ -989,6 +1005,8 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
|
|||||||
List *root_relids = NIL;
|
List *root_relids = NIL;
|
||||||
ListCell *lc;
|
ListCell *lc;
|
||||||
|
|
||||||
|
pubform = (Form_pg_publication) GETSTRUCT(tup);
|
||||||
|
|
||||||
parse_publication_options(pstate,
|
parse_publication_options(pstate,
|
||||||
stmt->options,
|
stmt->options,
|
||||||
&publish_given, &pubactions,
|
&publish_given, &pubactions,
|
||||||
@@ -997,7 +1015,12 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt,
|
|||||||
&publish_generated_columns_given,
|
&publish_generated_columns_given,
|
||||||
&publish_generated_columns);
|
&publish_generated_columns);
|
||||||
|
|
||||||
pubform = (Form_pg_publication) GETSTRUCT(tup);
|
if (pubform->puballsequences &&
|
||||||
|
(publish_given || publish_via_partition_root_given ||
|
||||||
|
publish_generated_columns_given))
|
||||||
|
ereport(NOTICE,
|
||||||
|
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
|
errmsg("publication parameters are not applicable to sequence synchronization and will be ignored for sequences"));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the publication doesn't publish changes via the root partitioned
|
* If the publication doesn't publish changes via the root partitioned
|
||||||
@@ -1451,20 +1474,50 @@ CheckAlterPublication(AlterPublicationStmt *stmt, HeapTuple tup,
|
|||||||
* Check that user is allowed to manipulate the publication tables in
|
* Check that user is allowed to manipulate the publication tables in
|
||||||
* schema
|
* schema
|
||||||
*/
|
*/
|
||||||
if (schemaidlist && pubform->puballtables)
|
if (schemaidlist && (pubform->puballtables || pubform->puballsequences))
|
||||||
ereport(ERROR,
|
{
|
||||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
if (pubform->puballtables && pubform->puballsequences)
|
||||||
errmsg("publication \"%s\" is defined as FOR ALL TABLES",
|
ereport(ERROR,
|
||||||
NameStr(pubform->pubname)),
|
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
errdetail("Schemas cannot be added to or dropped from FOR ALL TABLES publications.")));
|
errmsg("publication \"%s\" is defined as FOR ALL TABLES, ALL SEQUENCES",
|
||||||
|
NameStr(pubform->pubname)),
|
||||||
|
errdetail("Schemas cannot be added to or dropped from FOR ALL TABLES, ALL SEQUENCES publications."));
|
||||||
|
else if (pubform->puballtables)
|
||||||
|
ereport(ERROR,
|
||||||
|
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
|
errmsg("publication \"%s\" is defined as FOR ALL TABLES",
|
||||||
|
NameStr(pubform->pubname)),
|
||||||
|
errdetail("Schemas cannot be added to or dropped from FOR ALL TABLES publications."));
|
||||||
|
else
|
||||||
|
ereport(ERROR,
|
||||||
|
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
|
errmsg("publication \"%s\" is defined as FOR ALL SEQUENCES",
|
||||||
|
NameStr(pubform->pubname)),
|
||||||
|
errdetail("Schemas cannot be added to or dropped from FOR ALL SEQUENCES publications."));
|
||||||
|
}
|
||||||
|
|
||||||
/* Check that user is allowed to manipulate the publication tables. */
|
/* Check that user is allowed to manipulate the publication tables. */
|
||||||
if (tables && pubform->puballtables)
|
if (tables && (pubform->puballtables || pubform->puballsequences))
|
||||||
ereport(ERROR,
|
{
|
||||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
if (pubform->puballtables && pubform->puballsequences)
|
||||||
errmsg("publication \"%s\" is defined as FOR ALL TABLES",
|
ereport(ERROR,
|
||||||
NameStr(pubform->pubname)),
|
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
errdetail("Tables cannot be added to or dropped from FOR ALL TABLES publications.")));
|
errmsg("publication \"%s\" is defined as FOR ALL TABLES, ALL SEQUENCES",
|
||||||
|
NameStr(pubform->pubname)),
|
||||||
|
errdetail("Tables or sequences cannot be added to or dropped from FOR ALL TABLES, ALL SEQUENCES publications."));
|
||||||
|
else if (pubform->puballtables)
|
||||||
|
ereport(ERROR,
|
||||||
|
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
|
errmsg("publication \"%s\" is defined as FOR ALL TABLES",
|
||||||
|
NameStr(pubform->pubname)),
|
||||||
|
errdetail("Tables or sequences cannot be added to or dropped from FOR ALL TABLES publications."));
|
||||||
|
else
|
||||||
|
ereport(ERROR,
|
||||||
|
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
|
errmsg("publication \"%s\" is defined as FOR ALL SEQUENCES",
|
||||||
|
NameStr(pubform->pubname)),
|
||||||
|
errdetail("Tables or sequences cannot be added to or dropped from FOR ALL SEQUENCES publications."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2014,19 +2067,16 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
|||||||
aclcheck_error(aclresult, OBJECT_DATABASE,
|
aclcheck_error(aclresult, OBJECT_DATABASE,
|
||||||
get_database_name(MyDatabaseId));
|
get_database_name(MyDatabaseId));
|
||||||
|
|
||||||
if (form->puballtables && !superuser_arg(newOwnerId))
|
if (!superuser_arg(newOwnerId))
|
||||||
ereport(ERROR,
|
{
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
if (form->puballtables || form->puballsequences ||
|
||||||
errmsg("permission denied to change owner of publication \"%s\"",
|
is_schema_publication(form->oid))
|
||||||
NameStr(form->pubname)),
|
ereport(ERROR,
|
||||||
errhint("The owner of a FOR ALL TABLES publication must be a superuser.")));
|
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
|
errmsg("permission denied to change owner of publication \"%s\"",
|
||||||
if (!superuser_arg(newOwnerId) && is_schema_publication(form->oid))
|
NameStr(form->pubname)),
|
||||||
ereport(ERROR,
|
errhint("The owner of a FOR ALL TABLES or ALL SEQUENCES or TABLES IN SCHEMA publication must be a superuser."));
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
}
|
||||||
errmsg("permission denied to change owner of publication \"%s\"",
|
|
||||||
NameStr(form->pubname)),
|
|
||||||
errhint("The owner of a FOR TABLES IN SCHEMA publication must be a superuser.")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
form->pubowner = newOwnerId;
|
form->pubowner = newOwnerId;
|
||||||
|
@@ -202,6 +202,10 @@ static void processCASbits(int cas_bits, int location, const char *constrType,
|
|||||||
bool *not_valid, bool *no_inherit, core_yyscan_t yyscanner);
|
bool *not_valid, bool *no_inherit, core_yyscan_t yyscanner);
|
||||||
static PartitionStrategy parsePartitionStrategy(char *strategy, int location,
|
static PartitionStrategy parsePartitionStrategy(char *strategy, int location,
|
||||||
core_yyscan_t yyscanner);
|
core_yyscan_t yyscanner);
|
||||||
|
static void preprocess_pub_all_objtype_list(List *all_objects_list,
|
||||||
|
bool *all_tables,
|
||||||
|
bool *all_sequences,
|
||||||
|
core_yyscan_t yyscanner);
|
||||||
static void preprocess_pubobj_list(List *pubobjspec_list,
|
static void preprocess_pubobj_list(List *pubobjspec_list,
|
||||||
core_yyscan_t yyscanner);
|
core_yyscan_t yyscanner);
|
||||||
static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||||
@@ -260,6 +264,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
|||||||
PartitionBoundSpec *partboundspec;
|
PartitionBoundSpec *partboundspec;
|
||||||
RoleSpec *rolespec;
|
RoleSpec *rolespec;
|
||||||
PublicationObjSpec *publicationobjectspec;
|
PublicationObjSpec *publicationobjectspec;
|
||||||
|
PublicationAllObjSpec *publicationallobjectspec;
|
||||||
struct SelectLimit *selectlimit;
|
struct SelectLimit *selectlimit;
|
||||||
SetQuantifier setquantifier;
|
SetQuantifier setquantifier;
|
||||||
struct GroupClause *groupclause;
|
struct GroupClause *groupclause;
|
||||||
@@ -447,7 +452,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
|||||||
transform_element_list transform_type_list
|
transform_element_list transform_type_list
|
||||||
TriggerTransitions TriggerReferencing
|
TriggerTransitions TriggerReferencing
|
||||||
vacuum_relation_list opt_vacuum_relation_list
|
vacuum_relation_list opt_vacuum_relation_list
|
||||||
drop_option_list pub_obj_list
|
drop_option_list pub_obj_list pub_obj_type_list
|
||||||
|
|
||||||
%type <retclause> returning_clause
|
%type <retclause> returning_clause
|
||||||
%type <node> returning_option
|
%type <node> returning_option
|
||||||
@@ -585,6 +590,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
|||||||
%type <node> var_value zone_value
|
%type <node> var_value zone_value
|
||||||
%type <rolespec> auth_ident RoleSpec opt_granted_by
|
%type <rolespec> auth_ident RoleSpec opt_granted_by
|
||||||
%type <publicationobjectspec> PublicationObjSpec
|
%type <publicationobjectspec> PublicationObjSpec
|
||||||
|
%type <publicationallobjectspec> PublicationAllObjSpec
|
||||||
|
|
||||||
%type <keyword> unreserved_keyword type_func_name_keyword
|
%type <keyword> unreserved_keyword type_func_name_keyword
|
||||||
%type <keyword> col_name_keyword reserved_keyword
|
%type <keyword> col_name_keyword reserved_keyword
|
||||||
@@ -10704,7 +10710,12 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
|
|||||||
*
|
*
|
||||||
* CREATE PUBLICATION name [WITH options]
|
* CREATE PUBLICATION name [WITH options]
|
||||||
*
|
*
|
||||||
* CREATE PUBLICATION FOR ALL TABLES [WITH options]
|
* CREATE PUBLICATION FOR ALL pub_obj_type [, ...] [WITH options]
|
||||||
|
*
|
||||||
|
* pub_obj_type is one of:
|
||||||
|
*
|
||||||
|
* TABLES
|
||||||
|
* SEQUENCES
|
||||||
*
|
*
|
||||||
* CREATE PUBLICATION FOR pub_obj [, ...] [WITH options]
|
* CREATE PUBLICATION FOR pub_obj [, ...] [WITH options]
|
||||||
*
|
*
|
||||||
@@ -10724,13 +10735,16 @@ CreatePublicationStmt:
|
|||||||
n->options = $4;
|
n->options = $4;
|
||||||
$$ = (Node *) n;
|
$$ = (Node *) n;
|
||||||
}
|
}
|
||||||
| CREATE PUBLICATION name FOR ALL TABLES opt_definition
|
| CREATE PUBLICATION name FOR pub_obj_type_list opt_definition
|
||||||
{
|
{
|
||||||
CreatePublicationStmt *n = makeNode(CreatePublicationStmt);
|
CreatePublicationStmt *n = makeNode(CreatePublicationStmt);
|
||||||
|
|
||||||
n->pubname = $3;
|
n->pubname = $3;
|
||||||
n->options = $7;
|
n->pubobjects = (List *) $5;
|
||||||
n->for_all_tables = true;
|
preprocess_pub_all_objtype_list($5, &n->for_all_tables,
|
||||||
|
&n->for_all_sequences,
|
||||||
|
yyscanner);
|
||||||
|
n->options = $6;
|
||||||
$$ = (Node *) n;
|
$$ = (Node *) n;
|
||||||
}
|
}
|
||||||
| CREATE PUBLICATION name FOR pub_obj_list opt_definition
|
| CREATE PUBLICATION name FOR pub_obj_list opt_definition
|
||||||
@@ -10842,6 +10856,28 @@ pub_obj_list: PublicationObjSpec
|
|||||||
{ $$ = lappend($1, $3); }
|
{ $$ = lappend($1, $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
PublicationAllObjSpec:
|
||||||
|
ALL TABLES
|
||||||
|
{
|
||||||
|
$$ = makeNode(PublicationAllObjSpec);
|
||||||
|
$$->pubobjtype = PUBLICATION_ALL_TABLES;
|
||||||
|
$$->location = @1;
|
||||||
|
}
|
||||||
|
| ALL SEQUENCES
|
||||||
|
{
|
||||||
|
$$ = makeNode(PublicationAllObjSpec);
|
||||||
|
$$->pubobjtype = PUBLICATION_ALL_SEQUENCES;
|
||||||
|
$$->location = @1;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
pub_obj_type_list: PublicationAllObjSpec
|
||||||
|
{ $$ = list_make1($1); }
|
||||||
|
| pub_obj_type_list ',' PublicationAllObjSpec
|
||||||
|
{ $$ = lappend($1, $3); }
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
* ALTER PUBLICATION name SET ( options )
|
* ALTER PUBLICATION name SET ( options )
|
||||||
@@ -19639,6 +19675,47 @@ parsePartitionStrategy(char *strategy, int location, core_yyscan_t yyscanner)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Process all_objects_list to set all_tables and/or all_sequences.
|
||||||
|
* Also, checks if the pub_object_type has been specified more than once.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
preprocess_pub_all_objtype_list(List *all_objects_list, bool *all_tables,
|
||||||
|
bool *all_sequences, core_yyscan_t yyscanner)
|
||||||
|
{
|
||||||
|
if (!all_objects_list)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*all_tables = false;
|
||||||
|
*all_sequences = false;
|
||||||
|
|
||||||
|
foreach_ptr(PublicationAllObjSpec, obj, all_objects_list)
|
||||||
|
{
|
||||||
|
if (obj->pubobjtype == PUBLICATION_ALL_TABLES)
|
||||||
|
{
|
||||||
|
if (*all_tables)
|
||||||
|
ereport(ERROR,
|
||||||
|
errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
|
errmsg("invalid publication object list"),
|
||||||
|
errdetail("ALL TABLES can be specified only once."),
|
||||||
|
parser_errposition(obj->location));
|
||||||
|
|
||||||
|
*all_tables = true;
|
||||||
|
}
|
||||||
|
else if (obj->pubobjtype == PUBLICATION_ALL_SEQUENCES)
|
||||||
|
{
|
||||||
|
if (*all_sequences)
|
||||||
|
ereport(ERROR,
|
||||||
|
errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
|
errmsg("invalid publication object list"),
|
||||||
|
errdetail("ALL SEQUENCES can be specified only once."),
|
||||||
|
parser_errposition(obj->location));
|
||||||
|
|
||||||
|
*all_sequences = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process pubobjspec_list to check for errors in any of the objects and
|
* Process pubobjspec_list to check for errors in any of the objects and
|
||||||
* convert PUBLICATIONOBJ_CONTINUATION into appropriate PublicationObjSpecType.
|
* convert PUBLICATIONOBJ_CONTINUATION into appropriate PublicationObjSpecType.
|
||||||
|
@@ -4531,6 +4531,7 @@ getPublications(Archive *fout)
|
|||||||
int i_pubname;
|
int i_pubname;
|
||||||
int i_pubowner;
|
int i_pubowner;
|
||||||
int i_puballtables;
|
int i_puballtables;
|
||||||
|
int i_puballsequences;
|
||||||
int i_pubinsert;
|
int i_pubinsert;
|
||||||
int i_pubupdate;
|
int i_pubupdate;
|
||||||
int i_pubdelete;
|
int i_pubdelete;
|
||||||
@@ -4561,9 +4562,14 @@ getPublications(Archive *fout)
|
|||||||
appendPQExpBufferStr(query, "false AS pubviaroot, ");
|
appendPQExpBufferStr(query, "false AS pubviaroot, ");
|
||||||
|
|
||||||
if (fout->remoteVersion >= 180000)
|
if (fout->remoteVersion >= 180000)
|
||||||
appendPQExpBufferStr(query, "p.pubgencols ");
|
appendPQExpBufferStr(query, "p.pubgencols, ");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(query, "'%c' AS pubgencols ", PUBLISH_GENCOLS_NONE);
|
appendPQExpBuffer(query, "'%c' AS pubgencols, ", PUBLISH_GENCOLS_NONE);
|
||||||
|
|
||||||
|
if (fout->remoteVersion >= 190000)
|
||||||
|
appendPQExpBufferStr(query, "p.puballsequences ");
|
||||||
|
else
|
||||||
|
appendPQExpBufferStr(query, "false AS puballsequences ");
|
||||||
|
|
||||||
appendPQExpBufferStr(query, "FROM pg_publication p");
|
appendPQExpBufferStr(query, "FROM pg_publication p");
|
||||||
|
|
||||||
@@ -4579,6 +4585,7 @@ getPublications(Archive *fout)
|
|||||||
i_pubname = PQfnumber(res, "pubname");
|
i_pubname = PQfnumber(res, "pubname");
|
||||||
i_pubowner = PQfnumber(res, "pubowner");
|
i_pubowner = PQfnumber(res, "pubowner");
|
||||||
i_puballtables = PQfnumber(res, "puballtables");
|
i_puballtables = PQfnumber(res, "puballtables");
|
||||||
|
i_puballsequences = PQfnumber(res, "puballsequences");
|
||||||
i_pubinsert = PQfnumber(res, "pubinsert");
|
i_pubinsert = PQfnumber(res, "pubinsert");
|
||||||
i_pubupdate = PQfnumber(res, "pubupdate");
|
i_pubupdate = PQfnumber(res, "pubupdate");
|
||||||
i_pubdelete = PQfnumber(res, "pubdelete");
|
i_pubdelete = PQfnumber(res, "pubdelete");
|
||||||
@@ -4599,6 +4606,8 @@ getPublications(Archive *fout)
|
|||||||
pubinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_pubowner));
|
pubinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_pubowner));
|
||||||
pubinfo[i].puballtables =
|
pubinfo[i].puballtables =
|
||||||
(strcmp(PQgetvalue(res, i, i_puballtables), "t") == 0);
|
(strcmp(PQgetvalue(res, i, i_puballtables), "t") == 0);
|
||||||
|
pubinfo[i].puballsequences =
|
||||||
|
(strcmp(PQgetvalue(res, i, i_puballsequences), "t") == 0);
|
||||||
pubinfo[i].pubinsert =
|
pubinfo[i].pubinsert =
|
||||||
(strcmp(PQgetvalue(res, i, i_pubinsert), "t") == 0);
|
(strcmp(PQgetvalue(res, i, i_pubinsert), "t") == 0);
|
||||||
pubinfo[i].pubupdate =
|
pubinfo[i].pubupdate =
|
||||||
@@ -4650,8 +4659,12 @@ dumpPublication(Archive *fout, const PublicationInfo *pubinfo)
|
|||||||
appendPQExpBuffer(query, "CREATE PUBLICATION %s",
|
appendPQExpBuffer(query, "CREATE PUBLICATION %s",
|
||||||
qpubname);
|
qpubname);
|
||||||
|
|
||||||
if (pubinfo->puballtables)
|
if (pubinfo->puballtables && pubinfo->puballsequences)
|
||||||
|
appendPQExpBufferStr(query, " FOR ALL TABLES, ALL SEQUENCES");
|
||||||
|
else if (pubinfo->puballtables)
|
||||||
appendPQExpBufferStr(query, " FOR ALL TABLES");
|
appendPQExpBufferStr(query, " FOR ALL TABLES");
|
||||||
|
else if (pubinfo->puballsequences)
|
||||||
|
appendPQExpBufferStr(query, " FOR ALL SEQUENCES");
|
||||||
|
|
||||||
appendPQExpBufferStr(query, " WITH (publish = '");
|
appendPQExpBufferStr(query, " WITH (publish = '");
|
||||||
if (pubinfo->pubinsert)
|
if (pubinfo->pubinsert)
|
||||||
|
@@ -669,6 +669,7 @@ typedef struct _PublicationInfo
|
|||||||
DumpableObject dobj;
|
DumpableObject dobj;
|
||||||
const char *rolname;
|
const char *rolname;
|
||||||
bool puballtables;
|
bool puballtables;
|
||||||
|
bool puballsequences;
|
||||||
bool pubinsert;
|
bool pubinsert;
|
||||||
bool pubupdate;
|
bool pubupdate;
|
||||||
bool pubdelete;
|
bool pubdelete;
|
||||||
|
@@ -3432,6 +3432,27 @@ my %tests = (
|
|||||||
like => { %full_runs, section_post_data => 1, },
|
like => { %full_runs, section_post_data => 1, },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'CREATE PUBLICATION pub6' => {
|
||||||
|
create_order => 50,
|
||||||
|
create_sql => 'CREATE PUBLICATION pub6
|
||||||
|
FOR ALL SEQUENCES;',
|
||||||
|
regexp => qr/^
|
||||||
|
\QCREATE PUBLICATION pub6 FOR ALL SEQUENCES WITH (publish = 'insert, update, delete, truncate');\E
|
||||||
|
/xm,
|
||||||
|
like => { %full_runs, section_post_data => 1, },
|
||||||
|
},
|
||||||
|
|
||||||
|
'CREATE PUBLICATION pub7' => {
|
||||||
|
create_order => 50,
|
||||||
|
create_sql => 'CREATE PUBLICATION pub7
|
||||||
|
FOR ALL SEQUENCES, ALL TABLES
|
||||||
|
WITH (publish = \'\');',
|
||||||
|
regexp => qr/^
|
||||||
|
\QCREATE PUBLICATION pub7 FOR ALL TABLES, ALL SEQUENCES WITH (publish = '');\E
|
||||||
|
/xm,
|
||||||
|
like => { %full_runs, section_post_data => 1, },
|
||||||
|
},
|
||||||
|
|
||||||
'CREATE SUBSCRIPTION sub1' => {
|
'CREATE SUBSCRIPTION sub1' => {
|
||||||
create_order => 50,
|
create_order => 50,
|
||||||
create_sql => 'CREATE SUBSCRIPTION sub1
|
create_sql => 'CREATE SUBSCRIPTION sub1
|
||||||
|
@@ -1759,7 +1759,7 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
{
|
{
|
||||||
PGresult *result = NULL;
|
PGresult *result = NULL;
|
||||||
printQueryOpt myopt = pset.popt;
|
printQueryOpt myopt = pset.popt;
|
||||||
char *footers[2] = {NULL, NULL};
|
char *footers[3] = {NULL, NULL, NULL};
|
||||||
|
|
||||||
if (pset.sversion >= 100000)
|
if (pset.sversion >= 100000)
|
||||||
{
|
{
|
||||||
@@ -1855,6 +1855,39 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
}
|
}
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
|
|
||||||
|
/* Print any publications */
|
||||||
|
if (pset.sversion >= 190000)
|
||||||
|
{
|
||||||
|
printfPQExpBuffer(&buf, "SELECT pubname FROM pg_catalog.pg_publication p"
|
||||||
|
"\nWHERE p.puballsequences"
|
||||||
|
"\n AND pg_catalog.pg_relation_is_publishable('%s')"
|
||||||
|
"\nORDER BY 1",
|
||||||
|
oid);
|
||||||
|
|
||||||
|
result = PSQLexec(buf.data);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
int nrows = PQntuples(result);
|
||||||
|
|
||||||
|
if (nrows > 0)
|
||||||
|
{
|
||||||
|
printfPQExpBuffer(&tmpbuf, _("Publications:"));
|
||||||
|
for (i = 0; i < nrows; i++)
|
||||||
|
appendPQExpBuffer(&tmpbuf, "\n \"%s\"", PQgetvalue(result, i, 0));
|
||||||
|
|
||||||
|
/* Store in the first available footer slot */
|
||||||
|
if (footers[0] == NULL)
|
||||||
|
footers[0] = pg_strdup(tmpbuf.data);
|
||||||
|
else
|
||||||
|
footers[1] = pg_strdup(tmpbuf.data);
|
||||||
|
|
||||||
|
resetPQExpBuffer(&tmpbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
PQclear(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tableinfo.relpersistence == RELPERSISTENCE_UNLOGGED)
|
if (tableinfo.relpersistence == RELPERSISTENCE_UNLOGGED)
|
||||||
printfPQExpBuffer(&title, _("Unlogged sequence \"%s.%s\""),
|
printfPQExpBuffer(&title, _("Unlogged sequence \"%s.%s\""),
|
||||||
schemaname, relationname);
|
schemaname, relationname);
|
||||||
@@ -1870,6 +1903,7 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
|
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
|
||||||
|
|
||||||
free(footers[0]);
|
free(footers[0]);
|
||||||
|
free(footers[1]);
|
||||||
|
|
||||||
retval = true;
|
retval = true;
|
||||||
goto error_return; /* not an error, just return early */
|
goto error_return; /* not an error, just return early */
|
||||||
@@ -6398,7 +6432,7 @@ listPublications(const char *pattern)
|
|||||||
PQExpBufferData buf;
|
PQExpBufferData buf;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
printQueryOpt myopt = pset.popt;
|
printQueryOpt myopt = pset.popt;
|
||||||
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false};
|
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
|
||||||
|
|
||||||
if (pset.sversion < 100000)
|
if (pset.sversion < 100000)
|
||||||
{
|
{
|
||||||
@@ -6415,13 +6449,20 @@ listPublications(const char *pattern)
|
|||||||
printfPQExpBuffer(&buf,
|
printfPQExpBuffer(&buf,
|
||||||
"SELECT pubname AS \"%s\",\n"
|
"SELECT pubname AS \"%s\",\n"
|
||||||
" pg_catalog.pg_get_userbyid(pubowner) AS \"%s\",\n"
|
" pg_catalog.pg_get_userbyid(pubowner) AS \"%s\",\n"
|
||||||
" puballtables AS \"%s\",\n"
|
" puballtables AS \"%s\"",
|
||||||
" pubinsert AS \"%s\",\n"
|
|
||||||
" pubupdate AS \"%s\",\n"
|
|
||||||
" pubdelete AS \"%s\"",
|
|
||||||
gettext_noop("Name"),
|
gettext_noop("Name"),
|
||||||
gettext_noop("Owner"),
|
gettext_noop("Owner"),
|
||||||
gettext_noop("All tables"),
|
gettext_noop("All tables"));
|
||||||
|
|
||||||
|
if (pset.sversion >= 190000)
|
||||||
|
appendPQExpBuffer(&buf,
|
||||||
|
",\n puballsequences AS \"%s\"",
|
||||||
|
gettext_noop("All sequences"));
|
||||||
|
|
||||||
|
appendPQExpBuffer(&buf,
|
||||||
|
",\n pubinsert AS \"%s\",\n"
|
||||||
|
" pubupdate AS \"%s\",\n"
|
||||||
|
" pubdelete AS \"%s\"",
|
||||||
gettext_noop("Inserts"),
|
gettext_noop("Inserts"),
|
||||||
gettext_noop("Updates"),
|
gettext_noop("Updates"),
|
||||||
gettext_noop("Deletes"));
|
gettext_noop("Deletes"));
|
||||||
@@ -6532,6 +6573,7 @@ describePublications(const char *pattern)
|
|||||||
bool has_pubtruncate;
|
bool has_pubtruncate;
|
||||||
bool has_pubgencols;
|
bool has_pubgencols;
|
||||||
bool has_pubviaroot;
|
bool has_pubviaroot;
|
||||||
|
bool has_pubsequence;
|
||||||
|
|
||||||
PQExpBufferData title;
|
PQExpBufferData title;
|
||||||
printTableContent cont;
|
printTableContent cont;
|
||||||
@@ -6546,6 +6588,7 @@ describePublications(const char *pattern)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
has_pubsequence = (pset.sversion >= 190000);
|
||||||
has_pubtruncate = (pset.sversion >= 110000);
|
has_pubtruncate = (pset.sversion >= 110000);
|
||||||
has_pubgencols = (pset.sversion >= 180000);
|
has_pubgencols = (pset.sversion >= 180000);
|
||||||
has_pubviaroot = (pset.sversion >= 130000);
|
has_pubviaroot = (pset.sversion >= 130000);
|
||||||
@@ -6555,7 +6598,18 @@ describePublications(const char *pattern)
|
|||||||
printfPQExpBuffer(&buf,
|
printfPQExpBuffer(&buf,
|
||||||
"SELECT oid, pubname,\n"
|
"SELECT oid, pubname,\n"
|
||||||
" pg_catalog.pg_get_userbyid(pubowner) AS owner,\n"
|
" pg_catalog.pg_get_userbyid(pubowner) AS owner,\n"
|
||||||
" puballtables, pubinsert, pubupdate, pubdelete");
|
" puballtables");
|
||||||
|
|
||||||
|
if (has_pubsequence)
|
||||||
|
appendPQExpBufferStr(&buf,
|
||||||
|
", puballsequences");
|
||||||
|
else
|
||||||
|
appendPQExpBufferStr(&buf,
|
||||||
|
", false AS puballsequences");
|
||||||
|
|
||||||
|
appendPQExpBufferStr(&buf,
|
||||||
|
", pubinsert, pubupdate, pubdelete");
|
||||||
|
|
||||||
if (has_pubtruncate)
|
if (has_pubtruncate)
|
||||||
appendPQExpBufferStr(&buf,
|
appendPQExpBufferStr(&buf,
|
||||||
", pubtruncate");
|
", pubtruncate");
|
||||||
@@ -6630,6 +6684,8 @@ describePublications(const char *pattern)
|
|||||||
bool puballtables = strcmp(PQgetvalue(res, i, 3), "t") == 0;
|
bool puballtables = strcmp(PQgetvalue(res, i, 3), "t") == 0;
|
||||||
printTableOpt myopt = pset.popt.topt;
|
printTableOpt myopt = pset.popt.topt;
|
||||||
|
|
||||||
|
if (has_pubsequence)
|
||||||
|
ncols++;
|
||||||
if (has_pubtruncate)
|
if (has_pubtruncate)
|
||||||
ncols++;
|
ncols++;
|
||||||
if (has_pubgencols)
|
if (has_pubgencols)
|
||||||
@@ -6643,6 +6699,8 @@ describePublications(const char *pattern)
|
|||||||
|
|
||||||
printTableAddHeader(&cont, gettext_noop("Owner"), true, align);
|
printTableAddHeader(&cont, gettext_noop("Owner"), true, align);
|
||||||
printTableAddHeader(&cont, gettext_noop("All tables"), true, align);
|
printTableAddHeader(&cont, gettext_noop("All tables"), true, align);
|
||||||
|
if (has_pubsequence)
|
||||||
|
printTableAddHeader(&cont, gettext_noop("All sequences"), true, align);
|
||||||
printTableAddHeader(&cont, gettext_noop("Inserts"), true, align);
|
printTableAddHeader(&cont, gettext_noop("Inserts"), true, align);
|
||||||
printTableAddHeader(&cont, gettext_noop("Updates"), true, align);
|
printTableAddHeader(&cont, gettext_noop("Updates"), true, align);
|
||||||
printTableAddHeader(&cont, gettext_noop("Deletes"), true, align);
|
printTableAddHeader(&cont, gettext_noop("Deletes"), true, align);
|
||||||
@@ -6655,15 +6713,17 @@ describePublications(const char *pattern)
|
|||||||
|
|
||||||
printTableAddCell(&cont, PQgetvalue(res, i, 2), false, false);
|
printTableAddCell(&cont, PQgetvalue(res, i, 2), false, false);
|
||||||
printTableAddCell(&cont, PQgetvalue(res, i, 3), false, false);
|
printTableAddCell(&cont, PQgetvalue(res, i, 3), false, false);
|
||||||
printTableAddCell(&cont, PQgetvalue(res, i, 4), false, false);
|
if (has_pubsequence)
|
||||||
|
printTableAddCell(&cont, PQgetvalue(res, i, 4), false, false);
|
||||||
printTableAddCell(&cont, PQgetvalue(res, i, 5), false, false);
|
printTableAddCell(&cont, PQgetvalue(res, i, 5), false, false);
|
||||||
printTableAddCell(&cont, PQgetvalue(res, i, 6), false, false);
|
printTableAddCell(&cont, PQgetvalue(res, i, 6), false, false);
|
||||||
|
printTableAddCell(&cont, PQgetvalue(res, i, 7), false, false);
|
||||||
if (has_pubtruncate)
|
if (has_pubtruncate)
|
||||||
printTableAddCell(&cont, PQgetvalue(res, i, 7), false, false);
|
|
||||||
if (has_pubgencols)
|
|
||||||
printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false);
|
printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false);
|
||||||
if (has_pubviaroot)
|
if (has_pubgencols)
|
||||||
printTableAddCell(&cont, PQgetvalue(res, i, 9), false, false);
|
printTableAddCell(&cont, PQgetvalue(res, i, 9), false, false);
|
||||||
|
if (has_pubviaroot)
|
||||||
|
printTableAddCell(&cont, PQgetvalue(res, i, 10), false, false);
|
||||||
|
|
||||||
if (!puballtables)
|
if (!puballtables)
|
||||||
{
|
{
|
||||||
|
@@ -3585,11 +3585,11 @@ match_previous_words(int pattern_id,
|
|||||||
|
|
||||||
/* CREATE PUBLICATION */
|
/* CREATE PUBLICATION */
|
||||||
else if (Matches("CREATE", "PUBLICATION", MatchAny))
|
else if (Matches("CREATE", "PUBLICATION", MatchAny))
|
||||||
COMPLETE_WITH("FOR TABLE", "FOR ALL TABLES", "FOR TABLES IN SCHEMA", "WITH (");
|
COMPLETE_WITH("FOR TABLE", "FOR TABLES IN SCHEMA", "FOR ALL TABLES", "FOR ALL SEQUENCES", "WITH (");
|
||||||
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR"))
|
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR"))
|
||||||
COMPLETE_WITH("TABLE", "ALL TABLES", "TABLES IN SCHEMA");
|
COMPLETE_WITH("TABLE", "TABLES IN SCHEMA", "ALL TABLES", "ALL SEQUENCES");
|
||||||
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL"))
|
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL"))
|
||||||
COMPLETE_WITH("TABLES");
|
COMPLETE_WITH("TABLES", "SEQUENCES");
|
||||||
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES"))
|
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES"))
|
||||||
COMPLETE_WITH("WITH (");
|
COMPLETE_WITH("WITH (");
|
||||||
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLES"))
|
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLES"))
|
||||||
|
@@ -57,6 +57,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* yyyymmddN */
|
/* yyyymmddN */
|
||||||
#define CATALOG_VERSION_NO 202510083
|
#define CATALOG_VERSION_NO 202510091
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -12302,6 +12302,11 @@
|
|||||||
proargmodes => '{v,o,o,o,o}',
|
proargmodes => '{v,o,o,o,o}',
|
||||||
proargnames => '{pubname,pubid,relid,attrs,qual}',
|
proargnames => '{pubname,pubid,relid,attrs,qual}',
|
||||||
prosrc => 'pg_get_publication_tables' },
|
prosrc => 'pg_get_publication_tables' },
|
||||||
|
{ oid => '8052', descr => 'get OIDs of sequences in a publication',
|
||||||
|
proname => 'pg_get_publication_sequences', prorows => '1000', proretset => 't',
|
||||||
|
provolatile => 's', prorettype => 'oid', proargtypes => 'text',
|
||||||
|
proallargtypes => '{text,oid}', proargmodes => '{i,o}',
|
||||||
|
proargnames => '{pubname,relid}', prosrc => 'pg_get_publication_sequences' },
|
||||||
{ oid => '6121',
|
{ oid => '6121',
|
||||||
descr => 'returns whether a relation can be part of a publication',
|
descr => 'returns whether a relation can be part of a publication',
|
||||||
proname => 'pg_relation_is_publishable', provolatile => 's',
|
proname => 'pg_relation_is_publishable', provolatile => 's',
|
||||||
|
@@ -40,6 +40,12 @@ CATALOG(pg_publication,6104,PublicationRelationId)
|
|||||||
*/
|
*/
|
||||||
bool puballtables;
|
bool puballtables;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* indicates that this is special publication which should encompass all
|
||||||
|
* sequences in the database (except for the unlogged and temp ones)
|
||||||
|
*/
|
||||||
|
bool puballsequences;
|
||||||
|
|
||||||
/* true if inserts are published */
|
/* true if inserts are published */
|
||||||
bool pubinsert;
|
bool pubinsert;
|
||||||
|
|
||||||
@@ -129,6 +135,7 @@ typedef struct Publication
|
|||||||
Oid oid;
|
Oid oid;
|
||||||
char *name;
|
char *name;
|
||||||
bool alltables;
|
bool alltables;
|
||||||
|
bool allsequences;
|
||||||
bool pubviaroot;
|
bool pubviaroot;
|
||||||
PublishGencolsType pubgencols_type;
|
PublishGencolsType pubgencols_type;
|
||||||
PublicationActions pubactions;
|
PublicationActions pubactions;
|
||||||
@@ -163,7 +170,7 @@ typedef enum PublicationPartOpt
|
|||||||
|
|
||||||
extern List *GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt);
|
extern List *GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt);
|
||||||
extern List *GetAllTablesPublications(void);
|
extern List *GetAllTablesPublications(void);
|
||||||
extern List *GetAllTablesPublicationRelations(bool pubviaroot);
|
extern List *GetAllPublicationRelations(char relkind, bool pubviaroot);
|
||||||
extern List *GetPublicationSchemas(Oid pubid);
|
extern List *GetPublicationSchemas(Oid pubid);
|
||||||
extern List *GetSchemaPublications(Oid schemaid);
|
extern List *GetSchemaPublications(Oid schemaid);
|
||||||
extern List *GetSchemaPublicationRelations(Oid schemaid,
|
extern List *GetSchemaPublicationRelations(Oid schemaid,
|
||||||
|
@@ -4294,6 +4294,22 @@ typedef struct PublicationObjSpec
|
|||||||
ParseLoc location; /* token location, or -1 if unknown */
|
ParseLoc location; /* token location, or -1 if unknown */
|
||||||
} PublicationObjSpec;
|
} PublicationObjSpec;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Types of objects supported by FOR ALL publications
|
||||||
|
*/
|
||||||
|
typedef enum PublicationAllObjType
|
||||||
|
{
|
||||||
|
PUBLICATION_ALL_TABLES,
|
||||||
|
PUBLICATION_ALL_SEQUENCES,
|
||||||
|
} PublicationAllObjType;
|
||||||
|
|
||||||
|
typedef struct PublicationAllObjSpec
|
||||||
|
{
|
||||||
|
NodeTag type;
|
||||||
|
PublicationAllObjType pubobjtype; /* type of this publication object */
|
||||||
|
ParseLoc location; /* token location, or -1 if unknown */
|
||||||
|
} PublicationAllObjSpec;
|
||||||
|
|
||||||
typedef struct CreatePublicationStmt
|
typedef struct CreatePublicationStmt
|
||||||
{
|
{
|
||||||
NodeTag type;
|
NodeTag type;
|
||||||
@@ -4301,6 +4317,8 @@ typedef struct CreatePublicationStmt
|
|||||||
List *options; /* List of DefElem nodes */
|
List *options; /* List of DefElem nodes */
|
||||||
List *pubobjects; /* Optional list of publication objects */
|
List *pubobjects; /* Optional list of publication objects */
|
||||||
bool for_all_tables; /* Special publication for all tables in db */
|
bool for_all_tables; /* Special publication for all tables in db */
|
||||||
|
bool for_all_sequences; /* Special publication for all sequences
|
||||||
|
* in db */
|
||||||
} CreatePublicationStmt;
|
} CreatePublicationStmt;
|
||||||
|
|
||||||
typedef enum AlterPublicationAction
|
typedef enum AlterPublicationAction
|
||||||
|
@@ -6445,9 +6445,9 @@ List of schemas
|
|||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
\dRp "no.such.publication"
|
\dRp "no.such.publication"
|
||||||
List of publications
|
List of publications
|
||||||
Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Name | Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
------+-------+------------+---------+---------+---------+-----------+-------------------+----------
|
------+-------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
\dRs "no.such.subscription"
|
\dRs "no.such.subscription"
|
||||||
|
@@ -40,20 +40,20 @@ CREATE PUBLICATION testpub_xxx WITH (publish_generated_columns);
|
|||||||
ERROR: invalid value for publication parameter "publish_generated_columns": ""
|
ERROR: invalid value for publication parameter "publish_generated_columns": ""
|
||||||
DETAIL: Valid values are "none" and "stored".
|
DETAIL: Valid values are "none" and "stored".
|
||||||
\dRp
|
\dRp
|
||||||
List of publications
|
List of publications
|
||||||
Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Name | Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------+--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------+--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
testpub_default | regress_publication_user | f | f | t | f | f | none | f
|
testpub_default | regress_publication_user | f | f | f | t | f | f | none | f
|
||||||
testpub_ins_trunct | regress_publication_user | f | t | f | f | f | none | f
|
testpub_ins_trunct | regress_publication_user | f | f | t | f | f | f | none | f
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete');
|
ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete');
|
||||||
\dRp
|
\dRp
|
||||||
List of publications
|
List of publications
|
||||||
Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Name | Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------+--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------+--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
testpub_default | regress_publication_user | f | t | t | t | f | none | f
|
testpub_default | regress_publication_user | f | f | t | t | t | f | none | f
|
||||||
testpub_ins_trunct | regress_publication_user | f | t | f | f | f | none | f
|
testpub_ins_trunct | regress_publication_user | f | f | t | f | f | f | none | f
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
--- adding tables
|
--- adding tables
|
||||||
@@ -70,15 +70,15 @@ CREATE TABLE testpub_tbl2 (id serial primary key, data text);
|
|||||||
-- fail - can't add to for all tables publication
|
-- fail - can't add to for all tables publication
|
||||||
ALTER PUBLICATION testpub_foralltables ADD TABLE testpub_tbl2;
|
ALTER PUBLICATION testpub_foralltables ADD TABLE testpub_tbl2;
|
||||||
ERROR: publication "testpub_foralltables" is defined as FOR ALL TABLES
|
ERROR: publication "testpub_foralltables" is defined as FOR ALL TABLES
|
||||||
DETAIL: Tables cannot be added to or dropped from FOR ALL TABLES publications.
|
DETAIL: Tables or sequences cannot be added to or dropped from FOR ALL TABLES publications.
|
||||||
-- fail - can't drop from all tables publication
|
-- fail - can't drop from all tables publication
|
||||||
ALTER PUBLICATION testpub_foralltables DROP TABLE testpub_tbl2;
|
ALTER PUBLICATION testpub_foralltables DROP TABLE testpub_tbl2;
|
||||||
ERROR: publication "testpub_foralltables" is defined as FOR ALL TABLES
|
ERROR: publication "testpub_foralltables" is defined as FOR ALL TABLES
|
||||||
DETAIL: Tables cannot be added to or dropped from FOR ALL TABLES publications.
|
DETAIL: Tables or sequences cannot be added to or dropped from FOR ALL TABLES publications.
|
||||||
-- fail - can't add to for all tables publication
|
-- fail - can't add to for all tables publication
|
||||||
ALTER PUBLICATION testpub_foralltables SET TABLE pub_test.testpub_nopk;
|
ALTER PUBLICATION testpub_foralltables SET TABLE pub_test.testpub_nopk;
|
||||||
ERROR: publication "testpub_foralltables" is defined as FOR ALL TABLES
|
ERROR: publication "testpub_foralltables" is defined as FOR ALL TABLES
|
||||||
DETAIL: Tables cannot be added to or dropped from FOR ALL TABLES publications.
|
DETAIL: Tables or sequences cannot be added to or dropped from FOR ALL TABLES publications.
|
||||||
-- fail - can't add schema to 'FOR ALL TABLES' publication
|
-- fail - can't add schema to 'FOR ALL TABLES' publication
|
||||||
ALTER PUBLICATION testpub_foralltables ADD TABLES IN SCHEMA pub_test;
|
ALTER PUBLICATION testpub_foralltables ADD TABLES IN SCHEMA pub_test;
|
||||||
ERROR: publication "testpub_foralltables" is defined as FOR ALL TABLES
|
ERROR: publication "testpub_foralltables" is defined as FOR ALL TABLES
|
||||||
@@ -97,10 +97,10 @@ RESET client_min_messages;
|
|||||||
-- should be able to add schema to 'FOR TABLE' publication
|
-- should be able to add schema to 'FOR TABLE' publication
|
||||||
ALTER PUBLICATION testpub_fortable ADD TABLES IN SCHEMA pub_test;
|
ALTER PUBLICATION testpub_fortable ADD TABLES IN SCHEMA pub_test;
|
||||||
\dRp+ testpub_fortable
|
\dRp+ testpub_fortable
|
||||||
Publication testpub_fortable
|
Publication testpub_fortable
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_tbl1"
|
"public.testpub_tbl1"
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
@@ -109,20 +109,20 @@ Tables from schemas:
|
|||||||
-- should be able to drop schema from 'FOR TABLE' publication
|
-- should be able to drop schema from 'FOR TABLE' publication
|
||||||
ALTER PUBLICATION testpub_fortable DROP TABLES IN SCHEMA pub_test;
|
ALTER PUBLICATION testpub_fortable DROP TABLES IN SCHEMA pub_test;
|
||||||
\dRp+ testpub_fortable
|
\dRp+ testpub_fortable
|
||||||
Publication testpub_fortable
|
Publication testpub_fortable
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_tbl1"
|
"public.testpub_tbl1"
|
||||||
|
|
||||||
-- should be able to set schema to 'FOR TABLE' publication
|
-- should be able to set schema to 'FOR TABLE' publication
|
||||||
ALTER PUBLICATION testpub_fortable SET TABLES IN SCHEMA pub_test;
|
ALTER PUBLICATION testpub_fortable SET TABLES IN SCHEMA pub_test;
|
||||||
\dRp+ testpub_fortable
|
\dRp+ testpub_fortable
|
||||||
Publication testpub_fortable
|
Publication testpub_fortable
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test"
|
"pub_test"
|
||||||
|
|
||||||
@@ -133,10 +133,10 @@ CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA pub_test;
|
|||||||
CREATE PUBLICATION testpub_for_tbl_schema FOR TABLES IN SCHEMA pub_test, TABLE pub_test.testpub_nopk;
|
CREATE PUBLICATION testpub_for_tbl_schema FOR TABLES IN SCHEMA pub_test, TABLE pub_test.testpub_nopk;
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\dRp+ testpub_for_tbl_schema
|
\dRp+ testpub_for_tbl_schema
|
||||||
Publication testpub_for_tbl_schema
|
Publication testpub_for_tbl_schema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"pub_test.testpub_nopk"
|
"pub_test.testpub_nopk"
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
@@ -154,10 +154,10 @@ LINE 1: ...CATION testpub_parsertst FOR TABLES IN SCHEMA foo, test.foo;
|
|||||||
-- should be able to add a table of the same schema to the schema publication
|
-- should be able to add a table of the same schema to the schema publication
|
||||||
ALTER PUBLICATION testpub_forschema ADD TABLE pub_test.testpub_nopk;
|
ALTER PUBLICATION testpub_forschema ADD TABLE pub_test.testpub_nopk;
|
||||||
\dRp+ testpub_forschema
|
\dRp+ testpub_forschema
|
||||||
Publication testpub_forschema
|
Publication testpub_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"pub_test.testpub_nopk"
|
"pub_test.testpub_nopk"
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
@@ -166,10 +166,10 @@ Tables from schemas:
|
|||||||
-- should be able to drop the table
|
-- should be able to drop the table
|
||||||
ALTER PUBLICATION testpub_forschema DROP TABLE pub_test.testpub_nopk;
|
ALTER PUBLICATION testpub_forschema DROP TABLE pub_test.testpub_nopk;
|
||||||
\dRp+ testpub_forschema
|
\dRp+ testpub_forschema
|
||||||
Publication testpub_forschema
|
Publication testpub_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test"
|
"pub_test"
|
||||||
|
|
||||||
@@ -180,10 +180,10 @@ ERROR: relation "testpub_nopk" is not part of the publication
|
|||||||
-- should be able to set table to schema publication
|
-- should be able to set table to schema publication
|
||||||
ALTER PUBLICATION testpub_forschema SET TABLE pub_test.testpub_nopk;
|
ALTER PUBLICATION testpub_forschema SET TABLE pub_test.testpub_nopk;
|
||||||
\dRp+ testpub_forschema
|
\dRp+ testpub_forschema
|
||||||
Publication testpub_forschema
|
Publication testpub_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"pub_test.testpub_nopk"
|
"pub_test.testpub_nopk"
|
||||||
|
|
||||||
@@ -207,10 +207,10 @@ Not-null constraints:
|
|||||||
"testpub_tbl2_id_not_null" NOT NULL "id"
|
"testpub_tbl2_id_not_null" NOT NULL "id"
|
||||||
|
|
||||||
\dRp+ testpub_foralltables
|
\dRp+ testpub_foralltables
|
||||||
Publication testpub_foralltables
|
Publication testpub_foralltables
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | t | t | t | f | f | none | f
|
regress_publication_user | t | f | t | t | f | f | none | f
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
DROP TABLE testpub_tbl2;
|
DROP TABLE testpub_tbl2;
|
||||||
@@ -222,24 +222,110 @@ CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3;
|
|||||||
CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3;
|
CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3;
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\dRp+ testpub3
|
\dRp+ testpub3
|
||||||
Publication testpub3
|
Publication testpub3
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_tbl3"
|
"public.testpub_tbl3"
|
||||||
"public.testpub_tbl3a"
|
"public.testpub_tbl3a"
|
||||||
|
|
||||||
\dRp+ testpub4
|
\dRp+ testpub4
|
||||||
Publication testpub4
|
Publication testpub4
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_tbl3"
|
"public.testpub_tbl3"
|
||||||
|
|
||||||
DROP TABLE testpub_tbl3, testpub_tbl3a;
|
DROP TABLE testpub_tbl3, testpub_tbl3a;
|
||||||
DROP PUBLICATION testpub3, testpub4;
|
DROP PUBLICATION testpub3, testpub4;
|
||||||
|
--- Tests for publications with SEQUENCES
|
||||||
|
CREATE SEQUENCE regress_pub_seq0;
|
||||||
|
CREATE SEQUENCE pub_test.regress_pub_seq1;
|
||||||
|
-- FOR ALL SEQUENCES
|
||||||
|
SET client_min_messages = 'ERROR';
|
||||||
|
CREATE PUBLICATION regress_pub_forallsequences1 FOR ALL SEQUENCES;
|
||||||
|
RESET client_min_messages;
|
||||||
|
SELECT pubname, puballtables, puballsequences FROM pg_publication WHERE pubname = 'regress_pub_forallsequences1';
|
||||||
|
pubname | puballtables | puballsequences
|
||||||
|
------------------------------+--------------+-----------------
|
||||||
|
regress_pub_forallsequences1 | f | t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\d+ regress_pub_seq0
|
||||||
|
Sequence "public.regress_pub_seq0"
|
||||||
|
Type | Start | Minimum | Maximum | Increment | Cycles? | Cache
|
||||||
|
--------+-------+---------+---------------------+-----------+---------+-------
|
||||||
|
bigint | 1 | 1 | 9223372036854775807 | 1 | no | 1
|
||||||
|
Publications:
|
||||||
|
"regress_pub_forallsequences1"
|
||||||
|
|
||||||
|
\dRp+ regress_pub_forallsequences1
|
||||||
|
Publication regress_pub_forallsequences1
|
||||||
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
|
regress_publication_user | f | t | t | t | t | t | none | f
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages = 'ERROR';
|
||||||
|
CREATE PUBLICATION regress_pub_forallsequences2 FOR ALL SEQUENCES;
|
||||||
|
RESET client_min_messages;
|
||||||
|
-- check that describe sequence lists both publications the sequence belongs to
|
||||||
|
\d+ pub_test.regress_pub_seq1
|
||||||
|
Sequence "pub_test.regress_pub_seq1"
|
||||||
|
Type | Start | Minimum | Maximum | Increment | Cycles? | Cache
|
||||||
|
--------+-------+---------+---------------------+-----------+---------+-------
|
||||||
|
bigint | 1 | 1 | 9223372036854775807 | 1 | no | 1
|
||||||
|
Publications:
|
||||||
|
"regress_pub_forallsequences1"
|
||||||
|
"regress_pub_forallsequences2"
|
||||||
|
|
||||||
|
--- Specifying both ALL TABLES and ALL SEQUENCES
|
||||||
|
SET client_min_messages = 'ERROR';
|
||||||
|
CREATE PUBLICATION regress_pub_for_allsequences_alltables FOR ALL SEQUENCES, ALL TABLES;
|
||||||
|
-- Specifying WITH clause in an ALL SEQUENCES publication will emit a NOTICE.
|
||||||
|
SET client_min_messages = 'NOTICE';
|
||||||
|
CREATE PUBLICATION regress_pub_for_allsequences_alltables_withclause FOR ALL SEQUENCES, ALL TABLES WITH (publish = 'insert');
|
||||||
|
NOTICE: publication parameters are not applicable to sequence synchronization and will be ignored for sequences
|
||||||
|
WARNING: "wal_level" is insufficient to publish logical changes
|
||||||
|
HINT: Set "wal_level" to "logical" before creating subscriptions.
|
||||||
|
CREATE PUBLICATION regress_pub_for_allsequences_withclause FOR ALL SEQUENCES WITH (publish_generated_columns = 'stored');
|
||||||
|
NOTICE: publication parameters are not applicable to sequence synchronization and will be ignored for sequences
|
||||||
|
WARNING: "wal_level" is insufficient to publish logical changes
|
||||||
|
HINT: Set "wal_level" to "logical" before creating subscriptions.
|
||||||
|
RESET client_min_messages;
|
||||||
|
SELECT pubname, puballtables, puballsequences FROM pg_publication WHERE pubname = 'regress_pub_for_allsequences_alltables';
|
||||||
|
pubname | puballtables | puballsequences
|
||||||
|
----------------------------------------+--------------+-----------------
|
||||||
|
regress_pub_for_allsequences_alltables | t | t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\dRp+ regress_pub_for_allsequences_alltables
|
||||||
|
Publication regress_pub_for_allsequences_alltables
|
||||||
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
|
regress_publication_user | t | t | t | t | t | t | none | f
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
DROP SEQUENCE regress_pub_seq0, pub_test.regress_pub_seq1;
|
||||||
|
DROP PUBLICATION regress_pub_forallsequences1;
|
||||||
|
DROP PUBLICATION regress_pub_forallsequences2;
|
||||||
|
DROP PUBLICATION regress_pub_for_allsequences_alltables;
|
||||||
|
DROP PUBLICATION regress_pub_for_allsequences_alltables_withclause;
|
||||||
|
DROP PUBLICATION regress_pub_for_allsequences_withclause;
|
||||||
|
-- fail - Specifying ALL TABLES more than once
|
||||||
|
CREATE PUBLICATION regress_pub_for_allsequences_alltables FOR ALL SEQUENCES, ALL TABLES, ALL TABLES;
|
||||||
|
ERROR: invalid publication object list
|
||||||
|
LINE 1: ...equences_alltables FOR ALL SEQUENCES, ALL TABLES, ALL TABLES...
|
||||||
|
^
|
||||||
|
DETAIL: ALL TABLES can be specified only once.
|
||||||
|
-- fail - Specifying ALL SEQUENCES more than once
|
||||||
|
CREATE PUBLICATION regress_pub_for_allsequences_alltables FOR ALL SEQUENCES, ALL TABLES, ALL SEQUENCES;
|
||||||
|
ERROR: invalid publication object list
|
||||||
|
LINE 1: ...equences_alltables FOR ALL SEQUENCES, ALL TABLES, ALL SEQUEN...
|
||||||
|
^
|
||||||
|
DETAIL: ALL SEQUENCES can be specified only once.
|
||||||
-- Tests for partitioned tables
|
-- Tests for partitioned tables
|
||||||
SET client_min_messages = 'ERROR';
|
SET client_min_messages = 'ERROR';
|
||||||
CREATE PUBLICATION testpub_forparted;
|
CREATE PUBLICATION testpub_forparted;
|
||||||
@@ -255,10 +341,10 @@ UPDATE testpub_parted1 SET a = 1;
|
|||||||
-- only parent is listed as being in publication, not the partition
|
-- only parent is listed as being in publication, not the partition
|
||||||
ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted;
|
ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted;
|
||||||
\dRp+ testpub_forparted
|
\dRp+ testpub_forparted
|
||||||
Publication testpub_forparted
|
Publication testpub_forparted
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_parted"
|
"public.testpub_parted"
|
||||||
|
|
||||||
@@ -273,10 +359,10 @@ ALTER TABLE testpub_parted DETACH PARTITION testpub_parted1;
|
|||||||
UPDATE testpub_parted1 SET a = 1;
|
UPDATE testpub_parted1 SET a = 1;
|
||||||
ALTER PUBLICATION testpub_forparted SET (publish_via_partition_root = true);
|
ALTER PUBLICATION testpub_forparted SET (publish_via_partition_root = true);
|
||||||
\dRp+ testpub_forparted
|
\dRp+ testpub_forparted
|
||||||
Publication testpub_forparted
|
Publication testpub_forparted
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | t
|
regress_publication_user | f | f | t | t | t | t | none | t
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_parted"
|
"public.testpub_parted"
|
||||||
|
|
||||||
@@ -305,10 +391,10 @@ SET client_min_messages = 'ERROR';
|
|||||||
CREATE PUBLICATION testpub5 FOR TABLE testpub_rf_tbl1, testpub_rf_tbl2 WHERE (c <> 'test' AND d < 5) WITH (publish = 'insert');
|
CREATE PUBLICATION testpub5 FOR TABLE testpub_rf_tbl1, testpub_rf_tbl2 WHERE (c <> 'test' AND d < 5) WITH (publish = 'insert');
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\dRp+ testpub5
|
\dRp+ testpub5
|
||||||
Publication testpub5
|
Publication testpub5
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | f | f | f | none | f
|
regress_publication_user | f | f | t | f | f | f | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_rf_tbl1"
|
"public.testpub_rf_tbl1"
|
||||||
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
|
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
|
||||||
@@ -321,10 +407,10 @@ Tables:
|
|||||||
|
|
||||||
ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000);
|
ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000);
|
||||||
\dRp+ testpub5
|
\dRp+ testpub5
|
||||||
Publication testpub5
|
Publication testpub5
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | f | f | f | none | f
|
regress_publication_user | f | f | t | f | f | f | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_rf_tbl1"
|
"public.testpub_rf_tbl1"
|
||||||
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
|
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
|
||||||
@@ -340,10 +426,10 @@ Publications:
|
|||||||
|
|
||||||
ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2;
|
ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2;
|
||||||
\dRp+ testpub5
|
\dRp+ testpub5
|
||||||
Publication testpub5
|
Publication testpub5
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | f | f | f | none | f
|
regress_publication_user | f | f | t | f | f | f | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_rf_tbl1"
|
"public.testpub_rf_tbl1"
|
||||||
"public.testpub_rf_tbl3" WHERE ((e > 1000) AND (e < 2000))
|
"public.testpub_rf_tbl3" WHERE ((e > 1000) AND (e < 2000))
|
||||||
@@ -351,10 +437,10 @@ Tables:
|
|||||||
-- remove testpub_rf_tbl1 and add testpub_rf_tbl3 again (another WHERE expression)
|
-- remove testpub_rf_tbl1 and add testpub_rf_tbl3 again (another WHERE expression)
|
||||||
ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500);
|
ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500);
|
||||||
\dRp+ testpub5
|
\dRp+ testpub5
|
||||||
Publication testpub5
|
Publication testpub5
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | f | f | f | none | f
|
regress_publication_user | f | f | t | f | f | f | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_rf_tbl3" WHERE ((e > 300) AND (e < 500))
|
"public.testpub_rf_tbl3" WHERE ((e > 300) AND (e < 500))
|
||||||
|
|
||||||
@@ -387,10 +473,10 @@ SET client_min_messages = 'ERROR';
|
|||||||
CREATE PUBLICATION testpub_syntax1 FOR TABLE testpub_rf_tbl1, ONLY testpub_rf_tbl3 WHERE (e < 999) WITH (publish = 'insert');
|
CREATE PUBLICATION testpub_syntax1 FOR TABLE testpub_rf_tbl1, ONLY testpub_rf_tbl3 WHERE (e < 999) WITH (publish = 'insert');
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\dRp+ testpub_syntax1
|
\dRp+ testpub_syntax1
|
||||||
Publication testpub_syntax1
|
Publication testpub_syntax1
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | f | f | f | none | f
|
regress_publication_user | f | f | t | f | f | f | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_rf_tbl1"
|
"public.testpub_rf_tbl1"
|
||||||
"public.testpub_rf_tbl3" WHERE (e < 999)
|
"public.testpub_rf_tbl3" WHERE (e < 999)
|
||||||
@@ -400,10 +486,10 @@ SET client_min_messages = 'ERROR';
|
|||||||
CREATE PUBLICATION testpub_syntax2 FOR TABLE testpub_rf_tbl1, testpub_rf_schema1.testpub_rf_tbl5 WHERE (h < 999) WITH (publish = 'insert');
|
CREATE PUBLICATION testpub_syntax2 FOR TABLE testpub_rf_tbl1, testpub_rf_schema1.testpub_rf_tbl5 WHERE (h < 999) WITH (publish = 'insert');
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\dRp+ testpub_syntax2
|
\dRp+ testpub_syntax2
|
||||||
Publication testpub_syntax2
|
Publication testpub_syntax2
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | f | f | f | none | f
|
regress_publication_user | f | f | t | f | f | f | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_rf_tbl1"
|
"public.testpub_rf_tbl1"
|
||||||
"testpub_rf_schema1.testpub_rf_tbl5" WHERE (h < 999)
|
"testpub_rf_schema1.testpub_rf_tbl5" WHERE (h < 999)
|
||||||
@@ -518,10 +604,10 @@ CREATE PUBLICATION testpub6 FOR TABLES IN SCHEMA testpub_rf_schema2;
|
|||||||
ALTER PUBLICATION testpub6 SET TABLES IN SCHEMA testpub_rf_schema2, TABLE testpub_rf_schema2.testpub_rf_tbl6 WHERE (i < 99);
|
ALTER PUBLICATION testpub6 SET TABLES IN SCHEMA testpub_rf_schema2, TABLE testpub_rf_schema2.testpub_rf_tbl6 WHERE (i < 99);
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\dRp+ testpub6
|
\dRp+ testpub6
|
||||||
Publication testpub6
|
Publication testpub6
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"testpub_rf_schema2.testpub_rf_tbl6" WHERE (i < 99)
|
"testpub_rf_schema2.testpub_rf_tbl6" WHERE (i < 99)
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
@@ -813,10 +899,10 @@ CREATE PUBLICATION testpub_table_ins WITH (publish = 'insert, truncate');
|
|||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
ALTER PUBLICATION testpub_table_ins ADD TABLE testpub_tbl5 (a); -- ok
|
ALTER PUBLICATION testpub_table_ins ADD TABLE testpub_tbl5 (a); -- ok
|
||||||
\dRp+ testpub_table_ins
|
\dRp+ testpub_table_ins
|
||||||
Publication testpub_table_ins
|
Publication testpub_table_ins
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | f | f | t | none | f
|
regress_publication_user | f | f | t | f | f | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_tbl5" (a)
|
"public.testpub_tbl5" (a)
|
||||||
|
|
||||||
@@ -1006,10 +1092,10 @@ CREATE TABLE testpub_tbl_both_filters (a int, b int, c int, PRIMARY KEY (a,c));
|
|||||||
ALTER TABLE testpub_tbl_both_filters REPLICA IDENTITY USING INDEX testpub_tbl_both_filters_pkey;
|
ALTER TABLE testpub_tbl_both_filters REPLICA IDENTITY USING INDEX testpub_tbl_both_filters_pkey;
|
||||||
ALTER PUBLICATION testpub_both_filters ADD TABLE testpub_tbl_both_filters (a,c) WHERE (c != 1);
|
ALTER PUBLICATION testpub_both_filters ADD TABLE testpub_tbl_both_filters (a,c) WHERE (c != 1);
|
||||||
\dRp+ testpub_both_filters
|
\dRp+ testpub_both_filters
|
||||||
Publication testpub_both_filters
|
Publication testpub_both_filters
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.testpub_tbl_both_filters" (a, c) WHERE (c <> 1)
|
"public.testpub_tbl_both_filters" (a, c) WHERE (c <> 1)
|
||||||
|
|
||||||
@@ -1217,10 +1303,10 @@ ERROR: relation "testpub_tbl1" is already member of publication "testpub_fortbl
|
|||||||
CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1;
|
CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1;
|
||||||
ERROR: publication "testpub_fortbl" already exists
|
ERROR: publication "testpub_fortbl" already exists
|
||||||
\dRp+ testpub_fortbl
|
\dRp+ testpub_fortbl
|
||||||
Publication testpub_fortbl
|
Publication testpub_fortbl
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"pub_test.testpub_nopk"
|
"pub_test.testpub_nopk"
|
||||||
"public.testpub_tbl1"
|
"public.testpub_tbl1"
|
||||||
@@ -1260,10 +1346,10 @@ Not-null constraints:
|
|||||||
"testpub_tbl1_id_not_null" NOT NULL "id"
|
"testpub_tbl1_id_not_null" NOT NULL "id"
|
||||||
|
|
||||||
\dRp+ testpub_default
|
\dRp+ testpub_default
|
||||||
Publication testpub_default
|
Publication testpub_default
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | f | none | f
|
regress_publication_user | f | f | t | t | t | f | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"pub_test.testpub_nopk"
|
"pub_test.testpub_nopk"
|
||||||
"public.testpub_tbl1"
|
"public.testpub_tbl1"
|
||||||
@@ -1334,7 +1420,7 @@ SET ROLE regress_publication_user3;
|
|||||||
-- fail - new owner must be superuser
|
-- fail - new owner must be superuser
|
||||||
ALTER PUBLICATION testpub4 owner to regress_publication_user2; -- fail
|
ALTER PUBLICATION testpub4 owner to regress_publication_user2; -- fail
|
||||||
ERROR: permission denied to change owner of publication "testpub4"
|
ERROR: permission denied to change owner of publication "testpub4"
|
||||||
HINT: The owner of a FOR TABLES IN SCHEMA publication must be a superuser.
|
HINT: The owner of a FOR ALL TABLES or ALL SEQUENCES or TABLES IN SCHEMA publication must be a superuser.
|
||||||
ALTER PUBLICATION testpub4 owner to regress_publication_user; -- ok
|
ALTER PUBLICATION testpub4 owner to regress_publication_user; -- ok
|
||||||
SET ROLE regress_publication_user;
|
SET ROLE regress_publication_user;
|
||||||
DROP PUBLICATION testpub4;
|
DROP PUBLICATION testpub4;
|
||||||
@@ -1343,10 +1429,10 @@ REVOKE CREATE ON DATABASE regression FROM regress_publication_user2;
|
|||||||
DROP TABLE testpub_parted;
|
DROP TABLE testpub_parted;
|
||||||
DROP TABLE testpub_tbl1;
|
DROP TABLE testpub_tbl1;
|
||||||
\dRp+ testpub_default
|
\dRp+ testpub_default
|
||||||
Publication testpub_default
|
Publication testpub_default
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | f | none | f
|
regress_publication_user | f | f | t | t | t | f | none | f
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- fail - must be owner of publication
|
-- fail - must be owner of publication
|
||||||
@@ -1356,20 +1442,20 @@ ERROR: must be owner of publication testpub_default
|
|||||||
RESET ROLE;
|
RESET ROLE;
|
||||||
ALTER PUBLICATION testpub_default RENAME TO testpub_foo;
|
ALTER PUBLICATION testpub_default RENAME TO testpub_foo;
|
||||||
\dRp testpub_foo
|
\dRp testpub_foo
|
||||||
List of publications
|
List of publications
|
||||||
Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Name | Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
-------------+--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
-------------+--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
testpub_foo | regress_publication_user | f | t | t | t | f | none | f
|
testpub_foo | regress_publication_user | f | f | t | t | t | f | none | f
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- rename back to keep the rest simple
|
-- rename back to keep the rest simple
|
||||||
ALTER PUBLICATION testpub_foo RENAME TO testpub_default;
|
ALTER PUBLICATION testpub_foo RENAME TO testpub_default;
|
||||||
ALTER PUBLICATION testpub_default OWNER TO regress_publication_user2;
|
ALTER PUBLICATION testpub_default OWNER TO regress_publication_user2;
|
||||||
\dRp testpub_default
|
\dRp testpub_default
|
||||||
List of publications
|
List of publications
|
||||||
Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Name | Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
-----------------+---------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
-----------------+---------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
testpub_default | regress_publication_user2 | f | t | t | t | f | none | f
|
testpub_default | regress_publication_user2 | f | f | t | t | t | f | none | f
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- adding schemas and tables
|
-- adding schemas and tables
|
||||||
@@ -1385,19 +1471,19 @@ CREATE TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA"(id int);
|
|||||||
SET client_min_messages = 'ERROR';
|
SET client_min_messages = 'ERROR';
|
||||||
CREATE PUBLICATION testpub1_forschema FOR TABLES IN SCHEMA pub_test1;
|
CREATE PUBLICATION testpub1_forschema FOR TABLES IN SCHEMA pub_test1;
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
|
|
||||||
CREATE PUBLICATION testpub2_forschema FOR TABLES IN SCHEMA pub_test1, pub_test2, pub_test3;
|
CREATE PUBLICATION testpub2_forschema FOR TABLES IN SCHEMA pub_test1, pub_test2, pub_test3;
|
||||||
\dRp+ testpub2_forschema
|
\dRp+ testpub2_forschema
|
||||||
Publication testpub2_forschema
|
Publication testpub2_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
"pub_test2"
|
"pub_test2"
|
||||||
@@ -1411,44 +1497,44 @@ CREATE PUBLICATION testpub6_forschema FOR TABLES IN SCHEMA "CURRENT_SCHEMA", CUR
|
|||||||
CREATE PUBLICATION testpub_fortable FOR TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA";
|
CREATE PUBLICATION testpub_fortable FOR TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA";
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\dRp+ testpub3_forschema
|
\dRp+ testpub3_forschema
|
||||||
Publication testpub3_forschema
|
Publication testpub3_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"public"
|
"public"
|
||||||
|
|
||||||
\dRp+ testpub4_forschema
|
\dRp+ testpub4_forschema
|
||||||
Publication testpub4_forschema
|
Publication testpub4_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"CURRENT_SCHEMA"
|
"CURRENT_SCHEMA"
|
||||||
|
|
||||||
\dRp+ testpub5_forschema
|
\dRp+ testpub5_forschema
|
||||||
Publication testpub5_forschema
|
Publication testpub5_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"CURRENT_SCHEMA"
|
"CURRENT_SCHEMA"
|
||||||
"public"
|
"public"
|
||||||
|
|
||||||
\dRp+ testpub6_forschema
|
\dRp+ testpub6_forschema
|
||||||
Publication testpub6_forschema
|
Publication testpub6_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"CURRENT_SCHEMA"
|
"CURRENT_SCHEMA"
|
||||||
"public"
|
"public"
|
||||||
|
|
||||||
\dRp+ testpub_fortable
|
\dRp+ testpub_fortable
|
||||||
Publication testpub_fortable
|
Publication testpub_fortable
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"CURRENT_SCHEMA.CURRENT_SCHEMA"
|
"CURRENT_SCHEMA.CURRENT_SCHEMA"
|
||||||
|
|
||||||
@@ -1482,10 +1568,10 @@ ERROR: schema "testpub_view" does not exist
|
|||||||
-- dropping the schema should reflect the change in publication
|
-- dropping the schema should reflect the change in publication
|
||||||
DROP SCHEMA pub_test3;
|
DROP SCHEMA pub_test3;
|
||||||
\dRp+ testpub2_forschema
|
\dRp+ testpub2_forschema
|
||||||
Publication testpub2_forschema
|
Publication testpub2_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
"pub_test2"
|
"pub_test2"
|
||||||
@@ -1493,20 +1579,20 @@ Tables from schemas:
|
|||||||
-- renaming the schema should reflect the change in publication
|
-- renaming the schema should reflect the change in publication
|
||||||
ALTER SCHEMA pub_test1 RENAME to pub_test1_renamed;
|
ALTER SCHEMA pub_test1 RENAME to pub_test1_renamed;
|
||||||
\dRp+ testpub2_forschema
|
\dRp+ testpub2_forschema
|
||||||
Publication testpub2_forschema
|
Publication testpub2_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1_renamed"
|
"pub_test1_renamed"
|
||||||
"pub_test2"
|
"pub_test2"
|
||||||
|
|
||||||
ALTER SCHEMA pub_test1_renamed RENAME to pub_test1;
|
ALTER SCHEMA pub_test1_renamed RENAME to pub_test1;
|
||||||
\dRp+ testpub2_forschema
|
\dRp+ testpub2_forschema
|
||||||
Publication testpub2_forschema
|
Publication testpub2_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
"pub_test2"
|
"pub_test2"
|
||||||
@@ -1514,10 +1600,10 @@ Tables from schemas:
|
|||||||
-- alter publication add schema
|
-- alter publication add schema
|
||||||
ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test2;
|
ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test2;
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
"pub_test2"
|
"pub_test2"
|
||||||
@@ -1526,10 +1612,10 @@ Tables from schemas:
|
|||||||
ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA non_existent_schema;
|
ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA non_existent_schema;
|
||||||
ERROR: schema "non_existent_schema" does not exist
|
ERROR: schema "non_existent_schema" does not exist
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
"pub_test2"
|
"pub_test2"
|
||||||
@@ -1538,10 +1624,10 @@ Tables from schemas:
|
|||||||
ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test1;
|
ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test1;
|
||||||
ERROR: schema "pub_test1" is already member of publication "testpub1_forschema"
|
ERROR: schema "pub_test1" is already member of publication "testpub1_forschema"
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
"pub_test2"
|
"pub_test2"
|
||||||
@@ -1549,10 +1635,10 @@ Tables from schemas:
|
|||||||
-- alter publication drop schema
|
-- alter publication drop schema
|
||||||
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2;
|
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2;
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
|
|
||||||
@@ -1560,10 +1646,10 @@ Tables from schemas:
|
|||||||
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2;
|
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2;
|
||||||
ERROR: tables from schema "pub_test2" are not part of the publication
|
ERROR: tables from schema "pub_test2" are not part of the publication
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
|
|
||||||
@@ -1571,29 +1657,29 @@ Tables from schemas:
|
|||||||
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA non_existent_schema;
|
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA non_existent_schema;
|
||||||
ERROR: schema "non_existent_schema" does not exist
|
ERROR: schema "non_existent_schema" does not exist
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
|
|
||||||
-- drop all schemas
|
-- drop all schemas
|
||||||
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test1;
|
ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test1;
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- alter publication set multiple schema
|
-- alter publication set multiple schema
|
||||||
ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test2;
|
ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test2;
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
"pub_test2"
|
"pub_test2"
|
||||||
@@ -1602,10 +1688,10 @@ Tables from schemas:
|
|||||||
ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA non_existent_schema;
|
ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA non_existent_schema;
|
||||||
ERROR: schema "non_existent_schema" does not exist
|
ERROR: schema "non_existent_schema" does not exist
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
"pub_test2"
|
"pub_test2"
|
||||||
@@ -1614,10 +1700,10 @@ Tables from schemas:
|
|||||||
-- removing the duplicate schemas
|
-- removing the duplicate schemas
|
||||||
ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test1;
|
ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test1;
|
||||||
\dRp+ testpub1_forschema
|
\dRp+ testpub1_forschema
|
||||||
Publication testpub1_forschema
|
Publication testpub1_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
|
|
||||||
@@ -1696,18 +1782,18 @@ SET client_min_messages = 'ERROR';
|
|||||||
CREATE PUBLICATION testpub3_forschema;
|
CREATE PUBLICATION testpub3_forschema;
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\dRp+ testpub3_forschema
|
\dRp+ testpub3_forschema
|
||||||
Publication testpub3_forschema
|
Publication testpub3_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
ALTER PUBLICATION testpub3_forschema SET TABLES IN SCHEMA pub_test1;
|
ALTER PUBLICATION testpub3_forschema SET TABLES IN SCHEMA pub_test1;
|
||||||
\dRp+ testpub3_forschema
|
\dRp+ testpub3_forschema
|
||||||
Publication testpub3_forschema
|
Publication testpub3_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
|
|
||||||
@@ -1717,20 +1803,20 @@ CREATE PUBLICATION testpub_forschema_fortable FOR TABLES IN SCHEMA pub_test1, TA
|
|||||||
CREATE PUBLICATION testpub_fortable_forschema FOR TABLE pub_test2.tbl1, TABLES IN SCHEMA pub_test1;
|
CREATE PUBLICATION testpub_fortable_forschema FOR TABLE pub_test2.tbl1, TABLES IN SCHEMA pub_test1;
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\dRp+ testpub_forschema_fortable
|
\dRp+ testpub_forschema_fortable
|
||||||
Publication testpub_forschema_fortable
|
Publication testpub_forschema_fortable
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"pub_test2.tbl1"
|
"pub_test2.tbl1"
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
"pub_test1"
|
"pub_test1"
|
||||||
|
|
||||||
\dRp+ testpub_fortable_forschema
|
\dRp+ testpub_fortable_forschema
|
||||||
Publication testpub_fortable_forschema
|
Publication testpub_fortable_forschema
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"pub_test2.tbl1"
|
"pub_test2.tbl1"
|
||||||
Tables from schemas:
|
Tables from schemas:
|
||||||
@@ -1851,18 +1937,18 @@ DROP SCHEMA sch2 cascade;
|
|||||||
SET client_min_messages = 'ERROR';
|
SET client_min_messages = 'ERROR';
|
||||||
CREATE PUBLICATION pub1 FOR ALL TABLES WITH (publish_generated_columns = stored);
|
CREATE PUBLICATION pub1 FOR ALL TABLES WITH (publish_generated_columns = stored);
|
||||||
\dRp+ pub1
|
\dRp+ pub1
|
||||||
Publication pub1
|
Publication pub1
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | t | t | t | t | t | stored | f
|
regress_publication_user | t | f | t | t | t | t | stored | f
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
CREATE PUBLICATION pub2 FOR ALL TABLES WITH (publish_generated_columns = none);
|
CREATE PUBLICATION pub2 FOR ALL TABLES WITH (publish_generated_columns = none);
|
||||||
\dRp+ pub2
|
\dRp+ pub2
|
||||||
Publication pub2
|
Publication pub2
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | t | t | t | t | t | none | f
|
regress_publication_user | t | f | t | t | t | t | none | f
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
DROP PUBLICATION pub1;
|
DROP PUBLICATION pub1;
|
||||||
@@ -1873,50 +1959,50 @@ CREATE TABLE gencols (a int, gen1 int GENERATED ALWAYS AS (a * 2) STORED);
|
|||||||
-- Generated columns in column list, when 'publish_generated_columns'='none'
|
-- Generated columns in column list, when 'publish_generated_columns'='none'
|
||||||
CREATE PUBLICATION pub1 FOR table gencols(a, gen1) WITH (publish_generated_columns = none);
|
CREATE PUBLICATION pub1 FOR table gencols(a, gen1) WITH (publish_generated_columns = none);
|
||||||
\dRp+ pub1
|
\dRp+ pub1
|
||||||
Publication pub1
|
Publication pub1
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.gencols" (a, gen1)
|
"public.gencols" (a, gen1)
|
||||||
|
|
||||||
-- Generated columns in column list, when 'publish_generated_columns'='stored'
|
-- Generated columns in column list, when 'publish_generated_columns'='stored'
|
||||||
CREATE PUBLICATION pub2 FOR table gencols(a, gen1) WITH (publish_generated_columns = stored);
|
CREATE PUBLICATION pub2 FOR table gencols(a, gen1) WITH (publish_generated_columns = stored);
|
||||||
\dRp+ pub2
|
\dRp+ pub2
|
||||||
Publication pub2
|
Publication pub2
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | stored | f
|
regress_publication_user | f | f | t | t | t | t | stored | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.gencols" (a, gen1)
|
"public.gencols" (a, gen1)
|
||||||
|
|
||||||
-- Generated columns in column list, then set 'publish_generated_columns'='none'
|
-- Generated columns in column list, then set 'publish_generated_columns'='none'
|
||||||
ALTER PUBLICATION pub2 SET (publish_generated_columns = none);
|
ALTER PUBLICATION pub2 SET (publish_generated_columns = none);
|
||||||
\dRp+ pub2
|
\dRp+ pub2
|
||||||
Publication pub2
|
Publication pub2
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.gencols" (a, gen1)
|
"public.gencols" (a, gen1)
|
||||||
|
|
||||||
-- Remove generated columns from column list, when 'publish_generated_columns'='none'
|
-- Remove generated columns from column list, when 'publish_generated_columns'='none'
|
||||||
ALTER PUBLICATION pub2 SET TABLE gencols(a);
|
ALTER PUBLICATION pub2 SET TABLE gencols(a);
|
||||||
\dRp+ pub2
|
\dRp+ pub2
|
||||||
Publication pub2
|
Publication pub2
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.gencols" (a)
|
"public.gencols" (a)
|
||||||
|
|
||||||
-- Add generated columns in column list, when 'publish_generated_columns'='none'
|
-- Add generated columns in column list, when 'publish_generated_columns'='none'
|
||||||
ALTER PUBLICATION pub2 SET TABLE gencols(a, gen1);
|
ALTER PUBLICATION pub2 SET TABLE gencols(a, gen1);
|
||||||
\dRp+ pub2
|
\dRp+ pub2
|
||||||
Publication pub2
|
Publication pub2
|
||||||
Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root
|
||||||
--------------------------+------------+---------+---------+---------+-----------+-------------------+----------
|
--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+----------
|
||||||
regress_publication_user | f | t | t | t | t | none | f
|
regress_publication_user | f | f | t | t | t | t | none | f
|
||||||
Tables:
|
Tables:
|
||||||
"public.gencols" (a, gen1)
|
"public.gencols" (a, gen1)
|
||||||
|
|
||||||
|
@@ -1462,6 +1462,14 @@ pg_prepared_xacts| SELECT p.transaction,
|
|||||||
FROM ((pg_prepared_xact() p(transaction, gid, prepared, ownerid, dbid)
|
FROM ((pg_prepared_xact() p(transaction, gid, prepared, ownerid, dbid)
|
||||||
LEFT JOIN pg_authid u ON ((p.ownerid = u.oid)))
|
LEFT JOIN pg_authid u ON ((p.ownerid = u.oid)))
|
||||||
LEFT JOIN pg_database d ON ((p.dbid = d.oid)));
|
LEFT JOIN pg_database d ON ((p.dbid = d.oid)));
|
||||||
|
pg_publication_sequences| SELECT p.pubname,
|
||||||
|
n.nspname AS schemaname,
|
||||||
|
c.relname AS sequencename
|
||||||
|
FROM pg_publication p,
|
||||||
|
LATERAL pg_get_publication_sequences((p.pubname)::text) gps(relid),
|
||||||
|
(pg_class c
|
||||||
|
JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
|
||||||
|
WHERE (c.oid = gps.relid);
|
||||||
pg_publication_tables| SELECT p.pubname,
|
pg_publication_tables| SELECT p.pubname,
|
||||||
n.nspname AS schemaname,
|
n.nspname AS schemaname,
|
||||||
c.relname AS tablename,
|
c.relname AS tablename,
|
||||||
|
@@ -120,6 +120,52 @@ RESET client_min_messages;
|
|||||||
DROP TABLE testpub_tbl3, testpub_tbl3a;
|
DROP TABLE testpub_tbl3, testpub_tbl3a;
|
||||||
DROP PUBLICATION testpub3, testpub4;
|
DROP PUBLICATION testpub3, testpub4;
|
||||||
|
|
||||||
|
--- Tests for publications with SEQUENCES
|
||||||
|
CREATE SEQUENCE regress_pub_seq0;
|
||||||
|
CREATE SEQUENCE pub_test.regress_pub_seq1;
|
||||||
|
|
||||||
|
-- FOR ALL SEQUENCES
|
||||||
|
SET client_min_messages = 'ERROR';
|
||||||
|
CREATE PUBLICATION regress_pub_forallsequences1 FOR ALL SEQUENCES;
|
||||||
|
RESET client_min_messages;
|
||||||
|
|
||||||
|
SELECT pubname, puballtables, puballsequences FROM pg_publication WHERE pubname = 'regress_pub_forallsequences1';
|
||||||
|
\d+ regress_pub_seq0
|
||||||
|
\dRp+ regress_pub_forallsequences1
|
||||||
|
|
||||||
|
SET client_min_messages = 'ERROR';
|
||||||
|
CREATE PUBLICATION regress_pub_forallsequences2 FOR ALL SEQUENCES;
|
||||||
|
RESET client_min_messages;
|
||||||
|
|
||||||
|
-- check that describe sequence lists both publications the sequence belongs to
|
||||||
|
\d+ pub_test.regress_pub_seq1
|
||||||
|
|
||||||
|
--- Specifying both ALL TABLES and ALL SEQUENCES
|
||||||
|
SET client_min_messages = 'ERROR';
|
||||||
|
CREATE PUBLICATION regress_pub_for_allsequences_alltables FOR ALL SEQUENCES, ALL TABLES;
|
||||||
|
|
||||||
|
-- Specifying WITH clause in an ALL SEQUENCES publication will emit a NOTICE.
|
||||||
|
SET client_min_messages = 'NOTICE';
|
||||||
|
CREATE PUBLICATION regress_pub_for_allsequences_alltables_withclause FOR ALL SEQUENCES, ALL TABLES WITH (publish = 'insert');
|
||||||
|
CREATE PUBLICATION regress_pub_for_allsequences_withclause FOR ALL SEQUENCES WITH (publish_generated_columns = 'stored');
|
||||||
|
RESET client_min_messages;
|
||||||
|
|
||||||
|
SELECT pubname, puballtables, puballsequences FROM pg_publication WHERE pubname = 'regress_pub_for_allsequences_alltables';
|
||||||
|
\dRp+ regress_pub_for_allsequences_alltables
|
||||||
|
|
||||||
|
DROP SEQUENCE regress_pub_seq0, pub_test.regress_pub_seq1;
|
||||||
|
DROP PUBLICATION regress_pub_forallsequences1;
|
||||||
|
DROP PUBLICATION regress_pub_forallsequences2;
|
||||||
|
DROP PUBLICATION regress_pub_for_allsequences_alltables;
|
||||||
|
DROP PUBLICATION regress_pub_for_allsequences_alltables_withclause;
|
||||||
|
DROP PUBLICATION regress_pub_for_allsequences_withclause;
|
||||||
|
|
||||||
|
-- fail - Specifying ALL TABLES more than once
|
||||||
|
CREATE PUBLICATION regress_pub_for_allsequences_alltables FOR ALL SEQUENCES, ALL TABLES, ALL TABLES;
|
||||||
|
|
||||||
|
-- fail - Specifying ALL SEQUENCES more than once
|
||||||
|
CREATE PUBLICATION regress_pub_for_allsequences_alltables FOR ALL SEQUENCES, ALL TABLES, ALL SEQUENCES;
|
||||||
|
|
||||||
-- Tests for partitioned tables
|
-- Tests for partitioned tables
|
||||||
SET client_min_messages = 'ERROR';
|
SET client_min_messages = 'ERROR';
|
||||||
CREATE PUBLICATION testpub_forparted;
|
CREATE PUBLICATION testpub_forparted;
|
||||||
|
@@ -2354,6 +2354,8 @@ PsqlScanStateData
|
|||||||
PsqlSettings
|
PsqlSettings
|
||||||
Publication
|
Publication
|
||||||
PublicationActions
|
PublicationActions
|
||||||
|
PublicationAllObjSpec
|
||||||
|
PublicationAllObjType
|
||||||
PublicationDesc
|
PublicationDesc
|
||||||
PublicationInfo
|
PublicationInfo
|
||||||
PublicationObjSpec
|
PublicationObjSpec
|
||||||
|
Reference in New Issue
Block a user