summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--client/mysqldump.c37
-rw-r--r--client/mysqltest.c35
-rw-r--r--myisam/mi_create.c3
-rw-r--r--myisam/mi_open.c2
-rw-r--r--mysql-test/r/ctype_ucs.result11
-rw-r--r--mysql-test/r/ctype_utf8.result11
-rw-r--r--mysql-test/r/func_encrypt.result12
-rw-r--r--mysql-test/r/func_encrypt_nossl.result5
-rw-r--r--mysql-test/r/func_str.result50
-rw-r--r--mysql-test/r/group_by.result6
-rw-r--r--mysql-test/r/insert_select.result27
-rw-r--r--mysql-test/r/insert_update.result10
-rw-r--r--mysql-test/r/lowercase_table2.result3
-rw-r--r--mysql-test/r/select.result9
-rw-r--r--mysql-test/r/variables.result4
-rw-r--r--mysql-test/t/ctype_ucs.test12
-rw-r--r--mysql-test/t/ctype_utf8.test12
-rw-r--r--mysql-test/t/func_encrypt_nossl.test1
-rw-r--r--mysql-test/t/func_str.test56
-rw-r--r--mysql-test/t/group_by.test12
-rw-r--r--mysql-test/t/insert_select.test22
-rw-r--r--mysql-test/t/insert_update.test10
-rw-r--r--mysql-test/t/lowercase_table2.test3
-rw-r--r--mysql-test/t/ndb_alter_table.test11
-rw-r--r--mysql-test/t/select.test15
-rw-r--r--mysql-test/t/variables.test6
-rw-r--r--mysys/my_access.c9
-rw-r--r--mysys/my_fopen.c84
-rw-r--r--scripts/make_win_src_distribution.sh3
-rw-r--r--sql/field.cc9
-rw-r--r--sql/ha_ndbcluster.cc4
-rw-r--r--sql/handler.cc16
-rw-r--r--sql/item.cc4
-rw-r--r--sql/item.h11
-rw-r--r--sql/item_cmpfunc.h6
-rw-r--r--sql/item_strfunc.cc6
-rw-r--r--sql/item_strfunc.h1
-rw-r--r--sql/mysql_priv.h3
-rw-r--r--sql/mysqld.cc5
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/sql_base.cc42
-rw-r--r--sql/sql_insert.cc85
-rw-r--r--sql/sql_parse.cc10
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sql_select.cc43
-rw-r--r--sql/sql_table.cc1
-rw-r--r--sql/sql_yacc.yy15
-rw-r--r--strings/ctype-ucs2.c6
-rw-r--r--strings/ctype-utf8.c4
50 files changed, 520 insertions, 238 deletions
diff --git a/Makefile.am b/Makefile.am
index d7059c6adaf..6eb7421880e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,7 @@ EXTRA_DIST = INSTALL-SOURCE README COPYING EXCEPTIONS-CLIENT
SUBDIRS = . include @docs_dirs@ @zlib_dir@ @yassl_dir@ \
@readline_topdir@ sql-common \
@thread_dirs@ pstack \
- @sql_union_dirs@ scripts man tests \
+ @sql_union_dirs@ scripts @man_dirs@ tests \
netware @libmysqld_dirs@ \
@bench_dirs@ support-files @tools_dirs@
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 1f520243c7c..b2bf23c3e3a 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -539,6 +539,12 @@ static void write_footer(FILE *sql_file)
}
} /* write_footer */
+static void free_table_ent(char *key)
+
+{
+ my_free((gptr) key, MYF(0));
+}
+
byte* get_table_key(const char *entry, uint *length,
my_bool not_used __attribute__((unused)))
@@ -550,8 +556,9 @@ byte* get_table_key(const char *entry, uint *length,
void init_table_rule_hash(HASH* h)
{
- if(hash_init(h, charset_info, 16, 0, 0,
- (hash_get_key) get_table_key, 0, 0))
+ if (hash_init(h, charset_info, 16, 0, 0,
+ (hash_get_key) get_table_key,
+ (hash_free_key) free_table_ent, 0))
exit(EX_EOM);
}
@@ -806,7 +813,8 @@ static void DB_error(MYSQL *mysql, const char *when)
SYNOPSIS
mysql_query_with_error_report()
mysql_con connection to use
- res if non zero, result will be put there with mysql_store_result
+ res if non zero, result will be put there with
+ mysql_store_result()
query query to send to server
RETURN VALUES
@@ -958,13 +966,14 @@ static char *quote_name(const char *name, char *buff, my_bool force)
return buff;
} /* quote_name */
+
/*
Quote a table name so it can be used in "SHOW TABLES LIKE <tabname>"
SYNOPSIS
- quote_for_like
- name - name of the table
- buff - quoted name of the table
+ quote_for_like()
+ name name of the table
+ buff quoted name of the table
DESCRIPTION
Quote \, _, ' and % characters
@@ -980,7 +989,6 @@ static char *quote_name(const char *name, char *buff, my_bool force)
Example: "t\1" => "t\\\\1"
*/
-
static char *quote_for_like(const char *name, char *buff)
{
char *to= buff;
@@ -1690,7 +1698,7 @@ static void dump_table(uint numFields, char *table)
}
/* Check that there are any fields in the table */
- if(numFields == 0)
+ if (numFields == 0)
{
if (verbose)
fprintf(stderr,
@@ -2446,7 +2454,6 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
DYNAMIC_STRING lock_tables_query;
HASH dump_tables;
char *table_name;
-
DBUG_ENTER("dump_selected_tables");
if (init_dumping(db))
@@ -2454,15 +2461,16 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
/* Init hash table for storing the actual name of tables to dump */
if (hash_init(&dump_tables, charset_info, 16, 0, 0,
- (hash_get_key) get_table_key, 0, 0))
+ (hash_get_key) get_table_key, (hash_free_key) free_table_ent,
+ 0))
exit(EX_EOM);
init_dynamic_string(&lock_tables_query, "LOCK TABLES ", 256, 1024);
for (; tables > 0 ; tables-- , table_names++)
{
/* the table name passed on commandline may be wrong case */
- if (!get_actual_table_name( *table_names,
- new_table_name, sizeof(new_table_name) ))
+ if (!get_actual_table_name(*table_names,
+ new_table_name, sizeof(new_table_name)))
{
/* Add found table name to lock_tables_query */
if (lock_tables)
@@ -2509,7 +2517,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
{
table_name= hash_element(&dump_tables, i);
DBUG_PRINT("info",("Dumping table %s", table_name));
- numrows = get_table_structure(table_name, db);
+ numrows= get_table_structure(table_name, db);
dump_table(numrows, table_name);
}
@@ -2926,6 +2934,7 @@ int main(int argc, char **argv)
{
compatible_mode_normal_str[0]= 0;
default_charset= (char *)mysql_universal_client_charset;
+ bzero((char*) &ignore_table, sizeof(ignore_table));
MY_INIT("mysqldump");
if (get_options(&argc, &argv))
@@ -2984,6 +2993,8 @@ err:
if (md_result_file != stdout)
my_fclose(md_result_file, MYF(0));
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
+ if (hash_inited(&ignore_table))
+ hash_free(&ignore_table);
if (extended_insert)
dynstr_free(&extended_row);
if (insert_pat_inited)
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 65f8c9358c2..67fa931a3f3 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -994,28 +994,29 @@ static void do_exec(struct st_query* q)
error= pclose(res_file);
if (error != 0)
{
- uint status= WEXITSTATUS(error);
- if(q->abort_on_error)
+ uint status= WEXITSTATUS(error), i;
+ my_bool ok= 0;
+
+ if (q->abort_on_error)
die("At line %u: command \"%s\" failed", start_lineno, cmd);
- else
+
+ DBUG_PRINT("info",
+ ("error: %d, status: %d", error, status));
+ for (i=0 ; (uint) i < q->expected_errors ; i++)
{
- bool ok= 0;
- uint i;
DBUG_PRINT("info",
("error: %d, status: %d", error, status));
- for (i=0 ; (uint) i < q->expected_errors ; i++)
- {
- DBUG_PRINT("info", ("expected error: %d", q->expected_errno[i].code.errnum));
- if ((q->expected_errno[i].type == ERR_ERRNO) &&
- (q->expected_errno[i].code.errnum == status))
- ok= 1;
- verbose_msg("At line %u: command \"%s\" failed with expected error: %d",
- start_lineno, cmd, status);
- }
- if (!ok)
- die("At line: %u: command \"%s\" failed with wrong error: %d",
- start_lineno, cmd, status);
+ DBUG_PRINT("info", ("expected error: %d",
+ q->expected_errno[i].code.errnum));
+ if ((q->expected_errno[i].type == ERR_ERRNO) &&
+ (q->expected_errno[i].code.errnum == status))
+ ok= 1;
+ verbose_msg("At line %u: command \"%s\" failed with expected error: %d",
+ start_lineno, cmd, status);
}
+ if (!ok)
+ die("At line: %u: command \"%s\" failed with wrong error: %d",
+ start_lineno, cmd, status);
}
else if (q->expected_errno[0].type == ERR_ERRNO &&
q->expected_errno[0].code.errnum != 0)
diff --git a/myisam/mi_create.c b/myisam/mi_create.c
index 47332b02a72..33b344405ec 100644
--- a/myisam/mi_create.c
+++ b/myisam/mi_create.c
@@ -770,10 +770,13 @@ err:
uint mi_get_pointer_length(ulonglong file_length, uint def)
{
+ DBUG_ASSERT(def >= 2 && def <= 7);
if (file_length) /* If not default */
{
+#ifdef NOT_YET_READY_FOR_8_BYTE_POINTERS
if (file_length >= (longlong) 1 << 56)
def=8;
+#endif
if (file_length >= (longlong) 1 << 48)
def=7;
if (file_length >= (longlong) 1 << 40)
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index 456b87b7799..74b97a65609 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -78,7 +78,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
int lock_error,kfile,open_mode,save_errno,have_rtree=0;
uint i,j,len,errpos,head_length,base_pos,offset,info_length,keys,
key_parts,unique_key_parts,fulltext_keys,uniques;
- char name_buff[FN_REFLEN], org_name [FN_REFLEN], index_name[FN_REFLEN],
+ char name_buff[FN_REFLEN], org_name[FN_REFLEN], index_name[FN_REFLEN],
data_name[FN_REFLEN];
char *disk_cache, *disk_pos, *end_pos;
MI_INFO info,*m_info,*old_info;
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index 338fc429090..dd1fb491064 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -638,6 +638,17 @@ Warnings:
Warning 1264 Out of range value adjusted for column 'Field1' at row 1
DROP TABLE t1;
SET NAMES latin1;
+CREATE TABLE t1 (
+a varchar(255) NOT NULL default '',
+KEY a (a)
+) ENGINE=MyISAM DEFAULT CHARSET=ucs2 COLLATE ucs2_general_ci;
+insert into t1 values (0x803d);
+insert into t1 values (0x005b);
+select hex(a) from t1;
+hex(a)
+005B
+803D
+drop table t1;
CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
update t1 set b=a;
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index 0407a7f388c..b8ff3c70aa1 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -939,3 +939,14 @@ content msisdn
ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримримримр м.Дадимфшьмримд им.Адимимрн имадми 1234567890
11 g 1234567890
DROP TABLE t1,t2;
+CREATE TABLE t1 (
+a varchar(255) NOT NULL default '',
+KEY a (a)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;
+insert into t1 values (_utf8 0xe880bd);
+insert into t1 values (_utf8 0x5b);
+select hex(a) from t1;
+hex(a)
+5B
+E880BD
+drop table t1;
diff --git a/mysql-test/r/func_encrypt.result b/mysql-test/r/func_encrypt.result
index 992d01c66cd..3eb8ec4354c 100644
--- a/mysql-test/r/func_encrypt.result
+++ b/mysql-test/r/func_encrypt.result
@@ -128,18 +128,12 @@ Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(NULL);
des_encrypt(NULL)
NULL
-Warnings:
-Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(NULL, 10);
des_encrypt(NULL, 10)
NULL
-Warnings:
-Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(NULL, NULL);
des_encrypt(NULL, NULL)
NULL
-Warnings:
-Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(10, NULL);
des_encrypt(10, NULL)
NULL
@@ -156,18 +150,12 @@ hello
select des_decrypt(NULL);
des_decrypt(NULL)
NULL
-Warnings:
-Error 1108 Incorrect parameters to procedure 'des_decrypt'
select des_decrypt(NULL, 10);
des_decrypt(NULL, 10)
NULL
-Warnings:
-Error 1108 Incorrect parameters to procedure 'des_decrypt'
select des_decrypt(NULL, NULL);
des_decrypt(NULL, NULL)
NULL
-Warnings:
-Error 1108 Incorrect parameters to procedure 'des_decrypt'
select des_decrypt(10, NULL);
des_decrypt(10, NULL)
10
diff --git a/mysql-test/r/func_encrypt_nossl.result b/mysql-test/r/func_encrypt_nossl.result
index fea752f4a4a..d0df2335afa 100644
--- a/mysql-test/r/func_encrypt_nossl.result
+++ b/mysql-test/r/func_encrypt_nossl.result
@@ -23,6 +23,11 @@ des_encrypt("test", NULL)
NULL
Warnings:
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
+select des_encrypt(NULL, NULL);
+des_encrypt(NULL, NULL)
+NULL
+Warnings:
+Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_decrypt("test", 'anotherkeystr');
des_decrypt("test", 'anotherkeystr')
NULL
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index 3ae2adaf5e7..a725f1fe7ab 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -811,3 +811,53 @@ SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
str num
notnumber 0
DROP TABLE t1,t2;
+CREATE TABLE t1(
+id int(11) NOT NULL auto_increment,
+pc int(11) NOT NULL default '0',
+title varchar(20) default NULL,
+PRIMARY KEY (id)
+);
+INSERT INTO t1 VALUES
+(1, 0, 'Main'),
+(2, 1, 'Toys'),
+(3, 1, 'Games');
+SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
+FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
+LEFT JOIN t1 AS t3 ON t2.pc=t3.id;
+id col1
+1 Main
+2 Main->Toys
+3 Main->Games
+SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
+FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
+LEFT JOIN t1 AS t3 ON t2.pc=t3.id
+WHERE CONCAT_WS('->', t3.title, t2.title, t1.title) LIKE '%Toys%';
+id col1
+2 Main->Toys
+DROP TABLE t1;
+CREATE TABLE t1(
+trackid int(10) unsigned NOT NULL auto_increment,
+trackname varchar(100) NOT NULL default '',
+PRIMARY KEY (trackid)
+);
+CREATE TABLE t2(
+artistid int(10) unsigned NOT NULL auto_increment,
+artistname varchar(100) NOT NULL default '',
+PRIMARY KEY (artistid)
+);
+CREATE TABLE t3(
+trackid int(10) unsigned NOT NULL,
+artistid int(10) unsigned NOT NULL,
+PRIMARY KEY (trackid,artistid)
+);
+INSERT INTO t1 VALUES (1, 'April In Paris'), (2, 'Autumn In New York');
+INSERT INTO t2 VALUES (1, 'Vernon Duke');
+INSERT INTO t3 VALUES (1,1);
+SELECT CONCAT_WS(' ', trackname, artistname) trackname, artistname
+FROM t1 LEFT JOIN t3 ON t1.trackid=t3.trackid
+LEFT JOIN t2 ON t2.artistid=t3.artistid
+WHERE CONCAT_WS(' ', trackname, artistname) LIKE '%In%';
+trackname artistname
+April In Paris Vernon Duke Vernon Duke
+Autumn In New York NULL
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index a56cfd4492a..85b923bf15a 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -721,6 +721,12 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
WHERE hostname LIKE '%aol%'
GROUP BY hostname;
hostname no
+CREATE TABLE t1 (n int);
+INSERT INTO t1 VALUES (1);
+SELECT n+1 AS n FROM t1 GROUP BY n;
+n
+2
+DROP TABLE t1;
cache-dtc-af05.proxy.aol.com 1
DROP TABLE t1;
CREATE TABLE t1 (a int, b int);
diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result
index 026dae8381a..f745af182eb 100644
--- a/mysql-test/r/insert_select.result
+++ b/mysql-test/r/insert_select.result
@@ -1,4 +1,4 @@
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
@@ -636,16 +636,35 @@ ff1 ff2
drop table t1, t2;
create table t1 (a int unique);
create table t2 (a int, b int);
+create table t3 (c int, d int);
insert into t1 values (1),(2);
insert into t2 values (1,2);
+insert into t3 values (1,6),(3,7);
select * from t1;
a
1
2
-insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
+insert into t1 select a from t2 on duplicate key update a= t1.a + t2.b;
select * from t1;
a
2
3
-drop table t1;
-drop table t2;
+insert into t1 select a+1 from t2 on duplicate key update t1.a= t1.a + t2.b+1;
+select * from t1;
+a
+3
+5
+insert into t1 select t3.c from t3 on duplicate key update a= a + t3.d;
+select * from t1;
+a
+1
+5
+10
+insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= a + 10;
+insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
+ERROR 23000: Column 'a' in field list is ambiguous
+insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b;
+ERROR 42S02: Unknown table 't2' in field list
+insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b;
+ERROR 42S02: Unknown table 't2' in field list
+drop table t1,t2,t3;
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result
index 739beea6286..fc157093a7f 100644
--- a/mysql-test/r/insert_update.result
+++ b/mysql-test/r/insert_update.result
@@ -143,7 +143,7 @@ INSERT t1 VALUES (1,2,10), (3,4,20);
CREATE TABLE t2 (a INT, b INT, c INT, d INT);
INSERT t2 VALUES (5,6,30,1), (7,4,40,1), (8,9,60,1);
INSERT t2 VALUES (2,1,11,2), (7,4,40,2);
-INSERT t1 SELECT a,b,c FROM t2 WHERE d=1 ON DUPLICATE KEY UPDATE c=c+100;
+INSERT t1 SELECT a,b,c FROM t2 WHERE d=1 ON DUPLICATE KEY UPDATE c=t1.c+100;
SELECT * FROM t1;
a b c
1 2 10
@@ -158,6 +158,8 @@ a b c
5 0 30
8 9 60
INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a);
+ERROR 23000: Column 'c' in field list is ambiguous
+INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=t1.c+VALUES(t1.a);
SELECT *, VALUES(a) FROM t1;
a b c VALUES(a)
1 2 10 NULL
@@ -174,7 +176,7 @@ select * from t1;
a
1
2
-insert ignore into t1 select a from t1 on duplicate key update a=a+1 ;
+insert ignore into t1 select a from t1 as t2 on duplicate key update a=t1.a+1 ;
select * from t1;
a
1
@@ -185,5 +187,7 @@ a
2
3
insert into t1 select a from t1 on duplicate key update a=a+1 ;
-ERROR 23000: Duplicate entry '3' for key 1
+ERROR 23000: Column 'a' in field list is ambiguous
+insert ignore into t1 select a from t1 on duplicate key update a=t1.a+1 ;
+ERROR 23000: Column 't1.a' in field list is ambiguous
drop table t1;
diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result
index db833bcd970..f93a10dfbad 100644
--- a/mysql-test/r/lowercase_table2.result
+++ b/mysql-test/r/lowercase_table2.result
@@ -1,6 +1,7 @@
-DROP TABLE IF EXISTS t1,t2,t3;
+DROP TABLE IF EXISTS t1,t2,t3,t2aA,t1Aa;
DROP DATABASE IF EXISTS `TEST_$1`;
DROP DATABASE IF EXISTS `test_$1`;
+DROP DATABASE mysqltest_LC2;
CREATE TABLE T1 (a int);
INSERT INTO T1 VALUES (1);
SHOW TABLES LIKE "T1";
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 9f1ff2cd835..4381220eacc 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2681,6 +2681,15 @@ SELECT COUNT(*) FROM t1 WHERE
AND FK_firma_id = 2;
COUNT(*)
0
+CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);
+CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);
+INSERT INTO `t2` VALUES (0,'READ');
+CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);
+INSERT INTO `t3` VALUES (1,'fs');
+select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
+id name gid uid ident level
+1 fs NULL NULL 0 READ
+drop table t1,t2,t3;
drop table t1;
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 99b4f0529e6..5468508165c 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -504,10 +504,10 @@ t1 CREATE TABLE `t1` (
`c4` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
-SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8;
+SET GLOBAL MYISAM_DATA_POINTER_SIZE= 7;
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
Variable_name Value
-myisam_data_pointer_size 8
+myisam_data_pointer_size 7
SET GLOBAL table_cache=-1;
SHOW VARIABLES LIKE 'table_cache';
Variable_name Value
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index 2722e8572b0..f4327536795 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -408,6 +408,18 @@ DROP TABLE t1;
SET NAMES latin1;
#
+# Bug#9557 MyISAM utf8 table crash
+#
+CREATE TABLE t1 (
+ a varchar(255) NOT NULL default '',
+ KEY a (a)
+) ENGINE=MyISAM DEFAULT CHARSET=ucs2 COLLATE ucs2_general_ci;
+insert into t1 values (0x803d);
+insert into t1 values (0x005b);
+select hex(a) from t1;
+drop table t1;
+
+#
# Conversion from an UCS2 string to a decimal column
#
CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index 343b7c867e7..0a847057258 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -788,3 +788,15 @@ INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890';
DROP TABLE t1,t2;
+
+#
+# Bug#9557 MyISAM utf8 table crash
+#
+CREATE TABLE t1 (
+ a varchar(255) NOT NULL default '',
+ KEY a (a)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;
+insert into t1 values (_utf8 0xe880bd);
+insert into t1 values (_utf8 0x5b);
+select hex(a) from t1;
+drop table t1;
diff --git a/mysql-test/t/func_encrypt_nossl.test b/mysql-test/t/func_encrypt_nossl.test
index 0e9d93f5968..95c104ce046 100644
--- a/mysql-test/t/func_encrypt_nossl.test
+++ b/mysql-test/t/func_encrypt_nossl.test
@@ -9,6 +9,7 @@ select des_encrypt("test", 1);
select des_encrypt("test", 9);
select des_encrypt("test", 100);
select des_encrypt("test", NULL);
+select des_encrypt(NULL, NULL);
select des_decrypt("test", 'anotherkeystr');
select des_decrypt(1, 1);
select des_decrypt(des_encrypt("test", 'thekey'));
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 617de1b3cc5..2cb7dfe4824 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -543,3 +543,59 @@ SELECT * FROM t1, t2 WHERE num=str;
SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
DROP TABLE t1,t2;
+
+#
+# Bug #11469: NOT NULL optimization wrongly used for arguments of CONCAT_WS
+#
+
+CREATE TABLE t1(
+ id int(11) NOT NULL auto_increment,
+ pc int(11) NOT NULL default '0',
+ title varchar(20) default NULL,
+ PRIMARY KEY (id)
+);
+
+INSERT INTO t1 VALUES
+ (1, 0, 'Main'),
+ (2, 1, 'Toys'),
+ (3, 1, 'Games');
+
+SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
+ FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
+ LEFT JOIN t1 AS t3 ON t2.pc=t3.id;
+SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
+ FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
+ LEFT JOIN t1 AS t3 ON t2.pc=t3.id
+ WHERE CONCAT_WS('->', t3.title, t2.title, t1.title) LIKE '%Toys%';
+
+DROP TABLE t1;
+
+
+CREATE TABLE t1(
+ trackid int(10) unsigned NOT NULL auto_increment,
+ trackname varchar(100) NOT NULL default '',
+ PRIMARY KEY (trackid)
+);
+
+CREATE TABLE t2(
+ artistid int(10) unsigned NOT NULL auto_increment,
+ artistname varchar(100) NOT NULL default '',
+ PRIMARY KEY (artistid)
+);
+
+CREATE TABLE t3(
+ trackid int(10) unsigned NOT NULL,
+ artistid int(10) unsigned NOT NULL,
+ PRIMARY KEY (trackid,artistid)
+);
+
+INSERT INTO t1 VALUES (1, 'April In Paris'), (2, 'Autumn In New York');
+INSERT INTO t2 VALUES (1, 'Vernon Duke');
+INSERT INTO t3 VALUES (1,1);
+
+SELECT CONCAT_WS(' ', trackname, artistname) trackname, artistname
+ FROM t1 LEFT JOIN t3 ON t1.trackid=t3.trackid
+ LEFT JOIN t2 ON t2.artistid=t3.artistid
+ WHERE CONCAT_WS(' ', trackname, artistname) LIKE '%In%';
+
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 9f920a1dd83..aa7ea9bb6cb 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -543,6 +543,18 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
DROP TABLE t1;
#
+
+#
+# Test for bug #11414: crash on Windows for a simple GROUP BY query
+#
+
+CREATE TABLE t1 (n int);
+INSERT INTO t1 VALUES (1);
+
+SELECT n+1 AS n FROM t1 GROUP BY n;
+
+DROP TABLE t1;
+
# Test for bug #8614: GROUP BY 'const' with DISTINCT
#
diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test
index a6468c52645..92e8c7f1231 100644
--- a/mysql-test/t/insert_select.test
+++ b/mysql-test/t/insert_select.test
@@ -3,7 +3,7 @@
#
--disable_warnings
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
--enable_warnings
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
@@ -180,10 +180,24 @@ drop table t1, t2;
#
create table t1 (a int unique);
create table t2 (a int, b int);
+create table t3 (c int, d int);
insert into t1 values (1),(2);
insert into t2 values (1,2);
+insert into t3 values (1,6),(3,7);
select * from t1;
-insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
+insert into t1 select a from t2 on duplicate key update a= t1.a + t2.b;
select * from t1;
-drop table t1;
-drop table t2;
+insert into t1 select a+1 from t2 on duplicate key update t1.a= t1.a + t2.b+1;
+select * from t1;
+insert into t1 select t3.c from t3 on duplicate key update a= a + t3.d;
+select * from t1;
+insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= a + 10;
+
+#Some error cases
+--error 1052
+insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
+--error 1109
+insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b;
+--error 1109
+insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b;
+drop table t1,t2,t3;
diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test
index 7653fd8dd42..64a76aafa5e 100644
--- a/mysql-test/t/insert_update.test
+++ b/mysql-test/t/insert_update.test
@@ -72,11 +72,13 @@ CREATE TABLE t2 (a INT, b INT, c INT, d INT);
# column names deliberately clash with columns in t1 (Bug#8147)
INSERT t2 VALUES (5,6,30,1), (7,4,40,1), (8,9,60,1);
INSERT t2 VALUES (2,1,11,2), (7,4,40,2);
-INSERT t1 SELECT a,b,c FROM t2 WHERE d=1 ON DUPLICATE KEY UPDATE c=c+100;
+INSERT t1 SELECT a,b,c FROM t2 WHERE d=1 ON DUPLICATE KEY UPDATE c=t1.c+100;
SELECT * FROM t1;
INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
SELECT * FROM t1;
+--error 1052
INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a);
+INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=t1.c+VALUES(t1.a);
SELECT *, VALUES(a) FROM t1;
DROP TABLE t1;
DROP TABLE t2;
@@ -89,10 +91,12 @@ create table t1 (a int not null unique) engine=myisam;
insert into t1 values (1),(2);
insert ignore into t1 select 1 on duplicate key update a=2;
select * from t1;
-insert ignore into t1 select a from t1 on duplicate key update a=a+1 ;
+insert ignore into t1 select a from t1 as t2 on duplicate key update a=t1.a+1 ;
select * from t1;
insert into t1 select 1 on duplicate key update a=2;
select * from t1;
---error 1062
+--error 1052
insert into t1 select a from t1 on duplicate key update a=a+1 ;
+--error 1052
+insert ignore into t1 select a from t1 on duplicate key update a=t1.a+1 ;
drop table t1;
diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test
index 51c6f6b5ac3..5e38c59386d 100644
--- a/mysql-test/t/lowercase_table2.test
+++ b/mysql-test/t/lowercase_table2.test
@@ -10,9 +10,10 @@ show variables like "lower_case_table_names";
enable_query_log;
--disable_warnings
-DROP TABLE IF EXISTS t1,t2,t3;
+DROP TABLE IF EXISTS t1,t2,t3,t2aA,t1Aa;
DROP DATABASE IF EXISTS `TEST_$1`;
DROP DATABASE IF EXISTS `test_$1`;
+DROP DATABASE mysqltest_LC2;
--enable_warnings
CREATE TABLE T1 (a int);
diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test
index 1e5c31da98e..2e5e2293b5c 100644
--- a/mysql-test/t/ndb_alter_table.test
+++ b/mysql-test/t/ndb_alter_table.test
@@ -7,6 +7,13 @@ DROP TABLE IF EXISTS t1;
drop database if exists mysqltest;
--enable_warnings
+connect (con1,localhost,root,,test);
+connect (con2,localhost,root,,test);
+
+connection con2;
+-- sleep 2
+connection con1;
+
#
# Basic test to show that the ALTER TABLE
# is working
@@ -92,10 +99,6 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES (9410,9412);
-connect (con1,localhost,,,test);
-connect (con2,localhost,,,test);
-
-connection con1;
ALTER TABLE t1 ADD COLUMN c int not null;
select * from t1 order by a;
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index e131c3d0517..da08c7253a4 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -2007,6 +2007,21 @@ CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b));
INSERT INTO t1 VALUES (0x8000000000000000);
SELECT b FROM t1 WHERE b=0x8000000000000000;
DROP TABLE t1;
+
+#
+# IN with outer join condition (BUG#9393)
+#
+CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);
+
+CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);
+INSERT INTO `t2` VALUES (0,'READ');
+
+CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);
+INSERT INTO `t3` VALUES (1,'fs');
+
+select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
+
+drop table t1,t2,t3;
# Test for bug #6474
#
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index f8d833b6b73..c3ffdc79c16 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -373,9 +373,13 @@ drop table t1;
#
# Bug #6993: myisam_data_pointer_size
+# Wrong bug report, data pointer size must be restricted to 7,
+# setting to 8 will not work on all computers, myisamchk and
+# the server may see a wrong value, such as 0 or negative number
+# if 8 bytes is set.
#
-SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8;
+SET GLOBAL MYISAM_DATA_POINTER_SIZE= 7;
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
#
diff --git a/mysys/my_access.c b/mysys/my_access.c
index c01031827c0..256749ed447 100644
--- a/mysys/my_access.c
+++ b/mysys/my_access.c
@@ -98,17 +98,16 @@ int check_if_legal_filename(const char *path)
for (reserved_name= reserved_names; *reserved_name; reserved_name++)
{
+ const char *reserved= *reserved_name; /* never empty */
const char *name= path;
- const char *current_reserved_name= *reserved_name;
- while (name != end && *current_reserved_name)
+ do
{
- if (*current_reserved_name != my_toupper(&my_charset_latin1, *name))
+ if (*reserved != my_toupper(&my_charset_latin1, *name))
break;
- current_reserved_name++;
if (++name == end)
DBUG_RETURN(1); /* Found wrong path */
- }
+ } while (*++reserved);
}
DBUG_RETURN(0);
}
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index 002e5ca0f06..f07beec9f39 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -19,27 +19,36 @@
#include <errno.h>
#include "mysys_err.h"
-static void make_ftype(my_string to,int flag);
+static void make_ftype(my_string to,int flag);
- /* Open a file as stream */
+/*
+ Open a file as stream
-FILE *my_fopen(const char *FileName, int Flags, myf MyFlags)
- /* Path-name of file */
- /* Read | write .. */
- /* Special flags */
+ SYNOPSIS
+ my_fopen()
+ FileName Path-name of file
+ Flags Read | write | append | trunc (like for open())
+ MyFlags Flags for handling errors
+
+ RETURN
+ 0 Error
+ # File handler
+*/
+
+FILE *my_fopen(const char *filename, int flags, myf MyFlags)
{
FILE *fd;
char type[5];
DBUG_ENTER("my_fopen");
- DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d",
- FileName, Flags, MyFlags));
+ DBUG_PRINT("my",("Name: '%s' flags: %d MyFlags: %d",
+ filename, flags, MyFlags));
/*
if we are not creating, then we need to use my_access to make sure
the file exists since Windows doesn't handle files like "com1.sym"
very well
*/
#ifdef __WIN__
- if (check_if_legal_filename(FileName))
+ if (check_if_legal_filename(filename))
{
errno= EACCES;
fd= 0;
@@ -47,8 +56,8 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags)
else
#endif
{
- make_ftype(type,Flags);
- fd = fopen(FileName, type);
+ make_ftype(type,flags);
+ fd = fopen(filename, type);
}
if (fd != 0)
@@ -65,7 +74,7 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags)
}
pthread_mutex_lock(&THR_LOCK_open);
if ((my_file_info[fileno(fd)].name = (char*)
- my_strdup(FileName,MyFlags)))
+ my_strdup(filename,MyFlags)))
{
my_stream_opened++;
my_file_info[fileno(fd)].type = STREAM_BY_FOPEN;
@@ -81,9 +90,9 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags)
my_errno=errno;
DBUG_PRINT("error",("Got error %d on open",my_errno));
if (MyFlags & (MY_FFNF | MY_FAE | MY_WME))
- my_error((Flags & O_RDONLY) || (Flags == O_RDONLY ) ? EE_FILENOTFOUND :
+ my_error((flags & O_RDONLY) || (flags == O_RDONLY ) ? EE_FILENOTFOUND :
EE_CANTCREATEFILE,
- MYF(ME_BELL+ME_WAITTANG), FileName,my_errno);
+ MYF(ME_BELL+ME_WAITTANG), filename, my_errno);
DBUG_RETURN((FILE*) 0);
} /* my_fopen */
@@ -158,33 +167,39 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
DBUG_RETURN(fd);
} /* my_fdopen */
+
/*
- make_ftype
- Make a filehandler-open-typestring from ordinary inputflags
+ Make a fopen() typestring from a open() type bitmap
+
+ SYNOPSIS
+ make_ftype()
+ to String for fopen() is stored here
+ flag Flag used by open()
- Note: This routine attempts to find the best possible match
- between a numeric option and a string option that could be
- fed to fopen. There is not a 1 to 1 mapping between the two.
+ IMPLEMENTATION
+ This routine attempts to find the best possible match
+ between a numeric option and a string option that could be
+ fed to fopen. There is not a 1 to 1 mapping between the two.
- r == O_RDONLY
- w == O_WRONLY|O_TRUNC|O_CREAT
- a == O_WRONLY|O_APPEND|O_CREAT
- r+ == O_RDWR
- w+ == O_RDWR|O_TRUNC|O_CREAT
- a+ == O_RDWR|O_APPEND|O_CREAT
+ NOTE
+ On Unix, O_RDONLY is usually 0
+
+ MAPPING
+ r == O_RDONLY
+ w == O_WRONLY|O_TRUNC|O_CREAT
+ a == O_WRONLY|O_APPEND|O_CREAT
+ r+ == O_RDWR
+ w+ == O_RDWR|O_TRUNC|O_CREAT
+ a+ == O_RDWR|O_APPEND|O_CREAT
*/
+
static void make_ftype(register my_string to, register int flag)
{
-#if FILE_BINARY
- /* If we have binary-files */
- reg3 int org_flag=flag;
-#endif
- flag&= ~FILE_BINARY; /* remove binary bit */
-
/* check some possible invalid combinations */
- DBUG_ASSERT(flag & (O_TRUNC|O_APPEND) != O_TRUNC|O_APPEND);
+ DBUG_ASSERT((flag & (O_TRUNC | O_APPEND)) != (O_TRUNC | O_APPEND));
+ DBUG_ASSERT((flag & (O_WRONLY | O_RDWR)) != (O_WRONLY | O_RDWR));
- if (flag & (O_RDONLY|O_WRONLY) == O_WRONLY)
+ if ((flag & (O_RDONLY|O_WRONLY)) == O_WRONLY)
*to++= (flag & O_APPEND) ? 'a' : 'w';
else if (flag & O_RDWR)
{
@@ -201,9 +216,8 @@ static void make_ftype(register my_string to, register int flag)
*to++= 'r';
#if FILE_BINARY /* If we have binary-files */
- if (org_flag & FILE_BINARY)
+ if (flag & FILE_BINARY)
*to++='b';
#endif
*to='\0';
} /* make_ftype */
-
diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh
index 6165a31fac2..c79433f97c1 100644
--- a/scripts/make_win_src_distribution.sh
+++ b/scripts/make_win_src_distribution.sh
@@ -361,6 +361,9 @@ if [ -d $BASE/SSL/SCCS ]
then
find $BASE/ -type d -name SCCS -printf " \"%p\"" | xargs rm -r -f
fi
+find $BASE/ -type d -name .deps -printf " \"%p\"" | xargs rm -r -f
+find $BASE/ -type d -name .libs -printf " \"%p\"" | xargs rm -r -f
+rm -r -f "$BASE/mysql-test/var"
#
# Initialize the initial data directory
diff --git a/sql/field.cc b/sql/field.cc
index fb244de4275..56bb40e0f8f 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1444,6 +1444,7 @@ my_decimal *Field_str::val_decimal(my_decimal *decimal_value)
uint Field::fill_cache_field(CACHE_FIELD *copy)
{
+ uint store_length;
copy->str=ptr;
copy->length=pack_length();
copy->blob_field=0;
@@ -1457,10 +1458,16 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
else if (!zero_pack() &&
(type() == MYSQL_TYPE_STRING && copy->length >= 4 &&
copy->length < 256))
+ {
copy->strip=1; /* Remove end space */
+ store_length= 2;
+ }
else
+ {
copy->strip=0;
- return copy->length+(int) copy->strip;
+ store_length= 0;
+ }
+ return copy->length+ store_length;
}
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 1ce0ede7164..89b81f684a3 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -515,8 +515,10 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans)
if (m_rows_to_insert == 1)
m_dupkey= table->s->primary_key;
else
- // We are batching inserts, offending key is not available
+ {
+ /* We are batching inserts, offending key is not available */
m_dupkey= (uint) -1;
+ }
}
DBUG_RETURN(res);
}
diff --git a/sql/handler.cc b/sql/handler.cc
index 46a80770024..a61dce35501 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1949,14 +1949,12 @@ int ha_create_table_from_engine(THD* thd,
HA_CREATE_INFO create_info;
TABLE table;
DBUG_ENTER("ha_create_table_from_engine");
- DBUG_PRINT("enter", ("name '%s'.'%s'",
- db, name));
+ DBUG_PRINT("enter", ("name '%s'.'%s'", db, name));
bzero((char*) &create_info,sizeof(create_info));
-
- if(error= ha_discover(thd, db, name, &frmblob, &frmlen))
+ if ((error= ha_discover(thd, db, name, &frmblob, &frmlen)))
{
- // Table could not be discovered and thus not created
+ /* Table could not be discovered and thus not created */
DBUG_RETURN(error);
}
@@ -1967,11 +1965,10 @@ int ha_create_table_from_engine(THD* thd,
(void)strxnmov(path,FN_REFLEN,mysql_data_home,"/",db,"/",name,NullS);
// Save the frm file
- if (writefrm(path, frmblob, frmlen))
- {
- my_free((char*) frmblob, MYF(MY_ALLOW_ZERO_PTR));
+ error= writefrm(path, frmblob, frmlen);
+ my_free((char*) frmblob, MYF(0));
+ if (error)
DBUG_RETURN(2);
- }
if (openfrm(thd, path,"",0,(uint) READ_ALL, 0, &table))
DBUG_RETURN(3);
@@ -1987,7 +1984,6 @@ int ha_create_table_from_engine(THD* thd,
}
error=table.file->create(path,&table,&create_info);
VOID(closefrm(&table));
- my_free((char*) frmblob, MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN(error != 0);
}
diff --git a/sql/item.cc b/sql/item.cc
index 766d40f209e..8bc71ae5693 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -338,7 +338,6 @@ Item::Item():
place == IN_HAVING)
thd->lex->current_select->select_n_having_items++;
}
- item_flags= 0;
}
/*
@@ -359,8 +358,7 @@ Item::Item(THD *thd, Item *item):
unsigned_flag(item->unsigned_flag),
with_sum_func(item->with_sum_func),
fixed(item->fixed),
- collation(item->collation),
- item_flags(item->item_flags)
+ collation(item->collation)
{
next= thd->free_list; // Put in free list
thd->free_list= this;
diff --git a/sql/item.h b/sql/item.h
index d5d4edb84d5..560f1124fb4 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -312,13 +312,8 @@ struct Name_resolution_context
typedef bool (Item::*Item_processor)(byte *arg);
typedef Item* (Item::*Item_transformer) (byte *arg);
-
typedef void (*Cond_traverser) (const Item *item, void *arg);
-/*
- See comments for sql_yacc.yy: insert_update_elem rule
- */
-#define MY_ITEM_PREFER_1ST_TABLE 1
class Item {
Item(const Item &); /* Prevent use of these */
@@ -369,7 +364,6 @@ public:
my_bool is_autogenerated_name; /* indicate was name of this Item
autogenerated or set by user */
DTCollation collation;
- uint8 item_flags; /* Flags on how item should be processed */
// alloc & destruct is done as start of select using sql_alloc
Item();
@@ -684,11 +678,6 @@ public:
cleanup();
delete this;
}
- virtual bool set_flags_processor(byte *args)
- {
- this->item_flags|= *((uint8*)args);
- return false;
- }
virtual bool is_splocal() { return 0; } /* Needed for error checking */
};
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 16dab3c1b46..4ed04e89ce3 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -849,6 +849,12 @@ class Item_func_in :public Item_int_func
bool nulls_in_row();
bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
+ /*
+ IN() protect from NULL only first argument, if construction like
+ "expression IN ()" will be allowed, we will need to check number of
+ argument here, because "NOT(NULL IN ())" is TRUE.
+ */
+ table_map not_null_tables() const { return args[0]->not_null_tables(); }
};
/* Functions used by where clause */
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 40c4c501222..1ad65fb6208 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -371,8 +371,8 @@ String *Item_func_des_encrypt::val_str(String *str)
uint key_number, res_length, tail;
String *res= args[0]->val_str(str);
- if ((null_value=args[0]->null_value))
- goto error;
+ if ((null_value= args[0]->null_value))
+ return 0; // ENCRYPT(NULL) == NULL
if ((res_length=res->length()) == 0)
return &my_empty_string;
@@ -464,7 +464,7 @@ String *Item_func_des_decrypt::val_str(String *str)
uint length= 0, tail;
if ((null_value=args[0]->null_value))
- goto error;
+ return 0;
length=res->length();
if (length < 9 || (length % 8) != 1 || !((*res)[0] & 128))
return res; // Skip decryption if not encrypted
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index b8696895047..d85210984d9 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -95,6 +95,7 @@ public:
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "concat_ws"; }
+ table_map not_null_tables() const { return 0; }
};
class Item_func_reverse :public Item_str_func
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 9a3684c3865..daa3618808b 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -717,7 +717,8 @@ bool mysql_multi_update(THD *thd, TABLE_LIST *table_list,
COND *conds, ulong options,
enum enum_duplicates handle_duplicates, bool ignore,
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
-bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
+bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
+ TABLE_LIST *dup_table_list, TABLE *table,
List<Item> &fields, List_item *values,
List<Item> &update_fields,
List<Item> &update_values, enum_duplicates duplic,
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index bc4cc81506e..b24d42cbcfd 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -5388,7 +5388,7 @@ The minimum value for this variable is 4096.",
"Default pointer size to be used for MyISAM tables.",
(gptr*) &myisam_data_pointer_size,
(gptr*) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
- 6, 2, 8, 0, 1, 0},
+ 6, 2, 7, 0, 1, 0},
{"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
"Deprecated option",
(gptr*) &global_system_variables.myisam_max_extra_sort_file_size,
@@ -6360,9 +6360,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case (int) OPT_SLOW_QUERY_LOG:
opt_slow_log=1;
break;
- case (int) OPT_LOG_SLOW_ADMIN_STATEMENTS:
- opt_log_slow_admin_statements= 1;
- break;
case (int) OPT_SKIP_NEW:
opt_specialflag|= SPECIAL_NO_NEW_FUNC;
delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
diff --git a/sql/set_var.cc b/sql/set_var.cc
index fbf3332a37a..3f991713eb7 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1617,7 +1617,7 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
{
if (!(res= var->value->val_str(&str)))
{
- strmake(buff, "NULL", 4);
+ strmov(buff, "NULL");
goto err;
}
var->save_result.ulong_value= ((ulong)
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index ef3ccf794b0..0d19a45c438 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2619,7 +2619,7 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
const char *name=item->field_name;
uint length=(uint) strlen(name);
char name_buff[NAME_LEN+1];
-
+ bool allow_rowid;
if (item->cached_table)
{
/*
@@ -2686,13 +2686,10 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
db= name_buff;
}
- bool search_global= item->item_flags & MY_ITEM_PREFER_1ST_TABLE;
if (table_name && table_name[0])
{ /* Qualified field */
- bool found_table=0;
- uint table_idx= 0;
- for (; tables; tables= search_global?tables->next_global:tables->next_local,
- table_idx++)
+ bool found_table= 0;
+ for (; tables; tables= tables->next_local),
{
/* TODO; Ensure that db and tables->db always points to something ! */
if (!my_strcasecmp(table_alias_charset, tables->alias, table_name) &&
@@ -2728,8 +2725,6 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
return (Field*) 0;
}
found=find;
- if (table_idx == 0 && item->item_flags & MY_ITEM_PREFER_1ST_TABLE)
- break;
}
}
}
@@ -2754,11 +2749,10 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
return (Field*) not_found_field;
return (Field*) 0;
}
- bool allow_rowid= tables && !tables->next_local; // Only one table
- uint table_idx= 0;
- for (; tables ; tables= search_global?tables->next_global:tables->next_local,
- table_idx++)
+ allow_rowid= tables && !tables->next_local; // Only one table
+ for (; tables ; tables= tables->next_local)
{
+ Field *field;
if (!tables->table && !tables->ancestor)
{
if (report_error == REPORT_ALL_ERRORS ||
@@ -2767,17 +2761,17 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
return (Field*) not_found_field;
}
- Field *field= find_field_in_table(thd, tables, name, item->name,
- length, ref,
- (tables->table &&
- test(tables->table->grant.
- want_privilege) &&
- check_privileges),
- (test(tables->grant.want_privilege) &&
- check_privileges),
- allow_rowid,
- &(item->cached_field_index),
- register_tree_change);
+ field= find_field_in_table(thd, tables, name, item->name,
+ length, ref,
+ (tables->table &&
+ test(tables->table->grant.
+ want_privilege) &&
+ check_privileges),
+ (test(tables->grant.want_privilege) &&
+ check_privileges),
+ allow_rowid,
+ &(item->cached_field_index),
+ register_tree_change);
if (field)
{
if (field == WRONG_GRANT)
@@ -2793,8 +2787,6 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
return (Field*) 0;
}
found= field;
- if (table_idx == 0 && item->item_flags & MY_ITEM_PREFER_1ST_TABLE)
- break;
}
}
if (found)
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 53c47706734..adb1eb01292 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -327,7 +327,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
thd->used_tables=0;
values= its++;
- if (mysql_prepare_insert(thd, table_list, table, fields, values,
+ if (mysql_prepare_insert(thd, table_list, table_list, table, fields, values,
update_fields, update_values, duplic, &unused_conds,
FALSE))
goto abort;
@@ -734,28 +734,43 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
mysql_prepare_insert()
thd Thread handler
table_list Global/local table list
- table Table to insert into (can be NULL if table should be taken from
- table_list->table)
+ dup_table_list Tables to be used in ON DUPLICATE KEY
+ It's either all global tables or only the table we
+ insert into, depending on if we are using GROUP BY
+ in the SELECT clause).
+ table Table to insert into (can be NULL if table should
+ be taken from table_list->table)
where Where clause (for insert ... select)
select_insert TRUE if INSERT ... SELECT statement
+ TODO (in far future)
+ In cases of:
+ INSERT INTO t1 SELECT a, sum(a) as sum1 from t2 GROUP BY a
+ ON DUPLICATE KEY ...
+ we should be able to refer to sum1 in the ON DUPLICATE KEY part
+
+ WARNING
+ You MUST set table->insert_values to 0 after calling this function
+ before releasing the table object.
+
RETURN VALUE
FALSE OK
TRUE error
*/
-bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
+bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
+ TABLE_LIST *dup_table_list, TABLE *table,
List<Item> &fields, List_item *values,
List<Item> &update_fields, List<Item> &update_values,
enum_duplicates duplic,
COND **where, bool select_insert)
{
- TABLE_LIST *save_table_list= thd->lex->select_lex.context.table_list;
+ SELECT_LEX= &thd->lex->select_lex;
+ TABLE_LIST *save_table_list;
+ TABLE_LIST *save_next_local;
bool insert_into_view= (table_list->view != 0);
- bool save_resolve_in_select_list=
- thd->lex->select_lex.context.resolve_in_select_list;
+ bool save_resolve_in_select_list;
bool res;
- TABLE_LIST *next_local;
DBUG_ENTER("mysql_prepare_insert");
DBUG_PRINT("enter", ("table_list 0x%lx, table 0x%lx, view %d",
(ulong)table_list, (ulong)table,
@@ -768,7 +783,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
*/
if (!select_insert)
{
- for (SELECT_LEX_UNIT *un= thd->lex->select_lex.first_inner_unit();
+ for (SELECT_LEX_UNIT *un= select_lex->first_inner_unit();
un;
un= un->next_unit())
{
@@ -792,23 +807,30 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
select_insert))
DBUG_RETURN(TRUE);
- next_local= table_list->next_local;
+ save_table_list= select_lex->context.table_list;
+ save_resolve_in_select_list= select_lex->context.resolve_in_select_list;
+ save_next_local= table_list->next_local;
+
table_list->next_local= 0;
- thd->lex->select_lex.context.resolve_in_table_list_only(table_list);
+ select_lex->context.resolve_in_table_list_only(table_list);
if ((values && check_insert_fields(thd, table_list, fields, *values,
!insert_into_view)) ||
(values && setup_fields(thd, 0, *values, 0, 0, 0)) ||
- (duplic == DUP_UPDATE &&
- ((thd->lex->select_lex.no_wrap_view_item= TRUE,
- (res= check_update_fields(thd, table_list, update_fields)),
- thd->lex->select_lex.no_wrap_view_item= FALSE,
- res) ||
- setup_fields(thd, 0, update_values, 1, 0, 0))))
- DBUG_RETURN(TRUE);
- table_list->next_local= next_local;
- thd->lex->select_lex.context.table_list= save_table_list;
- thd->lex->select_lex.context.resolve_in_select_list=
- save_resolve_in_select_list;
+ setup_fields(thd, 0, update_values, 1, 0, 0))
+ res= TRUE;
+ else if (duplic == DUP_UPDATE)
+ {
+ select_lex->context.resolve_in_table_list_only(dup_table_list);
+ select_lex->no_wrap_view_item= TRUE;
+ res= check_update_fields(thd, table_list, update_fields);
+ select_lex->no_wrap_view_item= FALSE;
+ }
+ table_list->next_local= save_next_local;
+ select_lex->context.table_list= save_table_list;
+ select_lex->context.resolve_in_select_list= save_resolve_in_select_list;
+ if (res)
+ DBUG_RETURN(res);
+
if (!table)
table= table_list->table;
@@ -820,8 +842,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
DBUG_RETURN(TRUE);
}
- thd->lex->select_lex.fix_prepare_information(thd, &fake_conds);
- thd->lex->select_lex.first_execution= 0;
+ select_lex->fix_prepare_information(thd, &fake_conds);
+ select_lex->first_execution= 0;
}
if (duplic == DUP_UPDATE || duplic == DUP_REPLACE)
table->file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY);
@@ -1992,12 +2014,25 @@ bool mysql_insert_select_prepare(THD *thd)
{
LEX *lex= thd->lex;
TABLE_LIST *first_select_leaf_table;
+ TABLE_LIST dup_tables;
DBUG_ENTER("mysql_insert_select_prepare");
+
/*
SELECT_LEX do not belong to INSERT statement, so we can't add WHERE
clause if table is VIEW
*/
- if (mysql_prepare_insert(thd, lex->query_tables,
+
+ dup_tables= *lex->query_tables;
+ if (lex->select_lex->group_list.elements != 0)
+ {
+ /*
+ When we are using GROUP BY we can't refere to other tables in the
+ ON DUPLICATE KEY part
+ */
+ dup_tables.local_next= 0;
+ }
+
+ if (mysql_prepare_insert(thd, lex->query_tables, &dup_tables
lex->query_tables->table, lex->field_list, 0,
lex->update_list, lex->value_list,
lex->duplicates,
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 057d2f23ed3..d9e50cba9e4 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3236,6 +3236,7 @@ end_with_restore_list:
case SQLCOM_REPLACE_SELECT:
case SQLCOM_INSERT_SELECT:
{
+ select_result *result;
DBUG_ASSERT(first_table == all_tables && first_table != 0);
if ((res= insert_precheck(thd, all_tables)))
break;
@@ -3247,9 +3248,7 @@ end_with_restore_list:
/* Don't unlock tables until command is written to binary log */
select_lex->options|= SELECT_NO_UNLOCK;
- select_result *result;
unit->set_limit(select_lex);
-
if (!(res= open_and_lock_tables(thd, all_tables)))
{
/* Skip first table, which is the table we are inserting in */
@@ -6405,9 +6404,10 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
*/
/*
- Writing this command to the binlog may result in infinite loops when doing
- mysqlbinlog|mysql, and anyway it does not really make sense to log it
- automatically (would cause more trouble to users than it would help them)
+ Writing this command to the binlog may result in infinite loops
+ when doing mysqlbinlog|mysql, and anyway it does not really make
+ sense to log it automatically (would cause more trouble to users
+ than it would help them)
*/
tmp_write_to_binlog= 0;
mysql_log.new_file(1);
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 136854a4eaf..61f9ab9e00d 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -939,7 +939,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
table_list->table->insert_values=(byte *)1;
}
- if (mysql_prepare_insert(thd, table_list, table_list->table, fields,
+ if (mysql_prepare_insert(thd, table_list, table_list, table_list->table, fields,
values, update_fields, update_values, duplic,
&unused_conds, FALSE))
goto error;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index d7ef692e8c3..2e6794dd983 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -28,8 +28,6 @@
#include <hash.h>
#include <ft_global.h>
-typedef uint32 cache_rec_length_type;
-
const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
"MAYBE_REF","ALL","range","index","fulltext",
"ref_or_null","unique_subquery","index_subquery",
@@ -184,8 +182,8 @@ static void read_cached_record(JOIN_TAB *tab);
static bool cmp_buffer_with_ref(JOIN_TAB *tab);
static bool setup_new_fields(THD *thd, List<Item> &fields,
List<Item> &all_fields, ORDER *new_order);
-static ORDER *create_distinct_group(THD *thd, ORDER *order,
- List<Item> &fields,
+static ORDER *create_distinct_group(THD *thd, Item **ref_pointer_array,
+ ORDER *order, List<Item> &fields,
bool *all_order_by_fields_used);
static bool test_if_subpart(ORDER *a,ORDER *b);
static TABLE *get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables);
@@ -781,7 +779,8 @@ JOIN::optimize()
bool all_order_fields_used;
if (order)
skip_sort_order= test_if_skip_sort_order(tab, order, select_limit, 1);
- if ((group_list=create_distinct_group(thd, order, fields_list,
+ if ((group_list=create_distinct_group(thd, select_lex->ref_pointer_array,
+ order, fields_list,
&all_order_fields_used)))
{
bool skip_group= (skip_sort_order &&
@@ -11638,7 +11637,7 @@ used_blob_length(CACHE_FIELD **ptr)
static bool
store_record_in_cache(JOIN_CACHE *cache)
{
- cache_rec_length_type length;
+ uint length;
uchar *pos;
CACHE_FIELD *copy,*end_field;
bool last_record;
@@ -11683,9 +11682,9 @@ store_record_in_cache(JOIN_CACHE *cache)
end > str && end[-1] == ' ' ;
end--) ;
length=(uint) (end-str);
- memcpy(pos+sizeof(length), str, length);
- memcpy_fixed(pos, &length, sizeof(length));
- pos+= length+sizeof(length);
+ memcpy(pos+2, str, length);
+ int2store(pos, length);
+ pos+= length+2;
}
else
{
@@ -11719,7 +11718,7 @@ static void
read_cached_record(JOIN_TAB *tab)
{
uchar *pos;
- cache_rec_length_type length;
+ uint length;
bool last_record;
CACHE_FIELD *copy,*end_field;
@@ -11748,10 +11747,10 @@ read_cached_record(JOIN_TAB *tab)
{
if (copy->strip)
{
- memcpy_fixed(&length, pos, sizeof(length));
- memcpy(copy->str, pos+sizeof(length), length);
+ length= uint2korr(pos);
+ memcpy(copy->str, pos+2, length);
memset(copy->str+length, ' ', copy->length-length);
- pos+= sizeof(length)+length;
+ pos+= 2 + length;
}
else
{
@@ -11788,12 +11787,10 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref)
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
for (store_key **copy=ref->key_copy ; *copy ; copy++)
{
- int res;
- if ((res= (*copy)->copy()))
+ if ((*copy)->copy() & 1)
{
thd->count_cuted_fields= save_count_cuted_fields;
- if ((res= res & 1))
- return res; // Something went wrong
+ return 1; // Something went wrong
}
}
thd->count_cuted_fields= save_count_cuted_fields;
@@ -12093,12 +12090,14 @@ setup_new_fields(THD *thd, List<Item> &fields,
*/
static ORDER *
-create_distinct_group(THD *thd, ORDER *order_list, List<Item> &fields,
+create_distinct_group(THD *thd, Item **ref_pointer_array,
+ ORDER *order_list, List<Item> &fields,
bool *all_order_by_fields_used)
{
List_iterator<Item> li(fields);
Item *item;
ORDER *order,*group,**prev;
+ uint index= 0;
*all_order_by_fields_used= 1;
while ((item=li++))
@@ -12130,11 +12129,17 @@ create_distinct_group(THD *thd, ORDER *order_list, List<Item> &fields,
ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER));
if (!ord)
return 0;
- ord->item=li.ref();
+ /*
+ We have here only field_list (not all_field_list), so we can use
+ simple indexing of ref_pointer_array (order in the array and in the
+ list are same)
+ */
+ ord->item= ref_pointer_array + index;
ord->asc=1;
*prev=ord;
prev= &ord->next;
}
+ index++;
}
*prev=0;
return group;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 5903576947d..b050d46f358 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -267,7 +267,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
table->table_name);
else
error= 1;
-
}
else
{
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b1438f1c571..4fc9819d0e1 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -6148,24 +6148,9 @@ insert_update_elem:
simple_ident_nospvar equal expr_or_default
{
LEX *lex= Lex;
- uint8 tmp= MY_ITEM_PREFER_1ST_TABLE;
if (lex->update_list.push_back($1) ||
lex->value_list.push_back($3))
YYABORT;
- /*
- INSERT INTO a1(a) SELECT b1.a FROM b1 ON DUPLICATE KEY
- UPDATE a= a + b1.b
-
- Set MY_ITEM_PREFER_1ST_TABLE flag to $1 and $3 items
- to prevent find_field_in_tables() doing further item searching
- if it finds item occurence in first table in insert_table_list.
- This allows to avoid ambiguity in resolving 'a' field in
- example above.
- */
- $1->walk(&Item::set_flags_processor,
- (byte *) &tmp);
- $3->walk(&Item::set_flags_processor,
- (byte *) &tmp);
};
opt_low_priority:
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index 5844a6e688b..408e511d2e8 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -223,7 +223,7 @@ static int my_strnncoll_ucs2(CHARSET_INFO *cs,
t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
if ( s_wc != t_wc )
{
- return ((int) s_wc) - ((int) t_wc);
+ return s_wc > t_wc ? 1 : -1;
}
s+=s_res;
@@ -284,7 +284,7 @@ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)),
int t_wc = uni_plane[t[0]] ? (int) uni_plane[t[0]][t[1]].sort :
(((int) t[0]) << 8) + (int) t[1];
if ( s_wc != t_wc )
- return s_wc - t_wc;
+ return s_wc > t_wc ? 1 : -1;
s+= 2;
t+= 2;
@@ -1364,7 +1364,7 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO *cs,
}
if ( s_wc != t_wc )
{
- return ((int) s_wc) - ((int) t_wc);
+ return s_wc > t_wc ? 1 : -1;
}
s+=s_res;
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index 53197972dab..865c9f494c8 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -2204,7 +2204,7 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs,
t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
if ( s_wc != t_wc )
{
- return ((int) s_wc) - ((int) t_wc);
+ return s_wc > t_wc ? 1 : -1;
}
s+=s_res;
@@ -2277,7 +2277,7 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs,
t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
if ( s_wc != t_wc )
{
- return ((int) s_wc) - ((int) t_wc);
+ return s_wc > t_wc ? 1 : -1;
}
s+=s_res;