diff options
author | unknown <monty@hundin.mysql.fi> | 2002-08-13 02:18:39 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2002-08-13 02:18:39 +0300 |
commit | 51156c5af2a8a3a978085a7c54de0ad55f73775c (patch) | |
tree | 05ad0900ffa45f9028b912889f27021e3e9cb962 /sql | |
parent | 689a43874659ca5714edcd5effd3dcef2e3930cb (diff) | |
download | mariadb-git-51156c5af2a8a3a978085a7c54de0ad55f73775c.tar.gz |
Changed SQL variable delay_key_write to an enum
able delay_key_write as default (as it was in 4.0.2)
Docs/manual.texi:
Updated information about variable DELAY_KEY_WRITE.
mysql-test/r/type_decimal.result:
Updated results
mysql-test/r/variables.result:
Updated results
mysql-test/t/type_decimal.test:
Fixed test to not cause purify error in mathlib during purify.
mysql-test/t/variables.test:
Test new usage of DELAY_KEY_WRITE
sql/ha_innodb.cc:
Merge with 3.23 code
sql/mysql_priv.h:
Changed SQL variable delay_key_write to an enum
sql/mysqld.cc:
Changed SQL variable delay_key_write to an enum.
Enable delay_key_write as default (as it was in 4.0.2)
sql/set_var.cc:
Changed SQL variable delay_key_write to an enum
sql/set_var.h:
Changed SQL variable delay_key_write to an enum
sql/sql_class.h:
Changed SQL variable delay_key_write to an enum
sql/sql_yacc.yy:
Changed SQL variable delay_key_write to an enum
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_innodb.cc | 69 | ||||
-rw-r--r-- | sql/mysql_priv.h | 1 | ||||
-rw-r--r-- | sql/mysqld.cc | 81 | ||||
-rw-r--r-- | sql/set_var.cc | 42 | ||||
-rw-r--r-- | sql/set_var.h | 23 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 1 |
7 files changed, 158 insertions, 61 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 97dc26df184..eaf09325124 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -265,51 +265,60 @@ the prototype for this function! */ void innobase_mysql_print_thd( /*=====================*/ - char* buf, /* in/out: buffer where to print, must be at least - 300 bytes */ - void* input_thd)/* in: pointer to a MySQL THD object */ + char* buf, /* in/out: buffer where to print, must be at least + 400 bytes */ + void* input_thd)/* in: pointer to a MySQL THD object */ { - THD* thd; + THD* thd; + char* old_buf = buf; - thd = (THD*) input_thd; + thd = (THD*) input_thd; - /* We can't use value of sprintf() as this is not portable */ - buf+= my_sprintf(buf, + /* We cannot use the return value of normal sprintf() as this is + not portable to some old non-Posix Unixes, e.g., some old SCO + Unixes */ + + buf += my_sprintf(buf, (buf, "MySQL thread id %lu, query id %lu", thd->thread_id, thd->query_id)); - if (thd->host) - { - *buf++=' '; - buf=strnmov(buf, thd->host, 30); + if (thd->host) { + *buf = ' '; + buf++; + buf = strnmov(buf, thd->host, 30); } - if (thd->ip) - { - *buf++=' '; - buf=strnmov(buf, thd->ip, 20); + if (thd->ip) { + *buf = ' '; + buf++; + buf=strnmov(buf, thd->ip, 20); } - if (thd->user) - { - *buf++=' '; - buf=strnmov(buf, thd->user, 20); + if (thd->user) { + *buf = ' '; + buf++; + buf=strnmov(buf, thd->user, 20); } - if (thd->proc_info) - { - *buf++=' '; - buf=strnmov(buf, thd->proc_info, 50); + if (thd->proc_info) { + *buf = ' '; + buf++; + buf=strnmov(buf, thd->proc_info, 50); } - if (thd->query) - { - *buf++=' '; - buf=strnmov(buf, thd->query, 150); + if (thd->query) { + *buf = '\n'; + buf++; + buf=strnmov(buf, thd->query, 150); } - buf[0]='\n'; - buf[1]=0; - ut_a(strlen(buf) < 400); + buf[0] = '\n'; + buf[1] = '\0'; /* Note that we must put a null character here to end + the printed string */ + + /* We test the printed length did not overrun the buffer length of + 400 bytes */ + + ut_a(strlen(old_buf) < 400); } } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index e5a4f0f271f..7bd69055f5f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -635,6 +635,7 @@ extern ulong specialflag, current_pid; extern uint test_flags,select_errors,ha_open_options; extern uint protocol_version,dropping_tables; +extern uint delay_key_write_options; extern bool opt_endinfo, using_udf_functions, locked_in_memory; extern bool opt_using_transactions, use_temp_pool, mysql_embedded; extern bool using_update_log, opt_large_files; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 863ee5912c8..705f843dec0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -47,6 +47,12 @@ #define SIGNAL_THD #endif +#ifdef PURIFY +#define IF_PURIFY(A,B) (A) +#else +#define IF_PURIFY(A,B) (B) +#endif + /* stack traces are only supported on linux intel */ #if defined(__linux__) && defined(__i386__) && defined(USE_PSTACK) #define HAVE_STACK_TRACE_ON_SEGV @@ -259,6 +265,7 @@ bool opt_log, opt_update_log, opt_bin_log, opt_slow_log; bool opt_disable_networking=0, opt_skip_show_db=0; bool opt_enable_named_pipe= 0; my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol; +uint delay_key_write_options= (uint) DELAY_KEY_WRITE_ON; static bool opt_do_pstack = 0; static ulong opt_specialflag=SPECIAL_ENGLISH; @@ -2816,8 +2823,8 @@ enum options { OPT_FLUSH, OPT_SAFE, OPT_BOOTSTRAP, OPT_SKIP_SHOW_DB, OPT_TABLE_TYPE, OPT_INIT_FILE, - OPT_DELAY_KEY_WRITE, OPT_SLOW_QUERY_LOG, - OPT_USE_DELAY_KEY_WRITE, OPT_CHARSETS_DIR, + OPT_DELAY_KEY_WRITE_ALL, OPT_SLOW_QUERY_LOG, + OPT_DELAY_KEY_WRITE, OPT_CHARSETS_DIR, OPT_BDB_HOME, OPT_BDB_LOG, OPT_BDB_TMP, OPT_BDB_NOSYNC, OPT_BDB_LOCK, OPT_BDB_SKIP, @@ -2994,9 +3001,11 @@ struct my_option my_long_options[] = {"default-table-type", OPT_TABLE_TYPE, "Set the default table type for tables", 0, 0, 0, GET_NO_ARG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE, - "Don't flush key buffers between writes for any MyISAM table", 0, 0, 0, - GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE", + 0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL, + "Don't flush key buffers between writes for any MyISAM table (Depricated option, use --delay-key-write=all instead)", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"enable-locking", OPT_ENABLE_LOCK, "Depricated option, use --external-locking instead", (gptr*) &opt_external_locking, (gptr*) &opt_external_locking, @@ -3260,10 +3269,6 @@ struct my_option my_long_options[] = "Use concurrent insert with MyISAM. Disable with prefix --skip-", (gptr*) &myisam_concurrent_insert, (gptr*) &myisam_concurrent_insert, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"delay-key-write", OPT_USE_DELAY_KEY_WRITE, - "Use delay_key_write option for all tables. Disable with prefix --skip-", - (gptr*) &myisam_delay_key_write, (gptr*) &myisam_delay_key_write, 0, - GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-grant-tables", OPT_SKIP_GRANT, "Start without grant tables. This gives all users FULL ACCESS to all tables!", (gptr*) &opt_noacl, (gptr*) &opt_noacl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, @@ -3335,8 +3340,8 @@ struct my_option my_long_options[] = 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef USE_SYMDIR {"use-symbolic-links", 's', "Enable symbolic link support", - (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG, 0, 0, - 0, 0, 0, 0}, + (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG, + USE_PURIFY(0,1), 0, 0, 0, 0, 0}, #endif {"user", 'u', "Run mysqld daemon as user", (gptr*) &mysqld_user, (gptr*) &mysqld_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -3382,7 +3387,7 @@ struct my_option my_long_options[] = (gptr*) &connect_timeout, (gptr*) &connect_timeout, 0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 }, {"delayed_insert_timeout", OPT_DELAYED_INSERT_TIMEOUT, - "How long a INSERT DELAYED thread should wait for INSERT statements before terminating.", + "Ho wlong a INSERT DELAYED thread should wait for INSERT statements before terminating.", (gptr*) &delayed_insert_timeout, (gptr*) &delayed_insert_timeout, 0, GET_ULONG, REQUIRED_ARG, DELAYED_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, {"delayed_insert_limit", OPT_DELAYED_INSERT_LIMIT, @@ -4119,22 +4124,22 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case (int) OPT_SKIP_NEW: opt_specialflag|= SPECIAL_NO_NEW_FUNC; - myisam_delay_key_write=0; + delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE; myisam_concurrent_insert=0; myisam_recover_options= HA_RECOVER_NONE; my_disable_symlinks=1; my_use_symdir=0; have_symlink=SHOW_OPTION_DISABLED; - ha_open_options&= ~HA_OPEN_ABORT_IF_CRASHED; + ha_open_options&= ~(HA_OPEN_ABORT_IF_CRASHED | HA_OPEN_DELAY_KEY_WRITE); #ifdef HAVE_QUERY_CACHE query_cache_size=0; #endif break; case (int) OPT_SAFE: opt_specialflag|= SPECIAL_SAFE_MODE; - myisam_delay_key_write=0; + delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE; myisam_recover_options= HA_RECOVER_NONE; // To be changed - ha_open_options&= ~HA_OPEN_ABORT_IF_CRASHED; + ha_open_options&= ~(HA_OPEN_ABORT_IF_CRASHED | HA_OPEN_DELAY_KEY_WRITE); break; case (int) OPT_SKIP_PRIOR: opt_specialflag|= SPECIAL_NO_PRIOR; @@ -4239,9 +4244,25 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_SERVER_ID: server_id_supplied = 1; break; + case OPT_DELAY_KEY_WRITE_ALL: + if (argument != disabled_my_option) + argument= (char*) "ALL"; + /* Fall through */ case OPT_DELAY_KEY_WRITE: - ha_open_options|=HA_OPEN_DELAY_KEY_WRITE; - myisam_delay_key_write=1; + if (argument == disabled_my_option) + delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE; + else if (! argument) + delay_key_write_options= (uint) DELAY_KEY_WRITE_ON; + else + { + int type; + if ((type=find_type(argument, &delay_key_write_typelib, 2)) <= 0) + { + fprintf(stderr,"Unknown delay_key_write type: %s\n",argument); + exit(1); + } + delay_key_write_options= (uint) type-1; + } break; case OPT_CHARSETS_DIR: strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir)-1); @@ -4364,19 +4385,23 @@ static void get_options(int argc,char **argv) { int ho_error; - myisam_delay_key_write=1; // Allow use of this -#ifndef HAVE_purify - my_use_symdir=1; // Use internal symbolic links -#else - /* Symlinks gives too many warnings with purify */ - my_disable_symlinks=1; - my_use_symdir=0; - have_symlink=SHOW_OPTION_DISABLED; -#endif - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); +#ifdef HAVE_BROKEN_REALPATH + my_use_symdir=0; + my_disable_symlinks=1; + have_symlink=SHOW_OPTION_NO; +#else + if (!my_use_symdir) + { + my_disable_symlinks=1; + have_symlink=SHOW_OPTION_DISABLED; + } +#endif + /* Set global MyISAM variables from delay_key_write_options */ + fix_delay_key_write((THD*) 0, OPT_GLOBAL); + if (mysqld_chroot) set_root(mysqld_chroot); fix_paths(); diff --git a/sql/set_var.cc b/sql/set_var.cc index 87417354b99..3c71d1d32e3 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -62,6 +62,12 @@ TYPELIB bool_typelib= array_elements(bool_type_names)-1, "", bool_type_names }; +const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NullS }; +TYPELIB delay_key_write_typelib= +{ + array_elements(delay_key_write_type_names)-1, "", delay_key_write_type_names +}; + static bool sys_check_charset(THD *thd, set_var *var); static bool sys_update_charset(THD *thd, set_var *var); static void sys_set_default_charset(THD *thd, enum_var_type type); @@ -97,8 +103,10 @@ sys_var_bool_ptr sys_concurrent_insert("concurrent_insert", &myisam_concurrent_insert); sys_var_long_ptr sys_connect_timeout("connect_timeout", &connect_timeout); -sys_var_bool_ptr sys_delay_key_write("delay_key_write", - &myisam_delay_key_write); +sys_var_enum sys_delay_key_write("delay_key_write", + &delay_key_write_options, + &delay_key_write_typelib, + fix_delay_key_write); sys_var_long_ptr sys_delayed_insert_limit("delayed_insert_limit", &delayed_insert_limit); sys_var_long_ptr sys_delayed_insert_timeout("delayed_insert_timeout", @@ -625,6 +633,23 @@ static void fix_key_buffer_size(THD *thd, enum_var_type type) } +void fix_delay_key_write(THD *thd, enum_var_type type) +{ + switch ((enum_delay_key_write) delay_key_write_options) { + case DELAY_KEY_WRITE_NONE: + myisam_delay_key_write=0; + break; + case DELAY_KEY_WRITE_ON: + myisam_delay_key_write=1; + break; + case DELAY_KEY_WRITE_ALL: + myisam_delay_key_write=1; + ha_open_options|= HA_OPEN_DELAY_KEY_WRITE; + break; + } +} + + bool sys_var_long_ptr::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); @@ -655,6 +680,19 @@ void sys_var_bool_ptr::set_default(THD *thd, enum_var_type type) } +bool sys_var_enum::update(THD *thd, set_var *var) +{ + *value= (uint) var->save_result.ulong_value; + return 0; +} + + +byte *sys_var_enum::value_ptr(THD *thd, enum_var_type type) +{ + return (byte*) enum_names->type_names[*value]; +} + + bool sys_var_thd_ulong::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); diff --git a/sql/set_var.h b/sql/set_var.h index 46463089b03..cbe479b7902 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -28,7 +28,7 @@ class sys_var; class set_var; typedef struct system_variables SV; -extern TYPELIB bool_typelib; +extern TYPELIB bool_typelib, delay_key_write_typelib; enum enum_var_type { @@ -140,6 +140,26 @@ public: }; +class sys_var_enum :public sys_var +{ + uint *value; + TYPELIB *enum_names; +public: + sys_var_enum(const char *name_arg, uint *value_arg, + TYPELIB *typelib, sys_after_update_func func) + :sys_var(name_arg,func), value(value_arg), enum_names(typelib) + {} + bool check(THD *thd, set_var *var) + { + return check_enum(thd, var, enum_names); + } + bool update(THD *thd, set_var *var); + SHOW_TYPE type() { return SHOW_CHAR; } + byte *value_ptr(THD *thd, enum_var_type type); + bool check_update_type(Item_result type) { return 0; } +}; + + class sys_var_thd :public sys_var { public: @@ -415,5 +435,6 @@ void set_var_init(); void set_var_free(); sys_var *find_sys_var(const char *str, uint length=0); bool sql_set_variables(THD *thd, List<set_var_base> *var_list); +void fix_delay_key_write(THD *thd, enum_var_type type); extern sys_var_str sys_charset; diff --git a/sql/sql_class.h b/sql/sql_class.h index 042d4868bf5..102320f8f75 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -31,6 +31,8 @@ enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE }; enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY }; enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_IGNORE }; enum enum_log_type { LOG_CLOSED, LOG_NORMAL, LOG_NEW, LOG_BIN }; +enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON, + DELAY_KEY_WRITE_ALL }; // log info errors #define LOG_INFO_EOF -1 diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 0cde960aa2e..0b8b6337998 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3346,6 +3346,7 @@ set_expr_or_default: expr { $$=$1; } | DEFAULT { $$=0; } | ON { $$=new Item_string("ON",2); } + | ALL { $$=new Item_string("ALL",3); } ; |