~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Brian Aker
  • Date: 2011-07-18 02:56:15 UTC
  • mto: (2392.1.1 drizzle-autoconf)
  • mto: This revision was merged to the branch mainline in revision 2399.
  • Revision ID: brian@tangent.org-20110718025615-2an7nztjcb38c2ur
Add better error messages for issues on startup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
455
455
}
456
456
 
457
457
 
458
 
void unireg_abort(int exit_code)
 
458
void unireg_exit()
459
459
{
460
 
  if (exit_code)
461
 
  {
462
 
    errmsg_printf(error::ERROR, _("Aborting"));
463
 
  }
464
 
  else if (opt_help)
 
460
  if (opt_help)
465
461
  {
466
462
    usage();
467
463
  }
468
464
 
469
 
  clean_up(!opt_help && exit_code);
470
 
  internal::my_end();
471
 
  exit(exit_code);
 
465
  internal::my_end();
 
466
  exit(EXIT_SUCCESS);
 
467
}
 
468
 
 
469
void unireg_actual_abort(const char *file, int line, const char *func, const std::string& message)
 
470
{
 
471
  std::stringstream temp;
 
472
  temp << _("Aborting:") << "\"" << message << "\"" << " at " << file << ":" << line << " in " << func << "()";
 
473
  errmsg_printf(error::ERROR, temp.str().c_str());
 
474
 
 
475
  clean_up(opt_help == false);
 
476
  internal::my_end();
 
477
  exit(EXIT_FAILURE);
472
478
}
473
479
 
474
480
 
525
531
  }
526
532
  if (not user)
527
533
  {
528
 
      errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
529
 
                                    "the manual to find out how to run drizzled as root"));
530
 
    unireg_abort(1);
 
534
    unireg_abort << _("Fatal error: Please read \"Security\" section of the manual to find out how to run drizzled as root");
531
535
  }
532
536
 
533
537
  if (not strcmp(user, "root"))
 
538
  {
534
539
    return NULL;                        // Avoid problem with dynamic libraries
 
540
  }
535
541
 
536
 
  if (!(tmp_user_info= getpwnam(user)))
 
542
  if ((tmp_user_info= getpwnam(user)) == NULL)
537
543
  {
538
544
    // Allow a numeric uid to be used
539
545
    const char *pos;
540
546
    for (pos= user; my_isdigit(&my_charset_utf8_general_ci,*pos); pos++) ;
541
547
    if (*pos)                                   // Not numeric id
542
548
      goto err;
543
 
    if (!(tmp_user_info= getpwuid(atoi(user))))
 
549
 
 
550
    if ((tmp_user_info= getpwuid(atoi(user))) == NULL)
544
551
      goto err;
545
552
  }
546
553
  return tmp_user_info;
547
554
 
548
555
err:
549
 
  errmsg_printf(error::ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
550
 
                    "Please check that the user exists!\n"),user);
551
 
  unireg_abort(1);
 
556
  unireg_abort << "Fatal error: Can't change to run as user '" << user << "' ;  Please check that the user exists!";
552
557
 
553
558
#ifdef PR_SET_DUMPABLE
554
559
  if (getDebug().test(debug::CORE_ON_SIGNAL))
558
563
  }
559
564
#endif
560
565
 
561
 
/* Sun Studio 5.10 doesn't like this line.  5.9 requires it */
562
 
#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x590)
563
566
  return NULL;
564
 
#endif
565
 
 
566
567
}
567
568
 
568
569
void set_user(const char *user, passwd *user_info_arg)
571
572
  initgroups(user, user_info_arg->pw_gid);
572
573
  if (setgid(user_info_arg->pw_gid) == -1)
573
574
  {
574
 
    sql_perror(_("Set process group ID failed"));
575
 
    unireg_abort(1);
 
575
    unireg_abort << _("Set process group ID failed ") << strerror(errno); 
576
576
  }
577
577
  if (setuid(user_info_arg->pw_uid) == -1)
578
578
  {
579
 
    sql_perror(_("Set process user ID failed"));
580
 
    unireg_abort(1);
 
579
    unireg_abort << _("Set process user ID failed") << strerror(errno);
581
580
  }
582
581
}
583
582
 
586
585
/** Change root user if started with @c --chroot . */
587
586
static void set_root(const char *path)
588
587
{
589
 
  if ((chroot(path) == -1) || !chdir("/"))
 
588
  if ((chroot(path) == -1) or chdir("/") == 0)
590
589
  {
591
 
    sql_perror(_("Process chroot failed"));
592
 
    unireg_abort(1);
 
590
    unireg_abort << _("Process chroot failed");
593
591
  }
594
592
}
595
593
 
