@@ -462,7 +462,7 @@ job_t *set_job_error(job_t *j, const char *fmt, ...)
462462
463463int 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 );
466466return _at_move_job_to_log (j ,status ,process );
467467}
468468
@@ -513,9 +513,9 @@ int move_at_job_process(int job_id)
513513int set_at_job_done (job_t * job ,char * error ,int64 resubmit ,char * * set_error )
514514{
515515char * 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 };
519519bool canceled = false;
520520int i ;
521521char * oldpath ;
@@ -524,8 +524,9 @@ int set_at_job_done(job_t *job, char *error, int64 resubmit, char **set_error)
524524int n = 1 ;
525525spi_response_t * r ;
526526spi_response_t * r2 ;
527+
527528const 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 )" ;
529530const char * delete_sql = "delete from at_jobs_process where id = $1" ;
530531const 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}
559560argtypes [18 ]= BOOLOID ;
560561argtypes [19 ]= TEXTOID ;
562+ argtypes [20 ]= TIMESTAMPTZOID ;
561563nulls [18 ]= ' ' ;
562564nulls [19 ]= ' ' ;
565+ nulls [20 ]= ' ' ;
563566
564567canceled = 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{
570573this_error = _copy_string ("job was canceled while processing: cannot resubmit" );
571574sql = insert_sql ;
572- n = 20 ;
575+ n = 21 ;
573576
574577values [18 ]= BoolGetDatum (false);
575578values [19 ]= CStringGetTextDatum (this_error );
579+ values [20 ]= TimestampTzGetDatum (GetCurrentTimestamp ());
576580}
577581else 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{
586590this_error = _copy_string ("resubmit limit reached" );
587591sql = insert_sql ;
588- n = 20 ;
592+ n = 21 ;
589593
590594values [18 ]= BoolGetDatum (false);
591595values [19 ]= CStringGetTextDatum (this_error );
596+ values [20 ]= TimestampTzGetDatum (GetCurrentTimestamp ());
592597}
593598}
594599else
595600{
596- n = 20 ;
601+ n = 21 ;
597602sql = insert_sql ;
598603if (error )
599604{
@@ -605,6 +610,7 @@ int set_at_job_done(job_t *job, char *error, int64 resubmit, char **set_error)
605610values [18 ]= BoolGetDatum (true);
606611nulls [19 ]= 'n' ;
607612}
613+ values [20 ]= TimestampTzGetDatum (GetCurrentTimestamp ());
608614}
609615r2 = execute_spi_sql_with_args (sql ,n ,argtypes ,values ,nulls );
610616if (this_error )pfree (this_error );