~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to sql/mysqld.cc

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "sql_repl.h"
23
23
#include "rpl_filter.h"
24
24
#include "repl_failsafe.h"
25
 
#include "stacktrace.h"
 
25
#include <my_stacktrace.h>
26
26
#include "mysqld_suffix.h"
27
27
#include "mysys_err.h"
28
28
#include "events.h"
167
167
static void getvolumename();
168
168
static void getvolumeID(BYTE *volumeName);
169
169
#endif /* __NETWARE__ */
170
 
  
 
170
 
171
171
 
172
172
#ifdef _AIX41
173
173
int initgroups(const char *,unsigned int);
180
180
#endif
181
181
#endif /* __FreeBSD__ && HAVE_IEEEFP_H */
182
182
 
 
183
#ifdef HAVE_FENV_H
 
184
#include <fenv.h>
 
185
#endif
 
186
 
183
187
#ifdef HAVE_FPU_CONTROL_H
184
188
#include <fpu_control.h>
185
189
#endif
204
208
  fpsetmask(~(FP_X_INV |             FP_X_OFL | FP_X_UFL | FP_X_DZ |
205
209
              FP_X_IMP));
206
210
#endif /* __i386__ */
 
211
 
207
212
#endif /* __FreeBSD__ && HAVE_IEEEFP_H */
208
213
 
 
214
#ifdef HAVE_FESETROUND
 
215
  /* Set FPU rounding mode to "round-to-nearest" */
 
216
  fesetround(FE_TONEAREST);
 
217
#endif /* HAVE_FESETROUND */
 
218
 
209
219
  /*
210
220
    x86 (32-bit) requires FPU precision to be explicitly set to 64 bit for
211
221
    portable results of floating point operations
243
253
#endif
244
254
 
245
255
extern "C" sig_handler handle_segfault(int sig);
 
256
/* 
 
257
  Online backup initialization and shutdown functions - defined in 
 
258
  backup/kernel.cc
 
259
 */
 
260
#ifndef EMBEDDED_LIBRARY
 
261
int backup_init();
 
262
void backup_shutdown();
 
263
#endif
246
264
 
247
265
/* Constants */
248
266
 
375
393
const char *log_output_names[] = { "NONE", "FILE", "TABLE", NullS};
376
394
static const unsigned int log_output_names_len[]= { 4, 4, 5, 0 };
377
395
TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"",
378
 
                             log_output_names, 
 
396
                             log_output_names,
379
397
                             (unsigned int *) log_output_names_len};
380
398
 
381
399
/* static variables */
397
415
static char *character_set_filesystem_name;
398
416
static char *lc_time_names_name;
399
417
static char *my_bind_addr_str;
400
 
static char *default_collation_name; 
 
418
static char *default_collation_name;
401
419
static char *default_storage_engine_str;
402
420
static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
403
421
static I_List<THD> thread_cache;
404
422
static double long_query_time;
 
423
static ulong opt_my_crc_dbug_check;
405
424
 
406
425
static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
407
426
 
425
444
   @brief 'grant_option' is used to indicate if privileges needs
426
445
   to be checked, in which case the lock, LOCK_grant, is used
427
446
   to protect access to the grant table.
428
 
   @note This flag is dropped in 5.1 
 
447
   @note This flag is dropped in 5.1
429
448
   @see grant_init()
430
449
 */
431
450
bool volatile grant_option;
479
498
my_bool opt_large_pages= 0;
480
499
my_bool opt_myisam_use_mmap= 0;
481
500
uint    opt_large_page_size= 0;
 
501
#if defined(ENABLED_DEBUG_SYNC)
 
502
uint    opt_debug_sync_timeout= 0;
 
503
#endif /* defined(ENABLED_DEBUG_SYNC) */
482
504
my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
483
505
/*
484
506
  True if there is at least one per-hour limit for some user, so we should
508
530
ulonglong thd_startup_options;
509
531
ulong back_log, connect_timeout, concurrency, server_id;
510
532
ulong table_cache_size, table_def_size;
511
 
ulong thread_stack, what_to_log;
 
533
ulong what_to_log;
512
534
ulong query_buff_size, slow_launch_time, slave_open_temp_tables;
513
535
ulong open_files_limit, max_binlog_size, max_relay_log_size;
514
536
ulong slave_net_timeout, slave_trans_retries;
656
678
pthread_key(THD*, THR_THD);
657
679
pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count,
658
680
                LOCK_mapped_file, LOCK_status, LOCK_global_read_lock,
659
 
                LOCK_error_log, LOCK_uuid_generator,
 
681
                LOCK_error_log,
660
682
                LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create,
661
683
                LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
662
684
                LOCK_global_system_variables,
663
 
                LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
 
685
                LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
664
686
                LOCK_connection_count;
665
 
pthread_mutex_t LOCK_backup;
666
687
 
667
688
/**
668
689
  The below lock protects access to two global server variables:
701
722
#ifdef HAVE_STACK_TRACE_ON_SEGV
702
723
static my_bool opt_do_pstack;
703
724
#endif /* HAVE_STACK_TRACE_ON_SEGV */
704
 
static my_bool opt_bootstrap, opt_myisam_log;
 
725
static my_bool opt_bootstrap, opt_myisam_logical_log;
705
726
static int cleanup_done;
706
727
static ulong opt_specialflag, opt_myisam_block_size;
707
728
static char *opt_update_logname, *opt_binlog_index_name;
712
733
static char *opt_bin_logname;
713
734
 
714
735
static my_socket unix_sock,ip_sock;
715
 
struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD()
 
736
struct my_rnd_struct sql_rand; ///< used by sql_class.cc:THD::THD()
716
737
 
717
738
#ifndef EMBEDDED_LIBRARY
718
739
struct passwd *user_info;
862
883
  (void) pthread_mutex_lock(&LOCK_manager);
863
884
  if (manager_thread_in_use)
864
885
  {
865
 
    DBUG_PRINT("quit", ("killing manager thread: 0x%lx",
866
 
                        (ulong)manager_thread));
 
886
    DBUG_PRINT("quit", ("killing manager thread: 0x%llx",
 
887
                        (ulonglong)manager_thread));
867
888
   (void) pthread_cond_signal(&COND_manager);
868
889
  }
869
890
  (void) pthread_mutex_unlock(&LOCK_manager);
870
891
 
871
892
  /* kill connection thread */
872
893
#if !defined(__WIN__) && !defined(__NETWARE__)
873
 
  DBUG_PRINT("quit", ("waiting for select thread: 0x%lx",
874
 
                      (ulong) select_thread));
 
894
  DBUG_PRINT("quit", ("waiting for select thread: 0x%llx",
 
895
                      (ulonglong)select_thread));
875
896
  (void) pthread_mutex_lock(&LOCK_thread_count);
876
897
 
877
898
  while (select_thread_in_use)
894
915
        break;
895
916
    }
896
917
#ifdef EXTRA_DEBUG
897
 
    if (error != 0 && !count++)
 
918
    if (error != 0 && error != ETIMEDOUT && !count++)
898
919
      sql_print_error("Got error %d from pthread_cond_timedwait",error);
899
920
#endif
900
921
    close_server_sock();
1045
1066
  {
1046
1067
    ip_sock=INVALID_SOCKET;
1047
1068
    DBUG_PRINT("info",("calling shutdown on TCP/IP socket"));
1048
 
    VOID(shutdown(tmp_sock, SHUT_RDWR));
 
1069
    (void) shutdown(tmp_sock, SHUT_RDWR);
1049
1070
#if defined(__NETWARE__)
1050
1071
    /*
1051
1072
      The following code is disabled for normal systems as it causes MySQL
1052
1073
      to hang on AIX 4.3 during shutdown
1053
1074
    */
1054
1075
    DBUG_PRINT("info",("calling closesocket on TCP/IP socket"));
1055
 
    VOID(closesocket(tmp_sock));
 
1076
    (void) closesocket(tmp_sock);
1056
1077
#endif
1057
1078
  }
1058
1079
  tmp_sock=unix_sock;
1060
1081
  {
1061
1082
    unix_sock=INVALID_SOCKET;
1062
1083
    DBUG_PRINT("info",("calling shutdown on unix socket"));
1063
 
    VOID(shutdown(tmp_sock, SHUT_RDWR));
 
1084
    (void) shutdown(tmp_sock, SHUT_RDWR);
1064
1085
#if defined(__NETWARE__)
1065
1086
    /*
1066
1087
      The following code is disabled for normal systems as it may cause MySQL
1067
1088
      to hang on AIX 4.3 during shutdown
1068
1089
    */
1069
1090
    DBUG_PRINT("info",("calling closesocket on unix/IP socket"));
1070
 
    VOID(closesocket(tmp_sock));
 
1091
    (void) closesocket(tmp_sock);
1071
1092
#endif
1072
 
    VOID(unlink(mysqld_unix_port));
 
1093
    (void) unlink(mysqld_unix_port);
1073
1094
  }
1074
1095
  DBUG_VOID_RETURN;
1075
1096
#endif
1162
1183
  else
1163
1184
    sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
1164
1185
 
1165
 
#if defined(HAVE_SMEM) && defined(__WIN__)    
1166
 
  /*    
1167
 
   Send event to smem_event_connect_request for aborting    
1168
 
   */    
1169
 
  if (!SetEvent(smem_event_connect_request))    
1170
 
  {      
1171
 
          DBUG_PRINT("error",
1172
 
                ("Got error: %ld from SetEvent of smem_event_connect_request",
1173
 
                 GetLastError()));    
 
1186
#if defined(HAVE_SMEM) && defined(__WIN__)
 
1187
  /*
 
1188
   Send event to smem_event_connect_request for aborting
 
1189
   */
 
1190
  if (!SetEvent(smem_event_connect_request))
 
1191
  {
 
1192
    DBUG_PRINT("error",
 
1193
               ("Got error: %ld from SetEvent of smem_event_connect_request",
 
1194
                GetLastError()));
1174
1195
  }
1175
 
#endif  
1176
 
  
 
1196
#endif
 
1197
 
1177
1198
  close_connections();
1178
1199
  if (sig != MYSQL_KILL_SIGNAL &&
1179
1200
      sig != 0)
1304
1325
  grant_free();
1305
1326
#endif
1306
1327
  query_cache_destroy();
1307
 
  table_cache_free();
1308
1328
  table_def_free();
1309
1329
  hostname_cache_free();
 
1330
  mdl_destroy();
1310
1331
  item_user_lock_free();
1311
1332
  lex_free();                           /* Free some memory */
1312
1333
  item_create_cleanup();
1318
1339
    udf_free();
1319
1340
#endif
1320
1341
  }
 
