Hi, Thanks for the report.
On 2016/04/04 15:17, Rajkumar Raghuwanshi wrote: > Hi, > > I observed below in postgres_fdw > > * .Observation: *Prepare statement execution plan is not getting changed > even after altering foreign table to point to new schema. > [ ... ] > PREPARE stmt_ft AS select c1,c2 from ft; > > EXECUTE stmt_ft; > c1 | c2 > ----+------- > 1 | s1.lt > (1 row) > > --changed foreign table ft pointing schema from s1 to s2 > ALTER foreign table ft options (SET schema_name 's2', SET table_name 'lt'); > ANALYZE ft; > > EXPLAIN (COSTS OFF, VERBOSE) EXECUTE stmt_ft; > QUERY PLAN > ---------------------------------------- > Foreign Scan on public.ft > Output: c1, c2 > Remote SQL: SELECT c1, c2 FROM s1.lt > (3 rows) I wonder if performing relcache invalidation upon ATExecGenericOptions() is the correct solution for this problem. The attached patch fixes the issue for me. Thanks, Amit
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 9e9082d..6a4e1d6 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -11642,6 +11642,13 @@ ATExecGenericOptions(Relation rel, List *options) simple_heap_update(ftrel, &tuple->t_self, tuple); CatalogUpdateIndexes(ftrel, tuple); + /* + * Invalidate the relcache for the table, so that after this commit + * all sessions will refresh any cached plans that are based on older + * values of the options. + */ + CacheInvalidateRelcache(rel); + InvokeObjectPostAlterHook(ForeignTableRelationId, RelationGetRelid(rel), 0);
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers