RE: Logical Replication - Should Destination Table Columns Be Defined With Default Value

Поиск
Список
Период
Сортировка
От Avi Weinberg
Тема RE: Logical Replication - Should Destination Table Columns Be Defined With Default Value
Дата
Msg-id DB9PR07MB71802D47D944DAA9A8AB688FCB929@DB9PR07MB7180.eurprd07.prod.outlook.com
обсуждение исходный текст
Ответ на Re: Logical Replication - Should Destination Table Columns Be Defined With Default Value  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: Logical Replication - Should Destination Table Columns Be Defined With Default Value
Список pgsql-general

Thanks David for the reply.

 

I also thought that default value on the subscriber side are immaterial.  However, with the case I showed without having default value on subscriber side it get null when the following occurs:

  1. Table was created with two columns on publisher and subscriber side
  2. Data inserted into this table
  3. A third column is added to table with default value on publisher side, but without default value on subscriber side
  4. The default value column has value for existing rows on publisher, but null on the subscriber side. 
  5. Doing refresh publication etc. does not help and the column on subscriber side remains with nulls

 

 

Your input is most welcome

 

 

From: David G. Johnston [mailto:david.g.johnston@gmail.com]
Sent: Tuesday, November 9, 2021 5:55 PM
To: Avi Weinberg <AviW@gilat.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Logical Replication - Should Destination Table Columns Be Defined With Default Value

 

On Tue, Nov 9, 2021 at 7:50 AM Avi Weinberg <AviW@gilat.com> wrote:

Was this done on purpose, that default value for new column is not copied for existing data?  Does this mean that on destination side we must also define the table with default value? 

 

Logical replication has two modes, initial synchronization and ongoing change push.  The ongoing change push sends entire rows, when they change, from the publisher to subscriber.

 

The initial sync happens once, when the subscriber initially subscribes to the publication.

 

As entire rows are getting sent, defaults on the subscriber are immaterial so far as the published rows are concerned.

 

If you run a command on the publisher that causes every row to change then of course every row will be published with those new values to the subscriber.

 

David J.

 

IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain information which is confidential or privileged. If you are not the intended recipient, please inform the sender immediately and delete this email: you should not copy or use this e-mail for any purpose nor disclose its contents to any person.

В списке pgsql-general по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Logical Replication - Should Destination Table Columns Be Defined With Default Value
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Logical Replication - Should Destination Table Columns Be Defined With Default Value