diff options
-rw-r--r-- | src/backend/optimizer/path/equivclass.c | 3 | ||||
-rw-r--r-- | src/test/regress/expected/join.out | 30 | ||||
-rw-r--r-- | src/test/regress/sql/join.sql | 20 |
3 files changed, 52 insertions, 1 deletions
diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c index 70a925c63a1..b22b36ec0ef 100644 --- a/src/backend/optimizer/path/equivclass.c +++ b/src/backend/optimizer/path/equivclass.c @@ -497,8 +497,9 @@ canonicalize_ec_expression(Expr *expr, Oid req_type, Oid req_collation) /* * For a polymorphic-input-type opclass, just keep the same exposed type. + * RECORD opclasses work like polymorphic-type ones for this purpose. */ - if (IsPolymorphicType(req_type)) + if (IsPolymorphicType(req_type) || req_type == RECORDOID) req_type = expr_type; /* diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index cbc882d47ba..dc6262be43a 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -2674,6 +2674,36 @@ select * from a left join b on i = x and i = y and x = i; rollback; -- +-- test handling of merge clauses using record_ops +-- +begin; +create type mycomptype as (id int, v bigint); +create temp table tidv (idv mycomptype); +create index on tidv (idv); +explain (costs off) +select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv; + QUERY PLAN +---------------------------------------------------------- + Merge Join + Merge Cond: (a.idv = b.idv) + -> Index Only Scan using tidv_idv_idx on tidv a + -> Materialize + -> Index Only Scan using tidv_idv_idx on tidv b +(5 rows) + +set enable_mergejoin = 0; +explain (costs off) +select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv; + QUERY PLAN +---------------------------------------------------- + Nested Loop + -> Seq Scan on tidv a + -> Index Only Scan using tidv_idv_idx on tidv b + Index Cond: (idv = a.idv) +(4 rows) + +rollback; +-- -- test NULL behavior of whole-row Vars, per bug #5025 -- select t1.q2, count(t2.*) diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql index 86c6d5be283..d3ba2a1c339 100644 --- a/src/test/regress/sql/join.sql +++ b/src/test/regress/sql/join.sql @@ -674,6 +674,26 @@ select * from a left join b on i = x and i = y and x = i; rollback; -- +-- test handling of merge clauses using record_ops +-- +begin; + +create type mycomptype as (id int, v bigint); + +create temp table tidv (idv mycomptype); +create index on tidv (idv); + +explain (costs off) +select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv; + +set enable_mergejoin = 0; + +explain (costs off) +select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv; + +rollback; + +-- -- test NULL behavior of whole-row Vars, per bug #5025 -- select t1.q2, count(t2.*) |