mirror of https://github.com/citusdata/citus.git
fix
parent
c2bc7aca4a
commit
fe7d25ef77
|
@ -0,0 +1 @@
|
|||
Subproject commit 3376bd6845f0614908ed304f5033bd644c82d3bf
|
|
@ -441,7 +441,7 @@ FilterShardsFromPgclass(Node *node, void *context)
|
|||
/*
|
||||
* We process the whole rtable rather than visiting individual RangeTblEntry's
|
||||
* in the walker, since we need to know the varno to generate the right
|
||||
* fiter.
|
||||
* filter.
|
||||
*/
|
||||
int varno = 0;
|
||||
RangeTblEntry *rangeTableEntry = NULL;
|
||||
|
@ -471,9 +471,26 @@ FilterShardsFromPgclass(Node *node, void *context)
|
|||
/* make sure the expression is in the right memory context */
|
||||
MemoryContext originalContext = MemoryContextSwitchTo(queryContext);
|
||||
|
||||
|
||||
/* add relation_is_a_known_shard(oid) IS NOT TRUE to the quals of the query */
|
||||
Node *newQual = CreateRelationIsAKnownShardFilter(varno);
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_17
|
||||
/*
|
||||
* In PG17, MERGE queries introduce a new struct `mergeJoinCondition`.
|
||||
* We need to handle this condition safely.
|
||||
*/
|
||||
if (query->mergeJoinCondition != NULL)
|
||||
{
|
||||
/* Add the filter to mergeJoinCondition */
|
||||
query->mergeJoinCondition = (Node *) makeBoolExpr(
|
||||
AND_EXPR,
|
||||
list_make2(query->mergeJoinCondition, newQual),
|
||||
-1);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Handle older versions or queries without mergeJoinCondition */
|
||||
Node *oldQuals = query->jointree->quals;
|
||||
if (oldQuals)
|
||||
{
|
||||
|
@ -486,6 +503,7 @@ FilterShardsFromPgclass(Node *node, void *context)
|
|||
{
|
||||
query->jointree->quals = newQual;
|
||||
}
|
||||
}
|
||||
|
||||
MemoryContextSwitchTo(originalContext);
|
||||
}
|
||||
|
|
|
@ -2690,6 +2690,32 @@ SELECT * FROM sensor_readings ORDER BY 1;
|
|||
(4 rows)
|
||||
|
||||
-- End of MERGE ... WHEN NOT MATCHED BY SOURCE tests
|
||||
-- Issue #7846
|
||||
-- Create a non-distributed table with a random suffix
|
||||
CREATE TABLE non_dist_table_12345 (id INTEGER);
|
||||
-- Test crash scenario on a non-distributed table
|
||||
MERGE INTO non_dist_table_12345 AS target_0
|
||||
USING pg_catalog.pg_class AS ref_0
|
||||
ON target_0.id = ref_0.relpages
|
||||
WHEN NOT MATCHED THEN DO NOTHING;
|
||||
-- Create a distributed table with a random suffix
|
||||
CREATE TABLE dist_table_67890 (id INTEGER);
|
||||
SELECT create_distributed_table('dist_table_67890', 'id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- Test crash scenario on a distributed table
|
||||
MERGE INTO dist_table_67890 AS target_0
|
||||
USING pg_catalog.pg_class AS ref_0
|
||||
ON target_0.id = ref_0.relpages
|
||||
WHEN NOT MATCHED THEN DO NOTHING;
|
||||
ERROR: MERGE INTO an distributed table from Postgres table is not yet supported
|
||||
-- Cleanup
|
||||
DROP TABLE IF EXISTS non_dist_table_12345;
|
||||
DROP TABLE IF EXISTS dist_table_67890 CASCADE;
|
||||
-- End of Issue #7846
|
||||
\set VERBOSITY terse
|
||||
SET client_min_messages TO WARNING;
|
||||
DROP SCHEMA pg17 CASCADE;
|
||||
|
|
|
@ -1451,6 +1451,31 @@ SELECT * FROM sensor_readings ORDER BY 1;
|
|||
|
||||
-- End of MERGE ... WHEN NOT MATCHED BY SOURCE tests
|
||||
|
||||
-- Issue #7846
|
||||
-- Create a non-distributed table with a random suffix
|
||||
CREATE TABLE non_dist_table_12345 (id INTEGER);
|
||||
|
||||
-- Test crash scenario on a non-distributed table
|
||||
MERGE INTO non_dist_table_12345 AS target_0
|
||||
USING pg_catalog.pg_class AS ref_0
|
||||
ON target_0.id = ref_0.relpages
|
||||
WHEN NOT MATCHED THEN DO NOTHING;
|
||||
|
||||
-- Create a distributed table with a random suffix
|
||||
CREATE TABLE dist_table_67890 (id INTEGER);
|
||||
SELECT create_distributed_table('dist_table_67890', 'id');
|
||||
|
||||
-- Test crash scenario on a distributed table
|
||||
MERGE INTO dist_table_67890 AS target_0
|
||||
USING pg_catalog.pg_class AS ref_0
|
||||
ON target_0.id = ref_0.relpages
|
||||
WHEN NOT MATCHED THEN DO NOTHING;
|
||||
|
||||
-- Cleanup
|
||||
DROP TABLE IF EXISTS non_dist_table_12345;
|
||||
DROP TABLE IF EXISTS dist_table_67890 CASCADE;
|
||||
-- End of Issue #7846
|
||||
|
||||
\set VERBOSITY terse
|
||||
SET client_min_messages TO WARNING;
|
||||
DROP SCHEMA pg17 CASCADE;
|
||||
|
|
Loading…
Reference in New Issue