Commit 8457bf6
authored
Resolve inconsistent result issue in gpdtm_plpgsql test case (apache#491)
Fix apache#478
Change logs
ICW testcase gpdtm_plpgsql failed intermittently. The result of the following statements is not consistent.
CREATE TABLE test_parse_arr (a bigserial, b int[]);
-- parse_arr function is defined as a udf to convert string into in array, but it is not important to this issue
INSERT INTO test_parse_arr (b)
SELECT parse_arr(x) as pr FROM
(
SELECT '(1, 2, 3)' AS x
UNION ALL
SELECT NULL
UNION ALL
SELECT '(4, 5, 6)' AS x
) AS q order by pr ;
SELECT * FROM test_parse_arr ORDER BY a;
Here are results from two separate executions.
a | b
---+-----------
1 | {{4,5,6}}
2 | {{1,2,3}}
3 |
(3 rows)
a | b
---+-----------
1 |
2 | {{1,2,3}}
3 | {{4,5,6}}
(3 rows)
It is not a cbdb bug. Even though the ORDER BY clause in the INSERT statement ensures the elements in array b are ordered, due to data distribution mechanics—where data is dispatched to different nodes for processing — the sequential generation of auto-increment values(for column a) across these nodes cannot be consistently guaranteed.
Consequently, when querying "SELECT * FROM test_parse_arr ORDER BY a" the resulting sequence may not reflect the initial order of the array elements as they were inserted.
The test case need to be modified to make sure test result consistent.
Instead of verifying result via "SELECT * FROM test_parse_arr ORDER BY a" , verify column a and b separately as following:
SELECT a FROM test_parse_arr ORDER BY a;
SELECT b FROM test_parse_arr ORDER BY b;1 parent 705ee0b commit 8457bf6
2 files changed
Lines changed: 37 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
551 | 563 | | |
552 | 564 | | |
553 | 565 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
313 | 318 | | |
314 | 319 | | |
315 | 320 | | |
| |||
0 commit comments