Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit adac22b

Browse files
committed
When we added the ability to have zero-element ARRAY[] constructs by adding an
explicit cast to show the intended array type, we forgot to teach ruleutils.c to print out such constructs properly. Found by noting bogus output from recent changes in polymorphism regression test.
1 parent e32014d commit adac22b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.289 2008/12/18 18:20:34 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.290 2008/12/19 05:04:35 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -4451,6 +4451,14 @@ get_rule_expr(Node *node, deparse_context *context,
44514451
appendStringInfo(buf, "ARRAY[");
44524452
get_rule_expr((Node *) arrayexpr->elements, context, true);
44534453
appendStringInfoChar(buf, ']');
4454+
/*
4455+
* If the array isn't empty, we assume its elements are
4456+
* coerced to the desired type. If it's empty, though, we
4457+
* need an explicit coercion to the array type.
4458+
*/
4459+
if (arrayexpr->elements == NIL)
4460+
appendStringInfo(buf, "::%s",
4461+
format_type_with_typemod(arrayexpr->array_typeid, -1));
44544462
}
44554463
break;
44564464

src/test/regress/expected/polymorphism.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,10 +1005,10 @@ $$ select array_upper($1, 1) $$ language sql;
10051005
ERROR: cannot remove parameter defaults from existing function
10061006
HINT: Use DROP FUNCTION first.
10071007
\df dfunc
1008-
List of functions
1009-
Schema | Name | Result data type | Argument data types
1010-
--------+-------+------------------+--------------------------------------
1011-
public | dfunc | integer | VARIADIC a integer[] DEFAULT ARRAY[]
1008+
List of functions
1009+
Schema | Name | Result data type | Argument data types
1010+
--------+-------+------------------+-------------------------------------------------
1011+
public | dfunc | integer | VARIADIC a integer[] DEFAULT ARRAY[]::integer[]
10121012
(1 row)
10131013

10141014
drop function dfunc(a variadic int[]);

0 commit comments

Comments
 (0)