mirror of
https://github.com/postgres/postgres.git
synced 2025-07-20 05:03:10 +03:00
Fix format_type() to restore its old behavior.
Commit a26116c6c
accidentally changed the behavior of the SQL format_type()
function while refactoring. For the reasons explained in that function's
comment, a NULL typemod argument should behave differently from a -1
argument. Since we've managed to break this, add a regression test
memorializing the intended behavior.
In passing, be consistent about the type of the "flags" parameter.
Noted by Rushabh Lathia, though I revised the patch some more.
Discussion: https://postgr.es/m/CAGPqQf3RB2q-d2Awp_-x-Ur6aOxTUwnApt-vm-iTtceZxYnePg@mail.gmail.com
This commit is contained in:
@ -191,3 +191,23 @@ TABLE mytab;
|
||||
(-44,5.5,12)
|
||||
(2 rows)
|
||||
|
||||
-- and test format_type() a bit more, too
|
||||
select format_type('varchar'::regtype, 42);
|
||||
format_type
|
||||
-----------------------
|
||||
character varying(38)
|
||||
(1 row)
|
||||
|
||||
select format_type('bpchar'::regtype, null);
|
||||
format_type
|
||||
-------------
|
||||
character
|
||||
(1 row)
|
||||
|
||||
-- this behavior difference is intentional
|
||||
select format_type('bpchar'::regtype, -1);
|
||||
format_type
|
||||
-------------
|
||||
bpchar
|
||||
(1 row)
|
||||
|
||||
|
@ -148,3 +148,9 @@ WHERE attrelid = 'mytab'::regclass AND attnum > 0;
|
||||
-- might as well exercise the widget type while we're here
|
||||
INSERT INTO mytab VALUES ('(1,2,3)'), ('(-44,5.5,12)');
|
||||
TABLE mytab;
|
||||
|
||||
-- and test format_type() a bit more, too
|
||||
select format_type('varchar'::regtype, 42);
|
||||
select format_type('bpchar'::regtype, null);
|
||||
-- this behavior difference is intentional
|
||||
select format_type('bpchar'::regtype, -1);
|
||||
|
Reference in New Issue
Block a user