バージョンごとのドキュメント一覧

ALTER SUBSCRIPTION

ALTER SUBSCRIPTION <refpurpose>change the definition of a subscription</refpurpose> — サブスクリプションの定義を変更する

概要

ALTER SUBSCRIPTION name CONNECTION 'conninfo'
ALTER SUBSCRIPTION name SET PUBLICATION publication_name [, ...] [ WITH ( publication_option [= value] [, ... ] ) ]
ALTER SUBSCRIPTION name ADD PUBLICATION publication_name [, ...] [ WITH ( publication_option [= value] [, ... ] ) ]
ALTER SUBSCRIPTION name DROP PUBLICATION publication_name [, ...] [ WITH ( publication_option [= value] [, ... ] ) ]
ALTER SUBSCRIPTION name REFRESH PUBLICATION [ WITH ( refresh_option [= value] [, ... ] ) ]
ALTER SUBSCRIPTION name ENABLE
ALTER SUBSCRIPTION name DISABLE
ALTER SUBSCRIPTION name SET ( subscription_parameter [= value] [, ... ] )
ALTER SUBSCRIPTION name SKIP ( skip_option = value )
ALTER SUBSCRIPTION name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER SUBSCRIPTION name RENAME TO new_name

説明

<title>Description</title>

<command>ALTER SUBSCRIPTION</command> can change most of the subscription properties that can be specified in <xref linkend="sql-createsubscription"/>. ALTER SUBSCRIPTIONCREATE 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> and <command>ALTER SUBSCRIPTION ... {SET|ADD|DROP} PUBLICATION ...</command> with <literal>refresh</literal> option as <literal>true</literal> cannot be executed inside a transaction block. コマンドALTER SUBSCRIPTION ... REFRESH PUBLICATIONrefreshオプションがtrueALTER SUBSCRIPTION ... {SET|ADD|DROP} PUBLICATION ...は、トランザクションブロック内では実行できません。 These commands also cannot be executed when the subscription has <link linkend="sql-createsubscription-with-two-phase"><literal>two_phase</literal></link> commit enabled, unless <link linkend="sql-createsubscription-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_datafalseでない限り、これらのコマンドは実行できません。 実際の2相状態を知るには、pg_subscriptionsubtwophasestate列を参照してください。

パラメータ

<title>Parameters</title>
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_name
ADD PUBLICATION publication_name
DROP 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はパブリケーションをパブリケーションのリストから削除します。 ユーザーが後から追加できるよう存在しないパブリケーションをADDSETで指定することを許容します。 詳細は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 <command>CREATE SUBSCRIPTION</command> 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-with-origin"><literal>origin</literal></link> parameter. copy_data = trueoriginパラメータとどのように相互作用するかの詳細については、注釈を参照してください。

See the <link linkend="sql-createsubscription-with-binary"><literal>binary</literal></link> parameter of <command>CREATE SUBSCRIPTION</command> for details about copying pre-existing data in binary format. バイナリ形式の既存のデータをコピーする詳細については、CREATE SUBSCRIPTIONbinaryパラメータを参照してください。

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-with-slot-name"><literal>slot_name</literal></link>, <link linkend="sql-createsubscription-with-synchronous-commit"><literal>synchronous_commit</literal></link>, <link linkend="sql-createsubscription-with-binary"><literal>binary</literal></link>, <link linkend="sql-createsubscription-with-streaming"><literal>streaming</literal></link>, <link linkend="sql-createsubscription-with-disable-on-error"><literal>disable_on_error</literal></link>, <link linkend="sql-createsubscription-with-password-required"><literal>password_required</literal></link>, <link linkend="sql-createsubscription-with-run-as-owner"><literal>run_as_owner</literal></link>, and <link linkend="sql-createsubscription-with-origin"><literal>origin</literal></link>. Only a superuser can set <literal>password_required = false</literal>. この句では、元はCREATE SUBSCRIPTIONにより設定されたパラメータを変更します。 詳細な情報はそちらを参照してください。 変更できるパラメータは、 slot_namesynchronous_commitbinarystreamingdisable_on_errorpassword_requiredrun_as_ownerorigin です。 スーパーユーザだけがpassword_required = 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-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に格納されています)がクリアされます。 論理レプリケーションの競合の詳細については31.5を参照してください。

<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を指定するのと同じです。

<title>Examples</title>

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;

互換性

<title>Compatibility</title>

<command>ALTER SUBSCRIPTION</command> is a <productname>PostgreSQL</productname> extension. ALTER SUBSCRIPTIONPostgreSQLの拡張です。

関連項目

<title>See Also</title> CREATE SUBSCRIPTION, DROP SUBSCRIPTION, CREATE PUBLICATION, ALTER PUBLICATION