summaryrefslogtreecommitdiff
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
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
-rw-r--r--BUILD/SETUP.sh2
-rw-r--r--client/mysqltest.c60
-rw-r--r--myisam/mi_key.c2
-rw-r--r--myisam/mi_open.c6
-rw-r--r--myisam/mi_range.c5
-rw-r--r--myisam/mi_rkey.c2
-rw-r--r--myisam/mi_search.c4
-rw-r--r--myisam/myisamdef.h4
-rw-r--r--mysql-test/include/not_embedded.inc2
-rw-r--r--mysql-test/r/alter_table.result4
-rw-r--r--mysql-test/r/create.result6
-rw-r--r--mysql-test/r/ctype_recoding.result1
-rw-r--r--mysql-test/r/fulltext.result1
-rw-r--r--mysql-test/r/func_group.result94
-rw-r--r--mysql-test/r/group_by.result16
-rw-r--r--mysql-test/r/innodb.result12
-rw-r--r--mysql-test/r/join_outer.result1
-rw-r--r--mysql-test/r/null_key.result2
-rw-r--r--mysql-test/r/order_by.result4
-rw-r--r--mysql-test/r/query_cache.result20
-rw-r--r--mysql-test/r/repair.result2
-rw-r--r--mysql-test/r/rpl_flush_tables.result4
-rw-r--r--mysql-test/r/union.result37
-rw-r--r--mysql-test/r/update.result5
-rw-r--r--mysql-test/t/ansi.test2
-rw-r--r--mysql-test/t/create.test10
-rw-r--r--mysql-test/t/ctype_recoding.test1
-rw-r--r--mysql-test/t/ctype_ujis.test2
-rw-r--r--mysql-test/t/fulltext.test2
-rw-r--r--mysql-test/t/innodb.test1
-rw-r--r--mysql-test/t/join_outer.test2
-rw-r--r--mysql-test/t/loaddata.test2
-rw-r--r--mysql-test/t/order_by.test2
-rw-r--r--mysql-test/t/rpl_flush_tables.test2
-rw-r--r--mysql-test/t/status.test2
-rw-r--r--mysql-test/t/subselect.test2
-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
-rw-r--r--strings/ctype-ujis.c2
64 files changed, 688 insertions, 542 deletions
diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh
index 55b82e38d63..4a19c490e5d 100644
--- a/BUILD/SETUP.sh
+++ b/BUILD/SETUP.sh
@@ -52,7 +52,7 @@ debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFEMA
base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti"
-base_configs="--prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client"
+base_configs="--prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-readline"
static_link="--with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static"
alpha_configs="" # Not used yet
pentium_configs=""
diff --git a/client/mysqltest.c b/client/mysqltest.c
index fb2104f43f4..9889d365335 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -939,16 +939,16 @@ int do_system(struct st_query* q)
var_init(&v, 0, 0, 0, 0);
eval_expr(&v, p, 0); /* NULL terminated */
if (v.str_val_len)
- {
- char expr_buf[512];
- if ((uint)v.str_val_len > sizeof(expr_buf) - 1)
- v.str_val_len = sizeof(expr_buf) - 1;
- memcpy(expr_buf, v.str_val, v.str_val_len);
- expr_buf[v.str_val_len] = 0;
- DBUG_PRINT("info", ("running system command '%s'", expr_buf));
- if (system(expr_buf) && q->abort_on_error)
- die("system command '%s' failed", expr_buf);
- }
+ {
+ char expr_buf[512];
+ if ((uint)v.str_val_len > sizeof(expr_buf) - 1)
+ v.str_val_len = sizeof(expr_buf) - 1;
+ memcpy(expr_buf, v.str_val, v.str_val_len);
+ expr_buf[v.str_val_len] = 0;
+ DBUG_PRINT("info", ("running system command '%s'", expr_buf));
+ if (system(expr_buf) && q->abort_on_error)
+ die("system command '%s' failed", expr_buf);
+ }
var_free(&v);
return 0;
}
@@ -2284,7 +2284,7 @@ void get_query_type(struct st_query* q)
q->type=(enum enum_commands) type; /* Found command */
}
-static byte* get_var_key(const byte* var, uint* len,
+static byte *get_var_key(const byte* var, uint* len,
my_bool __attribute__((unused)) t)
{
register char* key;
@@ -2293,11 +2293,11 @@ static byte* get_var_key(const byte* var, uint* len,
return (byte*)key;
}
-static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
+static VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
int val_len)
{
int val_alloc_len;
- VAR* tmp_var;
+ VAR *tmp_var;
if (!name_len && name)
name_len = strlen(name);
if (!val_len && val)
@@ -2327,7 +2327,7 @@ static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
return tmp_var;
}
-static void var_free(void* v)
+static void var_free(void *v)
{
my_free(((VAR*) v)->str_val, MYF(MY_WME));
if (((VAR*)v)->alloced)
@@ -2335,10 +2335,10 @@ static void var_free(void* v)
}
-static void var_from_env(const char* name, const char* def_val)
+static void var_from_env(const char *name, const char *def_val)
{
- const char* tmp;
- VAR* v;
+ const char *tmp;
+ VAR *v;
if (!(tmp = getenv(name)))
tmp = def_val;
@@ -2347,9 +2347,9 @@ static void var_from_env(const char* name, const char* def_val)
}
-static void init_var_hash()
+static void init_var_hash(MYSQL *mysql)
{
- VAR* v;
+ VAR *v;
DBUG_ENTER("init_var_hash");
if (hash_init(&var_hash, charset_info,
1024, 0, 0, get_var_key, var_free, MYF(0)))
@@ -2358,16 +2358,19 @@ static void init_var_hash()
var_from_env("SLAVE_MYPORT", "9307");
var_from_env("MYSQL_TEST_DIR", "/tmp");
var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
- v=var_init(0,"MAX_TABLES", 0, (sizeof(ulong) == 4) ? "31" : "63",0);
- hash_insert(&var_hash, (byte*)v);
+ v= var_init(0,"MAX_TABLES", 0, (sizeof(ulong) == 4) ? "31" : "62",0);
+ hash_insert(&var_hash, (byte*) v);
+ v= var_init(0,"SERVER_VERSION", 0, mysql_get_server_info(mysql), 0);
+ hash_insert(&var_hash, (byte*) v);
+
DBUG_VOID_RETURN;
}
-int main(int argc, char** argv)
+int main(int argc, char **argv)
{
int error = 0;
- struct st_query* q;
+ struct st_query *q;
my_bool require_file=0, q_send_flag=0;
char save_file[FN_REFLEN];
MY_INIT(argv[0]);
@@ -2402,7 +2405,6 @@ int main(int argc, char** argv)
embedded_server_args,
(char**) embedded_server_groups))
die("Can't initialize MySQL server");
- init_var_hash();
if (cur_file == file_stack)
*++cur_file = stdin;
*lineno=1;
@@ -2421,14 +2423,14 @@ int main(int argc, char** argv)
opt_ssl_capath, opt_ssl_cipher);
#endif
- cur_con->name = my_strdup("default", MYF(MY_WME));
- if (!cur_con->name)
+ if (!(cur_con->name = my_strdup("default", MYF(MY_WME))))
die("Out of memory");
- if (safe_connect(&cur_con->mysql, host,
- user, pass, db, port, unix_sock))
+ if (safe_connect(&cur_con->mysql, host, user, pass, db, port, unix_sock))
die("Failed in mysql_real_connect(): %s", mysql_error(&cur_con->mysql));
+ init_var_hash(&cur_con->mysql);
+
while (!read_query(&q))
{
int current_line_inc = 1, processed = 0;
@@ -2596,7 +2598,7 @@ int main(int argc, char** argv)
*/
-static int read_server_arguments(const char* name)
+static int read_server_arguments(const char *name)
{
char argument[1024],buff[FN_REFLEN], *str=0;
FILE *file;
diff --git a/myisam/mi_key.c b/myisam/mi_key.c
index 37708a399b0..a375a415103 100644
--- a/myisam/mi_key.c
+++ b/myisam/mi_key.c
@@ -164,7 +164,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
*/
uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
- uint k_length, MI_KEYSEG **last_used_keyseg)
+ uint k_length, HA_KEYSEG **last_used_keyseg)
{
uint length;
uchar *pos,*end,*start_key=key;
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index 6da1a0395c0..178365577aa 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -186,12 +186,6 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
}
share->state_diff_length=len-MI_STATE_INFO_SIZE;
- if (share->state.header.fulltext_keys)
- {
- /* Not supported in this version */
- my_errno= HA_ERR_UNSUPPORTED;
- goto err;
- }
mi_state_info_read(disk_cache, &share->state);
len= mi_uint2korr(share->state.header.base_info_length);
if (len != MI_BASE_INFO_SIZE)
diff --git a/myisam/mi_range.c b/myisam/mi_range.c
index d5a786438cd..379ffba135a 100644
--- a/myisam/mi_range.c
+++ b/myisam/mi_range.c
@@ -59,7 +59,8 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, const byte *start_key,
if (start_key_len == 0)
start_key_len=USE_WHOLE_KEY;
key_buff=info->lastkey+info->s->base.max_key_length;
- start_key_len=_mi_pack_key(info,inx,key_buff,(uchar*) start_key,start_key_len);
+ start_key_len= _mi_pack_key(info,inx,key_buff,(uchar*) start_key,
+ start_key_len, (HA_KEYSEG**) 0);
res=rtree_estimate(info, inx, key_buff, start_key_len, myisam_read_vec[start_search_flag]);
res=res?res:1;
break;
@@ -104,7 +105,7 @@ static ha_rows _mi_record_pos(MI_INFO *info, const byte *key, uint key_len,
key_len=USE_WHOLE_KEY;
key_buff=info->lastkey+info->s->base.max_key_length;
key_len=_mi_pack_key(info,inx,key_buff,(uchar*) key,key_len,
- (MI_KEYSEG**) 0);
+ (HA_KEYSEG**) 0);
DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg,
(uchar*) key_buff,key_len););
nextflag=myisam_read_vec[search_flag];
diff --git a/myisam/mi_rkey.c b/myisam/mi_rkey.c
index a702f78b926..ddfac0a39a2 100644
--- a/myisam/mi_rkey.c
+++ b/myisam/mi_rkey.c
@@ -28,7 +28,7 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
uchar *key_buff;
MYISAM_SHARE *share=info->s;
MI_KEYDEF *keyinfo;
- MI_KEYSEG *last_used_keyseg;
+ HA_KEYSEG *last_used_keyseg;
uint pack_key_length, use_key_length, nextflag;
DBUG_ENTER("mi_rkey");
DBUG_PRINT("enter",("base: %lx inx: %d search_flag: %d",
diff --git a/myisam/mi_search.c b/myisam/mi_search.c
index 340d8ec2db6..7e8577c0656 100644
--- a/myisam/mi_search.c
+++ b/myisam/mi_search.c
@@ -1042,9 +1042,9 @@ uint _mi_keylength(MI_KEYDEF *keyinfo, register uchar *key)
*/
uint _mi_keylength_part(MI_KEYDEF *keyinfo, register uchar *key,
- MI_KEYSEG *end)
+ HA_KEYSEG *end)
{
- reg1 MI_KEYSEG *keyseg;
+ reg1 HA_KEYSEG *keyseg;
uchar *start= key;
for (keyseg=keyinfo->seg ; keyseg != end ; keyseg++)
diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h
index 0d9d7d43438..c986c483902 100644
--- a/myisam/myisamdef.h
+++ b/myisam/myisamdef.h
@@ -538,7 +538,7 @@ extern uchar *_mi_get_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page,
uchar *key, uchar *keypos, uint *return_key_length);
extern uint _mi_keylength(MI_KEYDEF *keyinfo,uchar *key);
extern uint _mi_keylength_part(MI_KEYDEF *keyinfo, register uchar *key,
- MI_KEYSEG *end);
+ HA_KEYSEG *end);
extern uchar *_mi_move_key(MI_KEYDEF *keyinfo,uchar *to,uchar *from);
extern int _mi_search_next(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key,
uint key_length,uint nextflag,my_off_t pos);
@@ -553,7 +553,7 @@ extern my_off_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo);
extern uint _mi_make_key(MI_INFO *info,uint keynr,uchar *key,
const byte *record,my_off_t filepos);
extern uint _mi_pack_key(MI_INFO *info,uint keynr,uchar *key,uchar *old,
- uint key_length, MI_KEYSEG **last_used_keyseg);
+ uint key_length, HA_KEYSEG **last_used_keyseg);
extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,byte *buf);
extern int _mi_read_cache(IO_CACHE *info,byte *buff,my_off_t pos,
uint length,int re_read_if_possibly);
diff --git a/mysql-test/include/not_embedded.inc b/mysql-test/include/not_embedded.inc
index 52ae026ece3..fcc1756caab 100644
--- a/mysql-test/include/not_embedded.inc
+++ b/mysql-test/include/not_embedded.inc
@@ -1,5 +1,5 @@
-- require r/not_embedded.require
disable_query_log;
-select version() like "%embedded%" as "have_embedded";
+select version() like N'%embedded%' as 'have_embedded';
enable_query_log;
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index 1fe874a211c..ec2f7220a3d 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -158,8 +158,8 @@ alter table t2 rename t1, add c char(10) comment "no comment";
show columns from t1;
Field Type Collation Null Key Default Extra
i int(10) unsigned binary PRI NULL auto_increment
-c char(10) latin1_swedish_ci YES NULL
-drop table t1;
+c char(10) latin1_swedish_ci YES NULL
+drop table t1;
create table t1 (a int, b int);
insert into t1 values(1,100), (2,100), (3, 100);
insert into t1 values(1,99), (2,99), (3, 99);
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index 520227c0fba..4e06c724142 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -183,18 +183,20 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0'
-) TYPE=HEAP
+) TYPE=HEAP CHARSET=latin1
drop table t1;
SET SESSION table_type="gemini";
SELECT @@table_type;
@@table_type
GEMINI
CREATE TABLE t1 (a int not null);
+Warnings:
+Warning 1259 Using storage engine MYISAM for table 't1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0'
-) TYPE=MyISAM
+) TYPE=MyISAM CHARSET=latin1
SET SESSION table_type=default;
drop table t1;
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result
index fb813e394f4..815445150cd 100644
--- a/mysql-test/r/ctype_recoding.result
+++ b/mysql-test/r/ctype_recoding.result
@@ -41,3 +41,4 @@ Field Type Collation Null Key Default Extra
поле char(32) character set koi8r koi8r_general_ci
SET CHARACTER SET koi8r;
DROP TABLE ÔÁÂÌÉÃÁ;
+SET CHARACTER SET default;
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index d87b00dd4d7..5b410396390 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -216,7 +216,6 @@ test.t1 repair status OK
select * from t1 where match (a) against ('aaaa');
a
drop table t1;
-drop table if exists t1;
create table t1 ( ref_mag text not null, fulltext (ref_mag));
insert into t1 values ('test');
select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index e9fb56a77d6..99d7bd2d087 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -42,22 +42,12 @@ insert into t1 values (null,null,'');
select count(distinct a),count(distinct grp) from t1;
count(distinct a) count(distinct grp)
6 3
-select sum(all a),count(all a),avg(all a),std(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
-sum(all a) count(all a) avg(all a) std(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c)
-21 6 3.5000 1.7078 7 0 1 6 E
-select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
-grp sum(a) count(a) avg(a) std(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c)
-NULL NULL 0 NULL NULL 0 0 NULL NULL
-1 1 1 1.0000 0.0000 1 1 1 1 a a
-2 5 2 2.5000 0.5000 3 2 2 3 b c
-3 15 3 5.0000 0.8165 7 4 4 6 C E
-select grp, sum(a)+count(a)+avg(a)+std(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
sum(all a) count(all a) avg(all a) std(all a) variance(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c)
21 6 3.5000 1.7078 2.9167 7 0 1 6 E
select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
grp sum(a) count(a) avg(a) std(a) variance(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c)
-NULL 0 0 NULL NULL NULL 0 0 NULL NULL
+NULL NULL 0 NULL NULL NULL 0 0 NULL NULL
1 1 1 1.0000 0.0000 0.0000 1 1 1 1 a a
2 5 2 2.5000 0.5000 0.2500 3 2 2 3 b c
3 15 3 5.0000 0.8165 0.6667 7 4 4 6 C E
@@ -231,47 +221,6 @@ select max(t1.a2),max(t2.a1) from t1 left outer join t2 on t1.a1=10;
max(t1.a2) max(t2.a1)
zzz BBB
drop table t1,t2;
-CREATE TABLE t1 (a int, b int);
-select count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1;
-count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-0 NULL NULL NULL NULL NULL -1 0
-select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
-a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-insert into t1 values (1,null);
-select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
-a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL -1 0
-insert into t1 values (1,null);
-insert into t1 values (2,null);
-select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
-a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL 0 0
-2 0 NULL NULL NULL NULL NULL 0 0
-select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
-a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL -1 0
-2 0 NULL NULL NULL NULL NULL -1 0
-insert into t1 values (2,1);
-select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
-a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL 0 0
-2 1 1 1.0000 0.0000 1 1 0 1
-select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
-a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL -1 0
-2 1 1 1.0000 0.0000 1 1 1 1
-insert into t1 values (3,1);
-select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
-a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL 0 0
-2 1 1 1.0000 0.0000 1 1 0 1
-3 1 1 1.0000 0.0000 1 1 1 1
-select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
-a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL -1 0
-2 1 1 1.0000 0.0000 1 1 1 1
-3 1 1 1.0000 0.0000 1 1 1 1
-drop table t1;
create table t1(
a1 char(3) primary key,
a2 smallint,
@@ -613,3 +562,44 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 3 NULL 14 Using index
1 SIMPLE t2 index NULL k2 4 NULL 6 Using where; Using index
drop table t1, t2;
+CREATE TABLE t1 (a int, b int);
+select count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1;
+count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
+0 NULL NULL NULL NULL NULL 18446744073709551615 0
+select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
+a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
+insert into t1 values (1,null);
+select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
+a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
+1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
+insert into t1 values (1,null);
+insert into t1 values (2,null);
+select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
+a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
+1 0 NULL NULL NULL NULL NULL 0 0
+2 0 NULL NULL NULL NULL NULL 0 0
+select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
+a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
+1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
+2 0 NULL NULL NULL NULL NULL 18446744073709551615 0
+insert into t1 values (2,1);
+select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
+a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
+1 0 NULL NULL NULL NULL NULL 0 0
+2 1 1 1.0000 0.0000 1 1 0 1
+select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
+a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
+1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
+2 1 1 1.0000 0.0000 1 1 1 1
+insert into t1 values (3,1);
+select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
+a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
+1 0 NULL NULL NULL NULL NULL 0 0
+2 1 1 1.0000 0.0000 1 1 0 1
+3 1 1 1.0000 0.0000 1 1 1 1
+select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
+a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
+1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
+2 1 1 1.0000 0.0000 1 1 1 1
+3 1 1 1.0000 0.0000 1 1 1 1
+drop table t1;
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 5a5689f0185..2f9a55e0c42 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -54,9 +54,9 @@ userid MIN(t1.score+0.0)
2 2.0
1 1.0
EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4 Using where; Using temporary
-t2 eq_ref PRIMARY PRIMARY 4 t1.userID 1 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using temporary
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 t1.userID 1 Using index
drop table t1,t2;
CREATE TABLE t1 (
PID int(10) unsigned NOT NULL auto_increment,
@@ -253,10 +253,10 @@ key (score)
INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3);
explain select userid,count(*) from t1 group by userid desc;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
explain select userid,count(*) from t1 group by userid desc order by null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary
select userid,count(*) from t1 group by userid desc;
userid count(*)
3 5
@@ -269,13 +269,13 @@ select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*));
userid count(*)
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index
+1 SIMPLE t1 range spID spID 5 NULL 3 Using where; Using index
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index
+1 SIMPLE t1 range spID spID 5 NULL 3 Using where; Using index
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index
+1 SIMPLE t1 range spID spID 5 NULL 3 Using where; Using index
select spid,count(*) from t1 where spid between 1 and 2 group by spid;
spid count(*)
1 1
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index 922f4816e90..98613dad628 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -1209,7 +1209,8 @@ SET AUTOCOMMIT=0;
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
ROLLBACK;
-Warning: Some non-transactional changed tables couldn't be rolled back
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
SELECT * FROM t1;
B_ID
drop table t1,t2;
@@ -1247,12 +1248,12 @@ select count(*) from t1;
count(*)
29267
explain select * from t1 where c between 1 and 10000;
-table type possible_keys key key_len ref rows Extra
-t1 range c c 5 NULL 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 5 NULL 1 Using where
update t1 set c=a;
explain select * from t1 where c between 1 and 10000;
-table type possible_keys key key_len ref rows Extra
-t1 ALL c NULL NULL NULL 29537 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL c NULL NULL NULL 29537 Using where
drop table t1,t2;
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) type=innodb;
insert into t1 (id) values (null),(null),(null),(null),(null);
@@ -1286,6 +1287,7 @@ a b
13 2
111 100
111 100
+drop table t1;
CREATE TABLE t1 (col1 int(1))TYPE=InnoDB;
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP(+0),INDEX stamp_idx
(stamp))TYPE=InnoDB;
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index 1412c5e7d10..123de82fe09 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -646,7 +646,6 @@ fooID barID fooID
20 2 NULL
30 3 30
drop table t1,t2;
-drop table if exists t3;
create table t1 (i int);
create table t2 (i int);
create table t3 (i int);
diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result
index 3248d359546..c55f29a4e78 100644
--- a/mysql-test/r/null_key.result
+++ b/mysql-test/r/null_key.result
@@ -84,7 +84,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a,b a 5 NULL 5 Using where
explain select * from t1 where (a is null or a = 7) and b=7 and c=0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a,b a 5 NULL 12 Using where
+1 SIMPLE t1 ALL a,b NULL NULL NULL 12 Using where
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a,b a 5 const 3 Using where
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index a8a6dd6312d..0cfe1534252 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -549,10 +549,10 @@ KEY FieldKey (FieldKey),
KEY LongField (FieldKey,LongVal),
KEY StringField (FieldKey,StringVal(32))
);
-INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
+INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref FieldKey,LongField,StringField LongField 36 const 2 Using where
+1 SIMPLE t1 ref FieldKey,LongField,StringField StringField 36 const 3 Using where; Using filesort
SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
FieldKey LongVal StringVal
1 0 2
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 48a2a8a5a21..1d46d1dcf25 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -382,14 +382,14 @@ a
set CHARACTER SET cp1251_koi8;
select * from t1;
a
-?
set CHARACTER SET DEFAULT;
show status like "Qcache_queries_in_cache";
Variable_name Value
-Qcache_queries_in_cache 2
+Qcache_queries_in_cache 1
show status like "Qcache_hits";
Variable_name Value
-Qcache_hits 4
+Qcache_hits 5
drop table t1;
create database if not exists mysqltest;
create table mysqltest.t1 (i int not null);
@@ -415,7 +415,7 @@ Variable_name Value
Qcache_queries_in_cache 2
show status like "Qcache_hits";
Variable_name Value
-Qcache_hits 6
+Qcache_hits 7
drop database mysqltest;
drop table t1;
create table t1 (i int not null);
@@ -429,7 +429,7 @@ FOUND_ROWS()
4
show status like "Qcache_hits";
Variable_name Value
-Qcache_hits 6
+Qcache_hits 7
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
@@ -441,7 +441,7 @@ FOUND_ROWS()
1
show status like "Qcache_hits";
Variable_name Value
-Qcache_hits 6
+Qcache_hits 7
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
@@ -454,7 +454,7 @@ FOUND_ROWS()
4
show status like "Qcache_hits";
Variable_name Value
-Qcache_hits 7
+Qcache_hits 8
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
@@ -466,7 +466,7 @@ FOUND_ROWS()
1
show status like "Qcache_hits";
Variable_name Value
-Qcache_hits 8
+Qcache_hits 9
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
@@ -535,7 +535,7 @@ a
3
show status like "Qcache_hits";
Variable_name Value
-Qcache_hits 11
+Qcache_hits 12
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
@@ -552,7 +552,7 @@ a
3
show status like "Qcache_hits";
Variable_name Value
-Qcache_hits 12
+Qcache_hits 13
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result
index 6c2107b2cf3..eb46622dcc1 100644
--- a/mysql-test/r/repair.result
+++ b/mysql-test/r/repair.result
@@ -7,7 +7,7 @@ test.t1 repair status OK
alter table t1 TYPE=HEAP;
repair table t1 use_frm;
Table Op Msg_type Msg_text
-test.t1 repair error The handler for the table doesn't support repair
+test.t1 repair error The storage enginge for the table doesn't support repair
drop table t1;
repair table t1 use_frm;
Table Op Msg_type Msg_text
diff --git a/mysql-test/r/rpl_flush_tables.result b/mysql-test/r/rpl_flush_tables.result
index 7eb3b77758e..6353a6101d6 100644
--- a/mysql-test/r/rpl_flush_tables.result
+++ b/mysql-test/r/rpl_flush_tables.result
@@ -14,7 +14,7 @@ rename table t1 to t5, t2 to t1;
flush no_write_to_binlog tables;
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.000001 4 Start 1 4 Server ver: 4.1.1-alpha-debug-log, Binlog ver: 3
+master-bin.000001 4 Start 1 4 Server ver: SERVER_VERSION, Binlog ver: 3
master-bin.000001 79 Query 1 79 use `test`; create table t1 (a int)
master-bin.000001 137 Query 1 137 use `test`; insert into t1 values (10)
master-bin.000001 198 Query 1 198 use `test`; create table t2 (a int)
@@ -27,7 +27,7 @@ a
flush tables;
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.000001 4 Start 1 4 Server ver: 4.1.1-alpha-debug-log, Binlog ver: 3
+master-bin.000001 4 Start 1 4 Server ver: SERVER_VERSION, Binlog ver: 3
master-bin.000001 79 Query 1 79 use `test`; create table t1 (a int)
master-bin.000001 137 Query 1 137 use `test`; insert into t1 values (10)
master-bin.000001 198 Query 1 198 use `test`; create table t2 (a int)
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index d506891b0fb..272ffdd330e 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -90,9 +90,6 @@ explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a l
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 UNION t2 ALL NULL NULL NULL NULL 4 Using filesort
-select found_rows();
-found_rows()
-0
explain select a,b from t1 union all select a,b from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
@@ -132,6 +129,23 @@ create table t3 select a,b from t1 union all select a,b from t2;
insert into t3 select a,b from t1 union all select a,b from t2;
replace into t3 select a,b as c from t1 union all select a,b from t2;
drop table t1,t2,t3;
+select * union select 1;
+No tables used
+select 1 as a,(select a union select a);
+a (select a union select a)
+1 1
+(select 1) union (select 2) order by 0;
+Unknown column '0' in 'order clause'
+SELECT @a:=1 UNION SELECT @a:=@a+1;
+@a:=1
+1
+2
+(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
+Unknown column 'a' in 'field list'
+(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
+1 3
+1 3
+2 1
CREATE TABLE t1 (
`pseudo` char(35) NOT NULL default '',
`pseudo1` char(35) NOT NULL default '',
@@ -255,11 +269,6 @@ uid rl g1 cid gg
uid rl g1 cid gg
1 NULL V1 NULL 1
drop table t1,t2,t3,t4,t5,t6;
-select * union select 1;
-No tables used
-select 1 as a,(select a union select a);
-a (select a union select a)
-1 1
CREATE TABLE t1 ( id int(3) unsigned default '0') TYPE=MyISAM;
INSERT INTO t1 (id) VALUES("1");
CREATE TABLE t2 ( id int(3) unsigned default '0', id_master int(5) default '0', text1 varchar(5) default NULL, text2 varchar(5) default NULL) TYPE=MyISAM;
@@ -286,10 +295,6 @@ id_master id text1 text2
1 3 NULL bar3
1 4 foo4 bar4
drop table if exists t1,t2;
-(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
-1 3
-1 3
-2 1
create table t1 (a int not null primary key auto_increment, b int, key(b));
create table t2 (a int not null primary key auto_increment, b int);
insert into t1 (b) values (1),(2),(2),(3);
@@ -323,11 +328,3 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
2 UNION t1 ref b b 5 const 1 Using where
drop table t1,t2;
-(select 1) union (select 2) order by 0;
-Unknown column '0' in 'order clause'
-SELECT @a:=1 UNION SELECT @a:=@a+1;
-@a:=1
-1
-2
-(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
-Unknown column 'a' in 'field list'
diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result
index c308b8fcbcd..1d483da2c77 100644
--- a/mysql-test/r/update.result
+++ b/mysql-test/r/update.result
@@ -137,7 +137,10 @@ a b
13 2
111 100
111 100
-drop table t1;
+create table t2 (a int not null, b int not null);
+insert into t2 values (1,1),(1,2),(1,3);
+update t1 set b=(select distinct 1 from (select * from t2) a);
+drop table t1,t2;
CREATE TABLE t1 (
`id_param` smallint(3) unsigned NOT NULL default '0',
`nom_option` char(40) NOT NULL default '',
diff --git a/mysql-test/t/ansi.test b/mysql-test/t/ansi.test
index e1ac8ffd4f9..da82b7a9e31 100644
--- a/mysql-test/t/ansi.test
+++ b/mysql-test/t/ansi.test
@@ -2,7 +2,9 @@
# Test of ansi mode
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
# Test some functions that works different in ansi mode
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 3a02e5d67e8..9bc37a0864d 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -145,9 +145,13 @@ drop table t1;
#
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
insert into t1 values ("a", 1), ("b", 2);
-!$1048 insert into t1 values ("c", NULL);
-!$1048 insert into t1 values (NULL, 3);
-!$1048 insert into t1 values (NULL, NULL);
+--error 1048
+insert into t1 values ("c", NULL);
+--error 1048
+insert into t1 values (NULL, 3);
+--error 1048
+insert into t1 values (NULL, NULL);
+drop table t1;
#
# Test create with foreign keys
diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test
index 0330bbd23b4..68526806166 100644
--- a/mysql-test/t/ctype_recoding.test
+++ b/mysql-test/t/ctype_recoding.test
@@ -26,3 +26,4 @@ SHOW FIELDS FROM таблица;
SET CHARACTER SET koi8r;
DROP TABLE ÔÁÂÌÉÃÁ;
+SET CHARACTER SET default;
diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test
index cd1dc965000..7308f26a8cf 100644
--- a/mysql-test/t/ctype_ujis.test
+++ b/mysql-test/t/ctype_ujis.test
@@ -1,7 +1,9 @@
#
# Tests with the ujis character set
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
#
# Test problem with LEFT()
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 1c579ddcc62..40ac7f905c7 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -180,11 +180,9 @@ drop table t1;
# FULLTEXT index on a TEXT filed converted to a CHAR field doesn't work anymore
#
-drop table if exists t1;
create table t1 ( ref_mag text not null, fulltext (ref_mag));
insert into t1 values ('test');
select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
alter table t1 change ref_mag ref_mag char (255) not null;
select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
drop table t1;
-
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index a0cb104df48..3736f4a2ddc 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -807,7 +807,6 @@ CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) TYPE=InnoDB;
SET AUTOCOMMIT=0;
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
--- error 1196
ROLLBACK;
SELECT * FROM t1;
drop table t1,t2;
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index 49f13abe7c2..df7e5b1524d 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -417,7 +417,7 @@ explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30;
drop table t1,t2;
-drop table if exists t3;
+
create table t1 (i int);
create table t2 (i int);
create table t3 (i int);
diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test
index ceb5c47af11..d7e84590dc0 100644
--- a/mysql-test/t/loaddata.test
+++ b/mysql-test/t/loaddata.test
@@ -2,7 +2,9 @@
# Some simple test of load data
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (a date, b date, c date not null, d date);
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',';
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index 5235eddd671..702feedc3ce 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -357,7 +357,7 @@ CREATE TABLE t1 (
KEY LongField (FieldKey,LongVal),
KEY StringField (FieldKey,StringVal(32))
);
-INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
+INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
diff --git a/mysql-test/t/rpl_flush_tables.test b/mysql-test/t/rpl_flush_tables.test
index e62ba2e94c7..67720343e83 100644
--- a/mysql-test/t/rpl_flush_tables.test
+++ b/mysql-test/t/rpl_flush_tables.test
@@ -17,12 +17,14 @@ rename table t1 to t5, t2 to t1;
# first don't write it to the binlog, to test the NO_WRITE_TO_BINLOG keyword.
flush no_write_to_binlog tables;
# Check that it's not in the binlog.
+--replace_result $SERVER_VERSION SERVER_VERSION
show binlog events;
# Check that the master is not confused.
select * from t3;
# This FLUSH should go into the binlog to not confuse the slave.
flush tables;
# Check that it's in the binlog.
+--replace_result $SERVER_VERSION SERVER_VERSION
show binlog events;
save_master_pos;
connection slave;
diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test
index 90d7f814359..30edcc79d9e 100644
--- a/mysql-test/t/status.test
+++ b/mysql-test/t/status.test
@@ -4,7 +4,7 @@
# This would work if mysqltest run would be threaded and handle each
# connection in a separate thread.
#
--- source include/not_embedded.inc
+--source include/not_embedded.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 8e8a3dfe1d4..4a171c36293 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -396,6 +396,8 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3);
SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
-- error 1093
INSERT INTO t2 VALUES ((SELECT * FROM t2));
+-- error 1093
+INSERT INTO t2 VALUES ((SELECT id FROM t2));
SELECT * FROM t2;
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1);
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 */
diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c
index 92214868018..8a9863f7940 100644
--- a/strings/ctype-ujis.c
+++ b/strings/ctype-ujis.c
@@ -8257,7 +8257,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
{
int c1,c2,c3;
- if (s>e)
+ if (s >= e)
return MY_CS_TOOFEW(0);
c1=s[0];