1342
#ifndef EMBEDDED_LIBRARY
 
1343
  backup_shutdown();
 
1344
#endif
1321
1345
  plugin_shutdown();
1322
1346
  ha_end();
1323
1347
  if (tc_log)
1359
1383
#ifdef USE_REGEX
1360
1384
  my_regex_end();
1361
1385
#endif
 
1386
#if defined(ENABLED_DEBUG_SYNC)
 
1387
  /* End the debug sync facility. See debug_sync.cc. */
 
1388
  debug_sync_end();
 
1389
#endif /* defined(ENABLED_DEBUG_SYNC) */
1362
1390
 
1363
1391
#if !defined(EMBEDDED_LIBRARY)
1364
1392
  if (!opt_bootstrap)
1379
1407
  /* do the broadcast inside the lock to ensure that my_end() is not called */
1380
1408
  (void) pthread_cond_broadcast(&COND_thread_count);
1381
1409
  (void) pthread_mutex_unlock(&LOCK_thread_count);
 
1410
  my_uuid_end();
1382
1411
 
1383
1412
  /*
1384
1413
    The following lines may never be executed as the main thread may have
1431
1460
  (void) pthread_mutex_destroy(&LOCK_bytes_sent);
1432
1461
  (void) pthread_mutex_destroy(&LOCK_bytes_received);
1433
1462
  (void) pthread_mutex_destroy(&LOCK_user_conn);
1434
 
  (void) pthread_mutex_destroy(&LOCK_backup);
1435
1463
  (void) pthread_mutex_destroy(&LOCK_connection_count);
1436
1464
  Events::destroy_mutexes();
1437
1465
#ifdef HAVE_OPENSSL
1450
1478
  (void) rwlock_destroy(&LOCK_sys_init_connect);
1451
1479
  (void) rwlock_destroy(&LOCK_sys_init_slave);
1452
1480
  (void) pthread_mutex_destroy(&LOCK_global_system_variables);
 
1481
  (void) pthread_mutex_destroy(&LOCK_uuid_short);
1453
1482
  (void) rwlock_destroy(&LOCK_system_variables_hash);
1454
1483
  (void) pthread_mutex_destroy(&LOCK_global_read_lock);
1455
 
  (void) pthread_mutex_destroy(&LOCK_uuid_generator);
1456
1484
  (void) pthread_mutex_destroy(&LOCK_prepared_stmt_count);
1457
1485
  (void) pthread_cond_destroy(&COND_thread_count);
1458
1486
  (void) pthread_cond_destroy(&COND_refresh);
1750
1778
  if (Service.IsNT() && mysqld_unix_port[0] && !opt_bootstrap &&
1751
1779
      opt_enable_named_pipe)
1752
1780
  {
1753
 
    
 
1781
 
1754
1782
    pipe_name[sizeof(pipe_name)-1]= 0;          /* Safety if too long string */
1755
1783
    strxnmov(pipe_name, sizeof(pipe_name)-1, "\\\\.\\pipe\\",
1756
1784
             mysqld_unix_port, NullS);
1908
1936
void unlink_thd(THD *thd)
1909
1937
{
1910
1938
  DBUG_ENTER("unlink_thd");
1911
 
  DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
 
1939
  DBUG_PRINT("enter", ("thd: %p", thd));
1912
1940
  thd->cleanup();
1913
1941
 
1914
1942
  pthread_mutex_lock(&LOCK_connection_count);
2066
2094
static BOOL WINAPI console_event_handler( DWORD type ) 
2067
2095
{
2068
2096
  DBUG_ENTER("console_event_handler");
 
2097
#ifndef EMBEDDED_LIBRARY
2069
2098
  if(type == CTRL_C_EVENT)
2070
2099
  {
2071
2100
     /*
2074
2103
       between main thread doing initialization and CTRL-C thread doing
2075
2104
       cleanup, which can result into crash.
2076
2105
     */
 
2106
#ifndef EMBEDDED_LIBRARY
2077
2107
     if(hEventShutdown)
2078
2108
       kill_mysql();
2079
2109
     else
 
2110
#endif
2080
2111
       sql_print_warning("CTRL-C ignored during startup");
2081
2112
     DBUG_RETURN(TRUE);
2082
2113
  }
 
2114
#endif
2083
2115
  DBUG_RETURN(FALSE);
2084
2116
}
2085
2117
 
2163
2195
#endif /* DEBUG_UNHANDLED_EXCEPTION_FILTER */
2164
2196
  __try
2165
2197
  {
2166
 
    set_exception_pointers(ex_pointers);
 
2198
    my_set_exception_pointers(ex_pointers);
2167
2199
    handle_segfault(ex_pointers->ExceptionRecord->ExceptionCode);
2168
2200
  }
2169
2201
  __except(EXCEPTION_EXECUTE_HANDLER)
2292
2324
{
2293
2325
 
2294
2326
  ConsumerRegistrationInfo reg_info;
2295
 
    
 
2327
 
2296
2328
  /* Clear NEB registration structure */
2297
2329
  bzero((char*) &reg_info, sizeof(struct ConsumerRegistrationInfo));
2298
2330
 
2308
2340
  reg_info.CRIOwnerID= (LoadDefinitionStructure *)getnlmhandle();
2309
2341
  reg_info.CRIConsumerESR= NULL;            // No consumer ESR required
2310
2342
  reg_info.CRISecurityToken= 0;             // No security token for the event
2311
 
  reg_info.CRIConsumerFlags= 0;             // SMP_ENABLED_BIT; 
 
2343
  reg_info.CRIConsumerFlags= 0;             // SMP_ENABLED_BIT;
2312
2344
  reg_info.CRIFilterName= 0;                // No event filtering
2313
2345
  reg_info.CRIFilterDataLength= 0;          // No filtering data
2314
2346
  reg_info.CRIFilterData= 0;                // No filtering data
2333
2365
    Get the NSS volume ID of the MySQL Data volume.
2334
2366
    Volume ID is stored in a global variable
2335
2367
  */
2336
 
  getvolumeID((BYTE*) datavolname);     
 
2368
  getvolumeID((BYTE*) datavolname);
2337
2369
}
2338
2370
 
2339
2371
 
2397
2429
 
2398
2430
  strxmov(path, (const char *) ADMIN_VOL_PATH, (const char *) volumeName,
2399
2431
          NullS);
2400
 
  if ((status= zOpen(rootKey, zNSS_TASK, zNSPACE_LONG|zMODE_UTF8, 
 
2432
  if ((status= zOpen(rootKey, zNSS_TASK, zNSPACE_LONG|zMODE_UTF8,
2401
2433
                     (BYTE *) path, zRR_READ_ACCESS, &fileKey)) != zOK)
2402
2434
  {
2403
2435
    consoleprintf("\nGetNSSVolumeProperties - Failed to get file, status: %d\n.", (int) status);
2405
2437
  }
2406
2438
 
2407
2439
  getInfoMask= zGET_IDS | zGET_VOLUME_INFO ;
2408
 
  if ((status= zGetInfo(fileKey, getInfoMask, sizeof(info), 
 
2440
  if ((status= zGetInfo(fileKey, getInfoMask, sizeof(info),
2409
2441
                        zINFO_VERSION_A, &info)) != zOK)
2410
2442
  {
2411
2443
    consoleprintf("\nGetNSSVolumeProperties - Failed in zGetInfo, status: %d\n.", (int) status);
2511
2543
We will try our best to scrape up some info that will hopefully help diagnose\n\
2512
2544
the problem, but since we have already crashed, something is definitely wrong\n\
2513
2545
and this may fail.\n\n");
2514
 
  fprintf(stderr, "key_buffer_size=%lu\n", 
 
2546
  fprintf(stderr, "key_buffer_size=%lu\n",
2515
2547
          (ulong) dflt_key_cache->key_cache_mem_size);
2516
2548
  fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
2517
2549
  fprintf(stderr, "max_used_connections=%lu\n", max_used_connections);
2547
2579
Attempting backtrace. You can use the following information to find out\n\
2548
2580
where mysqld died. If you see no messages after this, something went\n\
2549
2581
terribly wrong...\n");  
2550
 
    print_stacktrace(thd ? (uchar*) thd->thread_stack : (uchar*) 0,
2551
 
                   thread_stack);
 
2582
    my_print_stacktrace(thd ? (uchar*) thd->thread_stack : NULL,
 
2583
                        my_thread_stack_size);
2552
2584
  }
2553
2585
  if (thd)
2554
2586
  {
2572
2604
    }
2573
2605
    fprintf(stderr, "Trying to get some variables.\n\
2574
2606
Some pointers may be invalid and cause the dump to abort...\n");
2575
 
    safe_print_str("thd->query", thd->query, 1024);
 
2607
    my_safe_print_str("thd->query", thd->query, 1024);
2576
2608
    fprintf(stderr, "thd->thread_id=%lu\n", (ulong) thd->thread_id);
2577
2609
    fprintf(stderr, "thd->killed=%s\n", kreason);
2578
2610
  }
2602
2634
to be used with the LD_ASSUME_KERNEL environment variable. Please consult\n\
2603
2635
the documentation for your distribution on how to do that.\n");
2604
2636
#endif
2605
 
  
 
2637
 
2606
2638
  if (locked_in_memory)
2607
2639
  {
2608
2640
    fprintf(stderr, "\n\
2619
2651
  {
2620
2652
    fprintf(stderr, "Writing a core file\n");
2621
2653
    fflush(stderr);
2622
 
    write_core(sig);
 
2654
    my_write_core(sig);
2623
2655
  }
2624
2656
#endif
2625
2657
 
2653
2685
    sigemptyset(&sa.sa_mask);
2654
2686
    sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
2655
2687
 
2656
 
    init_stacktrace();
 
2688
#ifdef HAVE_STACKTRACE
 
2689
    my_init_stacktrace();
 
2690
#endif
2657
2691
#if defined(__amiga__)
2658
2692
    sa.sa_handler=(void(*)())handle_segfault;
2659
2693
#else
2702
2736
    sigaddset(&set,THR_SERVER_ALARM);
2703
2737
  if (test_flags & TEST_SIGINT)
2704
2738
  {
2705
 
    my_sigset(thr_kill_signal, end_thread_signal);
2706
2739
    // May be SIGINT
2707
2740
    sigdelset(&set, thr_kill_signal);
 
2741
    sigdelset(&set, SIGINT);
 
2742
    my_sigset(thr_kill_signal, end_thread_signal);
 
2743
    my_sigset(SIGINT, end_thread_signal);
2708
2744
  }
2709
2745
  else
2710
2746
    sigaddset(&set,SIGINT);
 
2747
 
2711
2748
  sigprocmask(SIG_SETMASK,&set,NULL);
2712
2749
  pthread_sigmask(SIG_SETMASK,&set,NULL);
2713
2750
  DBUG_VOID_RETURN;
2731
2768
    Peculiar things with ia64 platforms - it seems we only have half the
2732
2769
    stack size in reality, so we have to double it here
2733
2770
  */
2734
 
  pthread_attr_setstacksize(&thr_attr,thread_stack*2);
 
2771
  pthread_attr_setstacksize(&thr_attr,my_thread_stack_size*2);
2735
2772
#else
2736
 
  pthread_attr_setstacksize(&thr_attr,thread_stack);
 
2773
  pthread_attr_setstacksize(&thr_attr,my_thread_stack_size);
2737
2774
#endif
2738
2775
#endif
2739
2776
 
2905
2942
  for the client.
2906
2943
*/
2907
2944
/* ARGSUSED */
2908
 
extern "C" int my_message_sql(uint error, const char *str, myf MyFlags);
 
2945
extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
2909
2946
 
2910
 
int my_message_sql(uint error, const char *str, myf MyFlags)
 
2947
void my_message_sql(uint error, const char *str, myf MyFlags)
2911
2948
{
2912
2949
  THD *thd;
 
2950
  MYSQL_ERROR::enum_warning_level level;
 
2951
  sql_print_message_func func;
2913
2952
  DBUG_ENTER("my_message_sql");
2914
2953
  DBUG_PRINT("error", ("error: %u  message: '%s'", error, str));
2915
2954
  /*
2917
2956
    will be fixed
2918
2957
    DBUG_ASSERT(error != 0);
2919
2958
  */
 
2959
  if (MyFlags & ME_JUST_INFO)
 
2960
  {
 
2961
    level= MYSQL_ERROR::WARN_LEVEL_NOTE;
 
2962
    func= sql_print_information;
 
2963
  }
 
2964
  else if (MyFlags & ME_JUST_WARNING)
 
2965
  {
 
2966
    level= MYSQL_ERROR::WARN_LEVEL_WARN;
 
2967
    func= sql_print_warning;
 
2968
  }
 
2969
  else
 
2970
  {
 
2971
    level= MYSQL_ERROR::WARN_LEVEL_ERROR;
 
2972
    func= sql_print_error;
 
2973
  }
 
2974
 
2920
2975
  if ((thd= current_thd))
2921
2976
  {
 
2977
    if (MyFlags & ME_FATALERROR)
 
2978
      thd->is_fatal_error= 1;
 
2979
 
 
2980
#ifdef BUG_36098_FIXED
2922
2981
    mysql_audit_general(thd,MYSQL_AUDIT_GENERAL_ERROR,error,my_time(0),
2923
2982
                        0,0,str,str ? strlen(str) : 0,
2924
2983
                        thd->query,thd->query_length,
2925
2984
                        thd->variables.character_set_client,
2926
2985
                        thd->row_count);
 
2986
#endif
2927
2987
 
2928
2988
 
2929
2989
    /*
2930
2990
      TODO: There are two exceptions mechanism (THD and sp_rcontext),
2931
2991
      this could be improved by having a common stack of handlers.
2932
2992
    */
2933
 
    if (thd->handle_error(error, str,
2934
 
                          MYSQL_ERROR::WARN_LEVEL_ERROR))
2935
 
      DBUG_RETURN(0);
 
2993
    if (thd->handle_error(error, str, level))
 
2994
      DBUG_VOID_RETURN;
 
2995
 
 
2996
    if (level == MYSQL_ERROR::WARN_LEVEL_WARN)
 
2997
      push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, error, str);
 
2998
    if (level != MYSQL_ERROR::WARN_LEVEL_ERROR)
 
2999
      goto to_error_log;
2936
3000
 
2937
3001
    thd->is_slave_error=  1; // needed to catch query errors during replication
2938
3002
 
2966
3030
      If a continue handler is found, the error message will be cleared
2967
3031
      by the stored procedures code.
2968
3032
    */
2969
 
    if (thd->spcont &&
 
3033
    if (!thd->is_fatal_error && thd->spcont &&
 
3034
        ! (MyFlags & ME_NO_SP_HANDLER) &&
2970
3035
        thd->spcont->handle_error(error, MYSQL_ERROR::WARN_LEVEL_ERROR, thd))
2971
3036
    {
2972
3037
      /*
2973
3038
        Do not push any warnings, a handled error must be completely
2974
3039
        silenced.
2975
3040
      */
2976
 
      DBUG_RETURN(0);
 
3041
      DBUG_VOID_RETURN;
2977
3042
    }
2978
3043
 
2979
 
    if (!thd->no_warnings_for_error)
 
3044
    if (!thd->is_fatal_error && !thd->no_warnings_for_error &&
 
3045
        !(MyFlags & ME_NO_WARNING_FOR_ERROR))
2980
3046
    {
2981
3047
      /*
2982
3048
        Suppress infinite recursion if there a memory allocation error
2987
3053
      thd->no_warnings_for_error= FALSE;
2988
3054
    }
2989
3055
  }
2990
 
  if (!thd || MyFlags & ME_NOREFRESH)
2991
 
    sql_print_error("%s: %s",my_progname,str); /* purecov: inspected */
2992
 
  DBUG_RETURN(0);
 
3056
to_error_log:
 
3057
  if (!thd || (MyFlags & ME_NOREFRESH))
 
3058
    (*func)("%s: %s", my_progname_short, str); /* purecov: inspected */
 
3059
  DBUG_VOID_RETURN;
2993
3060
}
2994
3061
 
2995
3062
 
3164
3231
  {"savepoint",            (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
3165
3232
  {"select",               (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SELECT]), SHOW_LONG_STATUS},
3166
3233
  {"set_option",           (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
3167
 
  {"show_archive",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ARCHIVE]), SHOW_LONG_STATUS},
3168
3234
  {"show_authors",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_AUTHORS]), SHOW_LONG_STATUS},
3169
3235
  {"show_binlog_events",   (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOG_EVENTS]), SHOW_LONG_STATUS},
3170
3236
  {"show_binlogs",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOGS]), SHOW_LONG_STATUS},
3171
3237
  {"show_charsets",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CHARSETS]), SHOW_LONG_STATUS},
3172
3238
  {"show_collations",      (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_COLLATIONS]), SHOW_LONG_STATUS},
3173
 
  {"show_column_types",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_COLUMN_TYPES]), SHOW_LONG_STATUS},
3174
3239
  {"show_contributors",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CONTRIBUTORS]), SHOW_LONG_STATUS},
3175
3240
  {"show_create_db",       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
3176
3241
  {"show_create_event",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_EVENT]), SHOW_LONG_STATUS},
