Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
ALTER SUBSCRIPTION
Prev UpSQL CommandsHome Next

ALTER SUBSCRIPTION

ALTER SUBSCRIPTION — change the definition of a subscription

Synopsis

ALTER SUBSCRIPTIONname CONNECTION 'conninfo'ALTER SUBSCRIPTIONname SET PUBLICATIONpublication_name [, ...] [ WITH (publication_option [=value] [, ... ] ) ]ALTER SUBSCRIPTIONname ADD PUBLICATIONpublication_name [, ...] [ WITH (publication_option [=value] [, ... ] ) ]ALTER SUBSCRIPTIONname DROP PUBLICATIONpublication_name [, ...] [ WITH (publication_option [=value] [, ... ] ) ]ALTER SUBSCRIPTIONname REFRESH PUBLICATION [ WITH (refresh_option [=value] [, ... ] ) ]ALTER SUBSCRIPTIONname ENABLEALTER SUBSCRIPTIONname DISABLEALTER SUBSCRIPTIONname SET (subscription_parameter [=value] [, ... ] )ALTER SUBSCRIPTIONname SKIP (skip_option =value )ALTER SUBSCRIPTIONname OWNER TO {new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }ALTER SUBSCRIPTIONname RENAME TOnew_name

Description

ALTER SUBSCRIPTION can change most of the subscription properties that can be specified inCREATE SUBSCRIPTION.

You must own the subscription to useALTER SUBSCRIPTION. To alter the owner, you must also be a direct or indirect member of the new owning role. The new owner has to be a superuser. (Currently, all subscription owners must be superusers, so the owner checks will be bypassed in practice. But this might change in the future.)

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,Postgres Pro 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 inDROP SUBSCRIPTION.

CommandsALTER SUBSCRIPTION ... REFRESH PUBLICATION andALTER SUBSCRIPTION ... {SET|ADD|DROP} PUBLICATION ... withrefresh option astrue cannot be executed inside a transaction block. These commands also cannot be executed when the subscription hastwo_phase commit enabled, unlesscopy_data isfalse. See columnsubtwophasestate ofpg_subscription to know the actual two-phase state.

Parameters

name

The name of a subscription whose properties are to be altered.

CONNECTION 'conninfo'

This clause replaces the connection string originally set byCREATE SUBSCRIPTION. See there for more information.

SET PUBLICATIONpublication_name
ADD PUBLICATIONpublication_name
DROP PUBLICATIONpublication_name

These forms change the list of subscribed publications.SET replaces the entire list of publications with a new list,ADD adds additional publications to the list of publications, andDROP removes the publications from the list of publications. We allow non-existent publications to be specified inADD andSET variants so that users can add those later. SeeCREATE SUBSCRIPTION for more information. By default, this command will also act likeREFRESH PUBLICATION.

publication_option specifies additional options for this operation. The supported options are:

refresh (boolean)

When false, the command will not try to refresh table information.REFRESH PUBLICATION should then be executed separately. The default istrue.

Additionally, the options described underREFRESH PUBLICATION may be specified, to control the implicit refresh operation.

REFRESH PUBLICATION

Fetch missing table information from publisher. This will start replication of tables that were added to the subscribed-to publications sinceCREATE SUBSCRIPTION or the last invocation ofREFRESH PUBLICATION.

refresh_option specifies additional options for the refresh operation. The supported options are:

copy_data (boolean)

Specifies whether to copy pre-existing data in the publications that are being subscribed to when the replication starts. The default istrue.

Previously subscribed tables are not copied, even if a table's row filterWHERE clause has since been modified.

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 byCREATE SUBSCRIPTION. See there for more information. The parameters that can be altered areslot_name,synchronous_commit,binary,streaming, anddisable_on_error.

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 theALTER SUBSCRIPTION ... SKIP 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 enablingtwo_phase on subscriber. After the logical replication worker successfully skips the transaction or finishes a transaction, the LSN (stored inpg_subscription.subskiplsn) is cleared. SeeSection 29.5 for the details of logical replication conflicts. Using this command requires superuser privilege.

skip_option specifies options for this operation. The supported option is:

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. SettingNONE resets the LSN.

new_owner

The user name of the new owner of the subscription.

new_name

The new name for the subscription.

Examples

Change the publication subscribed by a subscription toinsert_only:

ALTER SUBSCRIPTION mysub SET PUBLICATION insert_only;

Disable (stop) the subscription:

ALTER SUBSCRIPTION mysub DISABLE;

Compatibility

ALTER SUBSCRIPTION is aPostgres Pro extension.


Prev Up Next
ALTER STATISTICS Home ALTER SYSTEM
pdfepub
Go to Postgres Pro Standard 15
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp