Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lP4T6-0005Mr-2E for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Mar 2021 14:26:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lP4T4-0002qJ-Rb for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Mar 2021 14:26:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lP4T4-0002qC-Gj for pgsql-bugs@lists.postgresql.org; Wed, 24 Mar 2021 14:26:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lP4T2-0006E8-69 for pgsql-bugs@postgresql.org; Wed, 24 Mar 2021 14:26:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 12OEQcVN1055941; Wed, 24 Mar 2021 10:26:39 -0400 From: Tom Lane To: "Mundla, Sankar" cc: "pgsql-bugs@postgresql.org" Subject: Re: After upgrade from version9.4.1 to 10.15, changes on the table structure In-reply-to: References: Comments: In-reply-to "Mundla, Sankar" message dated "Wed, 24 Mar 2021 11:09:03 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1055939.1616595998.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 24 Mar 2021 10:26:38 -0400 Message-ID: <1055940.1616595998@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Mundla, Sankar" writes: > [ dump and reload converts ] > "ck_am_dummy_simulation" CHECK (domain_object_type::text =3D ANY (AR= RAY['PRINCIPAL'::character varying, 'TOKEN'::character varying]::text[])) > [ into ] > "ck_am_dummy_simulation" CHECK (domain_object_type::text =3D ANY (AR= RAY['PRINCIPAL'::character varying::text, 'TOKEN'::character varying::text= ])) > Why is this behavior ? pg_dump, like psql, prefers to show implicit casts explicitly, to reduce the risk of the expression being interpreted differently when reloaded. So while you wrote the array without any cast to begin with, you get the first form in the dump. However, the parser treats array[...]::something[] differently from a bare array[]. The cast to "something" is applied to each array element immediately. The reason for that is that if we just transformed array[...] without applying the knowledge that the final type must be "something", we might get an unnecessary parse failure from inability to resolve a common type for the array elements. (The parser has no way to know, of course, that some previous cycle of processing successfully resolved a common type for the elements. This behavior is unnecessary in this context, but it does help for manually-entered expressions.) So you end up with something that looks a little different. It's semantically equivalent though, so I see no bug here. regards, tom lane