fix: serialize data instead of pointer in plan_foreign_modify #548
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Summary
Fix PostgreSQL server crash when using prepared statements with foreign tables.
Fixes #482
Related to #237
Problem
PostgreSQL caches query plans after ~5-6 executions (generic plan optimization).
The previous implementation stored a raw pointer to
FdwModifyStateinfdw_private, which became invalid afterend_foreign_modifyfreed the state.Subsequent executions with cached plans dereferenced this stale pointer, causing
a crash.
Solution
FdwModifyPrivatestruct holding serializable reconstruction dataplan_foreign_modifyFdwModifyStateinbegin_foreign_modifyfor each executionChanges
supabase-wrappers/src/modify.rs: Core fix - serialize data instead of pointerwrappers/src/fdw/clickhouse_fdw/tests.rs: Added stress testTest Plan