mirror of https://github.com/citusdata/citus.git
Test a query that failed on 9.5.8 when coordinator is in metadata (#5412)
This test starts passing because of PR #4508, to be precise commit:
24e60b44a1
When I undo that commit this newly added test starts failing. This adds
this test to make sure we don't regress on this again.
pull/5431/head
parent
d691148e7e
commit
0cb51f8c37
|
@ -464,6 +464,51 @@ WHERE x IN (SELECT num FROM cte_1);
|
||||||
3
|
3
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO ref VALUES (1, 1), (3, 3), (4, 4);
|
||||||
|
INSERT INTO ref2 VALUES (1, 1), (2, 2), (3, 3), (5, 5);
|
||||||
|
-- multiple CTEs working together
|
||||||
|
-- this qeury was reported as a bug by a user
|
||||||
|
WITH cte_ref AS (
|
||||||
|
SELECT a as abc from ref where a IN (1, 2)
|
||||||
|
),
|
||||||
|
cte_join1 AS (
|
||||||
|
SELECT
|
||||||
|
2 as result
|
||||||
|
FROM cte_ref
|
||||||
|
JOIN ref2 AS reff ON reff.b = cte_ref.abc
|
||||||
|
),
|
||||||
|
cte_join2 AS (
|
||||||
|
SELECT
|
||||||
|
1 as result
|
||||||
|
FROM cte_ref
|
||||||
|
LEFT JOIN test
|
||||||
|
ON test.x = cte_ref.abc
|
||||||
|
WHERE test.x IN (1, 2)
|
||||||
|
AND x > 0
|
||||||
|
),
|
||||||
|
cte_with_subq AS (
|
||||||
|
SELECT
|
||||||
|
(SELECT result FROM cte_join1 where result::int > 0) as result
|
||||||
|
FROM cte_join2
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
(SELECT result FROM cte_join1 where result::int < 10) as result
|
||||||
|
FROM cte_ref
|
||||||
|
)
|
||||||
|
SELECT * from cte_with_subq
|
||||||
|
UNION ALL SELECT 3 FROM cte_join1
|
||||||
|
UNION ALL SELECT 4 FROM cte_ref
|
||||||
|
ORDER BY 1;
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
2
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
-- query fails on the shards should be handled
|
-- query fails on the shards should be handled
|
||||||
-- nicely
|
-- nicely
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY terse
|
||||||
|
|
|
@ -46,6 +46,13 @@ SELECT create_reference_table('ref');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TABLE ref2(a int, b int);
|
||||||
|
SELECT create_reference_table('ref2');
|
||||||
|
create_reference_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
CREATE TABLE local(c int, d int);
|
CREATE TABLE local(c int, d int);
|
||||||
select citus_add_local_table_to_metadata('local');
|
select citus_add_local_table_to_metadata('local');
|
||||||
citus_add_local_table_to_metadata
|
citus_add_local_table_to_metadata
|
||||||
|
|
|
@ -245,6 +245,47 @@ FROM
|
||||||
test
|
test
|
||||||
WHERE x IN (SELECT num FROM cte_1);
|
WHERE x IN (SELECT num FROM cte_1);
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO ref VALUES (1, 1), (3, 3), (4, 4);
|
||||||
|
INSERT INTO ref2 VALUES (1, 1), (2, 2), (3, 3), (5, 5);
|
||||||
|
-- multiple CTEs working together
|
||||||
|
-- this qeury was reported as a bug by a user
|
||||||
|
WITH cte_ref AS (
|
||||||
|
SELECT a as abc from ref where a IN (1, 2)
|
||||||
|
),
|
||||||
|
cte_join1 AS (
|
||||||
|
SELECT
|
||||||
|
2 as result
|
||||||
|
FROM cte_ref
|
||||||
|
JOIN ref2 AS reff ON reff.b = cte_ref.abc
|
||||||
|
),
|
||||||
|
cte_join2 AS (
|
||||||
|
SELECT
|
||||||
|
1 as result
|
||||||
|
FROM cte_ref
|
||||||
|
LEFT JOIN test
|
||||||
|
ON test.x = cte_ref.abc
|
||||||
|
WHERE test.x IN (1, 2)
|
||||||
|
AND x > 0
|
||||||
|
),
|
||||||
|
cte_with_subq AS (
|
||||||
|
SELECT
|
||||||
|
(SELECT result FROM cte_join1 where result::int > 0) as result
|
||||||
|
FROM cte_join2
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
(SELECT result FROM cte_join1 where result::int < 10) as result
|
||||||
|
FROM cte_ref
|
||||||
|
)
|
||||||
|
|
||||||
|
SELECT * from cte_with_subq
|
||||||
|
UNION ALL SELECT 3 FROM cte_join1
|
||||||
|
UNION ALL SELECT 4 FROM cte_ref
|
||||||
|
ORDER BY 1;
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
-- query fails on the shards should be handled
|
-- query fails on the shards should be handled
|
||||||
-- nicely
|
-- nicely
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY terse
|
||||||
|
|
|
@ -30,6 +30,9 @@ SELECT create_distributed_table('test_2','x');
|
||||||
CREATE TABLE ref(a int, b int);
|
CREATE TABLE ref(a int, b int);
|
||||||
SELECT create_reference_table('ref');
|
SELECT create_reference_table('ref');
|
||||||
|
|
||||||
|
CREATE TABLE ref2(a int, b int);
|
||||||
|
SELECT create_reference_table('ref2');
|
||||||
|
|
||||||
CREATE TABLE local(c int, d int);
|
CREATE TABLE local(c int, d int);
|
||||||
select citus_add_local_table_to_metadata('local');
|
select citus_add_local_table_to_metadata('local');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue