fmgr_info() must be called in the applyCacheContext.
authorJan Wieck <[email protected]>
Wed, 13 Feb 2013 23:13:24 +0000 (18:13 -0500)
committerJan Wieck <[email protected]>
Wed, 13 Feb 2013 23:13:24 +0000 (18:13 -0500)
Subsequent calls using the FmgrInfo structure may add more
sub elements to the info. This will be allocated in the same
memory context, the fmgr_info() call was made in. That
context must exist at least long enough as the FmgrInfo
call itself exists.

src/backend/slony1_funcs.c

index 18cf7267dd25a84d60ed34cde37b6de1c4df453c..a186f448f35c0732ff4990134ebc8cec1866dfba 100644 (file)
@@ -1406,7 +1406,9 @@ _Slony_I_logApply(PG_FUNCTION_ARGS)
                                                         querycolnames[i / 2]);
                                        getTypeInputInfo(coltype, &typinput,
                                                        &(cacheEnt->typioparam[i / 2]));
+                                       oldContext = MemoryContextSwitchTo(applyCacheContext);
                                        fmgr_info(typinput, &(cacheEnt->finfo_input[i / 2]));
+                                       MemoryContextSwitchTo(oldContext);
                                        cacheEnt->typmod[i / 2] =
                                                target_rel->rd_att->attrs[colnum - 1]->atttypmod;
 
@@ -1471,7 +1473,9 @@ _Slony_I_logApply(PG_FUNCTION_ARGS)
                                                         colname);
                                        getTypeInputInfo(coltype, &typinput,
                                                        &(cacheEnt->typioparam[i / 2]));
+                                       oldContext = MemoryContextSwitchTo(applyCacheContext);
                                        fmgr_info(typinput, &(cacheEnt->finfo_input[i / 2]));
+                                       MemoryContextSwitchTo(oldContext);
                                        cacheEnt->typmod[i / 2] =
                                                target_rel->rd_att->attrs[colnum - 1]->atttypmod;
 
@@ -1566,7 +1570,9 @@ _Slony_I_logApply(PG_FUNCTION_ARGS)
                                                         colname);
                                        getTypeInputInfo(coltype, &typinput,
                                                        &(cacheEnt->typioparam[i / 2]));
+                                       oldContext = MemoryContextSwitchTo(applyCacheContext);
                                        fmgr_info(typinput, &(cacheEnt->finfo_input[i / 2]));
+                                       MemoryContextSwitchTo(oldContext);
                                        cacheEnt->typmod[i / 2] =
                                                target_rel->rd_att->attrs[colnum - 1]->atttypmod;