3218
3283
  {"stmt_execute",         (char*) offsetof(STATUS_VAR, com_stmt_execute), SHOW_LONG_STATUS},
3219
3284
  {"stmt_fetch",           (char*) offsetof(STATUS_VAR, com_stmt_fetch), SHOW_LONG_STATUS},
3220
3285
  {"stmt_prepare",         (char*) offsetof(STATUS_VAR, com_stmt_prepare), SHOW_LONG_STATUS},
 
3286
  {"stmt_reprepare",       (char*) offsetof(STATUS_VAR, com_stmt_reprepare), SHOW_LONG_STATUS},
3221
3287
  {"stmt_reset",           (char*) offsetof(STATUS_VAR, com_stmt_reset), SHOW_LONG_STATUS},
3222
3288
  {"stmt_send_long_data",  (char*) offsetof(STATUS_VAR, com_stmt_send_long_data), SHOW_LONG_STATUS},
3223
3289
  {"truncate",             (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
3306
3372
    We have few debug-only commands in com_status_vars, only visible in debug
3307
3373
    builds. for simplicity we enable the assert only in debug builds
3308
3374
 
3309
 
    There are 7 Com_ variables which don't have corresponding SQLCOM_ values:
 
3375
    There are 8 Com_ variables which don't have corresponding SQLCOM_ values:
3310
3376
    (TODO strictly speaking they shouldn't be here, should not have Com_ prefix
3311
3377
    that is. Perhaps Stmt_ ? Comstmt_ ? Prepstmt_ ?)
3312
3378
 
3315
3381
      Com_stmt_execute         => com_stmt_execute
3316
3382
      Com_stmt_fetch           => com_stmt_fetch
3317
3383
      Com_stmt_prepare         => com_stmt_prepare
 
3384
      Com_stmt_reprepare       => com_stmt_reprepare
3318
3385
      Com_stmt_reset           => com_stmt_reset
3319
3386
      Com_stmt_send_long_data  => com_stmt_send_long_data
3320
3387
 
3323
3390
    of SQLCOM_ constants.
3324
3391
  */
3325
3392
  compile_time_assert(sizeof(com_status_vars)/sizeof(com_status_vars[0]) - 1 ==
3326
 
                     SQLCOM_END + 7);
 
3393
                     SQLCOM_END + 8);
3327
3394
#endif
3328
3395
 
3329
3396
  load_defaults(conf_file_name, groups, &argc, &argv);
3481
3548
    return 1;
3482
3549
  }
3483
3550
  global_system_variables.lc_time_names= my_default_lc_time_names;
3484
 
  
 
3551
 
3485
3552
  sys_init_connect.value_length= 0;
3486
3553
  if ((sys_init_connect.value= opt_init_connect))
3487
3554
    sys_init_connect.value_length= strlen(opt_init_connect);
3515
3582
  sys_var_slow_log_path.value= my_strdup(s, MYF(0));
3516
3583
  sys_var_slow_log_path.value_length= strlen(s);
3517
3584
 
 
3585
#if defined(ENABLED_DEBUG_SYNC)
 
3586
  /* Initialize the debug sync facility. See debug_sync.cc. */
 
3587
  if (debug_sync_init())
 
3588
    return 1; /* purecov: tested */
 
3589
#endif /* defined(ENABLED_DEBUG_SYNC) */
 
3590
 
3518
3591
  if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1))
3519
3592
    return 1;
3520
3593
  if (my_database_names_init())
3595
3668
  (void) my_rwlock_init(&LOCK_system_variables_hash, NULL);