688
686
  global_system_variables.auto_increment_increment= 1;
689
687
  if (in_auto_increment_increment < 1 || in_auto_increment_increment > UINT64_MAX)
690
688
  {
691
 
    cout << _("Error: Invalid Value for auto_increment_increment");
692
 
    exit(-1);
 
689
    unireg_abort << _("Invalid Value for auto_increment_increment");
693
690
  }
694
691
  global_system_variables.auto_increment_increment= in_auto_increment_increment;
695
692
}
699
696
  global_system_variables.auto_increment_offset= 1;
700
697
  if (in_auto_increment_offset < 1 || in_auto_increment_offset > UINT64_MAX)
701
698
  {
702
 
    cout << _("Error: Invalid Value for auto_increment_offset");
703
 
    exit(-1);
 
699
    unireg_abort << _("Invalid Value for auto_increment_offset");
704
700
  }
705
701
  global_system_variables.auto_increment_offset= in_auto_increment_offset;
706
702
}
710
706
  global_system_variables.completion_type= 0;
711
707
  if (in_completion_type > 2)
712
708
  {
713
 
    cout << _("Error: Invalid Value for completion_type");
714
 
    exit(-1);
 
709
    unireg_abort << _("Invalid Value for completion_type");
715
710
  }
716
711
  global_system_variables.completion_type= in_completion_type;
717
712
}
722
717
  global_system_variables.div_precincrement= 4;
723
718
  if (in_div_precincrement > DECIMAL_MAX_SCALE)
724
719
  {
725
 
    cout << _("Error: Invalid Value for div-precision-increment");
726
 
    exit(-1);
 
720
    unireg_abort << _("Invalid Value for div-precision-increment");
727
721
  }
728
722
  global_system_variables.div_precincrement= in_div_precincrement;
729
723
}
733
727
  global_system_variables.group_concat_max_len= 1024;
734
728
  if (in_group_concat_max_len > ULONG_MAX || in_group_concat_max_len < 4)
735
729
  {
736
 
    cout << _("Error: Invalid Value for group_concat_max_len");
737
 
    exit(-1);
 
730
    unireg_abort << _("Invalid Value for group_concat_max_len");
738
731
  }
739
732
  global_system_variables.group_concat_max_len= in_group_concat_max_len;
740
733
}
744
737
  global_system_variables.join_buff_size= (128*1024L);
745
738
  if (in_join_buffer_size < IO_SIZE*2 || in_join_buffer_size > ULONG_MAX)
746
739
  {
747
 
    cout << _("Error: Invalid Value for join_buffer_size");
748
 
    exit(-1);
 
740
    unireg_abort << _("Invalid Value for join_buffer_size");
749
741
  }
750
742
  in_join_buffer_size-= in_join_buffer_size % IO_SIZE;
751
743
  global_system_variables.join_buff_size= in_join_buffer_size;
756
748
  global_system_variables.max_allowed_packet= (64*1024*1024L);
757
749
  if (in_max_allowed_packet < 1024 || in_max_allowed_packet > 1024*1024L*1024L)
758
750
  {
759
 
    cout << _("Error: Invalid Value for max_allowed_packet");
760
 
    exit(-1);
 
751
    unireg_abort << _("Invalid Value for max_allowed_packet");
761
752
  }
762
753
  in_max_allowed_packet-= in_max_allowed_packet % 1024;
763
754
  global_system_variables.max_allowed_packet= in_max_allowed_packet;
768
759
  global_system_variables.max_error_count= DEFAULT_ERROR_COUNT;
769
760
  if (in_max_error_count > 65535)
770
761
  {
771
 
    cout << _("Error: Invalid Value for max_error_count");
772
 
    exit(-1);
 
762
    unireg_abort << _("Invalid Value for max_error_count");
773
763
  }
774
764
  global_system_variables.max_error_count= in_max_error_count;
775
765
}
779
769
  global_system_variables.max_heap_table_size= (16*1024*1024L);
780
770
  if (in_max_heap_table_size < 16384 || in_max_heap_table_size > MAX_MEM_TABLE_SIZE)
781
771
  {
782
 
    cout << _("Error: Invalid Value for max_heap_table_size");
783
 
    exit(-1);
 
772
    unireg_abort << _("Invalid Value for max_heap_table_size");
784
773
  }
