Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5afaba9

Browse files
committed
bugfix: use different memory context for reloptions
1 parent feadce8 commit 5afaba9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pg_pageprep.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,9 @@ print_tuple(TupleDesc tupdesc, HeapTuple tuple)
17231723
static void (*orig_intorel_startup)
17241724
(DestReceiver *self, int operation, TupleDesc typeinfo) = NULL;
17251725

1726+
#define PointerMemoryContext(pointer) \
1727+
(*(MemoryContext *) (((char *) pointer) - sizeof(void *)))
1728+
17261729
static void
17271730
our_intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
17281731
{
@@ -1745,9 +1748,11 @@ our_intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
17451748
{
17461749
/*
17471750
* we just add one parameter to make that reloptions will be created
1748-
* and we can fill fillfactor at relcache hook
1751+
* and we can fill fillfactor at relcache hook. We use memory context
1752+
* of the IntoClause since this plan could be cached and hense
1753+
* transaction memory context won't be available anymore.
17491754
*/
1750-
oldcontext = MemoryContextSwitchTo(MessageContext);
1755+
oldcontext = MemoryContextSwitchTo(PointerMemoryContext(into));
17511756
#if PG_VERSION_NUM >= 100000
17521757
def = makeDefElemExtended("toast", "autovacuum_enabled", NULL, DEFELEM_SET, -1);
17531758
#else

0 commit comments

Comments
 (0)