Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit30a35bc

Browse files
committed
Fix crash in postgres_fdw for provably-empty remote UPDATE/DELETE.
In86dc900, I'd written find_modifytable_subplan with the assumptionthat if the immediate child of a ModifyTable is a Result, it must bea projecting Result with a subplan. However, if the UPDATE or DELETEhas a provably-constant-false WHERE clause, that's not so: we'llgenerate a dummy subplan with a childless Result. Add the missingnull-check so we don't crash on such cases.Per report from Alexander Pyhalov.Discussion:https://postgr.es/m/b9a6f53549456b2f3e2fd150dcd79d72@postgrespro.ru
1 parente48f2af commit30a35bc

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

‎contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6853,6 +6853,26 @@ DROP TRIGGER trig_row_before ON rem1;
68536853
DROP TRIGGER trig_row_after ON rem1;
68546854
DROP TRIGGER trig_local_before ON loc1;
68556855
-- Test direct foreign table modification functionality
6856+
EXPLAIN (verbose, costs off)
6857+
DELETE FROM rem1; -- can be pushed down
6858+
QUERY PLAN
6859+
---------------------------------------------
6860+
Delete on public.rem1
6861+
-> Foreign Delete on public.rem1
6862+
Remote SQL: DELETE FROM public.loc1
6863+
(3 rows)
6864+
6865+
EXPLAIN (verbose, costs off)
6866+
DELETE FROM rem1 WHERE false; -- currently can't be pushed down
6867+
QUERY PLAN
6868+
-------------------------------------------------------
6869+
Delete on public.rem1
6870+
Remote SQL: DELETE FROM public.loc1 WHERE ctid = $1
6871+
-> Result
6872+
Output: ctid
6873+
One-Time Filter: false
6874+
(5 rows)
6875+
68566876
-- Test with statement-level triggers
68576877
CREATE TRIGGER trig_stmt_before
68586878
BEFORE DELETE OR INSERT OR UPDATE ON rem1

‎contrib/postgres_fdw/postgres_fdw.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,9 @@ find_modifytable_subplan(PlannerInfo *root,
23702370
if (subplan_index<list_length(appendplan->appendplans))
23712371
subplan= (Plan*)list_nth(appendplan->appendplans,subplan_index);
23722372
}
2373-
elseif (IsA(subplan,Result)&&IsA(outerPlan(subplan),Append))
2373+
elseif (IsA(subplan,Result)&&
2374+
outerPlan(subplan)!=NULL&&
2375+
IsA(outerPlan(subplan),Append))
23742376
{
23752377
Append*appendplan= (Append*)outerPlan(subplan);
23762378

‎contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,10 @@ DROP TRIGGER trig_local_before ON loc1;
17381738

17391739

17401740
-- Test direct foreign table modification functionality
1741+
EXPLAIN (verbose, costs off)
1742+
DELETEFROM rem1;-- can be pushed down
1743+
EXPLAIN (verbose, costs off)
1744+
DELETEFROM rem1WHERE false;-- currently can't be pushed down
17411745

17421746
-- Test with statement-level triggers
17431747
CREATETRIGGERtrig_stmt_before

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp