Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash in fixeddecimalaggstateserialize and fixeddecimalaggstatedeserialize for parallel queries #1999

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions contrib/babelfishpg_money/fixeddecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2984,6 +2984,9 @@ fixeddecimalaggstateserialize(PG_FUNCTION_ARGS)
if (!AggCheckCallContext(fcinfo, NULL))
elog(ERROR, "aggregate function called in non-aggregate context");

if (PG_ARGISNULL(0))
PG_RETURN_NULL();

state = (FixedDecimalAggState *) PG_GETARG_POINTER(0);

pq_begintypsend(&buf);
Expand All @@ -3009,6 +3012,9 @@ fixeddecimalaggstatedeserialize(PG_FUNCTION_ARGS)
if (!AggCheckCallContext(fcinfo, NULL))
elog(ERROR, "aggregate function called in non-aggregate context");

if (PG_ARGISNULL(0))
PG_RETURN_NULL();

sstate = PG_GETARG_BYTEA_P(0);

/*
Expand Down
84 changes: 84 additions & 0 deletions test/JDBC/expected/BABEL-4261.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
CREATE TABLE t1_babel4261 (a money);
GO

BEGIN TRAN BABEL4261_T1;
GO

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
SELECT set_config('force_parallel_mode', '1', true)
SELECT set_config('parallel_setup_cost', '0', true)
SELECT set_config('parallel_tuple_cost', '0', true)
GO
~~START~~
text
on
~~END~~

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

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


--- 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~~

~~ROW COUNT: 1~~

~~ROW COUNT: 1~~

~~ROW COUNT: 1~~

~~ROW COUNT: 1~~

~~ROW COUNT: 1~~

~~ROW COUNT: 1~~

~~ROW COUNT: 1~~

~~ROW COUNT: 1~~

~~ROW COUNT: 1~~


SELECT sum(a) FROM t1_babel4261
SELECT sum(a) FROM t1_babel4261 -- should not crash
GO
~~START~~
money
54153.0000
~~END~~

~~START~~
money
54153.0000
~~END~~


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

DROP TABLE t1_babel4261;
GO

39 changes: 39 additions & 0 deletions test/JDBC/input/BABEL-4261.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
CREATE TABLE t1_babel4261 (a money);
GO

BEGIN TRAN BABEL4261_T1;
GO

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
SELECT set_config('force_parallel_mode', '1', true)
SELECT set_config('parallel_setup_cost', '0', true)
SELECT set_config('parallel_tuple_cost', '0', true)
GO

--- 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 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_T1;
GO

DROP TABLE t1_babel4261;
GO

3 changes: 0 additions & 3 deletions test/JDBC/parallel_query_jdbc_schedule
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,6 @@ ignore#!#Test-sp_addrolemember-dep-vu-verify
ignore#!#Test-sp_droprolemember-dep-vu-verify
ignore#!#babel_table_type

# BABEL-4422
ignore#!#babel_money

# BABEL-4423
ignore#!#BABEL-IDENTITY

Expand Down
Loading