785
774
  in_max_heap_table_size-= in_max_heap_table_size % 1024;
786
775
  global_system_variables.max_heap_table_size= in_max_heap_table_size;
791
780
  global_system_variables.min_examined_row_limit= 0;
792
781
  if (in_min_examined_row_limit > ULONG_MAX)
793
782
  {
794
 
    cout << _("Error: Invalid Value for min_examined_row_limit");
795
 
    exit(-1);
 
783
    unireg_abort << _("Invalid Value for min_examined_row_limit");
796
784
  }
797
785
  global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
798
786
}
802
790
  global_system_variables.max_join_size= INT32_MAX;
803
791
  if ((uint64_t)in_max_join_size < 1 || (uint64_t)in_max_join_size > INT32_MAX)
804
792
  {
805
 
    cout << _("Error: Invalid Value for max_join_size");
806
 
    exit(-1);
 
793
    unireg_abort << _("Invalid Value for max_join_size");
807
794
  }
808
795
  global_system_variables.max_join_size= in_max_join_size;
809
796
}
813
800
  global_system_variables.max_length_for_sort_data= 1024;
814
801
  if (in_max_length_for_sort_data < 4 || in_max_length_for_sort_data > 8192*1024L)
815
802
  {
816
 
    cout << _("Error: Invalid Value for max_length_for_sort_data");
817
 
    exit(-1);
 
803
    unireg_abort << _("Invalid Value for max_length_for_sort_data");
818
804
  }
819
805
  global_system_variables.max_length_for_sort_data= in_max_length_for_sort_data;
820
806
}
824
810
  global_system_variables.max_seeks_for_key= ULONG_MAX;
825
811
  if (in_max_seeks_for_key < 1 || in_max_seeks_for_key > ULONG_MAX)
826
812
  {
827
 
    cout << _("Error: Invalid Value for max_seeks_for_key");
828
 
    exit(-1);
 
813
    unireg_abort << _("Invalid Value for max_seeks_for_key");
829
814
  }
830
815
  global_system_variables.max_seeks_for_key= in_max_seeks_for_key;
831
816
}
835
820
  global_system_variables.max_sort_length= 1024;
836
821
  if ((int64_t)in_max_sort_length < 4 || (int64_t)in_max_sort_length > 8192*1024L)
837
822
  {
838
 
    cout << _("Error: Invalid Value for max_sort_length");
839
 
    exit(-1);
 
823
    unireg_abort << _("Invalid Value for max_sort_length");
840
824
  }
841
825
  global_system_variables.max_sort_length= in_max_sort_length;
842
826
}
846
830
  global_system_variables.optimizer_search_depth= 0;
847
831
  if (in_optimizer_search_depth > MAX_TABLES + 2)
848
832
  {
849
 
    cout << _("Error: Invalid Value for optimizer_search_depth");
850
 
    exit(-1);
 
833
    unireg_abort << _("Invalid Value for optimizer_search_depth");
851
834
  }
852
835
  global_system_variables.optimizer_search_depth= in_optimizer_search_depth;
853
836
}
857
840
  global_system_variables.preload_buff_size= (32*1024L);
858
841
  if (in_preload_buff_size < 1024 || in_preload_buff_size > 1024*1024*1024L)
859
842
  {
860
 
    cout << _("Error: Invalid Value for preload_buff_size");
861
 
    exit(-1);
 
843
    unireg_abort << _("Invalid Value for preload_buff_size");
862
844
  }
863
845
  global_system_variables.preload_buff_size= in_preload_buff_size;
864
846
}
868
850
  global_system_variables.query_alloc_block_size= QUERY_ALLOC_BLOCK_SIZE;
869
851
  if (in_query_alloc_block_size < 1024)
870
852
  {
871
 
    cout << _("Error: Invalid Value for query_alloc_block_size");
872
 
    exit(-1);
 
853
    unireg_abort << _("Invalid Value for query_alloc_block_size");
873
854
  }
874
855
  in_query_alloc_block_size-= in_query_alloc_block_size % 1024;
875
856
  global_system_variables.query_alloc_block_size= in_query_alloc_block_size;
880
861
  global_system_variables.query_prealloc_size= QUERY_ALLOC_PREALLOC_SIZE;
881
862
  if (in_query_prealloc_size < QUERY_ALLOC_PREALLOC_SIZE)
882
863
  {
883
 
    cout << _("Error: Invalid Value for query_prealloc_size");
884
 
    exit(-1);
 
864
    unireg_abort << _("Invalid Value for query_prealloc_size");
885
865
  }
