pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mundla, Sankar <Sankar.Mundla@rsa.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: After upgrade from version9.4.1 to 10.15, changes on the table structure
Date: Wed, 24 Mar 2021 10:26:38 -0400
Message-ID: <1055940.1616595998@sss.pgh.pa.us> (raw)
In-Reply-To: <MN2PR19MB2894A88649F46228653B64EAE0639@MN2PR19MB2894.namprd19.prod.outlook.com>
References: <MN2PR19MB2894A88649F46228653B64EAE0639@MN2PR19MB2894.namprd19.prod.outlook.com>

"Mundla, Sankar" <Sankar.Mundla@rsa.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





view thread (2+ messages)

Message-ID: <1055940.1616595998@sss.pgh.pa.us>
Permalink:  ../1055940.1616595998@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1055940.1616595998@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Sankar.Mundla@rsa.com
  Subject: Re: After upgrade from version9.4.1 to 10.15, changes on the table structure
  In-Reply-To: <1055940.1616595998@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox