Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5784b1a

Browse files
author
Vladimir Ershov
committed
fix free error
1 parente9aa92c commit5784b1a

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

‎src/scheduler_executor.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ int do_one_job(schd_executor_share_t *shared, schd_executor_status_t *status)
162162
inti;
163163
job_t*job;
164164
spi_response_t*r;
165-
MemoryContextold;
166-
MemoryContextmem=init_mem_ctx("executor");
167-
168-
old=MemoryContextSwitchTo(mem);
165+
MemoryContextold,mem;
169166

170167
EE.n=0;
171168
EE.errors=NULL;
@@ -178,6 +175,9 @@ int do_one_job(schd_executor_share_t *shared, schd_executor_status_t *status)
178175
return0;
179176
}
180177

178+
mem=init_mem_ctx("executor");
179+
old=MemoryContextSwitchTo(mem);
180+
181181
*status=shared->status=SchdExecutorWork;
182182
shared->message[0]=0;
183183

@@ -191,6 +191,9 @@ int do_one_job(schd_executor_share_t *shared, schd_executor_status_t *status)
191191
shared->worker_exit= true;
192192
*status=shared->status=SchdExecutorError;
193193

194+
MemoryContextSwitchTo(old);
195+
MemoryContextDelete(mem);
196+
194197
return-1;
195198
}
196199
current_job_id=job->cron_id;
@@ -211,6 +214,8 @@ int do_one_job(schd_executor_share_t *shared, schd_executor_status_t *status)
211214
}
212215
*status=shared->worker_exit= true;
213216
shared->status=SchdExecutorError;
217+
MemoryContextSwitchTo(old);
218+
MemoryContextDelete(mem);
214219
return-2;
215220
}
216221

@@ -257,7 +262,7 @@ int do_one_job(schd_executor_share_t *shared, schd_executor_status_t *status)
257262
destroy_spi_data(r);
258263
ABORT_SPI_SNAP();
259264
SetConfigOption("schedule.transaction_state","failure",PGC_INTERNAL,PGC_S_SESSION);
260-
executor_onrollback(job,&EE);
265+
executor_onrollback(mem,job,&EE);
261266

262267
break;
263268
}
@@ -467,7 +472,7 @@ TimestampTz get_next_excution_time(char *sql, executor_error_t *ee)
467472
returnts;
468473
}
469474

470-
intexecutor_onrollback(job_t*job,executor_error_t*ee)
475+
intexecutor_onrollback(MemoryContextmem,job_t*job,executor_error_t*ee)
471476
{
472477
intrv;
473478
spi_response_t*r;
@@ -476,7 +481,7 @@ int executor_onrollback(job_t *job, executor_error_t *ee)
476481
pgstat_report_activity(STATE_RUNNING,"execure onrollback");
477482

478483
START_SPI_SNAP();
479-
r=execute_spi(CurrentMemoryContext,job->onrollback);
484+
r=execute_spi(mem,job->onrollback);
480485
if(r->retval<0)
481486
{
482487
if(r->error)

‎src/scheduler_executor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extern PGDLLEXPORT void executor_worker_main(Datum arg);
6060
job_t*initializeExecutorJob(schd_executor_share_t*data);
6161
voidset_shared_message(schd_executor_share_t*shared,executor_error_t*ee);
6262
TimestampTzget_next_excution_time(char*sql,executor_error_t*ee);
63-
intexecutor_onrollback(job_t*job,executor_error_t*ee);
63+
intexecutor_onrollback(MemoryContextmem,job_t*job,executor_error_t*ee);
6464
voidset_pg_var(boolresulti,executor_error_t*ee);
6565
intpush_executor_error(executor_error_t*e,char*fmt, ...)pg_attribute_printf(2,3);
6666
intset_session_authorization(char*username,char**error);

‎src/scheduler_spi_utils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ spi_response_t *__error_spi_resp(MemoryContext ctx, int ret, char *error)
7878
r->retval=ret;
7979
r->types=NULL;
8080
r->rows=NULL;
81+
r->ref=NULL;
8182
r->error=_mcopy_string(ctx,error);
8283

8384
returnr;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp