Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/ref/alter_subscription.sgml`
3c9078fd29f10d3c2f58c255a286af4ed02126253124b0380000000100000fa1
 <literal>CREATE</literal> permission on the database. In addition,
   to alter the owner, you must be able to <literal>SET ROLE</literal> to the
   new owning role. If the subscription has
   <literal>password_required=false</literal>, only superusers can modify it.
  </para>

  <para>
   When refreshing a publication we remove the relations that are no longer
   part of the publication and we also remove the table synchronization slots
   if there are any. It is necessary to remove these slots so that the resources
   allocated for the subscription on the remote host are released. If due to
   network breakdown or some other error, <productname>PostgreSQL</productname>
   is unable to remove the slots, an error will be reported. To proceed in this
   situation, the user either needs to retry the operation or disassociate the
   slot from the subscription and drop the subscription as explained in
   <xref linkend="sql-dropsubscription"/>.
  </para>

  <para>
   Commands <command>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</command>,
   <command>ALTER SUBSCRIPTION ... {SET|ADD|DROP} PUBLICATION ...</command>
   with <literal>refresh</literal> option as <literal>true</literal>,
   <command>ALTER SUBSCRIPTION ... SET (failover = true|false)</command> and
   <command>ALTER SUBSCRIPTION ... SET (two_phase = false)</command>
   cannot be executed inside a transaction block.
  </para>

  <para>
   Commands <command>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</command> and
   <command>ALTER SUBSCRIPTION ... {SET|ADD|DROP} PUBLICATION ...</command>
   with <literal>refresh</literal> option as <literal>true</literal> also cannot
   be executed when the subscription has
   <link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>
   commit enabled, unless
   <link linkend="sql-createsubscription-params-with-copy-data"><literal>copy_data</literal></link>
   is <literal>false</literal>. See column <structfield>subtwophasestate</structfield>
   of <link linkend="catalog-pg-subscription"><structname>pg_subscription</structname></link>
   to know the actual two-phase state.
  </para>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

  <variablelist>
   <varlistentry id="sql-altersubscription-params-name">
    <term><replaceable class="parameter">name</replaceable></term>
    <listitem>
     <para>
      The name of a subscription whose properties are to be altered.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="sql-altersubscription-params-connection">
    <term><literal>CONNECTION '<replaceable class="parameter">conninfo</replaceable>'</literal></term>
    <listitem>
     <para>
      This clause replaces the connection string originally set by
      <xref linkend="sql-createsubscription"/>.  See there for more
      information.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="sql-altersubscription-params-setadddrop-publication">
    <term><literal>SET PUBLICATION <replaceable class="parameter">publication_name</replaceable></literal></term>
    <term><literal>ADD PUBLICATION <replaceable class="parameter">publication_name</replaceable></literal></term>
    <term><literal>DROP PUBLICATION <replaceable class="parameter">publication_name</replaceable></literal></term>
    <listitem>
     <para>
      These forms change the list of subscribed publications.
      <literal>SET</literal>
      replaces the entire list of publications with a new list,
      <literal>ADD</literal> adds additional publications to the list of
      publications, and <literal>DROP</literal> removes the publications from
      the list of publications.  We allow non-existent publications to be
      specified in <literal>ADD</literal> and <literal>SET</literal> variants
      so that users can add those later.  See <xref linkend="sql-createsubscription"/>
      for more information.  By default, this command will also act like
      <literal>REFRESH PUBLICATION</literal>.
     </para>

Title: ALTER SUBSCRIPTION continued: Restrictions and Parameters
Summary
This section describes restrictions on using ALTER SUBSCRIPTION, particularly regarding transaction blocks and two-phase commit. Certain ALTER SUBSCRIPTION commands, especially those involving refreshing or modifying publications, cannot be executed within a transaction block or when two-phase commit is enabled, unless copy_data is false. The section then details the parameters that can be used with ALTER SUBSCRIPTION, including name, CONNECTION, and commands to SET, ADD, or DROP publications. These commands allow modifying the list of publications to which the subscription is subscribed.