-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve TDS protocol violation occurring due to parallel query enforc…
…ed (#1937) (#2046) This issue was mainly caused by incorrect inference of typmod information for numeric expression where its being set to default when Parallel worker is planned. Reason for the same is explained below: When parallel query is enforced, Postgres engine planes Gather node on the top of top plan. For example, consider following query - SELECT amount + 100 FROM overflow_test where id = 1 -- If parallel query is not enforced- Query Text: SELECT amount + 100 FROM overflow_test where id = 1 Index Scan using overflow_test_pkey on master_dbo.overflow_test (cost=0.15..8.17 rows=1 width=32) Output: ((amount)::numeric + '100'::numeric) Index Cond: (overflow_test.id = 1) -- If parallel query is enforced then Postgres will wrap the above plan under Gather node - Query Text: SELECT amount + 100 FROM overflow_test where id = 1 Gather (cost=0.15..8.17 rows=1 width=32) Output: (((amount)::numeric + '100'::numeric)) Workers Planned: 1 Single Copy: true -> Index Scan using overflow_test_pkey on master_dbo.overflow_test (cost=0.15..8.17 rows=1 width=32) Output: ((amount)::numeric + '100'::numeric) Index Cond: (overflow_test.id = 1) When Postgres does this, it also modifies targetlist of gather node to refer to the tuples returned by its lefttree subplan or outerplan (Indexscan in this case). Hence, targetlist of gather node will contain only one tle in above case which is Var with attno = OUTER_VAR (it indicates reference to its outer plan) and vartypmod being -1. Now, While sending metadata from TDS layer we use this typmod to deduce max_scale and precision for numeric. This would be set to default since vartypmod = -1 whereas actual data being computed may not fit in it hence it will run into an error while sending numeric response. Hence, hang or crash of end client software. This commit fixes this issue by taking special Var into account while We extract the information of outer plan from planned stmt and use the same to get the original/referenced tle from outer plan. This commit further improves the implementation of resolve_numeric_typmod_from_exp to handle reference to outer var correctly. It can now handle Append and MergeAppend node correctly which was required for following test case - -- setup create table t1 (a numeric(6,4), b numeric(6,3)); insert into t1 values (4, 16); insert into t1 values (10.1234, 10.123); insert into t1 values (1.2, 6); insert into t1 values (NULL, 101.123); -- test select a from t1 UNION All select b from t1; For this UNION ALL expression, typmod was always computed to be -1 which is not right and it should (7,4) ideally. This commit introduces helped function called resolve_numeric_typmod_from_append_or_mergeappend to compute typmod for expression correctly. Task: BABEL-4424, BABEL-4359 Signed-off-by: Dipesh Dhameliya <[email protected]>
- Loading branch information
1 parent
4af8ec3
commit 077febc
Showing
12 changed files
with
1,475 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.