diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-10-20 17:12:27 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-10-20 17:12:27 -0400 |
commit | 36ea99c84d856177ec307307788a279cc600566e (patch) | |
tree | 5112f4161d589ee0854be07700ccc9353ba58765 /src/test | |
parent | a8f1efc8ace228b5258ee7d06eace923007072c4 (diff) | |
download | postgresql-36ea99c84d856177ec307307788a279cc600566e.tar.gz postgresql-36ea99c84d856177ec307307788a279cc600566e.zip |
Fix typcache's failure to treat ranges as container types.
Like the similar logic for arrays and records, it's necessary to examine
the range's subtype to decide whether the range type can support hashing.
We can omit checking the subtype for btree-defined operations, though,
since range subtypes are required to have those operations. (Possibly
that simplification for btree cases led us to overlook that it does
not apply for hash cases.)
This is only an issue if the subtype lacks hash support, which is not
true of any built-in range type, but it's easy to demonstrate a problem
with a range type over, eg, money: you can get a "could not identify
a hash function" failure when the planner is misled into thinking that
hash join or aggregation would work.
This was born broken, so back-patch to all supported branches.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/rangetypes.out | 12 | ||||
-rw-r--r-- | src/test/regress/sql/rangetypes.sql | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/test/regress/expected/rangetypes.out b/src/test/regress/expected/rangetypes.out index 4a2336cd8d3..accf1e0d9e2 100644 --- a/src/test/regress/expected/rangetypes.out +++ b/src/test/regress/expected/rangetypes.out @@ -1354,6 +1354,18 @@ select *, row_to_json(upper(t)) as u from drop type two_ints cascade; NOTICE: drop cascades to type two_ints_range -- +-- Check behavior when subtype lacks a hash function +-- +create type cashrange as range (subtype = money); +set enable_sort = off; -- try to make it pick a hash setop implementation +select '(2,5)'::cashrange except select '(5,6)'::cashrange; + cashrange +--------------- + ($2.00,$5.00) +(1 row) + +reset enable_sort; +-- -- OUT/INOUT/TABLE functions -- create function outparam_succeed(i anyrange, out r anyrange, out t text) diff --git a/src/test/regress/sql/rangetypes.sql b/src/test/regress/sql/rangetypes.sql index a60df9095e9..55638a85ee1 100644 --- a/src/test/regress/sql/rangetypes.sql +++ b/src/test/regress/sql/rangetypes.sql @@ -462,6 +462,18 @@ select *, row_to_json(upper(t)) as u from drop type two_ints cascade; -- +-- Check behavior when subtype lacks a hash function +-- + +create type cashrange as range (subtype = money); + +set enable_sort = off; -- try to make it pick a hash setop implementation + +select '(2,5)'::cashrange except select '(5,6)'::cashrange; + +reset enable_sort; + +-- -- OUT/INOUT/TABLE functions -- |