Typically, a table at the subscriber will be defined the same as the
publisher table, so if the publisher table has a <link linkend="ddl-generated-columns">
<literal>GENERATED column</literal></link> then the subscriber table will
have a matching generated column. In this case, it is always the subscriber
table generated column value that is used.
《機械翻訳》通常、サブスクライバーの表はパブリッシャーテーブルと同じように定義されるため、パブリッシャーテーブルにGENERATED column
がある場合、サブスクライバーテーブルにはマッチングによって生成されたカラムが含まれます。
このケースでは、常にサブスクライバーテーブルによって生成されたカラム値が使用されます。
For example, note below that subscriber table generated column value comes from the subscriber column's calculation. 《機械翻訳》例の場合、そのサブスクライバーテーブルの下のノートは、サブスクライバーカラムの計算から生成されたカラム値になります。
/* pub # */ CREATE TABLE tab_gen_to_gen (a int, b int GENERATED ALWAYS AS (a + 1) STORED); /* pub # */ INSERT INTO tab_gen_to_gen VALUES (1),(2),(3); /* pub # */ CREATE PUBLICATION pub1 FOR TABLE tab_gen_to_gen; /* pub # */ SELECT * FROM tab_gen_to_gen; a | b ---+--- 1 | 2 2 | 3 3 | 4 (3 rows) /* sub # */ CREATE TABLE tab_gen_to_gen (a int, b int GENERATED ALWAYS AS (a * 100) STORED); /* sub # */ CREATE SUBSCRIPTION sub1 CONNECTION 'dbname=test_pub' PUBLICATION pub1; /* sub # */ SELECT * from tab_gen_to_gen; a | b ---+---- 1 | 100 2 | 200 3 | 300 (3 rows)
In fact, prior to version 18.0, logical replication does not publish
<literal>GENERATED</literal> columns at all.
《機械翻訳》実際、18.0年のバージョン以前には、論理レプリケーションはパブリッシュしないGENERATED
コラムは全くない。
But, replicating a generated column to a regular column can sometimes be desirable. 《機械翻訳》しかし、生成されたカラムを通常のカラムに複製することが望ましい場合もある。
This feature may be useful when replicating data to a non-PostgreSQL database via output plugin, especially if the target database does not support generated columns. 《機械翻訳》この機能は、特にデータデータベースで生成されたカラムがない場合に、アウトプット・プラグインを介してPostgreSQLを非ターゲットデータベースにレプリケートするときに便利です。 サポート
Generated columns are not published by default, but users can opt to publish stored generated columns just like regular ones. 《機械翻訳》生成された列はデフォルトによって公開されていないが、ユーザは通常の列と同様に、保存された生成列をパブリッシュすることを選択できる。
There are two ways to do this: 《機械翻訳》これを行うには2つの方法があります。
Set the <command>PUBLICATION</command> parameter
<link linkend="sql-createpublication-params-with-publish-generated-columns">
<literal>publish_generated_columns</literal></link> to <literal>stored</literal>.
This instructs PostgreSQL logical replication to publish current and
future stored generated columns of the publication's tables.
《機械翻訳》PUBLICATION
パラメータpublish_generated_columns
をstored
に設定します。
これはPostgreSQL論理レプリケーションにパブリッシュ現在と将来格納されるパブリケーションのテーブルの生成列を指示します。
Specify a table <link linkend="logical-replication-col-lists">column list</link> to explicitly nominate which stored generated columns will be published. 《機械翻訳》どの格納された生成カラムがパブリッシュされるかを明示的に指定するテーブルカラムリストを指定します。
When determining which table columns will be published, a column list
takes precedence, overriding the effect of the
<literal>publish_generated_columns</literal> parameter.
《機械翻訳》どのテーブル列を発行するかを決定する際には、カラムリストが優先され、publish_generated_columns
パラメータの効果を上書きします。
The following table summarizes behavior when there are generated columns involved in the logical replication. Results are shown for when publishing generated columns is not enabled, and for when it is enabled. 《機械翻訳》次のテーブルは、論理レプリケーションに生成列が含まれる場合の動作をまとめたものです。 生成列の発行が有効でない場合の結果と、有効な場合の結果を示します。
表29.2 《機械翻訳》レプリケーション結果の概要
Publish generated columns? | Publisher table column | Subscriber table column | 結果 |
---|---|---|---|
No | GENERATED | GENERATED | Publisher table column is not replicated. Use the subscriber table generated column value. |
No | GENERATED | regular | Publisher table column is not replicated. Use the subscriber table regular column default value. |
No | GENERATED | --missing-- | Publisher table column is not replicated. Nothing happens. |
Yes | GENERATED | GENERATED | ERROR. Not supported. |
Yes | GENERATED | regular | Publisher table column value is replicated to the subscriber table column. |
Yes | GENERATED | --missing-- | ERROR. The column is reported as missing from the subscriber table. |
There's currently no support for subscriptions comprising several publications where the same table has been published with different column lists. See <xref linkend="logical-replication-col-lists"/>. 《機械翻訳》現在、同じサポートが異なるテーブルリストで公開されている複数の出版物で構成されるサブスクリプションのカラムはありません。 29.5を参照してください。
This same situation can occur if one publication is publishing generated columns, while another publication in the same subscription is not publishing generated columns for the same table. 《機械翻訳》この同じシチュエーションは、あるパブリケーションが生成列を発行していて、同じパブリケーションの別のサブスクリプションが同じテーブルの生成列を発行していない場合に発生します。
If the subscriber is from a release prior to 18, then initial table synchronization won't copy generated columns even if they are defined in the publisher. 《機械翻訳》サブスクライバーが18より前のリリースからのものである場合、最初のテーブルの同期では、コピーで生成されたカラムは、パブリッシャーで定義されていても生成されません。