aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/ruleutils.c28
-rw-r--r--src/test/regress/expected/create_view.out8
-rw-r--r--src/test/regress/sql/create_view.sql1
3 files changed, 20 insertions, 17 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index f3ea36a231c..a20a1b069bf 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -8254,11 +8254,12 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
{
case T_FuncExpr:
{
- /* special handling for casts */
+ /* special handling for casts and COERCE_SQL_SYNTAX */
CoercionForm type = ((FuncExpr *) parentNode)->funcformat;
if (type == COERCE_EXPLICIT_CAST ||
- type == COERCE_IMPLICIT_CAST)
+ type == COERCE_IMPLICIT_CAST ||
+ type == COERCE_SQL_SYNTAX)
return false;
return true; /* own parentheses */
}
@@ -8306,11 +8307,12 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
return false;
case T_FuncExpr:
{
- /* special handling for casts */
+ /* special handling for casts and COERCE_SQL_SYNTAX */
CoercionForm type = ((FuncExpr *) parentNode)->funcformat;
if (type == COERCE_EXPLICIT_CAST ||
- type == COERCE_IMPLICIT_CAST)
+ type == COERCE_IMPLICIT_CAST ||
+ type == COERCE_SQL_SYNTAX)
return false;
return true; /* own parentheses */
}
@@ -10046,9 +10048,11 @@ get_func_sql_syntax(FuncExpr *expr, deparse_context *context)
case F_TIMEZONE_TEXT_TIMETZ:
/* AT TIME ZONE ... note reversed argument order */
appendStringInfoChar(buf, '(');
- get_rule_expr((Node *) lsecond(expr->args), context, false);
+ get_rule_expr_paren((Node *) lsecond(expr->args), context, false,
+ (Node *) expr);
appendStringInfoString(buf, " AT TIME ZONE ");
- get_rule_expr((Node *) linitial(expr->args), context, false);
+ get_rule_expr_paren((Node *) linitial(expr->args), context, false,
+ (Node *) expr);
appendStringInfoChar(buf, ')');
return true;
@@ -10100,9 +10104,10 @@ get_func_sql_syntax(FuncExpr *expr, deparse_context *context)
case F_IS_NORMALIZED:
/* IS xxx NORMALIZED */
- appendStringInfoString(buf, "((");
- get_rule_expr((Node *) linitial(expr->args), context, false);
- appendStringInfoString(buf, ") IS");
+ appendStringInfoString(buf, "(");
+ get_rule_expr_paren((Node *) linitial(expr->args), context, false,
+ (Node *) expr);
+ appendStringInfoString(buf, " IS");
if (list_length(expr->args) == 2)
{
Const *con = (Const *) lsecond(expr->args);
@@ -10123,11 +10128,6 @@ get_func_sql_syntax(FuncExpr *expr, deparse_context *context)
appendStringInfoChar(buf, ')');
return true;
- /*
- * XXX EXTRACT, a/k/a date_part(), is intentionally not covered
- * yet. Add it after we change the return type to numeric.
- */
-
case F_NORMALIZE:
/* NORMALIZE() */
appendStringInfoString(buf, "NORMALIZE(");
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index f9bbad00df2..17ca29ddbf7 100644
--- a/src/test/regress/expected/create_view.out
+++ b/src/test/regress/expected/create_view.out
@@ -1922,6 +1922,7 @@ select pg_get_viewdef('tt20v', true);
-- reverse-listing of various special function syntaxes required by SQL
create view tt201v as
select
+ ('2022-12-01'::date + '1 day'::interval) at time zone 'UTC' as atz,
extract(day from now()) as extr,
(now(), '1 day'::interval) overlaps
(current_timestamp(2), '1 day'::interval) as o,
@@ -1976,10 +1977,11 @@ select
select pg_get_viewdef('tt201v', true);
pg_get_viewdef
-----------------------------------------------------------------------------------------------
- SELECT EXTRACT(day FROM now()) AS extr, +
+ SELECT (('12-01-2022'::date + '@ 1 day'::interval) AT TIME ZONE 'UTC'::text) AS atz, +
+ EXTRACT(day FROM now()) AS extr, +
((now(), '@ 1 day'::interval) OVERLAPS (CURRENT_TIMESTAMP(2), '@ 1 day'::interval)) AS o,+
- (('foo'::text) IS NORMALIZED) AS isn, +
- (('foo'::text) IS NFKC NORMALIZED) AS isnn, +
+ ('foo'::text IS NORMALIZED) AS isn, +
+ ('foo'::text IS NFKC NORMALIZED) AS isnn, +
NORMALIZE('foo'::text) AS n, +
NORMALIZE('foo'::text, NFKD) AS nfkd, +
OVERLAY('foo'::text PLACING 'bar'::text FROM 2) AS ovl, +
diff --git a/src/test/regress/sql/create_view.sql b/src/test/regress/sql/create_view.sql
index bd189b22092..8838a40f7ab 100644
--- a/src/test/regress/sql/create_view.sql
+++ b/src/test/regress/sql/create_view.sql
@@ -703,6 +703,7 @@ select pg_get_viewdef('tt20v', true);
create view tt201v as
select
+ ('2022-12-01'::date + '1 day'::interval) at time zone 'UTC' as atz,
extract(day from now()) as extr,
(now(), '1 day'::interval) overlaps
(current_timestamp(2), '1 day'::interval) as o,