pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix old bug with coercing the result of a COLLATE expression.
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix old bug with coercing the result of a COLLATE expression.
@ 2021-04-12 18:38 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2021-04-12 18:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix old bug with coercing the result of a COLLATE expression.

There are hacks in parse_coerce.c to push down a requested coercion
to below any CollateExpr that may appear.  However, we did that even
if the requested data type is non-collatable, leading to an invalid
expression tree in which CollateExpr is applied to a non-collatable
type.  The fix is just to drop the CollateExpr altogether, reasoning
that it's useless.

This bug is ten years old, dating to the original addition of
COLLATE support.  The lack of field complaints suggests that there
aren't a lot of user-visible consequences.  We noticed the problem
because it would trigger an assertion in DefineVirtualRelation if
the invalid structure appears as an output column of a view; however,
in a non-assert build, you don't see a crash just a (subtly incorrect)
complaint about applying collation to a non-collatable type.  I found
that by putting the incorrect structure further down in a view, I could
make a view definition that would fail dump/reload, per the added
regression test case.  But CollateExpr doesn't do anything at run-time,
so this likely doesn't lead to any really exciting consequences.

Per report from Yulin Pei.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/HK0PR01MB22744393C474D503E16C8509F4709@HK0PR01MB2274.apcprd01.prod.exchangelabs....

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c402b02b9fb53aee2a26876de90a8f95f9a9be92

Modified Files
--------------
src/backend/parser/parse_coerce.c     | 29 ++++++++++++++++++-----------
src/test/regress/expected/collate.out | 16 +++++++++++++++-
src/test/regress/sql/collate.sql      |  6 ++++++
3 files changed, 39 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix old bug with coercing the result of a COLLATE expression.
@ 2021-04-12 18:38 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2021-04-12 18:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix old bug with coercing the result of a COLLATE expression.

There are hacks in parse_coerce.c to push down a requested coercion
to below any CollateExpr that may appear.  However, we did that even
if the requested data type is non-collatable, leading to an invalid
expression tree in which CollateExpr is applied to a non-collatable
type.  The fix is just to drop the CollateExpr altogether, reasoning
that it's useless.

This bug is ten years old, dating to the original addition of
COLLATE support.  The lack of field complaints suggests that there
aren't a lot of user-visible consequences.  We noticed the problem
because it would trigger an assertion in DefineVirtualRelation if
the invalid structure appears as an output column of a view; however,
in a non-assert build, you don't see a crash just a (subtly incorrect)
complaint about applying collation to a non-collatable type.  I found
that by putting the incorrect structure further down in a view, I could
make a view definition that would fail dump/reload, per the added
regression test case.  But CollateExpr doesn't do anything at run-time,
so this likely doesn't lead to any really exciting consequences.

Per report from Yulin Pei.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/HK0PR01MB22744393C474D503E16C8509F4709@HK0PR01MB2274.apcprd01.prod.exchangelabs....

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8a7bd1e6cba37170afadcb252da3cf9c5386ef06

Modified Files
--------------
src/backend/parser/parse_coerce.c     | 29 ++++++++++++++++++-----------
src/test/regress/expected/collate.out | 16 +++++++++++++++-
src/test/regress/sql/collate.sql      |  6 ++++++
3 files changed, 39 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix old bug with coercing the result of a COLLATE expression.
@ 2021-04-12 18:38 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2021-04-12 18:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix old bug with coercing the result of a COLLATE expression.

There are hacks in parse_coerce.c to push down a requested coercion
to below any CollateExpr that may appear.  However, we did that even
if the requested data type is non-collatable, leading to an invalid
expression tree in which CollateExpr is applied to a non-collatable
type.  The fix is just to drop the CollateExpr altogether, reasoning
that it's useless.

This bug is ten years old, dating to the original addition of
COLLATE support.  The lack of field complaints suggests that there
aren't a lot of user-visible consequences.  We noticed the problem
because it would trigger an assertion in DefineVirtualRelation if
the invalid structure appears as an output column of a view; however,
in a non-assert build, you don't see a crash just a (subtly incorrect)
complaint about applying collation to a non-collatable type.  I found
that by putting the incorrect structure further down in a view, I could
make a view definition that would fail dump/reload, per the added
regression test case.  But CollateExpr doesn't do anything at run-time,
so this likely doesn't lead to any really exciting consequences.

Per report from Yulin Pei.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/HK0PR01MB22744393C474D503E16C8509F4709@HK0PR01MB2274.apcprd01.prod.exchangelabs....

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/27011bcffa74a5113c9b5408c678315e74fb9a70

Modified Files
--------------
src/backend/parser/parse_coerce.c     | 29 ++++++++++++++++++-----------
src/test/regress/expected/collate.out | 16 +++++++++++++++-
src/test/regress/sql/collate.sql      |  6 ++++++
3 files changed, 39 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix old bug with coercing the result of a COLLATE expression.
@ 2021-04-12 18:38 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2021-04-12 18:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix old bug with coercing the result of a COLLATE expression.

There are hacks in parse_coerce.c to push down a requested coercion
to below any CollateExpr that may appear.  However, we did that even
if the requested data type is non-collatable, leading to an invalid
expression tree in which CollateExpr is applied to a non-collatable
type.  The fix is just to drop the CollateExpr altogether, reasoning
that it's useless.

This bug is ten years old, dating to the original addition of
COLLATE support.  The lack of field complaints suggests that there
aren't a lot of user-visible consequences.  We noticed the problem
because it would trigger an assertion in DefineVirtualRelation if
the invalid structure appears as an output column of a view; however,
in a non-assert build, you don't see a crash just a (subtly incorrect)
complaint about applying collation to a non-collatable type.  I found
that by putting the incorrect structure further down in a view, I could
make a view definition that would fail dump/reload, per the added
regression test case.  But CollateExpr doesn't do anything at run-time,
so this likely doesn't lead to any really exciting consequences.

Per report from Yulin Pei.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/HK0PR01MB22744393C474D503E16C8509F4709@HK0PR01MB2274.apcprd01.prod.exchangelabs....

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/fb2cca828ec84f58bf119b65a4d6051400fe9438

Modified Files
--------------
src/backend/parser/parse_coerce.c     | 29 ++++++++++++++++++-----------
src/test/regress/expected/collate.out | 15 ++++++++++++++-
src/test/regress/sql/collate.sql      |  6 ++++++
3 files changed, 38 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix old bug with coercing the result of a COLLATE expression.
@ 2021-04-12 18:38 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2021-04-12 18:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix old bug with coercing the result of a COLLATE expression.

There are hacks in parse_coerce.c to push down a requested coercion
to below any CollateExpr that may appear.  However, we did that even
if the requested data type is non-collatable, leading to an invalid
expression tree in which CollateExpr is applied to a non-collatable
type.  The fix is just to drop the CollateExpr altogether, reasoning
that it's useless.

This bug is ten years old, dating to the original addition of
COLLATE support.  The lack of field complaints suggests that there
aren't a lot of user-visible consequences.  We noticed the problem
because it would trigger an assertion in DefineVirtualRelation if
the invalid structure appears as an output column of a view; however,
in a non-assert build, you don't see a crash just a (subtly incorrect)
complaint about applying collation to a non-collatable type.  I found
that by putting the incorrect structure further down in a view, I could
make a view definition that would fail dump/reload, per the added
regression test case.  But CollateExpr doesn't do anything at run-time,
so this likely doesn't lead to any really exciting consequences.

Per report from Yulin Pei.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/HK0PR01MB22744393C474D503E16C8509F4709@HK0PR01MB2274.apcprd01.prod.exchangelabs....

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4b0aecee8a7d4ca63075a8bee2d96c457147ad2a

Modified Files
--------------
src/backend/parser/parse_coerce.c     | 29 ++++++++++++++++++-----------
src/test/regress/expected/collate.out | 15 ++++++++++++++-
src/test/regress/sql/collate.sql      |  6 ++++++
3 files changed, 38 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix old bug with coercing the result of a COLLATE expression.
@ 2021-04-12 18:38 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2021-04-12 18:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix old bug with coercing the result of a COLLATE expression.

There are hacks in parse_coerce.c to push down a requested coercion
to below any CollateExpr that may appear.  However, we did that even
if the requested data type is non-collatable, leading to an invalid
expression tree in which CollateExpr is applied to a non-collatable
type.  The fix is just to drop the CollateExpr altogether, reasoning
that it's useless.

This bug is ten years old, dating to the original addition of
COLLATE support.  The lack of field complaints suggests that there
aren't a lot of user-visible consequences.  We noticed the problem
because it would trigger an assertion in DefineVirtualRelation if
the invalid structure appears as an output column of a view; however,
in a non-assert build, you don't see a crash just a (subtly incorrect)
complaint about applying collation to a non-collatable type.  I found
that by putting the incorrect structure further down in a view, I could
make a view definition that would fail dump/reload, per the added
regression test case.  But CollateExpr doesn't do anything at run-time,
so this likely doesn't lead to any really exciting consequences.

Per report from Yulin Pei.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/HK0PR01MB22744393C474D503E16C8509F4709@HK0PR01MB2274.apcprd01.prod.exchangelabs....

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a6158a4d9c2e6b8af0d4217b8d80afeff8adec0e

Modified Files
--------------
src/backend/parser/parse_coerce.c     | 29 ++++++++++++++++++-----------
src/test/regress/expected/collate.out | 16 +++++++++++++++-
src/test/regress/sql/collate.sql      |  6 ++++++
3 files changed, 39 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2021-04-12 18:38 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-12 18:38 pgsql: Fix old bug with coercing the result of a COLLATE expression. Tom Lane <tgl@sss.pgh.pa.us>
2021-04-12 18:38 pgsql: Fix old bug with coercing the result of a COLLATE expression. Tom Lane <tgl@sss.pgh.pa.us>
2021-04-12 18:38 pgsql: Fix old bug with coercing the result of a COLLATE expression. Tom Lane <tgl@sss.pgh.pa.us>
2021-04-12 18:38 pgsql: Fix old bug with coercing the result of a COLLATE expression. Tom Lane <tgl@sss.pgh.pa.us>
2021-04-12 18:38 pgsql: Fix old bug with coercing the result of a COLLATE expression. Tom Lane <tgl@sss.pgh.pa.us>
2021-04-12 18:38 pgsql: Fix old bug with coercing the result of a COLLATE expression. Tom Lane <tgl@sss.pgh.pa.us>

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