Skip to content

Commit

Permalink
Revert "Fix backward scan flag for parallel queries (babelfish-for-po…
Browse files Browse the repository at this point in the history
…stgresql#1604)"

This reverts commit f339cff.

Signed-off-by: Rohit Bhagat <[email protected]>
  • Loading branch information
Rohit Bhagat committed Nov 9, 2023
1 parent f339cff commit 4cd3eb1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 209 deletions.
155 changes: 19 additions & 136 deletions test/JDBC/expected/BABEL-4261.out
Original file line number Diff line number Diff line change
@@ -1,128 +1,10 @@
BEGIN TRAN BABEL4261_T1;
CREATE TABLE t1_babel4261 (a money);
GO

CREATE TABLE t_babel4261 (a int, b int);
BEGIN TRAN BABEL4261_T1;
GO

-- The third parameter is true to set config back to default after transaction is committed
select set_config('parallel_setup_cost', 0, true);
select set_config('parallel_tuple_cost', 0, true);
select set_config('min_parallel_table_scan_size', 0, true);
GO
~~START~~
text
0
~~END~~

~~START~~
text
0
~~END~~

~~START~~
text
0
~~END~~



-- show explicitly this is a parallel query plan
select set_config('babelfishpg_tsql.explain_timing', 'off', false);
GO
~~START~~
text
off
~~END~~


select set_config('babelfishpg_tsql.explain_summary', 'off', false);
GO
~~START~~
text
off
~~END~~


SELECT set_config('babelfishpg_tsql.explain_costs', 'off', false);
GO
~~START~~
text
off
~~END~~


SET BABELFISH_SHOWPLAN_ALL ON
GO

select a, count(*) from t_babel4261 group by a order by 2; -- should not crash
GO
~~START~~
text
Query Text: select a, count(*) from t_babel4261 group by a order by 2
Sort
Sort Key: (count(*)) NULLS FIRST
-> Finalize HashAggregate
Group Key: a
-> Gather
Workers Planned: 2
-> Partial HashAggregate
Group Key: a
-> Parallel Seq Scan on t_babel4261
~~END~~


-- set configurations back
SET BABELFISH_SHOWPLAN_ALL OFF
GO

select a, count(*) from t_babel4261 group by a order by 2; -- should not crash
GO
~~START~~
int#!#int
~~END~~


select set_config('babelfishpg_tsql.explain_timing', 'on', false);
GO
~~START~~
text
on
~~END~~


select set_config('babelfishpg_tsql.explain_summary', 'on', false);
GO
~~START~~
text
on
~~END~~


SELECT set_config('babelfishpg_tsql.explain_costs', 'on', false);
GO
~~START~~
text
on
~~END~~


-- Commiting sets parallel_setup_cost, parallel_tuple_cost, min_parallel_table_scan_size back to default
COMMIT TRAN BABEL4261_T1;
GO


DROP TABLE t_babel4261;
GO



CREATE TABLE t2_babel4261 (a money);
GO

BEGIN TRAN BABEL4261_T2;
GO

ALTER TABLE t2_babel4261 SET (parallel_workers = 16); -- note: this is PG syntax, not T-SQL
ALTER TABLE t1_babel4261 SET (parallel_workers = 16); -- note: this is PG syntax, not T-SQL
GO

-- The third parameter is true to set config back to default after transaction is committed
Expand All @@ -146,17 +28,17 @@ text
~~END~~


--- INSERT SOME data into t2_babel4261
INSERT t2_babel4261 SELECT 0.4245*10000
INSERT t2_babel4261 SELECT 0.5234*10000
INSERT t2_babel4261 SELECT 0.1113*10000
INSERT t2_babel4261 SELECT 0.6732*10000
INSERT t2_babel4261 SELECT 0.3467*10000
INSERT t2_babel4261 SELECT 0.5213*10000
INSERT t2_babel4261 SELECT 0.9893*10000
INSERT t2_babel4261 SELECT 0.6034*10000
INSERT t2_babel4261 SELECT 0.3334*10000
INSERT t2_babel4261 SELECT 0.8888*10000
--- INSERT SOME data into t1_babel4261
INSERT t1_babel4261 SELECT 0.4245*10000
INSERT t1_babel4261 SELECT 0.5234*10000
INSERT t1_babel4261 SELECT 0.1113*10000
INSERT t1_babel4261 SELECT 0.6732*10000
INSERT t1_babel4261 SELECT 0.3467*10000
INSERT t1_babel4261 SELECT 0.5213*10000
INSERT t1_babel4261 SELECT 0.9893*10000
INSERT t1_babel4261 SELECT 0.6034*10000
INSERT t1_babel4261 SELECT 0.3334*10000
INSERT t1_babel4261 SELECT 0.8888*10000
GO
~~ROW COUNT: 1~~

Expand All @@ -179,8 +61,8 @@ GO
~~ROW COUNT: 1~~


SELECT sum(a) FROM t2_babel4261
SELECT sum(a) FROM t2_babel4261 -- should not crash
SELECT sum(a) FROM t1_babel4261
SELECT sum(a) FROM t1_babel4261 -- should not crash
GO
~~START~~
money
Expand All @@ -194,8 +76,9 @@ money


-- Commiting sets force_parallel_mode, parallel_setup_cost, parallel_tuple_cost back to default
COMMIT TRAN BABEL4261_T2;
COMMIT TRAN BABEL4261_T1;
GO

DROP TABLE t2_babel4261;
DROP TABLE t1_babel4261;
GO

92 changes: 19 additions & 73 deletions test/JDBC/input/BABEL-4261.sql
Original file line number Diff line number Diff line change
@@ -1,65 +1,10 @@
BEGIN TRAN BABEL4261_T1;
CREATE TABLE t1_babel4261 (a money);
GO

CREATE TABLE t_babel4261 (a int, b int);
BEGIN TRAN BABEL4261_T1;
GO

-- The third parameter is true to set config back to default after transaction is committed
select set_config('parallel_setup_cost', 0, true);
select set_config('parallel_tuple_cost', 0, true);
select set_config('min_parallel_table_scan_size', 0, true);
GO


-- show explicitly this is a parallel query plan
select set_config('babelfishpg_tsql.explain_timing', 'off', false);
GO

select set_config('babelfishpg_tsql.explain_summary', 'off', false);
GO

SELECT set_config('babelfishpg_tsql.explain_costs', 'off', false);
GO

SET BABELFISH_SHOWPLAN_ALL ON
GO

select a, count(*) from t_babel4261 group by a order by 2; -- should not crash
GO

-- set configurations back
SET BABELFISH_SHOWPLAN_ALL OFF
GO

select a, count(*) from t_babel4261 group by a order by 2; -- should not crash
GO

select set_config('babelfishpg_tsql.explain_timing', 'on', false);
GO

select set_config('babelfishpg_tsql.explain_summary', 'on', false);
GO

SELECT set_config('babelfishpg_tsql.explain_costs', 'on', false);
GO

-- Commiting sets parallel_setup_cost, parallel_tuple_cost, min_parallel_table_scan_size back to default
COMMIT TRAN BABEL4261_T1;
GO


DROP TABLE t_babel4261;
GO



CREATE TABLE t2_babel4261 (a money);
GO

BEGIN TRAN BABEL4261_T2;
GO

ALTER TABLE t2_babel4261 SET (parallel_workers = 16); -- note: this is PG syntax, not T-SQL
ALTER TABLE t1_babel4261 SET (parallel_workers = 16); -- note: this is PG syntax, not T-SQL
GO

-- The third parameter is true to set config back to default after transaction is committed
Expand All @@ -68,26 +13,27 @@ SELECT set_config('parallel_setup_cost', '0', true)
SELECT set_config('parallel_tuple_cost', '0', true)
GO

--- INSERT SOME data into t2_babel4261
INSERT t2_babel4261 SELECT 0.4245*10000
INSERT t2_babel4261 SELECT 0.5234*10000
INSERT t2_babel4261 SELECT 0.1113*10000
INSERT t2_babel4261 SELECT 0.6732*10000
INSERT t2_babel4261 SELECT 0.3467*10000
INSERT t2_babel4261 SELECT 0.5213*10000
INSERT t2_babel4261 SELECT 0.9893*10000
INSERT t2_babel4261 SELECT 0.6034*10000
INSERT t2_babel4261 SELECT 0.3334*10000
INSERT t2_babel4261 SELECT 0.8888*10000
--- INSERT SOME data into t1_babel4261
INSERT t1_babel4261 SELECT 0.4245*10000
INSERT t1_babel4261 SELECT 0.5234*10000
INSERT t1_babel4261 SELECT 0.1113*10000
INSERT t1_babel4261 SELECT 0.6732*10000
INSERT t1_babel4261 SELECT 0.3467*10000
INSERT t1_babel4261 SELECT 0.5213*10000
INSERT t1_babel4261 SELECT 0.9893*10000
INSERT t1_babel4261 SELECT 0.6034*10000
INSERT t1_babel4261 SELECT 0.3334*10000
INSERT t1_babel4261 SELECT 0.8888*10000
GO

SELECT sum(a) FROM t2_babel4261
SELECT sum(a) FROM t2_babel4261 -- should not crash
SELECT sum(a) FROM t1_babel4261
SELECT sum(a) FROM t1_babel4261 -- should not crash
GO

-- Commiting sets force_parallel_mode, parallel_setup_cost, parallel_tuple_cost back to default
COMMIT TRAN BABEL4261_T2;
COMMIT TRAN BABEL4261_T1;
GO

DROP TABLE t2_babel4261;
DROP TABLE t1_babel4261;
GO

0 comments on commit 4cd3eb1

Please sign in to comment.