~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

Extracted the LOAD command into its own class and implementation files.
Removed the corresponding case label from the switch statement.

Show diffs side-by-side

added added

removed removed

Lines of Context:
215
215
 
216
216
/* static variables */
217
217
 
 
218
extern TYPELIB optimizer_use_mrr_typelib;
 
219
 
218
220
static bool volatile select_thread_in_use;
219
221
static bool volatile ready_to_exit;
220
222
static bool opt_debugging= 0;
342
344
FILE *stderror_file=0;
343
345
 
344
346
vector<Session*> session_list;
 
347
I_List<NAMED_LIST> key_caches;
345
348
 
346
349
struct system_variables global_system_variables;
347
350
struct system_variables max_system_variables;
557
560
  plugin_shutdown();
558
561
  ha_end();
559
562
  xid_cache_free();
 
563
  delete_elements(&key_caches, (void (*)(const char*, unsigned char*)) free_key_cache);
 
564
  multi_keycache_free();
560
565
  free_status_vars();
561
566
  if (defaults_argv)
562
567
    free_defaults(defaults_argv);
1124
1129
  }
1125
1130
  if (!session || MyFlags & ME_NOREFRESH)
1126
1131
    errmsg_printf(ERRMSG_LVL_ERROR, "%s: %s",my_progname,str); /* purecov: inspected */
 
1132
  return;;
1127
1133
}
1128
1134
 
1129
1135
 
1132
1138
 
