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

Commit 0e38b2c

Browse files
author
Vladimir Ershov
committed
fix intersection
1 parent f08cb86 commit 0e38b2c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/scheduler_job.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ job_t *set_job_error(job_t *j, const char *fmt, ...)
462462

463463
int move_job_to_log(job_t *j, bool status, bool process)
464464
{
465-
if(j->type == CronJob) _cron_move_job_to_log(j, status);
465+
if(j->type == CronJob) return _cron_move_job_to_log(j, status);
466466
return _at_move_job_to_log(j, status, process);
467467
}
468468

@@ -513,9 +513,9 @@ int move_at_job_process(int job_id)
513513
int set_at_job_done(job_t *job, char *error, int64 resubmit, char **set_error)
514514
{
515515
char *this_error = NULL;
516-
Datum values[20];
517-
char nulls[20];
518-
Oid argtypes[20] = { INT4OID };
516+
Datum values[21];
517+
char nulls[21];
518+
Oid argtypes[21] = { INT4OID };
519519
bool canceled = false;
520520
int i;
521521
char *oldpath;
@@ -524,8 +524,9 @@ int set_at_job_done(job_t *job, char *error, int64 resubmit, char **set_error)
524524
int n = 1;
525525
spi_response_t *r;
526526
spi_response_t *r2;
527+
527528
const char *get_sql = "select * from at_jobs_process where id = $1";
528-
const char *insert_sql = "insert into at_jobs_done values($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20)";
529+
const char *insert_sql = "insert into at_jobs_done values($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21)";
529530
const char *delete_sql = "delete from at_jobs_process where id = $1";
530531
const char *resubmit_sql = "insert into at_jobs_submitted values($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)";
531532

@@ -558,8 +559,10 @@ int set_at_job_done(job_t *job, char *error, int64 resubmit, char **set_error)
558559
}
559560
argtypes[18] = BOOLOID;
560561
argtypes[19] = TEXTOID;
562+
argtypes[20] = TIMESTAMPTZOID;
561563
nulls[18] = ' ';
562564
nulls[19] = ' ';
565+
nulls[20] = ' ';
563566

564567
canceled = nulls[15] == 'n' ? false: DatumGetBool(values[15]);
565568

@@ -569,10 +572,11 @@ int set_at_job_done(job_t *job, char *error, int64 resubmit, char **set_error)
569572
{
570573
this_error = _copy_string("job was canceled while processing: cannot resubmit");
571574
sql = insert_sql;
572-
n = 20;
575+
n = 21;
573576

574577
values[18] = BoolGetDatum(false);
575578
values[19] = CStringGetTextDatum(this_error);
579+
values[20] = TimestampTzGetDatum(GetCurrentTimestamp());
576580
}
577581
else if(job->attempt + 1 < job->resubmit_limit)
578582
{
@@ -585,15 +589,16 @@ int set_at_job_done(job_t *job, char *error, int64 resubmit, char **set_error)
585589
{
586590
this_error = _copy_string("resubmit limit reached");
587591
sql = insert_sql;
588-
n = 20;
592+
n = 21;
589593

590594
values[18] = BoolGetDatum(false);
591595
values[19] = CStringGetTextDatum(this_error);
596+
values[20] = TimestampTzGetDatum(GetCurrentTimestamp());
592597
}
593598
}
594599
else
595600
{
596-
n = 20;
601+
n = 21;
597602
sql = insert_sql;
598603
if(error)
599604
{
@@ -605,6 +610,7 @@ int set_at_job_done(job_t *job, char *error, int64 resubmit, char **set_error)
605610
values[18] = BoolGetDatum(true);
606611
nulls[19] = 'n';
607612
}
613+
values[20] = TimestampTzGetDatum(GetCurrentTimestamp());
608614
}
609615
r2 = execute_spi_sql_with_args(sql, n, argtypes, values, nulls);
610616
if(this_error) pfree(this_error);

0 commit comments

Comments
 (0)