pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #19767: pg_get_viewdef prints ORDER BY (- '3'::int4) as (- 3), which reparses as column position -3
7+ messages / 4 participants
[nested] [flat]
* BUG #19767: pg_get_viewdef prints ORDER BY (- '3'::int4) as (- 3), which reparses as column position -3
@ 2026-10-16 15:59 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 7+ messages in thread
From: PG Bug reporting form @ 2026-10-16 15:59 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: alpkeles99@gmail.com
The following bug has been logged on the website:
Bug reference: 19767
Logged by: Alperen Keles
Email address: alpkeles99@gmail.com
PostgreSQL version: 18.6
Operating system: Ubuntu 24.04 x86_64 (also macOS 26 arm64)
Description:
Hello,
In ORDER BY and GROUP BY, a bare integer constant is a column position
(ORDER BY 2), while "ORDER BY (- '3'::int4)" is an expression, the negation
of a typed literal, so it sorts by a constant -3.
pg_get_viewdef() prints that term as "(- 3)". When that text is parsed
again, the grammar folds "- 3" into the integer constant -3 (doNegate),
which ORDER BY then reads as a column position. So the printed
definition of a valid view is not a valid view, and pg_dump, which
prints views the same way, writes a dump that does not restore.
```
CREATE TABLE t (a int);
INSERT INTO t VALUES (1), (2);
CREATE VIEW o AS SELECT a FROM t ORDER BY (- '3'::int4);
CREATE VIEW g AS SELECT count(*) AS n FROM t GROUP BY (- '3'::int4);
SELECT * FROM o; -- 1, 2
SELECT * FROM g; -- 2
SELECT pg_get_viewdef('o'::regclass);
SELECT a
FROM t
ORDER BY (- 3);
SELECT pg_get_viewdef('g'::regclass);
SELECT count(*) AS n
FROM t
GROUP BY (- 3);
```
Creating each view again from its own printed definition fails:
```
CREATE VIEW o2 AS SELECT a FROM t ORDER BY (- 3);
ERROR: ORDER BY position -3 is not in select list
CREATE VIEW g2 AS SELECT count(*) AS n FROM t GROUP BY (- 3);
ERROR: GROUP BY position -3 is not in select list
```
That is what happens on restore: pg_dump of that database writes
```
CREATE VIEW public.o AS
SELECT a
FROM public.t
ORDER BY (- 3);
```
and restoring it with psql into an empty database gives
```
psql:dump.sql:44: ERROR: ORDER BY position -3 is not in select list
psql:dump.sql:67: ERROR: GROUP BY position -3 is not in select list
```
followed by "relation does not exist" for the views' ALTER OWNER and for
a view built on top of o, so those views are lost. pg_restore of a -Fc
dump fails the same way.
When the folded constant is a position that exists, the text silently
means something else. "- (- '1'::int4)" prints as "(- (- 1))", which
folds to 1:
```
CREATE TABLE t2 (a int, b int);
INSERT INTO t2 VALUES (1, 10), (2, 20), (1, 30);
CREATE VIEW v AS SELECT DISTINCT ON (- (- '1'::int4)) a, b FROM t2
ORDER BY - (- '1'::int4), b DESC;
SELECT * FROM v; -- one row: (1,30)
```
Its definition, run again (or restored from a dump), becomes
DISTINCT ON (a) ... ORDER BY a, b DESC and returns (1,30) and (2,20).
Reproduced on 18.6 (REL_18_STABLE dfbc1507cdb), 19rc1 (REL_19_STABLE
1212d5d33b1), 14.24 (REL_14_STABLE 14904052e65) and master a261fc2b722,
Ubuntu 24.04 x86_64, --enable-cassert, with pg_dump of the same version;
also on 18.6 and master on macOS arm64.
Found with a query fuzzer.
Regards,
Alperen Keles
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #19767: pg_get_viewdef prints ORDER BY (- '3'::int4) as (- 3), which reparses as column position -3
@ 2026-10-19 11:29 Nitin Motiani <nitinmotiani@google.com>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 7+ messages in thread
From: Nitin Motiani @ 2026-10-19 11:29 UTC (permalink / raw)
To: alpkeles99@gmail.com; pgsql-bugs@lists.postgresql.org
Hi,
On Fri, Oct 16, 2026 at 9:46 PM PG Bug reporting form
<noreply@postgresql.org> wrote:
>
> pg_get_viewdef() prints that term as "(- 3)". When that text is parsed
> again, the grammar folds "- 3" into the integer constant -3 (doNegate),
> which ORDER BY then reads as a column position. So the printed
> definition of a valid view is not a valid view, and pg_dump, which
> prints views the same way, writes a dump that does not restore.
>
> ```
> CREATE TABLE t (a int);
> INSERT INTO t VALUES (1), (2);
> CREATE VIEW o AS SELECT a FROM t ORDER BY (- '3'::int4);
> CREATE VIEW g AS SELECT count(*) AS n FROM t GROUP BY (- '3'::int4);
> SELECT * FROM o; -- 1, 2
> SELECT * FROM g; -- 2
>
I'm not sure if this kind of use case is common enough to warrant
concern. But I looked into a possible fix. The fix is small where
during deparsing, get_oper_expr checks if the argument to a prefix
operator is a constant and forces adding '::type' to it (so it would
create 3::int4 in this case). It might lead to some extra '::type'
prints in other cases unaffected by the bug but that seems fine to me.
I'm attaching the patch with the fix and a couple of tests. Please take a look.
Thanks & Regards,
Nitin Motiani
Google
Attachments:
v1-0001-Fix-deparsing-of-unary-operators-applied-to-const.patch (application/x-patch, 6.1K) download
From 3c34406a9582abd250da001a1dd570ec0d97006b Mon Sep 17 00:00:00 2001
From: Nitin Motiani <nitinmotiani@google.com>
Date: Mon, 19 Oct 2026 10:27:24 +0000
Subject: [PATCH v1] Fix deparsing of unary operators applied to constants.
ruleutils.c printed an expression such as "- '3'::int4" as "(- 3)".
When re-parsed, the grammar folds "- 3" into the integer constant -3,
which is not the same parse tree. Usually that's harmless, but in
ORDER BY, GROUP BY, or DISTINCT ON a bare integer constant is taken as
a column number, so a dumped view could fail to restore ("ORDER BY
position -3 is not in select list"), or worse, silently change meaning
("- (- '1'::int4)" became column 1).
To fix, force a type label on a Const that is the argument of a prefix
operator, so that it prints as "(- 3::integer)", which re-parses as a
negation of a typecast and so is not folded.
Reported-by: Alperen Keles <alpkeles99@gmail.com>
Discussion: https://postgr.es/m/19767-f1189fd6a83254b7@postgresql.org
---
src/backend/utils/adt/ruleutils.c | 13 ++++++-
src/test/regress/expected/create_view.out | 44 ++++++++++++++++++++++-
src/test/regress/sql/create_view.sql | 19 ++++++++++
3 files changed, 74 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 5e8e1683db0..b5c5d796c8c 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -10811,7 +10811,18 @@ get_oper_expr(OpExpr *expr, deparse_context *context)
generate_operator_name(opno,
InvalidOid,
exprType(arg)));
- get_rule_expr_paren(arg, context, true, (Node *) expr);
+
+ /*
+ * If the argument is a Const, force it to be labeled with its type.
+ * Otherwise, something like "- 3" would be folded by the grammar into
+ * a negative constant when re-parsed, which is not the same thing;
+ * notably, in ORDER BY or GROUP BY it would be taken as a column
+ * number.
+ */
+ if (arg && IsA(arg, Const))
+ get_const_expr((Const *) arg, context, 1);
+ else
+ get_rule_expr_paren(arg, context, true, (Node *) expr);
}
if (!PRETTY_PAREN(context))
appendStringInfoChar(buf, ')');
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index 053fa56573f..83bd0226a4e 100644
--- a/src/test/regress/expected/create_view.out
+++ b/src/test/regress/expected/create_view.out
@@ -2285,6 +2285,44 @@ select viewname from pg_views where viewname = 'tt27v'; -- Ok to access a system
(1 row)
reset restrict_nonsystem_relation_kind;
+-- check that unary minus applied to a constant is not printed in a way that
+-- would be read back as a negative constant, ie, a column number (bug #19767)
+create view tt28v as
+select distinct on (- (- '1'::int4)) x, y
+from (values (1, 2)) v(x, y)
+order by - (- '1'::int4), y, - 3.5::numeric;
+select pg_get_viewdef('tt28v', true);
+ pg_get_viewdef
+-----------------------------------------------------
+ SELECT DISTINCT ON ((- (- 1::integer))) x, +
+ y +
+ FROM ( VALUES (1,2)) v(x, y) +
+ ORDER BY (- (- 1::integer)), y, (- 3.5::numeric);
+(1 row)
+
+create view tt29v as
+select count(*) from (values (1)) v(x)
+group by - '3'::int4, rollup(- '3'::int4);
+select pg_get_viewdef('tt29v', true);
+ pg_get_viewdef
+----------------------------------------------------
+ SELECT count(*) AS count +
+ FROM ( VALUES (1)) v(x) +
+ GROUP BY (- 3::integer), ROLLUP((- 3::integer));
+(1 row)
+
+-- the printed definitions must be re-loadable
+do $$ begin
+ execute 'create view tt28v_copy as ' || pg_get_viewdef('tt28v');
+ execute 'create view tt29v_copy as ' || pg_get_viewdef('tt29v');
+end $$;
+select pg_get_viewdef('tt28v_copy', true) = pg_get_viewdef('tt28v', true),
+ pg_get_viewdef('tt29v_copy', true) = pg_get_viewdef('tt29v', true);
+ ?column? | ?column?
+----------+----------
+ t | t
+(1 row)
+
-- clean up all the random objects we made above
DROP SCHEMA temp_view_test CASCADE;
NOTICE: drop cascades to 27 other objects
@@ -2316,7 +2354,7 @@ drop cascades to view aliased_view_2
drop cascades to view aliased_view_3
drop cascades to view aliased_view_4
DROP SCHEMA testviewschm2 CASCADE;
-NOTICE: drop cascades to 80 other objects
+NOTICE: drop cascades to 84 other objects
DETAIL: drop cascades to table t1
drop cascades to view temporal1
drop cascades to view temporal2
@@ -2397,3 +2435,7 @@ drop cascades to view tt25v
drop cascades to view tt26v
drop cascades to table tt27v_tbl
drop cascades to view tt27v
+drop cascades to view tt28v
+drop cascades to view tt29v
+drop cascades to view tt28v_copy
+drop cascades to view tt29v_copy
diff --git a/src/test/regress/sql/create_view.sql b/src/test/regress/sql/create_view.sql
index 75b8cd5d0fb..3fc32c7a201 100644
--- a/src/test/regress/sql/create_view.sql
+++ b/src/test/regress/sql/create_view.sql
@@ -838,6 +838,25 @@ insert into tt27v values (1); -- Error
select viewname from pg_views where viewname = 'tt27v'; -- Ok to access a system view.
reset restrict_nonsystem_relation_kind;
+-- check that unary minus applied to a constant is not printed in a way that
+-- would be read back as a negative constant, ie, a column number (bug #19767)
+create view tt28v as
+select distinct on (- (- '1'::int4)) x, y
+from (values (1, 2)) v(x, y)
+order by - (- '1'::int4), y, - 3.5::numeric;
+select pg_get_viewdef('tt28v', true);
+create view tt29v as
+select count(*) from (values (1)) v(x)
+group by - '3'::int4, rollup(- '3'::int4);
+select pg_get_viewdef('tt29v', true);
+-- the printed definitions must be re-loadable
+do $$ begin
+ execute 'create view tt28v_copy as ' || pg_get_viewdef('tt28v');
+ execute 'create view tt29v_copy as ' || pg_get_viewdef('tt29v');
+end $$;
+select pg_get_viewdef('tt28v_copy', true) = pg_get_viewdef('tt28v', true),
+ pg_get_viewdef('tt29v_copy', true) = pg_get_viewdef('tt29v', true);
+
-- clean up all the random objects we made above
DROP SCHEMA temp_view_test CASCADE;
DROP SCHEMA testviewschm2 CASCADE;
--
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #19767: pg_get_viewdef prints ORDER BY (- '3'::int4) as (- 3), which reparses as column position -3
@ 2026-10-19 14:35 Henson Choi <assam258@gmail.com>
parent: Nitin Motiani <nitinmotiani@google.com>
0 siblings, 1 reply; 7+ messages in thread
From: Henson Choi @ 2026-10-19 14:35 UTC (permalink / raw)
To: Nitin Motiani <nitinmotiani@google.com>; +Cc: alpkeles99@gmail.com; pgsql-bugs@lists.postgresql.org
Hi Nitin,
> I'm not sure if this kind of use case is common enough to warrant
> concern. But I looked into a possible fix. The fix is small where
> during deparsing, get_oper_expr checks if the argument to a prefix
> operator is a constant and forces adding '::type' to it (so it would
> create 3::int4 in this case). It might lead to some extra '::type'
> prints in other cases unaffected by the bug but that seems fine to me.
I had been tracking an issue with the same cause, and this fix
resolves it too. When a user-defined prefix "-" operator is visible in
the search_path, pg_get_viewdef() prints it as a bare "-", and running
that text again folds "- 1" into the constant -1, so the operator
silently disappears:
create schema s;
create function s.neg42(int) returns int language sql immutable
return 42;
create operator s.- (rightarg = int4, function = s.neg42);
set search_path = s, pg_catalog, public;
create view public.vneg as select -(1::int) as x;
select x from public.vneg; -- 42
select pg_get_viewdef('public.vneg', true) as def \gset
create view public.vneg_re as :def
select x from public.vneg_re;
Before the patch:
select pg_get_viewdef('public.vneg', true);
pg_get_viewdef
-------------------
SELECT - 1 AS x;
(1 row)
select x from public.vneg_re;
x
----
-1
(1 row)
With the patch:
select pg_get_viewdef('public.vneg', true);
pg_get_viewdef
----------------------------
SELECT - 1::integer AS x;
(1 row)
select x from public.vneg_re;
x
----
42
(1 row)
That case seems even less common than the reported one, and pg_dump
keeps the meaning since it prints OPERATOR(s.-), so I do not think
it changes the case for the fix, and I am not sure it is worth a test
of its own either.
On master, the code change alone leaves all existing regression
output unchanged, so the extra '::type' you mention does not show up
there; it only affects prefix operators applied to int4 and numeric
constants, the only ones printed without a label. I also built REL_15
through REL_19 with the patch and ran the regression tests: the code
applies cleanly to all of them, and the patch applies as it is from
REL_16 on; on REL_15 only the expected output needs regenerating, for
the column qualification pretty mode still prints there.
Best regards,
Henson
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #19767: pg_get_viewdef prints ORDER BY (- '3'::int4) as (- 3), which reparses as column position -3
@ 2026-10-22 13:00 Nitin Motiani <nitinmotiani@google.com>
parent: Henson Choi <assam258@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Nitin Motiani @ 2026-10-22 13:00 UTC (permalink / raw)
To: assam258@gmail.com; +Cc: alpkeles99@gmail.com; pgsql-bugs@lists.postgresql.org
On Mon, Oct 19, 2026 at 8:05 PM Henson Choi <assam258@gmail.com> wrote:
>
> On master, the code change alone leaves all existing regression
> output unchanged, so the extra '::type' you mention does not show up
> there; it only affects prefix operators applied to int4 and numeric
> constants, the only ones printed without a label. I also built REL_15
> through REL_19 with the patch and ran the regression tests: the code
> applies cleanly to all of them, and the patch applies as it is from
> REL_16 on; on REL_15 only the expected output needs regenerating, for
> the column qualification pretty mode still prints there.
>
Thanks for the feedback and the analysis, Henson. I've created a
commitfest entry for this at
https://commitfest.postgresql.org/patch/7500/.
Regards,
Nitin Motiani
Google
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #19767: pg_get_viewdef prints ORDER BY (- '3'::int4) as (- 3), which reparses as column position -3
@ 2026-10-25 12:03 Nitin Motiani <nitinmotiani@google.com>
parent: Nitin Motiani <nitinmotiani@google.com>
0 siblings, 2 replies; 7+ messages in thread
From: Nitin Motiani @ 2026-10-25 12:03 UTC (permalink / raw)
To: assam258@gmail.com; +Cc: alpkeles99@gmail.com; pgsql-bugs@lists.postgresql.org
Attaching the rebased patch.
Thanks,
Nitin Motiani
Google
Attachments:
v2-0001-Fix-deparsing-of-unary-operators-applied-to-const.patch (application/x-patch, 6.1K) download
From f9dde5f93fd112d87718289a1a2d98ff14956252 Mon Sep 17 00:00:00 2001
From: Nitin Motiani <nitinmotiani@google.com>
Date: Mon, 19 Oct 2026 10:27:24 +0000
Subject: [PATCH v2] Fix deparsing of unary operators applied to constants.
ruleutils.c printed an expression such as "- '3'::int4" as "(- 3)".
When re-parsed, the grammar folds "- 3" into the integer constant -3,
which is not the same parse tree. Usually that's harmless, but in
ORDER BY, GROUP BY, or DISTINCT ON a bare integer constant is taken as
a column number, so a dumped view could fail to restore ("ORDER BY
position -3 is not in select list"), or worse, silently change meaning
("- (- '1'::int4)" became column 1).
To fix, force a type label on a Const that is the argument of a prefix
operator, so that it prints as "(- 3::integer)", which re-parses as a
negation of a typecast and so is not folded.
Reported-by: Alperen Keles <alpkeles99@gmail.com>
Discussion: https://postgr.es/m/19767-f1189fd6a83254b7@postgresql.org
---
src/backend/utils/adt/ruleutils.c | 13 ++++++-
src/test/regress/expected/create_view.out | 44 ++++++++++++++++++++++-
src/test/regress/sql/create_view.sql | 19 ++++++++++
3 files changed, 74 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index ccfd7f4728f..d464ab5fc8b 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -10845,7 +10845,18 @@ get_oper_expr(OpExpr *expr, deparse_context *context)
generate_operator_name(opno,
InvalidOid,
exprType(arg)));
- get_rule_expr_paren(arg, context, true, (Node *) expr);
+
+ /*
+ * If the argument is a Const, force it to be labeled with its type.
+ * Otherwise, something like "- 3" would be folded by the grammar into
+ * a negative constant when re-parsed, which is not the same thing;
+ * notably, in ORDER BY or GROUP BY it would be taken as a column
+ * number.
+ */
+ if (arg && IsA(arg, Const))
+ get_const_expr((Const *) arg, context, 1);
+ else
+ get_rule_expr_paren(arg, context, true, (Node *) expr);
}
if (!PRETTY_PAREN(context))
appendStringInfoChar(buf, ')');
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index 85ffca793f2..14a98a1ca07 100644
--- a/src/test/regress/expected/create_view.out
+++ b/src/test/regress/expected/create_view.out
@@ -2308,6 +2308,44 @@ select viewname from pg_views where viewname = 'tt27v'; -- Ok to access a system
(1 row)
reset restrict_nonsystem_relation_kind;
+-- check that unary minus applied to a constant is not printed in a way that
+-- would be read back as a negative constant, ie, a column number (bug #19767)
+create view tt28v as
+select distinct on (- (- '1'::int4)) x, y
+from (values (1, 2)) v(x, y)
+order by - (- '1'::int4), y, - 3.5::numeric;
+select pg_get_viewdef('tt28v', true);
+ pg_get_viewdef
+-----------------------------------------------------
+ SELECT DISTINCT ON ((- (- 1::integer))) x, +
+ y +
+ FROM ( VALUES (1,2)) v(x, y) +
+ ORDER BY (- (- 1::integer)), y, (- 3.5::numeric);
+(1 row)
+
+create view tt29v as
+select count(*) from (values (1)) v(x)
+group by - '3'::int4, rollup(- '3'::int4);
+select pg_get_viewdef('tt29v', true);
+ pg_get_viewdef
+----------------------------------------------------
+ SELECT count(*) AS count +
+ FROM ( VALUES (1)) v(x) +
+ GROUP BY (- 3::integer), ROLLUP((- 3::integer));
+(1 row)
+
+-- the printed definitions must be re-loadable
+do $$ begin
+ execute 'create view tt28v_copy as ' || pg_get_viewdef('tt28v');
+ execute 'create view tt29v_copy as ' || pg_get_viewdef('tt29v');
+end $$;
+select pg_get_viewdef('tt28v_copy', true) = pg_get_viewdef('tt28v', true),
+ pg_get_viewdef('tt29v_copy', true) = pg_get_viewdef('tt29v', true);
+ ?column? | ?column?
+----------+----------
+ t | t
+(1 row)
+
-- clean up all the random objects we made above
DROP SCHEMA temp_view_test CASCADE;
NOTICE: drop cascades to 27 other objects
@@ -2339,7 +2377,7 @@ drop cascades to view aliased_view_2
drop cascades to view aliased_view_3
drop cascades to view aliased_view_4
DROP SCHEMA testviewschm2 CASCADE;
-NOTICE: drop cascades to 82 other objects
+NOTICE: drop cascades to 86 other objects
DETAIL: drop cascades to table t1
drop cascades to view temporal1
drop cascades to view temporal2
@@ -2422,3 +2460,7 @@ drop cascades to operator ||(xml,xml)
drop cascades to view tt261v
drop cascades to table tt27v_tbl
drop cascades to view tt27v
+drop cascades to view tt28v
+drop cascades to view tt29v
+drop cascades to view tt28v_copy
+drop cascades to view tt29v_copy
diff --git a/src/test/regress/sql/create_view.sql b/src/test/regress/sql/create_view.sql
index 82b8d8ab395..ac9e7441c80 100644
--- a/src/test/regress/sql/create_view.sql
+++ b/src/test/regress/sql/create_view.sql
@@ -851,6 +851,25 @@ insert into tt27v values (1); -- Error
select viewname from pg_views where viewname = 'tt27v'; -- Ok to access a system view.
reset restrict_nonsystem_relation_kind;
+-- check that unary minus applied to a constant is not printed in a way that
+-- would be read back as a negative constant, ie, a column number (bug #19767)
+create view tt28v as
+select distinct on (- (- '1'::int4)) x, y
+from (values (1, 2)) v(x, y)
+order by - (- '1'::int4), y, - 3.5::numeric;
+select pg_get_viewdef('tt28v', true);
+create view tt29v as
+select count(*) from (values (1)) v(x)
+group by - '3'::int4, rollup(- '3'::int4);
+select pg_get_viewdef('tt29v', true);
+-- the printed definitions must be re-loadable
+do $$ begin
+ execute 'create view tt28v_copy as ' || pg_get_viewdef('tt28v');
+ execute 'create view tt29v_copy as ' || pg_get_viewdef('tt29v');
+end $$;
+select pg_get_viewdef('tt28v_copy', true) = pg_get_viewdef('tt28v', true),
+ pg_get_viewdef('tt29v_copy', true) = pg_get_viewdef('tt29v', true);
+
-- clean up all the random objects we made above
DROP SCHEMA temp_view_test CASCADE;
DROP SCHEMA testviewschm2 CASCADE;
--
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #19767: pg_get_viewdef prints ORDER BY (- '3'::int4) as (- 3), which reparses as column position -3
@ 2026-10-26 07:00 Henson Choi <assam258@gmail.com>
parent: Nitin Motiani <nitinmotiani@google.com>
1 sibling, 0 replies; 7+ messages in thread
From: Henson Choi @ 2026-10-26 07:00 UTC (permalink / raw)
To: Nitin Motiani <nitinmotiani@google.com>; +Cc: alpkeles99@gmail.com; pgsql-bugs@lists.postgresql.org
Hi Nitin,
> Attaching the rebased patch.
Thanks. I checked v2: the code and the test are the same as in v1,
and only the context at the end of create_view.out has changed.
The whole test suite passes with it, and a pg_dump/restore of objects
using prefix operators on constants round-trips to the same
definitions.
I also tried it on the back branches again: the code applies
cleanly to REL_14 through REL_19, and the test applies as it is from
REL_16 on; on REL_14 and REL_15 only the expected output needs
regenerating.
I will mark it Ready for Committer.
Best regards,
Henson
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: BUG #19767: pg_get_viewdef prints ORDER BY (- '3'::int4) as (- 3), which reparses as column position -3
@ 2026-10-27 09:30 solai v <solai.cdac@gmail.com>
parent: Nitin Motiani <nitinmotiani@google.com>
1 sibling, 0 replies; 7+ messages in thread
From: solai v @ 2026-10-27 09:30 UTC (permalink / raw)
To: Nitin Motiani <nitinmotiani@google.com>; +Cc: assam258@gmail.com; alpkeles99@gmail.com; pgsql-bugs@lists.postgresql.org
Hi,
I tested the v2 patch and I would like to share my observations.
Before applying the patch, pg_get_viewdef() generated output such as
ORDER BY (- 3), which could be misinterpreted as a column position
when the view definition was parsed again.
After applying the patch, the output included the explicit type cast,
for example, ORDER BY (- 3::integer). I also verified that the
recreated views worked correctly.
The regression tests covering ORDER BY, GROUP BY, and reloading the
generated view definitions passed, and all regression tests passed in
my testing environment.
Based on these results, the patch appears to address the reported
issue. Thank you for your work on this fix.
Regards,
Solai
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2026-10-27 09:30 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16 15:59 BUG #19767: pg_get_viewdef prints ORDER BY (- '3'::int4) as (- 3), which reparses as column position -3 PG Bug reporting form <noreply@postgresql.org>
2026-10-19 11:29 ` Nitin Motiani <nitinmotiani@google.com>
2026-10-19 14:35 ` Henson Choi <assam258@gmail.com>
2026-10-22 13:00 ` Nitin Motiani <nitinmotiani@google.com>
2026-10-25 12:03 ` Nitin Motiani <nitinmotiani@google.com>
2026-10-26 07:00 ` Henson Choi <assam258@gmail.com>
2026-10-27 09:30 ` solai v <solai.cdac@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox