diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-01-16 16:39:26 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-01-16 16:39:26 -0500 |
commit | 17da9d4c28297fd699cbbda969a9f64c4c09c665 (patch) | |
tree | 377a335283dc6020153257f991980015c9acd308 /src | |
parent | d91d4338e05486f943361260b9d4ad54421d3b44 (diff) | |
download | postgresql-17da9d4c28297fd699cbbda969a9f64c4c09c665.tar.gz postgresql-17da9d4c28297fd699cbbda969a9f64c4c09c665.zip |
Teach hash_ok_operator() that record_eq is only sometimes hashable.
The need for this was foreseen long ago, but when record_eq
actually became hashable (in commit 01e658fa7), we missed updating
this spot.
Per bug #17363 from Elvis Pranskevichus. Back-patch to v14 where
the faulty commit came in.
Discussion: https://postgr.es/m/17363-f6d42fd0d726be02@postgresql.org
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/plan/subselect.c | 6 | ||||
-rw-r--r-- | src/test/regress/expected/subselect.out | 23 | ||||
-rw-r--r-- | src/test/regress/sql/subselect.sql | 10 |
3 files changed, 36 insertions, 3 deletions
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index aee52951833..5d0680821b5 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -848,10 +848,10 @@ hash_ok_operator(OpExpr *expr) /* quick out if not a binary operator */ if (list_length(expr->args) != 2) return false; - if (opid == ARRAY_EQ_OP) + if (opid == ARRAY_EQ_OP || + opid == RECORD_EQ_OP) { - /* array_eq is strict, but must check input type to ensure hashable */ - /* XXX record_eq will need same treatment when it becomes hashable */ + /* these are strict, but must check input type to ensure hashable */ Node *leftarg = linitial(expr->args); return op_hashjoinable(opid, exprType(leftarg)); diff --git a/src/test/regress/expected/subselect.out b/src/test/regress/expected/subselect.out index 4e8ddc70613..45c75eecc5f 100644 --- a/src/test/regress/expected/subselect.out +++ b/src/test/regress/expected/subselect.out @@ -790,6 +790,29 @@ select 'foo'::text in (select 'bar'::name union all select 'bar'::name); (1 row) -- +-- Test that we don't try to hash nested records (bug #17363) +-- (Hashing could be supported, but for now we don't) +-- +explain (verbose, costs off) +select row(row(row(1))) = any (select row(row(1))); + QUERY PLAN +------------------------------------------- + Result + Output: (SubPlan 1) + SubPlan 1 + -> Materialize + Output: '("(1)")'::record + -> Result + Output: '("(1)")'::record +(7 rows) + +select row(row(row(1))) = any (select row(row(1))); + ?column? +---------- + t +(1 row) + +-- -- Test case for premature memory release during hashing of subplan output -- select '1'::text in (select '1'::name union all select '1'::name); diff --git a/src/test/regress/sql/subselect.sql b/src/test/regress/sql/subselect.sql index e879999708b..94ba91f5bb3 100644 --- a/src/test/regress/sql/subselect.sql +++ b/src/test/regress/sql/subselect.sql @@ -464,6 +464,16 @@ select 'foo'::text in (select 'bar'::name union all select 'bar'::name); select 'foo'::text in (select 'bar'::name union all select 'bar'::name); -- +-- Test that we don't try to hash nested records (bug #17363) +-- (Hashing could be supported, but for now we don't) +-- + +explain (verbose, costs off) +select row(row(row(1))) = any (select row(row(1))); + +select row(row(row(1))) = any (select row(row(1))); + +-- -- Test case for premature memory release during hashing of subplan output -- |