Re: After upgrade from version9.4.1 to 10.15, changes on the table structure

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Mundla, Sankar" <Sankar(dot)Mundla(at)rsa(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: After upgrade from version9.4.1 to 10.15, changes on the table structure
Date: 2021-03-24 14:26:38
Message-ID: 1055940.1616595998@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Mundla, Sankar" <Sankar(dot)Mundla(at)rsa(dot)com> writes:
> [ dump and reload converts ]
> "ck_am_dummy_simulation" CHECK (domain_object_type::text = ANY (ARRAY['PRINCIPAL'::character varying, 'TOKEN'::character varying]::text[]))
> [ into ]
> "ck_am_dummy_simulation" CHECK (domain_object_type::text = ANY (ARRAY['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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2021-03-24 16:39:31 Re: BUG #16931: source code problem about commit_ts
Previous Message Bryan Staley 2021-03-24 13:41:03 Re: BUG #16941: ECPG add support for const void*