886
866
  in_query_prealloc_size-= in_query_prealloc_size % 1024;
887
867
  global_system_variables.query_prealloc_size= in_query_prealloc_size;
892
872
  global_system_variables.range_alloc_block_size= RANGE_ALLOC_BLOCK_SIZE;
893
873
  if (in_range_alloc_block_size < RANGE_ALLOC_BLOCK_SIZE)
894
874
  {
895
 
    cout << _("Error: Invalid Value for range_alloc_block_size");
896
 
    exit(-1);
 
875
    unireg_abort << _("Invalid Value for range_alloc_block_size");
897
876
  }
898
877
  in_range_alloc_block_size-= in_range_alloc_block_size % 1024;
899
878
  global_system_variables.range_alloc_block_size= in_range_alloc_block_size;
904
883
  global_system_variables.read_buff_size= (128*1024L);
905
884
  if (in_read_buff_size < IO_SIZE*2 || in_read_buff_size > INT32_MAX)
906
885
  {
907
 
    cout << _("Error: Invalid Value for read_buff_size");
908
 
    exit(-1);
 
886
    unireg_abort << _("Invalid Value for read_buff_size");
909
887
  }
910
888
  in_read_buff_size-= in_read_buff_size % IO_SIZE;
911
889
  global_system_variables.read_buff_size= in_read_buff_size;
916
894
  global_system_variables.read_rnd_buff_size= (256*1024L);
917
895
  if (in_read_rnd_buff_size < 64 || in_read_rnd_buff_size > UINT32_MAX)
918
896
  {
919
 
    cout << _("Error: Invalid Value for read_rnd_buff_size");
920
 
    exit(-1);
 
897
    unireg_abort << _("Invalid Value for read_rnd_buff_size");
921
898
  }
922
899
  global_system_variables.read_rnd_buff_size= in_read_rnd_buff_size;
923
900
}
927
904
  global_system_variables.sortbuff_size= MAX_SORT_MEMORY;
928
905
  if ((uint32_t)in_sortbuff_size < MIN_SORT_MEMORY)
929
906
  {
930
 
    cout << _("Error: Invalid Value for sort_buff_size");
931
 
    exit(-1);
 
907
    unireg_abort << _("Invalid Value for sort_buff_size");
932
908
  }
933
909
  global_system_variables.sortbuff_size= in_sortbuff_size;
934
910
}
938
914
  table_def_size= 128;
939
915
  if (in_table_def_size < 1 || in_table_def_size > 512*1024L)
940
916
  {
941
 
    cout << _("Error: Invalid Value for table_def_size");
942
 
    exit(-1);
 
917
    unireg_abort << _("Invalid Value for table_def_size");
943
918
  }
944
919
  table_def_size= in_table_def_size;
945
920
}
949
924
  table_cache_size= TABLE_OPEN_CACHE_DEFAULT;
950
925
  if (in_table_cache_size < TABLE_OPEN_CACHE_MIN || in_table_cache_size > 512*1024L)
951
926
  {
952
 
    cout << _("Error: Invalid Value for table_cache_size");
953
 
    exit(-1);
 
927
    unireg_abort << _("Invalid Value for table_cache_size");
954
928
  }
955
929
  table_cache_size= in_table_cache_size;
956
930
}
960
934
  table_lock_wait_timeout= 50;
961
935
  if (in_table_lock_wait_timeout < 1 || in_table_lock_wait_timeout > 1024*1024*1024)
962
936
  {
963
 
    cout << _("Error: Invalid Value for table_lock_wait_timeout");
964
 
    exit(-1);
 
937
    unireg_abort <<  _("Invalid Value for table_lock_wait_timeout");
965
938
  }
966
939
  table_lock_wait_timeout= in_table_lock_wait_timeout;
967
940
}
976
949
  global_system_variables.tmp_table_size= 16*1024*1024L;
977
950
  if (in_tmp_table_size < 1024 || in_tmp_table_size > MAX_MEM_TABLE_SIZE)
978
951
  {
979
 
    cout << _("Error: Invalid Value for table_lock_wait_timeout");
980
 
    exit(-1);
 
952
    unireg_abort << _("Invalid Value for table_lock_wait_timeout");
981
953
  }
982
954
  global_system_variables.tmp_table_size= in_tmp_table_size;
983
955
}
987
959
  transaction_message_threshold= 1024*1024;
988
960
  if ((int64_t) in_transaction_message_threshold < 128*1024 || (int64_t)in_transaction_message_threshold > 1024*1024)
989
961
  {
990
 
    cout << _("Error: Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
991
 
    exit(-1);
 
962
    unireg_abort << _("Invalid Value for transaction_message_threshold valid values are between 131072 - 1048576 bytes");
992
963
  }
993
964
  transaction_message_threshold= in_transaction_message_threshold;
994
965
}
1024
995
  {
1025
996
    fs::path p(it);
1026
997
    if (fs::is_regular_file(p))
 
998
    {
1027
999
      defaults_file_list.push_back(it);
 
1000
    }
1028
1001
    else
1029
1002
    {
1030
 
      errmsg_printf(error::ERROR, _("Defaults file '%s' not found\n"), it.c_str());
1031
 
      unireg_abort(1);
 
1003
      unireg_abort << "Defaults file '" << it << "' not found";
1032
1004
    }
1033
1005
  }
1034
1006
}
1035
1007
 
1036
 
int init_basic_variables(int argc, char **argv)
 
1008
bool init_variables_before_daemonizing(int argc, char **argv)
1037
1009
{
1038
1010
  umask(((~internal::my_umask) & 0666));
1039
1011
  decimal_zero.set_zero(); // set decimal_zero constant;
1041
1013
 
1042
1014
  time_t curr_time= time(NULL);
1043
1015
  if (curr_time == (time_t)-1)
1044
 
    return 1;
 
1016
  {
 
1017
    return false;
 
1018
  }
1045
1019
 
1046
1020
  max_system_variables.pseudo_thread_id= UINT32_MAX;
1047
1021
  server_start_time= flush_status_time= curr_time;
1276
1250
  }
1277
1251
  catch (std::exception&)
1278
1252
  {
1279
 
    errmsg_printf(error::ERROR, _("Duplicate entry for command line option\n"));
1280
 
    unireg_abort(1);
 
1253
    unireg_abort << _("Duplicate entry for command line option");
1281
1254
  }
1282
1255
 
1283
1256
  if (not vm["no-defaults"].as<bool>())
1310
1283
  }
1311
1284
  catch (po::validation_error &err)
1312
1285
  {
1313
 
    errmsg_printf(error::ERROR, _("%s: %s.\nUse --help to get a list of available options\n"), internal::my_progname, err.what());
1314
 
    unireg_abort(1);
 
1286
    unireg_abort << "Use --help to get a list of available options. " << err.what(); 
1315
1287
  }
1316
1288
 
1317
1289
  process_defaults_files();
1325
1297
  }
1326
1298
  catch (po::validation_error &err)
1327
1299
  {
1328
 
    errmsg_printf(error::ERROR, _("%s: %s.\nUse --help to get a list of available options\n"), internal::my_progname, err.what());
1329
 
    unireg_abort(1);
 
1300
    unireg_abort << "Use --help to get a list of available options. " << err.what();
1330
1301
  }
1331
1302
 
1332
 
  return 0;
 
1303
  return true;
1333
1304
}
1334
1305
 
1335
 
int init_remaining_variables(module::Registry &plugins)
 
1306
// Return failure if we can't pass this, unireg_abort() will then be called
 
1307
// by the caller.
 
1308
bool init_variables_after_daemonizing(module::Registry &plugins)
1336
1309
{
1337
1310
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1338
1311
 
1344
1317
 
1345
1318
  if (plugin_init(plugins, plugin_options))
1346
1319
  {
1347
 
    errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
1348
 
    unireg_abort(1);
 
1320
    unireg_abort << _("Failed to initialize plugins");
1349
1321
  }
1350
1322
 
1351
1323
  full_options.add(plugin_options);
1365
1337
  }
1366
1338
  catch (po::validation_error &err)
1367
1339
  {
1368
 
    errmsg_printf(error::ERROR,
1369
 
                  _("%s: %s.\n"
1370
 
                    "Use --help to get a list of available options\n"),
1371
 
                  internal::my_progname, err.what());
1372
 
    unireg_abort(1);
 
1340
    unireg_abort << "Use --help to get a list of available options. " << err.what();
1373
1341
  }
1374
1342
  catch (po::invalid_command_line_syntax &err)
1375
1343
  {
1376
 
    errmsg_printf(error::ERROR,
1377
 
                  _("%s: %s.\n"
1378
 
                    "Use --help to get a list of available options\n"),
1379
 
                  internal::my_progname, err.what());
1380
 
    unireg_abort(1);
 
1344
    unireg_abort << "Use --help to get a list of available options. " << err.what();
1381
1345
  }
