Skip to content

Commit ba22bba

Browse files
author
Vladimir Ershov
committed
worker conetxt
1 parent 141c609 commit ba22bba

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/scheduler_manager.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ int update_cron_texttime(scheduler_manager_ctx_t *ctx, int cron_id, TimestampTz
13641364
{
13651365
nulls[1] = 'n';
13661366
}
1367-
r = execute_spi_sql_with_args(CurrentMemoryContext, sql, 2, types, values, nulls);
1367+
r = execute_spi_sql_with_args(SchedulerWorkerContext, sql, 2, types, values, nulls);
13681368
ret = r->retval;
13691369
if(ret < 0)
13701370
{
@@ -1487,7 +1487,7 @@ int insert_at_record(char *nodename, int cron_id, TimestampTz start_at, Timestam
14871487
values[1] = 0;
14881488
}
14891489

1490-
r = execute_spi_sql_with_args(CurrentMemoryContext, insert_sql, 4, argtypes, values, nulls);
1490+
r = execute_spi_sql_with_args(SchedulerWorkerContext, insert_sql, 4, argtypes, values, nulls);
14911491

14921492
ret = r->retval;
14931493
if(r->error) *error = my_copy_string(r->error);

src/scheduler_spi_utils.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,13 @@ spi_response_t *execute_spi_sql_with_args(MemoryContext ctx, const char *sql, in
495495
char other[100];
496496
ResourceOwner oldowner = CurrentResourceOwner;
497497
spi_response_t *rv = NULL;
498+
MemoryContext old;
499+
498500
if(!ctx) ctx = SchedulerWorkerContext;
499501

500502
SetCurrentStatementStartTimestamp();
501503
BeginInternalSubTransaction(NULL);
502-
MemoryContextSwitchTo(ctx);
504+
old = MemoryContextSwitchTo(ctx);
503505

504506
PG_TRY();
505507
{
@@ -572,10 +574,12 @@ spi_response_t *execute_spi_sql_with_args(MemoryContext ctx, const char *sql, in
572574
if(!rv)
573575
{
574576
elog(LOG, "ESSWA: Cannot allocate memory while reporting pg error");
577+
MemoryContextSwitchTo(old);
575578
return NULL;
576579
}
577580
}
578581

582+
MemoryContextSwitchTo(old);
579583
return rv;
580584
}
581585

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy