diff --git a/src/test/regress/expected/issue_7891.out b/src/test/regress/expected/issue_7891.out index a5ee494452a..cf10ea1c9c4 100644 --- a/src/test/regress/expected/issue_7891.out +++ b/src/test/regress/expected/issue_7891.out @@ -1,3 +1,6 @@ +-- This construct has been used as a regression test to ensure that the planner +-- correctly distinguishes between "local" and "reference" tables, avoiding an erroneous 0-task plan. +-- https://github.com/citusdata/citus/issues/7891 CREATE SCHEMA issue_7891; SET search_path TO issue_7891; @@ -62,67 +65,32 @@ SELECT 't2_ref data' AS label, * FROM t2_ref; -- Historically might produce a 0-task plan if the planner incorrectly fails to -- treat t4_pg/t2_ref as local/reference. -- ---- EXPLAIN of update (problem scenario) --- -EXPLAIN (VERBOSE, COSTS OFF) + +-- The outer subquery iterates over every row in table t4_pg. UPDATE t6_pg SET vkey = 43 WHERE EXISTS ( SELECT (SELECT c15 FROM t2_ref) FROM t4_pg ); - QUERY PLAN + +-- Show final data +SELECT 't6_pg after' AS label, * FROM t6_pg; + label | vkey | pkey | c26 --------------------------------------------------------------------- - Custom Scan (Citus Adaptive) - Task Count: 1 - Tasks Shown: All - -> Task - Query: UPDATE issue_7891.t6_pg SET vkey = 43 WHERE (EXISTS (SELECT (SELECT t2_ref.c15 FROM (SELECT NULL::integer AS vkey, NULL::integer AS pkey, NULL::timestamp without time zone AS c15 WHERE false) t2_ref(vkey, pkey, c15)) AS c15 FROM issue_7891.t4_pg)) - Node: host=localhost port=xxxxx dbname=regression - -> Update on issue_7891.t6_pg - InitPlan 1 - -> Seq Scan on issue_7891.t4_pg - -> Result - Output: 43, t6_pg.ctid - One-Time Filter: (InitPlan 1).col1 - -> Seq Scan on issue_7891.t6_pg - Output: t6_pg.ctid -(14 rows) - - ---- EXPLAIN reversing subquery usage --- -EXPLAIN (VERBOSE, COSTS OFF) -UPDATE t6_pg + t6_pg after | 43 | 12000 | +(1 row) + + +-- The outer subquery iterates over rows from the reference table t2_ref +UPDATE t6_pg SET vkey = 43 - WHERE EXISTS ( - SELECT (SELECT c22 FROM t4_pg) + WHERE EXISTS ( + SELECT (SELECT c22 FROM t4_pg) FROM t2_ref ); - QUERY PLAN ---------------------------------------------------------------------- - Custom Scan (Citus Adaptive) - Task Count: 1 - Tasks Shown: All - -> Task - Query: UPDATE issue_7891.t6_pg SET vkey = 43 WHERE (EXISTS (SELECT (SELECT t4_pg.c22 FROM issue_7891.t4_pg) AS c22 FROM issue_7891.t2_ref_363177 t2_ref)) - Node: host=localhost port=xxxxx dbname=regression - -> Update on issue_7891.t6_pg - InitPlan 1 - -> Seq Scan on issue_7891.t2_ref_363177 t2_ref - -> Result - Output: 43, t6_pg.ctid - One-Time Filter: (InitPlan 1).col1 - -> Seq Scan on issue_7891.t6_pg - Output: t6_pg.ctid -(14 rows) - - --- Now actually do the update to confirm it works -UPDATE t6_pg - SET vkey = 43 - WHERE EXISTS ( - SELECT (SELECT c15 FROM t2_ref) - FROM t4_pg -); +ERROR: relation "issue_7891.t6_pg" does not exist +CONTEXT: while executing command on localhost:xxxxx -- Show final data SELECT 't6_pg after' AS label, * FROM t6_pg; @@ -132,9 +100,5 @@ SELECT 't6_pg after' AS label, * FROM t6_pg; (1 row) +SET client_min_messages TO WARNING; DROP SCHEMA issue_7891 CASCADE; -NOTICE: drop cascades to 4 other objects -DETAIL: drop cascades to table t2_ref -drop cascades to table t4_pg -drop cascades to table t6_pg -drop cascades to table t2_ref_363177 diff --git a/src/test/regress/sql/issue_7891.sql b/src/test/regress/sql/issue_7891.sql index d577d928198..8994bafde1e 100644 --- a/src/test/regress/sql/issue_7891.sql +++ b/src/test/regress/sql/issue_7891.sql @@ -1,3 +1,6 @@ +-- This construct has been used as a regression test to ensure that the planner +-- correctly distinguishes between "local" and "reference" tables, avoiding an erroneous 0-task plan. +-- https://github.com/citusdata/citus/issues/7891 CREATE SCHEMA issue_7891; SET search_path TO issue_7891; @@ -42,8 +45,8 @@ SELECT 't2_ref data' AS label, * FROM t2_ref; -- Historically might produce a 0-task plan if the planner incorrectly fails to -- treat t4_pg/t2_ref as local/reference. -- ---- EXPLAIN of update (problem scenario) --- -EXPLAIN (VERBOSE, COSTS OFF) + +-- The outer subquery iterates over every row in table t4_pg. UPDATE t6_pg SET vkey = 43 WHERE EXISTS ( @@ -51,24 +54,19 @@ UPDATE t6_pg FROM t4_pg ); ---- EXPLAIN reversing subquery usage --- -EXPLAIN (VERBOSE, COSTS OFF) -UPDATE t6_pg - SET vkey = 43 - WHERE EXISTS ( - SELECT (SELECT c22 FROM t4_pg) - FROM t2_ref -); +-- Show final data +SELECT 't6_pg after' AS label, * FROM t6_pg; --- Now actually do the update to confirm it works -UPDATE t6_pg +-- The outer subquery iterates over rows from the reference table t2_ref +UPDATE t6_pg SET vkey = 43 - WHERE EXISTS ( - SELECT (SELECT c15 FROM t2_ref) - FROM t4_pg + WHERE EXISTS ( + SELECT (SELECT c22 FROM t4_pg) + FROM t2_ref ); -- Show final data SELECT 't6_pg after' AS label, * FROM t6_pg; +SET client_min_messages TO WARNING; DROP SCHEMA issue_7891 CASCADE;