1382
1346
  catch (po::unknown_option &err)
1383
1347
  {
1384
 
    errmsg_printf(error::ERROR,
1385
 
                  _("%s\nUse --help to get a list of available options\n"),
1386
 
                  err.what());
1387
 
    unireg_abort(1);
 
1348
    unireg_abort << "Use --help to get a list of available options. " << err.what();
1388
1349
  }
1389
1350
 
1390
1351
  try
1393
1354
  }
1394
1355
  catch (po::validation_error &err)
1395
1356
  {
1396
 
    errmsg_printf(error::ERROR,
1397
 
                  _("%s: %s.\n"
1398
 
                    "Use --help to get a list of available options\n"),
1399
 
                  internal::my_progname, err.what());
1400
 
    unireg_abort(1);
 
1357
    unireg_abort << "Use --help to get a list of available options. " << err.what();
1401
1358
  }
1402
1359
 
1403
1360
  get_options();
1420
1377
 
1421
1378
  item_create_init();
1422
1379
  if (sys_var_init())
1423
 
    return 1;
 
1380
  {
 
1381
    return false;
 
1382
  }
 
1383
 
1424
1384
  /* Creates static regex matching for temporal values */
1425
1385
  if (not init_temporal_formats())
1426
 
    return 1;
 
1386
    return false;
1427
1387
 
