postgres.git / summary / log / commit / refs
commit adac22bf8a451eef87ff5693cde021e738191c24
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Fri Dec 19 05:04:35 2008 +0000
First released in: 8.4.0
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.
src/backend/utils/adt/ruleutils.c | 10 +++++++++-
src/test/regress/expected/polymorphism.out | 8 ++++----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 5a6540b88ea..444ee7a2007 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.289 2008/12/18 18:20:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.290 2008/12/19 05:04:35 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -4451,6 +4451,14 @@ get_rule_expr(Node *node, deparse_context *context,
appendStringInfo(buf, "ARRAY[");
get_rule_expr((Node *) arrayexpr->elements, context, true);
appendStringInfoChar(buf, ']');
+ /*
+ * If the array isn't empty, we assume its elements are
+ * coerced to the desired type. If it's empty, though, we
+ * need an explicit coercion to the array type.
+ */
+ if (arrayexpr->elements == NIL)
+ appendStringInfo(buf, "::%s",
+ format_type_with_typemod(arrayexpr->array_typeid, -1));
}
break;
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index 6fafc0343cc..aace99cb625 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -1005,10 +1005,10 @@ $$ select array_upper($1, 1) $$ language sql;
ERROR: cannot remove parameter defaults from existing function
HINT: Use DROP FUNCTION first.
\df dfunc
- List of functions
- Schema | Name | Result data type | Argument data types
---------+-------+------------------+--------------------------------------
- public | dfunc | integer | VARIADIC a integer[] DEFAULT ARRAY[]
+ List of functions
+ Schema | Name | Result data type | Argument data types
+--------+-------+------------------+-------------------------------------------------
+ public | dfunc | integer | VARIADIC a integer[] DEFAULT ARRAY[]::integer[]
(1 row)
drop function dfunc(a variadic int[]);
[parent: e32014d85de4]