pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP
@ 2016-04-21 18:20 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-04-21 18:20 UTC (permalink / raw)
  To: pgsql-committers

Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXPR_SUBLINK.

When we shoehorned "x op ANY (array)" into the SQL syntax, we created a
fundamental ambiguity as to the proper treatment of a sub-SELECT on the
righthand side: perhaps what's meant is to compare x against each row of
the sub-SELECT's result, or perhaps the sub-SELECT is meant as a scalar
sub-SELECT that delivers a single array value whose members should be
compared against x.  The grammar resolves it as the former case whenever
the RHS is a select_with_parens, making the latter case hard to reach ---
but you can get at it, with tricks such as attaching a no-op cast to the
sub-SELECT.  Parse analysis would throw away the no-op cast, leaving a
parsetree with an EXPR_SUBLINK SubLink directly under a ScalarArrayOpExpr.
ruleutils.c was not clued in on this fine point, and would naively emit
"x op ANY ((SELECT ...))", which would be parsed as the first alternative,
typically leading to errors like "operator does not exist: text = text[]"
during dump/reload of a view or rule containing such a construct.  To fix,
emit a no-op cast when dumping such a parsetree.  This might well be
exactly what the user wrote to get the construct accepted in the first
place; and even if she got there with some other dodge, it is a valid
representation of the parsetree.

Per report from Karl Czajkowski.  He mentioned only a case involving
RLS policies, but actually the problem is very old, so back-patch to
all supported branches.

Report: <20160421001832.GB7976@moraine.isi.edu>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/1f7c85b820814810f985a270e92cde4c12ceded4

Modified Files
--------------
src/backend/utils/adt/ruleutils.c         | 18 ++++++++++++++++++
src/test/regress/expected/create_view.out | 28 ++++++++++++++++++++++++++++
src/test/regress/sql/create_view.sql      | 11 +++++++++++
3 files changed, 57 insertions(+)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP
@ 2016-04-21 18:20 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-04-21 18:20 UTC (permalink / raw)
  To: pgsql-committers

Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXPR_SUBLINK.

When we shoehorned "x op ANY (array)" into the SQL syntax, we created a
fundamental ambiguity as to the proper treatment of a sub-SELECT on the
righthand side: perhaps what's meant is to compare x against each row of
the sub-SELECT's result, or perhaps the sub-SELECT is meant as a scalar
sub-SELECT that delivers a single array value whose members should be
compared against x.  The grammar resolves it as the former case whenever
the RHS is a select_with_parens, making the latter case hard to reach ---
but you can get at it, with tricks such as attaching a no-op cast to the
sub-SELECT.  Parse analysis would throw away the no-op cast, leaving a
parsetree with an EXPR_SUBLINK SubLink directly under a ScalarArrayOpExpr.
ruleutils.c was not clued in on this fine point, and would naively emit
"x op ANY ((SELECT ...))", which would be parsed as the first alternative,
typically leading to errors like "operator does not exist: text = text[]"
during dump/reload of a view or rule containing such a construct.  To fix,
emit a no-op cast when dumping such a parsetree.  This might well be
exactly what the user wrote to get the construct accepted in the first
place; and even if she got there with some other dodge, it is a valid
representation of the parsetree.

Per report from Karl Czajkowski.  He mentioned only a case involving
RLS policies, but actually the problem is very old, so back-patch to
all supported branches.

Report: <20160421001832.GB7976@moraine.isi.edu>

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/4b52cc2892b809c4a5216f15d91f95d174ca72a5

Modified Files
--------------
src/backend/utils/adt/ruleutils.c         | 18 ++++++++++++++++++
src/test/regress/expected/create_view.out | 28 ++++++++++++++++++++++++++++
src/test/regress/sql/create_view.sql      | 11 +++++++++++
3 files changed, 57 insertions(+)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP
@ 2016-04-21 18:20 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-04-21 18:20 UTC (permalink / raw)
  To: pgsql-committers

Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXPR_SUBLINK.

When we shoehorned "x op ANY (array)" into the SQL syntax, we created a
fundamental ambiguity as to the proper treatment of a sub-SELECT on the
righthand side: perhaps what's meant is to compare x against each row of
the sub-SELECT's result, or perhaps the sub-SELECT is meant as a scalar
sub-SELECT that delivers a single array value whose members should be
compared against x.  The grammar resolves it as the former case whenever
the RHS is a select_with_parens, making the latter case hard to reach ---
but you can get at it, with tricks such as attaching a no-op cast to the
sub-SELECT.  Parse analysis would throw away the no-op cast, leaving a
parsetree with an EXPR_SUBLINK SubLink directly under a ScalarArrayOpExpr.
ruleutils.c was not clued in on this fine point, and would naively emit
"x op ANY ((SELECT ...))", which would be parsed as the first alternative,
typically leading to errors like "operator does not exist: text = text[]"
during dump/reload of a view or rule containing such a construct.  To fix,
emit a no-op cast when dumping such a parsetree.  This might well be
exactly what the user wrote to get the construct accepted in the first
place; and even if she got there with some other dodge, it is a valid
representation of the parsetree.

Per report from Karl Czajkowski.  He mentioned only a case involving
RLS policies, but actually the problem is very old, so back-patch to
all supported branches.

Report: <20160421001832.GB7976@moraine.isi.edu>

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/679c92238c74ed6c96e4251d7ea68f8a096ff674

Modified Files
--------------
src/backend/utils/adt/ruleutils.c         | 18 ++++++++++++++++++
src/test/regress/expected/create_view.out | 28 ++++++++++++++++++++++++++++
src/test/regress/sql/create_view.sql      | 11 +++++++++++
3 files changed, 57 insertions(+)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP
@ 2016-04-21 18:20 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-04-21 18:20 UTC (permalink / raw)
  To: pgsql-committers

Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXPR_SUBLINK.

When we shoehorned "x op ANY (array)" into the SQL syntax, we created a
fundamental ambiguity as to the proper treatment of a sub-SELECT on the
righthand side: perhaps what's meant is to compare x against each row of
the sub-SELECT's result, or perhaps the sub-SELECT is meant as a scalar
sub-SELECT that delivers a single array value whose members should be
compared against x.  The grammar resolves it as the former case whenever
the RHS is a select_with_parens, making the latter case hard to reach ---
but you can get at it, with tricks such as attaching a no-op cast to the
sub-SELECT.  Parse analysis would throw away the no-op cast, leaving a
parsetree with an EXPR_SUBLINK SubLink directly under a ScalarArrayOpExpr.
ruleutils.c was not clued in on this fine point, and would naively emit
"x op ANY ((SELECT ...))", which would be parsed as the first alternative,
typically leading to errors like "operator does not exist: text = text[]"
during dump/reload of a view or rule containing such a construct.  To fix,
emit a no-op cast when dumping such a parsetree.  This might well be
exactly what the user wrote to get the construct accepted in the first
place; and even if she got there with some other dodge, it is a valid
representation of the parsetree.

Per report from Karl Czajkowski.  He mentioned only a case involving
RLS policies, but actually the problem is very old, so back-patch to
all supported branches.

Report: <20160421001832.GB7976@moraine.isi.edu>

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/e5882f26b38c6510a22263566548060a3153cc09

Modified Files
--------------
src/backend/utils/adt/ruleutils.c         | 18 ++++++++++++++++++
src/test/regress/expected/create_view.out | 28 ++++++++++++++++++++++++++++
src/test/regress/sql/create_view.sql      | 11 +++++++++++
3 files changed, 57 insertions(+)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP
@ 2016-04-21 18:20 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-04-21 18:20 UTC (permalink / raw)
  To: pgsql-committers

Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXPR_SUBLINK.