3596
3669
  (void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
3597
3670
  (void) pthread_mutex_init(&LOCK_prepared_stmt_count, MY_MUTEX_INIT_FAST);
3598
 
  (void) pthread_mutex_init(&LOCK_uuid_generator, MY_MUTEX_INIT_FAST);
3599
 
  (void) pthread_mutex_init(&LOCK_backup, MY_MUTEX_INIT_FAST);
 
3671
  (void) pthread_mutex_init(&LOCK_uuid_short, MY_MUTEX_INIT_FAST);
3600
3672
  (void) pthread_mutex_init(&LOCK_connection_count, MY_MUTEX_INIT_FAST);
3601
3673
#ifdef HAVE_OPENSSL
3602
3674
  (void) pthread_mutex_init(&LOCK_des_key_file,MY_MUTEX_INIT_FAST);
3604
3676
  openssl_stdlocks= (openssl_lock_t*) OPENSSL_malloc(CRYPTO_num_locks() *
3605
3677
                                                     sizeof(openssl_lock_t));
3606
3678
  for (int i= 0; i < CRYPTO_num_locks(); ++i)
3607
 
    (void) my_rwlock_init(&openssl_stdlocks[i].lock, NULL); 
 
3679
    (void) my_rwlock_init(&openssl_stdlocks[i].lock, NULL);
3608
3680
  CRYPTO_set_dynlock_create_callback(openssl_dynlock_create);
3609
3681
  CRYPTO_set_dynlock_destroy_callback(openssl_dynlock_destroy);
3610
3682
  CRYPTO_set_dynlock_lock_callback(openssl_lock);
3634
3706
  DDL_blocker= DDL_blocker_class::get_DDL_blocker_class_instance();
3635
3707
 
3636
3708
  sp_cache_init();
 
3709
#ifdef HAVE_EVENT_SCHEDULER
3637
3710
  Events::init_mutexes();
 
3711
#endif
3638
3712
  /* Parameter for threads created for connections */
3639
3713
  (void) pthread_attr_init(&connection_attrib);
3640
3714
  (void) pthread_attr_setdetachstate(&connection_attrib,
3655
3729
 
3656
3730
#if defined(HAVE_OPENSSL) && !defined(HAVE_YASSL)
3657
3731
static unsigned long openssl_id_function()
3658
 
 
3732
{
3659
3733
  return (unsigned long) pthread_self();
3660
 
 
3734
}
3661
3735
 
3662
3736
 
3663
3737
static openssl_lock_t *openssl_dynlock_create(const char *file, int line)
3664
 
 
3738
{
3665
3739
  openssl_lock_t *lock= new openssl_lock_t;
3666
3740
  my_rwlock_init(&lock->lock, NULL);
3667
3741
  return lock;
3668
3742
}
3669
3743
 
3670
3744
 
3671
 
static void openssl_dynlock_destroy(openssl_lock_t *lock, const char *file, 
 
3745
static void openssl_dynlock_destroy(openssl_lock_t *lock, const char *file,
3672
3746
                                    int line)
3673
3747
{
3674
3748
  rwlock_destroy(&lock->lock);
3688
3762
}
3689
3763
 
3690
3764
 
3691
 
static void openssl_lock(int mode, openssl_lock_t *lock, const char *file, 
 
3765
static void openssl_lock(int mode, openssl_lock_t *lock, const char *file,
3692
3766
                         int line)
3693
3767
{
3694
3768
  int err;
3713
3787
    sql_print_error("Fatal: OpenSSL interface problem (mode=0x%x)", mode);
3714
3788
    abort();
3715
3789
  }
3716
 
  if (err) 
 
3790
  if (err)
3717
3791
  {
3718
3792
    sql_print_error("Fatal: can't %s OpenSSL lock", what);
3719
3793
    abort();
3732
3806
    ssl_acceptor_fd= new_VioSSLAcceptorFd(opt_ssl_key, opt_ssl_cert,
3733
3807
                                          opt_ssl_ca, opt_ssl_capath,
3734
3808
                                          opt_ssl_cipher);
3735
 
    DBUG_PRINT("info",("ssl_acceptor_fd: 0x%lx", (long) ssl_acceptor_fd));
 
3809
    DBUG_PRINT("info",("ssl_acceptor_fd: %p", ssl_acceptor_fd));
3736
3810
    if (!ssl_acceptor_fd)
3737
3811
    {
3738
3812
      sql_print_warning("Failed to setup SSL");
3774
3848
    We need to call each of these following functions to ensure that
3775
3849
    all things are initialized so that unireg_abort() doesn't fail
3776
3850
  */
3777
 
  if (table_cache_init() | table_def_init() | hostname_cache_init())
 
3851
  mdl_init();
 
3852
  if (table_def_init() | hostname_cache_init())
3778
3853
    unireg_abort(1);
3779
3854
 
3780
3855
  query_cache_result_size_limit(query_cache_limit);
3781
3856
  query_cache_set_min_res_unit(query_cache_min_res_unit);
3782
3857
  query_cache_init();
3783
3858
  query_cache_resize(query_cache_size);
3784
 
  randominit(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
 
3859
  my_rnd_init(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
3785
3860
  setup_fpu();
3786
3861
  init_thr_lock();
 
3862
  my_uuid_init((ulong) (my_rnd(&sql_rand))*12345,12345);
3787
3863
#ifdef HAVE_REPLICATION
3788
3864
  init_slave_list();
3789
3865
#endif
3814
3890
    }
3815
3891
  }
3816
3892
 
 
3893
  /* set up the hook before initializing plugins which may use it */
 
3894
  error_handler_hook= my_message_sql;
 
3895
 
3817
3896
  if (xid_cache_init())
3818
3897
  {
3819
3898
    sql_print_error("Out of memory");
3894
3973
    if (opt_binlog_format_id == BINLOG_FORMAT_UNSPEC)
3895
3974
      global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
3896
3975
    else
3897
 
    { 
 
3976
    {
3898
3977
      DBUG_ASSERT(global_system_variables.binlog_format != BINLOG_FORMAT_UNSPEC);
3899
3978
  }
3900
3979
 
3950
4029
    using_update_log=1;
3951
4030
  }
3952
4031
 
 
4032
  /* call ha_init_key_cache() on all key caches to init them */
 
4033
  process_key_caches(&ha_init_key_cache);
 
4034
 
 
4035
  /* Allow storage engine to give real error messages */
 
4036
  if (ha_init_errors())
 
4037
    DBUG_RETURN(1);
 
4038
 
3953
4039
  if (plugin_init(&defaults_argc, defaults_argv,
3954
4040
                  (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
3955
4041
                  (opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
3958
4044
    unireg_abort(1);
3959
4045
  }
3960
4046
 
 
4047
#ifndef EMBEDDED_LIBRARY
 
4048
  if (backup_init())
 
4049
  {
 
4050
    sql_print_error("Failed to initialize online backup.");
 
4051
    unireg_abort(1);
 
4052
  }
 
4053
#endif
 
4054
 
3961
4055
  if (opt_help)
3962
4056
    unireg_abort(0);
3963
4057
 
4050
4144
                       strlen(default_storage_engine_str) };
4051
4145
    plugin_ref plugin;
4052
4146
    handlerton *hton;
4053
 
    
 
4147
 
4054
4148
    if ((plugin= ha_resolve_by_name(0, &name)))
4055
4149
      hton= plugin_data(plugin, handlerton*);
4056
4150
    else
4072
4166
    else
4073
4167
    {
4074
4168
      /*
4075
 
        Need to unlock as global_system_variables.table_plugin 
 
4169
        Need to unlock as global_system_variables.table_plugin
4076
4170
        was acquired during plugin_init()
4077
4171
      */
4078
4172
      plugin_unlock(0, global_system_variables.table_plugin);
4079
4173
      global_system_variables.table_plugin= plugin;
4080
4174
    }
4081
4175
  }
 
4176
#if defined(WITH_MARIA_STORAGE_ENGINE) && defined(USE_MARIA_FOR_TMP_TABLES)
 
4177
  if (!ha_storage_engine_is_enabled(maria_hton) && !opt_bootstrap)
 
4178
  {
 
4179
    sql_print_error("Maria engine is not enabled or did not start. The Maria engine must be enabled to continue as mysqld was configured with --with-maria-tmp-tables");
 
4180
    unireg_abort(1);
 
4181
  }
 
4182
#endif
4082
4183
 
4083
4184
  tc_log= (total_ha_2pc > 1 ? (opt_bin_log  ?
4084
4185
                               (TC_LOG *) &mysql_bin_log :
4113
4214
  pthread_attr_setstacksize(&connection_attrib, NW_THD_STACKSIZE);
4114
4215
#endif
4115
4216
 
4116
 
  if (opt_myisam_log)
4117
 
    (void) mi_log(1);
4118
 
 
4119
 
  /* call ha_init_key_cache() on all key caches to init them */
4120
 
  process_key_caches(&ha_init_key_cache);
 
4217
  if (opt_myisam_logical_log)
 
4218
    (void) mi_log(MI_LOG_ACTION_OPEN, MI_LOG_LOGICAL, NULL, NULL);
4121
4219
 
4122
4220
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY)
4123
4221
  if (locked_in_memory && !getuid())
4228
4326
      handler_count--;
4229
4327
    }
4230
4328
  }
4231
 
#endif 
 
4329
#endif
4232
4330
 
4233
4331
  while (handler_count > 0)
4234
4332
    pthread_cond_wait(&COND_handler_count,&LOCK_thread_count);
4241
4339
  pthread_mutex_lock(&LOCK_thread_count);
4242
4340
  handler_count--;
4243
4341
  pthread_cond_signal(&COND_handler_count);
4244
 
  pthread_mutex_unlock(&LOCK_thread_count);  
 
4342
  pthread_mutex_unlock(&LOCK_thread_count);
4245
4343
  my_thread_end();
4246
4344
}
4247
4345
#else
4311
4409
    Peculiar things with ia64 platforms - it seems we only have half the
4312
4410
    stack size in reality, so we have to double it here
4313
4411
  */
4314
 
  pthread_attr_setstacksize(&connection_attrib,thread_stack*2);
 
4412
  pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size*2);
4315
4413
#else
4316
 
  pthread_attr_setstacksize(&connection_attrib,thread_stack);
 
4414
  pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size);
4317
4415
#endif
4318
4416
#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
4319
4417
  {
4324
4422
    stack_size/= 2;
4325
4423
#endif
4326
4424
    /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */
4327
 
    if (stack_size && stack_size < thread_stack)
 
4425
    if (stack_size && stack_size < my_thread_stack_size)
4328
4426
    {
4329
4427
      if (global_system_variables.log_warnings)
4330
4428
        sql_print_warning("Asked for %lu thread stack, but got %ld",
4331
 
                          thread_stack, (long) stack_size);
 
4429
                          my_thread_stack_size, (long) stack_size);
4332
4430
#if defined(__ia64__) || defined(__ia64)
4333
 
      thread_stack= stack_size*2;
 
4431
      my_thread_stack_size= stack_size*2;
4334
4432
#else
4335
 
      thread_stack= stack_size;
 
4433
      my_thread_stack_size= stack_size;
4336
4434
#endif
4337
4435
    }
4338
4436
  }
4409
4507
    init signals & alarm
4410
4508
    After this we can't quit by a simple unireg_abort
4411
4509
  */
4412
 
  error_handler_hook= my_message_sql;
4413
4510
  start_signal_handler();                               // Creates pidfile
4414
4511
 
4415
4512
  if (mysql_rm_tmp_tables() || acl_init(opt_noacl) ||
4501
4598
#endif /* __NT__ */
4502
4599
 
4503
4600
  /* (void) pthread_attr_destroy(&connection_attrib); */
4504
 
  
 
4601
 
4505
4602
  DBUG_PRINT("quit",("Exiting main thread"));
4506
4603
 
4507
4604
#ifndef __WIN__
4798
4895
 
4799
4896
     When we enter this function, LOCK_thread_count is hold!
4800
4897
*/
4801
 
   
 
4898
 
4802
4899
void handle_connection_in_main_thread(THD *thd)
4803
4900
{
4804
4901
  safe_mutex_assert_owner(&LOCK_thread_count);
4835
4932
                              handle_one_connection,
4836
4933
                              (void*) thd)))
4837
4934
    {
4838
 
      /* purify: begin inspected */
 
4935
      /* purecov: begin inspected */
4839
4936
      DBUG_PRINT("error",
4840
4937
                 ("Can't create thread to handle request (error %d)",
4841
4938
                  error));
5124
5221
    if (!(thd= new THD))
5125
5222
    {
5126
5223
      (void) shutdown(new_sock, SHUT_RDWR);
5127
 
      VOID(closesocket(new_sock));
 
5224
      (void) closesocket(new_sock);
5128
5225
      continue;
5129
5226
    }
5130
5227
    if (!(vio_tmp=vio_new(new_sock,
5440
5537
              NullS);
5441
5538
      sql_perror(buff);
5442
5539
    }
5443
 
    if (handle_client_file_map) 
 
5540
    if (handle_client_file_map)
5444
5541
      CloseHandle(handle_client_file_map);
5445
5542
    if (handle_client_map)
5446
5543
      UnmapViewOfFile(handle_client_map);
5488
5585
 
5489
5586
enum options_mysqld
5490
5587
{
5491
 
  OPT_ISAM_LOG=256,            OPT_SKIP_NEW, 
5492
 
  OPT_SKIP_GRANT,              OPT_SKIP_LOCK, 
 
5588
  OPT_ISAM_LOG=256,            OPT_SKIP_NEW,
 
5589
  OPT_SKIP_GRANT,              OPT_SKIP_LOCK,
5493
5590
  OPT_ENABLE_LOCK,             OPT_USE_LOCKING,
5494
5591
  OPT_SOCKET,                  OPT_UPDATE_LOG,
5495
5592
  OPT_BIN_LOG,                 OPT_SKIP_RESOLVE,
5513
5610
#ifndef DBUG_OFF
5514
5611
  OPT_BINLOG_SHOW_XID,
5515
5612
#endif
5516
 
  OPT_BINLOG_ROWS_EVENT_MAX_SIZE, 
 
5613
  OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
5517
5614
  OPT_WANT_CORE,               OPT_CONCURRENT_INSERT,
5518
5615
  OPT_MEMLOCK,                 OPT_MYISAM_RECOVER,
5519
5616
  OPT_REPLICATE_REWRITE_DB,    OPT_SERVER_ID,
5520
 
  OPT_SKIP_SLAVE_START,        OPT_SAFE_SHOW_DB, 
 
5617
  OPT_SKIP_SLAVE_START,        OPT_SAFE_SHOW_DB,
5521
5618
  OPT_SAFEMALLOC_MEM_LIMIT,    OPT_REPLICATE_DO_TABLE,
5522
5619
  OPT_REPLICATE_IGNORE_TABLE,  OPT_REPLICATE_WILD_DO_TABLE,
5523
5620
  OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
5524
5621
  OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
5525
5622
  OPT_ABORT_SLAVE_EVENT_COUNT,
5526
5623
  OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
5527
 
  OPT_ENGINE_CONDITION_PUSHDOWN, OPT_NDB_CONNECTSTRING, 
 
5624
  OPT_ENGINE_CONDITION_PUSHDOWN, OPT_NDB_CONNECTSTRING,
5528
5625
  OPT_NDB_USE_EXACT_COUNT, OPT_NDB_USE_TRANSACTIONS,
5529
5626
  OPT_NDB_FORCE_SEND, OPT_NDB_AUTOINCREMENT_PREFETCH_SZ,
5530
5627
  OPT_NDB_SHM, OPT_NDB_OPTIMIZED_NODE_SELECTION, OPT_NDB_CACHE_CHECK_TIME,
5572
5669
  OPT_MAX_SEEKS_FOR_KEY, OPT_MAX_TMP_TABLES, OPT_MAX_USER_CONNECTIONS,
5573
5670
  OPT_MAX_LENGTH_FOR_SORT_DATA,
5574
5671
  OPT_MAX_WRITE_LOCK_COUNT, OPT_BULK_INSERT_BUFFER_SIZE,
5575
 
  OPT_MAX_ERROR_COUNT, OPT_MULTI_RANGE_COUNT, OPT_MYISAM_DATA_POINTER_SIZE,
 
5672
  OPT_MAX_ERROR_COUNT, OPT_MYISAM_DATA_POINTER_SIZE,
 
5673
 
5576
5674
  OPT_MYISAM_BLOCK_SIZE, OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
5577
5675
  OPT_MYISAM_MAX_SORT_FILE_SIZE, OPT_MYISAM_SORT_BUFFER_SIZE,
5578
 
  OPT_MYISAM_USE_MMAP,
 
5676
  OPT_MYISAM_USE_MMAP, OPT_MYISAM_REPAIR_THREADS,
5579
5677
  OPT_MYISAM_STATS_METHOD,
 
5678
 
 
5679
  OPT_PAGECACHE_BUFFER_SIZE,
 
5680
  OPT_PAGECACHE_DIVISION_LIMIT, OPT_PAGECACHE_AGE_THRESHOLD,
 
5681
 
5580
5682
  OPT_NET_BUFFER_LENGTH, OPT_NET_RETRY_COUNT,
5581
5683
  OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT,
5582
5684
  OPT_OPEN_FILES_LIMIT,
5590
5692
  OPT_SORT_BUFFER, OPT_TABLE_OPEN_CACHE, OPT_TABLE_DEF_CACHE,
5591
5693
  OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE,
5592
5694
  OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
5593
 
  OPT_WAIT_TIMEOUT, OPT_MYISAM_REPAIR_THREADS,
 
5695
  OPT_WAIT_TIMEOUT,
5594
5696
  OPT_ERROR_LOG_FILE,
5595
5697
  OPT_DEFAULT_WEEK_FORMAT,
5596
5698
  OPT_RANGE_ALLOC_BLOCK_SIZE, OPT_ALLOW_SUSPICIOUS_UDFS,
5643
5745
  OPT_SECURE_FILE_PRIV,
5644
5746
  OPT_MIN_EXAMINED_ROW_LIMIT,
5645
5747
  OPT_LOG_SLOW_SLAVE_STATEMENTS,
 
5748
#if defined(ENABLED_DEBUG_SYNC)
 
5749
  OPT_DEBUG_SYNC_TIMEOUT,
 
5750
#endif /* defined(ENABLED_DEBUG_SYNC) */
5646
5751
  OPT_OLD_MODE,
5647
5752
#if HAVE_POOL_OF_THREADS == 1
5648
5753
  OPT_POOL_OF_THREADS,
5649
5754
#endif
 
5755
  OPT_DEBUG_CRC, OPT_DEBUG_ON,
5650
5756
  OPT_SLAVE_EXEC_MODE
5651
5757
};
5652
5758
 
5655
5761
 
5656
5762
struct my_option my_long_options[] =
5657
5763
{
5658
 
  {"help", '?', "Display this help and exit.", 
 
5764
  {"help", '?', "Display this help and exit.",
5659
5765
   (uchar**) &opt_help, (uchar**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
5660
5766
   0, 0},
5661
5767
#ifdef HAVE_REPLICATION
5721
5827
   "The maximum size of a row-based binary log event in bytes. Rows will be "
5722
5828
   "grouped into events smaller than this size if possible. "
5723
5829
   "The value has to be a multiple of 256.",
5724
 
   (uchar**) &opt_binlog_rows_event_max_size, 
5725
 
   (uchar**) &opt_binlog_rows_event_max_size, 0, 
5726
 
   GET_ULONG, REQUIRED_ARG, 
5727
 
   /* def_value */ 1024, /* min_value */  256, /* max_value */ ULONG_MAX, 
5728
 
   /* sub_size */     0, /* block_size */ 256, 
 
5830
   (uchar**) &opt_binlog_rows_event_max_size,
 
5831
   (uchar**) &opt_binlog_rows_event_max_size, 0,
 
5832
   GET_ULONG, REQUIRED_ARG,
 
5833
   /* def_value */ 1024, /* min_value */  256,
 
5834
   /* max_value */ (longlong) ULONG_MAX,
 
5835
   /* sub_size */     0, /* block_size */ 256,
5729
5836
   /* app_type */ 0
5730
5837
  },
5731
5838
#ifndef DISABLE_GRANT_OPTIONS
5772
5879
#ifndef DBUG_OFF
5773
5880
  {"debug", '#', "Debug log.", (uchar**) &default_dbug_option,
5774
5881
   (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 
5882
  {"debug-crc-break", OPT_DEBUG_CRC,
 
5883
   "Call my_debug_put_break_here() if crc matches this number (for debug).",
 
5884
   (uchar**) &opt_my_crc_dbug_check, (uchar**) &opt_my_crc_dbug_check,
 
5885
   0, GET_ULONG, REQUIRED_ARG, 0, 0, ~(ulong) 0L, 0, 0, 0},
5775
5886
#endif
5776
5887
  {"default-character-set", 'C', "Set the default character set (deprecated option, use --character-set-server instead).",
5777
5888
   (uchar**) &default_character_set_name, (uchar**) &default_character_set_name,
5921
6032
   (uchar**) &log_error_file_ptr, (uchar**) &log_error_file_ptr, 0, GET_STR,
5922
6033
   OPT_ARG, 0, 0, 0, 0, 0, 0},
5923
6034
  {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.",
5924
 
   (uchar**) &myisam_log_filename, (uchar**) &myisam_log_filename, 0, GET_STR,
5925
 
   OPT_ARG, 0, 0, 0, 0, 0, 0},
 
6035
   (uchar**) &myisam_logical_log_filename, (uchar**)
 
6036
   &myisam_logical_log_filename, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
5926
6037
  {"log-long-format", '0',
5927
 
   "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.", 
 
6038
   "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.",
5928
6039
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
5929
6040
#ifdef WITH_CSV_STORAGE_ENGINE
5930
6041
  {"log-output", OPT_LOG_OUTPUT,
5967
6078
#ifdef HAVE_MMAP
5968
6079
  {"log-tc-size", OPT_LOG_TC_SIZE, "Size of transaction coordinator log.",
5969
6080
   (uchar**) &opt_tc_log_size, (uchar**) &opt_tc_log_size, 0, GET_ULONG,
5970
 
   REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ULONG_MAX, 0,
 
6081
   REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, (longlong) ULONG_MAX, 0,
5971
6082
   TC_LOG_PAGE_SIZE, 0},
5972
6083
#endif
5973
6084
  {"log-update", OPT_UPDATE_LOG,
6390
6501
   "Decision to use in heuristic recover process. Possible values are COMMIT or ROLLBACK.",
6391
6502
   (uchar**) &opt_tc_heuristic_recover, (uchar**) &opt_tc_heuristic_recover,
6392
6503
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
6504
#if defined(ENABLED_DEBUG_SYNC)
 
6505
  {"debug-sync-timeout", OPT_DEBUG_SYNC_TIMEOUT,
 
6506
   "Enable the debug sync facility "
 
6507
   "and optionally specify a default wait timeout in seconds. "
 
6508
   "A zero value keeps the facility disabled.",
 
6509
   (uchar**) &opt_debug_sync_timeout, 0,
 
6510
   0, GET_UINT, OPT_ARG, 0, 0, UINT_MAX, 0, 0, 0},
 
6511
#endif /* defined(ENABLED_DEBUG_SYNC) */
6393
6512
  {"temp-pool", OPT_TEMP_POOL,
6394
6513
   "Using this option will cause most temporary files created to use a small set of names, rather than a unique name for each new file.",
6395
6514
   (uchar**) &use_temp_pool, (uchar**) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1,
6396
6515
   0, 0, 0, 0, 0},
6397
6516
  {"timed_mutexes", OPT_TIMED_MUTEXES,
6398
6517
   "Specify whether to time mutexes (only InnoDB mutexes are currently supported)",
6399
 
   (uchar**) &timed_mutexes, (uchar**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, 
 
6518
   (uchar**) &timed_mutexes, (uchar**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0,
6400
6519
    0, 0, 0, 0, 0},
6401
6520
  {"tmpdir", 't',
6402
6521
   "Path for temporary files. Several paths may be specified, separated by a "
6424
6543
  {"warnings", 'W', "Deprecated; use --log-warnings instead.",
6425
6544
   (uchar**) &global_system_variables.log_warnings,
6426
6545
   (uchar**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG,
6427
 
   1, 0, ULONG_MAX, 0, 0, 0},
 
6546
   1, 0, (longlong) ULONG_MAX, 0, 0, 0},
6428
6547
  { "back_log", OPT_BACK_LOG,
6429
6548
    "The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.",
6430
6549
    (uchar**) &back_log, (uchar**) &back_log, 0, GET_ULONG,
6432
6551
  {"binlog_cache_size", OPT_BINLOG_CACHE_SIZE,
6433
6552
   "The size of the cache to hold the SQL statements for the binary log during a transaction. If you often use big, multi-statement transactions you can increase this to get more performance.",
6434
6553
   (uchar**) &binlog_cache_size, (uchar**) &binlog_cache_size, 0, GET_ULONG,
6435
 
   REQUIRED_ARG, 32*1024L, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
 
6554
   REQUIRED_ARG, 32*1024L, IO_SIZE, (longlong) ULONG_MAX, 0, IO_SIZE, 0},
6436
6555
  {"bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
6437
6556
   "Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread!",
6438
6557
   (uchar**) &global_system_variables.bulk_insert_buff_size,
6439
6558
   (uchar**) &max_system_variables.bulk_insert_buff_size,
6440
 
   0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
 
6559
   0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, (longlong) ULONG_MAX, 0, 1, 0},
6441
6560
  {"connect_timeout", OPT_CONNECT_TIMEOUT,
6442
6561
   "The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake'.",
6443
6562
    (uchar**) &connect_timeout, (uchar**) &connect_timeout,
6460
6579
  {"delayed_insert_limit", OPT_DELAYED_INSERT_LIMIT,
6461
6580
   "After inserting delayed_insert_limit rows, the INSERT DELAYED handler will check if there are any SELECT statements pending. If so, it allows these to execute before continuing.",
6462
6581
    (uchar**) &delayed_insert_limit, (uchar**) &delayed_insert_limit, 0, GET_ULONG,
6463
 
    REQUIRED_ARG, DELAYED_LIMIT, 1, ULONG_MAX, 0, 1, 0},
 
6582
    REQUIRED_ARG, DELAYED_LIMIT, 1, (longlong) ULONG_MAX, 0, 1, 0},
6464
6583
  {"delayed_insert_timeout", OPT_DELAYED_INSERT_TIMEOUT,
6465
6584
   "How long a INSERT DELAYED thread should wait for INSERT statements before terminating.",
6466
6585
   (uchar**) &delayed_insert_timeout, (uchar**) &delayed_insert_timeout, 0,
6468
6587
  { "delayed_queue_size", OPT_DELAYED_QUEUE_SIZE,
6469
6588
    "What size queue (in rows) should be allocated for handling INSERT DELAYED. If the queue becomes full, any client that does INSERT DELAYED will wait until there is room in the queue again.",
6470
6589
    (uchar**) &delayed_queue_size, (uchar**) &delayed_queue_size, 0, GET_ULONG,
6471
 
    REQUIRED_ARG, DELAYED_QUEUE_SIZE, 1, ULONG_MAX, 0, 1, 0},
 
6590
    REQUIRED_ARG, DELAYED_QUEUE_SIZE, 1, (longlong) ULONG_MAX, 0, 1, 0},
6472
6591
  {"div_precision_increment", OPT_DIV_PRECINCREMENT,
6473
6592
   "Precision of the result of '/' operator will be increased on that value.",
6474
6593
   (uchar**) &global_system_variables.div_precincrement,
6508
6627
    "The maximum length of the result of function  group_concat.",
6509
6628
    (uchar**) &global_system_variables.group_concat_max_len,
6510
6629
    (uchar**) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
6511
 
    REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0},
 
6630
    REQUIRED_ARG, 1024, 4, (longlong) ULONG_MAX, 0, 1, 0},
6512
6631
  {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
6513
6632
   "The number of seconds the server waits for activity on an interactive connection before closing it.",
6514
6633
   (uchar**) &global_system_variables.net_interactive_timeout,
6518
6637
   "The size of the buffer that is used for full joins.",
6519
6638
   (uchar**) &global_system_variables.join_buff_size,
6520
6639
   (uchar**) &max_system_variables.join_buff_size, 0, GET_ULONG,
6521
 
   REQUIRED_ARG, 128*1024L, 128+MALLOC_OVERHEAD, ULONG_MAX,
 
6640
   REQUIRED_ARG, 128*1024L, 128+MALLOC_OVERHEAD, (longlong) ULONG_MAX,
6522
6641
   MALLOC_OVERHEAD, 128, 0},
6523
6642
   {"join_cache_level", OPT_JOIN_CACHE_LEVEL,
6524
6643
   "Controls what join operations can be executed with join buffers. Odd numbers are used for plain join buffers while even numbers are used for linked buffers",
6525
6644
   (uchar**) &global_system_variables.join_cache_level,
6526
6645
   (uchar**) &max_system_variables.join_cache_level,
6527
6646
   0, GET_ULONG, REQUIRED_ARG, 1, 0, 8, 0, 1, 0},
6528
 
 {"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE,
 
6647
  {"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE,
6529
6648
   "Don't overwrite stale .MYD and .MYI even if no directory is specified.",
6530
6649
   (uchar**) &global_system_variables.keep_files_on_create,
6531
6650
   (uchar**) &max_system_variables.keep_files_on_create,
6541
6660
   "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache",
6542
6661
   (uchar**) &dflt_key_cache_var.param_age_threshold,
6543
6662
   (uchar**) 0,
6544
 
   0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 
6545
 
   300, 100, ULONG_MAX, 0, 100, 0},
 
6663
   0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
 
6664
   300, 100, (longlong) ULONG_MAX, 0, 100, 0},
6546
6665
  {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
6547
6666
   "The default size of key cache blocks",
6548
6667
   (uchar**) &dflt_key_cache_var.param_block_size,
6574
6693
   "Max packetlength to send/receive from to server.",
6575
6694
   (uchar**) &global_system_variables.max_allowed_packet,
6576
6695
   (uchar**) &max_system_variables.max_allowed_packet, 0, GET_ULONG,
6577
 
   REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
 
6696
   REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, 0, 1024, 0},
6578
6697
  {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE,
6579
6698
   "Can be used to restrict the total size used to cache a multi-transaction query.",
6580
6699
   (uchar**) &max_binlog_cache_size, (uchar**) &max_binlog_cache_size, 0,
6581
 
   GET_ULONG, REQUIRED_ARG, ULONG_MAX, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
 
6700
   GET_ULONG, REQUIRED_ARG, (longlong) ULONG_MAX, IO_SIZE,
 
6701
   (longlong) ULONG_MAX, 0, IO_SIZE, 0},
6582
6702
  {"max_binlog_size", OPT_MAX_BINLOG_SIZE,
6583
6703
   "Binary log will be rotated automatically when the size exceeds this \
6584
6704
value. Will also apply to relay logs if max_relay_log_size is 0. \
6588
6708
  {"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
6589
6709
   "If there is more than this number of interrupted connections from a host this host will be blocked from further connections.",
6590
6710
   (uchar**) &max_connect_errors, (uchar**) &max_connect_errors, 0, GET_ULONG,
6591
 
    REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
 
6711
    REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, (longlong) ULONG_MAX, 0, 1, 0},
6592
6712
  // Default max_connections of 151 is larger than Apache's default max
6593
6713
  // children, to avoid "too many connections" error in a common setup
6594
6714
  {"max_connections", OPT_MAX_CONNECTIONS,
6615
6735
   "Joins that are probably going to read more than max_join_size records return an error.",
6616
6736
   (uchar**) &global_system_variables.max_join_size,
6617
6737
   (uchar**) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG,
6618
 
   ~0L, 1, ~0L, 0, 1, 0},
 
6738
   HA_POS_ERROR, 1, HA_POS_ERROR, 0, 1, 0},
6619
6739
   {"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA,
6620
6740
    "Max number of bytes in sorted records.",
6621
6741
    (uchar**) &global_system_variables.max_length_for_sort_data,
6633
6753
    "Limit assumed max number of seeks when looking up rows based on a key",
6634
6754
    (uchar**) &global_system_variables.max_seeks_for_key,
6635
6755
    (uchar**) &max_system_variables.max_seeks_for_key, 0, GET_ULONG,
6636
 
    REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0 },
 
6756
    REQUIRED_ARG, (longlong) ULONG_MAX, 1, (longlong) ULONG_MAX, 0, 1, 0 },
6637
6757
  {"max_sort_length", OPT_MAX_SORT_LENGTH,
6638
6758
   "The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored).",
6639
6759
   (uchar**) &global_system_variables.max_sort_length,
6648
6768
   "Maximum number of temporary tables a client can keep open at a time.",
6649
6769
   (uchar**) &global_system_variables.max_tmp_tables,
6650
6770
   (uchar**) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
6651
 
   REQUIRED_ARG, 32, 1, ULONG_MAX, 0, 1, 0},
 
6771
   REQUIRED_ARG, 32, 1, (longlong) ULONG_MAX, 0, 1, 0},
6652
6772
  {"max_user_connections", OPT_MAX_USER_CONNECTIONS,
6653
6773
   "The maximum number of active connections for a single user (0 = no limit).",
6654
6774
   (uchar**) &max_user_connections, (uchar**) &max_user_connections, 0, GET_UINT,
6655
 
   REQUIRED_ARG, 0, 1, UINT_MAX, 0, 1, 0},
 
6775
   REQUIRED_ARG, 0, 0, UINT_MAX, 0, 1, 0},
6656
6776
  {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
6657
6777
   "After this many write locks, allow some read locks to run in between.",
6658
6778
   (uchar**) &max_write_lock_count, (uchar**) &max_write_lock_count, 0, GET_ULONG,
6659
 
   REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0},
 
6779
   REQUIRED_ARG, (longlong) ULONG_MAX, 1, (longlong) ULONG_MAX, 0, 1, 0},
6660
6780
  {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
6661
6781
   "Don't log queries which examine less than min_examined_row_limit rows to file.",
6662
6782
   (uchar**) &global_system_variables.min_examined_row_limit,
6663
6783
   (uchar**) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
6664
 
  REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1L, 0},
 
6784
   REQUIRED_ARG, 0, 0, (longlong) ULONG_MAX, 0, 1L, 0},
6665
6785
  {"myisam_block_size", OPT_MYISAM_BLOCK_SIZE,
6666
6786
   "Block size to be used for MyISAM index pages.",
6667
6787
   (uchar**) &opt_myisam_block_size,
6673
6793
   (uchar**) &myisam_data_pointer_size,
6674
6794
   (uchar**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
6675
6795
   6, 2, 7, 0, 1, 0},
6676
 
  {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
6677
 
   "Deprecated option",
6678
 
   (uchar**) &global_system_variables.myisam_max_extra_sort_file_size,
6679
 
   (uchar**) &max_system_variables.myisam_max_extra_sort_file_size,
6680
 
   0, GET_ULL, REQUIRED_ARG, (ulonglong) MI_MAX_TEMP_LENGTH,
6681
 
   0, (ulonglong) MAX_FILE_SIZE, 0, 1, 0},
6682
6796
  {"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE,
6683
6797
   "Don't use the fast sort index method to created index if the temporary file would get bigger than this.",
6684
6798
   (uchar**) &global_system_variables.myisam_max_sort_file_size,
6689
6803
   "Number of threads to use when repairing MyISAM tables. The value of 1 disables parallel repair.",
6690
6804
   (uchar**) &global_system_variables.myisam_repair_threads,
6691
6805
   (uchar**) &max_system_variables.myisam_repair_threads, 0,
6692
 
   GET_ULONG, REQUIRED_ARG, 1, 1, ULONG_MAX, 0, 1, 0},
 
6806
   GET_ULONG, REQUIRED_ARG, 1, 1, (longlong) ULONG_MAX, 0, 1, 0},
6693
6807
  {"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE,
6694
6808
   "The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.",
6695
6809
   (uchar**) &global_system_variables.myisam_sort_buff_size,
6696
6810
   (uchar**) &max_system_variables.myisam_sort_buff_size, 0,
6697
 
   GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0},
 
6811
   GET_ULONG, REQUIRED_ARG, 8192*1024, 4, (longlong) ULONG_MAX, 0, 1, 0},
6698
6812
  {"myisam_use_mmap", OPT_MYISAM_USE_MMAP,
6699
6813
   "Use memory mapping for reading and writing MyISAM tables",
6700
6814
   (uchar**) &opt_myisam_use_mmap,
6701
 
   (uchar**) &opt_myisam_use_mmap, 0, GET_BOOL, NO_ARG, 0, 
 
6815
   (uchar**) &opt_myisam_use_mmap, 0, GET_BOOL, NO_ARG, 0,
6702
6816
    0, 0, 0, 0, 0},
6703
6817
  {"myisam_stats_method", OPT_MYISAM_STATS_METHOD,
6704
6818
   "Specifies how MyISAM index statistics collection code should threat NULLs. "
6720
6834
   "If a read on a communication port is interrupted, retry this many times before giving up.",
6721
6835
   (uchar**) &global_system_variables.net_retry_count,
6722
6836
   (uchar**) &max_system_variables.net_retry_count,0,
6723
 
   GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ULONG_MAX, 0, 1, 0},
 
6837
   GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, (longlong) ULONG_MAX,
 
6838
   0, 1, 0},
6724
6839
  {"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
6725
6840
   "Number of seconds to wait for a block to be written to a connection  before aborting the write.",
6726
6841
   (uchar**) &global_system_variables.net_write_timeout,
6727
6842
   (uchar**) &max_system_variables.net_write_timeout, 0, GET_ULONG,
6728
6843
   REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
6729
 
  { "old", OPT_OLD_MODE, "Use compatible behavior.", 
 
6844
  {"old", OPT_OLD_MODE, "Use compatible behavior.",
6730
6845
    (uchar**) &global_system_variables.old_mode,
6731
 
    (uchar**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG, 
 
6846
    (uchar**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG,
6732
6847
    0, 0, 0, 0, 0, 0},
6733
6848
  {"open_files_limit", OPT_OPEN_FILES_LIMIT,
6734
6849
   "If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of files.",
6754
6869
   (uchar**) &opt_plugin_load, (uchar**) &opt_plugin_load, 0,
6755
6870
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
6756
6871
  {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
6757
 
    "The size of the buffer that is allocated when preloading indexes",
6758
 
    (uchar**) &global_system_variables.preload_buff_size,
6759
 
    (uchar**) &max_system_variables.preload_buff_size, 0, GET_ULONG,
6760
 
    REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0},
 
6872
   "The size of the buffer that is allocated when preloading indexes",
 
6873
   (uchar**) &global_system_variables.preload_buff_size,
 
6874
   (uchar**) &max_system_variables.preload_buff_size, 0, GET_ULONG,
 
6875
   REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0},
6761
6876
  {"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE,
6762
6877
   "Allocation block size for query parsing and execution",
6763
6878
   (uchar**) &global_system_variables.query_alloc_block_size,
6764
6879
   (uchar**) &max_system_variables.query_alloc_block_size, 0, GET_ULONG,
6765
 
   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
 
6880
   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, (longlong) ULONG_MAX, 0, 1024,
 
6881
   0},
6766
6882
#ifdef HAVE_QUERY_CACHE
6767
6883
  {"query_cache_limit", OPT_QUERY_CACHE_LIMIT,
6768
6884
   "Don't cache results that are bigger than this.",
6769
6885
   (uchar**) &query_cache_limit, (uchar**) &query_cache_limit, 0, GET_ULONG,
6770
 
   REQUIRED_ARG, 1024*1024L, 0, ULONG_MAX, 0, 1, 0},
 
6886
   REQUIRED_ARG, 1024*1024L, 0, (longlong) ULONG_MAX, 0, 1, 0},
6771
6887
  {"query_cache_min_res_unit", OPT_QUERY_CACHE_MIN_RES_UNIT,
6772
6888
   "minimal size of unit in wich space for results is allocated (last unit will be trimed after writing all result data.",
6773
6889
   (uchar**) &query_cache_min_res_unit, (uchar**) &query_cache_min_res_unit,
6774
6890
   0, GET_ULONG, REQUIRED_ARG, QUERY_CACHE_MIN_RESULT_DATA_SIZE,
6775
 
   0, ULONG_MAX, 0, 1, 0},
 
6891
   0, (longlong) ULONG_MAX, 0, 1, 0},
6776
6892
#endif /*HAVE_QUERY_CACHE*/
6777
6893
  {"query_cache_size", OPT_QUERY_CACHE_SIZE,
6778
6894
   "The memory allocated to store results from old queries.",
6795
6911
   (uchar**) &global_system_variables.query_prealloc_size,
6796
6912
   (uchar**) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
6797
6913
   REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE,
6798
 
   ULONG_MAX, 0, 1024, 0},
 
6914
   (longlong) ULONG_MAX, 0, 1024, 0},
6799
6915
  {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
6800
6916
   "Allocation block size for storing ranges during optimization",
6801
6917
   (uchar**) &global_system_variables.range_alloc_block_size,
6802
6918
   (uchar**) &max_system_variables.range_alloc_block_size, 0, GET_ULONG,
6803
 
   REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE, ULONG_MAX,
6804
 
   0, 1024, 0},
 
6919
   REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE,
 
6920
   (longlong) ULONG_MAX, 0, 1024, 0},
6805
6921
  {"read_buffer_size", OPT_RECORD_BUFFER,
6806
6922
   "Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.",
6807
6923
   (uchar**) &global_system_variables.read_buff_size,
6863
6979
   "Each thread that needs to do a sort allocates a buffer of this size.",
6864
6980
   (uchar**) &global_system_variables.sortbuff_size,
6865
6981
   (uchar**) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
6866
 
   MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ULONG_MAX,
 
6982
   MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, (longlong) ULONG_MAX,
6867
6983
   MALLOC_OVERHEAD, 1, 0},
6868
6984
  {"sync-binlog", OPT_SYNC_BINLOG,
6869
6985
   "Synchronously flush binary log to disk after every #th event. "
6870
6986
   "Use 0 (default) to disable synchronous flushing.",
6871
6987
   (uchar**) &sync_binlog_period, (uchar**) &sync_binlog_period, 0, GET_ULONG,
6872
 
   REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0},
 
6988
   REQUIRED_ARG, 0, 0, (longlong) ULONG_MAX, 0, 1, 0},
6873
6989
  {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.",
6874
6990
   (uchar**) &opt_sync_frm, (uchar**) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
6875
6991
   0, 0, 0, 0},
6880
6996
  {"table_definition_cache", OPT_TABLE_DEF_CACHE,
6881
6997
   "The number of cached table definitions.",
6882
6998
   (uchar**) &table_def_size, (uchar**) &table_def_size,
6883
 
   0, GET_ULONG, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
 
6999
   0, GET_ULONG, REQUIRED_ARG, TABLE_DEF_CACHE_DEFAULT, TABLE_DEF_CACHE_MIN,
 
7000
   512*1024L, 0, 1, 0},
6884
7001
  {"table_open_cache", OPT_TABLE_OPEN_CACHE,
6885
7002
   "The number of cached open tables.",
6886
7003
   (uchar**) &table_cache_size, (uchar**) &table_cache_size, 0, GET_ULONG,
6905
7022
   REQUIRED_ARG, 20, 1, 16384, 0, 1, 0},
6906
7023
#endif
6907
7024
  {"thread_stack", OPT_THREAD_STACK,
6908
 
   "The stack size for each thread.", (uchar**) &thread_stack,
6909
 
   (uchar**) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK,
6910
 
   1024L*128L, ULONG_MAX, 0, 1024, 0},
 
7025
   "The stack size for each thread.", (uchar**) &my_thread_stack_size,
 
7026
   (uchar**) &my_thread_stack_size, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK,
 
7027
   1024L*128L, (longlong) ULONG_MAX, 0, 1024, 0},
6911
7028
  { "time_format", OPT_TIME_FORMAT,
6912
7029
    "The TIME format (for future).",
6913
7030
    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME],
6920
7037
   (uchar**) &max_system_variables.tmp_table_size, 0, GET_ULL,
6921
7038
   REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0},
6922
7039
  {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE,
6923
 
   "Allocation block size for various transaction-related structures",
 
7040
   "Allocation block size for transactions to be stored in binary log",
6924
7041
   (uchar**) &global_system_variables.trans_alloc_block_size,
6925
7042
   (uchar**) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG,
6926
 
   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
 
7043
   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, (longlong) ULONG_MAX, 0, 1024,
 
7044
   0},
6927
7045
  {"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE,
6928
 
   "Persistent buffer for various transaction-related structures",
 
7046
   "Persistent buffer for transactions to be stored in binary log",
6929
7047
   (uchar**) &global_system_variables.trans_prealloc_size,
6930
7048
   (uchar**) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
6931
 
   REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
 
7049
   REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, (longlong) ULONG_MAX, 0,
 
7050
   1024, 0},
6932
7051
  {"thread_handling", OPT_THREAD_HANDLING,
6933
7052
   "Define threads usage for handling queries:  "
6934
7053
   "one-thread-per-connection or no-threads", 0, 0,
6947
7066
  {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
6948
7067
};
6949
7068
 
6950
 
static int show_question(THD *thd, SHOW_VAR *var, char *buff)
6951
 
{
6952
 
  var->type= SHOW_LONGLONG;
6953
 
  var->value= (char *)&thd->query_id;
6954
 
  return 0;
6955
 
}
6956
 
 
6957
7069
static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff)
6958
7070
{
6959
7071
  var->type= SHOW_MY_BOOL;
7244
7356
}
7245
7357
 
7246
7358
/*
7247
 
   Functions relying on SSL 
 
7359
   Functions relying on SSL
7248
7360
   Note: In the show_ssl_* functions, we need to check if we have a
7249
7361
         valid vio-object since this isn't always true, specifically
7250
7362
         when session_status or global_status is requested from
7392
7504
  {"Open_tables",              (char*) &show_open_tables,       SHOW_FUNC},
7393
7505
  {"Opened_files",             (char*) &my_file_total_opened, SHOW_LONG_NOFLUSH},
7394
7506
  {"Opened_tables",            (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
 
7507
  {"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
7395
7508
  {"Prepared_stmt_count",      (char*) &show_prepared_stmt_count, SHOW_FUNC},
7396
7509
#ifdef HAVE_QUERY_CACHE
7397
7510
  {"Qcache_free_blocks",       (char*) &query_cache.free_memory_blocks, SHOW_LONG_NOFLUSH},
7403
7516
  {"Qcache_queries_in_cache",  (char*) &query_cache.queries_in_cache, SHOW_LONG_NOFLUSH},
7404
7517
  {"Qcache_total_blocks",      (char*) &query_cache.total_blocks, SHOW_LONG_NOFLUSH},
7405
7518
#endif /*HAVE_QUERY_CACHE*/
7406
 
  {"Questions",                (char*) &show_question,            SHOW_FUNC},
 
7519
  {"Questions",                (char*) offsetof(STATUS_VAR, questions), SHOW_LONG_STATUS},
7407
7520
#ifdef HAVE_REPLICATION
7408
7521
  {"Rpl_status",               (char*) &show_rpl_status,          SHOW_FUNC},
7409
7522
#endif
7560
7673
  opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
7561
7674
  opt_secure_auth= 0;
7562
7675
  opt_secure_file_priv= 0;
7563
 
  opt_bootstrap= opt_myisam_log= 0;
 
7676
  opt_bootstrap= opt_myisam_logical_log= 0;
7564
7677
  mqh_used= 0;
7565
7678
  segfaulted= kill_in_progress= 0;
7566
7679
  cleanup_done= 0;
7588
7701
  bzero((uchar*) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
7589
7702
  bzero((char *) &global_status_var, sizeof(global_status_var));
7590
7703
  opt_large_pages= 0;
 
7704
#if defined(ENABLED_DEBUG_SYNC)
 
7705
  opt_debug_sync_timeout= 0;
 
7706
#endif /* defined(ENABLED_DEBUG_SYNC) */
7591
7707
  key_map_full.set_all();
7592
7708
 
7593
7709
  /* Character sets */
7624
7740
  thread_cache.empty();
7625
7741
  key_caches.empty();
7626
7742
  if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str,
7627
 
                                               default_key_cache_base.length)))
 
7743
                                                default_key_cache_base.length)))
7628
7744
    exit(1);
7629
 
  multi_keycache_init(); /* set key_cache_hash.default_value = dflt_key_cache */
 
7745
 
 
7746
  /* set key_cache_hash.default_value = dflt_key_cache */
 
7747
  multi_keycache_init();
7630
7748
 
7631
7749
  /* Set directory paths */
7632
7750
  strmake(language, LANGUAGE, sizeof(language)-1);
7774
7892
                      char *argument)
7775
7893
{
7776
7894
  switch(optid) {
 
7895
#ifndef DBUG_OFF
7777
7896
  case '#':
7778
 
#ifndef DBUG_OFF
7779
 
    DBUG_SET_INITIAL(argument ? argument : default_dbug_option);
7780
 
#endif
 
7897
    if (!argument)
 
7898
      argument= (char*) default_dbug_option;
 
7899
    if (argument[0] == '0' && !argument[1])
 
7900
    {
 
7901
      DEBUGGER_OFF;
 
7902
      break;
 
7903
    }
 
7904
    DEBUGGER_ON;
 
7905
    if (argument[0] == '1' && !argument[1])
 
7906
      break;
 
7907
    DBUG_SET_INITIAL(argument);
7781
7908
    opt_endinfo=1;                              /* unireg: memory allocation */
7782
7909
    break;
 
7910
#endif
7783
7911
  case 'a':
7784
7912
    global_system_variables.sql_mode= fix_sql_mode(MODE_ANSI);
7785
7913
    global_system_variables.tx_isolation= ISO_SERIALIZABLE;
7843
7971
    thd_startup_options|=OPTION_BIG_TABLES;
7844
7972
    break;
7845
7973
  case (int) OPT_ISAM_LOG:
7846
 
    opt_myisam_log=1;
 
7974
    opt_myisam_logical_log=1;
7847
7975
    break;
7848
7976
  case (int) OPT_UPDATE_LOG:
7849
7977
    opt_update_log=1;
7981
8109
  }
7982
8110
#endif
7983
8111
  case OPT_EVENT_SCHEDULER:
 
8112
#ifndef HAVE_EVENT_SCHEDULER
 
8113
    sql_perror("Event scheduler is not supported in embedded build.");
 
8114
#else
7984
8115
    if (Events::set_opt_event_scheduler(argument))
7985
8116
        exit(1);
 
8117
#endif
7986
8118
    break;
7987
8119
  case (int) OPT_SKIP_NEW:
7988
8120
    opt_specialflag|= SPECIAL_NO_NEW_FUNC;
8246
8378
    lower_case_table_names= argument ? atoi(argument) : 1;
8247
8379
    lower_case_table_names_used= 1;
8248
8380
    break;
 
8381
#if defined(ENABLED_DEBUG_SYNC)
 
8382
  case OPT_DEBUG_SYNC_TIMEOUT:
 
8383
    /*
 
8384
      Debug Sync Facility. See debug_sync.cc.
 
8385
      Default timeout for WAIT_FOR action.
 
8386
      Default value is zero (facility disabled).
 
8387
      If option is given without an argument, supply a non-zero value.
 
8388
    */
 
8389
    if (!argument)
 
8390
    {
 
8391
      /* purecov: begin tested */
 
8392
      opt_debug_sync_timeout= DEBUG_SYNC_DEFAULT_WAIT_TIMEOUT;
 
8393
      /* purecov: end */
 
8394
    }
 
8395
    break;
 
8396
#endif /* defined(ENABLED_DEBUG_SYNC) */
8249
8397
  }
8250
8398
  return 0;
8251
8399
}
8281
8429
    }
8282
8430
  }
8283
8431
  }
8284
 
 return option->value;
 
8432
  return option->value;
8285
8433
}
8286
8434
 
8287
8435
 
8372
8520
 
8373
8521
  /* Set global variables based on startup options */
8374
8522
  myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
 
8523
  my_crc_dbug_check= opt_my_crc_dbug_check;
8375
8524
 
8376
8525
  /* long_query_time is in microseconds */
8377
8526
  global_system_variables.long_query_time= max_system_variables.long_query_time=
8533
8682
  ulong res;
8534
8683
 
8535
8684
  const char **ptr;
8536
 
  
 
8685
 
8537
8686
  if ((res= find_bit_type(x, bit_lib)) == ~(ulong) 0)
8538
8687
  {
8539
8688
    ptr= bit_lib->type_names;