1133
1139
SHOW_VAR com_status_vars[]= {
1134
1140
  {"admin_commands",       (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS},
 
1141
  {"assign_to_keycache",   (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS},
1135
1142
  {"alter_db",             (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
1136
1143
  {"alter_table",          (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
1137
1144
  {"analyze",              (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
1144
1151
  {"create_index",         (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS},
1145
1152
  {"create_table",         (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS},
1146
1153
  {"delete",               (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DELETE]), SHOW_LONG_STATUS},
 
1154
  {"delete_multi",         (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DELETE_MULTI]), SHOW_LONG_STATUS},
1147
1155
  {"drop_db",              (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DROP_DB]), SHOW_LONG_STATUS},
1148
1156
  {"drop_index",           (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DROP_INDEX]), SHOW_LONG_STATUS},
1149
1157
  {"drop_table",           (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DROP_TABLE]), SHOW_LONG_STATUS},
1171
1179
  {"show_fields",          (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_FIELDS]), SHOW_LONG_STATUS},
1172
1180
  {"show_keys",            (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS},
1173
1181
  {"show_open_tables",     (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
 
1182
  {"show_plugins",         (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
1174
1183
  {"show_processlist",     (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
1175
1184
  {"show_status",          (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
1176
1185
  {"show_table_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
1180
1189
  {"truncate",             (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
1181
1190
  {"unlock_tables",        (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
1182
1191
  {"update",               (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
 
1192
  {"update_multi",         (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS},
1183
1193
  {NULL, NULL, SHOW_LONGLONG}
1184
1194
};
1185
1195
 
1281
1291
  /* Set collactions that depends on the default collation */
1282
1292
  global_system_variables.collation_server=      default_charset_info;
1283
1293
 
 
1294
  global_system_variables.optimizer_use_mrr= 1;
1284
1295
  global_system_variables.optimizer_switch= 0;
1285
1296
 
1286
1297
  if (!(character_set_filesystem=
1349
1360
    unireg_abort(1);
1350
1361
  }
1351
1362
 
 
1363
  /* call ha_init_key_cache() on all key caches to init them */
 
1364
  process_key_caches(&ha_init_key_cache);
 
1365
 
1352
1366
  /* Allow storage engine to give real error messages */
1353
1367
  if (ha_init_errors())
1354
1368
    return(1);
1422
1436
    "memory" engine which will be configurable longterm. We should be able to
1423
1437
    remove partition and myisammrg.
1424
1438
  */
1425
 
  const std::string myisam_engine_name("MyISAM");
1426
 
  const std::string heap_engine_name("MEMORY");
1427
 
  myisam_engine= ha_resolve_by_name(NULL, myisam_engine_name);
1428
 
  heap_engine= ha_resolve_by_name(NULL, heap_engine_name);
 
1439
  const LEX_STRING myisam_engine_name= { C_STRING_WITH_LEN("MyISAM") };
 
1440
  const LEX_STRING heap_engine_name= { C_STRING_WITH_LEN("MEMORY") };
 
1441
  myisam_engine= ha_resolve_by_name(NULL, &myisam_engine_name);
 
1442
  heap_engine= ha_resolve_by_name(NULL, &heap_engine_name);
1429
1443
 
1430
1444
  /*
1431
1445
    Check that the default storage engine is actually available.
1432
1446
  */
1433
1447
  if (default_storage_engine_str)
1434
1448
  {
1435
 
    const std::string name(default_storage_engine_str);
 
1449
    LEX_STRING name= { default_storage_engine_str,
 
1450
                       strlen(default_storage_engine_str) };
1436
1451
    StorageEngine *engine;
1437
1452
 
1438
 
    engine= ha_resolve_by_name(0, name);
1439
 
    if (engine == NULL)
 
1453
    if (!(engine= ha_resolve_by_name(0, &name)))
1440
1454
    {
1441
1455
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported table type: %s"),
1442
1456
                    default_storage_engine_str);
1682
1696
  OPT_MEMLOCK,
1683
1697
  OPT_SERVER_ID,
1684
1698
  OPT_TC_HEURISTIC_RECOVER,
 
1699
  OPT_ENGINE_CONDITION_PUSHDOWN,
1685
1700
  OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
1686
1701
  OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
1687
1702
  OPT_DO_PSTACK,
1735
1750
  OPT_PLUGIN_DIR,
1736
1751
  OPT_PORT_OPEN_TIMEOUT,
1737
1752
  OPT_SECURE_FILE_PRIV,
1738
 
  OPT_MIN_EXAMINED_ROW_LIMIT
 
1753
  OPT_MIN_EXAMINED_ROW_LIMIT,
 
1754
  OPT_OPTIMIZER_USE_MRR
1739
1755
};
1740
1756
 
1741
1757
 
1803
1819
   (char**) &opt_do_pstack, (char**) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0,
1804
1820
   0, 0, 0, 0},
1805
1821
#endif /* HAVE_STACK_TRACE_ON_SEGV */
 
1822
  {"engine-condition-pushdown",
 
1823
   OPT_ENGINE_CONDITION_PUSHDOWN,
 
1824
   N_("Push supported query conditions to the storage engine."),
 
1825
   (char**) &global_system_variables.engine_condition_pushdown,
 
1826
   (char**) &global_system_variables.engine_condition_pushdown,
 
1827
   0, GET_BOOL, NO_ARG, false, 0, 0, 0, 0, 0},
1806
1828
  /* See how it's handled in get_one_option() */
1807
1829
  {"exit-info", 'T',
1808
1830
   N_("Used for debugging;  Use at your own risk!"),
1930
1952
      "writes) to as much as you can afford;"),
1931
1953
   (char**) &dflt_key_cache_var.param_buff_size,
1932
1954
   (char**) 0,
1933
 
   0, (GET_ULL),
 
1955
   0, (GET_ULL | GET_ASK_ADDR),
1934
1956
   REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, SIZE_T_MAX, MALLOC_OVERHEAD,
1935
1957
   IO_SIZE, 0},
1936
1958
  {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD,
1940
1962
      "total number of blocks in key cache"),
1941
1963
   (char**) &dflt_key_cache_var.param_age_threshold,
1942
1964
   (char**) 0,
1943
 
   0, (GET_UINT32), REQUIRED_ARG,
 
1965
   0, (GET_UINT32 | GET_ASK_ADDR), REQUIRED_ARG,
1944
1966
   300, 100, ULONG_MAX, 0, 100, 0},
1945
1967
  {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
1946
1968
   N_("The default size of key cache blocks"),
1947
1969
   (char**) &dflt_key_cache_var.param_block_size,
1948
1970
   (char**) 0,
1949
 
   0, (GET_UINT32), REQUIRED_ARG,
 
1971
   0, (GET_UINT32 | GET_ASK_ADDR), REQUIRED_ARG,
1950
1972
   KEY_CACHE_BLOCK_SIZE, 512, 1024 * 16, 0, 512, 0},
1951
1973
  {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT,
1952
1974
   N_("The minimum percentage of warm blocks in key cache"),
1953
1975
   (char**) &dflt_key_cache_var.param_division_limit,
1954
1976
   (char**) 0,
1955
 
   0, (GET_UINT32) , REQUIRED_ARG, 100,
 
1977
   0, (GET_UINT32 | GET_ASK_ADDR) , REQUIRED_ARG, 100,
1956
1978
   1, 100, 0, 1, 0},
1957
1979
  {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
1958
1980
   N_("Max packetlength to send/receive from to server."),
2058
2080
   (char**) &global_system_variables.optimizer_search_depth,
2059
2081
   (char**) &max_system_variables.optimizer_search_depth,
2060
2082
   0, GET_UINT, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0},
 
2083
  {"optimizer_use_mrr", OPT_OPTIMIZER_USE_MRR,
 
2084
   N_("Should the Optmizer use MRR or not. "
 
2085
      "Valid values are auto, force and disable"),
 
2086
   0, 0, 0, GET_STR, REQUIRED_ARG, 0,
 
2087
   0, 0, 0, 0, 0},
2061
2088
  {"plugin_dir", OPT_PLUGIN_DIR,
2062
2089
   N_("Directory for plugins."),
2063
2090
   (char**) &opt_plugin_dir_ptr, (char**) &opt_plugin_dir_ptr, 0,
2362
2389
  thread_id= 1;
2363
2390
  myisam_stats_method_str= "nulls_unequal";
2364
2391
  session_list.clear();
 
2392
  key_caches.empty();
 
2393
  if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str,
 
2394
                                                default_key_cache_base.length)))
 
2395
    exit(1);
 
2396
  /* set key_cache_hash.default_value = dflt_key_cache */
 
2397
  multi_keycache_init();
2365
2398
 
2366
2399
  /* Set directory paths */
2367
2400
  strncpy(language, LANGUAGE, sizeof(language)-1);
2519
2552
      global_system_variables.tx_isolation= (type-1);
2520
2553
      break;
2521
2554
    }
 
2555
  case OPT_OPTIMIZER_USE_MRR:
 
2556
    {
 
2557
      int type;
 
2558
      type= find_type_or_exit(argument, &optimizer_use_mrr_typelib, opt->name);
 
2559
      global_system_variables.optimizer_use_mrr= (type-1);
 
2560
      break;
 
2561
    }
2522
2562
  case OPT_TC_HEURISTIC_RECOVER:
2523
2563
    tc_heuristic_recover= find_type_or_exit(argument,
2524
2564
                                            &tc_heuristic_recover_typelib,
2552
2592
}
2553
2593
 
2554
2594
 
 
2595
/** Handle arguments for multiple key caches. */
 
2596
 
 
2597
extern "C" char **drizzle_getopt_value(const char *keyname, uint32_t key_length,
 
2598
                                       const struct my_option *option);
 
2599
 
 
2600
char**
 
2601
drizzle_getopt_value(const char *keyname, uint32_t key_length,
 
2602
                    const struct my_option *option)
 
2603
{
 
2604
  switch (option->id) {
 
2605
  case OPT_KEY_BUFFER_SIZE:
 
2606
  case OPT_KEY_CACHE_BLOCK_SIZE:
 
2607
  case OPT_KEY_CACHE_DIVISION_LIMIT:
 
2608
  case OPT_KEY_CACHE_AGE_THRESHOLD:
 
2609
  {
 
2610
    KEY_CACHE *key_cache;
 
2611
    if (!(key_cache= get_or_create_key_cache(keyname, key_length)))
 
2612
      exit(1);
 
2613
    switch (option->id) {
 
2614
    case OPT_KEY_BUFFER_SIZE:
 
2615
      return (char**) &key_cache->param_buff_size;
 
2616
    case OPT_KEY_CACHE_BLOCK_SIZE:
 
2617
      return (char**) &key_cache->param_block_size;
 
2618
    case OPT_KEY_CACHE_DIVISION_LIMIT:
 
2619
      return (char**) &key_cache->param_division_limit;
 
2620
    case OPT_KEY_CACHE_AGE_THRESHOLD:
 
2621
      return (char**) &key_cache->param_age_threshold;
 
2622
    }
 
2623
  }
 
2624
  }
 
2625
  return (char **)option->value;
 
2626
}
 
2627
 
 
2628
 
2555
2629
extern "C" void option_error_reporter(enum loglevel level, const char *format, ...);
2556
2630
 
2557
2631
void option_error_reporter(enum loglevel level, const char *format, ...)
2576
2650
{
2577
2651
  int ho_error;
2578
2652
 
 
2653
  my_getopt_register_get_addr(drizzle_getopt_value);
2579
2654
  my_getopt_error_reporter= option_error_reporter;
2580
2655
 
2581
2656
  /* Skip unknown options so that they may be processed later by plugins */
2723
2798
/* Used templates */
2724
2799
template class I_List<i_string>;
2725
2800
template class I_List<i_string_pair>;
 
2801
template class I_List<NAMED_LIST>;
2726
2802
template class I_List<Statement>;
2727
2803
template class I_List_iterator<Statement>;
2728
2804
#endif