@@ -452,7 +452,7 @@ job_t *get_expired_cron_jobs(char *nodename, int *n, int *is_error)
452
452
return jobs ;
453
453
}
454
454
455
- job_t * set_job_error (job_t * j , const char * fmt , ...)
455
+ job_t * set_job_error (MemoryContext mem , job_t * j , const char * fmt , ...)
456
456
{
457
457
va_list arglist ;
458
458
char buf [1024 ];
@@ -462,7 +462,7 @@ job_t *set_job_error(job_t *j, const char *fmt, ...)
462
462
va_end (arglist );
463
463
464
464
if (j -> error ) pfree (j -> error );
465
- j -> error = my_copy_string ( buf );
465
+ j -> error = _mcopy_string ( mem , buf );
466
466
467
467
return j ;
468
468
}
@@ -771,6 +771,46 @@ int _cron_move_job_to_log(job_t *j, bool status)
771
771
return ret ;
772
772
}
773
773
774
+ void copy_job (MemoryContext mem , job_t * dst , job_t * src )
775
+ {
776
+ int i ;
777
+
778
+ memcpy (dst , src , sizeof (job_t ));
779
+ if (src -> node ) dst -> node = _mcopy_string (mem , src -> node );
780
+ if (src -> executor ) dst -> executor = _mcopy_string (mem , src -> executor );
781
+ if (src -> owner ) dst -> owner = _mcopy_string (mem , src -> owner );
782
+ if (src -> onrollback ) dst -> onrollback = _mcopy_string (mem , src -> onrollback );
783
+ if (src -> next_time_statement ) dst -> next_time_statement = _mcopy_string (mem , src -> next_time_statement );
784
+ if (src -> error ) dst -> error = _mcopy_string (mem , src -> error );
785
+ if (src -> dosql_n && src -> dosql )
786
+ {
787
+ src -> dosql = MemoryContextAlloc (mem , sizeof (char * ) * src -> dosql_n );
788
+ for (i = 0 ; i < src -> dosql_n ; i ++ )
789
+ {
790
+ if (src -> dosql [i ])
791
+ dst -> dosql [i ] = _mcopy_string (mem , src -> dosql [i ]);
792
+ else
793
+ dst -> dosql [i ] = NULL ;
794
+ }
795
+ }
796
+ if (src -> sql_params_n && src -> sql_params )
797
+ {
798
+ src -> sql_params = MemoryContextAlloc (mem , sizeof (char * ) * src -> sql_params_n );
799
+ for (i = 0 ; i < src -> sql_params_n ; i ++ )
800
+ {
801
+ if (src -> sql_params [i ])
802
+ dst -> sql_params [i ] = _mcopy_string (mem , src -> sql_params [i ]);
803
+ else
804
+ dst -> sql_params [i ] = NULL ;
805
+ }
806
+ }
807
+ if (src -> depends_on_n > 0 )
808
+ {
809
+ dst -> depends_on = MemoryContextAlloc (mem , sizeof (int64 ) * src -> depends_on_n );
810
+ memcpy (dst -> depends_on , src -> depends_on , sizeof (int64 ) * src -> depends_on_n );
811
+ }
812
+ }
813
+
774
814
void destroy_job (job_t * j , int selfdestroy )
775
815
{
776
816
int i ;
0 commit comments