Re: Table's REPLICATE IDENTITY : where is it kept?
| От | Achilleas Mantzios |
|---|---|
| Тема | Re: Table's REPLICATE IDENTITY : where is it kept? |
| Дата | |
| Msg-id | 88a346ef-9ec0-ca97-5a15-94529d68cbc2@matrix.gatewaynet.com обсуждение |
| Ответ на | Re: Table's REPLICATE IDENTITY : where is it kept? (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: Table's REPLICATE IDENTITY : where is it kept?
|
| Список | 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 по дате отправления: