diff options
| author | Alexander Korotkov | 2023-12-27 01:34:29 +0000 |
|---|---|---|
| committer | Alexander Korotkov | 2023-12-27 01:57:57 +0000 |
| commit | e0477837ce49d73c9f21a5e00143b741ce6e1f89 (patch) | |
| tree | e1029bfebccd8160cdfe381d292ba2dfbbc0aae0 /src/test | |
| parent | 7d58f2342bd3d2f0474207b63a3a548c29e20a9e (diff) | |
Make replace_relid() leave argument unmodified
There are a lot of situations when we share the same pointer to a Bitmapset
structure across different places. In order to evade undesirable side effects
replace_relid() function should always return a copy.
Reported-by: Richard Guo
Discussion: https://postgr.es/m/CAMbWs4_wJthNtYBL%2BSsebpgF-5L2r5zFFk6xYbS0A78GKOTFHw%40mail.gmail.com
Reviewed-by: Richard Guo, Andres Freund, Ashutosh Bapat, Andrei Lepikhov
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/join.out | 15 | ||||
| -rw-r--r-- | src/test/regress/sql/join.sql | 6 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index 69427287ffd..1557e17299c 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -6853,6 +6853,21 @@ on true; Filter: (t3.id IS NOT NULL) (8 rows) +-- Check that SJE replaces join clauses involving the removed rel correctly +explain (costs off) +select * from emp1 t1 + inner join emp1 t2 on t1.id = t2.id + left join emp1 t3 on t1.id > 1 and t1.id < 2; + QUERY PLAN +---------------------------------------------- + Nested Loop Left Join + Join Filter: ((t2.id > 1) AND (t2.id < 2)) + -> Seq Scan on emp1 t2 + Filter: (id IS NOT NULL) + -> Materialize + -> Seq Scan on emp1 t3 +(6 rows) + -- We can remove the join even if we find the join can't duplicate rows and -- the base quals of each side are different. In the following case we end up -- moving quals over to s1 to make it so it can't match any rows. diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql index 9d6fce21ded..fed9e83e31d 100644 --- a/src/test/regress/sql/join.sql +++ b/src/test/regress/sql/join.sql @@ -2610,6 +2610,12 @@ select * from generate_series(1,10) t1(id) left join lateral (select t1.id as t1id, t2.id from emp1 t2 join emp1 t3 on t2.id = t3.id) on true; +-- Check that SJE replaces join clauses involving the removed rel correctly +explain (costs off) +select * from emp1 t1 + inner join emp1 t2 on t1.id = t2.id + left join emp1 t3 on t1.id > 1 and t1.id < 2; + -- We can remove the join even if we find the join can't duplicate rows and -- the base quals of each side are different. In the following case we end up -- moving quals over to s1 to make it so it can't match any rows. |
