From: | David Rowley <drowley(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix deparsing of Consts in postgres_fdw ORDER BY |
Date: | 2024-03-10 23:27:35 |
Message-ID: | E1rjSZr-0038OI-B9@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix deparsing of Consts in postgres_fdw ORDER BY
For UNION ALL queries where a union child query contained a foreign
table, if the targetlist of that query contained a constant, and the
top-level query performed an ORDER BY which contained the column for the
constant value, then postgres_fdw would find the EquivalenceMember with
the Const and then try to produce an ORDER BY containing that Const.
This caused problems with INT typed Consts as these could appear to be
requests to order by an ordinal column position rather than the constant
value. This could lead to either an error such as:
ERROR: ORDER BY position <int const> is not in select list
or worse, if the constant value is a valid column, then we could just
sort by the wrong column altogether.
Here we fix this issue by just not including these Consts in the ORDER
BY clause.
In passing, add a new section for testing ORDER BY in the postgres_fdw
tests and move two existing tests which were misplaced in the WHERE
clause testing section into it.
Reported-by: Michał Kłeczek
Reviewed-by: Ashutosh Bapat, Richard Guo
Bug: #18381
Discussion: https://postgr.es/m/0714C8B8-8D82-4ABB-9F8D-A0C3657E7B6E%40kleczek.org
Discussion: https://postgr.es/m/18381-137456acd168bf93%40postgresql.org
Backpatch-through: 12, oldest supported version
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/c399248b3b44bd6cece1ada47eee346b67a88a0a
Modified Files
--------------
contrib/postgres_fdw/deparse.c | 25 +++++--
contrib/postgres_fdw/expected/postgres_fdw.out | 93 +++++++++++++++++++-------
contrib/postgres_fdw/sql/postgres_fdw.sql | 32 +++++++--
3 files changed, 114 insertions(+), 36 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2024-03-10 23:28:05 | pgsql: Fix deparsing of Consts in postgres_fdw ORDER BY |
Previous Message | Peter Eisentraut | 2024-03-10 07:02:10 | pgsql: Combine headerscheck and cpluspluscheck scripts |