@@ -25,7 +25,7 @@ job_t *init_scheduler_job(job_t *j, unsigned char type)
25
25
job_t * get_at_job (int cron_id ,char * nodename ,char * * perror )
26
26
{
27
27
job_t * j ;
28
- const char * sql = "select last_start_available,same_transaction , do_sql, executor, postpone, max_run_time as time_limit,max_instances, onrollback_statement, start_at fromat_process where node = $1 and id = $2" ;
28
+ const char * sql = "select last_start_available,array_append('{}'::text[] , do_sql)::text[] , executor, postpone, max_run_time as time_limit,at, params, depends_on fromONLY at_jobs_process where node = $1 and id = $2" ;
29
29
Oid argtypes [2 ]= {TEXTOID ,INT4OID };
30
30
Datum args [2 ];
31
31
int ret ;
@@ -60,15 +60,16 @@ job_t *get_at_job(int cron_id, char *nodename, char **perror)
60
60
* perror = _copy_string (buffer );
61
61
return NULL ;
62
62
}
63
- STOP_SPI_SNAP ();
64
63
65
64
j = init_scheduler_job (NULL ,AtJob );
66
65
j -> node = _copy_string (nodename );
67
- j -> same_transaction = get_boolean_from_spi (0 ,2 , false);
68
- j -> dosql = get_textarray_from_spi (0 ,3 ,& j -> dosql_n );
69
- j -> executor = get_text_from_spi (0 ,4 );
70
- j -> onrollback = get_text_from_spi (0 ,8 );
71
- j -> start_at = get_timestamp_from_spi (0 ,9 ,0 );
66
+ j -> dosql = get_textarray_from_spi (0 ,2 ,& j -> dosql_n );
67
+ j -> executor = get_text_from_spi (0 ,3 );
68
+ j -> start_at = get_timestamp_from_spi (0 ,6 ,0 );
69
+ j -> sql_params = get_textarray_from_spi (0 ,7 ,& j -> sql_params_n );
70
+ j -> depends_on = get_int64array_from_spi (0 ,8 ,& j -> depends_on_n );
71
+
72
+ STOP_SPI_SNAP ();
72
73
73
74
* perror = NULL ;
74
75
return j ;
@@ -125,7 +126,6 @@ job_t *get_cron_job(int cron_id, TimestampTz start_at, char *nodename, char **pe
125
126
pfree (ts );
126
127
return NULL ;
127
128
}
128
- STOP_SPI_SNAP ();
129
129
130
130
j = init_scheduler_job (NULL ,CronJob );
131
131
j -> start_at = start_at ;
@@ -135,6 +135,7 @@ job_t *get_cron_job(int cron_id, TimestampTz start_at, char *nodename, char **pe
135
135
j -> executor = get_text_from_spi (0 ,4 );
136
136
j -> onrollback = get_text_from_spi (0 ,8 );
137
137
j -> next_time_statement = get_text_from_spi (0 ,9 );
138
+ STOP_SPI_SNAP ();
138
139
139
140
* perror = NULL ;
140
141
return j ;
@@ -167,7 +168,7 @@ job_t *_at_get_jobs_to_do(char *nodename, int *n, int *is_error, int limit)
167
168
* is_error = * n = 0 ;
168
169
START_SPI_SNAP ();
169
170
values [0 ]= CStringGetTextDatum (nodename );
170
- values [1 ]= Int32GetDatum (limit );
171
+ values [1 ]= Int32GetDatum (limit + 1 );
171
172
ret = SPI_execute_with_args (get_job_sql ,2 ,argtypes ,values ,NULL , true,0 );
172
173
if (ret == SPI_OK_SELECT )
173
174
{
@@ -208,7 +209,7 @@ job_t *_cron_get_jobs_to_do(char *nodename, int *n, int *is_error, int limit)
208
209
* is_error = * n = 0 ;
209
210
START_SPI_SNAP ();
210
211
values [0 ]= CStringGetTextDatum (nodename );
211
- values [1 ]= Int32GetDatum (limit );
212
+ values [1 ]= Int32GetDatum (limit + 1 );
212
213
ret = SPI_execute_with_args (get_job_sql ,2 ,argtypes ,values ,NULL , true,0 );
213
214
if (ret == SPI_OK_SELECT )
214
215
{
@@ -409,6 +410,15 @@ void destroy_job(job_t *j, int selfdestroy)
409
410
}
410
411
pfree (j -> dosql );
411
412
}
413
+ if (j -> sql_params_n && j -> sql_params )
414
+ {
415
+ for (i = 0 ;i < j -> sql_params_n ;i ++ )
416
+ {
417
+ if (j -> sql_params [i ])pfree (j -> sql_params [i ]);
418
+ }
419
+ pfree (j -> sql_params );
420
+ }
421
+ if (j -> depends_on_n && j -> depends_on )pfree (j -> depends_on );
412
422
413
423
if (selfdestroy )pfree (j );
414
424
}