When we shoehorned "x op ANY (array)" into the SQL syntax, we created a
fundamental ambiguity as to the proper treatment of a sub-SELECT on the
righthand side: perhaps what's meant is to compare x against each row of
the sub-SELECT's result, or perhaps the sub-SELECT is meant as a scalar
sub-SELECT that delivers a single array value whose members should be
compared against x.  The grammar resolves it as the former case whenever
the RHS is a select_with_parens, making the latter case hard to reach ---
but you can get at it, with tricks such as attaching a no-op cast to the
sub-SELECT.  Parse analysis would throw away the no-op cast, leaving a
parsetree with an EXPR_SUBLINK SubLink directly under a ScalarArrayOpExpr.
ruleutils.c was not clued in on this fine point, and would naively emit
"x op ANY ((SELECT ...))", which would be parsed as the first alternative,
typically leading to errors like "operator does not exist: text = text[]"
during dump/reload of a view or rule containing such a construct.  To fix,
emit a no-op cast when dumping such a parsetree.  This might well be
exactly what the user wrote to get the construct accepted in the first
place; and even if she got there with some other dodge, it is a valid
representation of the parsetree.

Per report from Karl Czajkowski.  He mentioned only a case involving
RLS policies, but actually the problem is very old, so back-patch to
all supported branches.

Report: <20160421001832.GB7976@moraine.isi.edu>

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/c7c145e4fb8f38c2c6b7a3b239e4c33f1aa0ae87

Modified Files
--------------
src/backend/utils/adt/ruleutils.c         | 18 ++++++++++++++++++
src/test/regress/expected/create_view.out | 28 ++++++++++++++++++++++++++++
src/test/regress/sql/create_view.sql      | 11 +++++++++++
3 files changed, 57 insertions(+)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP
@ 2016-04-21 18:20 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-04-21 18:20 UTC (permalink / raw)
  To: pgsql-committers

Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXPR_SUBLINK.

When we shoehorned "x op ANY (array)" into the SQL syntax, we created a
fundamental ambiguity as to the proper treatment of a sub-SELECT on the
righthand side: perhaps what's meant is to compare x against each row of
the sub-SELECT's result, or perhaps the sub-SELECT is meant as a scalar
sub-SELECT that delivers a single array value whose members should be
compared against x.  The grammar resolves it as the former case whenever
the RHS is a select_with_parens, making the latter case hard to reach ---
but you can get at it, with tricks such as attaching a no-op cast to the
sub-SELECT.  Parse analysis would throw away the no-op cast, leaving a
parsetree with an EXPR_SUBLINK SubLink directly under a ScalarArrayOpExpr.
ruleutils.c was not clued in on this fine point, and would naively emit
"x op ANY ((SELECT ...))", which would be parsed as the first alternative,
typically leading to errors like "operator does not exist: text = text[]"
during dump/reload of a view or rule containing such a construct.  To fix,
emit a no-op cast when dumping such a parsetree.  This might well be
exactly what the user wrote to get the construct accepted in the first
place; and even if she got there with some other dodge, it is a valid
representation of the parsetree.

Per report from Karl Czajkowski.  He mentioned only a case involving
RLS policies, but actually the problem is very old, so back-patch to
all supported branches.

Report: <20160421001832.GB7976@moraine.isi.edu>

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/663624e60bd679ef7d4abeca1e68aceb5f2f5bbe

Modified Files
--------------
src/backend/utils/adt/ruleutils.c         | 18 ++++++++++++++++++
src/test/regress/expected/create_view.out | 27 +++++++++++++++++++++++++++
src/test/regress/sql/create_view.sql      | 11 +++++++++++
3 files changed, 56 insertions(+)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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


end of thread, other threads:[~2016-04-21 18:20 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-04-21 18:20 pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP Tom Lane <tgl@sss.pgh.pa.us>
2016-04-21 18:20 pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP Tom Lane <tgl@sss.pgh.pa.us>
2016-04-21 18:20 pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP Tom Lane <tgl@sss.pgh.pa.us>
2016-04-21 18:20 pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP Tom Lane <tgl@sss.pgh.pa.us>
2016-04-21 18:20 pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP Tom Lane <tgl@sss.pgh.pa.us>
2016-04-21 18:20 pgsql: Fix ruleutils.c's dumping of ScalarArrayOpExpr containing an EXP 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