Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fk8tJ-0005AH-3z for pgsql-admin@arkaria.postgresql.org; Mon, 30 Jul 2018 14:11:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fk8tH-0004N4-B1 for pgsql-admin@arkaria.postgresql.org; Mon, 30 Jul 2018 14:11:15 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fk8tG-0004Mx-WA for pgsql-admin@lists.postgresql.org; Mon, 30 Jul 2018 14:11:15 +0000 Received: from hermes.gatewaynet.com ([193.92.121.98]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fk8tC-0000tS-W7 for pgsql-admin@lists.postgresql.org; Mon, 30 Jul 2018 14:11:13 +0000 Received: from smadev.internal.net (pc131.internal.net [10.9.200.131]) by hermes.gatewaynet.com (8.14.3/8.14.3/Debian-9.4) with ESMTP id w6UEB1Is004722; Mon, 30 Jul 2018 17:11:06 +0300 Received: from smadev.internal.net (smadev [10.9.200.131]) by smadev.internal.net (8.15.2/8.15.2) with ESMTP id w6UEB1Rx092255; Mon, 30 Jul 2018 17:11:01 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) Subject: Re: Table's REPLICATE IDENTITY : where is it kept? To: Tom Lane Cc: pgsql-admin@lists.postgresql.org References: <1e6cc5ad-b84a-7c07-8c08-a4d0c3cdc938@matrix.gatewaynet.com> <24602.1532957847@sss.pgh.pa.us> From: Achilleas Mantzios Message-ID: <88a346ef-9ec0-ca97-5a15-94529d68cbc2@matrix.gatewaynet.com> Date: Mon, 30 Jul 2018 17:11:01 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <24602.1532957847@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Virus-Scanned: clamav-milter 0.98.7 at hermes X-Virus-Status: Clean X-Spam-Status: No, score=-32.2 required=5.0 tests=ALL_TRUSTED,DYN_HAM_COORD, DYN_HAM_IT,DYN_HAM_IT_PARTNERS,DYN_HAM_NAUTICAL,DYN_HAM_SIGNAT1,DYN_SPAM_SUBJ, DYN_SPAM_WATCHES8,SARE_SPEC_REPLICA_OBFU autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on hermes.gatewaynet.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 30/07/2018 16:37, Tom Lane wrote: > Achilleas Mantzios 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