Skip to content

Commit

Permalink
PG17 regress sanity: fix diffs in multi_router_planner,
Browse files Browse the repository at this point in the history
multi_router_planner_fast_path and query_single_shard_table

Restore the expected DEBUG error messages from the router planner.
In the case of query_single_shard_table the diffs are because of
PG17's ability to pull up correlated ANY subqueries (*). The fix
is to inhibit pull up with a volatile function.

In the case of multi_router_planner and multi_router_planner_fast_path
the diffs are because of PG17's ability to remove redundant IS (NOT)
NULL expressions (**). The fix is to adjust the table definition so
the column used for distribution is not marked NOT NULL.

(*) https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=9f1337639
(**) https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=b262ad440
  • Loading branch information
colm-mchugh committed Nov 25, 2024
1 parent c396ce6 commit 2d0e9ae
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/test/regress/expected/multi_router_planner.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CREATE SCHEMA multi_router_planner;
SET search_path TO multi_router_planner;
CREATE TABLE articles_hash (
id bigint NOT NULL,
author_id bigint NOT NULL,
author_id bigint,
title varchar(20) NOT NULL,
word_count integer
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ DEBUG: query has a single distribution column value: 10
SELECT *
FROM articles_hash a
WHERE a.author_id is null;
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Creating router plan
id | author_id | title | word_count
---------------------------------------------------------------------
(0 rows)
Expand Down
8 changes: 4 additions & 4 deletions src/test/regress/expected/query_single_shard_table.out
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ DEBUG: Local tables cannot be used in distributed queries.
DEBUG: skipping recursive planning for the subquery since it contains references to outer queries
ERROR: direct joins between distributed and local tables are not supported
SELECT COUNT(*) FROM nullkey_c1_t1 t1
WHERE t1.b IN (
WHERE t1.b + random() IN (
SELECT b+1 FROM citus_local_table t2 WHERE t2.b = t1.a
);
DEBUG: router planner does not support queries that reference non-colocated distributed tables
Expand Down Expand Up @@ -1258,7 +1258,7 @@ DEBUG: Local tables cannot be used in distributed queries.
DEBUG: skipping recursive planning for the subquery since it contains references to outer queries
ERROR: direct joins between distributed and local tables are not supported
SELECT COUNT(*) FROM citus_local_table t1
WHERE t1.b IN (
WHERE t1.b + random() IN (
SELECT b+1 FROM nullkey_c1_t1 t2 WHERE t2.b = t1.a
);
DEBUG: router planner does not support queries that reference non-colocated distributed tables
Expand Down Expand Up @@ -1312,7 +1312,7 @@ DEBUG: skipping recursive planning for the subquery since it contains reference
ERROR: direct joins between distributed and local tables are not supported
HINT: Use CTE's or subqueries to select from local tables and use them in joins
SELECT COUNT(*) FROM nullkey_c1_t1 t1
WHERE t1.b IN (
WHERE t1.b + random() IN (
SELECT b+1 FROM postgres_local_table t2 WHERE t2.b = t1.a
);
DEBUG: found no worker with all shard placements
Expand Down Expand Up @@ -1344,7 +1344,7 @@ DEBUG: skipping recursive planning for the subquery since it contains reference
ERROR: direct joins between distributed and local tables are not supported
HINT: Use CTE's or subqueries to select from local tables and use them in joins
SELECT COUNT(*) FROM postgres_local_table t1
WHERE t1.b IN (
WHERE t1.b + random() IN (
SELECT b+1 FROM nullkey_c1_t1 t2 WHERE t2.b = t1.a
);
DEBUG: found no worker with all shard placements
Expand Down
2 changes: 1 addition & 1 deletion src/test/regress/sql/multi_router_planner.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SET search_path TO multi_router_planner;

CREATE TABLE articles_hash (
id bigint NOT NULL,
author_id bigint NOT NULL,
author_id bigint,
title varchar(20) NOT NULL,
word_count integer
);
Expand Down
8 changes: 4 additions & 4 deletions src/test/regress/sql/query_single_shard_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ WHERE NOT EXISTS (
);

SELECT COUNT(*) FROM nullkey_c1_t1 t1
WHERE t1.b IN (
WHERE t1.b + random() IN (
SELECT b+1 FROM citus_local_table t2 WHERE t2.b = t1.a
);

Expand Down Expand Up @@ -543,7 +543,7 @@ WHERE EXISTS (
);

SELECT COUNT(*) FROM citus_local_table t1
WHERE t1.b IN (
WHERE t1.b + random() IN (
SELECT b+1 FROM nullkey_c1_t1 t2 WHERE t2.b = t1.a
);

Expand Down Expand Up @@ -573,7 +573,7 @@ WHERE NOT EXISTS (
);

SELECT COUNT(*) FROM nullkey_c1_t1 t1
WHERE t1.b IN (
WHERE t1.b + random() IN (
SELECT b+1 FROM postgres_local_table t2 WHERE t2.b = t1.a
);

Expand All @@ -593,7 +593,7 @@ WHERE EXISTS (
);

SELECT COUNT(*) FROM postgres_local_table t1
WHERE t1.b IN (
WHERE t1.b + random() IN (
SELECT b+1 FROM nullkey_c1_t1 t2 WHERE t2.b = t1.a
);

Expand Down

0 comments on commit 2d0e9ae

Please sign in to comment.