2003-07-06 18:09:57 +02:00
|
|
|
/* Copyright (C) 2000-2003 MySQL AB
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
@file
|
|
|
|
|
|
|
|
@brief
|
2002-07-23 17:31:22 +02:00
|
|
|
Handling of MySQL SQL variables
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@details
|
2002-07-23 17:31:22 +02:00
|
|
|
To add a new variable, one has to do the following:
|
|
|
|
|
|
|
|
- Use one of the 'sys_var... classes from set_var.h or write a specific
|
|
|
|
one for the variable type.
|
|
|
|
- Define it in the 'variable definition list' in this file.
|
2004-04-28 12:08:54 +02:00
|
|
|
- If the variable is thread specific, add it to 'system_variables' struct.
|
|
|
|
If not, add it to mysqld.cc and an declaration in 'mysql_priv.h'
|
2002-07-23 17:31:22 +02:00
|
|
|
- If the variable should be changed from the command line, add a definition
|
2005-01-21 17:38:46 +01:00
|
|
|
of it in the my_option structure list in mysqld.cc
|
2004-04-28 12:08:54 +02:00
|
|
|
- Don't forget to initialize new fields in global_system_variables and
|
|
|
|
max_system_variables!
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@todo
|
|
|
|
Add full support for the variable character_set (for 4.1)
|
|
|
|
|
|
|
|
@todo
|
|
|
|
When updating myisam_delay_key_write, we should do a 'flush tables'
|
|
|
|
of all MyISAM tables to ensure that they are reopen with the
|
|
|
|
new attribute.
|
|
|
|
|
|
|
|
@note
|
|
|
|
Be careful with var->save_result: sys_var::check() only updates
|
2004-08-16 17:00:48 +02:00
|
|
|
ulonglong_value; so other members of the union are garbage then; to use
|
|
|
|
them you must first assign a value to them (in specific ::check() for
|
|
|
|
example).
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
2005-05-26 12:09:14 +02:00
|
|
|
#ifdef USE_PRAGMA_IMPLEMENTATION
|
2002-07-23 17:31:22 +02:00
|
|
|
#pragma implementation // gcc: Class implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "mysql_priv.h"
|
2002-12-16 14:33:29 +01:00
|
|
|
#include <mysql.h>
|
2002-07-23 17:31:22 +02:00
|
|
|
#include "slave.h"
|
2007-04-12 08:58:04 +02:00
|
|
|
#include "rpl_mi.h"
|
2002-07-23 17:31:22 +02:00
|
|
|
#include <my_getopt.h>
|
2003-10-16 06:44:18 +02:00
|
|
|
#include <thr_alarm.h>
|
2002-07-23 17:31:22 +02:00
|
|
|
#include <myisam.h>
|
2006-06-19 15:30:55 +02:00
|
|
|
#include <my_dir.h>
|
2005-11-07 16:25:06 +01:00
|
|
|
|
2006-07-04 18:44:35 +02:00
|
|
|
#include "events.h"
|
2006-05-22 20:46:13 +02:00
|
|
|
|
2005-11-07 16:25:06 +01:00
|
|
|
/* WITH_NDBCLUSTER_STORAGE_ENGINE */
|
2007-04-20 14:36:10 +02:00
|
|
|
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
|
2005-11-07 16:25:06 +01:00
|
|
|
extern ulong ndb_cache_check_time;
|
2007-04-17 20:32:17 +02:00
|
|
|
extern char opt_ndb_constrbuf[];
|
2006-01-12 19:51:02 +01:00
|
|
|
extern ulong ndb_extra_logging;
|
2007-04-20 14:36:10 +02:00
|
|
|
#endif
|
|
|
|
|
2006-01-12 19:51:02 +01:00
|
|
|
#ifdef HAVE_NDB_BINLOG
|
|
|
|
extern ulong ndb_report_thresh_binlog_epoch_slip;
|
|
|
|
extern ulong ndb_report_thresh_binlog_mem_usage;
|
|
|
|
#endif
|
2005-11-07 16:25:06 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
extern CHARSET_INFO *character_set_filesystem;
|
2005-11-07 16:25:06 +01:00
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static DYNAMIC_ARRAY fixed_show_vars;
|
2002-07-23 17:31:22 +02:00
|
|
|
static HASH system_variable_hash;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
const char *bool_type_names[]= { "OFF", "ON", NullS };
|
|
|
|
TYPELIB bool_typelib=
|
|
|
|
{
|
2004-10-25 14:51:26 +02:00
|
|
|
array_elements(bool_type_names)-1, "", bool_type_names, NULL
|
2002-07-23 17:31:22 +02:00
|
|
|
};
|
|
|
|
|
2002-08-13 01:18:39 +02:00
|
|
|
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NullS };
|
|
|
|
TYPELIB delay_key_write_typelib=
|
|
|
|
{
|
2004-10-25 14:51:26 +02:00
|
|
|
array_elements(delay_key_write_type_names)-1, "",
|
|
|
|
delay_key_write_type_names, NULL
|
2002-08-13 01:18:39 +02:00
|
|
|
};
|
|
|
|
|
2007-12-12 11:14:59 +01:00
|
|
|
const char *slave_exec_mode_names[]=
|
|
|
|
{ "STRICT", "IDEMPOTENT", NullS };
|
|
|
|
static const unsigned int slave_exec_mode_names_len[]=
|
|
|
|
{ sizeof("STRICT") - 1, sizeof("IDEMPOTENT") - 1, 0 };
|
|
|
|
TYPELIB slave_exec_mode_typelib=
|
|
|
|
{
|
|
|
|
array_elements(slave_exec_mode_names)-1, "",
|
|
|
|
slave_exec_mode_names, (unsigned int *) slave_exec_mode_names_len
|
|
|
|
};
|
|
|
|
|
2004-04-28 12:08:54 +02:00
|
|
|
static int sys_check_ftb_syntax(THD *thd, set_var *var);
|
|
|
|
static bool sys_update_ftb_syntax(THD *thd, set_var * var);
|
|
|
|
static void sys_default_ftb_syntax(THD *thd, enum_var_type type);
|
2003-07-18 11:11:01 +02:00
|
|
|
static bool sys_update_init_connect(THD*, set_var*);
|
|
|
|
static void sys_default_init_connect(THD*, enum_var_type type);
|
|
|
|
static bool sys_update_init_slave(THD*, set_var*);
|
|
|
|
static void sys_default_init_slave(THD*, enum_var_type type);
|
2002-07-23 17:31:22 +02:00
|
|
|
static bool set_option_bit(THD *thd, set_var *var);
|
|
|
|
static bool set_option_autocommit(THD *thd, set_var *var);
|
2004-04-28 12:08:54 +02:00
|
|
|
static int check_log_update(THD *thd, set_var *var);
|
2002-07-23 17:31:22 +02:00
|
|
|
static bool set_log_update(THD *thd, set_var *var);
|
2004-04-28 12:08:54 +02:00
|
|
|
static int check_pseudo_thread_id(THD *thd, set_var *var);
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
void fix_binlog_format_after_update(THD *thd, enum_var_type type);
|
2002-07-23 17:31:22 +02:00
|
|
|
static void fix_low_priority_updates(THD *thd, enum_var_type type);
|
2005-11-03 01:38:23 +01:00
|
|
|
static int check_tx_isolation(THD *thd, set_var *var);
|
2002-07-23 17:31:22 +02:00
|
|
|
static void fix_tx_isolation(THD *thd, enum_var_type type);
|
2005-02-01 20:48:05 +01:00
|
|
|
static int check_completion_type(THD *thd, set_var *var);
|
|
|
|
static void fix_completion_type(THD *thd, enum_var_type type);
|
2002-07-23 17:31:22 +02:00
|
|
|
static void fix_net_read_timeout(THD *thd, enum_var_type type);
|
|
|
|
static void fix_net_write_timeout(THD *thd, enum_var_type type);
|
2002-08-08 19:49:06 +02:00
|
|
|
static void fix_net_retry_count(THD *thd, enum_var_type type);
|
2002-07-23 17:31:22 +02:00
|
|
|
static void fix_max_join_size(THD *thd, enum_var_type type);
|
|
|
|
static void fix_query_cache_size(THD *thd, enum_var_type type);
|
2003-03-02 20:39:03 +01:00
|
|
|
static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type);
|
2003-05-13 18:34:51 +02:00
|
|
|
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
|
2003-07-06 17:59:54 +02:00
|
|
|
static void fix_max_binlog_size(THD *thd, enum_var_type type);
|
|
|
|
static void fix_max_relay_log_size(THD *thd, enum_var_type type);
|
2003-10-06 14:11:16 +02:00
|
|
|
static void fix_max_connections(THD *thd, enum_var_type type);
|
2004-04-09 18:50:28 +02:00
|
|
|
static int check_max_delayed_threads(THD *thd, set_var *var);
|
2004-04-28 12:08:54 +02:00
|
|
|
static void fix_thd_mem_root(THD *thd, enum_var_type type);
|
|
|
|
static void fix_trans_mem_root(THD *thd, enum_var_type type);
|
2004-05-19 15:03:32 +02:00
|
|
|
static void fix_server_id(THD *thd, enum_var_type type);
|
2007-12-19 21:31:04 +01:00
|
|
|
static ulonglong fix_unsigned(THD *, ulonglong, const struct my_option *);
|
2007-12-06 01:28:01 +01:00
|
|
|
static bool get_unsigned(THD *thd, set_var *var);
|
2007-11-30 06:32:04 +01:00
|
|
|
static void throw_bounds_warning(THD *thd, const char *name, ulonglong num);
|
2003-11-20 21:06:25 +01:00
|
|
|
static KEY_CACHE *create_key_cache(const char *name, uint length);
|
2003-06-04 17:28:51 +02:00
|
|
|
void fix_sql_mode_var(THD *thd, enum_var_type type);
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
static uchar *get_error_count(THD *thd);
|
|
|
|
static uchar *get_warning_count(THD *thd);
|
|
|
|
static uchar *get_tmpdir(THD *thd);
|
2006-06-19 15:30:55 +02:00
|
|
|
static int sys_check_log_path(THD *thd, set_var *var);
|
|
|
|
static bool sys_update_general_log_path(THD *thd, set_var * var);
|
|
|
|
static void sys_default_general_log_path(THD *thd, enum_var_type type);
|
|
|
|
static bool sys_update_slow_log_path(THD *thd, set_var * var);
|
|
|
|
static void sys_default_slow_log_path(THD *thd, enum_var_type type);
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Variable definition list
|
|
|
|
|
|
|
|
These are variables that can be set from the command line, in
|
2006-03-04 09:20:56 +01:00
|
|
|
alphabetic order.
|
|
|
|
|
|
|
|
The variables are linked into the list. A variable is added to
|
|
|
|
it in the constructor (see sys_var class for details).
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_chain vars = { NULL, NULL };
|
2005-11-06 01:36:40 +01:00
|
|
|
|
2008-03-07 13:59:36 +01:00
|
|
|
static sys_var_thd_ulong
|
|
|
|
sys_auto_increment_increment(&vars, "auto_increment_increment",
|
|
|
|
&SV::auto_increment_increment, NULL, NULL,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
|
|
|
static sys_var_thd_ulong
|
|
|
|
sys_auto_increment_offset(&vars, "auto_increment_offset",
|
|
|
|
&SV::auto_increment_offset, NULL, NULL,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2004-09-15 21:10:31 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_bool_ptr sys_automatic_sp_privileges(&vars, "automatic_sp_privileges",
|
2004-12-23 11:46:24 +01:00
|
|
|
&sp_automatic_privileges);
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_const_str sys_basedir(&vars, "basedir", mysql_home);
|
|
|
|
static sys_var_long_ptr sys_binlog_cache_size(&vars, "binlog_cache_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&binlog_cache_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_binlog_format sys_binlog_format(&vars, "binlog_format",
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
&SV::binlog_format);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::bulk_insert_buff_size);
|
2008-03-07 13:59:36 +01:00
|
|
|
static sys_var_character_set_sv
|
|
|
|
sys_character_set_server(&vars, "character_set_server",
|
|
|
|
&SV::collation_server, &default_charset_info, 0,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var_const_str sys_charset_system(&vars, "character_set_system",
|
2005-09-07 12:38:09 +02:00
|
|
|
(char *)my_charset_utf8_general_ci.name);
|
2008-03-07 13:59:36 +01:00
|
|
|
static sys_var_character_set_database
|
|
|
|
sys_character_set_database(&vars, "character_set_database",
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
|
|
|
static sys_var_character_set_client
|
|
|
|
sys_character_set_client(&vars, "character_set_client",
|
|
|
|
&SV::character_set_client,
|
|
|
|
&default_charset_info,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
|
|
|
static sys_var_character_set_sv
|
|
|
|
sys_character_set_connection(&vars, "character_set_connection",
|
|
|
|
&SV::collation_connection,
|
|
|
|
&default_charset_info, 0,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_character_set_sv sys_character_set_results(&vars, "character_set_results",
|
|
|
|
&SV::character_set_results,
|
|
|
|
&default_charset_info, true);
|
|
|
|
static sys_var_character_set_sv sys_character_set_filesystem(&vars, "character_set_filesystem",
|
|
|
|
&SV::character_set_filesystem,
|
|
|
|
&character_set_filesystem);
|
|
|
|
static sys_var_thd_ulong sys_completion_type(&vars, "completion_type",
|
2005-02-01 20:48:05 +01:00
|
|
|
&SV::completion_type,
|
|
|
|
check_completion_type,
|
|
|
|
fix_completion_type);
|
2008-03-07 13:59:36 +01:00
|
|
|
static sys_var_collation_sv
|
|
|
|
sys_collation_connection(&vars, "collation_connection",
|
|
|
|
&SV::collation_connection, &default_charset_info,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
|
|
|
static sys_var_collation_sv
|
|
|
|
sys_collation_database(&vars, "collation_database", &SV::collation_database,
|
|
|
|
&default_charset_info,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
|
|
|
static sys_var_collation_sv
|
|
|
|
sys_collation_server(&vars, "collation_server", &SV::collation_server,
|
|
|
|
&default_charset_info,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_concurrent_insert(&vars, "concurrent_insert",
|
2005-05-13 11:08:08 +02:00
|
|
|
&myisam_concurrent_insert);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
|
2002-07-23 17:31:22 +02:00
|
|
|
&connect_timeout);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_const_str sys_datadir(&vars, "datadir", mysql_real_data_home);
|
2006-02-14 22:36:11 +01:00
|
|
|
#ifndef DBUG_OFF
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_dbug sys_dbug(&vars, "debug");
|
2006-02-14 22:36:11 +01:00
|
|
|
#endif
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_enum sys_delay_key_write(&vars, "delay_key_write",
|
2002-08-13 01:18:39 +02:00
|
|
|
&delay_key_write_options,
|
|
|
|
&delay_key_write_typelib,
|
|
|
|
fix_delay_key_write);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_delayed_insert_limit(&vars, "delayed_insert_limit",
|
2002-07-23 17:31:22 +02:00
|
|
|
&delayed_insert_limit);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_delayed_insert_timeout(&vars, "delayed_insert_timeout",
|
2002-07-23 17:31:22 +02:00
|
|
|
&delayed_insert_timeout);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_delayed_queue_size(&vars, "delayed_queue_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&delayed_queue_size);
|
2006-05-22 20:46:13 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_event_scheduler sys_event_scheduler(&vars, "event_scheduler");
|
|
|
|
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
|
2003-03-11 10:49:06 +01:00
|
|
|
&expire_logs_days);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush);
|
|
|
|
static sys_var_long_ptr sys_flush_time(&vars, "flush_time", &flush_time);
|
|
|
|
static sys_var_str sys_ft_boolean_syntax(&vars, "ft_boolean_syntax",
|
2004-04-28 12:08:54 +02:00
|
|
|
sys_check_ftb_syntax,
|
|
|
|
sys_update_ftb_syntax,
|
|
|
|
sys_default_ftb_syntax,
|
|
|
|
ft_boolean_syntax);
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var_str sys_init_connect(&vars, "init_connect", 0,
|
2004-04-28 12:08:54 +02:00
|
|
|
sys_update_init_connect,
|
|
|
|
sys_default_init_connect,0);
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var_str sys_init_slave(&vars, "init_slave", 0,
|
2004-04-28 12:08:54 +02:00
|
|
|
sys_update_init_slave,
|
|
|
|
sys_default_init_slave,0);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_interactive_timeout(&vars, "interactive_timeout",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::net_interactive_timeout);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_join_buffer_size(&vars, "join_buffer_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::join_buff_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_key_buffer_size sys_key_buffer_size(&vars, "key_buffer_size");
|
|
|
|
static sys_var_key_cache_long sys_key_cache_block_size(&vars, "key_cache_block_size",
|
2003-11-20 21:06:25 +01:00
|
|
|
offsetof(KEY_CACHE,
|
|
|
|
param_block_size));
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_key_cache_long sys_key_cache_division_limit(&vars, "key_cache_division_limit",
|
2003-11-20 21:06:25 +01:00
|
|
|
offsetof(KEY_CACHE,
|
|
|
|
param_division_limit));
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_key_cache_long sys_key_cache_age_threshold(&vars, "key_cache_age_threshold",
|
2003-11-20 21:06:25 +01:00
|
|
|
offsetof(KEY_CACHE,
|
|
|
|
param_age_threshold));
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
|
2002-07-23 17:31:22 +02:00
|
|
|
&opt_local_infile);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_trust_routine_creators
|
|
|
|
sys_trust_routine_creators(&vars, "log_bin_trust_routine_creators",
|
2005-11-10 17:50:51 +01:00
|
|
|
&trust_function_creators);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_bool_ptr
|
|
|
|
sys_trust_function_creators(&vars, "log_bin_trust_function_creators",
|
2005-11-10 17:50:51 +01:00
|
|
|
&trust_function_creators);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_bool_ptr
|
|
|
|
sys_log_queries_not_using_indexes(&vars, "log_queries_not_using_indexes",
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
&opt_log_queries_not_using_indexes);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_log_warnings(&vars, "log_warnings", &SV::log_warnings);
|
2007-07-30 10:33:50 +02:00
|
|
|
static sys_var_microseconds sys_var_long_query_time(&vars, "long_query_time",
|
|
|
|
&SV::long_query_time);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::low_priority_updates,
|
|
|
|
fix_low_priority_updates);
|
|
|
|
#ifndef TO_BE_DELETED /* Alias for the low_priority_updates */
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bool sys_sql_low_priority_updates(&vars, "sql_low_priority_updates",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::low_priority_updates,
|
|
|
|
fix_low_priority_updates);
|
|
|
|
#endif
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_max_allowed_packet(&vars, "max_allowed_packet",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::max_allowed_packet);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&max_binlog_cache_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_max_binlog_size(&vars, "max_binlog_size",
|
2003-07-06 17:59:54 +02:00
|
|
|
&max_binlog_size,
|
|
|
|
fix_max_binlog_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_max_connections(&vars, "max_connections",
|
2003-10-06 14:11:16 +02:00
|
|
|
&max_connections,
|
|
|
|
fix_max_connections);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_max_connect_errors(&vars, "max_connect_errors",
|
2002-07-23 17:31:22 +02:00
|
|
|
&max_connect_errors);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_max_insert_delayed_threads(&vars, "max_insert_delayed_threads",
|
2004-04-09 18:50:28 +02:00
|
|
|
&SV::max_insert_delayed_threads,
|
|
|
|
check_max_delayed_threads,
|
|
|
|
fix_max_connections);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_max_delayed_threads(&vars, "max_delayed_threads",
|
2004-04-28 12:08:54 +02:00
|
|
|
&SV::max_insert_delayed_threads,
|
2004-04-09 18:50:28 +02:00
|
|
|
check_max_delayed_threads,
|
|
|
|
fix_max_connections);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_max_error_count(&vars, "max_error_count",
|
2002-10-02 12:33:08 +02:00
|
|
|
&SV::max_error_count);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulonglong sys_max_heap_table_size(&vars, "max_heap_table_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::max_heap_table_size);
|
2008-03-07 13:59:36 +01:00
|
|
|
static sys_var_thd_ulong sys_pseudo_thread_id(&vars, "pseudo_thread_id",
|
|
|
|
&SV::pseudo_thread_id,
|
|
|
|
check_pseudo_thread_id, 0,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ha_rows sys_max_join_size(&vars, "max_join_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::max_join_size,
|
|
|
|
fix_max_join_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_max_seeks_for_key(&vars, "max_seeks_for_key",
|
2003-06-27 02:04:54 +02:00
|
|
|
&SV::max_seeks_for_key);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
|
2004-04-28 12:08:54 +02:00
|
|
|
&SV::max_length_for_sort_data);
|
2002-07-23 17:31:22 +02:00
|
|
|
#ifndef TO_BE_DELETED /* Alias for max_join_size */
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ha_rows sys_sql_max_join_size(&vars, "sql_max_join_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::max_join_size,
|
|
|
|
fix_max_join_size);
|
|
|
|
#endif
|
2006-04-07 21:37:06 +02:00
|
|
|
static sys_var_long_ptr_global
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_max_prepared_stmt_count(&vars, "max_prepared_stmt_count",
|
2006-04-07 21:37:06 +02:00
|
|
|
&max_prepared_stmt_count,
|
|
|
|
&LOCK_prepared_stmt_count);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_max_relay_log_size(&vars, "max_relay_log_size",
|
2003-07-06 17:59:54 +02:00
|
|
|
&max_relay_log_size,
|
|
|
|
fix_max_relay_log_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_max_sort_length(&vars, "max_sort_length",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::max_sort_length);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_max_sp_recursion_depth(&vars, "max_sp_recursion_depth",
|
2005-11-23 00:11:19 +01:00
|
|
|
&SV::max_sp_recursion_depth);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_max_user_conn sys_max_user_connections(&vars, "max_user_connections");
|
|
|
|
static sys_var_thd_ulong sys_max_tmp_tables(&vars, "max_tmp_tables",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::max_tmp_tables);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_max_write_lock_count(&vars, "max_write_lock_count",
|
2002-07-23 17:31:22 +02:00
|
|
|
&max_write_lock_count);
|
2007-07-30 10:33:50 +02:00
|
|
|
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
|
|
|
|
&SV::min_examined_row_limit);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_multi_range_count(&vars, "multi_range_count",
|
2004-12-23 21:45:10 +01:00
|
|
|
&SV::multi_range_count);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size",
|
2004-05-01 15:41:59 +02:00
|
|
|
&myisam_data_pointer_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulonglong sys_myisam_max_sort_file_size(&vars, "myisam_max_sort_file_size", &SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1);
|
|
|
|
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
|
|
|
|
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
|
2007-04-16 18:16:17 +02:00
|
|
|
static sys_var_bool_ptr sys_myisam_use_mmap(&vars, "myisam_use_mmap",
|
2005-12-01 13:34:48 +01:00
|
|
|
&opt_myisam_use_mmap);
|
2005-09-21 00:18:29 +02:00
|
|
|
|
2007-04-16 18:16:17 +02:00
|
|
|
static sys_var_thd_enum sys_myisam_stats_method(&vars, "myisam_stats_method",
|
2005-09-21 00:18:29 +02:00
|
|
|
&SV::myisam_stats_method,
|
|
|
|
&myisam_stats_method_typelib,
|
|
|
|
NULL);
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_net_buffer_length(&vars, "net_buffer_length",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::net_buffer_length);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_net_read_timeout(&vars, "net_read_timeout",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::net_read_timeout,
|
2004-04-28 12:08:54 +02:00
|
|
|
0, fix_net_read_timeout);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_net_write_timeout(&vars, "net_write_timeout",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::net_write_timeout,
|
2004-04-28 12:08:54 +02:00
|
|
|
0, fix_net_write_timeout);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_net_retry_count(&vars, "net_retry_count",
|
2002-08-08 19:49:06 +02:00
|
|
|
&SV::net_retry_count,
|
2004-04-28 12:08:54 +02:00
|
|
|
0, fix_net_retry_count);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bool sys_new_mode(&vars, "new", &SV::new_mode);
|
2007-04-16 18:16:17 +02:00
|
|
|
static sys_var_bool_ptr_readonly sys_old_mode(&vars, "old",
|
2007-03-26 18:15:30 +02:00
|
|
|
&global_system_variables.old_mode);
|
2007-04-16 18:16:17 +02:00
|
|
|
/* these two cannot be static */
|
|
|
|
sys_var_thd_bool sys_old_alter_table(&vars, "old_alter_table",
|
|
|
|
&SV::old_alter_table);
|
|
|
|
sys_var_thd_bool sys_old_passwords(&vars, "old_passwords", &SV::old_passwords);
|
|
|
|
static sys_var_thd_ulong sys_optimizer_prune_level(&vars, "optimizer_prune_level",
|
2004-05-20 16:47:43 +02:00
|
|
|
&SV::optimizer_prune_level);
|
2007-04-16 18:16:17 +02:00
|
|
|
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
|
2004-05-20 16:47:43 +02:00
|
|
|
&SV::optimizer_search_depth);
|
2007-04-16 18:16:17 +02:00
|
|
|
static sys_var_thd_ulong sys_preload_buff_size(&vars, "preload_buffer_size",
|
2003-06-12 13:29:02 +02:00
|
|
|
&SV::preload_buff_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_read_buff_size(&vars, "read_buffer_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::read_buff_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_opt_readonly sys_readonly(&vars, "read_only", &opt_readonly);
|
|
|
|
static sys_var_thd_ulong sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::read_rnd_buff_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment",
|
2005-05-05 17:06:49 +02:00
|
|
|
&SV::div_precincrement);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
|
2002-07-23 17:31:22 +02:00
|
|
|
&rpl_recovery_rank);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_query_cache_size(&vars, "query_cache_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&query_cache_size,
|
|
|
|
fix_query_cache_size);
|
2003-10-11 21:00:24 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
|
2003-10-11 21:00:24 +02:00
|
|
|
&SV::range_alloc_block_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_query_alloc_block_size(&vars, "query_alloc_block_size",
|
2004-04-28 12:08:54 +02:00
|
|
|
&SV::query_alloc_block_size,
|
|
|
|
0, fix_thd_mem_root);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_query_prealloc_size(&vars, "query_prealloc_size",
|
2004-04-28 12:08:54 +02:00
|
|
|
&SV::query_prealloc_size,
|
|
|
|
0, fix_thd_mem_root);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
|
|
|
|
static sys_var_thd_ulong sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
|
2004-04-28 12:08:54 +02:00
|
|
|
&SV::trans_alloc_block_size,
|
|
|
|
0, fix_trans_mem_root);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
|
2004-04-28 12:08:54 +02:00
|
|
|
&SV::trans_prealloc_size,
|
|
|
|
0, fix_trans_mem_root);
|
2007-12-11 23:30:42 +01:00
|
|
|
sys_var_enum_const sys_thread_handling(&vars, "thread_handling",
|
2007-02-23 12:13:55 +01:00
|
|
|
&SV::thread_handling,
|
|
|
|
&thread_handling_typelib,
|
|
|
|
NULL);
|
2003-10-11 21:00:24 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
#ifdef HAVE_QUERY_CACHE
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_query_cache_limit(&vars, "query_cache_limit",
|
2002-07-23 17:31:22 +02:00
|
|
|
&query_cache.query_cache_limit);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit",
|
2003-03-02 20:39:03 +01:00
|
|
|
&query_cache_min_res_unit,
|
|
|
|
fix_query_cache_min_res_unit);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_enum sys_query_cache_type(&vars, "query_cache_type",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::query_cache_type,
|
|
|
|
&query_cache_type_typelib);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bool
|
|
|
|
sys_query_cache_wlock_invalidate(&vars, "query_cache_wlock_invalidate",
|
2004-04-28 12:08:54 +02:00
|
|
|
&SV::query_cache_wlock_invalidate);
|
2002-07-23 17:31:22 +02:00
|
|
|
#endif /* HAVE_QUERY_CACHE */
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth);
|
2007-04-16 10:37:50 +02:00
|
|
|
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
|
2007-02-14 14:44:34 +01:00
|
|
|
&opt_secure_file_priv);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
|
|
|
|
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
|
2002-08-08 02:12:02 +02:00
|
|
|
&opt_slave_compressed_protocol);
|
2007-12-12 11:14:59 +01:00
|
|
|
static sys_var_set_slave_mode slave_exec_mode(&vars,
|
|
|
|
"slave_exec_mode",
|
|
|
|
&slave_exec_mode_options,
|
|
|
|
&slave_exec_mode_typelib,
|
|
|
|
0);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_slow_launch_time(&vars, "slow_launch_time",
|
2002-07-23 17:31:22 +02:00
|
|
|
&slow_launch_time);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_sort_buffer(&vars, "sort_buffer_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::sortbuff_size);
|
2008-03-07 13:59:36 +01:00
|
|
|
/*
|
|
|
|
sql_mode should *not* have binlog_mode=SESSION_VARIABLE_IN_BINLOG:
|
|
|
|
even though it is written to the binlog, the slave ignores the
|
|
|
|
MODE_NO_DIR_IN_CREATE variable, so slave's value differs from
|
|
|
|
master's (see log_event.cc: Query_log_event::do_apply_event()).
|
|
|
|
*/
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_sql_mode sys_sql_mode(&vars, "sql_mode",
|
2008-03-07 13:59:36 +01:00
|
|
|
&SV::sql_mode);
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
#ifdef HAVE_OPENSSL
|
|
|
|
extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher,
|
|
|
|
*opt_ssl_key;
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_const_str_ptr sys_ssl_ca(&vars, "ssl_ca", &opt_ssl_ca);
|
|
|
|
static sys_var_const_str_ptr sys_ssl_capath(&vars, "ssl_capath", &opt_ssl_capath);
|
|
|
|
static sys_var_const_str_ptr sys_ssl_cert(&vars, "ssl_cert", &opt_ssl_cert);
|
|
|
|
static sys_var_const_str_ptr sys_ssl_cipher(&vars, "ssl_cipher", &opt_ssl_cipher);
|
|
|
|
static sys_var_const_str_ptr sys_ssl_key(&vars, "ssl_key", &opt_ssl_key);
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
#else
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_const_str sys_ssl_ca(&vars, "ssl_ca", NULL);
|
|
|
|
static sys_var_const_str sys_ssl_capath(&vars, "ssl_capath", NULL);
|
|
|
|
static sys_var_const_str sys_ssl_cert(&vars, "ssl_cert", NULL);
|
|
|
|
static sys_var_const_str sys_ssl_cipher(&vars, "ssl_cipher", NULL);
|
|
|
|
static sys_var_const_str sys_ssl_key(&vars, "ssl_key", NULL);
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
#endif
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_enum
|
|
|
|
sys_updatable_views_with_limit(&vars, "updatable_views_with_limit",
|
2004-10-07 11:13:42 +02:00
|
|
|
&SV::updatable_views_with_limit,
|
|
|
|
&updatable_views_with_limit_typelib);
|
2004-07-16 00:15:55 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_table_type sys_table_type(&vars, "table_type",
|
|
|
|
&SV::table_plugin);
|
|
|
|
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
|
|
|
|
&SV::table_plugin);
|
|
|
|
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
|
|
|
|
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
|
2006-04-21 06:56:53 +02:00
|
|
|
system_time_zone);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
|
2005-11-23 21:45:02 +01:00
|
|
|
&table_def_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_table_cache_size(&vars, "table_open_cache",
|
2002-07-23 17:31:22 +02:00
|
|
|
&table_cache_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout",
|
2005-07-19 20:21:12 +02:00
|
|
|
&table_lock_wait_timeout);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr sys_thread_cache_size(&vars, "thread_cache_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&thread_cache_size);
|
2007-02-23 12:13:55 +01:00
|
|
|
#if HAVE_POOL_OF_THREADS == 1
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var_long_ptr sys_thread_pool_size(&vars, "thread_pool_size",
|
2007-02-23 12:13:55 +01:00
|
|
|
&thread_pool_size);
|
|
|
|
#endif
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_enum sys_tx_isolation(&vars, "tx_isolation",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::tx_isolation,
|
|
|
|
&tx_isolation_typelib,
|
2005-11-03 01:38:23 +01:00
|
|
|
fix_tx_isolation,
|
|
|
|
check_tx_isolation);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulonglong sys_tmp_table_size(&vars, "tmp_table_size",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::tmp_table_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes",
|
2004-12-24 13:31:21 +01:00
|
|
|
&timed_mutexes);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_const_str sys_version(&vars, "version", server_version);
|
|
|
|
static sys_var_const_str sys_version_comment(&vars, "version_comment",
|
2006-04-21 06:56:53 +02:00
|
|
|
MYSQL_COMPILATION_COMMENT);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
|
2006-04-21 06:56:53 +02:00
|
|
|
MACHINE_TYPE);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
|
2006-04-21 06:56:53 +02:00
|
|
|
SYSTEM_TYPE);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_net_wait_timeout(&vars, "wait_timeout",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::net_wait_timeout);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2005-02-11 22:05:24 +01:00
|
|
|
/* Condition pushdown to storage engine */
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bool
|
|
|
|
sys_engine_condition_pushdown(&vars, "engine_condition_pushdown",
|
2005-02-11 22:05:24 +01:00
|
|
|
&SV::engine_condition_pushdown);
|
|
|
|
|
2007-04-20 14:36:10 +02:00
|
|
|
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
|
2004-12-09 11:47:20 +01:00
|
|
|
/* ndb thread specific variable settings */
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong
|
|
|
|
sys_ndb_autoincrement_prefetch_sz(&vars, "ndb_autoincrement_prefetch_sz",
|
2004-11-17 09:15:53 +01:00
|
|
|
&SV::ndb_autoincrement_prefetch_sz);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bool
|
|
|
|
sys_ndb_force_send(&vars, "ndb_force_send", &SV::ndb_force_send);
|
2006-01-12 19:51:02 +01:00
|
|
|
#ifdef HAVE_NDB_BINLOG
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr
|
|
|
|
sys_ndb_report_thresh_binlog_epoch_slip(&vars, "ndb_report_thresh_binlog_epoch_slip",
|
2006-01-12 19:51:02 +01:00
|
|
|
&ndb_report_thresh_binlog_epoch_slip);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr
|
|
|
|
sys_ndb_report_thresh_binlog_mem_usage(&vars, "ndb_report_thresh_binlog_mem_usage",
|
2006-01-12 19:51:02 +01:00
|
|
|
&ndb_report_thresh_binlog_mem_usage);
|
|
|
|
#endif
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bool
|
|
|
|
sys_ndb_use_exact_count(&vars, "ndb_use_exact_count", &SV::ndb_use_exact_count);
|
|
|
|
static sys_var_thd_bool
|
|
|
|
sys_ndb_use_transactions(&vars, "ndb_use_transactions", &SV::ndb_use_transactions);
|
|
|
|
static sys_var_long_ptr
|
|
|
|
sys_ndb_cache_check_time(&vars, "ndb_cache_check_time", &ndb_cache_check_time);
|
2007-05-10 08:06:09 +02:00
|
|
|
static sys_var_const_str
|
|
|
|
sys_ndb_connectstring(&vars, "ndb_connectstring", opt_ndb_constrbuf);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bool
|
|
|
|
sys_ndb_index_stat_enable(&vars, "ndb_index_stat_enable",
|
2005-09-15 02:33:28 +02:00
|
|
|
&SV::ndb_index_stat_enable);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong
|
|
|
|
sys_ndb_index_stat_cache_entries(&vars, "ndb_index_stat_cache_entries",
|
2005-09-15 02:33:28 +02:00
|
|
|
&SV::ndb_index_stat_cache_entries);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong
|
|
|
|
sys_ndb_index_stat_update_freq(&vars, "ndb_index_stat_update_freq",
|
2005-09-15 02:33:28 +02:00
|
|
|
&SV::ndb_index_stat_update_freq);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_long_ptr
|
|
|
|
sys_ndb_extra_logging(&vars, "ndb_extra_logging", &ndb_extra_logging);
|
|
|
|
static sys_var_thd_bool
|
|
|
|
sys_ndb_use_copying_alter_table(&vars, "ndb_use_copying_alter_table", &SV::ndb_use_copying_alter_table);
|
2007-04-20 14:36:10 +02:00
|
|
|
#endif //WITH_NDBCLUSTER_STORAGE_ENGINE
|
2003-11-03 13:01:59 +01:00
|
|
|
|
|
|
|
/* Time/date/datetime formats */
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
|
2003-11-03 13:01:59 +01:00
|
|
|
&SV::time_format,
|
2004-06-24 17:08:36 +02:00
|
|
|
MYSQL_TIMESTAMP_TIME);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
|
2003-11-03 13:01:59 +01:00
|
|
|
&SV::date_format,
|
2004-06-24 17:08:36 +02:00
|
|
|
MYSQL_TIMESTAMP_DATE);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
|
2003-11-03 13:01:59 +01:00
|
|
|
&SV::datetime_format,
|
2004-06-24 17:08:36 +02:00
|
|
|
MYSQL_TIMESTAMP_DATETIME);
|
2003-11-03 13:01:59 +01:00
|
|
|
|
|
|
|
/* Variables that are bits in THD */
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var_thd_bit sys_autocommit(&vars, "autocommit", 0,
|
2005-09-13 17:16:12 +02:00
|
|
|
set_option_autocommit,
|
|
|
|
OPTION_NOT_AUTOCOMMIT,
|
|
|
|
1);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_big_tables(&vars, "big_tables", 0,
|
2002-07-23 17:31:22 +02:00
|
|
|
set_option_bit,
|
|
|
|
OPTION_BIG_TABLES);
|
|
|
|
#ifndef TO_BE_DELETED /* Alias for big_tables */
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_sql_big_tables(&vars, "sql_big_tables", 0,
|
2002-07-23 17:31:22 +02:00
|
|
|
set_option_bit,
|
|
|
|
OPTION_BIG_TABLES);
|
|
|
|
#endif
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_big_selects(&vars, "sql_big_selects", 0,
|
2002-07-23 17:31:22 +02:00
|
|
|
set_option_bit,
|
2003-03-19 16:25:59 +01:00
|
|
|
OPTION_BIG_SELECTS);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_log_off(&vars, "sql_log_off",
|
2006-06-28 02:10:49 +02:00
|
|
|
check_log_update,
|
2002-07-23 17:31:22 +02:00
|
|
|
set_option_bit,
|
|
|
|
OPTION_LOG_OFF);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_log_update(&vars, "sql_log_update",
|
2004-04-28 12:08:54 +02:00
|
|
|
check_log_update,
|
2002-07-23 17:31:22 +02:00
|
|
|
set_log_update,
|
2006-03-04 09:20:56 +01:00
|
|
|
OPTION_BIN_LOG);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_log_binlog(&vars, "sql_log_bin",
|
2004-04-28 12:08:54 +02:00
|
|
|
check_log_update,
|
2006-03-04 09:20:56 +01:00
|
|
|
set_option_bit,
|
2004-04-28 12:08:54 +02:00
|
|
|
OPTION_BIN_LOG);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_sql_warnings(&vars, "sql_warnings", 0,
|
2002-07-23 17:31:22 +02:00
|
|
|
set_option_bit,
|
|
|
|
OPTION_WARNINGS);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_sql_notes(&vars, "sql_notes", 0,
|
2005-02-21 18:40:28 +01:00
|
|
|
set_option_bit,
|
2005-02-22 12:40:31 +01:00
|
|
|
OPTION_SQL_NOTES);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_auto_is_null(&vars, "sql_auto_is_null", 0,
|
2002-07-23 17:31:22 +02:00
|
|
|
set_option_bit,
|
2008-03-07 13:59:36 +01:00
|
|
|
OPTION_AUTO_IS_NULL, 0,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
|
2002-07-23 17:31:22 +02:00
|
|
|
set_option_bit,
|
|
|
|
OPTION_SAFE_UPDATES);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
|
2002-07-23 17:31:22 +02:00
|
|
|
set_option_bit,
|
|
|
|
OPTION_BUFFER_RESULT);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_quote_show_create(&vars, "sql_quote_show_create", 0,
|
2002-07-23 17:31:22 +02:00
|
|
|
set_option_bit,
|
|
|
|
OPTION_QUOTE_SHOW_CREATE);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
|
2002-08-08 02:12:02 +02:00
|
|
|
set_option_bit,
|
|
|
|
OPTION_NO_FOREIGN_KEY_CHECKS,
|
2008-03-07 13:59:36 +01:00
|
|
|
1, sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_bit sys_unique_checks(&vars, "unique_checks", 0,
|
2002-08-08 02:12:02 +02:00
|
|
|
set_option_bit,
|
|
|
|
OPTION_RELAXED_UNIQUE_CHECKS,
|
2008-03-07 13:59:36 +01:00
|
|
|
1,
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2007-04-25 00:11:55 +02:00
|
|
|
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
|
2007-10-31 21:39:59 +01:00
|
|
|
static sys_var_thd_bit sys_profiling(&vars, "profiling", NULL,
|
|
|
|
set_option_bit,
|
2007-02-22 16:03:08 +01:00
|
|
|
ulonglong(OPTION_PROFILING));
|
2007-10-31 21:39:59 +01:00
|
|
|
static sys_var_thd_ulong sys_profiling_history_size(&vars, "profiling_history_size",
|
2007-02-22 16:03:08 +01:00
|
|
|
&SV::profiling_history_size);
|
|
|
|
#endif
|
2002-08-08 02:12:02 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/* Local state variables */
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ha_rows sys_select_limit(&vars, "sql_select_limit",
|
2002-07-23 17:31:22 +02:00
|
|
|
&SV::select_limit);
|
2008-03-07 13:59:36 +01:00
|
|
|
static sys_var_timestamp sys_timestamp(&vars, "timestamp",
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
|
|
|
static sys_var_last_insert_id
|
|
|
|
sys_last_insert_id(&vars, "last_insert_id",
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
|
|
|
/*
|
|
|
|
identity is an alias for last_insert_id(), so that we are compatible
|
|
|
|
with Sybase
|
|
|
|
*/
|
|
|
|
static sys_var_last_insert_id
|
|
|
|
sys_identity(&vars, "identity", sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2006-07-04 14:40:40 +02:00
|
|
|
|
2008-03-07 13:59:36 +01:00
|
|
|
static sys_var_thd_lc_time_names
|
|
|
|
sys_lc_time_names(&vars, "lc_time_names", sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2006-07-04 14:40:40 +02:00
|
|
|
|
2008-03-07 13:59:36 +01:00
|
|
|
/*
|
|
|
|
insert_id should *not* be marked as written to the binlog (i.e., it
|
|
|
|
should *not* have binlog_status==SESSION_VARIABLE_IN_BINLOG),
|
|
|
|
because we want any statement that refers to insert_id explicitly to
|
|
|
|
be unsafe. (By "explicitly", we mean using @@session.insert_id,
|
|
|
|
whereas insert_id is used "implicitly" when NULL value is inserted
|
|
|
|
into an auto_increment column).
|
|
|
|
|
|
|
|
We want statements referring explicitly to @@session.insert_id to be
|
|
|
|
unsafe, because insert_id is modified internally by the slave sql
|
|
|
|
thread when NULL values are inserted in an AUTO_INCREMENT column.
|
|
|
|
This modification interfers with the value of the
|
|
|
|
@@session.insert_id variable if @@session.insert_id is referred
|
|
|
|
explicitly by an insert statement (as is seen by executing "SET
|
|
|
|
@@session.insert_id=0; CREATE TABLE t (a INT, b INT KEY
|
|
|
|
AUTO_INCREMENT); INSERT INTO t(a) VALUES (@@session.insert_id);" in
|
|
|
|
statement-based logging mode: t will be different on master and
|
|
|
|
slave).
|
|
|
|
*/
|
|
|
|
static sys_var_insert_id sys_insert_id(&vars, "insert_id");
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_readonly sys_error_count(&vars, "error_count",
|
2002-10-02 12:33:08 +02:00
|
|
|
OPT_SESSION,
|
|
|
|
SHOW_LONG,
|
|
|
|
get_error_count);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_readonly sys_warning_count(&vars, "warning_count",
|
2002-10-02 12:33:08 +02:00
|
|
|
OPT_SESSION,
|
|
|
|
SHOW_LONG,
|
|
|
|
get_warning_count);
|
|
|
|
|
2008-03-07 13:59:36 +01:00
|
|
|
static sys_var_rand_seed1 sys_rand_seed1(&vars, "rand_seed1",
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
|
|
|
static sys_var_rand_seed2 sys_rand_seed2(&vars, "rand_seed2",
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_thd_ulong sys_default_week_format(&vars, "default_week_format",
|
2003-02-19 13:05:35 +01:00
|
|
|
&SV::default_week_format);
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var_thd_ulong sys_group_concat_max_len(&vars, "group_concat_max_len",
|
2003-04-02 15:16:19 +02:00
|
|
|
&SV::group_concat_max_len);
|
|
|
|
|
2008-03-07 13:59:36 +01:00
|
|
|
sys_var_thd_time_zone sys_time_zone(&vars, "time_zone",
|
|
|
|
sys_var::SESSION_VARIABLE_IN_BINLOG);
|
2004-04-28 12:08:54 +02:00
|
|
|
|
2007-04-16 10:37:50 +02:00
|
|
|
/* Global read-only variable containing hostname */
|
|
|
|
static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname);
|
2008-03-07 13:39:37 +01:00
|
|
|
|
|
|
|
#ifndef EMBEDDED_LIBRARY
|
2008-03-05 11:25:55 +01:00
|
|
|
static sys_var_const_str_ptr sys_repl_report_host(&vars, "report_host", &report_host);
|
|
|
|
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
|
|
|
|
static sys_var_const_str_ptr sys_repl_report_password(&vars, "report_password", &report_password);
|
|
|
|
|
|
|
|
static uchar *slave_get_report_port(THD *thd)
|
|
|
|
{
|
|
|
|
thd->sys_var_tmp.long_value= report_port;
|
|
|
|
return (uchar*) &thd->sys_var_tmp.long_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
|
|
|
|
|
2008-03-07 13:39:37 +01:00
|
|
|
#endif
|
2004-04-28 12:08:54 +02:00
|
|
|
|
2007-07-11 10:57:49 +02:00
|
|
|
sys_var_thd_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
|
2007-07-11 09:49:54 +02:00
|
|
|
&SV::keep_files_on_create);
|
2004-04-28 12:08:54 +02:00
|
|
|
/* Read only variables */
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
|
|
|
|
static sys_var_have_variable sys_have_crypt(&vars, "have_crypt", &have_crypt);
|
|
|
|
static sys_var_have_plugin sys_have_csv(&vars, "have_csv", C_STRING_WITH_LEN("csv"), MYSQL_STORAGE_ENGINE_PLUGIN);
|
|
|
|
static sys_var_have_variable sys_have_dlopen(&vars, "have_dynamic_loading", &have_dlopen);
|
|
|
|
static sys_var_have_variable sys_have_geometry(&vars, "have_geometry", &have_geometry);
|
|
|
|
static sys_var_have_plugin sys_have_innodb(&vars, "have_innodb", C_STRING_WITH_LEN("innodb"), MYSQL_STORAGE_ENGINE_PLUGIN);
|
|
|
|
static sys_var_have_plugin sys_have_ndbcluster(&vars, "have_ndbcluster", C_STRING_WITH_LEN("ndbcluster"), MYSQL_STORAGE_ENGINE_PLUGIN);
|
2007-04-16 18:16:17 +02:00
|
|
|
static sys_var_have_variable sys_have_openssl(&vars, "have_openssl", &have_ssl);
|
|
|
|
static sys_var_have_variable sys_have_ssl(&vars, "have_ssl", &have_ssl);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_have_plugin sys_have_partition_db(&vars, "have_partitioning", C_STRING_WITH_LEN("partition"), MYSQL_STORAGE_ENGINE_PLUGIN);
|
|
|
|
static sys_var_have_variable sys_have_query_cache(&vars, "have_query_cache",
|
2006-04-27 23:42:55 +02:00
|
|
|
&have_query_cache);
|
2007-10-17 20:05:43 +02:00
|
|
|
static sys_var_have_variable sys_have_community_features(&vars, "have_community_features", &have_community_features);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_have_variable sys_have_rtree_keys(&vars, "have_rtree_keys", &have_rtree_keys);
|
|
|
|
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
|
2005-11-06 01:36:40 +01:00
|
|
|
/* Global read-only variable describing server license */
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
|
2006-06-19 15:30:55 +02:00
|
|
|
/* Global variables which enable|disable logging */
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
|
2006-06-19 15:30:55 +02:00
|
|
|
QUERY_LOG_GENERAL);
|
2007-10-25 12:03:24 +02:00
|
|
|
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
|
|
|
|
static sys_var_log_state sys_var_log(&vars, "log", &opt_log,
|
|
|
|
QUERY_LOG_GENERAL);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
|
2006-06-19 15:30:55 +02:00
|
|
|
QUERY_LOG_SLOW);
|
2007-10-25 12:03:24 +02:00
|
|
|
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
|
|
|
|
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
|
|
|
|
&opt_slow_log, QUERY_LOG_SLOW);
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
|
2006-06-19 15:30:55 +02:00
|
|
|
sys_update_general_log_path,
|
|
|
|
sys_default_general_log_path,
|
|
|
|
opt_logname);
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
|
2006-06-19 15:30:55 +02:00
|
|
|
sys_update_slow_log_path,
|
|
|
|
sys_default_slow_log_path,
|
|
|
|
opt_slow_logname);
|
2007-03-02 17:43:45 +01:00
|
|
|
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
|
2006-06-19 15:30:55 +02:00
|
|
|
&log_output_typelib, 0);
|
|
|
|
|
2006-01-02 15:41:13 +01:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/*
|
2007-03-02 17:43:45 +01:00
|
|
|
Additional variables (not derived from sys_var class, not accessible as
|
|
|
|
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
|
|
|
|
maintenance - SHOW VARIABLES will sort its output.
|
|
|
|
TODO: remove this list completely
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
|
|
|
|
static SHOW_VAR fixed_vars[]= {
|
2002-07-23 17:31:22 +02:00
|
|
|
{"back_log", (char*) &back_log, SHOW_LONG},
|
2004-04-28 12:08:54 +02:00
|
|
|
{"character_sets_dir", mysql_charsets_dir, SHOW_CHAR},
|
2002-07-23 17:31:22 +02:00
|
|
|
{"ft_max_word_len", (char*) &ft_max_word_len, SHOW_LONG},
|
2004-04-28 12:08:54 +02:00
|
|
|
{"ft_min_word_len", (char*) &ft_min_word_len, SHOW_LONG},
|
2003-10-23 15:21:06 +02:00
|
|
|
{"ft_query_expansion_limit",(char*) &ft_query_expansion_limit, SHOW_LONG},
|
2003-01-27 12:12:12 +01:00
|
|
|
{"ft_stopword_file", (char*) &ft_stopword_file, SHOW_CHAR_PTR},
|
2004-04-28 12:08:54 +02:00
|
|
|
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
|
2002-07-23 17:31:22 +02:00
|
|
|
{"language", language, SHOW_CHAR},
|
2004-04-28 12:08:54 +02:00
|
|
|
{"large_files_support", (char*) &opt_large_files, SHOW_BOOL},
|
2004-12-14 20:26:31 +01:00
|
|
|
{"large_page_size", (char*) &opt_large_page_size, SHOW_INT},
|
2005-08-30 20:15:43 +02:00
|
|
|
{"large_pages", (char*) &opt_large_pages, SHOW_MY_BOOL},
|
2002-07-23 17:31:22 +02:00
|
|
|
#ifdef HAVE_MLOCKALL
|
2007-03-02 17:43:45 +01:00
|
|
|
{"locked_in_memory", (char*) &locked_in_memory, SHOW_MY_BOOL},
|
2002-07-23 17:31:22 +02:00
|
|
|
#endif
|
|
|
|
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
|
2004-04-28 12:08:54 +02:00
|
|
|
{"log_error", (char*) log_error_file, SHOW_CHAR},
|
2004-05-19 15:38:12 +02:00
|
|
|
{"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
|
2004-04-28 12:08:54 +02:00
|
|
|
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
|
|
|
|
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
|
2002-07-23 17:31:22 +02:00
|
|
|
#ifdef __NT__
|
2002-08-28 18:22:42 +02:00
|
|
|
{"named_pipe", (char*) &opt_enable_named_pipe, SHOW_MY_BOOL},
|
2004-11-17 09:15:53 +01:00
|
|
|
#endif
|
2002-07-23 17:31:22 +02:00
|
|
|
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
|
|
|
|
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
|
2005-11-06 13:13:06 +01:00
|
|
|
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
|
2007-03-02 17:43:45 +01:00
|
|
|
{"port", (char*) &mysqld_port, SHOW_INT},
|
2004-04-28 12:08:54 +02:00
|
|
|
{"protocol_version", (char*) &protocol_version, SHOW_INT},
|
2002-11-14 20:16:30 +01:00
|
|
|
#ifdef HAVE_SMEM
|
|
|
|
{"shared_memory", (char*) &opt_enable_shared_memory, SHOW_MY_BOOL},
|
|
|
|
{"shared_memory_base_name", (char*) &shared_memory_base_name, SHOW_CHAR_PTR},
|
|
|
|
#endif
|
2002-07-24 18:55:08 +02:00
|
|
|
{"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
|
2002-07-23 17:31:22 +02:00
|
|
|
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
|
|
|
|
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
|
2002-11-05 21:45:42 +01:00
|
|
|
#ifdef HAVE_SYS_UN_H
|
2007-03-02 17:43:45 +01:00
|
|
|
{"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
|
2005-08-28 02:20:10 +02:00
|
|
|
#endif
|
2002-07-23 17:31:22 +02:00
|
|
|
#ifdef HAVE_THR_SETCONCURRENCY
|
|
|
|
{"thread_concurrency", (char*) &concurrency, SHOW_LONG},
|
|
|
|
#endif
|
|
|
|
{"thread_stack", (char*) &thread_stack, SHOW_LONG},
|
|
|
|
};
|
|
|
|
|
2003-10-20 10:24:18 +02:00
|
|
|
|
2003-10-24 16:28:32 +02:00
|
|
|
bool sys_var::check(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
var->save_result.ulonglong_value= var->value->val_int();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-04-28 12:08:54 +02:00
|
|
|
bool sys_var_str::check(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
if (!check_func)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if ((res=(*check_func)(thd, var)) < 0)
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0),
|
|
|
|
name, var->value->str_value.ptr());
|
2004-04-28 12:08:54 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/*
|
|
|
|
Functions to check and update variables
|
|
|
|
*/
|
|
|
|
|
2003-07-18 11:11:01 +02:00
|
|
|
|
2003-12-08 06:13:14 +01:00
|
|
|
/*
|
|
|
|
Update variables 'init_connect, init_slave'.
|
|
|
|
|
|
|
|
In case of 'DEFAULT' value
|
|
|
|
(for example: 'set GLOBAL init_connect=DEFAULT')
|
|
|
|
'var' parameter is NULL pointer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool update_sys_var_str(sys_var_str *var_str, rw_lock_t *var_mutex,
|
|
|
|
set_var *var)
|
2003-07-18 11:11:01 +02:00
|
|
|
{
|
2004-04-28 12:08:54 +02:00
|
|
|
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
|
|
|
|
uint new_length= (var ? var->value->str_value.length() : 0);
|
|
|
|
if (!old_value)
|
|
|
|
old_value= (char*) "";
|
2006-07-07 21:03:19 +02:00
|
|
|
if (!(res= my_strndup(old_value, new_length, MYF(0))))
|
2004-04-28 12:08:54 +02:00
|
|
|
return 1;
|
2003-07-18 11:11:01 +02:00
|
|
|
/*
|
|
|
|
Replace the old value in such a way that the any thread using
|
|
|
|
the value will work.
|
|
|
|
*/
|
2003-12-08 06:13:14 +01:00
|
|
|
rw_wrlock(var_mutex);
|
|
|
|
old_value= var_str->value;
|
|
|
|
var_str->value= res;
|
|
|
|
var_str->value_length= new_length;
|
|
|
|
rw_unlock(var_mutex);
|
2003-07-18 11:11:01 +02:00
|
|
|
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-08 06:13:14 +01:00
|
|
|
static bool sys_update_init_connect(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-18 11:11:01 +02:00
|
|
|
static void sys_default_init_connect(THD* thd, enum_var_type type)
|
|
|
|
{
|
2003-12-08 06:13:14 +01:00
|
|
|
update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
|
2003-07-18 11:11:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool sys_update_init_slave(THD *thd, set_var *var)
|
|
|
|
{
|
2003-12-08 06:13:14 +01:00
|
|
|
return update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, var);
|
2003-07-18 11:11:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void sys_default_init_slave(THD* thd, enum_var_type type)
|
|
|
|
{
|
2003-12-08 06:13:14 +01:00
|
|
|
update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
|
2003-07-18 11:11:01 +02:00
|
|
|
}
|
|
|
|
|
2004-04-28 12:08:54 +02:00
|
|
|
static int sys_check_ftb_syntax(THD *thd, set_var *var)
|
|
|
|
{
|
2005-09-15 21:29:07 +02:00
|
|
|
if (thd->security_ctx->master_access & SUPER_ACL)
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (ft_boolean_check_syntax_string((uchar*)
|
2005-09-15 21:29:07 +02:00
|
|
|
var->value->str_value.c_ptr()) ?
|
|
|
|
-1 : 0);
|
2004-04-28 12:08:54 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool sys_update_ftb_syntax(THD *thd, set_var * var)
|
|
|
|
{
|
|
|
|
strmake(ft_boolean_syntax, var->value->str_value.c_ptr(),
|
|
|
|
sizeof(ft_boolean_syntax)-1);
|
2007-05-08 11:24:07 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_QUERY_CACHE
|
|
|
|
query_cache.flush();
|
|
|
|
#endif /* HAVE_QUERY_CACHE */
|
|
|
|
|
2004-04-28 12:08:54 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sys_default_ftb_syntax(THD *thd, enum_var_type type)
|
|
|
|
{
|
2004-04-07 20:58:33 +02:00
|
|
|
strmake(ft_boolean_syntax, def_ft_boolean_syntax,
|
2004-04-28 12:08:54 +02:00
|
|
|
sizeof(ft_boolean_syntax)-1);
|
|
|
|
}
|
2003-07-18 11:11:01 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
2002-07-23 17:31:22 +02:00
|
|
|
If one sets the LOW_PRIORIY UPDATES flag, we also must change the
|
2007-10-11 20:37:45 +02:00
|
|
|
used lock type.
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void fix_low_priority_updates(THD *thd, enum_var_type type)
|
|
|
|
{
|
2007-06-03 08:40:00 +02:00
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
thr_upgraded_concurrent_insert_lock=
|
|
|
|
(global_system_variables.low_priority_updates ?
|
|
|
|
TL_WRITE_LOW_PRIORITY : TL_WRITE);
|
|
|
|
else
|
2002-07-23 17:31:22 +02:00
|
|
|
thd->update_lock_default= (thd->variables.low_priority_updates ?
|
|
|
|
TL_WRITE_LOW_PRIORITY : TL_WRITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-13 18:34:51 +02:00
|
|
|
static void
|
|
|
|
fix_myisam_max_sort_file_size(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
myisam_max_temp_length=
|
|
|
|
(my_off_t) global_system_variables.myisam_max_sort_file_size;
|
|
|
|
}
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Set the OPTION_BIG_SELECTS flag if max_join_size == HA_POS_ERROR.
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void fix_max_join_size(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type != OPT_GLOBAL)
|
|
|
|
{
|
2002-12-20 13:58:27 +01:00
|
|
|
if (thd->variables.max_join_size == HA_POS_ERROR)
|
2002-07-23 17:31:22 +02:00
|
|
|
thd->options|= OPTION_BIG_SELECTS;
|
|
|
|
else
|
|
|
|
thd->options&= ~OPTION_BIG_SELECTS;
|
|
|
|
}
|
|
|
|
}
|
2003-10-06 14:11:16 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
2005-11-03 01:38:23 +01:00
|
|
|
Can't change the 'next' tx_isolation while we are already in
|
|
|
|
a transaction
|
|
|
|
*/
|
|
|
|
static int check_tx_isolation(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
if (var->type == OPT_DEFAULT && (thd->server_status & SERVER_STATUS_IN_TRANS))
|
|
|
|
{
|
|
|
|
my_error(ER_CANT_CHANGE_TX_ISOLATION, MYF(0));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/*
|
|
|
|
If one doesn't use the SESSION modifier, the isolation level
|
2007-10-11 20:37:45 +02:00
|
|
|
is only active for the next command.
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
static void fix_tx_isolation(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type == OPT_SESSION)
|
|
|
|
thd->session_tx_isolation= ((enum_tx_isolation)
|
|
|
|
thd->variables.tx_isolation);
|
|
|
|
}
|
|
|
|
|
2006-09-29 05:15:58 +02:00
|
|
|
static void fix_completion_type(THD *thd __attribute__((unused)),
|
|
|
|
enum_var_type type __attribute__((unused))) {}
|
2005-02-01 20:48:05 +01:00
|
|
|
|
|
|
|
static int check_completion_type(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
longlong val= var->value->val_int();
|
|
|
|
if (val < 0 || val > 2)
|
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name, llstr(val, buf));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
If we are changing the thread variable, we have to copy it to NET too
|
|
|
|
*/
|
|
|
|
|
2003-01-15 09:11:44 +01:00
|
|
|
#ifdef HAVE_REPLICATION
|
2002-07-23 17:31:22 +02:00
|
|
|
static void fix_net_read_timeout(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type != OPT_GLOBAL)
|
2007-05-24 11:21:27 +02:00
|
|
|
my_net_set_read_timeout(&thd->net, thd->variables.net_read_timeout);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void fix_net_write_timeout(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type != OPT_GLOBAL)
|
2007-05-24 11:21:27 +02:00
|
|
|
my_net_set_write_timeout(&thd->net, thd->variables.net_write_timeout);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
2002-08-08 19:49:06 +02:00
|
|
|
static void fix_net_retry_count(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type != OPT_GLOBAL)
|
|
|
|
thd->net.retry_count=thd->variables.net_retry_count;
|
|
|
|
}
|
2003-01-15 09:11:44 +01:00
|
|
|
#else /* HAVE_REPLICATION */
|
2006-08-17 21:25:40 +02:00
|
|
|
static void fix_net_read_timeout(THD *thd __attribute__((unused)),
|
|
|
|
enum_var_type type __attribute__((unused)))
|
2002-12-16 14:33:29 +01:00
|
|
|
{}
|
2006-08-17 21:25:40 +02:00
|
|
|
static void fix_net_write_timeout(THD *thd __attribute__((unused)),
|
|
|
|
enum_var_type type __attribute__((unused)))
|
2002-12-16 14:33:29 +01:00
|
|
|
{}
|
2006-08-17 21:25:40 +02:00
|
|
|
static void fix_net_retry_count(THD *thd __attribute__((unused)),
|
|
|
|
enum_var_type type __attribute__((unused)))
|
2002-12-16 14:33:29 +01:00
|
|
|
{}
|
2003-01-15 09:11:44 +01:00
|
|
|
#endif /* HAVE_REPLICATION */
|
2002-08-08 19:49:06 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
static void fix_query_cache_size(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_QUERY_CACHE
|
2007-05-23 12:54:15 +02:00
|
|
|
ulong new_cache_size= query_cache.resize(query_cache_size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Note: query_cache_size is a global variable reflecting the
|
|
|
|
requested cache size. See also query_cache_size_arg
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (query_cache_size != new_cache_size)
|
2003-10-08 23:13:15 +02:00
|
|
|
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
|
|
|
ER_WARN_QC_RESIZE, ER(ER_WARN_QC_RESIZE),
|
2007-05-23 12:54:15 +02:00
|
|
|
query_cache_size, new_cache_size);
|
|
|
|
|
|
|
|
query_cache_size= new_cache_size;
|
2002-07-23 17:31:22 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-02 20:39:03 +01:00
|
|
|
#ifdef HAVE_QUERY_CACHE
|
|
|
|
static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
query_cache_min_res_unit=
|
|
|
|
query_cache.set_min_res_unit(query_cache_min_res_unit);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2003-10-06 14:11:16 +02:00
|
|
|
extern void fix_delay_key_write(THD *thd, enum_var_type type)
|
2002-08-13 01:18:39 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-12 11:14:59 +01:00
|
|
|
bool sys_var_set::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
*value= var->save_result.ulong_value;
|
|
|
|
return 0;
|
2008-02-08 17:33:24 +01:00
|
|
|
}
|
2007-12-12 11:14:59 +01:00
|
|
|
|
|
|
|
uchar *sys_var_set::value_ptr(THD *thd, enum_var_type type,
|
|
|
|
LEX_STRING *base)
|
|
|
|
{
|
|
|
|
char buff[256];
|
|
|
|
String tmp(buff, sizeof(buff), &my_charset_latin1);
|
|
|
|
ulong length;
|
|
|
|
ulong val= *value;
|
|
|
|
|
|
|
|
tmp.length(0);
|
|
|
|
for (uint i= 0; val; val>>= 1, i++)
|
|
|
|
{
|
|
|
|
if (val & 1)
|
|
|
|
{
|
|
|
|
tmp.append(enum_names->type_names[i],
|
|
|
|
enum_names->type_lengths[i]);
|
|
|
|
tmp.append(',');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((length= tmp.length()))
|
|
|
|
length--;
|
|
|
|
return (uchar*) thd->strmake(tmp.ptr(), length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sys_var_set_slave_mode::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
slave_exec_mode_options= 0;
|
|
|
|
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sys_var_set_slave_mode::check(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
bool rc= sys_var_set::check(thd, var);
|
|
|
|
if (!rc &&
|
|
|
|
bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_STRICT) == 1 &&
|
|
|
|
bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
|
|
|
|
{
|
|
|
|
rc= true;
|
|
|
|
my_error(ER_SLAVE_AMBIGOUS_EXEC_MODE, MYF(0), "");
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sys_var_set_slave_mode::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
bool rc;
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
rc= sys_var_set::update(thd, var);
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fix_slave_exec_mode(enum_var_type type)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("fix_slave_exec_mode");
|
|
|
|
compile_time_assert(sizeof(slave_exec_mode_options) * CHAR_BIT
|
|
|
|
> SLAVE_EXEC_MODE_LAST_BIT - 1);
|
|
|
|
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
|
|
|
|
bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
|
|
|
|
{
|
|
|
|
sql_print_error("Ambiguous slave modes combination."
|
|
|
|
" STRICT will be used");
|
|
|
|
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
|
|
|
|
}
|
|
|
|
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
|
|
|
|
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
|
|
|
|
}
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
|
|
|
|
bool sys_var_thd_binlog_format::is_readonly() const
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Under certain circumstances, the variable is read-only (unchangeable):
|
|
|
|
*/
|
|
|
|
THD *thd= current_thd;
|
|
|
|
/*
|
|
|
|
If RBR and open temporary tables, their CREATE TABLE may not be in the
|
|
|
|
binlog, so we can't toggle to SBR in this connection.
|
|
|
|
The test below will also prevent SET GLOBAL, well it was not easy to test
|
|
|
|
if global or not here.
|
|
|
|
And this test will also prevent switching from RBR to RBR (a no-op which
|
|
|
|
should not happen too often).
|
2006-05-16 11:16:23 +02:00
|
|
|
|
|
|
|
If we don't have row-based replication compiled in, the variable
|
|
|
|
is always read-only.
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
*/
|
|
|
|
if ((thd->variables.binlog_format == BINLOG_FORMAT_ROW) &&
|
|
|
|
thd->temporary_tables)
|
|
|
|
{
|
|
|
|
my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
/*
|
* Mixed replication mode * :
1) Fix for BUG#19630 "stored function inserting into two auto_increment breaks
statement-based binlog":
a stored function inserting into two such tables may fail to replicate
(inserting wrong data in the slave's copy of the second table) if the slave's
second table had an internal auto_increment counter different from master's.
Because the auto_increment value autogenerated by master for the 2nd table
does not go into binlog, only the first does, so the slave lacks information.
To fix this, if running in mixed binlogging mode, if the stored function or
trigger plans to update two different tables both having auto_increment
columns, we switch to row-based for the whole function.
We don't have a simple solution for statement-based binlogging mode, there
the bug remains and will be documented as a known problem.
Re-enabling rpl_switch_stm_row_mixed.
2) Fix for BUG#20630 "Mixed binlogging mode does not work with stored
functions, triggers, views", which was a documented limitation (in mixed
mode, we didn't detect that a stored function's execution needed row-based
binlogging (due to some UUID() call for example); same for
triggers, same for views (a view created from a SELECT UUID(), and doing
INSERT INTO sometable SELECT theview; would not replicate row-based).
This is implemented by, after parsing a routine's body, remembering in sp_head
that this routine needs row-based binlogging. Then when this routine is used,
the caller is marked to require row-based binlogging too.
Same for views: when we parse a view and detect that its SELECT needs
row-based binary logging, we mark the calling LEX as such.
3) Fix for BUG#20499 "mixed mode with temporary table breaks binlog":
a temporary table containing e.g. UUID has its changes not binlogged,
so any query updating a permanent table with data from the temporary table
will run wrongly on slave. Solution: in mixed mode we don't switch back
from row-based to statement-based when there exists temporary tables.
4) Attempt to test mysqlbinlog on a binlog generated by mysqlbinlog;
impossible due to BUG#11312 and BUG#20329, but test is in place for when
they are fixed.
2006-07-09 17:00:47 +02:00
|
|
|
if in a stored function/trigger, it's too late to change mode
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
*/
|
* Mixed replication mode * :
1) Fix for BUG#19630 "stored function inserting into two auto_increment breaks
statement-based binlog":
a stored function inserting into two such tables may fail to replicate
(inserting wrong data in the slave's copy of the second table) if the slave's
second table had an internal auto_increment counter different from master's.
Because the auto_increment value autogenerated by master for the 2nd table
does not go into binlog, only the first does, so the slave lacks information.
To fix this, if running in mixed binlogging mode, if the stored function or
trigger plans to update two different tables both having auto_increment
columns, we switch to row-based for the whole function.
We don't have a simple solution for statement-based binlogging mode, there
the bug remains and will be documented as a known problem.
Re-enabling rpl_switch_stm_row_mixed.
2) Fix for BUG#20630 "Mixed binlogging mode does not work with stored
functions, triggers, views", which was a documented limitation (in mixed
mode, we didn't detect that a stored function's execution needed row-based
binlogging (due to some UUID() call for example); same for
triggers, same for views (a view created from a SELECT UUID(), and doing
INSERT INTO sometable SELECT theview; would not replicate row-based).
This is implemented by, after parsing a routine's body, remembering in sp_head
that this routine needs row-based binlogging. Then when this routine is used,
the caller is marked to require row-based binlogging too.
Same for views: when we parse a view and detect that its SELECT needs
row-based binary logging, we mark the calling LEX as such.
3) Fix for BUG#20499 "mixed mode with temporary table breaks binlog":
a temporary table containing e.g. UUID has its changes not binlogged,
so any query updating a permanent table with data from the temporary table
will run wrongly on slave. Solution: in mixed mode we don't switch back
from row-based to statement-based when there exists temporary tables.
4) Attempt to test mysqlbinlog on a binlog generated by mysqlbinlog;
impossible due to BUG#11312 and BUG#20329, but test is in place for when
they are fixed.
2006-07-09 17:00:47 +02:00
|
|
|
if (thd->in_sub_stmt)
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
{
|
|
|
|
my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return sys_var_thd_enum::is_readonly();
|
|
|
|
}
|
|
|
|
|
2006-05-17 15:57:45 +02:00
|
|
|
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
void fix_binlog_format_after_update(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
thd->reset_current_stmt_binlog_row_based();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-06 14:11:16 +02:00
|
|
|
static void fix_max_binlog_size(THD *thd, enum_var_type type)
|
2003-07-06 17:59:54 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("fix_max_binlog_size");
|
|
|
|
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
|
|
|
|
max_binlog_size, max_relay_log_size));
|
|
|
|
mysql_bin_log.set_max_size(max_binlog_size);
|
2003-08-19 15:00:12 +02:00
|
|
|
#ifdef HAVE_REPLICATION
|
2003-07-06 17:59:54 +02:00
|
|
|
if (!max_relay_log_size)
|
|
|
|
active_mi->rli.relay_log.set_max_size(max_binlog_size);
|
2003-08-18 23:08:08 +02:00
|
|
|
#endif
|
2003-07-06 17:59:54 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
2003-10-06 14:11:16 +02:00
|
|
|
static void fix_max_relay_log_size(THD *thd, enum_var_type type)
|
2003-07-06 17:59:54 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("fix_max_relay_log_size");
|
|
|
|
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
|
|
|
|
max_binlog_size, max_relay_log_size));
|
2003-08-19 15:00:12 +02:00
|
|
|
#ifdef HAVE_REPLICATION
|
2003-07-06 17:59:54 +02:00
|
|
|
active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
|
|
|
|
max_relay_log_size: max_binlog_size);
|
2003-08-19 15:00:12 +02:00
|
|
|
#endif
|
2003-07-06 17:59:54 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
2002-08-13 01:18:39 +02:00
|
|
|
|
2003-10-16 06:44:18 +02:00
|
|
|
|
2004-04-09 18:50:28 +02:00
|
|
|
static int check_max_delayed_threads(THD *thd, set_var *var)
|
|
|
|
{
|
2004-04-27 14:33:40 +02:00
|
|
|
longlong val= var->value->val_int();
|
2004-04-09 18:50:28 +02:00
|
|
|
if (var->type != OPT_GLOBAL && val != 0 &&
|
2004-04-27 14:33:40 +02:00
|
|
|
val != (longlong) global_system_variables.max_insert_delayed_threads)
|
2004-04-09 18:50:28 +02:00
|
|
|
{
|
|
|
|
char buf[64];
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name, llstr(val, buf));
|
2004-04-09 18:50:28 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-10-16 06:44:18 +02:00
|
|
|
static void fix_max_connections(THD *thd, enum_var_type type)
|
2003-10-06 14:11:16 +02:00
|
|
|
{
|
2004-07-22 21:00:50 +02:00
|
|
|
#ifndef EMBEDDED_LIBRARY
|
2004-04-28 12:08:54 +02:00
|
|
|
resize_thr_alarm(max_connections +
|
|
|
|
global_system_variables.max_insert_delayed_threads + 10);
|
2004-07-22 21:00:50 +02:00
|
|
|
#endif
|
2004-04-28 12:08:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void fix_thd_mem_root(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type != OPT_GLOBAL)
|
2004-11-08 00:13:54 +01:00
|
|
|
reset_root_defaults(thd->mem_root,
|
2004-04-28 12:08:54 +02:00
|
|
|
thd->variables.query_alloc_block_size,
|
|
|
|
thd->variables.query_prealloc_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void fix_trans_mem_root(THD *thd, enum_var_type type)
|
|
|
|
{
|
2005-03-04 12:29:05 +01:00
|
|
|
#ifdef USING_TRANSACTIONS
|
2004-04-28 12:08:54 +02:00
|
|
|
if (type != OPT_GLOBAL)
|
|
|
|
reset_root_defaults(&thd->transaction.mem_root,
|
|
|
|
thd->variables.trans_alloc_block_size,
|
|
|
|
thd->variables.trans_prealloc_size);
|
2005-03-04 12:29:05 +01:00
|
|
|
#endif
|
2003-10-06 14:11:16 +02:00
|
|
|
}
|
|
|
|
|
2004-05-19 23:54:52 +02:00
|
|
|
|
2004-05-19 15:03:32 +02:00
|
|
|
static void fix_server_id(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
server_id_supplied = 1;
|
2007-12-21 04:02:48 +01:00
|
|
|
thd->server_id= server_id;
|
2004-05-19 15:03:32 +02:00
|
|
|
}
|
2004-02-02 21:01:58 +01:00
|
|
|
|
2006-04-07 21:37:06 +02:00
|
|
|
|
2007-11-30 06:32:04 +01:00
|
|
|
static void throw_bounds_warning(THD *thd, const char *name, ulonglong num)
|
|
|
|
{
|
|
|
|
char buf[22];
|
|
|
|
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
|
|
|
ER_TRUNCATED_WRONG_VALUE,
|
|
|
|
ER(ER_TRUNCATED_WRONG_VALUE), name,
|
|
|
|
ullstr(num, buf));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ulonglong fix_unsigned(THD *thd, ulonglong num,
|
|
|
|
const struct my_option *option_limits)
|
|
|
|
{
|
2008-02-18 23:29:39 +01:00
|
|
|
my_bool fixed= FALSE;
|
2007-11-30 06:32:04 +01:00
|
|
|
ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
|
|
|
|
|
|
|
|
if (fixed)
|
|
|
|
throw_bounds_warning(thd, option_limits->name, num);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2007-12-06 01:28:01 +01:00
|
|
|
static bool get_unsigned(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
if (var->value->unsigned_flag)
|
|
|
|
var->save_result.ulonglong_value= (ulonglong) var->value->val_int();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
longlong v= var->value->val_int();
|
|
|
|
var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-30 06:32:04 +01:00
|
|
|
|
2006-04-07 21:37:06 +02:00
|
|
|
sys_var_long_ptr::
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, ulong *value_ptr_arg,
|
2006-04-07 21:37:06 +02:00
|
|
|
sys_after_update_func after_update_arg)
|
2007-03-02 17:43:45 +01:00
|
|
|
:sys_var_long_ptr_global(chain, name_arg, value_ptr_arg,
|
2006-04-07 21:37:06 +02:00
|
|
|
&LOCK_global_system_variables, after_update_arg)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_long_ptr_global::check(THD *thd, set_var *var)
|
2005-02-17 12:04:04 +01:00
|
|
|
{
|
2007-12-06 01:28:01 +01:00
|
|
|
return get_unsigned(thd, var);
|
2005-02-17 12:04:04 +01:00
|
|
|
}
|
2004-05-19 23:54:52 +02:00
|
|
|
|
2006-04-07 21:37:06 +02:00
|
|
|
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2003-10-24 16:28:32 +02:00
|
|
|
ulonglong tmp= var->save_result.ulonglong_value;
|
2006-04-07 21:37:06 +02:00
|
|
|
pthread_mutex_lock(guard);
|
2002-07-23 17:31:22 +02:00
|
|
|
if (option_limits)
|
2007-11-30 06:32:04 +01:00
|
|
|
*value= (ulong) fix_unsigned(thd, tmp, option_limits);
|
2002-07-23 17:31:22 +02:00
|
|
|
else
|
2007-11-30 06:32:04 +01:00
|
|
|
{
|
|
|
|
#if SIZEOF_LONG < SIZEOF_LONG_LONG
|
|
|
|
/* Avoid overflows on 32 bit systems */
|
2007-12-06 01:28:01 +01:00
|
|
|
if (tmp > ULONG_MAX)
|
2007-11-30 06:32:04 +01:00
|
|
|
{
|
2007-12-06 01:28:01 +01:00
|
|
|
tmp= ULONG_MAX;
|
2007-11-30 06:32:04 +01:00
|
|
|
throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
|
|
|
|
}
|
|
|
|
#endif
|
2002-07-23 17:31:22 +02:00
|
|
|
*value= (ulong) tmp;
|
2007-11-30 06:32:04 +01:00
|
|
|
}
|
|
|
|
|
2006-04-07 21:37:06 +02:00
|
|
|
pthread_mutex_unlock(guard);
|
2002-07-23 17:31:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-07 21:37:06 +02:00
|
|
|
void sys_var_long_ptr_global::set_default(THD *thd, enum_var_type type)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2008-02-18 23:29:39 +01:00
|
|
|
my_bool not_used;
|
2006-04-07 21:37:06 +02:00
|
|
|
pthread_mutex_lock(guard);
|
2007-12-19 21:31:04 +01:00
|
|
|
*value= (ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
|
|
|
|
option_limits, ¬_used);
|
2006-04-07 21:37:06 +02:00
|
|
|
pthread_mutex_unlock(guard);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-05 15:38:49 +01:00
|
|
|
bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
|
|
|
|
{
|
2003-10-24 16:28:32 +02:00
|
|
|
ulonglong tmp= var->save_result.ulonglong_value;
|
2003-08-17 13:10:15 +02:00
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2002-12-05 15:38:49 +01:00
|
|
|
if (option_limits)
|
2007-11-30 06:32:04 +01:00
|
|
|
*value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
|
2002-12-05 15:38:49 +01:00
|
|
|
else
|
|
|
|
*value= (ulonglong) tmp;
|
2003-08-17 13:10:15 +02:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
2002-12-05 15:38:49 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_ulonglong_ptr::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
2008-02-18 23:29:39 +01:00
|
|
|
my_bool not_used;
|
2003-08-17 13:10:15 +02:00
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2007-12-19 21:31:04 +01:00
|
|
|
*value= getopt_ull_limit_value((ulonglong) option_limits->def_value,
|
|
|
|
option_limits, ¬_used);
|
2003-08-17 13:10:15 +02:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
2002-12-05 15:38:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
bool sys_var_bool_ptr::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
*value= (my_bool) var->save_result.ulong_value;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_bool_ptr::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
*value= (my_bool) option_limits->def_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-13 01:18:39 +02:00
|
|
|
bool sys_var_enum::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
*value= (uint) var->save_result.ulong_value;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
|
2002-08-13 01:18:39 +02:00
|
|
|
{
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) enum_names->type_names[*value];
|
2002-08-13 01:18:39 +02:00
|
|
|
}
|
|
|
|
|
2007-12-11 23:30:42 +01:00
|
|
|
|
|
|
|
uchar *sys_var_enum_const::value_ptr(THD *thd, enum_var_type type,
|
|
|
|
LEX_STRING *base)
|
|
|
|
{
|
|
|
|
return (uchar*) enum_names->type_names[global_system_variables.*offset];
|
|
|
|
}
|
|
|
|
|
2004-04-28 12:08:54 +02:00
|
|
|
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
|
|
|
|
{
|
2007-12-06 01:28:01 +01:00
|
|
|
return (get_unsigned(thd, var) ||
|
2004-04-28 12:08:54 +02:00
|
|
|
(check_func && (*check_func)(thd, var)));
|
|
|
|
}
|
2002-08-13 01:18:39 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
|
|
|
|
{
|
2003-10-24 16:28:32 +02:00
|
|
|
ulonglong tmp= var->save_result.ulonglong_value;
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
/* Don't use bigger value than given with --maximum-variable-name=.. */
|
|
|
|
if ((ulong) tmp > max_system_variables.*offset)
|
2007-10-04 10:34:00 +02:00
|
|
|
{
|
2007-11-30 06:32:04 +01:00
|
|
|
throw_bounds_warning(thd, name, tmp);
|
2002-07-23 17:31:22 +02:00
|
|
|
tmp= max_system_variables.*offset;
|
2007-10-04 10:34:00 +02:00
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-11-30 06:32:04 +01:00
|
|
|
if (option_limits)
|
|
|
|
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
|
|
|
|
#if SIZEOF_LONG < SIZEOF_LONG_LONG
|
2007-12-06 01:28:01 +01:00
|
|
|
else if (tmp > ULONG_MAX)
|
2007-10-04 10:34:00 +02:00
|
|
|
{
|
2007-12-06 01:28:01 +01:00
|
|
|
tmp= ULONG_MAX;
|
2007-11-30 06:32:04 +01:00
|
|
|
throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
|
2007-10-04 10:34:00 +02:00
|
|
|
}
|
2005-07-31 11:49:55 +02:00
|
|
|
#endif
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
if (var->type == OPT_GLOBAL)
|
2002-08-12 02:33:46 +02:00
|
|
|
global_system_variables.*offset= (ulong) tmp;
|
2002-07-23 17:31:22 +02:00
|
|
|
else
|
|
|
|
thd->variables.*offset= (ulong) tmp;
|
2007-11-30 06:32:04 +01:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
{
|
2008-02-18 23:29:39 +01:00
|
|
|
my_bool not_used;
|
2002-07-23 17:31:22 +02:00
|
|
|
/* We will not come here if option_limits is not set */
|
2007-12-19 21:31:04 +01:00
|
|
|
global_system_variables.*offset=
|
2007-12-21 11:28:34 +01:00
|
|
|
(ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
|
|
|
|
option_limits, ¬_used);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
thd->variables.*offset= global_system_variables.*offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
|
2003-07-06 18:09:57 +02:00
|
|
|
LEX_STRING *base)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &(global_system_variables.*offset);
|
|
|
|
return (uchar*) &(thd->variables.*offset);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-20 13:58:27 +01:00
|
|
|
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
|
|
|
|
{
|
2003-10-24 16:28:32 +02:00
|
|
|
ulonglong tmp= var->save_result.ulonglong_value;
|
2002-12-20 13:58:27 +01:00
|
|
|
|
|
|
|
/* Don't use bigger value than given with --maximum-variable-name=.. */
|
|
|
|
if ((ha_rows) tmp > max_system_variables.*offset)
|
|
|
|
tmp= max_system_variables.*offset;
|
|
|
|
|
|
|
|
if (option_limits)
|
2007-11-30 06:32:04 +01:00
|
|
|
tmp= (ha_rows) fix_unsigned(thd, tmp, option_limits);
|
2002-12-20 13:58:27 +01:00
|
|
|
if (var->type == OPT_GLOBAL)
|
|
|
|
{
|
|
|
|
/* Lock is needed to make things safe on 32 bit systems */
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
global_system_variables.*offset= (ha_rows) tmp;
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
thd->variables.*offset= (ha_rows) tmp;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_thd_ha_rows::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
{
|
2008-02-18 23:29:39 +01:00
|
|
|
my_bool not_used;
|
2002-12-20 13:58:27 +01:00
|
|
|
/* We will not come here if option_limits is not set */
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2007-12-19 21:31:04 +01:00
|
|
|
global_system_variables.*offset=
|
|
|
|
(ha_rows) getopt_ull_limit_value((ha_rows) option_limits->def_value,
|
|
|
|
option_limits, ¬_used);
|
2002-12-20 13:58:27 +01:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
thd->variables.*offset= global_system_variables.*offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
|
2003-07-06 18:09:57 +02:00
|
|
|
LEX_STRING *base)
|
2002-12-20 13:58:27 +01:00
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &(global_system_variables.*offset);
|
|
|
|
return (uchar*) &(thd->variables.*offset);
|
2002-12-20 13:58:27 +01:00
|
|
|
}
|
|
|
|
|
2007-12-06 01:28:01 +01:00
|
|
|
bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
return get_unsigned(thd, var);
|
|
|
|
}
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
|
|
|
|
{
|
2003-10-24 16:28:32 +02:00
|
|
|
ulonglong tmp= var->save_result.ulonglong_value;
|
2003-05-13 18:34:51 +02:00
|
|
|
|
2004-05-19 14:42:29 +02:00
|
|
|
if (tmp > max_system_variables.*offset)
|
2003-05-13 18:34:51 +02:00
|
|
|
tmp= max_system_variables.*offset;
|
|
|
|
|
|
|
|
if (option_limits)
|
2007-11-30 06:32:04 +01:00
|
|
|
tmp= fix_unsigned(thd, tmp, option_limits);
|
2002-07-23 17:31:22 +02:00
|
|
|
if (var->type == OPT_GLOBAL)
|
2002-12-20 13:58:27 +01:00
|
|
|
{
|
|
|
|
/* Lock is needed to make things safe on 32 bit systems */
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2003-05-13 18:34:51 +02:00
|
|
|
global_system_variables.*offset= (ulonglong) tmp;
|
2002-12-20 13:58:27 +01:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
else
|
2003-05-13 18:34:51 +02:00
|
|
|
thd->variables.*offset= (ulonglong) tmp;
|
2002-07-23 17:31:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_thd_ulonglong::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
2002-12-20 13:58:27 +01:00
|
|
|
{
|
2008-02-18 23:29:39 +01:00
|
|
|
my_bool not_used;
|
2002-12-20 13:58:27 +01:00
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2007-12-19 21:31:04 +01:00
|
|
|
global_system_variables.*offset=
|
|
|
|
getopt_ull_limit_value((ulonglong) option_limits->def_value,
|
|
|
|
option_limits, ¬_used);
|
2002-12-20 13:58:27 +01:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
else
|
|
|
|
thd->variables.*offset= global_system_variables.*offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
|
2003-07-06 18:09:57 +02:00
|
|
|
LEX_STRING *base)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &(global_system_variables.*offset);
|
|
|
|
return (uchar*) &(thd->variables.*offset);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_thd_bool::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
if (var->type == OPT_GLOBAL)
|
|
|
|
global_system_variables.*offset= (my_bool) var->save_result.ulong_value;
|
|
|
|
else
|
|
|
|
thd->variables.*offset= (my_bool) var->save_result.ulong_value;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_thd_bool::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
global_system_variables.*offset= (my_bool) option_limits->def_value;
|
|
|
|
else
|
|
|
|
thd->variables.*offset= global_system_variables.*offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
|
2003-07-06 18:09:57 +02:00
|
|
|
LEX_STRING *base)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &(global_system_variables.*offset);
|
|
|
|
return (uchar*) &(thd->variables.*offset);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-05 13:24:34 +02:00
|
|
|
bool sys_var::check_enum(THD *thd, set_var *var, const TYPELIB *enum_names)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE];
|
2003-10-14 15:30:42 +02:00
|
|
|
const char *value;
|
2002-10-02 12:33:08 +02:00
|
|
|
String str(buff, sizeof(buff), system_charset_info), *res;
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
if (var->value->result_type() == STRING_RESULT)
|
|
|
|
{
|
|
|
|
if (!(res=var->value->val_str(&str)) ||
|
|
|
|
((long) (var->save_result.ulong_value=
|
2003-11-03 13:01:59 +01:00
|
|
|
(ulong) find_type(enum_names, res->ptr(),
|
|
|
|
res->length(),1)-1)) < 0)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2003-10-14 15:30:42 +02:00
|
|
|
value= res ? res->c_ptr() : "NULL";
|
2002-07-23 17:31:22 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ulonglong tmp=var->value->val_int();
|
|
|
|
if (tmp >= enum_names->count)
|
|
|
|
{
|
|
|
|
llstr(tmp,buff);
|
|
|
|
value=buff; // Wrong value is here
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
var->save_result.ulong_value= (ulong) tmp; // Save for update
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, value);
|
2002-07-23 17:31:22 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-01-16 01:04:50 +01:00
|
|
|
|
|
|
|
bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
|
|
|
|
{
|
2003-04-30 09:02:28 +02:00
|
|
|
bool not_used;
|
2005-02-08 23:50:45 +01:00
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
|
2003-01-16 01:04:50 +01:00
|
|
|
uint error_len= 0;
|
|
|
|
String str(buff, sizeof(buff), system_charset_info), *res;
|
|
|
|
|
|
|
|
if (var->value->result_type() == STRING_RESULT)
|
|
|
|
{
|
|
|
|
if (!(res= var->value->val_str(&str)))
|
2005-06-09 11:39:29 +02:00
|
|
|
{
|
2005-06-21 17:18:58 +02:00
|
|
|
strmov(buff, "NULL");
|
2003-01-16 01:04:50 +01:00
|
|
|
goto err;
|
2005-06-09 11:39:29 +02:00
|
|
|
}
|
2003-08-18 23:08:08 +02:00
|
|
|
var->save_result.ulong_value= ((ulong)
|
|
|
|
find_set(enum_names, res->c_ptr(),
|
2004-10-26 10:17:37 +02:00
|
|
|
res->length(),
|
|
|
|
NULL,
|
|
|
|
&error, &error_len,
|
2003-08-18 23:08:08 +02:00
|
|
|
¬_used));
|
2003-01-16 01:04:50 +01:00
|
|
|
if (error_len)
|
|
|
|
{
|
2007-10-18 10:47:54 +02:00
|
|
|
strmake(buff, error, min(sizeof(buff) - 1, error_len));
|
2003-01-16 01:04:50 +01:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ulonglong tmp= var->value->val_int();
|
2006-02-18 17:32:15 +01:00
|
|
|
/*
|
|
|
|
For when the enum is made to contain 64 elements, as 1ULL<<64 is
|
|
|
|
undefined, we guard with a "count<64" test.
|
|
|
|
*/
|
|
|
|
if (unlikely((tmp >= ((ULL(1)) << enum_names->count)) &&
|
|
|
|
(enum_names->count < 64)))
|
2003-01-16 01:04:50 +01:00
|
|
|
{
|
|
|
|
llstr(tmp, buff);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
var->save_result.ulong_value= (ulong) tmp; // Save for update
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buff);
|
2003-01-16 01:04:50 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Return an Item for a variable.
|
|
|
|
|
|
|
|
Used with @@[global.]variable_name.
|
|
|
|
|
|
|
|
If type is not given, return local value if exists, else global.
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
if (check_type(var_type))
|
|
|
|
{
|
|
|
|
if (var_type != OPT_DEFAULT)
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0),
|
|
|
|
name, var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL");
|
2002-07-23 17:31:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* As there was no local variable, return the global value */
|
|
|
|
var_type= OPT_GLOBAL;
|
|
|
|
}
|
2006-12-14 23:51:37 +01:00
|
|
|
switch (show_type()) {
|
2005-01-19 22:54:01 +01:00
|
|
|
case SHOW_INT:
|
|
|
|
{
|
|
|
|
uint value;
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
value= *(uint*) value_ptr(thd, var_type, base);
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
2005-07-31 11:49:55 +02:00
|
|
|
return new Item_uint((ulonglong) value);
|
2005-01-19 22:54:01 +01:00
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
case SHOW_LONG:
|
2003-11-18 12:47:27 +01:00
|
|
|
{
|
|
|
|
ulong value;
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
value= *(ulong*) value_ptr(thd, var_type, base);
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
2005-07-31 11:49:55 +02:00
|
|
|
return new Item_uint((ulonglong) value);
|
2003-11-18 12:47:27 +01:00
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
case SHOW_LONGLONG:
|
2003-08-17 13:10:15 +02:00
|
|
|
{
|
|
|
|
longlong value;
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2003-08-29 12:44:35 +02:00
|
|
|
value= *(longlong*) value_ptr(thd, var_type, base);
|
2003-08-17 13:10:15 +02:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
return new Item_int(value);
|
|
|
|
}
|
2007-07-30 10:33:50 +02:00
|
|
|
case SHOW_DOUBLE:
|
|
|
|
{
|
|
|
|
double value;
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
value= *(double*) value_ptr(thd, var_type, base);
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
/* 6, as this is for now only used with microseconds */
|
|
|
|
return new Item_float(value, 6);
|
|
|
|
}
|
2002-12-20 13:58:27 +01:00
|
|
|
case SHOW_HA_ROWS:
|
2003-08-17 13:10:15 +02:00
|
|
|
{
|
|
|
|
ha_rows value;
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2003-08-29 12:44:35 +02:00
|
|
|
value= *(ha_rows*) value_ptr(thd, var_type, base);
|
2003-08-17 13:10:15 +02:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
2007-12-10 08:12:41 +01:00
|
|
|
return new Item_int((ulonglong) value);
|
2003-08-17 13:10:15 +02:00
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
case SHOW_MY_BOOL:
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
int32 value;
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
value= *(my_bool*) value_ptr(thd, var_type, base);
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
return new Item_int(value,1);
|
|
|
|
}
|
2007-05-26 01:40:24 +02:00
|
|
|
case SHOW_CHAR_PTR:
|
|
|
|
{
|
|
|
|
Item *tmp;
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
char *str= *(char**) value_ptr(thd, var_type, base);
|
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
uint length= strlen(str);
|
|
|
|
tmp= new Item_string(thd->strmake(str, length), length,
|
|
|
|
system_charset_info, DERIVATION_SYSCONST);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmp= new Item_null();
|
|
|
|
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
|
|
|
|
}
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
return tmp;
|
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
case SHOW_CHAR:
|
|
|
|
{
|
2005-08-30 14:11:59 +02:00
|
|
|
Item *tmp;
|
2003-11-03 13:01:59 +01:00
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2003-07-06 18:09:57 +02:00
|
|
|
char *str= (char*) value_ptr(thd, var_type, base);
|
2005-08-30 14:11:59 +02:00
|
|
|
if (str)
|
|
|
|
tmp= new Item_string(str, strlen(str),
|
|
|
|
system_charset_info, DERIVATION_SYSCONST);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmp= new Item_null();
|
|
|
|
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
|
|
|
|
}
|
2003-11-03 13:01:59 +01:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
return tmp;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
default:
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_VAR_CANT_BE_READ, MYF(0), name);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_thd_enum::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
if (var->type == OPT_GLOBAL)
|
|
|
|
global_system_variables.*offset= var->save_result.ulong_value;
|
|
|
|
else
|
|
|
|
thd->variables.*offset= var->save_result.ulong_value;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_thd_enum::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
global_system_variables.*offset= (ulong) option_limits->def_value;
|
|
|
|
else
|
|
|
|
thd->variables.*offset= global_system_variables.*offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
|
2003-07-06 18:09:57 +02:00
|
|
|
LEX_STRING *base)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
ulong tmp= ((type == OPT_GLOBAL) ?
|
|
|
|
global_system_variables.*offset :
|
|
|
|
thd->variables.*offset);
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) enum_names->type_names[tmp];
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
2004-04-28 12:08:54 +02:00
|
|
|
bool sys_var_thd_bit::check(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
return (check_enum(thd, var, &bool_typelib) ||
|
|
|
|
(check_func && (*check_func)(thd, var)));
|
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
bool sys_var_thd_bit::update(THD *thd, set_var *var)
|
|
|
|
{
|
2002-09-22 17:02:39 +02:00
|
|
|
int res= (*update_func)(thd, var);
|
2002-07-23 17:31:22 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type,
|
2003-07-06 18:09:57 +02:00
|
|
|
LEX_STRING *base)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
If reverse is 0 (default) return 1 if bit is set.
|
|
|
|
If reverse is 1, return 0 if bit is set
|
|
|
|
*/
|
|
|
|
thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
|
|
|
|
!reverse : reverse);
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &thd->sys_var_tmp.my_bool_value;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/** Update a date_time format variable based on given value. */
|
2003-11-03 13:01:59 +01:00
|
|
|
|
|
|
|
void sys_var_thd_date_time_format::update2(THD *thd, enum_var_type type,
|
|
|
|
DATE_TIME_FORMAT *new_value)
|
|
|
|
{
|
|
|
|
DATE_TIME_FORMAT *old;
|
|
|
|
DBUG_ENTER("sys_var_date_time_format::update2");
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
DBUG_DUMP("positions", (uchar*) new_value->positions,
|
2003-11-03 13:01:59 +01:00
|
|
|
sizeof(new_value->positions));
|
|
|
|
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
old= (global_system_variables.*offset);
|
|
|
|
(global_system_variables.*offset)= new_value;
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
old= (thd->variables.*offset);
|
|
|
|
(thd->variables.*offset)= new_value;
|
|
|
|
}
|
|
|
|
my_free((char*) old, MYF(MY_ALLOW_ZERO_PTR));
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_thd_date_time_format::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
DATE_TIME_FORMAT *new_value;
|
|
|
|
/* We must make a copy of the last value to get it into normal memory */
|
|
|
|
new_value= date_time_format_copy((THD*) 0,
|
|
|
|
var->save_result.date_time_format);
|
|
|
|
if (!new_value)
|
|
|
|
return 1; // Out of memory
|
|
|
|
update2(thd, var->type, new_value); // Can't fail
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_thd_date_time_format::check(THD *thd, set_var *var)
|
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE];
|
2003-11-03 13:01:59 +01:00
|
|
|
String str(buff,sizeof(buff), system_charset_info), *res;
|
|
|
|
DATE_TIME_FORMAT *format;
|
|
|
|
|
|
|
|
if (!(res=var->value->val_str(&str)))
|
|
|
|
res= &my_empty_string;
|
|
|
|
|
|
|
|
if (!(format= date_time_format_make(date_time_type,
|
|
|
|
res->ptr(), res->length())))
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, res->c_ptr());
|
2003-11-03 13:01:59 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
We must copy result to thread space to not get a memory leak if
|
|
|
|
update is aborted
|
|
|
|
*/
|
|
|
|
var->save_result.date_time_format= date_time_format_copy(thd, format);
|
|
|
|
my_free((char*) format, MYF(0));
|
|
|
|
return var->save_result.date_time_format == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_thd_date_time_format::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
DATE_TIME_FORMAT *res= 0;
|
|
|
|
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
{
|
|
|
|
const char *format;
|
|
|
|
if ((format= opt_date_time_formats[date_time_type]))
|
|
|
|
res= date_time_format_make(date_time_type, format, strlen(format));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Make copy with malloc */
|
|
|
|
res= date_time_format_copy((THD *) 0, global_system_variables.*offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res) // Should always be true
|
|
|
|
update2(thd, type, res);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
|
2003-11-03 13:01:59 +01:00
|
|
|
LEX_STRING *base)
|
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
{
|
|
|
|
char *res;
|
|
|
|
/*
|
|
|
|
We do a copy here just to be sure things will work even if someone
|
|
|
|
is modifying the original string while the copy is accessed
|
|
|
|
(Can't happen now in SQL SHOW, but this is a good safety for the future)
|
|
|
|
*/
|
|
|
|
res= thd->strmake((global_system_variables.*offset)->format.str,
|
|
|
|
(global_system_variables.*offset)->format.length);
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) res;
|
2003-11-03 13:01:59 +01:00
|
|
|
}
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) (thd->variables.*offset)->format.str;
|
2003-11-03 13:01:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-07 13:10:27 +02:00
|
|
|
typedef struct old_names_map_st
|
|
|
|
{
|
2003-03-18 14:01:32 +01:00
|
|
|
const char *old_name;
|
|
|
|
const char *new_name;
|
|
|
|
} my_old_conv;
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2003-03-18 14:01:32 +01:00
|
|
|
static my_old_conv old_conv[]=
|
|
|
|
{
|
2003-11-03 13:01:59 +01:00
|
|
|
{ "cp1251_koi8" , "cp1251" },
|
|
|
|
{ "cp1250_latin2" , "cp1250" },
|
|
|
|
{ "kam_latin2" , "keybcs2" },
|
|
|
|
{ "mac_latin2" , "MacRoman" },
|
|
|
|
{ "macce_latin2" , "MacCE" },
|
|
|
|
{ "pc2_latin2" , "pclatin2" },
|
|
|
|
{ "vga_latin2" , "pclatin1" },
|
|
|
|
{ "koi8_cp1251" , "koi8r" },
|
|
|
|
{ "win1251ukr_koi8_ukr" , "win1251ukr" },
|
|
|
|
{ "koi8_ukr_win1251ukr" , "koi8u" },
|
|
|
|
{ NULL , NULL }
|
2003-03-18 14:01:32 +01:00
|
|
|
};
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2003-04-05 15:56:15 +02:00
|
|
|
CHARSET_INFO *get_old_charset_by_name(const char *name)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2003-08-18 23:08:08 +02:00
|
|
|
my_old_conv *conv;
|
2003-03-18 14:01:32 +01:00
|
|
|
|
2003-08-18 23:08:08 +02:00
|
|
|
for (conv= old_conv; conv->old_name; conv++)
|
2002-12-14 16:43:01 +01:00
|
|
|
{
|
2003-08-18 23:08:08 +02:00
|
|
|
if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
|
|
|
|
return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
|
2002-12-14 16:43:01 +01:00
|
|
|
}
|
2003-03-18 14:01:32 +01:00
|
|
|
return NULL;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
2003-08-18 23:08:08 +02:00
|
|
|
|
2003-04-07 13:10:27 +02:00
|
|
|
bool sys_var_collation::check(THD *thd, set_var *var)
|
2003-02-26 13:37:41 +01:00
|
|
|
{
|
|
|
|
CHARSET_INFO *tmp;
|
2006-03-29 13:27:36 +02:00
|
|
|
LINT_INIT(tmp);
|
2003-02-26 13:37:41 +01:00
|
|
|
|
2004-06-03 23:17:18 +02:00
|
|
|
if (var->value->result_type() == STRING_RESULT)
|
2004-04-28 12:08:54 +02:00
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE];
|
2004-06-03 23:17:18 +02:00
|
|
|
String str(buff,sizeof(buff), system_charset_info), *res;
|
|
|
|
if (!(res=var->value->val_str(&str)))
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
|
2004-06-03 23:17:18 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0))))
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_UNKNOWN_COLLATION, MYF(0), res->c_ptr());
|
2004-06-03 23:17:18 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2004-04-28 12:08:54 +02:00
|
|
|
}
|
2004-06-03 23:17:18 +02:00
|
|
|
else // INT_RESULT
|
2003-05-21 14:44:12 +02:00
|
|
|
{
|
2004-07-08 14:45:25 +02:00
|
|
|
if (!(tmp=get_charset((int) var->value->val_int(),MYF(0))))
|
2004-06-03 23:17:18 +02:00
|
|
|
{
|
|
|
|
char buf[20];
|
2004-07-08 14:45:25 +02:00
|
|
|
int10_to_str((int) var->value->val_int(), buf, -10);
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_UNKNOWN_COLLATION, MYF(0), buf);
|
2004-06-03 23:17:18 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2003-05-21 14:44:12 +02:00
|
|
|
}
|
|
|
|
var->save_result.charset= tmp; // Save for update
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2003-05-21 14:44:12 +02:00
|
|
|
bool sys_var_character_set::check(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
CHARSET_INFO *tmp;
|
2006-03-29 13:27:36 +02:00
|
|
|
LINT_INIT(tmp);
|
2003-05-21 14:44:12 +02:00
|
|
|
|
2004-06-03 23:17:18 +02:00
|
|
|
if (var->value->result_type() == STRING_RESULT)
|
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE];
|
2004-06-03 23:17:18 +02:00
|
|
|
String str(buff,sizeof(buff), system_charset_info), *res;
|
|
|
|
if (!(res=var->value->val_str(&str)))
|
2003-05-30 10:56:02 +02:00
|
|
|
{
|
2004-06-03 23:17:18 +02:00
|
|
|
if (!nullable)
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
|
2004-06-03 23:17:18 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
tmp= NULL;
|
|
|
|
}
|
|
|
|
else if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) &&
|
|
|
|
!(tmp=get_old_charset_by_name(res->c_ptr())))
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
|
2003-05-30 10:56:02 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2004-06-03 23:17:18 +02:00
|
|
|
else // INT_RESULT
|
2003-02-26 13:37:41 +01:00
|
|
|
{
|
2004-07-08 14:45:25 +02:00
|
|
|
if (!(tmp=get_charset((int) var->value->val_int(),MYF(0))))
|
2004-06-03 23:17:18 +02:00
|
|
|
{
|
|
|
|
char buf[20];
|
2004-07-08 14:45:25 +02:00
|
|
|
int10_to_str((int) var->value->val_int(), buf, -10);
|
2004-06-03 23:17:18 +02:00
|
|
|
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), buf);
|
|
|
|
return 1;
|
|
|
|
}
|
2003-02-26 13:37:41 +01:00
|
|
|
}
|
|
|
|
var->save_result.charset= tmp; // Save for update
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2003-05-30 10:03:56 +02:00
|
|
|
bool sys_var_character_set::update(THD *thd, set_var *var)
|
2003-02-26 13:37:41 +01:00
|
|
|
{
|
2003-05-30 10:03:56 +02:00
|
|
|
ci_ptr(thd,var->type)[0]= var->save_result.charset;
|
2003-09-16 14:14:23 +02:00
|
|
|
thd->update_charset();
|
2003-02-26 13:37:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
|
2003-07-06 18:09:57 +02:00
|
|
|
LEX_STRING *base)
|
2003-02-26 13:37:41 +01:00
|
|
|
{
|
2003-05-30 10:03:56 +02:00
|
|
|
CHARSET_INFO *cs= ci_ptr(thd,type)[0];
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return cs ? (uchar*) cs->csname : (uchar*) NULL;
|
2006-01-18 09:55:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
void sys_var_character_set_sv::set_default(THD *thd, enum_var_type type)
|
2003-04-07 13:10:27 +02:00
|
|
|
{
|
2003-05-30 10:03:56 +02:00
|
|
|
if (type == OPT_GLOBAL)
|
2007-03-02 17:43:45 +01:00
|
|
|
global_system_variables.*offset= *global_default;
|
2003-04-07 13:10:27 +02:00
|
|
|
else
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
thd->variables.*offset= global_system_variables.*offset;
|
|
|
|
thd->update_charset();
|
|
|
|
}
|
2003-04-07 13:10:27 +02:00
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
|
2003-05-30 10:03:56 +02:00
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
2007-03-02 17:43:45 +01:00
|
|
|
return &(global_system_variables.*offset);
|
2003-05-30 10:03:56 +02:00
|
|
|
else
|
2007-03-02 17:43:45 +01:00
|
|
|
return &(thd->variables.*offset);
|
2003-05-30 10:03:56 +02:00
|
|
|
}
|
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2007-10-24 10:28:46 +02:00
|
|
|
bool sys_var_character_set_client::check(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
if (sys_var_character_set_sv::check(thd, var))
|
|
|
|
return 1;
|
|
|
|
/* Currently, UCS-2 cannot be used as a client character set */
|
|
|
|
if (var->save_result.charset->mbminlen > 1)
|
|
|
|
{
|
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
|
|
|
|
var->save_result.charset->csname);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
|
|
|
|
enum_var_type type)
|
2003-05-30 10:03:56 +02:00
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
2003-09-15 13:31:04 +02:00
|
|
|
return &global_system_variables.collation_database;
|
2003-05-30 10:03:56 +02:00
|
|
|
else
|
2003-09-15 13:31:04 +02:00
|
|
|
return &thd->variables.collation_database;
|
2003-04-07 13:10:27 +02:00
|
|
|
}
|
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2003-05-30 10:03:56 +02:00
|
|
|
void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
2003-09-15 13:31:04 +02:00
|
|
|
global_system_variables.collation_database= default_charset_info;
|
2003-05-30 10:03:56 +02:00
|
|
|
else
|
2003-08-18 23:08:08 +02:00
|
|
|
{
|
2003-09-15 13:31:04 +02:00
|
|
|
thd->variables.collation_database= thd->db_charset;
|
2003-08-18 23:08:08 +02:00
|
|
|
thd->update_charset();
|
|
|
|
}
|
2003-05-30 10:03:56 +02:00
|
|
|
}
|
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
bool sys_var_collation_sv::update(THD *thd, set_var *var)
|
2003-04-08 11:38:17 +02:00
|
|
|
{
|
|
|
|
if (var->type == OPT_GLOBAL)
|
2007-03-02 17:43:45 +01:00
|
|
|
global_system_variables.*offset= var->save_result.charset;
|
2003-04-08 11:38:17 +02:00
|
|
|
else
|
2003-08-18 23:08:08 +02:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
thd->variables.*offset= var->save_result.charset;
|
2003-08-18 23:08:08 +02:00
|
|
|
thd->update_charset();
|
|
|
|
}
|
2003-04-08 11:38:17 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
void sys_var_collation_sv::set_default(THD *thd, enum_var_type type)
|
2003-04-08 11:38:17 +02:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
global_system_variables.*offset= *global_default;
|
2003-09-15 13:31:04 +02:00
|
|
|
else
|
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
thd->variables.*offset= global_system_variables.*offset;
|
2003-09-15 13:31:04 +02:00
|
|
|
thd->update_charset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-24 12:24:36 +02:00
|
|
|
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
|
2007-05-28 13:37:39 +02:00
|
|
|
LEX_STRING *base)
|
2003-09-15 13:31:04 +02:00
|
|
|
{
|
|
|
|
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
|
2007-05-24 12:24:36 +02:00
|
|
|
global_system_variables.*offset : thd->variables.*offset);
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return cs ? (uchar*) cs->name : (uchar*) "NULL";
|
2003-09-15 13:31:04 +02:00
|
|
|
}
|
|
|
|
|
2003-04-07 13:10:27 +02:00
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
LEX_STRING default_key_cache_base= {(char *) "default", 7 };
|
2003-08-02 11:43:18 +02:00
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
static KEY_CACHE zero_key_cache;
|
2003-08-02 11:43:18 +02:00
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
KEY_CACHE *get_key_cache(LEX_STRING *cache_name)
|
2003-08-02 11:43:18 +02:00
|
|
|
{
|
2003-11-18 12:47:27 +01:00
|
|
|
safe_mutex_assert_owner(&LOCK_global_system_variables);
|
|
|
|
if (!cache_name || ! cache_name->length)
|
2003-08-02 11:43:18 +02:00
|
|
|
cache_name= &default_key_cache_base;
|
2003-11-20 21:06:25 +01:00
|
|
|
return ((KEY_CACHE*) find_named(&key_caches,
|
2003-11-18 12:47:27 +01:00
|
|
|
cache_name->str, cache_name->length, 0));
|
2003-08-02 11:43:18 +02:00
|
|
|
}
|
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
|
2003-08-02 11:43:18 +02:00
|
|
|
LEX_STRING *base)
|
2003-07-06 18:09:57 +02:00
|
|
|
{
|
2003-11-20 21:06:25 +01:00
|
|
|
KEY_CACHE *key_cache= get_key_cache(base);
|
2003-08-02 11:43:18 +02:00
|
|
|
if (!key_cache)
|
|
|
|
key_cache= &zero_key_cache;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) key_cache + offset ;
|
2003-08-02 11:43:18 +02:00
|
|
|
}
|
2004-04-28 12:08:54 +02:00
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
|
|
|
|
{
|
2003-10-24 16:28:32 +02:00
|
|
|
ulonglong tmp= var->save_result.ulonglong_value;
|
2003-08-18 23:08:08 +02:00
|
|
|
LEX_STRING *base_name= &var->base;
|
2003-11-20 21:06:25 +01:00
|
|
|
KEY_CACHE *key_cache;
|
2003-11-18 12:47:27 +01:00
|
|
|
bool error= 0;
|
|
|
|
|
|
|
|
/* If no basename, assume it's for the key cache named 'default' */
|
2003-08-18 23:08:08 +02:00
|
|
|
if (!base_name->length)
|
2003-08-27 00:14:13 +02:00
|
|
|
base_name= &default_key_cache_base;
|
2003-11-18 12:47:27 +01:00
|
|
|
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
key_cache= get_key_cache(base_name);
|
2003-08-02 11:43:18 +02:00
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
if (!key_cache)
|
|
|
|
{
|
2003-11-18 12:47:27 +01:00
|
|
|
/* Key cache didn't exists */
|
2003-07-06 18:09:57 +02:00
|
|
|
if (!tmp) // Tried to delete cache
|
2003-11-18 12:47:27 +01:00
|
|
|
goto end; // Ok, nothing to do
|
|
|
|
if (!(key_cache= create_key_cache(base_name->str, base_name->length)))
|
|
|
|
{
|
|
|
|
error= 1;
|
|
|
|
goto end;
|
|
|
|
}
|
2003-07-06 18:09:57 +02:00
|
|
|
}
|
2003-11-18 12:47:27 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
Abort if some other thread is changing the key cache
|
|
|
|
TODO: This should be changed so that we wait until the previous
|
|
|
|
assignment is done and then do the new assign
|
|
|
|
*/
|
|
|
|
if (key_cache->in_init)
|
|
|
|
goto end;
|
|
|
|
|
2003-08-18 23:08:08 +02:00
|
|
|
if (!tmp) // Zero size means delete
|
2003-07-06 18:09:57 +02:00
|
|
|
{
|
2005-01-19 11:55:54 +01:00
|
|
|
if (key_cache == dflt_key_cache)
|
2005-08-07 20:39:17 +02:00
|
|
|
{
|
|
|
|
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
|
|
|
ER_WARN_CANT_DROP_DEFAULT_KEYCACHE,
|
|
|
|
ER(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE));
|
2003-11-18 12:47:27 +01:00
|
|
|
goto end; // Ignore default key cache
|
2005-08-07 20:39:17 +02:00
|
|
|
}
|
2003-11-18 12:47:27 +01:00
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
if (key_cache->key_cache_inited) // If initied
|
2003-07-06 18:09:57 +02:00
|
|
|
{
|
|
|
|
/*
|
2003-11-18 12:47:27 +01:00
|
|
|
Move tables using this key cache to the default key cache
|
|
|
|
and clear the old key cache.
|
2003-07-06 18:09:57 +02:00
|
|
|
*/
|
2003-08-27 00:14:13 +02:00
|
|
|
NAMED_LIST *list;
|
2003-11-20 21:06:25 +01:00
|
|
|
key_cache= (KEY_CACHE *) find_named(&key_caches, base_name->str,
|
2003-08-27 00:14:13 +02:00
|
|
|
base_name->length, &list);
|
2003-11-18 12:47:27 +01:00
|
|
|
key_cache->in_init= 1;
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
2005-01-19 11:55:54 +01:00
|
|
|
error= reassign_keycache_tables(thd, key_cache, dflt_key_cache);
|
2003-11-18 12:47:27 +01:00
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
key_cache->in_init= 0;
|
2003-07-06 18:09:57 +02:00
|
|
|
}
|
2003-11-18 12:47:27 +01:00
|
|
|
/*
|
|
|
|
We don't delete the key cache as some running threads my still be
|
|
|
|
in the key cache code with a pointer to the deleted (empty) key cache
|
|
|
|
*/
|
|
|
|
goto end;
|
2003-07-06 18:09:57 +02:00
|
|
|
}
|
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
key_cache->param_buff_size=
|
2007-11-30 06:32:04 +01:00
|
|
|
(ulonglong) fix_unsigned(thd, tmp, option_limits);
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
/* If key cache didn't existed initialize it, else resize it */
|
|
|
|
key_cache->in_init= 1;
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
if (!key_cache->key_cache_inited)
|
2003-11-18 12:47:27 +01:00
|
|
|
error= (bool) (ha_init_key_cache("", key_cache));
|
2003-08-02 11:43:18 +02:00
|
|
|
else
|
2003-11-18 12:47:27 +01:00
|
|
|
error= (bool)(ha_resize_key_cache(key_cache));
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
key_cache->in_init= 0;
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
end:
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
return error;
|
2003-07-06 18:09:57 +02:00
|
|
|
}
|
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
@todo
|
|
|
|
Abort if some other thread is changing the key cache.
|
|
|
|
This should be changed so that we wait until the previous
|
|
|
|
assignment is done and then do the new assign
|
|
|
|
*/
|
2003-11-18 12:47:27 +01:00
|
|
|
bool sys_var_key_cache_long::update(THD *thd, set_var *var)
|
2003-08-09 20:12:22 +02:00
|
|
|
{
|
2003-11-21 00:53:01 +01:00
|
|
|
ulong tmp= (ulong) var->value->val_int();
|
2003-08-27 00:14:13 +02:00
|
|
|
LEX_STRING *base_name= &var->base;
|
2003-11-18 12:47:27 +01:00
|
|
|
bool error= 0;
|
|
|
|
|
2003-08-27 00:14:13 +02:00
|
|
|
if (!base_name->length)
|
2003-08-26 09:13:22 +02:00
|
|
|
base_name= &default_key_cache_base;
|
2003-11-18 12:47:27 +01:00
|
|
|
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2003-11-20 21:06:25 +01:00
|
|
|
KEY_CACHE *key_cache= get_key_cache(base_name);
|
2004-04-28 12:08:54 +02:00
|
|
|
|
2003-08-26 09:13:22 +02:00
|
|
|
if (!key_cache && !(key_cache= create_key_cache(base_name->str,
|
|
|
|
base_name->length)))
|
2003-11-18 12:47:27 +01:00
|
|
|
{
|
|
|
|
error= 1;
|
|
|
|
goto end;
|
|
|
|
}
|
2004-04-28 12:08:54 +02:00
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
/*
|
|
|
|
Abort if some other thread is changing the key cache
|
|
|
|
TODO: This should be changed so that we wait until the previous
|
|
|
|
assignment is done and then do the new assign
|
|
|
|
*/
|
|
|
|
if (key_cache->in_init)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
*((ulong*) (((char*) key_cache) + offset))=
|
2007-11-30 06:32:04 +01:00
|
|
|
(ulong) fix_unsigned(thd, tmp, option_limits);
|
2003-08-18 23:08:08 +02:00
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
/*
|
|
|
|
Don't create a new key cache if it didn't exist
|
|
|
|
(key_caches are created only when the user sets block_size)
|
|
|
|
*/
|
|
|
|
key_cache->in_init= 1;
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
error= (bool) (ha_resize_key_cache(key_cache));
|
|
|
|
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
key_cache->in_init= 0;
|
|
|
|
|
|
|
|
end:
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
return error;
|
2003-07-06 18:09:57 +02:00
|
|
|
}
|
|
|
|
|
2003-05-30 10:03:56 +02:00
|
|
|
|
2006-06-19 15:30:55 +02:00
|
|
|
bool sys_var_log_state::update(THD *thd, set_var *var)
|
|
|
|
{
|
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log)
Bug#25422 (Hang with log tables)
Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the
thread)
Bug 23044 (Warnings on flush of a log table)
Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
a deadlock)
Prior to this fix, the server would hang when performing concurrent
ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES,
which are mysql.general_log and mysql.slow_log.
The root cause traces to the following code:
in sql_base.cc, open_table()
if (table->in_use != thd)
{
/* wait_for_condition will unlock LOCK_open for us */
wait_for_condition(thd, &LOCK_open, &COND_refresh);
}
The problem with this code is that the current implementation of the
LOGGER creates 'fake' THD objects, like
- Log_to_csv_event_handler::general_log_thd
- Log_to_csv_event_handler::slow_log_thd
which are not associated to a real thread running in the server,
so that waiting for these non-existing threads to release table locks
cause the dead lock.
In general, the design of Log_to_csv_event_handler does not fit into the
general architecture of the server, so that the concept of general_log_thd
and slow_log_thd has to be abandoned:
- this implementation does not work with table locking
- it will not work with commands like SHOW PROCESSLIST
- having the log tables always opened does not integrate well with DDL
operations / FLUSH TABLES / SET GLOBAL READ_ONLY
With this patch, the fundamental design of the LOGGER has been changed to:
- always open and close a log table when writing a log
- remove totally the usage of fake THD objects
- clarify how locking of log tables is implemented in general.
See WL#3984 for details related to the new locking design.
Additional changes (misc bugs exposed and fixed):
1)
mysqldump which would ignore some tables in dump_all_tables_in_db(),
but forget to ignore the same in dump_all_views_in_db().
2)
mysqldump would also issue an empty "LOCK TABLE" command when all the tables
to lock are to be ignored (numrows == 0), instead of not issuing the query.
3)
Internal errors handlers could intercept errors but not warnings
(see sql_error.cc).
4)
Implementing a nested call to open tables, for the performance schema tables,
exposed an existing bug in remove_table_from_cache(), which would perform:
in_use->some_tables_deleted=1;
against another thread, without any consideration about thread locking.
This call inside remove_table_from_cache() was not required anyway,
since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads
that might hold a lock on a table.
This line (in_use->some_tables_deleted=1) has been removed.
2007-07-27 08:31:06 +02:00
|
|
|
bool res;
|
2006-06-19 15:30:55 +02:00
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
if (!var->save_result.ulong_value)
|
|
|
|
{
|
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log)
Bug#25422 (Hang with log tables)
Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the
thread)
Bug 23044 (Warnings on flush of a log table)
Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
a deadlock)
Prior to this fix, the server would hang when performing concurrent
ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES,
which are mysql.general_log and mysql.slow_log.
The root cause traces to the following code:
in sql_base.cc, open_table()
if (table->in_use != thd)
{
/* wait_for_condition will unlock LOCK_open for us */
wait_for_condition(thd, &LOCK_open, &COND_refresh);
}
The problem with this code is that the current implementation of the
LOGGER creates 'fake' THD objects, like
- Log_to_csv_event_handler::general_log_thd
- Log_to_csv_event_handler::slow_log_thd
which are not associated to a real thread running in the server,
so that waiting for these non-existing threads to release table locks
cause the dead lock.
In general, the design of Log_to_csv_event_handler does not fit into the
general architecture of the server, so that the concept of general_log_thd
and slow_log_thd has to be abandoned:
- this implementation does not work with table locking
- it will not work with commands like SHOW PROCESSLIST
- having the log tables always opened does not integrate well with DDL
operations / FLUSH TABLES / SET GLOBAL READ_ONLY
With this patch, the fundamental design of the LOGGER has been changed to:
- always open and close a log table when writing a log
- remove totally the usage of fake THD objects
- clarify how locking of log tables is implemented in general.
See WL#3984 for details related to the new locking design.
Additional changes (misc bugs exposed and fixed):
1)
mysqldump which would ignore some tables in dump_all_tables_in_db(),
but forget to ignore the same in dump_all_views_in_db().
2)
mysqldump would also issue an empty "LOCK TABLE" command when all the tables
to lock are to be ignored (numrows == 0), instead of not issuing the query.
3)
Internal errors handlers could intercept errors but not warnings
(see sql_error.cc).
4)
Implementing a nested call to open tables, for the performance schema tables,
exposed an existing bug in remove_table_from_cache(), which would perform:
in_use->some_tables_deleted=1;
against another thread, without any consideration about thread locking.
This call inside remove_table_from_cache() was not required anyway,
since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads
that might hold a lock on a table.
This line (in_use->some_tables_deleted=1) has been removed.
2007-07-27 08:31:06 +02:00
|
|
|
logger.deactivate_log_handler(thd, log_type);
|
|
|
|
res= false;
|
2006-06-19 15:30:55 +02:00
|
|
|
}
|
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log)
Bug#25422 (Hang with log tables)
Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the
thread)
Bug 23044 (Warnings on flush of a log table)
Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
a deadlock)
Prior to this fix, the server would hang when performing concurrent
ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES,
which are mysql.general_log and mysql.slow_log.
The root cause traces to the following code:
in sql_base.cc, open_table()
if (table->in_use != thd)
{
/* wait_for_condition will unlock LOCK_open for us */
wait_for_condition(thd, &LOCK_open, &COND_refresh);
}
The problem with this code is that the current implementation of the
LOGGER creates 'fake' THD objects, like
- Log_to_csv_event_handler::general_log_thd
- Log_to_csv_event_handler::slow_log_thd
which are not associated to a real thread running in the server,
so that waiting for these non-existing threads to release table locks
cause the dead lock.
In general, the design of Log_to_csv_event_handler does not fit into the
general architecture of the server, so that the concept of general_log_thd
and slow_log_thd has to be abandoned:
- this implementation does not work with table locking
- it will not work with commands like SHOW PROCESSLIST
- having the log tables always opened does not integrate well with DDL
operations / FLUSH TABLES / SET GLOBAL READ_ONLY
With this patch, the fundamental design of the LOGGER has been changed to:
- always open and close a log table when writing a log
- remove totally the usage of fake THD objects
- clarify how locking of log tables is implemented in general.
See WL#3984 for details related to the new locking design.
Additional changes (misc bugs exposed and fixed):
1)
mysqldump which would ignore some tables in dump_all_tables_in_db(),
but forget to ignore the same in dump_all_views_in_db().
2)
mysqldump would also issue an empty "LOCK TABLE" command when all the tables
to lock are to be ignored (numrows == 0), instead of not issuing the query.
3)
Internal errors handlers could intercept errors but not warnings
(see sql_error.cc).
4)
Implementing a nested call to open tables, for the performance schema tables,
exposed an existing bug in remove_table_from_cache(), which would perform:
in_use->some_tables_deleted=1;
against another thread, without any consideration about thread locking.
This call inside remove_table_from_cache() was not required anyway,
since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads
that might hold a lock on a table.
This line (in_use->some_tables_deleted=1) has been removed.
2007-07-27 08:31:06 +02:00
|
|
|
else
|
|
|
|
res= logger.activate_log_handler(thd, log_type);
|
2006-06-19 15:30:55 +02:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sys_var_log_state::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
logger.deactivate_log_handler(thd, log_type);
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int sys_check_log_path(THD *thd, set_var *var)
|
|
|
|
{
|
2007-10-16 14:19:07 +02:00
|
|
|
char path[FN_REFLEN], buff[FN_REFLEN];
|
2006-06-19 15:30:55 +02:00
|
|
|
MY_STAT f_stat;
|
2007-10-16 14:19:07 +02:00
|
|
|
String str(buff, sizeof(buff), system_charset_info), *res;
|
|
|
|
const char *log_file_str;
|
|
|
|
|
|
|
|
if (!(res= var->value->val_str(&str)))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
log_file_str= res->c_ptr();
|
2006-06-19 15:30:55 +02:00
|
|
|
bzero(&f_stat, sizeof(MY_STAT));
|
|
|
|
|
2007-10-16 14:19:07 +02:00
|
|
|
(void) unpack_filename(path, log_file_str);
|
2006-06-19 15:30:55 +02:00
|
|
|
if (my_stat(path, &f_stat, MYF(0)))
|
|
|
|
{
|
|
|
|
/* Check if argument is a file and we have 'write' permission */
|
|
|
|
if (!MY_S_ISREG(f_stat.st_mode) ||
|
|
|
|
!(f_stat.st_mode & MY_S_IWRITE))
|
2007-10-16 14:19:07 +02:00
|
|
|
goto err;
|
2006-06-19 15:30:55 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
size_t path_length;
|
2006-06-19 15:30:55 +02:00
|
|
|
/*
|
|
|
|
Check if directory exists and
|
|
|
|
we have permission to create file & write to file
|
|
|
|
*/
|
2007-10-16 14:19:07 +02:00
|
|
|
(void) dirname_part(path, log_file_str, &path_length);
|
2006-06-19 15:30:55 +02:00
|
|
|
if (my_access(path, (F_OK|W_OK)))
|
2007-10-16 14:19:07 +02:00
|
|
|
goto err;
|
2006-06-19 15:30:55 +02:00
|
|
|
}
|
|
|
|
return 0;
|
2007-10-16 14:19:07 +02:00
|
|
|
|
|
|
|
err:
|
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name,
|
|
|
|
res ? log_file_str : "NULL");
|
|
|
|
return 1;
|
2006-06-19 15:30:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool update_sys_var_str_path(THD *thd, sys_var_str *var_str,
|
|
|
|
set_var *var, const char *log_ext,
|
|
|
|
bool log_state, uint log_type)
|
|
|
|
{
|
2006-06-21 11:53:40 +02:00
|
|
|
MYSQL_QUERY_LOG *file_log;
|
2006-06-19 15:30:55 +02:00
|
|
|
char buff[FN_REFLEN];
|
|
|
|
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
|
|
|
|
bool result= 0;
|
|
|
|
uint str_length= (var ? var->value->str_value.length() : 0);
|
|
|
|
|
|
|
|
switch (log_type) {
|
|
|
|
case QUERY_LOG_SLOW:
|
|
|
|
file_log= logger.get_slow_log_file_handler();
|
|
|
|
break;
|
|
|
|
case QUERY_LOG_GENERAL:
|
|
|
|
file_log= logger.get_log_file_handler();
|
|
|
|
break;
|
|
|
|
default:
|
2007-02-23 12:13:55 +01:00
|
|
|
assert(0); // Impossible
|
2006-06-19 15:30:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!old_value)
|
|
|
|
{
|
|
|
|
old_value= make_default_log_name(buff, log_ext);
|
|
|
|
str_length= strlen(old_value);
|
|
|
|
}
|
2006-07-07 21:03:19 +02:00
|
|
|
if (!(res= my_strndup(old_value, str_length, MYF(MY_FAE+MY_WME))))
|
2006-06-19 15:30:55 +02:00
|
|
|
{
|
|
|
|
result= 1;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log)
Bug#25422 (Hang with log tables)
Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the
thread)
Bug 23044 (Warnings on flush of a log table)
Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
a deadlock)
Prior to this fix, the server would hang when performing concurrent
ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES,
which are mysql.general_log and mysql.slow_log.
The root cause traces to the following code:
in sql_base.cc, open_table()
if (table->in_use != thd)
{
/* wait_for_condition will unlock LOCK_open for us */
wait_for_condition(thd, &LOCK_open, &COND_refresh);
}
The problem with this code is that the current implementation of the
LOGGER creates 'fake' THD objects, like
- Log_to_csv_event_handler::general_log_thd
- Log_to_csv_event_handler::slow_log_thd
which are not associated to a real thread running in the server,
so that waiting for these non-existing threads to release table locks
cause the dead lock.
In general, the design of Log_to_csv_event_handler does not fit into the
general architecture of the server, so that the concept of general_log_thd
and slow_log_thd has to be abandoned:
- this implementation does not work with table locking
- it will not work with commands like SHOW PROCESSLIST
- having the log tables always opened does not integrate well with DDL
operations / FLUSH TABLES / SET GLOBAL READ_ONLY
With this patch, the fundamental design of the LOGGER has been changed to:
- always open and close a log table when writing a log
- remove totally the usage of fake THD objects
- clarify how locking of log tables is implemented in general.
See WL#3984 for details related to the new locking design.
Additional changes (misc bugs exposed and fixed):
1)
mysqldump which would ignore some tables in dump_all_tables_in_db(),
but forget to ignore the same in dump_all_views_in_db().
2)
mysqldump would also issue an empty "LOCK TABLE" command when all the tables
to lock are to be ignored (numrows == 0), instead of not issuing the query.
3)
Internal errors handlers could intercept errors but not warnings
(see sql_error.cc).
4)
Implementing a nested call to open tables, for the performance schema tables,
exposed an existing bug in remove_table_from_cache(), which would perform:
in_use->some_tables_deleted=1;
against another thread, without any consideration about thread locking.
This call inside remove_table_from_cache() was not required anyway,
since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads
that might hold a lock on a table.
This line (in_use->some_tables_deleted=1) has been removed.
2007-07-27 08:31:06 +02:00
|
|
|
logger.lock_exclusive();
|
2006-06-19 15:30:55 +02:00
|
|
|
|
|
|
|
if (file_log && log_state)
|
|
|
|
file_log->close(0);
|
|
|
|
old_value= var_str->value;
|
|
|
|
var_str->value= res;
|
|
|
|
var_str->value_length= str_length;
|
|
|
|
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
|
|
|
|
if (file_log && log_state)
|
2006-06-21 11:53:40 +02:00
|
|
|
{
|
|
|
|
switch (log_type) {
|
|
|
|
case QUERY_LOG_SLOW:
|
2007-02-02 12:21:04 +01:00
|
|
|
file_log->open_slow_log(sys_var_slow_log_path.value);
|
2006-06-21 11:53:40 +02:00
|
|
|
break;
|
|
|
|
case QUERY_LOG_GENERAL:
|
|
|
|
file_log->open_query_log(sys_var_general_log_path.value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
}
|
|
|
|
}
|
2006-06-19 15:30:55 +02:00
|
|
|
|
|
|
|
logger.unlock();
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
|
|
|
|
err:
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool sys_update_general_log_path(THD *thd, set_var * var)
|
|
|
|
{
|
|
|
|
return update_sys_var_str_path(thd, &sys_var_general_log_path,
|
|
|
|
var, ".log", opt_log, QUERY_LOG_GENERAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void sys_default_general_log_path(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
(void) update_sys_var_str_path(thd, &sys_var_general_log_path,
|
|
|
|
0, ".log", opt_log, QUERY_LOG_GENERAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool sys_update_slow_log_path(THD *thd, set_var * var)
|
|
|
|
{
|
|
|
|
return update_sys_var_str_path(thd, &sys_var_slow_log_path,
|
|
|
|
var, "-slow.log", opt_slow_log,
|
|
|
|
QUERY_LOG_SLOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void sys_default_slow_log_path(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
(void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
|
|
|
|
0, "-slow.log", opt_slow_log,
|
|
|
|
QUERY_LOG_SLOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_log_output::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log)
Bug#25422 (Hang with log tables)
Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the
thread)
Bug 23044 (Warnings on flush of a log table)
Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
a deadlock)
Prior to this fix, the server would hang when performing concurrent
ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES,
which are mysql.general_log and mysql.slow_log.
The root cause traces to the following code:
in sql_base.cc, open_table()
if (table->in_use != thd)
{
/* wait_for_condition will unlock LOCK_open for us */
wait_for_condition(thd, &LOCK_open, &COND_refresh);
}
The problem with this code is that the current implementation of the
LOGGER creates 'fake' THD objects, like
- Log_to_csv_event_handler::general_log_thd
- Log_to_csv_event_handler::slow_log_thd
which are not associated to a real thread running in the server,
so that waiting for these non-existing threads to release table locks
cause the dead lock.
In general, the design of Log_to_csv_event_handler does not fit into the
general architecture of the server, so that the concept of general_log_thd
and slow_log_thd has to be abandoned:
- this implementation does not work with table locking
- it will not work with commands like SHOW PROCESSLIST
- having the log tables always opened does not integrate well with DDL
operations / FLUSH TABLES / SET GLOBAL READ_ONLY
With this patch, the fundamental design of the LOGGER has been changed to:
- always open and close a log table when writing a log
- remove totally the usage of fake THD objects
- clarify how locking of log tables is implemented in general.
See WL#3984 for details related to the new locking design.
Additional changes (misc bugs exposed and fixed):
1)
mysqldump which would ignore some tables in dump_all_tables_in_db(),
but forget to ignore the same in dump_all_views_in_db().
2)
mysqldump would also issue an empty "LOCK TABLE" command when all the tables
to lock are to be ignored (numrows == 0), instead of not issuing the query.
3)
Internal errors handlers could intercept errors but not warnings
(see sql_error.cc).
4)
Implementing a nested call to open tables, for the performance schema tables,
exposed an existing bug in remove_table_from_cache(), which would perform:
in_use->some_tables_deleted=1;
against another thread, without any consideration about thread locking.
This call inside remove_table_from_cache() was not required anyway,
since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads
that might hold a lock on a table.
This line (in_use->some_tables_deleted=1) has been removed.
2007-07-27 08:31:06 +02:00
|
|
|
logger.lock_exclusive();
|
2006-06-19 15:30:55 +02:00
|
|
|
logger.init_slow_log(var->save_result.ulong_value);
|
|
|
|
logger.init_general_log(var->save_result.ulong_value);
|
|
|
|
*value= var->save_result.ulong_value;
|
|
|
|
logger.unlock();
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_log_output::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log)
Bug#25422 (Hang with log tables)
Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the
thread)
Bug 23044 (Warnings on flush of a log table)
Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
a deadlock)
Prior to this fix, the server would hang when performing concurrent
ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES,
which are mysql.general_log and mysql.slow_log.
The root cause traces to the following code:
in sql_base.cc, open_table()
if (table->in_use != thd)
{
/* wait_for_condition will unlock LOCK_open for us */
wait_for_condition(thd, &LOCK_open, &COND_refresh);
}
The problem with this code is that the current implementation of the
LOGGER creates 'fake' THD objects, like
- Log_to_csv_event_handler::general_log_thd
- Log_to_csv_event_handler::slow_log_thd
which are not associated to a real thread running in the server,
so that waiting for these non-existing threads to release table locks
cause the dead lock.
In general, the design of Log_to_csv_event_handler does not fit into the
general architecture of the server, so that the concept of general_log_thd
and slow_log_thd has to be abandoned:
- this implementation does not work with table locking
- it will not work with commands like SHOW PROCESSLIST
- having the log tables always opened does not integrate well with DDL
operations / FLUSH TABLES / SET GLOBAL READ_ONLY
With this patch, the fundamental design of the LOGGER has been changed to:
- always open and close a log table when writing a log
- remove totally the usage of fake THD objects
- clarify how locking of log tables is implemented in general.
See WL#3984 for details related to the new locking design.
Additional changes (misc bugs exposed and fixed):
1)
mysqldump which would ignore some tables in dump_all_tables_in_db(),
but forget to ignore the same in dump_all_views_in_db().
2)
mysqldump would also issue an empty "LOCK TABLE" command when all the tables
to lock are to be ignored (numrows == 0), instead of not issuing the query.
3)
Internal errors handlers could intercept errors but not warnings
(see sql_error.cc).
4)
Implementing a nested call to open tables, for the performance schema tables,
exposed an existing bug in remove_table_from_cache(), which would perform:
in_use->some_tables_deleted=1;
against another thread, without any consideration about thread locking.
This call inside remove_table_from_cache() was not required anyway,
since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads
that might hold a lock on a table.
This line (in_use->some_tables_deleted=1) has been removed.
2007-07-27 08:31:06 +02:00
|
|
|
logger.lock_exclusive();
|
|
|
|
logger.init_slow_log(LOG_FILE);
|
|
|
|
logger.init_general_log(LOG_FILE);
|
|
|
|
*value= LOG_FILE;
|
2006-06-19 15:30:55 +02:00
|
|
|
logger.unlock();
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_log_output::value_ptr(THD *thd, enum_var_type type,
|
2006-06-23 01:49:19 +02:00
|
|
|
LEX_STRING *base)
|
2006-06-19 15:30:55 +02:00
|
|
|
{
|
|
|
|
char buff[256];
|
|
|
|
String tmp(buff, sizeof(buff), &my_charset_latin1);
|
|
|
|
ulong length;
|
|
|
|
ulong val= *value;
|
|
|
|
|
|
|
|
tmp.length(0);
|
|
|
|
for (uint i= 0; val; val>>= 1, i++)
|
|
|
|
{
|
|
|
|
if (val & 1)
|
|
|
|
{
|
|
|
|
tmp.append(log_output_typelib.type_names[i],
|
|
|
|
log_output_typelib.type_lengths[i]);
|
|
|
|
tmp.append(',');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((length= tmp.length()))
|
|
|
|
length--;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) thd->strmake(tmp.ptr(), length);
|
2006-06-19 15:30:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-07 13:10:27 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
Functions to handle SET NAMES and SET CHARACTER SET
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2003-04-23 15:19:22 +02:00
|
|
|
int set_var_collation_client::check(THD *thd)
|
2003-04-07 13:10:27 +02:00
|
|
|
{
|
2007-10-24 10:28:46 +02:00
|
|
|
/* Currently, UCS-2 cannot be used as a client character set */
|
|
|
|
if (character_set_client->mbminlen > 1)
|
|
|
|
{
|
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "character_set_client",
|
|
|
|
character_set_client->csname);
|
|
|
|
return 1;
|
|
|
|
}
|
2003-04-07 13:10:27 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-04-23 15:19:22 +02:00
|
|
|
int set_var_collation_client::update(THD *thd)
|
2003-04-07 13:10:27 +02:00
|
|
|
{
|
2003-05-21 14:44:12 +02:00
|
|
|
thd->variables.character_set_client= character_set_client;
|
|
|
|
thd->variables.character_set_results= character_set_results;
|
2003-04-23 15:19:22 +02:00
|
|
|
thd->variables.collation_connection= collation_connection;
|
2003-08-18 23:08:08 +02:00
|
|
|
thd->update_charset();
|
2007-01-30 22:48:05 +01:00
|
|
|
thd->protocol_text.init(thd);
|
|
|
|
thd->protocol_binary.init(thd);
|
2003-04-07 13:10:27 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
bool sys_var_timestamp::update(THD *thd, set_var *var)
|
|
|
|
{
|
2003-10-24 16:28:32 +02:00
|
|
|
thd->set_time((time_t) var->save_result.ulonglong_value);
|
2002-07-23 17:31:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_timestamp::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
thd->user_time=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type,
|
2003-07-06 18:09:57 +02:00
|
|
|
LEX_STRING *base)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
thd->sys_var_tmp.long_value= (long) thd->start_time;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &thd->sys_var_tmp.long_value;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
|
|
|
|
{
|
WL#3146 "less locking in auto_increment":
this is a cleanup patch for our current auto_increment handling:
new names for auto_increment variables in THD, new methods to manipulate them
(see sql_class.h), some move into handler::, causing less backup/restore
work when executing substatements.
This makes the logic hopefully clearer, less work is is needed in
mysql_insert().
By cleaning up, using different variables for different purposes (instead
of one for 3 things...), we fix those bugs, which someone may want to fix
in 5.0 too:
BUG#20339 "stored procedure using LAST_INSERT_ID() does not replicate
statement-based"
BUG#20341 "stored function inserting into one auto_increment puts bad
data in slave"
BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY UPDATE"
(now if a row is updated, LAST_INSERT_ID() will return its id)
and re-fixes:
BUG#6880 "LAST_INSERT_ID() value changes during multi-row INSERT"
(already fixed differently by Ramil in 4.1)
Test of documented behaviour of mysql_insert_id() (there was no test).
The behaviour changes introduced are:
- LAST_INSERT_ID() now returns "the first autogenerated auto_increment value
successfully inserted", instead of "the first autogenerated auto_increment
value if any row was successfully inserted", see auto_increment.test.
Same for mysql_insert_id(), see mysql_client_test.c.
- LAST_INSERT_ID() returns the id of the updated row if ON DUPLICATE KEY
UPDATE, see auto_increment.test. Same for mysql_insert_id(), see
mysql_client_test.c.
- LAST_INSERT_ID() does not change if no autogenerated value was successfully
inserted (it used to then be 0), see auto_increment.test.
- if in INSERT SELECT no autogenerated value was successfully inserted,
mysql_insert_id() now returns the id of the last inserted row (it already
did this for INSERT VALUES), see mysql_client_test.c.
- if INSERT SELECT uses LAST_INSERT_ID(X), mysql_insert_id() now returns X
(it already did this for INSERT VALUES), see mysql_client_test.c.
- NDB now behaves like other engines wrt SET INSERT_ID: with INSERT IGNORE,
the id passed in SET INSERT_ID is re-used until a row succeeds; SET INSERT_ID
influences not only the first row now.
Additionally, when unlocking a table we check that the thread is not keeping
a next_insert_id (as the table is unlocked that id is potentially out-of-date);
forgetting about this next_insert_id is done in a new
handler::ha_release_auto_increment().
Finally we prepare for engines capable of reserving finite-length intervals
of auto_increment values: we store such intervals in THD. The next step
(to be done by the replication team in 5.1) is to read those intervals from
THD and actually store them in the statement-based binary log. NDB
will be a good engine to test that.
2006-07-09 17:52:19 +02:00
|
|
|
thd->first_successful_insert_id_in_prev_stmt=
|
|
|
|
var->save_result.ulonglong_value;
|
2002-07-23 17:31:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type,
|
2003-07-06 18:09:57 +02:00
|
|
|
LEX_STRING *base)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
WL#3146 "less locking in auto_increment":
this is a cleanup patch for our current auto_increment handling:
new names for auto_increment variables in THD, new methods to manipulate them
(see sql_class.h), some move into handler::, causing less backup/restore
work when executing substatements.
This makes the logic hopefully clearer, less work is is needed in
mysql_insert().
By cleaning up, using different variables for different purposes (instead
of one for 3 things...), we fix those bugs, which someone may want to fix
in 5.0 too:
BUG#20339 "stored procedure using LAST_INSERT_ID() does not replicate
statement-based"
BUG#20341 "stored function inserting into one auto_increment puts bad
data in slave"
BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY UPDATE"
(now if a row is updated, LAST_INSERT_ID() will return its id)
and re-fixes:
BUG#6880 "LAST_INSERT_ID() value changes during multi-row INSERT"
(already fixed differently by Ramil in 4.1)
Test of documented behaviour of mysql_insert_id() (there was no test).
The behaviour changes introduced are:
- LAST_INSERT_ID() now returns "the first autogenerated auto_increment value
successfully inserted", instead of "the first autogenerated auto_increment
value if any row was successfully inserted", see auto_increment.test.
Same for mysql_insert_id(), see mysql_client_test.c.
- LAST_INSERT_ID() returns the id of the updated row if ON DUPLICATE KEY
UPDATE, see auto_increment.test. Same for mysql_insert_id(), see
mysql_client_test.c.
- LAST_INSERT_ID() does not change if no autogenerated value was successfully
inserted (it used to then be 0), see auto_increment.test.
- if in INSERT SELECT no autogenerated value was successfully inserted,
mysql_insert_id() now returns the id of the last inserted row (it already
did this for INSERT VALUES), see mysql_client_test.c.
- if INSERT SELECT uses LAST_INSERT_ID(X), mysql_insert_id() now returns X
(it already did this for INSERT VALUES), see mysql_client_test.c.
- NDB now behaves like other engines wrt SET INSERT_ID: with INSERT IGNORE,
the id passed in SET INSERT_ID is re-used until a row succeeds; SET INSERT_ID
influences not only the first row now.
Additionally, when unlocking a table we check that the thread is not keeping
a next_insert_id (as the table is unlocked that id is potentially out-of-date);
forgetting about this next_insert_id is done in a new
handler::ha_release_auto_increment().
Finally we prepare for engines capable of reserving finite-length intervals
of auto_increment values: we store such intervals in THD. The next step
(to be done by the replication team in 5.1) is to read those intervals from
THD and actually store them in the statement-based binary log. NDB
will be a good engine to test that.
2006-07-09 17:52:19 +02:00
|
|
|
/*
|
|
|
|
this tmp var makes it robust againt change of type of
|
|
|
|
read_first_successful_insert_id_in_prev_stmt().
|
|
|
|
*/
|
|
|
|
thd->sys_var_tmp.ulonglong_value=
|
|
|
|
thd->read_first_successful_insert_id_in_prev_stmt();
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_insert_id::update(THD *thd, set_var *var)
|
|
|
|
{
|
WL#3146 "less locking in auto_increment":
this is a cleanup patch for our current auto_increment handling:
new names for auto_increment variables in THD, new methods to manipulate them
(see sql_class.h), some move into handler::, causing less backup/restore
work when executing substatements.
This makes the logic hopefully clearer, less work is is needed in
mysql_insert().
By cleaning up, using different variables for different purposes (instead
of one for 3 things...), we fix those bugs, which someone may want to fix
in 5.0 too:
BUG#20339 "stored procedure using LAST_INSERT_ID() does not replicate
statement-based"
BUG#20341 "stored function inserting into one auto_increment puts bad
data in slave"
BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY UPDATE"
(now if a row is updated, LAST_INSERT_ID() will return its id)
and re-fixes:
BUG#6880 "LAST_INSERT_ID() value changes during multi-row INSERT"
(already fixed differently by Ramil in 4.1)
Test of documented behaviour of mysql_insert_id() (there was no test).
The behaviour changes introduced are:
- LAST_INSERT_ID() now returns "the first autogenerated auto_increment value
successfully inserted", instead of "the first autogenerated auto_increment
value if any row was successfully inserted", see auto_increment.test.
Same for mysql_insert_id(), see mysql_client_test.c.
- LAST_INSERT_ID() returns the id of the updated row if ON DUPLICATE KEY
UPDATE, see auto_increment.test. Same for mysql_insert_id(), see
mysql_client_test.c.
- LAST_INSERT_ID() does not change if no autogenerated value was successfully
inserted (it used to then be 0), see auto_increment.test.
- if in INSERT SELECT no autogenerated value was successfully inserted,
mysql_insert_id() now returns the id of the last inserted row (it already
did this for INSERT VALUES), see mysql_client_test.c.
- if INSERT SELECT uses LAST_INSERT_ID(X), mysql_insert_id() now returns X
(it already did this for INSERT VALUES), see mysql_client_test.c.
- NDB now behaves like other engines wrt SET INSERT_ID: with INSERT IGNORE,
the id passed in SET INSERT_ID is re-used until a row succeeds; SET INSERT_ID
influences not only the first row now.
Additionally, when unlocking a table we check that the thread is not keeping
a next_insert_id (as the table is unlocked that id is potentially out-of-date);
forgetting about this next_insert_id is done in a new
handler::ha_release_auto_increment().
Finally we prepare for engines capable of reserving finite-length intervals
of auto_increment values: we store such intervals in THD. The next step
(to be done by the replication team in 5.1) is to read those intervals from
THD and actually store them in the statement-based binary log. NDB
will be a good engine to test that.
2006-07-09 17:52:19 +02:00
|
|
|
thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
|
2002-07-23 17:31:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type,
|
2003-07-06 18:09:57 +02:00
|
|
|
LEX_STRING *base)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
WL#3146 "less locking in auto_increment":
this is a cleanup patch for our current auto_increment handling:
new names for auto_increment variables in THD, new methods to manipulate them
(see sql_class.h), some move into handler::, causing less backup/restore
work when executing substatements.
This makes the logic hopefully clearer, less work is is needed in
mysql_insert().
By cleaning up, using different variables for different purposes (instead
of one for 3 things...), we fix those bugs, which someone may want to fix
in 5.0 too:
BUG#20339 "stored procedure using LAST_INSERT_ID() does not replicate
statement-based"
BUG#20341 "stored function inserting into one auto_increment puts bad
data in slave"
BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY UPDATE"
(now if a row is updated, LAST_INSERT_ID() will return its id)
and re-fixes:
BUG#6880 "LAST_INSERT_ID() value changes during multi-row INSERT"
(already fixed differently by Ramil in 4.1)
Test of documented behaviour of mysql_insert_id() (there was no test).
The behaviour changes introduced are:
- LAST_INSERT_ID() now returns "the first autogenerated auto_increment value
successfully inserted", instead of "the first autogenerated auto_increment
value if any row was successfully inserted", see auto_increment.test.
Same for mysql_insert_id(), see mysql_client_test.c.
- LAST_INSERT_ID() returns the id of the updated row if ON DUPLICATE KEY
UPDATE, see auto_increment.test. Same for mysql_insert_id(), see
mysql_client_test.c.
- LAST_INSERT_ID() does not change if no autogenerated value was successfully
inserted (it used to then be 0), see auto_increment.test.
- if in INSERT SELECT no autogenerated value was successfully inserted,
mysql_insert_id() now returns the id of the last inserted row (it already
did this for INSERT VALUES), see mysql_client_test.c.
- if INSERT SELECT uses LAST_INSERT_ID(X), mysql_insert_id() now returns X
(it already did this for INSERT VALUES), see mysql_client_test.c.
- NDB now behaves like other engines wrt SET INSERT_ID: with INSERT IGNORE,
the id passed in SET INSERT_ID is re-used until a row succeeds; SET INSERT_ID
influences not only the first row now.
Additionally, when unlocking a table we check that the thread is not keeping
a next_insert_id (as the table is unlocked that id is potentially out-of-date);
forgetting about this next_insert_id is done in a new
handler::ha_release_auto_increment().
Finally we prepare for engines capable of reserving finite-length intervals
of auto_increment values: we store such intervals in THD. The next step
(to be done by the replication team in 5.1) is to read those intervals from
THD and actually store them in the statement-based binary log. NDB
will be a good engine to test that.
2006-07-09 17:52:19 +02:00
|
|
|
thd->sys_var_tmp.ulonglong_value=
|
|
|
|
thd->auto_inc_intervals_forced.minimum();
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2004-06-10 15:56:13 +02:00
|
|
|
|
|
|
|
|
2002-11-07 03:02:37 +01:00
|
|
|
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
|
|
|
|
{
|
2003-10-24 16:28:32 +02:00
|
|
|
thd->rand.seed1= (ulong) var->save_result.ulonglong_value;
|
2002-11-07 03:02:37 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
|
|
|
|
{
|
2003-10-24 16:28:32 +02:00
|
|
|
thd->rand.seed2= (ulong) var->save_result.ulonglong_value;
|
2002-11-07 03:02:37 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-18 08:11:31 +02:00
|
|
|
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
|
|
|
|
{
|
2005-04-05 13:17:49 +02:00
|
|
|
char buff[MAX_TIME_ZONE_NAME_LENGTH];
|
2004-06-18 08:11:31 +02:00
|
|
|
String str(buff, sizeof(buff), &my_charset_latin1);
|
|
|
|
String *res= var->value->val_str(&str);
|
|
|
|
|
BUG#9953: CONVERT_TZ requires mysql.time_zone_name to be locked
The problem was that some facilities (like CONVERT_TZ() function or
server HELP statement) may require implicit access to some tables in
'mysql' database. This access was done by ordinary means of adding
such tables to the list of tables the query is going to open.
However, if we issued LOCK TABLES before that, we would get "table
was not locked" error trying to open such implicit tables.
The solution is to treat certain tables as MySQL system tables, like
we already do for mysql.proc. Such tables may be opened for reading
at any moment regardless of any locks in effect. The cost of this is
that system table may be locked for writing only together with other
system tables, it is disallowed to lock system tables for writing and
have any other lock on any other table.
After this patch the following tables are treated as MySQL system
tables:
mysql.help_category
mysql.help_keyword
mysql.help_relation
mysql.help_topic
mysql.proc (it already was)
mysql.time_zone
mysql.time_zone_leap_second
mysql.time_zone_name
mysql.time_zone_transition
mysql.time_zone_transition_type
These tables are now opened with open_system_tables_for_read() and
closed with close_system_tables(), or one table may be opened with
open_system_table_for_update() and closed with close_thread_tables()
(the latter is used for mysql.proc table, which is updated as part of
normal MySQL server operation). These functions may be used when
some tables were opened and locked already.
NOTE: online update of time zone tables is not possible during
replication, because there's no time zone cache flush neither on LOCK
TABLES, nor on FLUSH TABLES, so the master may serve stale time zone
data from cache, while on slave updated data will be loaded from the
time zone tables.
2007-03-09 11:12:31 +01:00
|
|
|
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
|
2004-06-18 08:11:31 +02:00
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL");
|
2004-06-18 08:11:31 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_thd_time_zone::update(THD *thd, set_var *var)
|
|
|
|
{
|
2005-01-26 20:25:02 +01:00
|
|
|
/* We are using Time_zone object found during check() phase. */
|
|
|
|
if (var->type == OPT_GLOBAL)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
global_system_variables.time_zone= var->save_result.time_zone;
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
thd->variables.time_zone= var->save_result.time_zone;
|
2004-06-18 08:11:31 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
|
2004-06-18 08:11:31 +02:00
|
|
|
LEX_STRING *base)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
We can use ptr() instead of c_ptr() here because String contaning
|
|
|
|
time zone name is guaranteed to be zero ended.
|
|
|
|
*/
|
|
|
|
if (type == OPT_GLOBAL)
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
|
2004-06-18 08:11:31 +02:00
|
|
|
else
|
2005-03-22 00:26:12 +01:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
This is an ugly fix for replication: we don't replicate properly queries
|
|
|
|
invoking system variables' values to update tables; but
|
|
|
|
CONVERT_TZ(,,@@session.time_zone) is so popular that we make it
|
|
|
|
replicable (i.e. we tell the binlog code to store the session
|
|
|
|
timezone). If it's the global value which was used we can't replicate
|
|
|
|
(binlog code stores session value only).
|
|
|
|
*/
|
|
|
|
thd->time_zone_used= 1;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar *)(thd->variables.time_zone->get_name()->ptr());
|
2005-03-22 00:26:12 +01:00
|
|
|
}
|
2004-06-18 08:11:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_thd_time_zone::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
2005-01-26 20:25:02 +01:00
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2004-06-18 08:11:31 +02:00
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
{
|
|
|
|
if (default_tz_name)
|
|
|
|
{
|
|
|
|
String str(default_tz_name, &my_charset_latin1);
|
2005-01-26 20:25:02 +01:00
|
|
|
/*
|
|
|
|
We are guaranteed to find this time zone since its existence
|
|
|
|
is checked during start-up.
|
|
|
|
*/
|
BUG#9953: CONVERT_TZ requires mysql.time_zone_name to be locked
The problem was that some facilities (like CONVERT_TZ() function or
server HELP statement) may require implicit access to some tables in
'mysql' database. This access was done by ordinary means of adding
such tables to the list of tables the query is going to open.
However, if we issued LOCK TABLES before that, we would get "table
was not locked" error trying to open such implicit tables.
The solution is to treat certain tables as MySQL system tables, like
we already do for mysql.proc. Such tables may be opened for reading
at any moment regardless of any locks in effect. The cost of this is
that system table may be locked for writing only together with other
system tables, it is disallowed to lock system tables for writing and
have any other lock on any other table.
After this patch the following tables are treated as MySQL system
tables:
mysql.help_category
mysql.help_keyword
mysql.help_relation
mysql.help_topic
mysql.proc (it already was)
mysql.time_zone
mysql.time_zone_leap_second
mysql.time_zone_name
mysql.time_zone_transition
mysql.time_zone_transition_type
These tables are now opened with open_system_tables_for_read() and
closed with close_system_tables(), or one table may be opened with
open_system_table_for_update() and closed with close_thread_tables()
(the latter is used for mysql.proc table, which is updated as part of
normal MySQL server operation). These functions may be used when
some tables were opened and locked already.
NOTE: online update of time zone tables is not possible during
replication, because there's no time zone cache flush neither on LOCK
TABLES, nor on FLUSH TABLES, so the master may serve stale time zone
data from cache, while on slave updated data will be loaded from the
time zone tables.
2007-03-09 11:12:31 +01:00
|
|
|
global_system_variables.time_zone= my_tz_find(thd, &str);
|
2004-06-18 08:11:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
global_system_variables.time_zone= my_tz_SYSTEM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
thd->variables.time_zone= global_system_variables.time_zone;
|
2005-01-26 20:25:02 +01:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
2004-06-18 08:11:31 +02:00
|
|
|
}
|
|
|
|
|
2004-12-29 18:30:37 +01:00
|
|
|
|
|
|
|
bool sys_var_max_user_conn::check(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
if (var->type == OPT_GLOBAL)
|
|
|
|
return sys_var_thd::check(thd, var);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Per-session values of max_user_connections can't be set directly.
|
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),
- New optional handler function introduced: reset()
This is called after every DML statement to make it easy for a handler to
statement specific cleanups.
(The only case it's not called is if force the file to be closed)
- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
should be moved to handler::reset()
- table->read_set contains a bitmap over all columns that are needed
in the query. read_row() and similar functions only needs to read these
columns
- table->write_set contains a bitmap over all columns that will be updated
in the query. write_row() and update_row() only needs to update these
columns.
The above bitmaps should now be up to date in all context
(including ALTER TABLE, filesort()).
The handler is informed of any changes to the bitmap after
fix_fields() by calling the virtual function
handler::column_bitmaps_signal(). If the handler does caching of
these bitmaps (instead of using table->read_set, table->write_set),
it should redo the caching in this code. as the signal() may be sent
several times, it's probably best to set a variable in the signal
and redo the caching on read_row() / write_row() if the variable was
set.
- Removed the read_set and write_set bitmap objects from the handler class
- Removed all column bit handling functions from the handler class.
(Now one instead uses the normal bitmap functions in my_bitmap.c instead
of handler dedicated bitmap functions)
- field->query_id is removed. One should instead instead check
table->read_set and table->write_set if a field is used in the query.
- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
instead use table->read_set to check for which columns to retrieve.
- If a handler needs to call Field->val() or Field->store() on columns
that are not used in the query, one should install a temporary
all-columns-used map while doing so. For this, we provide the following
functions:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
field->val();
dbug_tmp_restore_column_map(table->read_set, old_map);
and similar for the write map:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
field->val();
dbug_tmp_restore_column_map(table->write_set, old_map);
If this is not done, you will sooner or later hit a DBUG_ASSERT
in the field store() / val() functions.
(For not DBUG binaries, the dbug_tmp_restore_column_map() and
dbug_tmp_restore_column_map() are inline dummy functions and should
be optimized away be the compiler).
- If one needs to temporary set the column map for all binaries (and not
just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
methods) one should use the functions tmp_use_all_columns() and
tmp_restore_column_map() instead of the above dbug_ variants.
- All 'status' fields in the handler base class (like records,
data_file_length etc) are now stored in a 'stats' struct. This makes
it easier to know what status variables are provided by the base
handler. This requires some trivial variable names in the extra()
function.
- New virtual function handler::records(). This is called to optimize
COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
(stats.records is not supposed to be an exact value. It's only has to
be 'reasonable enough' for the optimizer to be able to choose a good
optimization path).
- Non virtual handler::init() function added for caching of virtual
constants from engine.
- Removed has_transactions() virtual method. Now one should instead return
HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
transactions.
- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
that is to be used with 'new handler_name()' to allocate the handler
in the right area. The xxxx_create_handler() function is also
responsible for any initialization of the object before returning.
For example, one should change:
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
->
static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
{
return new (mem_root) ha_myisam(table);
}
- New optional virtual function: use_hidden_primary_key().
This is called in case of an update/delete when
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
but we don't have a primary key. This allows the handler to take precisions
in remembering any hidden primary key to able to update/delete any
found row. The default handler marks all columns to be read.
- handler::table_flags() now returns a ulonglong (to allow for more flags).
- New/changed table_flags()
- HA_HAS_RECORDS Set if ::records() is supported
- HA_NO_TRANSACTIONS Set if engine doesn't support transactions
- HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
Set if we should mark all primary key columns for
read when reading rows as part of a DELETE
statement. If there is no primary key,
all columns are marked for read.
- HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some
cases (based on table->read_set)
- HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- HA_DUPP_POS Renamed to HA_DUPLICATE_POS
- HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
Set this if we should mark ALL key columns for
read when when reading rows as part of a DELETE
statement. In case of an update we will mark
all keys for read for which key part changed
value.
- HA_STATS_RECORDS_IS_EXACT
Set this if stats.records is exact.
(This saves us some extra records() calls
when optimizing COUNT(*))
- Removed table_flags()
- HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if
handler::records() gives an exact count() and
HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
- HA_READ_RND_SAME Removed (no one supported this one)
- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()
- Renamed handler::dupp_pos to handler::dup_pos
- Removed not used variable handler::sortkey
Upper level handler changes:
- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
cache is updated on engine creation time and updated on open.
MySQL level changes (not obvious from the above):
- DBUG_ASSERT() added to check that column usage matches what is set
in the column usage bit maps. (This found a LOT of bugs in current
column marking code).
- In 5.1 before, all used columns was marked in read_set and only updated
columns was marked in write_set. Now we only mark columns for which we
need a value in read_set.
- Column bitmaps are created in open_binary_frm() and open_table_from_share().
(Before this was in table.cc)
- handler::table_flags() calls are replaced with handler::ha_table_flags()
- For calling field->val() you must have the corresponding bit set in
table->read_set. For calling field->store() you must have the
corresponding bit set in table->write_set. (There are asserts in
all store()/val() functions to catch wrong usage)
- thd->set_query_id is renamed to thd->mark_used_columns and instead
of setting this to an integer value, this has now the values:
MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
Changed also all variables named 'set_query_id' to mark_used_columns.
- In filesort() we now inform the handler of exactly which columns are needed
doing the sort and choosing the rows.
- The TABLE_SHARE object has a 'all_set' column bitmap one can use
when one needs a column bitmap with all columns set.
(This is used for table->use_all_columns() and other places)
- The TABLE object has 3 column bitmaps:
- def_read_set Default bitmap for columns to be read
- def_write_set Default bitmap for columns to be written
- tmp_set Can be used as a temporary bitmap when needed.
The table object has also two pointer to bitmaps read_set and write_set
that the handler should use to find out which columns are used in which way.
- count() optimization now calls handler::records() instead of using
handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).
- Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
- Added TABLE parameter to cp_buffer_from_ref()
- Don't close tables created with CREATE ... SELECT but keep them in
the table cache. (Faster usage of newly created tables).
New interfaces:
- table->clear_column_bitmaps() to initialize the bitmaps for tables
at start of new statements.
- table->column_bitmaps_set() to set up new column bitmaps and signal
the handler about this.
- table->column_bitmaps_set_no_signal() for some few cases where we need
to setup new column bitmaps but don't signal the handler (as the handler
has already been signaled about these before). Used for the momement
only in opt_range.cc when doing ROR scans.
- table->use_all_columns() to install a bitmap where all columns are marked
as use in the read and the write set.
- table->default_column_bitmaps() to install the normal read and write
column bitmaps, but not signaling the handler about this.
This is mainly used when creating TABLE instances.
- table->mark_columns_needed_for_delete(),
table->mark_columns_needed_for_delete() and
table->mark_columns_needed_for_insert() to allow us to put additional
columns in column usage maps if handler so requires.
(The handler indicates what it neads in handler->table_flags())
- table->prepare_for_position() to allow us to tell handler that it
needs to read primary key parts to be able to store them in
future table->position() calls.
(This replaces the table->file->ha_retrieve_all_pk function)
- table->mark_auto_increment_column() to tell handler are going to update
columns part of any auto_increment key.
- table->mark_columns_used_by_index() to mark all columns that is part of
an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
it to quickly know that it only needs to read colums that are part
of the key. (The handler can also use the column map for detecting this,
but simpler/faster handler can just monitor the extra() call).
- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
also mark all columns that is used by the given key.
- table->restore_column_maps_after_mark_index() to restore to default
column maps after a call to table->mark_columns_used_by_index().
- New item function register_field_in_read_map(), for marking used columns
in table->read_map. Used by filesort() to mark all used columns
- Maintain in TABLE->merge_keys set of all keys that are used in query.
(Simplices some optimization loops)
- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
but the field in the clustered key is not assumed to be part of all index.
(used in opt_range.cc for faster loops)
- dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
mark all columns as usable. The 'dbug_' version is primarily intended
inside a handler when it wants to just call Field:store() & Field::val()
functions, but don't need the column maps set for any other usage.
(ie:: bitmap_is_set() is never called)
- We can't use compare_records() to skip updates for handlers that returns
a partial column set and the read_set doesn't cover all columns in the
write set. The reason for this is that if we have a column marked only for
write we can't in the MySQL level know if the value changed or not.
The reason this worked before was that MySQL marked all to be written
columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
bug'.
- open_table_from_share() does not anymore setup temporary MEM_ROOT
object as a thread specific variable for the handler. Instead we
send the to-be-used MEMROOT to get_new_handler().
(Simpler, faster code)
Bugs fixed:
- Column marking was not done correctly in a lot of cases.
(ALTER TABLE, when using triggers, auto_increment fields etc)
(Could potentially result in wrong values inserted in table handlers
relying on that the old column maps or field->set_query_id was correct)
Especially when it comes to triggers, there may be cases where the
old code would cause lost/wrong values for NDB and/or InnoDB tables.
- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
This allowed me to remove some wrong warnings about:
"Some non-transactional changed tables couldn't be rolled back"
- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
(thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
some warnings about
"Some non-transactional changed tables couldn't be rolled back")
- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
which could cause delete_table to report random failures.
- Fixed core dumps for some tests when running with --debug
- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after
crash)
- slow_logs was not properly initialized, which could maybe cause
extra/lost entries in slow log.
- If we get an duplicate row on insert, change column map to read and
write all columns while retrying the operation. This is required by
the definition of REPLACE and also ensures that fields that are only
part of UPDATE are properly handled. This fixed a bug in NDB and
REPLACE where REPLACE wrongly copied some column values from the replaced
row.
- For table handler that doesn't support NULL in keys, we would give an error
when creating a primary key with NULL fields, even after the fields has been
automaticly converted to NOT NULL.
- Creating a primary key on a SPATIAL key, would fail if field was not
declared as NOT NULL.
Cleanups:
- Removed not used condition argument to setup_tables
- Removed not needed item function reset_query_id_processor().
- Field->add_index is removed. Now this is instead maintained in
(field->flags & FIELD_IN_ADD_INDEX)
- Field->fieldnr is removed (use field->field_index instead)
- New argument to filesort() to indicate that it should return a set of
row pointers (not used columns). This allowed me to remove some references
to sql_command in filesort and should also enable us to return column
results in some cases where we couldn't before.
- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
bitmap, which allowed me to use bitmap functions instead of looping over
all fields to create some needed bitmaps. (Faster and smaller code)
- Broke up found too long lines
- Moved some variable declaration at start of function for better code
readability.
- Removed some not used arguments from functions.
(setup_fields(), mysql_prepare_insert_check_table())
- setup_fields() now takes an enum instead of an int for marking columns
usage.
- For internal temporary tables, use handler::write_row(),
handler::delete_row() and handler::update_row() instead of
handler::ha_xxxx() for faster execution.
- Changed some constants to enum's and define's.
- Using separate column read and write sets allows for easier checking
of timestamp field was set by statement.
- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()
- Don't build table->normalized_path as this is now identical to table->path
(after bar's fixes to convert filenames)
- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
do comparision with the 'convert-dbug-for-diff' tool.
Things left to do in 5.1:
- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
Mats has promised to look into this.
- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
(I added several test cases for this, but in this case it's better that
someone else also tests this throughly).
Lars has promosed to do this.
2006-06-04 17:52:22 +02:00
|
|
|
May be we should have a separate error message for this?
|
2004-12-29 18:30:37 +01:00
|
|
|
*/
|
|
|
|
my_error(ER_GLOBAL_VARIABLE, MYF(0), name);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sys_var_max_user_conn::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(var->type == OPT_GLOBAL);
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
2005-03-19 01:12:25 +01:00
|
|
|
max_user_connections= (uint)var->save_result.ulonglong_value;
|
2004-12-29 18:30:37 +01:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_max_user_conn::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(type == OPT_GLOBAL);
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
max_user_connections= (ulong) option_limits->def_value;
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
|
2004-12-29 18:30:37 +01:00
|
|
|
LEX_STRING *base)
|
|
|
|
{
|
|
|
|
if (type != OPT_GLOBAL &&
|
|
|
|
thd->user_connect && thd->user_connect->user_resources.user_conn)
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &(thd->user_connect->user_resources.user_conn);
|
|
|
|
return (uchar*) &(max_user_connections);
|
2004-12-29 18:30:37 +01:00
|
|
|
}
|
|
|
|
|
2006-12-05 11:08:19 +01:00
|
|
|
|
2006-07-04 14:40:40 +02:00
|
|
|
bool sys_var_thd_lc_time_names::check(THD *thd, set_var *var)
|
|
|
|
{
|
2006-12-05 10:45:21 +01:00
|
|
|
MY_LOCALE *locale_match;
|
2006-07-04 14:40:40 +02:00
|
|
|
|
2006-12-05 10:45:21 +01:00
|
|
|
if (var->value->result_type() == INT_RESULT)
|
2006-07-04 14:40:40 +02:00
|
|
|
{
|
2006-12-05 10:45:21 +01:00
|
|
|
if (!(locale_match= my_locale_by_number((uint) var->value->val_int())))
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
int10_to_str((int) var->value->val_int(), buf, -10);
|
|
|
|
my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), buf);
|
|
|
|
return 1;
|
|
|
|
}
|
2006-07-04 14:40:40 +02:00
|
|
|
}
|
2006-12-05 10:45:21 +01:00
|
|
|
else // STRING_RESULT
|
2006-07-04 14:40:40 +02:00
|
|
|
{
|
2006-12-05 10:45:21 +01:00
|
|
|
char buff[6];
|
|
|
|
String str(buff, sizeof(buff), &my_charset_latin1), *res;
|
|
|
|
if (!(res=var->value->val_str(&str)))
|
|
|
|
{
|
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
const char *locale_str= res->c_ptr();
|
|
|
|
if (!(locale_match= my_locale_by_name(locale_str)))
|
|
|
|
{
|
|
|
|
my_printf_error(ER_UNKNOWN_ERROR,
|
|
|
|
"Unknown locale: '%s'", MYF(0), locale_str);
|
|
|
|
return 1;
|
|
|
|
}
|
2006-07-04 14:40:40 +02:00
|
|
|
}
|
2006-12-05 10:45:21 +01:00
|
|
|
|
2006-07-08 00:30:07 +02:00
|
|
|
var->save_result.locale_value= locale_match;
|
|
|
|
return 0;
|
2006-07-04 14:40:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_thd_lc_time_names::update(THD *thd, set_var *var)
|
|
|
|
{
|
2007-04-09 14:58:56 +02:00
|
|
|
if (var->type == OPT_GLOBAL)
|
|
|
|
global_system_variables.lc_time_names= var->save_result.locale_value;
|
|
|
|
else
|
|
|
|
thd->variables.lc_time_names= var->save_result.locale_value;
|
2006-07-04 14:40:40 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd, enum_var_type type,
|
2006-07-04 14:40:40 +02:00
|
|
|
LEX_STRING *base)
|
|
|
|
{
|
2007-04-09 14:58:56 +02:00
|
|
|
return type == OPT_GLOBAL ?
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
(uchar *) global_system_variables.lc_time_names->name :
|
|
|
|
(uchar *) thd->variables.lc_time_names->name;
|
2006-07-04 14:40:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_thd_lc_time_names::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
2007-04-09 14:58:56 +02:00
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
global_system_variables.lc_time_names= my_default_lc_time_names;
|
|
|
|
else
|
|
|
|
thd->variables.lc_time_names= global_system_variables.lc_time_names;
|
2006-07-04 14:40:40 +02:00
|
|
|
}
|
2004-12-29 18:30:37 +01:00
|
|
|
|
2007-07-30 10:33:50 +02:00
|
|
|
/*
|
|
|
|
Handling of microseoncds given as seconds.part_seconds
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
The argument to long query time is in seconds in decimal
|
|
|
|
which is converted to ulonglong integer holding microseconds for storage.
|
|
|
|
This is used for handling long_query_time
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool sys_var_microseconds::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
double num= var->value->val_real();
|
|
|
|
longlong microseconds;
|
|
|
|
if (num > (double) option_limits->max_value)
|
|
|
|
num= (double) option_limits->max_value;
|
|
|
|
if (num < (double) option_limits->min_value)
|
|
|
|
num= (double) option_limits->min_value;
|
|
|
|
microseconds= (longlong) (num * 1000000.0 + 0.5);
|
|
|
|
if (var->type == OPT_GLOBAL)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
(global_system_variables.*offset)= microseconds;
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
thd->variables.*offset= microseconds;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_microseconds::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
longlong microseconds= (longlong) (option_limits->def_value * 1000000.0);
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
global_system_variables.*offset= microseconds;
|
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
thd->variables.*offset= microseconds;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
|
|
|
|
LEX_STRING *base)
|
|
|
|
{
|
|
|
|
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
|
|
|
|
global_system_variables.*offset :
|
|
|
|
thd->variables.*offset) / 1000000.0;
|
|
|
|
return (uchar*) &thd->tmp_double_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/*
|
|
|
|
Functions to update thd->options bits
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool set_option_bit(THD *thd, set_var *var)
|
|
|
|
{
|
2002-08-08 02:12:02 +02:00
|
|
|
sys_var_thd_bit *sys_var= ((sys_var_thd_bit*) var->var);
|
|
|
|
if ((var->save_result.ulong_value != 0) == sys_var->reverse)
|
|
|
|
thd->options&= ~sys_var->bit_flag;
|
2002-07-23 17:31:22 +02:00
|
|
|
else
|
2002-08-08 02:12:02 +02:00
|
|
|
thd->options|= sys_var->bit_flag;
|
2002-07-23 17:31:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool set_option_autocommit(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
/* The test is negative as the flag we use is NOT autocommit */
|
|
|
|
|
2006-11-30 02:40:42 +01:00
|
|
|
ulonglong org_options= thd->options;
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
if (var->save_result.ulong_value != 0)
|
|
|
|
thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
|
|
|
|
else
|
|
|
|
thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag;
|
|
|
|
|
|
|
|
if ((org_options ^ thd->options) & OPTION_NOT_AUTOCOMMIT)
|
|
|
|
{
|
|
|
|
if ((org_options & OPTION_NOT_AUTOCOMMIT))
|
|
|
|
{
|
|
|
|
/* We changed to auto_commit mode */
|
2007-03-29 20:11:17 +02:00
|
|
|
thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG);
|
2007-07-30 17:27:36 +02:00
|
|
|
thd->transaction.all.modified_non_trans_table= FALSE;
|
2002-07-23 17:31:22 +02:00
|
|
|
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
|
|
|
|
if (ha_commit(thd))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-07-30 17:27:36 +02:00
|
|
|
thd->transaction.all.modified_non_trans_table= FALSE;
|
2002-07-23 17:31:22 +02:00
|
|
|
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-04-28 12:08:54 +02:00
|
|
|
static int check_log_update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2005-09-15 21:29:07 +02:00
|
|
|
if (!(thd->security_ctx->master_access & SUPER_ACL))
|
2004-04-28 12:08:54 +02:00
|
|
|
{
|
|
|
|
my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
static bool set_log_update(THD *thd, set_var *var)
|
|
|
|
{
|
2003-04-02 00:15:20 +02:00
|
|
|
/*
|
|
|
|
The update log is not supported anymore since 5.0.
|
|
|
|
See sql/mysqld.cc/, comments in function init_server_components() for an
|
|
|
|
explaination of the different warnings we send below
|
|
|
|
*/
|
2006-03-01 21:36:05 +01:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
if (opt_sql_bin_update)
|
2003-04-02 00:15:20 +02:00
|
|
|
{
|
|
|
|
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
|
|
|
ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
|
|
|
|
ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
|
|
|
ER_UPDATE_LOG_DEPRECATED_IGNORED,
|
|
|
|
ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
|
2002-07-23 17:31:22 +02:00
|
|
|
set_option_bit(thd, var);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-28 12:08:54 +02:00
|
|
|
static int check_pseudo_thread_id(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
var->save_result.ulonglong_value= var->value->val_int();
|
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2005-09-15 21:29:07 +02:00
|
|
|
if (thd->security_ctx->master_access & SUPER_ACL)
|
2004-04-28 12:08:54 +02:00
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
2003-04-02 00:15:20 +02:00
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
static uchar *get_warning_count(THD *thd)
|
2002-10-02 12:33:08 +02:00
|
|
|
{
|
|
|
|
thd->sys_var_tmp.long_value=
|
|
|
|
(thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
|
2006-10-04 16:49:39 +02:00
|
|
|
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
|
2002-10-02 12:33:08 +02:00
|
|
|
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &thd->sys_var_tmp.long_value;
|
2002-10-02 12:33:08 +02:00
|
|
|
}
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
static uchar *get_error_count(THD *thd)
|
2002-10-02 12:33:08 +02:00
|
|
|
{
|
|
|
|
thd->sys_var_tmp.long_value=
|
|
|
|
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) &thd->sys_var_tmp.long_value;
|
2002-10-02 12:33:08 +02:00
|
|
|
}
|
|
|
|
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Get the tmpdir that was specified or chosen by default.
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
This is necessary because if the user does not specify a temporary
|
|
|
|
directory via the command line, one is chosen based on the environment
|
|
|
|
or system defaults. But we can't just always use mysql_tmpdir, because
|
|
|
|
that is actually a call to my_tmpdir() which cycles among possible
|
|
|
|
temporary directories.
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param thd thread handle
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
ptr pointer to NUL-terminated string
|
2007-10-11 20:37:45 +02:00
|
|
|
*/
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
static uchar *get_tmpdir(THD *thd)
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
{
|
|
|
|
if (opt_mysql_tmpdir)
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar *)opt_mysql_tmpdir;
|
|
|
|
return (uchar*)mysql_tmpdir;
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
2006-05-09 01:38:45 +02:00
|
|
|
}
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/****************************************************************************
|
|
|
|
Main handling of variables:
|
|
|
|
- Initialisation
|
|
|
|
- Searching during parsing
|
|
|
|
- Update loop
|
|
|
|
****************************************************************************/
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Find variable name in option my_getopt structure used for
|
|
|
|
command line args.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param opt option structure array to search in
|
|
|
|
@param name variable name
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2002-07-23 17:31:22 +02:00
|
|
|
0 Error
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2002-07-23 17:31:22 +02:00
|
|
|
ptr pointer to option structure
|
|
|
|
*/
|
|
|
|
|
|
|
|
static struct my_option *find_option(struct my_option *opt, const char *name)
|
|
|
|
{
|
|
|
|
uint length=strlen(name);
|
|
|
|
for (; opt->name; opt++)
|
|
|
|
{
|
|
|
|
if (!getopt_compare_strings(opt->name, name, length) &&
|
|
|
|
!opt->name[length])
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Only accept the option if one can set values through it.
|
|
|
|
If not, there is no default value or limits in the option.
|
|
|
|
*/
|
|
|
|
return (opt->value) ? opt : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Return variable name and length for hashing of variables.
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
|
|
|
|
my_bool first)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
*length= var->name_length;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) var->name;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2007-03-02 17:43:45 +01:00
|
|
|
Add variables to the dynamic hash of system variables
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
mysql_add_sys_var_chain()
|
|
|
|
first Pointer to first system variable to add
|
|
|
|
long_opt (optional)command line arguments may be tied for limit checks.
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
0 SUCCESS
|
|
|
|
otherwise FAILURE
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2005-11-06 01:36:40 +01:00
|
|
|
sys_var *var;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
/* A write lock should be held on LOCK_system_variables_hash */
|
|
|
|
|
|
|
|
for (var= first; var; var= var->next)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2005-11-06 01:36:40 +01:00
|
|
|
var->name_length= strlen(var->name);
|
2007-03-02 17:43:45 +01:00
|
|
|
/* this fails if there is a conflicting variable name. see HASH_UNIQUE */
|
2007-05-24 12:24:36 +02:00
|
|
|
if (my_hash_insert(&system_variable_hash, (uchar*) var))
|
2007-03-02 17:43:45 +01:00
|
|
|
goto error;
|
|
|
|
if (long_options)
|
|
|
|
var->option_limits= find_option(long_options, var->name);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
for (; first != var; first= first->next)
|
2007-05-24 12:24:36 +02:00
|
|
|
hash_delete(&system_variable_hash, (uchar*) first);
|
2007-03-02 17:43:45 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2007-05-24 12:24:36 +02:00
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
Remove variables to the dynamic hash of system variables
|
2007-05-24 12:24:36 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
SYNOPSIS
|
|
|
|
mysql_del_sys_var_chain()
|
|
|
|
first Pointer to first system variable to remove
|
2007-05-24 12:24:36 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
RETURN VALUES
|
|
|
|
0 SUCCESS
|
|
|
|
otherwise FAILURE
|
|
|
|
*/
|
2007-05-24 12:24:36 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
int mysql_del_sys_var_chain(sys_var *first)
|
|
|
|
{
|
|
|
|
int result= 0;
|
2007-05-24 12:24:36 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/* A write lock should be held on LOCK_system_variables_hash */
|
2007-05-24 12:24:36 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
for (sys_var *var= first; var; var= var->next)
|
2007-05-24 12:24:36 +02:00
|
|
|
result|= hash_delete(&system_variable_hash, (uchar*) var);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2007-05-24 12:24:36 +02:00
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static int show_cmp(SHOW_VAR *a, SHOW_VAR *b)
|
|
|
|
{
|
|
|
|
return strcmp(a->name, b->name);
|
|
|
|
}
|
2007-05-24 12:24:36 +02:00
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
Constructs an array of system variables for display to the user.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
enumerate_sys_vars()
|
|
|
|
thd current thread
|
|
|
|
sorted If TRUE, the system variables should be sorted
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
pointer Array of SHOW_VAR elements for display
|
|
|
|
NULL FAILURE
|
|
|
|
*/
|
|
|
|
|
|
|
|
SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted)
|
|
|
|
{
|
|
|
|
int count= system_variable_hash.records, i;
|
|
|
|
int fixed_count= fixed_show_vars.elements;
|
|
|
|
int size= sizeof(SHOW_VAR) * (count + fixed_count + 1);
|
|
|
|
SHOW_VAR *result= (SHOW_VAR*) thd->alloc(size);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
SHOW_VAR *show= result + fixed_count;
|
|
|
|
memcpy(result, fixed_show_vars.buffer, fixed_count * sizeof(SHOW_VAR));
|
|
|
|
|
|
|
|
for (i= 0; i < count; i++)
|
|
|
|
{
|
|
|
|
sys_var *var= (sys_var*) hash_element(&system_variable_hash, i);
|
|
|
|
show->name= var->name;
|
|
|
|
show->value= (char*) var;
|
|
|
|
show->type= SHOW_SYS;
|
|
|
|
show++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sort into order */
|
|
|
|
if (sorted)
|
2007-10-18 13:17:21 +02:00
|
|
|
my_qsort(result, count + fixed_count, sizeof(SHOW_VAR),
|
|
|
|
(qsort_cmp) show_cmp);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
/* make last element empty */
|
|
|
|
bzero(show, sizeof(SHOW_VAR));
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Initialize the system variables
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
set_var_init()
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
0 SUCCESS
|
|
|
|
otherwise FAILURE
|
|
|
|
*/
|
|
|
|
|
|
|
|
int set_var_init()
|
|
|
|
{
|
|
|
|
uint count= 0;
|
|
|
|
DBUG_ENTER("set_var_init");
|
|
|
|
|
|
|
|
for (sys_var *var=vars.first; var; var= var->next, count++);
|
|
|
|
|
|
|
|
if (my_init_dynamic_array(&fixed_show_vars, sizeof(SHOW_VAR),
|
|
|
|
FIXED_VARS_SIZE + 64, 64))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
fixed_show_vars.elements= FIXED_VARS_SIZE;
|
|
|
|
memcpy(fixed_show_vars.buffer, fixed_vars, sizeof(fixed_vars));
|
|
|
|
|
|
|
|
if (hash_init(&system_variable_hash, system_charset_info, count, 0,
|
|
|
|
0, (hash_get_key) get_sys_var_length, 0, HASH_UNIQUE))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
vars.last->next= NULL;
|
|
|
|
if (mysql_add_sys_var_chain(vars.first, my_long_options))
|
|
|
|
goto error;
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/*
|
|
|
|
Special cases
|
|
|
|
Needed because MySQL can't find the limits for a variable it it has
|
|
|
|
a different name than the command line option.
|
|
|
|
As these variables are deprecated, this code will disappear soon...
|
|
|
|
*/
|
|
|
|
sys_sql_max_join_size.option_limits= sys_max_join_size.option_limits;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
|
|
|
|
error:
|
|
|
|
fprintf(stderr, "failed to initialize system variables");
|
|
|
|
DBUG_RETURN(1);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void set_var_free()
|
|
|
|
{
|
|
|
|
hash_free(&system_variable_hash);
|
2007-03-02 17:43:45 +01:00
|
|
|
delete_dynamic(&fixed_show_vars);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Add elements to the dynamic list of read-only system variables.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
mysql_append_static_vars()
|
|
|
|
show_vars Pointer to start of array
|
|
|
|
count Number of elements
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
0 SUCCESS
|
|
|
|
otherwise FAILURE
|
|
|
|
*/
|
|
|
|
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count)
|
|
|
|
{
|
|
|
|
for (; count > 0; count--, show_vars++)
|
2007-05-24 18:47:58 +02:00
|
|
|
if (insert_dynamic(&fixed_show_vars, (uchar*) show_vars))
|
2007-03-02 17:43:45 +01:00
|
|
|
return 1;
|
|
|
|
return 0;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Find a user set-table variable.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param str Name of system variable to find
|
|
|
|
@param length Length of variable. zero means that we should use strlen()
|
|
|
|
on the variable
|
|
|
|
@param no_error Refuse to emit an error, even if one occurred.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2002-07-23 17:31:22 +02:00
|
|
|
pointer pointer to variable definitions
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2002-07-23 17:31:22 +02:00
|
|
|
0 Unknown variable (error message is given)
|
|
|
|
*/
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var *intern_find_sys_var(const char *str, uint length, bool no_error)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var *var;
|
|
|
|
|
|
|
|
/*
|
|
|
|
This function is only called from the sql_plugin.cc.
|
|
|
|
A lock on LOCK_system_variable_hash should be held
|
|
|
|
*/
|
|
|
|
var= (sys_var*) hash_search(&system_variable_hash,
|
2007-05-24 12:24:36 +02:00
|
|
|
(uchar*) str, length ? length : strlen(str));
|
2007-03-02 17:43:45 +01:00
|
|
|
if (!(var || no_error))
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Execute update of all variables.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
First run a check of all variables that all updates will go ok.
|
|
|
|
If yes, then execute all updates, returning an error if any one failed.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
This should ensure that in all normal cases none all or variables are
|
|
|
|
updated.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param THD Thread id
|
|
|
|
@param var_list List of variables to update
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2002-07-23 17:31:22 +02:00
|
|
|
0 ok
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2002-09-22 17:02:39 +02:00
|
|
|
1 ERROR, message sent (normally no variables was updated)
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2002-09-22 17:02:39 +02:00
|
|
|
-1 ERROR, message not sent
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int sql_set_variables(THD *thd, List<set_var_base> *var_list)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2004-12-02 13:43:51 +01:00
|
|
|
int error;
|
2003-05-27 17:40:37 +02:00
|
|
|
List_iterator_fast<set_var_base> it(*var_list);
|
2003-08-18 23:08:08 +02:00
|
|
|
DBUG_ENTER("sql_set_variables");
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
set_var_base *var;
|
|
|
|
while ((var=it++))
|
|
|
|
{
|
2004-12-02 13:43:51 +01:00
|
|
|
if ((error= var->check(thd)))
|
2004-11-22 11:05:10 +01:00
|
|
|
goto err;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2007-10-30 18:08:16 +01:00
|
|
|
if (!(error= test(thd->is_error())))
|
2004-11-22 11:05:10 +01:00
|
|
|
{
|
|
|
|
it.rewind();
|
|
|
|
while ((var= it++))
|
|
|
|
error|= var->update(thd); // Returns 0, -1 or 1
|
|
|
|
}
|
2004-12-02 13:43:51 +01:00
|
|
|
|
2004-11-22 11:05:10 +01:00
|
|
|
err:
|
|
|
|
free_underlaid_joins(thd, &thd->lex->select_lex);
|
2003-08-18 23:08:08 +02:00
|
|
|
DBUG_RETURN(error);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Say if all variables set by a SET support the ONE_SHOT keyword
|
|
|
|
(currently, only character set and collation do; later timezones
|
|
|
|
will).
|
2004-06-03 23:17:18 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param var_list List of variables to update
|
2004-06-03 23:17:18 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@note
|
2004-06-03 23:17:18 +02:00
|
|
|
It has a "not_" because it makes faster tests (no need to "!")
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2004-06-03 23:17:18 +02:00
|
|
|
0 all variables of the list support ONE_SHOT
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2004-06-03 23:17:18 +02:00
|
|
|
1 at least one does not support ONE_SHOT
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool not_all_support_one_shot(List<set_var_base> *var_list)
|
|
|
|
{
|
|
|
|
List_iterator_fast<set_var_base> it(*var_list);
|
|
|
|
set_var_base *var;
|
|
|
|
while ((var= it++))
|
|
|
|
{
|
|
|
|
if (var->no_support_one_shot())
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
Functions to handle SET mysql_internal_variable=const_expr
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var::check(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2005-05-13 13:18:27 +02:00
|
|
|
if (var->is_readonly())
|
|
|
|
{
|
|
|
|
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), var->name, "read only");
|
|
|
|
return -1;
|
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
if (var->check_type(type))
|
|
|
|
{
|
2004-11-12 13:34:00 +01:00
|
|
|
int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(err, MYF(0), var->name);
|
2002-09-22 17:02:39 +02:00
|
|
|
return -1;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
if ((type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL)))
|
|
|
|
return 1;
|
|
|
|
/* value is a NULL pointer if we are using SET ... = DEFAULT */
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
if (var->check_default(type))
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_NO_DEFAULT, MYF(0), var->name);
|
2002-09-22 17:02:39 +02:00
|
|
|
return -1;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
if ((!value->fixed &&
|
2005-07-01 06:05:42 +02:00
|
|
|
value->fix_fields(thd, &value)) || value->check_cols(1))
|
2002-09-22 17:02:39 +02:00
|
|
|
return -1;
|
2002-07-23 17:31:22 +02:00
|
|
|
if (var->check_update_type(value->result_type()))
|
|
|
|
{
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name);
|
2002-09-22 17:02:39 +02:00
|
|
|
return -1;
|
2003-10-06 14:11:16 +02:00
|
|
|
}
|
2002-09-22 17:02:39 +02:00
|
|
|
return var->check(thd, this) ? -1 : 0;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Check variable, but without assigning value (used by PS).
|
2004-04-10 00:14:32 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param thd thread handler
|
2004-04-10 00:14:32 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2004-04-10 00:14:32 +02:00
|
|
|
0 ok
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2004-04-10 00:14:32 +02:00
|
|
|
1 ERROR, message sent (normally no variables was updated)
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
-1 ERROR, message not sent
|
2004-04-10 00:14:32 +02:00
|
|
|
*/
|
2004-04-07 23:16:17 +02:00
|
|
|
int set_var::light_check(THD *thd)
|
|
|
|
{
|
|
|
|
if (var->check_type(type))
|
|
|
|
{
|
2004-11-12 13:34:00 +01:00
|
|
|
int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(err, MYF(0), var->name);
|
2004-04-07 23:16:17 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2004-04-10 00:14:32 +02:00
|
|
|
if (type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL))
|
2004-04-07 23:16:17 +02:00
|
|
|
return 1;
|
|
|
|
|
2005-07-01 06:05:42 +02:00
|
|
|
if (value && ((!value->fixed && value->fix_fields(thd, &value)) ||
|
2004-12-14 01:36:19 +01:00
|
|
|
value->check_cols(1)))
|
2004-04-07 23:16:17 +02:00
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-12 11:14:59 +01:00
|
|
|
/**
|
|
|
|
Update variable
|
2004-04-07 23:16:17 +02:00
|
|
|
|
2007-12-12 11:14:59 +01:00
|
|
|
@param thd thread handler
|
|
|
|
@returns 0|1 ok or ERROR
|
|
|
|
|
|
|
|
@note ERROR can be only due to abnormal operations involving
|
|
|
|
the server's execution evironment such as
|
|
|
|
out of memory, hard disk failure or the computer blows up.
|
|
|
|
Consider set_var::check() method if there is a need to return
|
|
|
|
an error due to logics.
|
|
|
|
*/
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var::update(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
if (!value)
|
|
|
|
var->set_default(thd, type);
|
|
|
|
else if (var->update(thd, this))
|
2002-09-22 17:02:39 +02:00
|
|
|
return -1; // should never happen
|
2002-07-23 17:31:22 +02:00
|
|
|
if (var->after_update)
|
|
|
|
(*var->after_update)(thd, type);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
Functions to handle SET @user_variable=const_expr
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var_user::check(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2003-11-02 16:27:35 +01:00
|
|
|
/*
|
|
|
|
Item_func_set_user_var can't substitute something else on its place =>
|
2004-04-28 12:08:54 +02:00
|
|
|
0 can be passed as last argument (reference on item)
|
2003-11-02 16:27:35 +01:00
|
|
|
*/
|
2005-07-01 06:05:42 +02:00
|
|
|
return (user_var_item->fix_fields(thd, (Item**) 0) ||
|
2006-08-22 15:37:41 +02:00
|
|
|
user_var_item->check(0)) ? -1 : 0;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Check variable, but without assigning value (used by PS).
|
2004-04-10 00:14:32 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param thd thread handler
|
2004-04-10 00:14:32 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2004-04-10 00:14:32 +02:00
|
|
|
0 ok
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2004-04-10 00:14:32 +02:00
|
|
|
1 ERROR, message sent (normally no variables was updated)
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
-1 ERROR, message not sent
|
2004-04-10 00:14:32 +02:00
|
|
|
*/
|
2004-04-07 23:16:17 +02:00
|
|
|
int set_var_user::light_check(THD *thd)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Item_func_set_user_var can't substitute something else on its place =>
|
|
|
|
0 can be passed as last argument (reference on item)
|
|
|
|
*/
|
2005-07-01 06:05:42 +02:00
|
|
|
return (user_var_item->fix_fields(thd, (Item**) 0));
|
2004-04-07 23:16:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var_user::update(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
if (user_var_item->update())
|
|
|
|
{
|
|
|
|
/* Give an error if it's not given already */
|
2004-11-12 13:34:00 +01:00
|
|
|
my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), MYF(0));
|
2002-09-22 17:02:39 +02:00
|
|
|
return -1;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
Functions to handle SET PASSWORD
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var_password::check(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2003-09-26 12:33:13 +02:00
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2002-07-23 17:31:22 +02:00
|
|
|
if (!user->host.str)
|
2005-08-23 00:48:50 +02:00
|
|
|
{
|
2005-09-15 21:29:07 +02:00
|
|
|
if (*thd->security_ctx->priv_host != 0)
|
2005-08-23 00:48:50 +02:00
|
|
|
{
|
2005-09-15 21:29:07 +02:00
|
|
|
user->host.str= (char *) thd->security_ctx->priv_host;
|
|
|
|
user->host.length= strlen(thd->security_ctx->priv_host);
|
2005-08-23 00:48:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
user->host.str= (char *)"%";
|
|
|
|
user->host.length= 1;
|
|
|
|
}
|
|
|
|
}
|
2002-09-22 17:02:39 +02:00
|
|
|
/* Returns 1 as the function sends error to client */
|
2005-01-24 15:48:25 +01:00
|
|
|
return check_change_password(thd, user->host.str, user->user.str,
|
|
|
|
password, strlen(password)) ? 1 : 0;
|
2004-07-30 22:05:08 +02:00
|
|
|
#else
|
2003-09-26 12:33:13 +02:00
|
|
|
return 0;
|
|
|
|
#endif
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var_password::update(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2003-09-26 12:33:13 +02:00
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2002-09-22 17:02:39 +02:00
|
|
|
/* Returns 1 as the function sends error to client */
|
2004-07-30 22:05:08 +02:00
|
|
|
return change_password(thd, user->host.str, user->user.str, password) ?
|
|
|
|
1 : 0;
|
2003-09-26 12:33:13 +02:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
2003-12-02 21:23:13 +01:00
|
|
|
/****************************************************************************
|
|
|
|
Functions to handle table_type
|
|
|
|
****************************************************************************/
|
|
|
|
|
2003-12-08 11:25:37 +01:00
|
|
|
/* Based upon sys_var::check_enum() */
|
|
|
|
|
2003-12-17 23:52:03 +01:00
|
|
|
bool sys_var_thd_storage_engine::check(THD *thd, set_var *var)
|
2003-12-02 21:23:13 +01:00
|
|
|
{
|
2005-02-08 23:50:45 +01:00
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE];
|
2003-12-02 21:23:13 +01:00
|
|
|
const char *value;
|
|
|
|
String str(buff, sizeof(buff), &my_charset_latin1), *res;
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
var->save_result.plugin= NULL;
|
2003-12-02 21:23:13 +01:00
|
|
|
if (var->value->result_type() == STRING_RESULT)
|
|
|
|
{
|
2007-08-13 15:11:25 +02:00
|
|
|
LEX_STRING engine_name;
|
2007-03-02 17:43:45 +01:00
|
|
|
handlerton *hton;
|
2003-12-02 21:23:13 +01:00
|
|
|
if (!(res=var->value->val_str(&str)) ||
|
2007-08-13 15:11:25 +02:00
|
|
|
!(engine_name.str= (char *)res->ptr()) ||
|
|
|
|
!(engine_name.length= res->length()) ||
|
|
|
|
!(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
|
2007-03-02 17:43:45 +01:00
|
|
|
!(hton= plugin_data(var->save_result.plugin, handlerton *)) ||
|
|
|
|
ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton)
|
2003-12-02 21:23:13 +01:00
|
|
|
{
|
|
|
|
value= res ? res->c_ptr() : "NULL";
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2003-12-19 15:25:50 +01:00
|
|
|
value= "unknown";
|
2003-12-02 21:23:13 +01:00
|
|
|
|
|
|
|
err:
|
2004-11-13 18:35:51 +01:00
|
|
|
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), value);
|
2004-11-12 13:34:00 +01:00
|
|
|
return 1;
|
2003-12-02 21:23:13 +01:00
|
|
|
}
|
|
|
|
|
2003-12-08 11:25:37 +01:00
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
|
2003-12-17 23:52:03 +01:00
|
|
|
LEX_STRING *base)
|
2003-12-02 21:23:13 +01:00
|
|
|
{
|
2007-05-24 12:24:36 +02:00
|
|
|
uchar* result;
|
2007-03-02 17:43:45 +01:00
|
|
|
handlerton *hton;
|
2007-08-13 15:11:25 +02:00
|
|
|
LEX_STRING *engine_name;
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_ref plugin= thd->variables.*offset;
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
|
|
|
|
hton= plugin_data(plugin, handlerton*);
|
2007-08-13 15:11:25 +02:00
|
|
|
engine_name= &hton2plugin[hton->slot]->name;
|
|
|
|
result= (uchar *) thd->strmake(engine_name->str, engine_name->length);
|
2007-03-02 17:43:45 +01:00
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
plugin_unlock(thd, plugin);
|
|
|
|
return result;
|
2003-12-02 21:23:13 +01:00
|
|
|
}
|
|
|
|
|
2003-12-08 11:25:37 +01:00
|
|
|
|
2003-12-17 23:52:03 +01:00
|
|
|
void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type)
|
2003-12-02 21:23:13 +01:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_ref old_value, new_value, *value;
|
2003-12-02 21:23:13 +01:00
|
|
|
if (type == OPT_GLOBAL)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
value= &(global_system_variables.*offset);
|
|
|
|
new_value= ha_lock_engine(NULL, myisam_hton);
|
|
|
|
}
|
2003-12-02 21:23:13 +01:00
|
|
|
else
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
value= &(thd->variables.*offset);
|
|
|
|
new_value= my_plugin_lock(NULL, &(global_system_variables.*offset));
|
|
|
|
}
|
|
|
|
DBUG_ASSERT(new_value);
|
|
|
|
old_value= *value;
|
|
|
|
*value= new_value;
|
|
|
|
plugin_unlock(NULL, old_value);
|
2003-12-02 21:23:13 +01:00
|
|
|
}
|
|
|
|
|
2003-12-08 11:25:37 +01:00
|
|
|
|
2003-12-17 23:52:03 +01:00
|
|
|
bool sys_var_thd_storage_engine::update(THD *thd, set_var *var)
|
2003-12-02 21:23:13 +01:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_ref *value= &(global_system_variables.*offset), old_value;
|
|
|
|
if (var->type != OPT_GLOBAL)
|
|
|
|
value= &(thd->variables.*offset);
|
|
|
|
old_value= *value;
|
|
|
|
if (old_value != var->save_result.plugin)
|
|
|
|
{
|
|
|
|
*value= my_plugin_lock(NULL, &var->save_result.plugin);
|
|
|
|
plugin_unlock(NULL, old_value);
|
|
|
|
}
|
2003-12-02 21:23:13 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-12-17 23:52:03 +01:00
|
|
|
void sys_var_thd_table_type::warn_deprecated(THD *thd)
|
|
|
|
{
|
2006-03-01 21:36:05 +01:00
|
|
|
WARN_DEPRECATED(thd, "5.2", "table_type", "'storage_engine'");
|
2003-12-17 23:52:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_var_thd_table_type::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
warn_deprecated(thd);
|
|
|
|
sys_var_thd_storage_engine::set_default(thd, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sys_var_thd_table_type::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
warn_deprecated(thd);
|
|
|
|
return sys_var_thd_storage_engine::update(thd, var);
|
|
|
|
}
|
|
|
|
|
2003-12-08 11:25:37 +01:00
|
|
|
|
2003-06-04 17:28:51 +02:00
|
|
|
/****************************************************************************
|
|
|
|
Functions to handle sql_mode
|
|
|
|
****************************************************************************/
|
2003-04-05 12:59:29 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Make string representation of mode.
|
2005-07-28 21:39:11 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@param[in] thd thread handler
|
|
|
|
@param[in] val sql_mode value
|
|
|
|
@param[out] len pointer on length of string
|
|
|
|
|
|
|
|
@return
|
|
|
|
pointer to string with sql_mode representation
|
2005-07-28 21:39:11 +02:00
|
|
|
*/
|
|
|
|
|
2007-04-05 13:24:34 +02:00
|
|
|
bool
|
|
|
|
sys_var_thd_sql_mode::
|
|
|
|
symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep)
|
2003-06-04 17:28:51 +02:00
|
|
|
{
|
2007-04-05 13:24:34 +02:00
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE*8];
|
2003-06-04 17:28:51 +02:00
|
|
|
String tmp(buff, sizeof(buff), &my_charset_latin1);
|
|
|
|
|
|
|
|
tmp.length(0);
|
2007-04-05 13:24:34 +02:00
|
|
|
|
2003-06-04 17:28:51 +02:00
|
|
|
for (uint i= 0; val; val>>= 1, i++)
|
|
|
|
{
|
|
|
|
if (val & 1)
|
|
|
|
{
|
2005-07-28 21:39:11 +02:00
|
|
|
tmp.append(sql_mode_typelib.type_names[i],
|
|
|
|
sql_mode_typelib.type_lengths[i]);
|
2003-06-04 17:28:51 +02:00
|
|
|
tmp.append(',');
|
|
|
|
}
|
|
|
|
}
|
2005-07-31 21:56:24 +02:00
|
|
|
|
2007-04-05 13:24:34 +02:00
|
|
|
if (tmp.length())
|
|
|
|
tmp.length(tmp.length() - 1); /* trim the trailing comma */
|
|
|
|
|
|
|
|
rep->str= thd->strmake(tmp.ptr(), tmp.length());
|
|
|
|
|
|
|
|
rep->length= rep->str ? tmp.length() : 0;
|
|
|
|
|
|
|
|
return rep->length != tmp.length();
|
2003-06-04 17:28:51 +02:00
|
|
|
}
|
|
|
|
|
2005-07-31 21:56:24 +02:00
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type,
|
2005-07-28 21:39:11 +02:00
|
|
|
LEX_STRING *base)
|
|
|
|
{
|
2007-04-05 13:24:34 +02:00
|
|
|
LEX_STRING sql_mode;
|
2006-11-30 02:40:42 +01:00
|
|
|
ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
|
|
|
|
thd->variables.*offset);
|
2007-04-05 13:24:34 +02:00
|
|
|
(void) symbolic_mode_representation(thd, val, &sql_mode);
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar *) sql_mode.str;
|
2003-06-04 17:28:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sys_var_thd_sql_mode::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
global_system_variables.*offset= 0;
|
|
|
|
else
|
|
|
|
thd->variables.*offset= global_system_variables.*offset;
|
|
|
|
}
|
|
|
|
|
2005-07-31 21:56:24 +02:00
|
|
|
|
2003-06-04 17:28:51 +02:00
|
|
|
void fix_sql_mode_var(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
global_system_variables.sql_mode=
|
|
|
|
fix_sql_mode(global_system_variables.sql_mode);
|
|
|
|
else
|
2005-06-24 03:29:56 +02:00
|
|
|
{
|
2003-06-04 17:28:51 +02:00
|
|
|
thd->variables.sql_mode= fix_sql_mode(thd->variables.sql_mode);
|
2005-06-24 03:29:56 +02:00
|
|
|
/*
|
|
|
|
Update thd->server_status
|
|
|
|
*/
|
|
|
|
if (thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES)
|
|
|
|
thd->server_status|= SERVER_STATUS_NO_BACKSLASH_ESCAPES;
|
|
|
|
else
|
|
|
|
thd->server_status&= ~SERVER_STATUS_NO_BACKSLASH_ESCAPES;
|
|
|
|
}
|
2003-06-04 17:28:51 +02:00
|
|
|
}
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/** Map database specific bits to function bits. */
|
2003-04-05 12:59:29 +02:00
|
|
|
|
2003-06-04 17:28:51 +02:00
|
|
|
ulong fix_sql_mode(ulong sql_mode)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Note that we dont set
|
|
|
|
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS | MODE_NO_FIELD_OPTIONS
|
|
|
|
to allow one to get full use of MySQL in this mode.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (sql_mode & MODE_ANSI)
|
2005-02-17 05:12:31 +01:00
|
|
|
{
|
2003-06-04 17:28:51 +02:00
|
|
|
sql_mode|= (MODE_REAL_AS_FLOAT | MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
2005-02-17 05:12:31 +01:00
|
|
|
MODE_IGNORE_SPACE);
|
|
|
|
/*
|
|
|
|
MODE_ONLY_FULL_GROUP_BY removed from ANSI mode because it is currently
|
|
|
|
overly restrictive (see BUG#8510).
|
|
|
|
*/
|
|
|
|
}
|
2003-06-04 17:28:51 +02:00
|
|
|
if (sql_mode & MODE_ORACLE)
|
|
|
|
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
|
|
|
MODE_IGNORE_SPACE |
|
|
|
|
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
2004-11-02 15:45:26 +01:00
|
|
|
MODE_NO_FIELD_OPTIONS | MODE_NO_AUTO_CREATE_USER);
|
2003-06-04 17:28:51 +02:00
|
|
|
if (sql_mode & MODE_MSSQL)
|
|
|
|
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
|
|
|
MODE_IGNORE_SPACE |
|
|
|
|
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
|
|
|
MODE_NO_FIELD_OPTIONS);
|
|
|
|
if (sql_mode & MODE_POSTGRESQL)
|
|
|
|
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
|
|
|
MODE_IGNORE_SPACE |
|
|
|
|
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
|
|
|
MODE_NO_FIELD_OPTIONS);
|
|
|
|
if (sql_mode & MODE_DB2)
|
|
|
|
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
|
|
|
MODE_IGNORE_SPACE |
|
|
|
|
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
|
|
|
MODE_NO_FIELD_OPTIONS);
|
2003-10-15 11:50:36 +02:00
|
|
|
if (sql_mode & MODE_MAXDB)
|
2003-06-04 17:28:51 +02:00
|
|
|
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
|
|
|
MODE_IGNORE_SPACE |
|
|
|
|
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
2004-11-02 15:45:26 +01:00
|
|
|
MODE_NO_FIELD_OPTIONS | MODE_NO_AUTO_CREATE_USER);
|
2003-06-04 17:28:51 +02:00
|
|
|
if (sql_mode & MODE_MYSQL40)
|
2006-05-04 17:35:58 +02:00
|
|
|
sql_mode|= MODE_HIGH_NOT_PRECEDENCE;
|
2003-06-04 17:28:51 +02:00
|
|
|
if (sql_mode & MODE_MYSQL323)
|
2006-05-04 17:35:58 +02:00
|
|
|
sql_mode|= MODE_HIGH_NOT_PRECEDENCE;
|
2004-09-28 19:08:00 +02:00
|
|
|
if (sql_mode & MODE_TRADITIONAL)
|
|
|
|
sql_mode|= (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES |
|
|
|
|
MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
|
2004-11-02 15:45:26 +01:00
|
|
|
MODE_ERROR_FOR_DIVISION_BY_ZERO | MODE_NO_AUTO_CREATE_USER);
|
2003-06-04 17:28:51 +02:00
|
|
|
return sql_mode;
|
|
|
|
}
|
2003-04-05 12:59:29 +02:00
|
|
|
|
|
|
|
|
2003-07-06 18:09:57 +02:00
|
|
|
/****************************************************************************
|
|
|
|
Named list handling
|
|
|
|
****************************************************************************/
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
|
2003-08-18 23:08:08 +02:00
|
|
|
NAMED_LIST **found)
|
2003-07-06 18:09:57 +02:00
|
|
|
{
|
|
|
|
I_List_iterator<NAMED_LIST> it(*list);
|
|
|
|
NAMED_LIST *element;
|
|
|
|
while ((element= it++))
|
|
|
|
{
|
|
|
|
if (element->cmp(name, length))
|
2003-08-18 23:08:08 +02:00
|
|
|
{
|
2003-08-27 00:14:13 +02:00
|
|
|
if (found)
|
|
|
|
*found= element;
|
2003-07-06 18:09:57 +02:00
|
|
|
return element->data;
|
2003-08-18 23:08:08 +02:00
|
|
|
}
|
2003-07-06 18:09:57 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-18 12:47:27 +01:00
|
|
|
void delete_elements(I_List<NAMED_LIST> *list,
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
void (*free_element)(const char *name, uchar*))
|
2003-07-06 18:09:57 +02:00
|
|
|
{
|
|
|
|
NAMED_LIST *element;
|
2003-08-18 23:08:08 +02:00
|
|
|
DBUG_ENTER("delete_elements");
|
2003-07-06 18:09:57 +02:00
|
|
|
while ((element= list->get()))
|
|
|
|
{
|
2003-11-18 12:47:27 +01:00
|
|
|
(*free_element)(element->name, element->data);
|
2003-07-06 18:09:57 +02:00
|
|
|
delete element;
|
|
|
|
}
|
2003-08-18 23:08:08 +02:00
|
|
|
DBUG_VOID_RETURN;
|
2003-07-06 18:09:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Key cache functions */
|
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
static KEY_CACHE *create_key_cache(const char *name, uint length)
|
2003-07-06 18:09:57 +02:00
|
|
|
{
|
2003-11-20 21:06:25 +01:00
|
|
|
KEY_CACHE *key_cache;
|
2003-11-18 12:47:27 +01:00
|
|
|
DBUG_ENTER("create_key_cache");
|
|
|
|
DBUG_PRINT("enter",("name: %.*s", length, name));
|
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
|
2003-11-18 12:47:27 +01:00
|
|
|
MYF(MY_ZEROFILL | MY_WME))))
|
2003-08-02 11:43:18 +02:00
|
|
|
{
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
|
2003-11-18 12:47:27 +01:00
|
|
|
{
|
|
|
|
my_free((char*) key_cache, MYF(0));
|
2003-08-02 11:43:18 +02:00
|
|
|
key_cache= 0;
|
2003-11-18 12:47:27 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Set default values for a key cache
|
|
|
|
The values in dflt_key_cache_var is set by my_getopt() at startup
|
|
|
|
|
|
|
|
We don't set 'buff_size' as this is used to enable the key cache
|
|
|
|
*/
|
2003-11-20 21:06:25 +01:00
|
|
|
key_cache->param_block_size= dflt_key_cache_var.param_block_size;
|
|
|
|
key_cache->param_division_limit= dflt_key_cache_var.param_division_limit;
|
|
|
|
key_cache->param_age_threshold= dflt_key_cache_var.param_age_threshold;
|
2003-11-18 12:47:27 +01:00
|
|
|
}
|
2003-08-02 11:43:18 +02:00
|
|
|
}
|
2003-11-18 12:47:27 +01:00
|
|
|
DBUG_RETURN(key_cache);
|
2003-07-06 18:09:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
KEY_CACHE *get_or_create_key_cache(const char *name, uint length)
|
2003-07-06 18:09:57 +02:00
|
|
|
{
|
2003-08-02 11:43:18 +02:00
|
|
|
LEX_STRING key_cache_name;
|
2003-11-20 21:06:25 +01:00
|
|
|
KEY_CACHE *key_cache;
|
2003-11-18 12:47:27 +01:00
|
|
|
|
2003-08-02 11:43:18 +02:00
|
|
|
key_cache_name.str= (char *) name;
|
|
|
|
key_cache_name.length= length;
|
2003-11-18 12:47:27 +01:00
|
|
|
pthread_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
if (!(key_cache= get_key_cache(&key_cache_name)))
|
2003-07-06 18:09:57 +02:00
|
|
|
key_cache= create_key_cache(name, length);
|
2003-11-18 12:47:27 +01:00
|
|
|
pthread_mutex_unlock(&LOCK_global_system_variables);
|
2003-07-06 18:09:57 +02:00
|
|
|
return key_cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
void free_key_cache(const char *name, KEY_CACHE *key_cache)
|
2003-07-06 18:09:57 +02:00
|
|
|
{
|
2003-11-18 12:47:27 +01:00
|
|
|
ha_end_key_cache(key_cache);
|
|
|
|
my_free((char*) key_cache, MYF(0));
|
2003-08-02 11:43:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-13 15:11:25 +02:00
|
|
|
bool process_key_caches(process_key_cache_t func)
|
2003-11-18 12:47:27 +01:00
|
|
|
{
|
2003-08-02 11:43:18 +02:00
|
|
|
I_List_iterator<NAMED_LIST> it(key_caches);
|
|
|
|
NAMED_LIST *element;
|
2003-11-18 12:47:27 +01:00
|
|
|
|
2003-08-02 11:43:18 +02:00
|
|
|
while ((element= it++))
|
|
|
|
{
|
2003-11-20 21:06:25 +01:00
|
|
|
KEY_CACHE *key_cache= (KEY_CACHE *) element->data;
|
2003-11-18 12:47:27 +01:00
|
|
|
func(element->name, key_cache);
|
2003-08-02 11:43:18 +02:00
|
|
|
}
|
|
|
|
return 0;
|
2003-07-06 18:09:57 +02:00
|
|
|
}
|
|
|
|
|
2003-04-05 12:59:29 +02:00
|
|
|
|
2005-11-10 17:50:51 +01:00
|
|
|
void sys_var_trust_routine_creators::warn_deprecated(THD *thd)
|
|
|
|
{
|
2006-03-01 21:36:05 +01:00
|
|
|
WARN_DEPRECATED(thd, "5.2", "log_bin_trust_routine_creators",
|
|
|
|
"'log_bin_trust_function_creators'");
|
2005-11-10 17:50:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_var_trust_routine_creators::set_default(THD *thd, enum_var_type type)
|
|
|
|
{
|
|
|
|
warn_deprecated(thd);
|
|
|
|
sys_var_bool_ptr::set_default(thd, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sys_var_trust_routine_creators::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
warn_deprecated(thd);
|
|
|
|
return sys_var_bool_ptr::update(thd, var);
|
|
|
|
}
|
|
|
|
|
2006-11-21 04:40:35 +01:00
|
|
|
bool sys_var_opt_readonly::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
bool result;
|
|
|
|
|
|
|
|
DBUG_ENTER("sys_var_opt_readonly::update");
|
|
|
|
|
|
|
|
/* Prevent self dead-lock */
|
|
|
|
if (thd->locked_tables || thd->active_transaction())
|
|
|
|
{
|
|
|
|
my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thd->global_read_lock)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
This connection already holds the global read lock.
|
|
|
|
This can be the case with:
|
|
|
|
- FLUSH TABLES WITH READ LOCK
|
|
|
|
- SET GLOBAL READ_ONLY = 1
|
|
|
|
*/
|
|
|
|
result= sys_var_bool_ptr::update(thd, var);
|
|
|
|
DBUG_RETURN(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Perform a 'FLUSH TABLES WITH READ LOCK'.
|
|
|
|
This is a 3 step process:
|
|
|
|
- [1] lock_global_read_lock()
|
|
|
|
- [2] close_cached_tables()
|
|
|
|
- [3] make_global_read_lock_block_commit()
|
|
|
|
[1] prevents new connections from obtaining tables locked for write.
|
|
|
|
[2] waits until all existing connections close their tables.
|
|
|
|
[3] prevents transactions from being committed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (lock_global_read_lock(thd))
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
|
|
|
|
/*
|
|
|
|
This call will be blocked by any connection holding a READ or WRITE lock.
|
|
|
|
Ideally, we want to wait only for pending WRITE locks, but since:
|
|
|
|
con 1> LOCK TABLE T FOR READ;
|
|
|
|
con 2> LOCK TABLE T FOR WRITE; (blocked by con 1)
|
|
|
|
con 3> SET GLOBAL READ ONLY=1; (blocked by con 2)
|
|
|
|
can cause to wait on a read lock, it's required for the client application
|
|
|
|
to unlock everything, and acceptable for the server to wait on all locks.
|
|
|
|
*/
|
2007-12-12 22:44:14 +01:00
|
|
|
if (result= close_cached_tables(thd, NULL, FALSE, TRUE, TRUE))
|
2006-11-21 04:40:35 +01:00
|
|
|
goto end_with_read_lock;
|
|
|
|
|
|
|
|
if (result= make_global_read_lock_block_commit(thd))
|
|
|
|
goto end_with_read_lock;
|
|
|
|
|
|
|
|
/* Change the opt_readonly system variable, safe because the lock is held */
|
|
|
|
result= sys_var_bool_ptr::update(thd, var);
|
|
|
|
|
|
|
|
end_with_read_lock:
|
|
|
|
/* Release the lock */
|
|
|
|
unlock_global_read_lock(thd);
|
|
|
|
DBUG_RETURN(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-14 22:36:11 +01:00
|
|
|
/* even session variable here requires SUPER, because of -#o,file */
|
|
|
|
bool sys_var_thd_dbug::check(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
return check_global_access(thd, SUPER_ACL);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sys_var_thd_dbug::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
if (var->type == OPT_GLOBAL)
|
|
|
|
DBUG_SET_INITIAL(var ? var->value->str_value.c_ptr() : "");
|
|
|
|
else
|
2008-02-26 16:03:59 +01:00
|
|
|
DBUG_SET(var ? var->value->str_value.c_ptr() : "");
|
|
|
|
|
2006-02-14 22:36:11 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-01 13:08:44 +02:00
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
|
2006-02-14 22:36:11 +01:00
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
if (type == OPT_GLOBAL)
|
|
|
|
DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
|
|
|
|
else
|
|
|
|
DBUG_EXPLAIN(buf, sizeof(buf));
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar*) thd->strdup(buf);
|
2006-02-14 22:36:11 +01:00
|
|
|
}
|
2005-12-06 16:15:29 +01:00
|
|
|
|
2006-05-22 20:46:13 +02:00
|
|
|
|
2006-09-01 13:08:44 +02:00
|
|
|
bool sys_var_event_scheduler::check(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
return check_enum(thd, var, &Events::var_typelib);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-22 20:46:13 +02:00
|
|
|
/*
|
|
|
|
The update method of the global variable event_scheduler.
|
|
|
|
If event_scheduler is switched from 0 to 1 then the scheduler main
|
|
|
|
thread is resumed and if from 1 to 0 the scheduler thread is suspended
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
sys_var_event_scheduler::update()
|
|
|
|
thd Thread context (unused)
|
|
|
|
var The new value
|
|
|
|
|
|
|
|
Returns
|
|
|
|
FALSE OK
|
|
|
|
TRUE Error
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
|
|
|
sys_var_event_scheduler::update(THD *thd, set_var *var)
|
|
|
|
{
|
2006-06-28 01:28:03 +02:00
|
|
|
int res;
|
2006-05-22 20:46:13 +02:00
|
|
|
/* here start the thread if not running. */
|
|
|
|
DBUG_ENTER("sys_var_event_scheduler::update");
|
2006-11-27 00:47:38 +01:00
|
|
|
DBUG_PRINT("info", ("new_value: %d", (int) var->save_result.ulong_value));
|
2006-07-04 18:44:35 +02:00
|
|
|
|
2007-04-05 13:24:34 +02:00
|
|
|
enum Events::enum_opt_event_scheduler
|
|
|
|
new_state=
|
|
|
|
(enum Events::enum_opt_event_scheduler) var->save_result.ulong_value;
|
|
|
|
|
2007-04-05 18:47:22 +02:00
|
|
|
res= Events::switch_event_scheduler_state(new_state);
|
2006-05-22 20:46:13 +02:00
|
|
|
|
|
|
|
DBUG_RETURN((bool) res);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar *sys_var_event_scheduler::value_ptr(THD *thd, enum_var_type type,
|
2006-05-22 20:46:13 +02:00
|
|
|
LEX_STRING *base)
|
|
|
|
{
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
return (uchar *) Events::get_opt_event_scheduler_str();
|
2006-05-22 20:46:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/****************************************************************************
|
|
|
|
Used templates
|
|
|
|
****************************************************************************/
|
|
|
|
|
2005-06-22 11:08:28 +02:00
|
|
|
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
|
2002-07-23 17:31:22 +02:00
|
|
|
template class List<set_var_base>;
|
2003-05-27 17:40:37 +02:00
|
|
|
template class List_iterator_fast<set_var_base>;
|
2003-07-06 18:09:57 +02:00
|
|
|
template class I_List_iterator<NAMED_LIST>;
|
2002-07-23 17:31:22 +02:00
|
|
|
#endif
|