@@ -336,7 +336,7 @@ const char *check_multimaster_database(void)
336
336
/* at first need to parse shared_preload_libraries */
337
337
libs = GetConfigOption ("shared_preload_libraries" , true, false);
338
338
if (!libs ) return NULL ;
339
- split_libs = _split_string_to_char_array ((char * )libs );
339
+ split_libs = _split_string_to_char_array ((char * )libs , true );
340
340
if (split_libs -> n == 0 )
341
341
{
342
342
destroyCharArray (split_libs );
@@ -351,21 +351,19 @@ const char *check_multimaster_database(void)
351
351
}
352
352
}
353
353
destroyCharArray (split_libs );
354
- if (0 && !mtm_present ) return NULL ;
354
+ if (!mtm_present ) return NULL ;
355
355
356
356
/* now check id multimaster.node_id set */
357
357
mtm_id_str = GetConfigOption ("multimaster.node_id" , true, false);
358
358
if (!mtm_id_str ) return NULL ;
359
359
mtm_id = atoi (mtm_id_str );
360
360
if (mtm_id == 0 ) return NULL ;
361
- elog (LOG , "got mtm_id %d" , mtm_id );
362
361
363
362
/* find proper connection string from mtm_id */
364
363
mtm_cstring = GetConfigOption ("multimaster.conn_strings" , true, false);
365
364
if (!mtm_cstring ) return NULL ;
366
- elog (LOG , "got mtm_connstring" );
367
365
368
- conns = _split_string_to_char_array ((char * )mtm_cstring );
366
+ conns = _split_string_to_char_array ((char * )mtm_cstring , false );
369
367
if (conns -> n < mtm_id )
370
368
{
371
369
destroyCharArray (conns );
@@ -377,10 +375,8 @@ const char *check_multimaster_database(void)
377
375
destroyCharArray (conns );
378
376
return NULL ;
379
377
}
380
- elog (LOG , "GOT BEGIN" );
381
378
382
- memset (buffer , 0 , 256 );
383
- for (i = 7 ; dbbeg [i ] != 0 || i < 249 ; i ++ )
379
+ for (i = 7 ; dbbeg [i ] != 0 && i < 256 ; i ++ )
384
380
{
385
381
if (dbbeg [i ] != ' ' )
386
382
{
@@ -391,13 +387,13 @@ const char *check_multimaster_database(void)
391
387
break ;
392
388
}
393
389
}
390
+ buffer [j ] = 0 ;
394
391
destroyCharArray (conns );
395
- elog (LOG , "Almost ready %s" , buffer );
396
392
if (j > 0 ) return buffer ;
397
393
return NULL ;
398
394
}
399
395
400
- char_array_t * _split_string_to_char_array (char * str )
396
+ char_array_t * _split_string_to_char_array (char * str , bool do_clean )
401
397
{
402
398
int str_len , cv_len = 0 , i ;
403
399
char * clean_value ;
@@ -410,17 +406,15 @@ char_array_t *_split_string_to_char_array(char *str)
410
406
clean_value = worker_alloc (sizeof (char )* (str_len + 1 ));
411
407
for (i = 0 ; i < str_len ; i ++ )
412
408
{
413
- if (str [i ] != ' ' )
409
+ if (do_clean && str [i ] == ' ' ) continue ;
410
+ if (str [i ] == ',' )
414
411
{
415
- if (str [i ] == ',' )
416
- {
417
- nnames ++ ;
418
- clean_value [cv_len ++ ] = 0 ;
419
- }
420
- else
421
- {
422
- clean_value [cv_len ++ ] = str [i ];
423
- }
412
+ nnames ++ ;
413
+ clean_value [cv_len ++ ] = 0 ;
414
+ }
415
+ else
416
+ {
417
+ clean_value [cv_len ++ ] = str [i ];
424
418
}
425
419
}
426
420
clean_value [cv_len ] = 0 ;
@@ -462,7 +456,6 @@ char_array_t *readBasesToCheck(void)
462
456
result = makeCharArray ();
463
457
464
458
value = check_multimaster_database ();
465
- elog (LOG , "From mm: %s" , value );
466
459
467
460
if (!value )
468
461
value = GetConfigOption ("schedule.database" , true, false);
@@ -472,8 +465,8 @@ char_array_t *readBasesToCheck(void)
472
465
return result ;
473
466
}
474
467
475
- names = _split_string_to_char_array ((char * )value );
476
- if (names -> n == 0 )
468
+ names = _split_string_to_char_array ((char * )value , true );
469
+ if (names == NULL || names -> n == 0 )
477
470
{
478
471
destroyCharArray (names );
479
472
return result ;
@@ -525,7 +518,6 @@ void parent_scheduler_main(Datum arg)
525
518
CurrentResourceOwner = ResourceOwnerCreate (NULL , "pgpro_scheduler" );
526
519
527
520
init_worker_mem_ctx ("Parent scheduler context" );
528
- elog (LOG , "Start PostgresPro scheduler." );
529
521
530
522
SetConfigOption ("application_name" , "pgp-s supervisor" , PGC_USERSET , PGC_S_SESSION );
531
523
pgstat_report_activity (STATE_RUNNING , "Initialize" );
0 commit comments