ALTER SUBSCRIPTION <refpurpose>change the definition of a subscription</refpurpose> — サブスクリプションの定義を変更する
ALTER SUBSCRIPTIONnameCONNECTION 'conninfo' ALTER SUBSCRIPTIONnameSET PUBLICATIONpublication_name[, ...] [ WITH (publication_option[=value] [, ... ] ) ] ALTER SUBSCRIPTIONnameADD PUBLICATIONpublication_name[, ...] [ WITH (publication_option[=value] [, ... ] ) ] ALTER SUBSCRIPTIONnameDROP PUBLICATIONpublication_name[, ...] [ WITH (publication_option[=value] [, ... ] ) ] ALTER SUBSCRIPTIONnameREFRESH PUBLICATION [ WITH (refresh_option[=value] [, ... ] ) ] ALTER SUBSCRIPTIONnameENABLE ALTER SUBSCRIPTIONnameDISABLE ALTER SUBSCRIPTIONnameSET (subscription_parameter[=value] [, ... ] ) ALTER SUBSCRIPTIONnameSKIP (skip_option=value) ALTER SUBSCRIPTIONnameOWNER TO {new_owner| CURRENT_ROLE | CURRENT_USER | SESSION_USER } ALTER SUBSCRIPTIONnameRENAME TOnew_name
<command>ALTER SUBSCRIPTION</command> can change most of the subscription
properties that can be specified
in <xref linkend="sql-createsubscription"/>.
ALTER SUBSCRIPTIONはCREATE SUBSCRIPTIONで指定できるサブスクリプションの属性のほとんどを変更できます。
You must own the subscription to use <command>ALTER SUBSCRIPTION</command>.
To rename a subscription or alter the owner, you must have
<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.
ALTER SUBSCRIPTIONを使用するには、そのサブスクリプションを所有していなければなりません。
サブスクリプションの名前を変更したり、所有者を変更したりするには、データベースに対するCREATE権限が必要です。
さらに、所有者を変更するには、新しい所有者ロールに対してSET ROLEができなければなりません。
所有者を変更するには、また、そのロールは型のスキーマにおいてCREATE権限を持たなければなりません。
サブスクリプションがpassword_required=falseである場合、スーパーユーザのみが変更できます。
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"/>. パブリケーションを更新するときには、もうパブリケーションの一部ではないリレーションを削除し、存在すればテーブル同期スロットも削除します。 リモートホストでサブスクリプションのために割り当てられたリソースを解放するために、これらのスロットを解放することが必要です。 ネットワーク切れやその他のエラーによりPostgreSQLがスロットを削除できなかった場合、エラーが報告されます。 この状況で処理を進めるためには、ユーザは操作を再度試みるか、または、スロットをサブスクリプションから切り離し、DROP SUBSCRIPTIONで説明するようサブスクリプションを削除することが必要です。
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.
コマンドALTER SUBSCRIPTION ... REFRESH PUBLICATIONとrefreshオプションがtrueのALTER SUBSCRIPTION ... {SET|ADD|DROP} PUBLICATION ...、ALTER SUBSCRIPTION ... SET (failover = true|false)、そしてALTER SUBSCRIPTION ... SET (two_phase = false)は、トランザクションブロック内では実行できません。
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.
サブスクリプションがtwo_phaseコミットを有効にしている場合でも、copy_dataがfalseでない限り、コマンドALTER SUBSCRIPTION ... REFRESH PUBLICATIONとrefreshオプションがtrueのALTER SUBSCRIPTION ... {SET|ADD|DROP} PUBLICATION ...は実行できません。
実際の2相状態を知るには、pg_subscriptionのsubtwophasestate列を参照してください。
name #The name of a subscription whose properties are to be altered. 属性の変更の対象となるサブスクリプションの名前です。
CONNECTION 'conninfo' #This clause replaces the connection string originally set by <xref linkend="sql-createsubscription"/>. See there for more information. この句では、元はCREATE SUBSCRIPTIONにより設定された接続文字列を置き換えます。 詳細な情報はそちらを参照してください。
SET PUBLICATION publication_nameADD PUBLICATION publication_nameDROP PUBLICATION publication_name #
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>.
この形式はサブスクライブするパブリケーションのリストを変更します。
SETはパブリケーションのリスト全体を新しいリストで置き換え、ADDは追加のパブリケーションをパブリケーションのリストに追加し、DROPはパブリケーションをパブリケーションのリストから削除します。
ユーザが後から追加できるよう存在しないパブリケーションをADDやSETで指定することを許容します。
詳細はCREATE SUBSCRIPTIONを参照してください。
デフォルトでは、このコマンドはREFRESH PUBLICATIONのような動作もします。
<replaceable>publication_option</replaceable> specifies additional
options for this operation. The supported options are:
publication_optionは、この操作についての追加のオプションを指定します。
以下のオプションがサポートされています。
refresh (boolean)
When false, the command will not try to refresh table information.
<literal>REFRESH PUBLICATION</literal> should then be executed separately.
The default is <literal>true</literal>.
falseにすると、このコマンドはテーブル情報を更新しません。
後で別にREFRESH PUBLICATIONを実行することになります。
デフォルトはtrueです。
Additionally, the options described under
<literal>REFRESH PUBLICATION</literal> may be specified, to control the
implicit refresh operation.
さらに、暗黙の更新動作を制御するためにREFRESH PUBLICATIONの項で説明されているオプションを指定できます。
REFRESH PUBLICATION #
Fetch missing table information from publisher. This will start
replication of tables that were added to the subscribed-to publications
since <link linkend="sql-createsubscription">
<command>CREATE SUBSCRIPTION</command></link> or
the last invocation of <command>REFRESH PUBLICATION</command>.
不足しているテーブル情報をパブリッシャーから取得します。
CREATE SUBSCRIPTION、あるいは最後のREFRESH PUBLICATIONの実行の後でサブスクライブ対象のパブリケーションに追加されたテーブルの複製が、これにより開始されます。
<replaceable>refresh_option</replaceable> specifies additional options for the
refresh operation. The supported options are:
refresh_optionは更新(refresh)の操作について追加のオプションを指定します。
以下のオプションがサポートされています。
copy_data (boolean)
Specifies whether to copy pre-existing data in the publications
that are being subscribed to when the replication starts.
The default is <literal>true</literal>.
サブスクライブ対象のパブリケーションにある既存のデータが、レプリケーションの開始時にコピーされるかどうかを指定します。
デフォルトはtrueです。
Previously subscribed tables are not copied, even if a table's row
filter <literal>WHERE</literal> clause has since been modified.
テーブルの行フィルタWHERE句が変更されていても、以前にサブスクライブされたテーブルはコピーされません。
See <xref linkend="sql-createsubscription-notes"/> for details of
how <literal>copy_data = true</literal> can interact with the
<link linkend="sql-createsubscription-params-with-origin"><literal>origin</literal></link>
parameter.
copy_data = trueがoriginパラメータとどのように相互作用するかの詳細については、注釈を参照してください。
See the
<link linkend="sql-createsubscription-params-with-binary"><literal>binary</literal></link>
parameter of <command>CREATE SUBSCRIPTION</command> for details about
copying pre-existing data in binary format.
バイナリ形式の既存のデータをコピーする詳細については、CREATE SUBSCRIPTIONのbinaryパラメータを参照してください。
ENABLE #Enables a previously disabled subscription, starting the logical replication worker at the end of the transaction. 以前に無効化されたサブスクリプションを有効化し、トランザクションの終了時に論理レプリケーションワーカーを起動します。
DISABLE #Disables a running subscription, stopping the logical replication worker at the end of the transaction. 実行中のサブスクリプションを無効化し、トランザクションの終了時に論理レプリケーションワーカーを停止します。
SET ( subscription_parameter [= value] [, ... ] ) #
This clause alters parameters originally set by
<xref linkend="sql-createsubscription"/>. See there for more
information. The parameters that can be altered are
<link linkend="sql-createsubscription-params-with-slot-name"><literal>slot_name</literal></link>,
<link linkend="sql-createsubscription-params-with-synchronous-commit"><literal>synchronous_commit</literal></link>,
<link linkend="sql-createsubscription-params-with-binary"><literal>binary</literal></link>,
<link linkend="sql-createsubscription-params-with-streaming"><literal>streaming</literal></link>,
<link linkend="sql-createsubscription-params-with-disable-on-error"><literal>disable_on_error</literal></link>,
<link linkend="sql-createsubscription-params-with-password-required"><literal>password_required</literal></link>,
<link linkend="sql-createsubscription-params-with-run-as-owner"><literal>run_as_owner</literal></link>,
<link linkend="sql-createsubscription-params-with-origin"><literal>origin</literal></link>,
<link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>, and
<link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>.
Only a superuser can set <literal>password_required = false</literal>.
この句では、元はCREATE SUBSCRIPTIONにより設定されたパラメータを変更します。
詳細な情報はそちらを参照してください。
変更できるパラメータは、
slot_name、
synchronous_commit、
binary、
streaming、
disable_on_error、
password_required、
run_as_owner、
origin、
failover、そして
two_phase
です。
スーパーユーザだけがpassword_required = falseを設定できます。
When altering the
<link linkend="sql-createsubscription-params-with-slot-name"><literal>slot_name</literal></link>,
the <literal>failover</literal> and <literal>two_phase</literal> property
values of the named slot may differ from the counterpart
<link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>
and <link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>
parameters specified in the subscription. When creating the slot, ensure
the slot properties <literal>failover</literal> and <literal>two_phase</literal>
match their counterpart parameters of the subscription.
Otherwise, the slot on the publisher may behave differently from what these
subscription options say: for example, the slot on the publisher could either be
synced to the standbys even when the subscription's
<link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>
option is disabled or could be disabled for sync
even when the subscription's
<link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>
option is enabled.
slot_nameを変更する際、指定されたスロットのfailoverとtwo_phaseの値が、サブスクリプションで指定された対応するfailoverおよびtwo_phaseパラメータと異なる可能性があります。
スロットを作成する際、スロットプロパティのfailoverおよびtwo_phaseが対応するサブスクリプションパラメータと一致することを確認してください。
そうしないと、パブリッシャー上のスロットがこれらサブスクリプションオプションで指定されている内容とは異なる動作をする場合があります。
例えば、サブスクリプションオプションのfailoverが無効になっていても、パブリッシャー上のスロットがスタンバイと同期されたり、逆にサブスクリプションオプションのfailoverが有効になっている場合でも、同期が行われなかったりする可能性があります。
The <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>
and <link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>
parameters can only be altered when the subscription is disabled.
failoverおよびtwo_phaseパラメータは、サブスクリプションが無効になっている場合にのみ変更できます。
When altering <link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>
from <literal>true</literal> to <literal>false</literal>, the backend
process reports an error if any prepared transactions done by the
logical replication worker (from when <literal>two_phase</literal>
parameter was still <literal>true</literal>) are found. You can resolve
prepared transactions on the publisher node, or manually roll back them
on the subscriber, and then try again. The transactions prepared by
logical replication worker corresponding to a particular subscription have
the following pattern: <quote><literal>pg_gid_%u_%u</literal></quote>
(parameters: subscription <parameter>oid</parameter>, remote transaction id <parameter>xid</parameter>).
To resolve such transactions manually, you need to roll back all
the prepared transactions with corresponding subscription IDs in their
names. Applications can check
<link linkend="view-pg-prepared-xacts"><structname>pg_prepared_xacts</structname></link>
to find the required prepared transactions. After the <literal>two_phase</literal>
option is changed from <literal>true</literal> to <literal>false</literal>,
the publisher will replicate the transactions again when they are committed.
two_phaseをtrueからfalseに変更する際、適用ワーカーによって実行されたプリペアドトランザクション(two_phaseパラメータがまだtrueだった時点から)が見つかった場合は、バックエンドプロセスはエラーを報告します。
パブリッシャーノードでプリペアドトランザクションを解決するか、サブスクライバーノードで手動ロールバックを行ってから再試行することができます。
特定のサブスクリプションに対応する適用ワーカーによって準備されたトランザクションは次のようなパターンを持ちます。
「pg_gid_%u_%u」(パラメータ:サブスクリプションoid、リモートトランザクションIDxid)。
このようなトランザクションを手動で解決するには、関連するサブスクリプションIDを名前に持つすべてのプリペアドトランザクションをロールバックする必要があります。
アプリケーションはpg_prepared_xactsを確認して、必要なプリペアドトランザクションを見つけることができます。
two_phaseオプションをtrueからfalseに変更すると、パブリッシャーはそれらのトランザクションがコミットされたときに再度レプリケートします。
SKIP ( skip_option = value ) #
Skips applying all changes of the remote transaction. If incoming data
violates any constraints, logical replication will stop until it is
resolved. By using the <command>ALTER SUBSCRIPTION ... SKIP</command> command,
the logical replication worker skips all data modification changes within
the transaction. This option has no effect on the transactions that are
already prepared by enabling
<link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>
on the subscriber.
After the logical replication worker successfully skips the transaction or
finishes a transaction, the LSN (stored in
<structname>pg_subscription</structname>.<structfield>subskiplsn</structfield>)
is cleared. See <xref linkend="logical-replication-conflicts"/> for
the details of logical replication conflicts.
リモートトランザクションのすべての変更の適用をスキップします。
受信データが何らかの制約に違反している場合、解決されるまで論理レプリケーションは停止します。
ALTER SUBSCRIPTION ... SKIPコマンドを使用すると、論理レプリケーションワーカーはトランザクション内のすべてのデータ修正変更をスキップします。
このオプションは、サブスクライバーでtwo_phaseを有効にしてすでに準備されているトランザクションには影響しません。
論理レプリケーションワーカーがトランザクションをスキップするかトランザクションを終了することに成功した後、LSN(pg_subscription.subskiplsnに格納されています)がクリアされます。
論理レプリケーションの競合の詳細については29.7を参照してください。
<replaceable>skip_option</replaceable> specifies options for this operation.
The supported option is:
skip_optionは、この操作のオプションを指定します。
サポートされているオプションは以下の通りです。
lsn (pg_lsn)
Specifies the finish LSN of the remote transaction whose changes
are to be skipped by the logical replication worker. The finish LSN
is the LSN at which the transaction is either committed or prepared.
Skipping individual subtransactions is not supported. Setting
<literal>NONE</literal> resets the LSN.
論理レプリケーションワーカーによって変更がスキップされるリモートトランザクションの終了LSNを指定します。
終了LSNは、トランザクションがコミットまたは準備されるLSNです。
個々のサブトランザクションのスキップはサポートされません。
NONEを設定すると、LSNがリセットされます。
new_owner #The user name of the new owner of the subscription. サブスクリプションの新しい所有者のユーザ名です。
new_name #The new name for the subscription. サブスクリプションの新しい名前です。
When specifying a parameter of type <type>boolean</type>, the
<literal>=</literal> <replaceable class="parameter">value</replaceable>
part can be omitted, which is equivalent to
specifying <literal>TRUE</literal>.
boolean型のパラメータを指定する場合、= valueの部分を省略できます。これはTRUEを指定するのと同じです。
Change the publication subscribed by a subscription to
<literal>insert_only</literal>:
サブスクリプションがサブスクライブするパブリケーションをinsert_onlyに変更します。
ALTER SUBSCRIPTION mysub SET PUBLICATION insert_only;
Disable (stop) the subscription: サブスクリプションを無効化(停止)します。
ALTER SUBSCRIPTION mysub DISABLE;
<command>ALTER SUBSCRIPTION</command> is a <productname>PostgreSQL</productname>
extension.
ALTER SUBSCRIPTIONはPostgreSQLの拡張です。