Re: Table's REPLICATE IDENTITY : where is it kept? - Mailing list pgsql-admin

From Achilleas Mantzios
Subject Re: Table's REPLICATE IDENTITY : where is it kept?
Date
Msg-id 88a346ef-9ec0-ca97-5a15-94529d68cbc2@matrix.gatewaynet.com
Whole thread Raw
In response to Re: Table's REPLICATE IDENTITY : where is it kept?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Table's REPLICATE IDENTITY : where is it kept?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-admin
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



pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: Table's REPLICATE IDENTITY : where is it kept?
Next
From: Tom Lane
Date:
Subject: Re: Table's REPLICATE IDENTITY : where is it kept?