~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Brian Aker
  • Date: 2009-06-25 14:56:24 UTC
  • mfrom: (1067.1.7 ddl-code-cleanup)
  • Revision ID: brian@gaz-20090625145624-pjw9bxbq36istfag
Merge Stewart

Show diffs side-by-side

added added

removed removed

Lines of Context:
343
343
char server_version[SERVER_VERSION_LENGTH];
344
344
char *drizzle_tmpdir= NULL;
345
345
char *opt_drizzle_tmpdir= NULL;
346
 
const char *myisam_recover_options_str="OFF";
347
346
const char *myisam_stats_method_str="nulls_unequal";
348
347
 
349
348
/** name of reference on left espression in rewritten IN subquery */
433
432
static void fix_paths(void);
434
433
void handle_connections_sockets();
435
434
extern "C" pthread_handler_t handle_slave(void *arg);
436
 
static uint32_t find_bit_type(const char *x, TYPELIB *bit_lib);
437
 
static uint32_t find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
438
 
                                   const char *option);
439
435
static void clean_up(bool print_message);
440
436
 
441
437
static void usage(void);
2016
2012
 
2017
2013
enum options_drizzled
2018
2014
{
2019
 
  OPT_ISAM_LOG=256,
2020
 
  OPT_SOCKET,
 
2015
  OPT_SOCKET=256,
2021
2016
  OPT_BIND_ADDRESS,            OPT_PID_FILE,
2022
2017
  OPT_STORAGE_ENGINE,          
2023
2018
  OPT_INIT_FILE,
2025
2020
  OPT_DELAY_KEY_WRITE,
2026
2021
  OPT_WANT_CORE,
2027
2022
  OPT_MEMLOCK,
2028
 
  OPT_MYISAM_RECOVER,
2029
2023
  OPT_SERVER_ID,
2030
2024
  OPT_TC_HEURISTIC_RECOVER,
2031
2025
  OPT_ENGINE_CONDITION_PUSHDOWN,
2081
2075
  OPT_PLUGIN_LOAD,
2082
2076
  OPT_PLUGIN_DIR,
2083
2077
  OPT_PORT_OPEN_TIMEOUT,
2084
 
  OPT_KEEP_FILES_ON_CREATE,
2085
2078
  OPT_SECURE_FILE_PRIV,
2086
2079
  OPT_MIN_EXAMINED_ROW_LIMIT,
2087
2080
  OPT_OPTIMIZER_USE_MRR
2190
2183
   N_("Log connections and queries to file."),
2191
2184
   (char**) &opt_logname,
2192
2185
   (char**) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
2193
 
  {"log-isam", OPT_ISAM_LOG,
2194
 
   N_("Log all MyISAM changes to file."),
2195
 
   (char**) &myisam_log_filename, (char**) &myisam_log_filename, 0, GET_STR,
2196
 
   OPT_ARG, 0, 0, 0, 0, 0, 0},
2197
2186
  {"log-warnings", 'W',
2198
2187
   N_("Log some not critical warnings to the log file."),
2199
2188
   (char**) &global_system_variables.log_warnings,
2203
2192
   N_("Lock drizzled in memory."),
2204
2193
   (char**) &locked_in_memory,
2205
2194
   (char**) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
2206
 
  {"myisam-recover", OPT_MYISAM_RECOVER,
2207
 
   N_("Syntax: myisam-recover[=option[,option...]], where option can be "
2208
 
      "DEFAULT, BACKUP, FORCE or QUICK."),
2209
 
   (char**) &myisam_recover_options_str, (char**) &myisam_recover_options_str, 0,
2210
 
   GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
2211
2195
  {"pid-file", OPT_PID_FILE,
2212
2196
   N_("Pid file used by safe_mysqld."),
2213
2197
   (char**) &pidfile_name_ptr, (char**) &pidfile_name_ptr, 0, GET_STR,
2301
2285
   (char**) &max_system_variables.join_buff_size, 0, GET_UINT64,
2302
2286
   REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ULONG_MAX,
2303
2287
   MALLOC_OVERHEAD, IO_SIZE, 0},
2304
 
  {"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE,
2305
 
   N_("Don't overwrite stale .MYD and .MYI even if no directory is specified."),
2306
 
   (char**) &global_system_variables.keep_files_on_create,
2307
 
   (char**) &max_system_variables.keep_files_on_create,
2308
 
   0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
2309
2288
  {"key_buffer_size", OPT_KEY_BUFFER_SIZE,
2310
2289
   N_("The size of the buffer used for index blocks for MyISAM tables. "
2311
2290
      "Increase this to get better index handling (for all reads and multiple "
2380
2359
   (char**) &global_system_variables.max_sort_length,
2381
2360
   (char**) &max_system_variables.max_sort_length, 0, GET_SIZE,
2382
2361
   REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
2383
 
  {"max_tmp_tables", OPT_MAX_TMP_TABLES,
2384
 
   N_("Maximum number of temporary tables a client can keep open at a time."),
2385
 
   (char**) &global_system_variables.max_tmp_tables,
2386
 
   (char**) &max_system_variables.max_tmp_tables, 0, GET_UINT64,
2387
 
   REQUIRED_ARG, 32, 1, ULONG_MAX, 0, 1, 0},
2388
2362
  {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
2389
2363
   N_("After this many write locks, allow some read locks to run in between."),
2390
2364
   (char**) &max_write_lock_count, (char**) &max_write_lock_count, 0, GET_ULL,
2762
2736
  refresh_version= 1L;  /* Increments on each reload */
2763
2737
  thread_id= 1;
2764
2738
  strcpy(server_version, VERSION);
2765
 
  myisam_recover_options_str= "OFF";
2766
2739
  myisam_stats_method_str= "nulls_unequal";
2767
2740
  session_list.clear();
2768
2741
  key_caches.empty();
2933
2906
      global_system_variables.optimizer_use_mrr= (type-1);
2934
2907
      break;
2935
2908
    }
2936
 
  case OPT_MYISAM_RECOVER:
2937
 
    {
2938
 
      if (!argument)
2939
 
      {
2940
 
        myisam_recover_options=    HA_RECOVER_DEFAULT;
2941
 
        myisam_recover_options_str= myisam_recover_typelib.type_names[0];
2942
 
      }
2943
 
      else if (!argument[0])
2944
 
      {
2945
 
        myisam_recover_options= HA_RECOVER_NONE;
2946
 
        myisam_recover_options_str= "OFF";
2947
 
      }
2948
 
      else
2949
 
      {
2950
 
        myisam_recover_options_str=argument;
2951
 
        myisam_recover_options=
2952
 
          find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name);
2953
 
      }
2954
 
      ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
2955
 
      break;
2956
 
    }
2957
2909
  case OPT_TC_HEURISTIC_RECOVER:
2958
2910
    tc_heuristic_recover= find_type_or_exit(argument,
2959
2911
                                            &tc_heuristic_recover_typelib,
3204
3156
  }
3205
3157
}
3206
3158
 
3207
 
 
3208
 
static uint32_t find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
3209
 
                                      const char *option)
3210
 
{
3211
 
  uint32_t res;
3212
 
 
3213
 
  const char **ptr;
3214
 
 
3215
 
  if ((res= find_bit_type(x, bit_lib)) == ~(uint32_t) 0)
3216
 
  {
3217
 
    ptr= bit_lib->type_names;
3218
 
    if (!*x)
3219
 
      fprintf(stderr, _("No option given to %s\n"), option);
3220
 
    else
3221
 
      fprintf(stderr, _("Wrong option to %s. Option(s) given: %s\n"),
3222
 
              option, x);
3223
 
    fprintf(stderr, _("Alternatives are: '%s'"), *ptr);
3224
 
    while (*++ptr)
3225
 
      fprintf(stderr, ",'%s'", *ptr);
3226
 
    fprintf(stderr, "\n");
3227
 
    exit(1);
3228
 
  }
3229
 
  return res;
3230
 
}
3231
 
 
3232
 
 
3233
 
/**
3234
 
  @return
3235
 
    a bitfield from a string of substrings separated by ','
3236
 
    or
3237
 
    ~(uint32_t) 0 on error.
3238
 
*/
3239
 
 
3240
 
static uint32_t find_bit_type(const char *x, TYPELIB *bit_lib)
3241
 
{
3242
 
  bool found_end;
3243
 
  int  found_count;
3244
 
  const char *end,*i,*j;
3245
 
  const char **array, *pos;
3246
 
  uint32_t found,found_int,bit;
3247
 
 
3248
 
  found=0;
3249
 
  found_end= 0;
3250
 
  pos=(char *) x;
3251
 
  while (*pos == ' ') pos++;
3252
 
  found_end= *pos == 0;
3253
 
  while (!found_end)
3254
 
  {
3255
 
    if ((end=strrchr(pos,',')) != NULL)         /* Let end point at fieldend */
3256
 
    {
3257
 
      while (end > pos && end[-1] == ' ')
3258
 
        end--;                                  /* Skip end-space */
3259
 
      found_end=1;
3260
 
    }
3261
 
    else
3262
 
    {
3263
 
        end=pos+strlen(pos);
3264
 
        found_end=1;
3265
 
    }
3266
 
    found_int=0; found_count=0;
3267
 
    for (array=bit_lib->type_names, bit=1 ; (i= *array++) ; bit<<=1)
3268
 
    {
3269
 
      j=pos;
3270
 
      while (j != end)
3271
 
      {
3272
 
        if (my_toupper(mysqld_charset,*i++) !=
3273
 
            my_toupper(mysqld_charset,*j++))
3274
 
          goto skip;
3275
 
      }
3276
 
      found_int=bit;
3277
 
      if (! *i)
3278
 
      {
3279
 
        found_count=1;
3280
 
        break;
3281
 
      }
3282
 
      else if (j != pos)                        // Half field found
3283
 
      {
3284
 
        found_count++;                          // Could be one of two values
3285
 
      }
3286
 
skip: ;
3287
 
    }
3288
 
    if (found_count != 1)
3289
 
      return(~(uint32_t) 0);                            // No unique value
3290
 
    found|=found_int;
3291
 
    pos=end+1;
3292
 
  }
3293
 
 
3294
 
  return(found);
3295
 
} /* find_bit_type */
3296
 
 
3297
3159
/*****************************************************************************
3298
3160
  Instantiate templates
3299
3161
*****************************************************************************/