change in behaviour for format_type() call

From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: change in behaviour for format_type() call
Date: 2018-03-01 10:16:12
Message-ID: CAGPqQf3RB2q-d2Awp_-x-Ur6aOxTUwnApt-vm-iTtceZxYnePg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Commit a26116c6cbf4117e8efaa7cfc5bacc887f01517f changed the behaviour
for format_type.

Prior to commit, format_type() used to set typemod_given to false for
typemode = NULL.

format_type()
..
if (PG_ARGISNULL(1))
result = format_type_internal(type_oid, -1, false, true, false);
else
{
typemod = PG_GETARG_INT32(1);
result = format_type_internal(type_oid, typemod, true, true, false);
}
..

With the commit format_type() always set the FORMAT_TYPE_TYPEMOD_GIVEN
flag even when typemode is NULL (-1).

Below are the difference it's making to the query output:

Before commit:

postgres(at)95320=#select format_type('bpchar'::regtype, null);
format_type
-------------
character
(1 row)

postgres(at)95320=#select format_type('bit'::regtype, null);
format_type
-------------
bit
(1 row)

After commit:

postgres(at)90169=#select format_type('bpchar'::regtype, null);
format_type
-------------
bpchar
(1 row)

postgres(at)90169=#select format_type('bit'::regtype, null);
format_type
-------------
"bit"
(1 row)

Is this expected behaviour? attaching patch to get back the older
behaviour.

Thanks,

Regards,
Rushabh Lathia
www.EnterpriseDB.com

Attachment Content-Type Size
format_type_fix.patch text/x-patch 881 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-03-01 10:16:55 Re: to_typemod(type_name) information function
Previous Message Arseny Sher 2018-03-01 10:12:13 Re: Why chain of snapshots is used in ReorderBufferCommit?