pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: Table's REPLICATE IDENTITY : where is it kept?
Date: Mon, 30 Jul 2018 17:11:01 +0300
Message-ID: <88a346ef-9ec0-ca97-5a15-94529d68cbc2@matrix.gatewaynet.com> (raw)
In-Reply-To: <24602.1532957847@sss.pgh.pa.us>
References: <1e6cc5ad-b84a-7c07-8c08-a4d0c3cdc938@matrix.gatewaynet.com>
	<24602.1532957847@sss.pgh.pa.us>

On 30/07/2018 16:37, Tom Lane wrote:
> Achilleas Mantzios <achill@matrix.gatewaynet.com> writes:
>> I noticed that after changing a table's REPLICA IDENTITY via the ALTER TABLE command, this is not reflected in pg_dump.
> Really?  There's certainly code in there that purports to do it:
When its a plain INDEX it is pg_dump'ed correctly.
But when this is a CONSTRAINT index it is not.
e.g.
\d status
...
Indexes:
     "status_id_key" UNIQUE CONSTRAINT, btree (id)
     "status_uk" UNIQUE, btree (id)

alter table status REPLICA IDENTITY USING INDEX status_id_key;
This does not get dumped:
postgres@TEST-smadb:~$ pg_dump --schema-only | grep "REPLICA IDENTITY"
postgres@TEST-smadb:~$

But if I do :

alter table status REPLICA IDENTITY USING INDEX status_uk;
then I get correct result :

postgres@TEST-smadb:~$ pg_dump --schema-only | grep "REPLICA IDENTITY"
ALTER TABLE ONLY public.status REPLICA IDENTITY USING INDEX status_uk;
postgres@TEST-smadb:~$

>      /*
>       * dump properties we only have ALTER TABLE syntax for
>       */
>      if ((tbinfo->relkind == RELKIND_RELATION ||
>           tbinfo->relkind == RELKIND_PARTITIONED_TABLE ||
>           tbinfo->relkind == RELKIND_MATVIEW) &&
>          tbinfo->relreplident != REPLICA_IDENTITY_DEFAULT)
>      {
>          if (tbinfo->relreplident == REPLICA_IDENTITY_INDEX)
>          {
>              /* nothing to do, will be set when the index is dumped */
>          }
>          else if (tbinfo->relreplident == REPLICA_IDENTITY_NOTHING)
>          {
>              appendPQExpBuffer(q, "\nALTER TABLE ONLY %s REPLICA IDENTITY NOTHING;\n",
>                                qualrelname);
>          }
>          else if (tbinfo->relreplident == REPLICA_IDENTITY_FULL)
>          {
>              appendPQExpBuffer(q, "\nALTER TABLE ONLY %s REPLICA IDENTITY FULL;\n",
>                                qualrelname);
>          }
>      }
>
> 			regards, tom lane


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt





view thread (4+ messages)  latest in thread

Message-ID: <88a346ef-9ec0-ca97-5a15-94529d68cbc2@matrix.gatewaynet.com>
Permalink:  ../88a346ef-9ec0-ca97-5a15-94529d68cbc2@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/88a346ef-9ec0-ca97-5a15-94529d68cbc2@matrix.gatewaynet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: achill@matrix.gatewaynet.com, tgl@sss.pgh.pa.us, pgsql-admin@lists.postgresql.org
  Subject: Re: Table's REPLICATE IDENTITY : where is it kept?
  In-Reply-To: <88a346ef-9ec0-ca97-5a15-94529d68cbc2@matrix.gatewaynet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox