From: | Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-admin(at)lists(dot)postgresql(dot)org |
Subject: | Re: Table's REPLICATE IDENTITY : where is it kept? |
Date: | 2018-07-30 14:11:01 |
Message-ID: | 88a346ef-9ec0-ca97-5a15-94529d68cbc2@matrix.gatewaynet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On 30/07/2018 16:37, Tom Lane wrote:
> Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)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(at)TEST-smadb:~$ pg_dump --schema-only | grep "REPLICA IDENTITY"
postgres(at)TEST-smadb:~$
But if I do :
alter table status REPLICA IDENTITY USING INDEX status_uk;
then I get correct result :
postgres(at)TEST-smadb:~$ pg_dump --schema-only | grep "REPLICA IDENTITY"
ALTER TABLE ONLY public.status REPLICA IDENTITY USING INDEX status_uk;
postgres(at)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-07-30 14:48:45 | Re: Table's REPLICATE IDENTITY : where is it kept? |
Previous Message | Tom Lane | 2018-07-30 13:37:27 | Re: Table's REPLICATE IDENTITY : where is it kept? |