1428
 
  if (!(default_charset_info=
1429
 
        get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
 
1388
  if (!(default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1430
1389
  {
1431
1390
    errmsg_printf(error::ERROR, _("Error getting default charset"));
1432
 
    return 1;                           // Eof of the list
 
1391
    return false;                           // Eof of the list
1433
1392
  }
1434
1393
 
1435
1394
  if (vm.count("scheduler"))
1436
1395
    opt_scheduler= vm["scheduler"].as<string>().c_str();
1437
1396
 
1438
 
  if (default_collation_name)
1439
 
  {
1440
 
    const charset_info_st * const default_collation= get_charset_by_name(default_collation_name);
1441
 
    if (not default_collation)
1442
 
    {
1443
 
      errmsg_printf(error::ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1444
 
      return 1;
1445
 
    }
1446
 
    if (not my_charset_same(default_charset_info, default_collation))
1447
 
    {
1448
 
      errmsg_printf(error::ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1449
 
                    default_collation_name,
1450
 
                    default_charset_info->csname);
1451
 
      return 1;
1452
 
    }
1453
 
    default_charset_info= default_collation;
1454
 
  }
1455
1397
  /* Set collactions that depends on the default collation */
1456
1398
  global_system_variables.collation_server=      default_charset_info;
1457
1399
 
1459
1401
           get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1460
1402
  {
1461
1403
    errmsg_printf(error::ERROR, _("Error setting collation"));
1462
 
    return 1;
 
1404
    return false;
1463
1405
  }
1464
1406
  global_system_variables.character_set_filesystem= character_set_filesystem;
1465
1407
 
1466
 
  if (!(my_default_lc_time_names=
1467
 
        my_locale_by_name(lc_time_names_name)))
 
1408
  if ((my_default_lc_time_names= my_locale_by_name(lc_time_names_name)) == NULL)
1468
1409
  {
1469
1410
    errmsg_printf(error::ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
1470
 
    return 1;
 
1411
    return false;
1471
1412
  }
1472
1413
  global_system_variables.lc_time_names= my_default_lc_time_names;
1473
1414
 
1474
1415
  /* Reset table_alias_charset */
1475
1416
  table_alias_charset= files_charset_info;
1476
1417
 
1477
 
  return 0;
 
1418
  return true;
1478
1419
}
1479
1420
 
1480
1421
 
1496
1437
  ha_init_errors();
1497
1438
 
1498
1439
  if (opt_help)
1499
 
    unireg_abort(0);
 
1440
  {
 
1441
    unireg_exit();
 
1442
  }
1500
1443
 
1501
1444
  if (plugin_finalize(plugins))
1502
1445
  {
1503
 
    unireg_abort(1);
 
1446
    unireg_abort << "plugin_finalize() failed";
1504
1447
  }
1505
1448
 
1506
1449
  if (plugin::Scheduler::setPlugin(opt_scheduler))
1507
1450
  {
1508
 
      errmsg_printf(error::ERROR, _("No scheduler found, cannot continue!\n"));
1509
 
      unireg_abort(1);
 
1451
    unireg_abort << _("No scheduler found");
1510
1452
  }
1511
1453
 
1512
1454
  /*
1524
1466
    plugin::StorageEngine *engine= plugin::StorageEngine::findByName(default_storage_engine_str);
1525
1467
    if (engine == NULL)
1526
1468
    {
1527
 
      errmsg_printf(error::ERROR, _("Unknown/unsupported storage engine: %s\n"), default_storage_engine_str);
1528
 
      unireg_abort(1);
 
1469
      unireg_abort << _("Unknown/unsupported storage engine: ") << default_storage_engine_str;
1529
1470
    }
1530
1471
    global_system_variables.storage_engine= engine;
1531
1472
  }
1533
1474
  if (plugin::XaResourceManager::recoverAllXids())
1534
1475
  {
1535
1476
    /* This function alredy generates error messages */
1536
 
    unireg_abort(1);
 
1477
    unireg_abort << "plugin::XaResourceManager::recoverAllXids() failed";
1537
1478
  }
1538
1479
 
1539
1480
  init_update_queries();
1638
1579
   N_("Chroot drizzled daemon during startup."),
1639
1580
   (char**) &drizzled_chroot, NULL, 0, GET_STR, REQUIRED_ARG,
1640
1581
   0, 0, 0, 0, 0, 0},
1641
 
  {"collation-server", OPT_DEFAULT_COLLATION,
1642
 
   N_("Set the default collation."),
1643
 
   (char**) &default_collation_name, NULL,
1644
 
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1645
1582
  {"completion-type", OPT_COMPLETION_TYPE,
1646
1583
   N_("Default completion type."),
1647
1584
   (char**) &global_system_variables.completion_type,
1909
1846
 
1910
1847
static void usage()
1911
1848
{
1912
 
  if (!(default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1913
 
    exit(1);
1914
 
  if (!default_collation_name)
 
1849
  if ((default_charset_info= get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)) == NULL)
 
1850
  {
 
1851
    unireg_abort << "Failed to load default_charset_info:" << default_character_set_name;
 
1852
  }
 
1853
 
 
1854
  if (default_collation_name == NULL)
 
1855
  {
1915
1856
    default_collation_name= default_charset_info->name;
 
1857
  }
 
1858
 
1916
1859
  print_version();
1917
 
  puts(_("Copyright (C) 2008 Sun Microsystems\n"
 
1860
  puts(_("Copyright (C) 2010-2011 Drizzle Developers, Copyright (C) 2008 Sun Microsystems\n"
1918
1861
         "This software comes with ABSOLUTELY NO WARRANTY. "
1919
1862
         "This is free software,\n"
1920
1863
         "and you are welcome to modify and redistribute it under the GPL "
2038
1981
  if (vm.count("version"))
2039
1982
  {
2040
1983
    print_version();
2041
 
    exit(0);
 
1984
    unireg_exit();
2042
1985
  }
2043
1986
 
2044
1987
  if (vm.count("sort-heap-threshold"))
2045
1988
  {
2046
1989
    if ((vm["sort-heap-threshold"].as<uint64_t>() > 0) and
2047
 
      (vm["sort-heap-threshold"].as<uint64_t>() <
2048
 
      global_system_variables.sortbuff_size))
 
1990
      (vm["sort-heap-threshold"].as<uint64_t>() < global_system_variables.sortbuff_size))
2049
1991
    {
2050
 
      cout << _("Error: sort-heap-threshold cannot be less than sort-buffer-size") << endl;
2051
 
      exit(-1);
 
1992
      unireg_abort << _("sort-heap-threshold cannot be less than sort-buffer-size");
2052
1993
    }
2053
1994
 
2054
1995
    global_sort_buffer.setMaxSize(vm["sort-heap-threshold"].as<uint64_t>());
2057
1998
  if (vm.count("join-heap-threshold"))
2058
1999
  {
2059
2000
    if ((vm["join-heap-threshold"].as<uint64_t>() > 0) and
2060
 
      (vm["join-heap-threshold"].as<uint64_t>() <
2061
 
      global_system_variables.join_buff_size))
 
2001
      (vm["join-heap-threshold"].as<uint64_t>() < global_system_variables.join_buff_size))
2062
2002
    {
2063
 
      cout << _("Error: join-heap-threshold cannot be less than join-buffer-size") << endl;
2064
 
      exit(-1);
 
2003
      unireg_abort << _("join-heap-threshold cannot be less than join-buffer-size");
2065
2004
    }
2066
2005
 
2067
2006
    global_join_buffer.setMaxSize(vm["join-heap-threshold"].as<uint64_t>());
2070
2009
  if (vm.count("read-rnd-threshold"))
2071
2010
  {
2072
2011
    if ((vm["read-rnd-threshold"].as<uint64_t>() > 0) and
2073
 
      (vm["read-rnd-threshold"].as<uint64_t>() <
2074
 
      global_system_variables.read_rnd_buff_size))
 
2012
      (vm["read-rnd-threshold"].as<uint64_t>() < global_system_variables.read_rnd_buff_size))
2075
2013
    {
2076
 
      cout << _("Error: read-rnd-threshold cannot be less than read-rnd-buffer-size") << endl;
2077
 
      exit(-1);
 
2014
      unireg_abort << _("read-rnd-threshold cannot be less than read-rnd-buffer-size");
2078
2015
    }
2079
2016
 
2080
2017
    global_read_rnd_buffer.setMaxSize(vm["read-rnd-threshold"].as<uint64_t>());
2083
2020
  if (vm.count("read-buffer-threshold"))
2084
2021
  {
2085
2022
    if ((vm["read-buffer-threshold"].as<uint64_t>() > 0) and
2086
 
      (vm["read-buffer-threshold"].as<uint64_t>() <
2087
 
      global_system_variables.read_buff_size))
 
2023
      (vm["read-buffer-threshold"].as<uint64_t>() < global_system_variables.read_buff_size))
2088
2024
    {
2089
 
      cout << _("Error: read-buffer-threshold cannot be less than read-buffer-size") << endl;
2090
 
      exit(-1);
 
2025
      unireg_abort << _("read-buffer-threshold cannot be less than read-buffer-size");
2091
2026
    }
2092
2027
 
2093
2028
    global_read_buffer.setMaxSize(vm["read-buffer-threshold"].as<uint64_t>());
2113
2048
 
2114
2049
  if (vm.count("skip-symlinks"))
2115
2050
  {
2116
 
    internal::my_use_symdir=0;
 
2051
    internal::my_use_symdir= 0;
 
2052
  }
 
2053
 
 
2054
  if (vm.count("collation-server"))
 
2055
  {
 
2056
    const charset_info_st * const default_collation= get_charset_by_name(vm["collation-server"].as<string>().c_str());
 
2057
    if (not default_collation)
 
2058
    {
 
2059
      unireg_abort << "Unknown collation: " << default_collation_name;
 
2060
    }
 
2061
 
 
2062
    if (not my_charset_same(default_charset_info, default_collation))
 
2063
    {
 
2064
      unireg_abort << "COLLATION '" << default_collation_name << "' is not valid for CHARACTER SET '" << default_charset_info->csname << "'";
 
2065
    }
 
2066
    default_charset_info= default_collation;
2117
2067
  }
2118
2068
 
2119
2069
  if (vm.count("transaction-isolation"))
2149
2099
  }
2150
2100
 
2151
2101
  if (drizzled_chroot)
 
2102
  {
2152
2103
    set_root(drizzled_chroot);
 
2104
  }
2153
2105
 
2154
2106
  /*
2155
2107
    Set some global variables from the global_system_variables
2197
2149
    {
2198
2150
      if (errno != EEXIST)
2199
2151
      {
2200
 
        errmsg_printf(error::ERROR, _("There was an error creating the '%s' part of the path '%s'.  Please check the path exists and is writable.\n"), fs::path(drizzle_tmpdir).leaf().c_str(), drizzle_tmpdir.c_str());
2201
 
        exit(1);
 
2152
        unireg_abort << "There was an error creating the '" 
 
2153
          << fs::path(drizzle_tmpdir).leaf() 
 
2154
          << "' part of the path '" 
 
2155
          << drizzle_tmpdir 
 
2156
          << "'.  Please check the path exists and is writable.";
2202
2157
      }
2203
2158
    }
2204
2159
 
2205
2160
    if (stat(drizzle_tmpdir.c_str(), &buf) || not S_ISDIR(buf.st_mode))
2206
2161
    {
2207
 
      errmsg_printf(error::ERROR, _("There was an error opening the path '%s', please check the path exists and is writable.\n"), drizzle_tmpdir.c_str());
2208
 
      exit(1);
 
2162
      unireg_abort << "There was an error opening the path '" << drizzle_tmpdir << "', please check the path exists and is writable.";
2209
2163
    }
2210
2164
  }
2211
 
 
2212
2165
}
2213
2166
 
2214
2167
} /* namespace drizzled */