forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0bb8528
committed
Fix postgres_fdw to return the right ctid value in EvalPlanQual cases.
If a postgres_fdw foreign table is a non-locked source relation in anUPDATE, DELETE, or SELECT FOR UPDATE/SHARE, and the query selects itsctid column, the wrong value would be returned if an EvalPlanQualrecheck occurred. This happened because the foreign table's result rowwas copied via the ROW_MARK_COPY code path, and EvalPlanQualFetchRowMarksjust unconditionally set the reconstructed tuple's t_self to "invalid".To fix that, we can have EvalPlanQualFetchRowMarks copy the compositedatum's t_ctid field, and be sure to initialize that along with t_selfwhen postgres_fdw constructs a tuple to return.If we just did that much then EvalPlanQualFetchRowMarks would startreturning "(0,0)" as ctid for all other ROW_MARK_COPY cases, which perhapsdoes not matter much, but then again maybe it might. The cause of that isthat heap_form_tuple, which is the ultimate source of all composite datums,simply leaves t_ctid as zeroes in newly constructed tuples. That seemslike a bad idea on general principles: a field that's really not beeninitialized shouldn't appear to have a valid value. So let's eat thetrivial additional overhead of doing "ItemPointerSetInvalid(&(td->t_ctid))"in heap_form_tuple.This closes out our handling of Etsuro Fujita's report that tableoid andctid weren't correctly set in postgres_fdw EvalPlanQual cases. Along theway we did a great deal of work to improve FDWs' ability to control rowlocking behavior; which was not wasted effort by any means, but it didn'tend up being a fix for this problem because that feature would be tooexpensive for postgres_fdw to use all the time.Although the fix for the tableoid misbehavior was back-patched, I'mhesitant to do so here; it seems far less likely that people would careabout remote ctid than tableoid, and even such a minor behavioral changeas this in heap_form_tuple is perhaps best not back-patched. So committo HEAD only, at least for the moment.Etsuro Fujita, with some adjustments by me1 parent3f2cec7 commit0bb8528
File tree
3 files changed
+12
-3
lines changed- contrib/postgres_fdw
- src/backend
- access/common
- executor
3 files changed
+12
-3
lines changedLines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2964 | 2964 |
| |
2965 | 2965 |
| |
2966 | 2966 |
| |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
2967 | 2973 |
| |
2968 |
| - | |
| 2974 | + | |
2969 | 2975 |
| |
2970 | 2976 |
| |
2971 | 2977 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
727 | 727 |
| |
728 | 728 |
| |
729 | 729 |
| |
| 730 | + | |
| 731 | + | |
730 | 732 |
| |
731 | 733 |
| |
732 | 734 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2613 | 2613 |
| |
2614 | 2614 |
| |
2615 | 2615 |
| |
2616 |
| - | |
| 2616 | + | |
2617 | 2617 |
| |
2618 | 2618 |
| |
2619 |
| - | |
| 2619 | + | |
| 2620 | + | |
2620 | 2621 |
| |
2621 | 2622 |
| |
2622 | 2623 |
| |
|
0 commit comments
Comments
(0)