summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-05-21 21:39:58 +0300
committerunknown <monty@mashka.mysql.fi>2003-05-21 21:39:58 +0300
commitf72611b4fa7eb45259b26d75a733f7a29d20dc04 (patch)
tree3df25ac7036fb4b2e95ab56b9dc90477ec234b7c /sql
parentdaac922bc306847581b9acee4bcf0a31707d72e7 (diff)
downloadmariadb-git-f72611b4fa7eb45259b26d75a733f7a29d20dc04.tar.gz
After merge fixes
Added initialization of all important global variables BUILD/SETUP.sh: build with readline client/mysqltest.c: Added variable SERVER_VERSION myisam/mi_key.c: Indentation change myisam/mi_open.c: After merge fix myisam/mi_range.c: After merge fix myisam/mi_rkey.c: After merge fix myisam/mi_search.c: After merge fix myisam/myisamdef.h: After merge fix mysql-test/include/not_embedded.inc: Fix test (because of wrong utf8 test) mysql-test/r/alter_table.result: Updated results after merge mysql-test/r/create.result: Updated results after merge mysql-test/r/ctype_recoding.result: Updated results after merge mysql-test/r/fulltext.result: Updated results after merge mysql-test/r/func_group.result: Updated results after merge mysql-test/r/group_by.result: Updated results after merge mysql-test/r/innodb.result: Updated results after merge mysql-test/r/join_outer.result: Updated results after merge mysql-test/r/null_key.result: Updated results after merge mysql-test/r/order_by.result: Updated results after merge mysql-test/r/query_cache.result: Updated results after merge mysql-test/r/repair.result: Updated results after merge mysql-test/r/rpl_flush_tables.result: Updated results after merge mysql-test/r/union.result: Updated results after merge mysql-test/r/update.result: Updated results after merge mysql-test/t/ansi.test: After merge fixes mysql-test/t/create.test: After merge fixes mysql-test/t/ctype_recoding.test: After merge fixes mysql-test/t/ctype_ujis.test: After merge fixes mysql-test/t/fulltext.test: After merge fixes mysql-test/t/innodb.test: After merge fixes mysql-test/t/join_outer.test: After merge fixes mysql-test/t/loaddata.test: After merge fixes mysql-test/t/order_by.test: After merge fixes mysql-test/t/rpl_flush_tables.test: After merge fixes mysql-test/t/status.test: After merge fixes mysql-test/t/subselect.test: After merge fixes sql/convert.cc: Code cleanup sql/field.cc: After merge fixes sql/filesort.cc: Remove compiler warning sql/item.cc: More efficient set_name() (no mallocs) sql/item_cmpfunc.cc: Code Code cleanup Item_bool_func2::fix_fields() added to get error handling right for cmp_charset sql/item_cmpfunc.h: New prototypes sql/item_func.cc: After merge fix sql/item_strfunc.cc: Faster check for BINARY sql/log_event.cc: Comment cleanup sql/mysql_priv.h: New prototypes and variables sql/mysqld.cc: Added initialization of all important global variables. Cleanup of variable declarations This is needed ot make the embedded version restartable sql/opt_sum.cc: After merge fix sql/set_var.cc: Code cleanup sql/sql_acl.cc: After merge fix Better error message sql/sql_db.cc: After merge fix sql/sql_derived.cc: After merge fix sql/sql_insert.cc: Indentation cleanups sql/sql_list.h: Added empty() to base_ilist sql/sql_parse.cc: After merge fix sql/sql_select.cc: After merge fix Fixed derived name handling in EXPLAIN sql/sql_show.cc: After merge fix sql/sql_string.cc: Made copy_and_convert global sql/sql_string.h: Made copy_and_convert global sql/sql_update.cc: After merge fix sql/sql_yacc.yy: After merge fix sql/thr_malloc.cc: Added sql_strmake_with_convert() sql/unireg.h: Added MAX_ALIAS_NAME strings/ctype-ujis.c: Fixed bug in converting to ujis
Diffstat (limited to 'sql')
-rw-r--r--sql/convert.cc4
-rw-r--r--sql/field.cc18
-rw-r--r--sql/filesort.cc2
-rw-r--r--sql/item.cc43
-rw-r--r--sql/item_cmpfunc.cc73
-rw-r--r--sql/item_cmpfunc.h3
-rw-r--r--sql/item_func.cc12
-rw-r--r--sql/item_strfunc.cc2
-rw-r--r--sql/log_event.cc60
-rw-r--r--sql/mysql_priv.h6
-rw-r--r--sql/mysqld.cc551
-rw-r--r--sql/opt_sum.cc1
-rw-r--r--sql/set_var.cc3
-rw-r--r--sql/sql_acl.cc7
-rw-r--r--sql/sql_db.cc4
-rw-r--r--sql/sql_derived.cc16
-rw-r--r--sql/sql_insert.cc10
-rw-r--r--sql/sql_list.h1
-rw-r--r--sql/sql_parse.cc6
-rw-r--r--sql/sql_select.cc16
-rw-r--r--sql/sql_show.cc3
-rw-r--r--sql/sql_string.cc5
-rw-r--r--sql/sql_string.h3
-rw-r--r--sql/sql_update.cc8
-rw-r--r--sql/sql_yacc.yy14
-rw-r--r--sql/thr_malloc.cc30
-rw-r--r--sql/unireg.h1
27 files changed, 523 insertions, 379 deletions
diff --git a/sql/convert.cc b/sql/convert.cc
index bfdf49bf42d..880c462f4aa 100644
--- a/sql/convert.cc
+++ b/sql/convert.cc
@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#if 0
+#ifdef NOT_USED
/*
** Convert tables between different character sets
@@ -462,4 +462,4 @@ bool CONVERT::store(String *packet,const char *from,uint length)
return 0;
}
-#endif
+#endif /* NOT_USED */
diff --git a/sql/field.cc b/sql/field.cc
index d6f9797071b..9557bca9b28 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -3977,23 +3977,19 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)),
int Field_string::cmp(const char *a_ptr, const char *b_ptr)
{
-#ifdef USE_STRCOLL
- if (field_charset->mbmaxlen > 1)
+ if (field_charset->strxfrm_multiply > 1)
{
/*
We have to remove end space to be able to compare multi-byte-characters
like in latin_de 'ae' and 0xe4
*/
- uint a_length= field_length_without_space(a_ptr, field_length);
- uint b_length= field_length_without_space(b_ptr, field_length);
- return my_strnncoll(field_charset,
- (const uchar*) a_ptr, a_length,
- (const uchar*) b_ptr, b_length);
+ return field_charset->strnncollsp(field_charset,
+ (const uchar*) a_ptr, field_length,
+ (const uchar*) b_ptr, field_length);
}
-#endif
- return my_strnncoll(field_charset,
- (const uchar*) a_ptr, field_length,
- (const uchar*) b_ptr, field_length);
+ return field_charset->strnncoll(field_charset,
+ (const uchar*) a_ptr, field_length,
+ (const uchar*) b_ptr, field_length);
}
void Field_string::sort_string(char *to,uint length)
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 68b8737bc79..2130bdaeb93 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -76,7 +76,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
ulong memavl, min_sort_memory;
uint maxbuffer;
BUFFPEK *buffpek;
- ha_rows records;
+ ha_rows records= HA_POS_ERROR;
uchar **sort_keys;
IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile;
SORTPARAM param;
diff --git a/sql/item.cc b/sql/item.cc
index 7599ae6486f..636cefb511b 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -90,28 +90,32 @@ bool Item::check_cols(uint c)
return 0;
}
-void Item::set_name(const char *str,uint length, CHARSET_INFO *cs)
+
+void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
{
if (!length)
- name= (char*) str; // Empty string, used by AS
- else
{
- while (length && !my_isgraph(cs,*str))
- { // Fix problem with yacc
- length--;
- str++;
- }
- if (length && !my_charset_same(cs, system_charset_info))
- {
- String tmp;
- tmp.copy(str, length, cs, system_charset_info);
- name=sql_strmake(tmp.ptr(),min(tmp.length(),MAX_FIELD_WIDTH));
- }
- else
- name=sql_strmake(str,min(length,MAX_FIELD_WIDTH));
+ /* Empty string, used by AS or internal function like last_insert_id() */
+ name= (char*) str;
+ return;
+ }
+ while (length && !my_isgraph(cs,*str))
+ { // Fix problem with yacc
+ length--;
+ str++;
}
+ if (!my_charset_same(cs, system_charset_info))
+ {
+ uint32 res_length;
+ name= sql_strmake_with_convert(str, length, cs,
+ MAX_ALIAS_NAME, system_charset_info,
+ &res_length);
+ }
+ else
+ name=sql_strmake(str, min(length,MAX_ALIAS_NAME));
}
+
/*
This function is only called when comparing items in the WHERE clause
*/
@@ -1048,13 +1052,6 @@ inline uint char_val(char X)
X-'a'+10);
}
-/* In MySQL 4.1 this will always return STRING_RESULT */
-
-enum Item_result Item_varbinary::result_type () const
-{
- return (current_thd->variables.new_mode) ? STRING_RESULT : INT_RESULT;
-}
-
Item_varbinary::Item_varbinary(const char *str, uint str_length)
{
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 7cc07690fcc..4892516c080 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -90,7 +90,7 @@ static bool convert_constant_item(Field *field, Item **item)
bool Item_bool_func2::set_cmp_charset(CHARSET_INFO *cs1, enum coercion co1,
CHARSET_INFO *cs2, enum coercion co2)
{
- if((cs1 == &my_charset_bin) || (cs2 == &my_charset_bin))
+ if ((cs1 == &my_charset_bin) || (cs2 == &my_charset_bin))
{
cmp_charset= &my_charset_bin;
return 0;
@@ -114,29 +114,42 @@ bool Item_bool_func2::set_cmp_charset(CHARSET_INFO *cs1, enum coercion co1,
{
if (co1 == COER_COERCIBLE)
{
- CHARSET_INFO *c= get_charset_by_csname(cs1->csname,MY_CS_PRIMARY,MYF(0));
- if (c)
+ CHARSET_INFO *c;
+ if ((c= get_charset_by_csname(cs1->csname, MY_CS_PRIMARY, MYF(0))))
{
cmp_charset= c;
return 0;
}
- else
- return 1;
}
- else
- return 1;
+ return 1;
}
}
return 0;
}
+
+bool Item_bool_func2::fix_fields(THD *thd, struct st_table_list *tables,
+ Item ** ref)
+{
+ if (Item_int_func::fix_fields(thd, tables, ref))
+ return 1;
+ if (!cmp_charset)
+ {
+ /* set_cmp_charset() failed */
+ my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name());
+ return 1;
+ }
+ return 0;
+}
+
+
void Item_bool_func2::fix_length_and_dec()
{
max_length= 1; // Function returns 0 or 1
/*
As some compare functions are generated after sql_yacc,
- we have to check for out of memory conditons here
+ we have to check for out of memory conditions here
*/
if (!args[0] || !args[1])
return;
@@ -149,7 +162,8 @@ void Item_bool_func2::fix_length_and_dec()
if (convert_constant_item(field,&args[1]))
{
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
- INT_RESULT); // Works for all types.
+ INT_RESULT); // Works for all types.
+ cmp_charset= &my_charset_bin; // For test in fix_fields
return;
}
}
@@ -163,17 +177,19 @@ void Item_bool_func2::fix_length_and_dec()
{
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
INT_RESULT); // Works for all types.
+ cmp_charset= &my_charset_bin; // For test in fix_fields
return;
}
}
}
- if (set_cmp_charset(args[0]->charset(), args[0]->coercibility,
- args[1]->charset(), args[1]->coercibility))
- {
- my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name());
- return;
- }
set_cmp_func();
+ /*
+ We must set cmp_charset here as we may be called from for an automatic
+ generated item, like in natural join
+ */
+end:
+ set_cmp_charset(args[0]->charset(), args[0]->coercibility,
+ args[1]->charset(), args[1]->coercibility);
}
@@ -191,22 +207,22 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type)
comparators= 0;
return 1;
}
- if ((comparators= (Arg_comparator *) sql_alloc(sizeof(Arg_comparator)*n)))
- for (uint i=0; i < n; i++)
+ if (!(comparators= (Arg_comparator *) sql_alloc(sizeof(Arg_comparator)*n)))
+ return 1;
+ for (uint i=0; i < n; i++)
+ {
+ if ((*a)->el(i)->cols() != (*b)->el(i)->cols())
{
- if ((*a)->el(i)->cols() != (*b)->el(i)->cols())
- {
- my_error(ER_CARDINALITY_COL, MYF(0), (*a)->el(i)->cols());
- return 1;
- }
- comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
+ my_error(ER_CARDINALITY_COL, MYF(0), (*a)->el(i)->cols());
+ return 1;
}
- else
- return 1;
+ comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
+ }
}
return 0;
}
+
int Arg_comparator::compare_string()
{
String *res1,*res2;
@@ -1875,13 +1891,6 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref)
if (Item_bool_func2::fix_fields(thd, tlist, ref))
return 1;
- if (set_cmp_charset(args[0]->charset(), args[0]->coercibility,
- args[1]->charset(), args[1]->coercibility))
- {
- my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name());
- return 1;
- }
-
/*
We could also do boyer-more for non-const items, but as we would have to
recompute the tables for each row it's not worth it.
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 5e246e3e285..ff469deab30 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -116,7 +116,8 @@ protected:
public:
Item_bool_func2(Item *a,Item *b):
- Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1) {}
+ Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1), cmp_charset(0) {}
+ bool fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref);
void fix_length_and_dec();
void set_cmp_func()
{
diff --git a/sql/item_func.cc b/sql/item_func.cc
index eeab2367b2e..cc428822dd8 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -40,8 +40,8 @@ eval_const_cond(COND *cond)
}
-Item_func::Item_func(List<Item> &list):
- allowed_arg_cols(1)
+Item_func::Item_func(List<Item> &list)
+ :allowed_arg_cols(1)
{
arg_count=list.elements;
if ((args=(Item**) sql_alloc(sizeof(Item*)*arg_count)))
@@ -109,10 +109,12 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{ // Print purify happy
for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
{
- Item *item= *arg;
- if (item->fix_fields(thd, tables, arg) ||
- item->check_cols(allowed_arg_cols))
+ Item *item;
+ /* We can't yet set item to *arg as fix_fields may change *arg */
+ if ((*arg)->fix_fields(thd, tables, arg) ||
+ (*arg)->check_cols(allowed_arg_cols))
return 1; /* purecov: inspected */
+ item= *arg;
if (item->maybe_null)
maybe_null=1;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index d28341c3bd0..ff96e1060a3 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2174,7 +2174,7 @@ void Item_func_set_collation::fix_length_and_dec()
const char *colname;
String tmp, *str= args[1]->val_str(&tmp);
colname= str->c_ptr();
- if (!strncmp(colname,"BINARY",6))
+ if (colname == binary_keyword)
set_collation= get_charset_by_csname(args[0]->charset()->csname,
MY_CS_BINSORT,MYF(0));
else
diff --git a/sql/log_event.cc b/sql/log_event.cc
index be5b5079eee..900d0a482aa 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -195,9 +195,9 @@ static inline int read_str(char * &buf, char *buf_end, char * &str,
}
-/**************************************************************************/
+/**************************************************************************
Log_event methods
-***************************************************************************/
+**************************************************************************/
/*
Log_event::get_type_str()
@@ -715,9 +715,9 @@ void Log_event::set_log_pos(MYSQL_LOG* log)
#endif // !MYSQL_CLIENT
-/**************************************************************************/
+/**************************************************************************
Query_log_event methods
-***************************************************************************/
+**************************************************************************/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
@@ -982,9 +982,9 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
#endif
-/**************************************************************************/
+/**************************************************************************
Start_log_event methods
-***************************************************************************/
+**************************************************************************/
/*
Start_log_event::pack_info()
@@ -1093,9 +1093,9 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli)
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
-/**************************************************************************/
+/**************************************************************************
Load_log_event methods
-***************************************************************************/
+**************************************************************************/
/*
Load_log_event::pack_info()
@@ -1651,9 +1651,9 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
#endif
-/****************************************************************************/
+/**************************************************************************
Rotate_log_event methods
-*****************************************************************************/
+**************************************************************************/
/*
Rotate_log_event::pack_info()
@@ -1788,9 +1788,9 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
#endif
-/***************************************************************************/
+/**************************************************************************
Intvar_log_event methods
-****************************************************************************/
+**************************************************************************/
/*
Intvar_log_event::pack_info()
@@ -1902,9 +1902,9 @@ int Intvar_log_event::exec_event(struct st_relay_log_info* rli)
#endif
-/****************************************************************************
+/**************************************************************************
Rand_log_event methods
-****************************************************************************/
+**************************************************************************/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Rand_log_event::pack_info(Protocol *protocol)
@@ -1964,9 +1964,9 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli)
#endif // !MYSQL_CLIENT
-/***************************************************************************
+/**************************************************************************
User_var_log_event methods
-***************************************************************************/
+**************************************************************************/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void User_var_log_event::pack_info(Protocol* protocol)
@@ -2195,9 +2195,9 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli)
#endif // !MYSQL_CLIENT
-/****************************************************************************
+/**************************************************************************
Slave_log_event methods
-****************************************************************************/
+**************************************************************************/
#ifdef HAVE_REPLICATION
#ifdef MYSQL_CLIENT
@@ -2342,9 +2342,9 @@ int Slave_log_event::exec_event(struct st_relay_log_info* rli)
#endif // !MYSQL_CLIENT
-/***************************************************************************/
+/**************************************************************************
Stop_log_event methods
-****************************************************************************/
+**************************************************************************/
/*
Stop_log_event::print()
@@ -2403,9 +2403,9 @@ int Stop_log_event::exec_event(struct st_relay_log_info* rli)
#endif /* HAVE_REPLICATION */
-/***************************************************************************/
+/**************************************************************************
Create_file_log_event methods
-****************************************************************************/
+**************************************************************************/
/*
Create_file_log_event ctor
@@ -2622,9 +2622,9 @@ err:
#endif
-/***************************************************************************/
+/**************************************************************************
Append_block_log_event methods
-****************************************************************************/
+**************************************************************************/
/*
Append_block_log_event ctor
@@ -2739,9 +2739,9 @@ err:
#endif
-/***************************************************************************/
+/**************************************************************************
Delete_file_log_event methods
-****************************************************************************/
+**************************************************************************/
/*
Delete_file_log_event ctor
@@ -2829,9 +2829,9 @@ int Delete_file_log_event::exec_event(struct st_relay_log_info* rli)
#endif
-/**************************************************************************/
+/**************************************************************************
Execute_load_log_event methods
-***************************************************************************/
+**************************************************************************/
/*
Execute_load_log_event ctor
@@ -2971,9 +2971,9 @@ err:
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
-/**************************************************************************/
+/**************************************************************************
sql_ex_info methods
-***************************************************************************/
+**************************************************************************/
/*
sql_ex_info::write_data()
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 5caa93115ab..a3545ee6098 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -45,6 +45,10 @@ char *sql_strdup(const char *str);
char *sql_strmake(const char *str,uint len);
gptr sql_memdup(const void * ptr,unsigned size);
void sql_element_free(void *ptr);
+char *sql_strmake_with_convert(const char *str, uint32 arg_length,
+ CHARSET_INFO *from_cs,
+ uint32 max_res_length,
+ CHARSET_INFO *to_cs, uint32 *result_length);
void kill_one_thread(THD *thd, ulong id);
bool net_request_file(NET* net, const char* fname);
char* query_table_status(THD *thd,const char *db,const char *table_name);
@@ -687,7 +691,7 @@ extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
#define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
extern MY_TMPDIR mysql_tmpdir_list;
extern const char *command_name[];
-extern const char *first_keyword, *localhost, *delayed_user;
+extern const char *first_keyword, *localhost, *delayed_user, *binary_keyword;
extern const char **errmesg; /* Error messages */
extern const char *myisam_recover_options_str;
extern uchar *days_in_month;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index c75b1981426..dca881557f1 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -116,7 +116,7 @@ int deny_severity = LOG_WARNING;
#define my_fromhost(A) fromhost()
#define my_hosts_access(A) hosts_access()
#define my_eval_client(A) eval_client()
-#endif
+#endif /* __STDC__ */
#endif /* HAVE_LIBWRAP */
#ifdef HAVE_SYS_MMAN_H
@@ -128,8 +128,8 @@ int deny_severity = LOG_WARNING;
#include <library.h>
#include <monitor.h>
-event_handle_t eh;
-Report_t ref;
+static event_handle_t eh;
+static Report_t ref;
#endif /* __NETWARE__ */
#ifdef _AIX41
@@ -169,6 +169,7 @@ inline void reset_floating_point_exceptions()
#else
#define THR_KILL_SIGNAL SIGUSR2 // Can't use this with LinuxThreads
#endif
+#define MYSQL_KILL_SIGNAL SIGTERM
#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
#include <sys/types.h>
@@ -183,26 +184,6 @@ inline void reset_floating_point_exceptions()
extern "C" int gethostname(char *name, int namelen);
#endif
-#define MYSQL_KILL_SIGNAL SIGTERM
-
-#ifndef DBUG_OFF
-static const char* default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace",
- "d:t:i:o,/tmp/mysqld.trace");
-#endif
-
-#ifdef __NT__
-static char szPipeName [ 257 ];
-static SECURITY_ATTRIBUTES saPipeSecurity;
-static SECURITY_DESCRIPTOR sdPipeDescriptor;
-static HANDLE hPipe = INVALID_HANDLE_VALUE;
-#endif
-#ifdef __WIN__
-static pthread_cond_t COND_handler_count;
-static uint handler_count;
-static bool start_mode=0, use_opt_args;
-static int opt_argc;
-static char **opt_argv;
-#endif
/* Set prefix for windows binary */
#ifdef __WIN__
@@ -220,192 +201,78 @@ static char **opt_argv;
#endif /* __NT__ */
#endif /* __WIN__ */
-#ifdef HAVE_BERKELEY_DB
-SHOW_COMP_OPTION have_berkeley_db=SHOW_OPTION_YES;
-#else
-SHOW_COMP_OPTION have_berkeley_db=SHOW_OPTION_NO;
-#endif
-#ifdef HAVE_INNOBASE_DB
-SHOW_COMP_OPTION have_innodb=SHOW_OPTION_YES;
-#else
-SHOW_COMP_OPTION have_innodb=SHOW_OPTION_NO;
-#endif
-#ifdef HAVE_ISAM
-SHOW_COMP_OPTION have_isam=SHOW_OPTION_YES;
-#else
-SHOW_COMP_OPTION have_isam=SHOW_OPTION_NO;
-#endif
-#ifdef USE_RAID
-SHOW_COMP_OPTION have_raid=SHOW_OPTION_YES;
-#else
-SHOW_COMP_OPTION have_raid=SHOW_OPTION_NO;
-#endif
-#ifdef HAVE_OPENSSL
-SHOW_COMP_OPTION have_openssl=SHOW_OPTION_YES;
-#else
-SHOW_COMP_OPTION have_openssl=SHOW_OPTION_NO;
-#endif
-#ifdef HAVE_BROKEN_REALPATH
-SHOW_COMP_OPTION have_symlink=SHOW_OPTION_NO;
-#else
-SHOW_COMP_OPTION have_symlink=SHOW_OPTION_YES;
-#endif
-#ifdef HAVE_QUERY_CACHE
-SHOW_COMP_OPTION have_query_cache=SHOW_OPTION_YES;
-#else
-SHOW_COMP_OPTION have_query_cache=SHOW_OPTION_NO;
-#endif
-#ifdef HAVE_CRYPT
-SHOW_COMP_OPTION have_crypt=SHOW_OPTION_YES;
-#else
-SHOW_COMP_OPTION have_crypt=SHOW_OPTION_NO;
-#endif
-#ifdef HAVE_COMPRESS
-SHOW_COMP_OPTION have_compress= SHOW_OPTION_YES;
-#else
-SHOW_COMP_OPTION have_compress= SHOW_OPTION_NO;
-#endif
-const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"};
+/* Constants */
-bool opt_large_files= sizeof(my_off_t) > 4;
+const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"};
+const char *sql_mode_names[] =
+{
+ "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
+ "SERIALIZE", "ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",
+ "POSTGRESQL", "ORACLE", "MSSQL", "DB2", "SAPDB", "NO_KEY_OPTIONS",
+ "NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS", "MYSQL323", "MYSQL40",
+ NullS
+};
+TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"",
+ sql_mode_names };
+const char *first_keyword= "first", *binary_keyword= "BINARY";
+const char *localhost= "localhost", *delayed_user= "DELAYED";
#if SIZEOF_OFF_T > 4 && defined(BIG_TABLES)
#define GET_HA_ROWS GET_ULL
#else
#define GET_HA_ROWS GET_ULONG
#endif
-#ifdef HAVE_LIBWRAP
-char *libwrapName= NULL;
-#endif
+bool opt_large_files= sizeof(my_off_t) > 4;
+arg_cmp_func Arg_comparator::comparator_matrix[4][2] =
+{{&Arg_comparator::compare_string, &Arg_comparator::compare_e_string},
+ {&Arg_comparator::compare_real, &Arg_comparator::compare_e_real},
+ {&Arg_comparator::compare_int, &Arg_comparator::compare_e_int},
+ {&Arg_comparator::compare_row, &Arg_comparator::compare_e_row}};
-/*
- Variables to store startup options
-*/
-my_bool opt_skip_slave_start = 0; // If set, slave is not autostarted
-/*
- If set, some standard measures to enforce slave data integrity will not
- be performed
-*/
-my_bool opt_reckless_slave = 0;
+/* Global variables */
-ulong back_log, connect_timeout, concurrency;
-char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], time_zone[30];
-char log_error_file[FN_REFLEN];
bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
bool opt_error_log= IF_WIN(1,0);
bool opt_disable_networking=0, opt_skip_show_db=0;
+bool server_id_supplied = 0;
+bool opt_endinfo,using_udf_functions, locked_in_memory;
+bool opt_using_transactions, using_update_log;
+bool volatile abort_loop, select_thread_in_use, signal_thread_in_use;
+bool volatile ready_to_exit, shutdown_in_progress, grant_option;
+
+my_bool opt_skip_slave_start = 0; // If set, slave is not autostarted
+my_bool opt_reckless_slave = 0;
my_bool opt_enable_named_pipe= 0;
my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol;
-uint delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
-
-static my_bool opt_do_pstack = 0;
-static ulong opt_specialflag=SPECIAL_ENGLISH;
-
-static ulong opt_myisam_block_size;
-static my_socket unix_sock= INVALID_SOCKET,ip_sock= INVALID_SOCKET;
-static my_string opt_logname=0,opt_update_logname=0,
- opt_binlog_index_name = 0,opt_slow_logname=0;
-
-static char* mysql_home_ptr= mysql_home;
-static char* pidfile_name_ptr= pidfile_name;
-char* log_error_file_ptr= log_error_file;
-static pthread_t select_thread;
-static my_bool opt_noacl=0, opt_bootstrap=0, opt_myisam_log=0;
my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
my_bool lower_case_table_names, opt_old_rpl_compat;
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
my_bool opt_log_slave_updates= 0, opt_old_passwords=0, use_old_passwords=0;
my_bool opt_console= 0, opt_bdb, opt_innodb, opt_isam;
+my_bool opt_readonly, use_temp_pool, relay_log_purge;
+volatile bool mqh_used = 0;
-volatile bool mqh_used = 0;
-FILE *bootstrap_file=0;
+uint mysql_port, test_flags, select_errors, dropping_tables, ha_open_options;
+uint delay_key_write_options, protocol_version;
+uint volatile thread_count, thread_running, kill_cached_threads, wake_thread;
-static bool kill_in_progress=0, segfaulted= 0;
-struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
-static int cleanup_done;
-static char **defaults_argv;
-char glob_hostname[FN_REFLEN];
-
-#include "sslopt-vars.h"
-#ifdef HAVE_OPENSSL
-char *des_key_file = 0;
-struct st_VioSSLAcceptorFd *ssl_acceptor_fd= 0;
-#endif /* HAVE_OPENSSL */
-
-I_List <i_string_pair> replicate_rewrite_db;
-I_List<i_string> replicate_do_db, replicate_ignore_db;
-// allow the user to tell us which db to replicate and which to ignore
-I_List<i_string> binlog_do_db, binlog_ignore_db;
-
-/* if we guessed server_id , we need to know about it */
-ulong server_id= 0; // Must be long becasue of set_var.cc
-bool server_id_supplied = 0;
-
-uint mysql_port;
-uint test_flags = 0, select_errors=0, dropping_tables=0,ha_open_options=0;
-uint volatile thread_count=0, thread_running=0, kill_cached_threads=0,
- wake_thread=0;
-ulong thd_startup_options=(OPTION_UPDATE_LOG | OPTION_AUTO_IS_NULL |
- OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE );
-uint protocol_version=PROTOCOL_VERSION;
-struct system_variables global_system_variables;
-struct system_variables max_system_variables;
-ulonglong keybuff_size;
-ulong table_cache_size,
- thread_stack,
- thread_stack_min,what_to_log= ~ (1L << (uint) COM_TIME),
- query_buff_size,
- slow_launch_time = 2L,
- slave_open_temp_tables=0,
- open_files_limit=0, max_binlog_size;
-ulong com_stat[(uint) SQLCOM_END], com_other;
+ulong back_log, connect_timeout, concurrency;
+ulong server_id, thd_startup_options;
+ulong table_cache_size, thread_stack, thread_stack_min, what_to_log;
+ulong query_buff_size, slow_launch_time, slave_open_temp_tables;
+ulong open_files_limit, max_binlog_size;
ulong slave_net_timeout;
ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
ulong query_cache_size=0;
-#ifdef HAVE_QUERY_CACHE
-ulong query_cache_limit= 0;
-ulong query_cache_min_res_unit= QUERY_CACHE_MIN_RESULT_DATA_SIZE;
-Query_cache query_cache;
-#endif
-arg_cmp_func Arg_comparator::comparator_matrix[4][2] =
-{{&Arg_comparator::compare_string, &Arg_comparator::compare_e_string},
- {&Arg_comparator::compare_real, &Arg_comparator::compare_e_real},
- {&Arg_comparator::compare_int, &Arg_comparator::compare_e_int},
- {&Arg_comparator::compare_row, &Arg_comparator::compare_e_row}};
-#ifdef HAVE_SMEM
-char *shared_memory_base_name=default_shared_memory_base_name;
-my_bool opt_enable_shared_memory = 0;
-#endif
-
-volatile ulong cached_thread_count=0;
-
-// replication parameters, if master_host is not NULL, we are a slave
-my_string master_user = (char*) "test", master_password = 0, master_host=0,
- master_info_file = (char*) "master.info",
- relay_log_info_file = (char*) "relay-log.info",
- master_ssl_key=0, master_ssl_cert=0, master_ssl_capath=0, master_ssl_cipher=0;
-my_string report_user = 0, report_password = 0, report_host=0;
-
-const char *localhost=LOCAL_HOST;
-const char *delayed_user="DELAYED";
-uint master_port = MYSQL_PORT, master_connect_retry = 60;
-uint report_port = MYSQL_PORT;
-my_bool master_ssl = 0;
-
-ulong master_retry_count=0;
-ulong bytes_sent = 0L, bytes_received = 0L;
-
-bool opt_endinfo,using_udf_functions, locked_in_memory;
-bool opt_using_transactions, using_update_log;
-bool volatile abort_loop, select_thread_in_use, signal_thread_in_use;
-bool volatile ready_to_exit, shutdown_in_progress, grant_option;
+ulong com_stat[(uint) SQLCOM_END], com_other;
+ulong bytes_sent, bytes_received;
ulong refresh_version=1L,flush_version=1L; /* Increments on each reload */
-ulong query_id=1L,long_query_count,aborted_threads,
- aborted_connects,delayed_insert_timeout,delayed_insert_limit,
- delayed_queue_size,delayed_insert_threads,delayed_insert_writes,
- delayed_rows_in_use,delayed_insert_errors,flush_time, thread_created;
+ulong query_id, long_query_count, aborted_threads, aborted_connects;
+ulong delayed_insert_timeout, delayed_insert_limit, delayed_queue_size;
+ulong delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use;
+ulong delayed_insert_errors,flush_time, thread_created;
ulong filesort_rows, filesort_range_count, filesort_scan_count;
ulong filesort_merge_passes;
ulong select_range_check_count, select_range_count, select_scan_count;
@@ -417,51 +284,52 @@ ulong max_connections,max_insert_delayed_threads,max_used_connections,
ulong thread_id=1L,current_pid;
ulong slow_launch_threads = 0;
ulong expire_logs_days = 0;
+ulong rpl_recovery_rank=0;
+ulong my_bind_addr; /* the address we bind to */
+volatile ulong cached_thread_count= 0;
+
+ulonglong keybuff_size;
+
+double log_10[32]; /* 10 potences */
+
+time_t start_time;
+char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], time_zone[30];
+char log_error_file[FN_REFLEN], glob_hostname[FN_REFLEN];
+char* log_error_file_ptr= log_error_file;
char mysql_real_data_home[FN_REFLEN],
language[LIBLEN],reg_ext[FN_EXTLEN],
mysql_charsets_dir[FN_REFLEN], *charsets_list,
max_sort_char,*mysqld_user,*mysqld_chroot, *opt_init_file;
char *language_ptr= language;
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
-#ifndef EMBEDDED_LIBRARY
-bool mysql_embedded=0;
-#else
-bool mysql_embedded=1;
-#endif
-
-static char *opt_bin_logname = 0;
-char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION;
-const char *first_keyword="first";
+char *mysql_unix_port, *opt_mysql_tmpdir;
+char *my_bind_addr_str;
const char **errmesg; /* Error messages */
const char *myisam_recover_options_str="OFF";
const char *sql_mode_str="OFF";
-ulong rpl_recovery_rank=0;
-my_bool relay_log_purge=1;
-my_string mysql_unix_port=NULL, opt_mysql_tmpdir=NULL;
-MY_TMPDIR mysql_tmpdir_list;
-ulong my_bind_addr; /* the address we bind to */
-char *my_bind_addr_str;
-DATE_FORMAT dayord;
-double log_10[32]; /* 10 potences */
+FILE *bootstrap_file;
+
+I_List <i_string_pair> replicate_rewrite_db;
+I_List<i_string> replicate_do_db, replicate_ignore_db;
+// allow the user to tell us which db to replicate and which to ignore
+I_List<i_string> binlog_do_db, binlog_ignore_db;
I_List<THD> threads,thread_cache;
-time_t start_time;
-const char *sql_mode_names[] =
-{
- "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
- "SERIALIZE", "ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",
- "POSTGRESQL", "ORACLE", "MSSQL", "DB2", "SAPDB", "NO_KEY_OPTIONS",
- "NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS", "MYSQL323", "MYSQL40",
- NullS
-};
-TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"",
- sql_mode_names};
+struct system_variables global_system_variables;
+struct system_variables max_system_variables;
+MY_TMPDIR mysql_tmpdir_list;
+DATE_FORMAT dayord;
MY_BITMAP temp_pool;
-my_bool use_temp_pool=0;
+
+SHOW_COMP_OPTION have_berkeley_db, have_innodb, have_isam;
+SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_query_cache;
+SHOW_COMP_OPTION have_crypt, have_compress;
+
+/* Thread specific variables */
pthread_key(MEM_ROOT*,THR_MALLOC);
pthread_key(THD*, THR_THD);
@@ -479,24 +347,98 @@ pthread_cond_t COND_thread_cache,COND_flush_thread_cache;
pthread_t signal_thread;
pthread_attr_t connection_attrib;
+/* replication parameters, if master_host is not NULL, we are a slave */
+my_bool master_ssl;
+uint master_port= MYSQL_PORT, master_connect_retry = 60;
+uint report_port= MYSQL_PORT;
+ulong master_retry_count=0;
+char *master_user, *master_password, *master_host, *master_info_file;
+char *relay_log_info_file, *master_ssl_key, *master_ssl_cert;
+char *master_ssl_capath, *master_ssl_cipher, *report_user;
+char *report_password, *report_host;
+char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
+
+/* Static variables */
+
+static bool kill_in_progress, segfaulted;
+static my_bool opt_do_pstack, opt_noacl, opt_bootstrap, opt_myisam_log;
+static int cleanup_done;
+static ulong opt_specialflag, opt_myisam_block_size;
+static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
+static char *opt_slow_logname;
+static char *mysql_home_ptr, *pidfile_name_ptr;
+static char **defaults_argv;
+static char *opt_bin_logname;
+
+static my_socket unix_sock,ip_sock;
+static pthread_t select_thread;
+struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
+
+/* OS specific variables */
+
#ifdef __WIN__
#undef getpid
#include <process.h>
+
+static pthread_cond_t COND_handler_count;
+static uint handler_count;
+static bool start_mode=0, use_opt_args;
+static int opt_argc;
+static char **opt_argv;
+
#if !defined(EMBEDDED_LIBRARY)
-HANDLE hEventShutdown;
+static HANDLE hEventShutdown;
static char shutdown_event_name[40];
#include "nt_servc.h"
static NTService Service; // Service object for WinNT
-#endif
+#endif /* EMBEDDED_LIBRARY */
+#endif /* __WIN__ */
+
+#ifdef __NT__
+static char szPipeName [ 257 ];
+static SECURITY_ATTRIBUTES saPipeSecurity;
+static SECURITY_DESCRIPTOR sdPipeDescriptor;
+static HANDLE hPipe = INVALID_HANDLE_VALUE;
#endif
#ifdef OS2
pthread_cond_t eventShutdown;
#endif
+#ifndef EMBEDDED_LIBRARY
+bool mysql_embedded=0;
+#else
+bool mysql_embedded=1;
+#endif
+
+#ifndef DBUG_OFF
+static const char* default_dbug_option;
+#endif
+#ifdef HAVE_LIBWRAP
+char *libwrapName= NULL;
+#endif
+#ifdef HAVE_QUERY_CACHE
+ulong query_cache_limit= 0;
+ulong query_cache_min_res_unit= QUERY_CACHE_MIN_RESULT_DATA_SIZE;
+Query_cache query_cache;
+#endif
+#ifdef HAVE_SMEM
+char *shared_memory_base_name= default_shared_memory_base_name;
+my_bool opt_enable_shared_memory;
+#endif
+
+#include "sslopt-vars.h"
+#ifdef HAVE_OPENSSL
+char *des_key_file;
+struct st_VioSSLAcceptorFd *ssl_acceptor_fd;
+#endif /* HAVE_OPENSSL */
+
+
+/* Function declarations */
+
static void start_signal_handler(void);
extern "C" pthread_handler_decl(signal_hand, arg);
-static void set_options(void);
+static void mysql_init_variables(void);
static void get_options(int argc,char **argv);
static int init_thread_environment();
static char *get_relative_path(const char *path);
@@ -1998,6 +1940,7 @@ static int init_common_variables(const char *conf_file_name, int argc,
max_system_variables.pseudo_thread_id= (ulong)~0;
start_time=time((time_t*) 0);
+ mysql_init_variables();
#ifdef OS2
{
@@ -2036,7 +1979,6 @@ static int init_common_variables(const char *conf_file_name, int argc,
load_defaults(conf_file_name, groups, &argc, &argv);
defaults_argv=argv;
- set_options();
get_options(argc,argv);
if (init_thread_environment())
return 1;
@@ -4610,18 +4552,110 @@ To see what values a running MySQL server is using, type\n\
}
-static void set_options(void)
-{
-#if !defined( my_pthread_setprio ) && !defined( HAVE_PTHREAD_SETSCHEDPARAM )
- opt_specialflag |= SPECIAL_NO_PRIOR;
-#endif
+/*
+ Initialize all MySQL global variables to default values
+ SYNOPSIS
+ mysql_init_variables()
+
+ NOTES
+ The reason to set a lot of global variables to zero is to allow one to
+ restart the embedded server with a clean environment
+ It's also needed on some exotic platforms where global variables are
+ not set to 0 when a program starts.
+
+ We don't need to set numeric variables refered to in my_long_options
+ as these are initialized by my_getopt.
+*/
+
+static void mysql_init_variables(void)
+{
+ /* Things reset to zero */
+ opt_skip_slave_start= opt_reckless_slave = 0;
+ mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
+ opt_log= opt_update_log= opt_bin_log= opt_slow_log= 0;
+ opt_disable_networking= opt_skip_show_db=0;
+ opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname=0;
+ opt_bootstrap= opt_myisam_log= use_old_passwords= 0;
+ mqh_used= 0;
+ segfaulted= kill_in_progress= 0;
+ cleanup_done= 0;
+ defaults_argv= 0;
+ server_id_supplied= 0;
+ test_flags= select_errors= dropping_tables= ha_open_options=0;
+ thread_count= thread_running= kill_cached_threads= wake_thread=0;
+ slave_open_temp_tables= 0;
+ com_other= 0;
+ cached_thread_count= 0;
+ bytes_sent= bytes_received= 0;
+ opt_endinfo= using_udf_functions= 0;
+ opt_using_transactions= using_update_log= 0;
+ abort_loop= select_thread_in_use= signal_thread_in_use= 0;
+ ready_to_exit= shutdown_in_progress= grant_option= 0;
+ long_query_count= aborted_threads= aborted_connects= 0;
+ delayed_insert_threads= delayed_insert_writes= delayed_rows_in_use= 0;
+ delayed_insert_errors= thread_created= 0;
+ filesort_rows= filesort_range_count= filesort_scan_count= 0;
+ filesort_merge_passes= select_range_check_count= select_range_count= 0;
+ select_scan_count= select_full_range_join_count= select_full_join_count= 0;
+ specialflag= opened_tables= created_tmp_tables= created_tmp_disk_tables= 0;
+ max_used_connections= slow_launch_threads = 0;
+ max_sort_char= 0;
+ mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
+ errmesg= 0;
+ mysql_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS;
+ bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
+ bzero((gptr) &com_stat, sizeof(com_stat));
+
+ /* Things with default values that are not zero */
+ delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
+ opt_specialflag= SPECIAL_ENGLISH;
+ unix_sock= ip_sock= INVALID_SOCKET;
+ mysql_home_ptr= mysql_home;
+ pidfile_name_ptr= pidfile_name;
+ log_error_file_ptr= log_error_file;
+ language_ptr= language;
+ mysql_data_home= mysql_real_data_home;
+ thd_startup_options= (OPTION_UPDATE_LOG | OPTION_AUTO_IS_NULL |
+ OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE);
+ protocol_version= PROTOCOL_VERSION;
+ what_to_log= ~ (1L << (uint) COM_TIME);
+ refresh_version= flush_version= 1L; /* Increments on each reload */
+ thread_id= 1L;
+ strmov(server_version, MYSQL_SERVER_VERSION);
+ myisam_recover_options_str= sql_mode_str= "OFF";
+ my_bind_addr = htonl(INADDR_ANY);
+ threads.empty();
+ thread_cache.empty();
+
+ /* Initialize structures that is used when processing options */
+ replicate_rewrite_db.empty();
+ replicate_do_db.empty();
+ replicate_ignore_db.empty();
+ binlog_do_db.empty();
+ binlog_ignore_db.empty();
+
+ /* Set directory paths */
+ strmake(language, LANGUAGE, sizeof(language)-1);
+ strmake(mysql_real_data_home, get_relative_path(DATADIR),
+ sizeof(mysql_real_data_home)-1);
+ mysql_data_home_buff[0]=FN_CURLIB; // all paths are relative from here
+ mysql_data_home_buff[1]=0;
+
+ /* Replication parameters */
+ master_user= (char*) "test";
+ master_password= master_host= 0;
+ master_info_file= (char*) "master.info",
+ relay_log_info_file= (char*) "relay-log.info",
+ master_ssl_key= master_ssl_cert= master_ssl_capath= master_ssl_cipher= 0;
+ report_user= report_password = report_host= 0; /* TO BE DELETED */
+ opt_relay_logname= opt_relaylog_index_name= 0;
+
+ /* Variables in libraries */
+ charsets_dir= 0;
sys_charset.value= (char*) MYSQL_CHARSET;
- (void) strmake(language, LANGUAGE, sizeof(language)-1);
- (void) strmake(mysql_real_data_home, get_relative_path(DATADIR),
- sizeof(mysql_real_data_home)-1);
- /* Set default values for some variables */
+ /* Set default values for some option variables */
global_system_variables.collation_results= default_charset_info;
global_system_variables.collation_client= default_charset_info;
global_system_variables.collation_connection= default_charset_info;
@@ -4632,6 +4666,71 @@ static void set_options(void)
global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
+ /* Variables that depends on compile options */
+#ifndef DBUG_OFF
+ default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace",
+ "d:t:i:o,/tmp/mysqld.trace");
+#endif
+ opt_error_log= IF_WIN(1,0);
+#ifdef HAVE_BERKELEY_DB
+ have_berkeley_db= SHOW_OPTION_YES;
+#else
+ have_berkeley_db= SHOW_OPTION_NO;
+#endif
+#ifdef HAVE_INNOBASE_DB
+ have_innodb=SHOW_OPTION_YES;
+#else
+ have_innodb=SHOW_OPTION_NO;
+#endif
+#ifdef HAVE_ISAM
+ have_isam=SHOW_OPTION_YES;
+#else
+ have_isam=SHOW_OPTION_NO;
+#endif
+#ifdef USE_RAID
+ have_raid=SHOW_OPTION_YES;
+#else
+ have_raid=SHOW_OPTION_NO;
+#endif
+#ifdef HAVE_OPENSSL
+ have_openssl=SHOW_OPTION_YES;
+#else
+ have_openssl=SHOW_OPTION_NO;
+#endif
+#ifdef HAVE_BROKEN_REALPATH
+ have_symlink=SHOW_OPTION_NO;
+#else
+ have_symlink=SHOW_OPTION_YES;
+#endif
+#ifdef HAVE_QUERY_CACHE
+ have_query_cache=SHOW_OPTION_YES;
+#else
+ have_query_cache=SHOW_OPTION_NO;
+#endif
+#ifdef HAVE_CRYPT
+ have_crypt=SHOW_OPTION_YES;
+#else
+ have_crypt=SHOW_OPTION_NO;
+#endif
+#ifdef HAVE_COMPRESS
+ SHOW_COMP_OPTION have_compress= SHOW_OPTION_YES;
+#else
+ SHOW_COMP_OPTION have_compress= SHOW_OPTION_NO;
+#endif
+#ifdef HAVE_LIBWRAP
+ libwrapName= NullS;
+#endif
+#ifdef HAVE_OPENSSL
+ des_key_file = 0;
+ ssl_acceptor_fd= 0;
+#endif
+#ifdef HAVE_SMEM
+ shared_memory_base_name= default_shared_memory_base_name;
+#endif
+#if !defined(my_pthread_setprio) && !defined(HAVE_PTHREAD_SETSCHEDPARAM)
+ opt_specialflag |= SPECIAL_NO_PRIOR;
+#endif
+
#if defined(__WIN__) || defined(__NETWARE__)
/* Allow Win32 and NetWare users to move MySQL anywhere */
{
@@ -4646,10 +4745,6 @@ static void set_options(void)
tmpenv = DEFAULT_MYSQL_HOME;
(void) strmake(mysql_home, tmpenv, sizeof(mysql_home)-1);
#endif
-
- my_disable_locking=myisam_single_user= 1;
- opt_external_locking=0;
- my_bind_addr = htonl( INADDR_ANY );
}
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index b96c6383bbb..34cce98d087 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -280,6 +280,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
if (!error && reckey_in_range(1, &ref, item_field->field,
conds, range_fl, prefix_len))
error= HA_ERR_KEY_NOT_FOUND;
+ }
if (table->key_read)
{
table->key_read=0;
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 0071f50f7a0..3071bc7ff92 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -232,8 +232,7 @@ sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol",
sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout",
&slave_net_timeout);
#endif
-sys_var_bool_ptr sys_readonly("read_only",
- &opt_readonly);
+sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
sys_var_long_ptr sys_slow_launch_time("slow_launch_time",
&slow_launch_time);
sys_var_thd_ulong sys_sort_buffer("sort_buffer_size",
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index accbc9cf205..ec6db64ea73 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -2672,9 +2672,12 @@ bool check_grant_all_columns(THD *thd, ulong want_access, TABLE *table)
want_access &= ~table->grant.privilege;
if (!want_access)
- return 0; // Already checked
+ return 0; // Already checked
if (!grant_option)
+ {
+ field= table->field[0]; // To give a meaningful error message
goto err2;
+ }
rw_rdlock(&LOCK_grant);
@@ -3134,7 +3137,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
}
global.append(" ON `",5);
global.append(grant_table->db);
- global.append("`.`,3);
+ global.append("`.`",3);
global.append(grant_table->tname);
global.append("` TO '",6);
global.append(lex_user->user.str,lex_user->user.length);
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index b288dc68b42..e0a592d2450 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -434,7 +434,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
my_dirend(dirp);
DBUG_RETURN(-1);
}
- raid_dirs.push_back(dir=new String(newpath));
+ raid_dirs.push_back(dir=new String(newpath, &my_charset_latin1));
dir->copy();
continue;
}
@@ -448,7 +448,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
continue;
}
strxmov(filePath,org_path,"/",file->name,NullS);
- if (db && !my_strcasecmp(&my_charset_latin1,
+ if (db && !my_strcasecmp(&my_charset_latin1,
fn_ext(file->name), reg_ext))
{
/* Drop the table nicely */
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 7f555f37d40..2bf1a68e504 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -116,7 +116,8 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
TABLE_LIST *first_table= (TABLE_LIST*) select_cursor->table_list.first;
/* Setting up. A must if a join or IGNORE, USE or similar are utilised */
if (setup_tables(first_table) ||
- setup_wild(thd, first_table, select_cursor->item_list, 0, select_cursor->with_wild))
+ setup_wild(thd, first_table, select_cursor->item_list, 0,
+ select_cursor->with_wild))
{
res= -1;
goto exit;
@@ -128,16 +129,18 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
(item_list.elements + select_cursor->with_sum_func +
select_cursor->order_list.elements +
select_cursor->group_list.elements)) ||
- setup_fields(thd, select_cursor->ref_pointer_array, first_table, item_list,
- 0, 0, 1))
+ setup_fields(thd, select_cursor->ref_pointer_array, first_table,
+ item_list, 0, 0, 1))
{
res= -1;
goto exit;
}
bzero((char*) &tmp_table_param,sizeof(tmp_table_param));
tmp_table_param.field_count= item_list.elements;
- /* temp table is created so that it hounours if UNION without ALL is to be
- processed */
+ /*
+ Temp table is created so that it hounours if UNION without ALL is to be
+ processed
+ */
if (!(table= create_tmp_table(thd, &tmp_table_param, item_list,
(ORDER*) 0,
is_union && !unit->union_option, 1,
@@ -190,6 +193,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
org_table_list->table=table;
table->derived_select_number= select_cursor->select_number;
table->tmp_table= TMP_TABLE;
+ org_table_list->grant.privilege= SELECT_ACL;
if (lex->describe)
{
// to fix a problem in EXPLAIN
@@ -206,7 +210,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
/* Try to catch errors if this is accessed */
org_table_list->derived=(SELECT_LEX_UNIT *) 1;
#endif
-// This line is required to force read of table stats in the optimizer
+ // Force read of table stats in the optimizer
table->file->info(HA_STATUS_VARIABLE);
}
}
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 829300859cf..003c40077ed 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -483,7 +483,8 @@ int write_record(TABLE *table,COPY_INFO *info)
key_copy((byte*) key,table,key_nr,0);
if ((error=(table->file->index_read_idx(table->record[1],key_nr,
(byte*) key,
- table->key_info[key_nr].key_length,
+ table->key_info[key_nr].
+ key_length,
HA_READ_KEY_EXACT))))
goto err;
}
@@ -495,7 +496,7 @@ int write_record(TABLE *table,COPY_INFO *info)
*/
store_record(table,insert_values);
restore_record(table,record[1]);
- if (fill_record(*info->update_fields,*info->update_values))
+ if (fill_record(*info->update_fields, *info->update_values, 0))
goto err;
if ((error=table->file->update_row(table->record[1],table->record[0])))
goto err;
@@ -506,10 +507,11 @@ int write_record(TABLE *table,COPY_INFO *info)
{
if (last_uniq_key(table,key_nr))
{
- if ((error=table->file->update_row(table->record[1],table->record[0])))
+ if ((error=table->file->update_row(table->record[1],
+ table->record[0])))
goto err;
info->deleted++;
- break; /* Update logfile and count */
+ break; /* Update logfile and count */
}
else if ((error=table->file->delete_row(table->record[1])))
goto err;
diff --git a/sql/sql_list.h b/sql/sql_list.h
index 27cdc117267..ff21663576a 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -368,6 +368,7 @@ template <class T>
class I_List :private base_ilist {
public:
I_List() :base_ilist() {}
+ inline void empty() { base_ilist::empty(); }
inline bool is_empty() { return base_ilist::is_empty(); }
inline void append(T* a) { base_ilist::append(a); }
inline void push_back(T* a) { base_ilist::push_back(a); }
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 45c5ea4d520..3c2380b619d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -213,7 +213,7 @@ static int check_user(THD *thd,enum_server_command command, const char *user,
thd->db=0;
thd->db_length=0;
USER_RESOURCES ur;
- char tmp_passwd[SCRAMBL41_LENGTH];
+ char tmp_passwd[SCRAMBLE41_LENGTH];
DBUG_ENTER("check_user");
/*
@@ -231,7 +231,7 @@ static int check_user(THD *thd,enum_server_command command, const char *user,
}
thd->master_access=acl_getroot(thd, thd->host, thd->ip, thd->user,
passwd, thd->scramble,
- &thd->priv_user, &thd->priv_host,
+ &thd->priv_user, thd->priv_host,
(protocol_version == 9 ||
!(thd->client_capabilities &
CLIENT_LONG_PASSWORD)),
@@ -1666,7 +1666,7 @@ mysql_execute_command(THD *thd)
!(thd->slave_thread || (thd->master_access & SUPER_ACL)) &&
(uc_update_queries[lex->sql_command] > 0))
{
- send_error(&thd->net,ER_CANT_UPDATE_WITH_READLOCK);
+ send_error(thd, ER_CANT_UPDATE_WITH_READLOCK);
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 4456c631032..b03438bdbe0 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -626,7 +626,7 @@ JOIN::optimize()
Force MySQL to read the table in sorted order to get result in
ORDER BY order.
*/
- join.tmp_table_param.quick_group=0;
+ tmp_table_param.quick_group=0;
}
order=0;
}
@@ -4264,7 +4264,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
table->blob_ptr_size=mi_portable_sizeof_char_ptr;
table->map=1;
table->tmp_table= TMP_TABLE;
- table->derived_select_number= 0;
table->db_low_byte_first=1; // True for HEAP and MyISAM
table->temp_pool_slot = temp_pool_slot;
table->copy_blobs= 1;
@@ -7983,6 +7982,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
TABLE *table=tab->table;
char buff[512],*buff_ptr=buff;
char buff1[512], buff2[512];
+ char derived_name[64];
String tmp1(buff1,sizeof(buff1),cs);
String tmp2(buff2,sizeof(buff2),cs);
tmp1.length(0);
@@ -7996,13 +7996,13 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
cs));
if (tab->type == JT_ALL && tab->select && tab->select->quick)
tab->type= JT_RANGE;
- if (table->tmp_table == TMP_TABLE && table->derived_select_number != 0)
+ if (table->derived_select_number)
{
- // Derived table name generation
- char buff[512];
- int len= my_snprintf(buff, 512, "<derived%u>",
+ /* Derived table name generation */
+ int len= my_snprintf(derived_name, sizeof(derived_name)-1,
+ "<derived%u>",
table->derived_select_number);
- item_list.push_back(new Item_string(buff, len, cs));
+ item_list.push_back(new Item_string(derived_name, len, cs));
}
else
item_list.push_back(new Item_string(table->table_name,
@@ -8196,5 +8196,3 @@ void free_underlaid_joins(THD *thd, SELECT_LEX *select)
unit= unit->next_unit())
unit->cleanup();
}
-
-
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index a77987e4806..25bbd4851ba 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1590,11 +1590,10 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
case SHOW_QUESTION:
end= int10_to_str((long) thd->query_id, buff, 10);
break;
-#ifndef EMBEDDED_LIBRARY
+#ifdef HAVE_REPLICATION
case SHOW_RPL_STATUS:
end= strmov(buff, rpl_status_type[(int)rpl_status]);
break;
-#ifdef HAVE_REPLICATION
case SHOW_SLAVE_RUNNING:
{
LOCK_ACTIVE_MI;
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index ca38651b3b6..bd101944160 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -34,9 +34,6 @@ CHARSET_INFO *national_charset_info= &my_charset_utf8;
extern gptr sql_alloc(unsigned size);
extern void sql_element_free(void *ptr);
-static uint32
-copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
- const char *from, uint32 from_length, CHARSET_INFO *from_cs);
#include "sql_string.h"
@@ -630,7 +627,7 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
*/
-static uint32
+uint32
copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
const char *from, uint32 from_length, CHARSET_INFO *from_cs)
{
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 9c494600058..8212bd0a2bd 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -27,6 +27,9 @@
class String;
int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
+uint32 copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
+ const char *from, uint32 from_length,
+ CHARSET_INFO *from_cs);
class String
{
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 1526908f025..b0e6cd1e644 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -97,7 +97,7 @@ int mysql_update(THD *thd,
setup_ref_array(thd, &thd->lex.select_lex.ref_pointer_array,
order_num) ||
setup_order(thd, thd->lex.select_lex.ref_pointer_array,
- &tables, fields, all_fields, order) ||
+ &tables, all_fields, all_fields, order) ||
setup_ftfuncs(&thd->lex.select_lex))
DBUG_RETURN(-1); /* purecov: inspected */
@@ -207,7 +207,7 @@ int mysql_update(THD *thd,
MYF(MY_FAE | MY_ZEROFILL));
if (!(sortorder=make_unireg_sortorder(order, &length)) ||
(table->sort.found_records = filesort(thd, table, sortorder, length,
- select, 0L, limit,
+ select, limit,
&examined_rows))
== HA_POS_ERROR)
{
@@ -755,7 +755,7 @@ bool multi_update::send_data(List<Item> &not_used_values)
{
table->status|= STATUS_UPDATED;
store_record(table,record[1]);
- if (fill_record(*fields_for_table[offset], *values_for_table[offset]), 0)
+ if (fill_record(*fields_for_table[offset], *values_for_table[offset], 0))
DBUG_RETURN(1);
found++;
if (compare_record(table, thd->query_id))
@@ -793,7 +793,7 @@ bool multi_update::send_data(List<Item> &not_used_values)
(error != HA_ERR_FOUND_DUPP_KEY &&
error != HA_ERR_FOUND_DUPP_UNIQUE))
{
- if (create_myisam_from_heap(thd, table, tmp_table_param + offset,
+ if (create_myisam_from_heap(thd, tmp_table, tmp_table_param + offset,
error, 1))
{
do_update=0;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 659cddb1090..2adb7377348 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -2180,8 +2180,10 @@ simple_expr:
simple_ident
| simple_expr COLLATE_SYM ident_or_text %prec NEG
{
- $$= new Item_func_set_collation($1,new Item_string($3.str,$3.length,
- YYTHD->charset()));
+ $$= new Item_func_set_collation($1,
+ new Item_string($3.str,
+ $3.length,
+ YYTHD->charset()));
}
| literal
| param_marker
@@ -2228,8 +2230,8 @@ simple_expr:
| ASCII_SYM '(' expr ')' { $$= new Item_func_ascii($3); }
| BINARY expr %prec NEG
{
- $$= new Item_func_set_collation($2,new Item_string("BINARY",6,
- &my_charset_latin1));
+ $$= new Item_func_set_collation($2,new Item_string(binary_keyword,
+ 6, &my_charset_latin1));
}
| CAST_SYM '(' expr AS cast_type ')' { $$= create_func_cast($3, $5); }
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
@@ -2580,9 +2582,9 @@ sum_expr:
| COUNT_SYM '(' in_sum_expr ')'
{ $$=new Item_sum_count($3); }
| COUNT_SYM '(' DISTINCT
- { Select->in_sum_expr++; }
+ { Select->select_lex()->in_sum_expr++; }
expr_list
- { Select->in_sum_expr--; }
+ { Select->select_lex()->in_sum_expr--; }
')'
{ $$=new Item_sum_count_distinct(* $5); }
| GROUP_UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' in_sum_expr ')'
diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc
index 57560715fbe..fa678ec7de2 100644
--- a/sql/thr_malloc.cc
+++ b/sql/thr_malloc.cc
@@ -85,3 +85,33 @@ gptr sql_memdup(const void *ptr,uint len)
void sql_element_free(void *ptr __attribute__((unused)))
{} /* purecov: deadcode */
+
+
+
+char *sql_strmake_with_convert(const char *str, uint32 arg_length,
+ CHARSET_INFO *from_cs,
+ uint32 max_res_length,
+ CHARSET_INFO *to_cs, uint32 *result_length)
+{
+ char *pos;
+ uint32 new_length= to_cs->mbmaxlen*arg_length;
+ max_res_length--; // Reserve place for end null
+
+ set_if_smaller(new_length, max_res_length);
+ if (!(pos= sql_alloc(new_length+1)))
+ return pos; // Error
+
+ if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
+ {
+ // Safety if to_cs->mbmaxlen > 0
+ new_length= min(arg_length, max_res_length);
+ memcpy(pos, str, new_length);
+ }
+ else
+ new_length= copy_and_convert((char*) pos, new_length, to_cs, str,
+ arg_length, from_cs);
+ pos[new_length]= 0;
+ *result_length= new_length;
+ return pos;
+}
+
diff --git a/sql/unireg.h b/sql/unireg.h
index b3ea6e3fa21..6ddd9856724 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -45,6 +45,7 @@
#define LIBLEN FN_REFLEN-FN_LEN /* Max l{ngd p} dev */
#define MAX_DBKEY_LENGTH (FN_LEN*2+6) /* extra 4 bytes for slave tmp
* tables */
+#define MAX_ALIAS_NAME 256
#define MAX_FIELD_NAME 34 /* Max colum name length +2 */
#define MAX_SYS_VAR_LENGTH 32
#define MAX_KEY 32 /* Max used keys */