Merge with 4.1

This commit is contained in:
monty@mysql.com 2005-07-03 14:17:52 +03:00
commit 86d7b02199
50 changed files with 521 additions and 239 deletions

View File

@ -23,7 +23,7 @@ EXTRA_DIST = INSTALL-SOURCE README COPYING EXCEPTIONS-CLIENT
SUBDIRS = . include @docs_dirs@ @zlib_dir@ @yassl_dir@ \ SUBDIRS = . include @docs_dirs@ @zlib_dir@ @yassl_dir@ \
@readline_topdir@ sql-common \ @readline_topdir@ sql-common \
@thread_dirs@ pstack \ @thread_dirs@ pstack \
@sql_union_dirs@ scripts man tests \ @sql_union_dirs@ scripts @man_dirs@ tests \
netware @libmysqld_dirs@ \ netware @libmysqld_dirs@ \
@bench_dirs@ support-files @tools_dirs@ @bench_dirs@ support-files @tools_dirs@

View File

@ -539,6 +539,12 @@ static void write_footer(FILE *sql_file)
} }
} /* write_footer */ } /* write_footer */
static void free_table_ent(char *key)
{
my_free((gptr) key, MYF(0));
}
byte* get_table_key(const char *entry, uint *length, byte* get_table_key(const char *entry, uint *length,
my_bool not_used __attribute__((unused))) 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) void init_table_rule_hash(HASH* h)
{ {
if(hash_init(h, charset_info, 16, 0, 0, if (hash_init(h, 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); exit(EX_EOM);
} }
@ -806,7 +813,8 @@ static void DB_error(MYSQL *mysql, const char *when)
SYNOPSIS SYNOPSIS
mysql_query_with_error_report() mysql_query_with_error_report()
mysql_con connection to use 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 query query to send to server
RETURN VALUES RETURN VALUES
@ -958,13 +966,14 @@ static char *quote_name(const char *name, char *buff, my_bool force)
return buff; return buff;
} /* quote_name */ } /* quote_name */
/* /*
Quote a table name so it can be used in "SHOW TABLES LIKE <tabname>" Quote a table name so it can be used in "SHOW TABLES LIKE <tabname>"
SYNOPSIS SYNOPSIS
quote_for_like quote_for_like()
name - name of the table name name of the table
buff - quoted name of the table buff quoted name of the table
DESCRIPTION DESCRIPTION
Quote \, _, ' and % characters Quote \, _, ' and % characters
@ -980,7 +989,6 @@ static char *quote_name(const char *name, char *buff, my_bool force)
Example: "t\1" => "t\\\\1" Example: "t\1" => "t\\\\1"
*/ */
static char *quote_for_like(const char *name, char *buff) static char *quote_for_like(const char *name, char *buff)
{ {
char *to= 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 */ /* Check that there are any fields in the table */
if(numFields == 0) if (numFields == 0)
{ {
if (verbose) if (verbose)
fprintf(stderr, fprintf(stderr,
@ -2446,7 +2454,6 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
DYNAMIC_STRING lock_tables_query; DYNAMIC_STRING lock_tables_query;
HASH dump_tables; HASH dump_tables;
char *table_name; char *table_name;
DBUG_ENTER("dump_selected_tables"); DBUG_ENTER("dump_selected_tables");
if (init_dumping(db)) 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 */ /* Init hash table for storing the actual name of tables to dump */
if (hash_init(&dump_tables, charset_info, 16, 0, 0, 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); exit(EX_EOM);
init_dynamic_string(&lock_tables_query, "LOCK TABLES ", 256, 1024); init_dynamic_string(&lock_tables_query, "LOCK TABLES ", 256, 1024);
for (; tables > 0 ; tables-- , table_names++) for (; tables > 0 ; tables-- , table_names++)
{ {
/* the table name passed on commandline may be wrong case */ /* the table name passed on commandline may be wrong case */
if (!get_actual_table_name( *table_names, if (!get_actual_table_name(*table_names,
new_table_name, sizeof(new_table_name) )) new_table_name, sizeof(new_table_name)))
{ {
/* Add found table name to lock_tables_query */ /* Add found table name to lock_tables_query */
if (lock_tables) 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); table_name= hash_element(&dump_tables, i);
DBUG_PRINT("info",("Dumping table %s", table_name)); 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); dump_table(numrows, table_name);
} }
@ -2926,6 +2934,7 @@ int main(int argc, char **argv)
{ {
compatible_mode_normal_str[0]= 0; compatible_mode_normal_str[0]= 0;
default_charset= (char *)mysql_universal_client_charset; default_charset= (char *)mysql_universal_client_charset;
bzero((char*) &ignore_table, sizeof(ignore_table));
MY_INIT("mysqldump"); MY_INIT("mysqldump");
if (get_options(&argc, &argv)) if (get_options(&argc, &argv))
@ -2984,6 +2993,8 @@ err:
if (md_result_file != stdout) if (md_result_file != stdout)
my_fclose(md_result_file, MYF(0)); my_fclose(md_result_file, MYF(0));
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
if (hash_inited(&ignore_table))
hash_free(&ignore_table);
if (extended_insert) if (extended_insert)
dynstr_free(&extended_row); dynstr_free(&extended_row);
if (insert_pat_inited) if (insert_pat_inited)

View File

@ -994,28 +994,29 @@ static void do_exec(struct st_query* q)
error= pclose(res_file); error= pclose(res_file);
if (error != 0) if (error != 0)
{ {
uint status= WEXITSTATUS(error); uint status= WEXITSTATUS(error), i;
if(q->abort_on_error) my_bool ok= 0;
if (q->abort_on_error)
die("At line %u: command \"%s\" failed", start_lineno, cmd); 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", DBUG_PRINT("info",
("error: %d, status: %d", error, status)); ("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));
DBUG_PRINT("info", ("expected error: %d", q->expected_errno[i].code.errnum)); if ((q->expected_errno[i].type == ERR_ERRNO) &&
if ((q->expected_errno[i].type == ERR_ERRNO) && (q->expected_errno[i].code.errnum == status))
(q->expected_errno[i].code.errnum == status)) ok= 1;
ok= 1; verbose_msg("At line %u: command \"%s\" failed with expected error: %d",
verbose_msg("At line %u: command \"%s\" failed with expected error: %d", start_lineno, cmd, status);
start_lineno, cmd, status);
}
if (!ok)
die("At line: %u: command \"%s\" failed with wrong 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 && else if (q->expected_errno[0].type == ERR_ERRNO &&
q->expected_errno[0].code.errnum != 0) q->expected_errno[0].code.errnum != 0)

View File

@ -770,10 +770,13 @@ err:
uint mi_get_pointer_length(ulonglong file_length, uint def) uint mi_get_pointer_length(ulonglong file_length, uint def)
{ {
DBUG_ASSERT(def >= 2 && def <= 7);
if (file_length) /* If not default */ if (file_length) /* If not default */
{ {
#ifdef NOT_YET_READY_FOR_8_BYTE_POINTERS
if (file_length >= (longlong) 1 << 56) if (file_length >= (longlong) 1 << 56)
def=8; def=8;
#endif
if (file_length >= (longlong) 1 << 48) if (file_length >= (longlong) 1 << 48)
def=7; def=7;
if (file_length >= (longlong) 1 << 40) if (file_length >= (longlong) 1 << 40)

View File

@ -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; int lock_error,kfile,open_mode,save_errno,have_rtree=0;
uint i,j,len,errpos,head_length,base_pos,offset,info_length,keys, uint i,j,len,errpos,head_length,base_pos,offset,info_length,keys,
key_parts,unique_key_parts,fulltext_keys,uniques; 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]; data_name[FN_REFLEN];
char *disk_cache, *disk_pos, *end_pos; char *disk_cache, *disk_pos, *end_pos;
MI_INFO info,*m_info,*old_info; MI_INFO info,*m_info,*old_info;

View File

@ -638,6 +638,17 @@ Warnings:
Warning 1264 Out of range value adjusted for column 'Field1' at row 1 Warning 1264 Out of range value adjusted for column 'Field1' at row 1
DROP TABLE t1; DROP TABLE t1;
SET NAMES latin1; 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)); CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
update t1 set b=a; update t1 set b=a;

View File

@ -939,3 +939,14 @@ content msisdn
ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримримримр м.Дадимфшьмримд им.Адимимрн имадми 1234567890 ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримримримр м.Дадимфшьмримд им.Адимимрн имадми 1234567890
11 g 1234567890 11 g 1234567890
DROP TABLE t1,t2; 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;

View File

@ -128,18 +128,12 @@ Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(NULL); select des_encrypt(NULL);
des_encrypt(NULL) des_encrypt(NULL)
NULL NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(NULL, 10); select des_encrypt(NULL, 10);
des_encrypt(NULL, 10) des_encrypt(NULL, 10)
NULL NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(NULL, NULL); select des_encrypt(NULL, NULL);
des_encrypt(NULL, NULL) des_encrypt(NULL, NULL)
NULL NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(10, NULL); select des_encrypt(10, NULL);
des_encrypt(10, NULL) des_encrypt(10, NULL)
NULL NULL
@ -156,18 +150,12 @@ hello
select des_decrypt(NULL); select des_decrypt(NULL);
des_decrypt(NULL) des_decrypt(NULL)
NULL NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_decrypt'
select des_decrypt(NULL, 10); select des_decrypt(NULL, 10);
des_decrypt(NULL, 10) des_decrypt(NULL, 10)
NULL NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_decrypt'
select des_decrypt(NULL, NULL); select des_decrypt(NULL, NULL);
des_decrypt(NULL, NULL) des_decrypt(NULL, NULL)
NULL NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_decrypt'
select des_decrypt(10, NULL); select des_decrypt(10, NULL);
des_decrypt(10, NULL) des_decrypt(10, NULL)
10 10

View File

@ -23,6 +23,11 @@ des_encrypt("test", NULL)
NULL NULL
Warnings: Warnings:
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working 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'); select des_decrypt("test", 'anotherkeystr');
des_decrypt("test", 'anotherkeystr') des_decrypt("test", 'anotherkeystr')
NULL NULL

View File

@ -811,3 +811,53 @@ SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
str num str num
notnumber 0 notnumber 0
DROP TABLE t1,t2; 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;

View File

@ -721,6 +721,12 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
WHERE hostname LIKE '%aol%' WHERE hostname LIKE '%aol%'
GROUP BY hostname; GROUP BY hostname;
hostname no 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 cache-dtc-af05.proxy.aol.com 1
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a int, b int); CREATE TABLE t1 (a int, b int);

View File

@ -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); 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); 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); create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
@ -636,16 +636,35 @@ ff1 ff2
drop table t1, t2; drop table t1, t2;
create table t1 (a int unique); create table t1 (a int unique);
create table t2 (a int, b int); create table t2 (a int, b int);
create table t3 (c int, d int);
insert into t1 values (1),(2); insert into t1 values (1),(2);
insert into t2 values (1,2); insert into t2 values (1,2);
insert into t3 values (1,6),(3,7);
select * from t1; select * from t1;
a a
1 1
2 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; select * from t1;
a a
2 2
3 3
drop table t1; insert into t1 select a+1 from t2 on duplicate key update t1.a= t1.a + t2.b+1;
drop table t2; 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;

View File

@ -143,7 +143,7 @@ INSERT t1 VALUES (1,2,10), (3,4,20);
CREATE TABLE t2 (a INT, b INT, c INT, d INT); 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 (5,6,30,1), (7,4,40,1), (8,9,60,1);
INSERT t2 VALUES (2,1,11,2), (7,4,40,2); 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; SELECT * FROM t1;
a b c a b c
1 2 10 1 2 10
@ -158,6 +158,8 @@ a b c
5 0 30 5 0 30
8 9 60 8 9 60
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=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; SELECT *, VALUES(a) FROM t1;
a b c VALUES(a) a b c VALUES(a)
1 2 10 NULL 1 2 10 NULL
@ -174,7 +176,7 @@ select * from t1;
a a
1 1
2 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; select * from t1;
a a
1 1
@ -185,5 +187,7 @@ a
2 2
3 3
insert into t1 select a from t1 on duplicate key update a=a+1 ; 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; drop table t1;

View File

@ -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 IF EXISTS `test_$1`; DROP DATABASE IF EXISTS `test_$1`;
DROP DATABASE mysqltest_LC2;
CREATE TABLE T1 (a int); CREATE TABLE T1 (a int);
INSERT INTO T1 VALUES (1); INSERT INTO T1 VALUES (1);
SHOW TABLES LIKE "T1"; SHOW TABLES LIKE "T1";

View File

@ -2681,6 +2681,15 @@ SELECT COUNT(*) FROM t1 WHERE
AND FK_firma_id = 2; AND FK_firma_id = 2;
COUNT(*) COUNT(*)
0 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; drop table t1;
CREATE TABLE t1 (a int); CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int); CREATE TABLE t2 (a int);

View File

@ -504,10 +504,10 @@ t1 CREATE TABLE `t1` (
`c4` double default NULL `c4` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8; SET GLOBAL MYISAM_DATA_POINTER_SIZE= 7;
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE'; SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
Variable_name Value Variable_name Value
myisam_data_pointer_size 8 myisam_data_pointer_size 7
SET GLOBAL table_cache=-1; SET GLOBAL table_cache=-1;
SHOW VARIABLES LIKE 'table_cache'; SHOW VARIABLES LIKE 'table_cache';
Variable_name Value Variable_name Value

View File

@ -407,6 +407,18 @@ INSERT INTO t1 VALUES ('-1');
DROP TABLE t1; DROP TABLE t1;
SET NAMES latin1; 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 # Conversion from an UCS2 string to a decimal column
# #

View File

@ -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'; SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890';
DROP TABLE t1,t2; 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;

View File

@ -9,6 +9,7 @@ select des_encrypt("test", 1);
select des_encrypt("test", 9); select des_encrypt("test", 9);
select des_encrypt("test", 100); select des_encrypt("test", 100);
select des_encrypt("test", NULL); select des_encrypt("test", NULL);
select des_encrypt(NULL, NULL);
select des_decrypt("test", 'anotherkeystr'); select des_decrypt("test", 'anotherkeystr');
select des_decrypt(1, 1); select des_decrypt(1, 1);
select des_decrypt(des_encrypt("test", 'thekey')); select des_decrypt(des_encrypt("test", 'thekey'));

View File

@ -543,3 +543,59 @@ SELECT * FROM t1, t2 WHERE num=str;
SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6); SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
DROP TABLE t1,t2; 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;

View File

@ -543,6 +543,18 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
DROP TABLE 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 # Test for bug #8614: GROUP BY 'const' with DISTINCT
# #

View File

@ -3,7 +3,7 @@
# #
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2,t3;
--enable_warnings --enable_warnings
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL); 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 t1 (a int unique);
create table t2 (a int, b int); create table t2 (a int, b int);
create table t3 (c int, d int);
insert into t1 values (1),(2); insert into t1 values (1),(2);
insert into t2 values (1,2); insert into t2 values (1,2);
insert into t3 values (1,6),(3,7);
select * from t1; select * from t1;
insert into t1 select a from t2 on duplicate key update a= t1.a + t2.b;
select * from t1;
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; insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
select * from t1; --error 1109
drop table t1; insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b;
drop table t2; --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;

View File

@ -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) # 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 (5,6,30,1), (7,4,40,1), (8,9,60,1);
INSERT t2 VALUES (2,1,11,2), (7,4,40,2); 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; SELECT * FROM t1;
INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0; INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
SELECT * FROM t1; 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=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; SELECT *, VALUES(a) FROM t1;
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
@ -89,10 +91,12 @@ create table t1 (a int not null unique) engine=myisam;
insert into t1 values (1),(2); insert into t1 values (1),(2);
insert ignore into t1 select 1 on duplicate key update a=2; insert ignore into t1 select 1 on duplicate key update a=2;
select * from t1; 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; select * from t1;
insert into t1 select 1 on duplicate key update a=2; insert into t1 select 1 on duplicate key update a=2;
select * from t1; select * from t1;
--error 1062 --error 1052
insert into t1 select a from t1 on duplicate key update a=a+1 ; 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; drop table t1;

View File

@ -10,9 +10,10 @@ show variables like "lower_case_table_names";
enable_query_log; enable_query_log;
--disable_warnings --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 IF EXISTS `test_$1`; DROP DATABASE IF EXISTS `test_$1`;
DROP DATABASE mysqltest_LC2;
--enable_warnings --enable_warnings
CREATE TABLE T1 (a int); CREATE TABLE T1 (a int);

View File

@ -7,6 +7,13 @@ DROP TABLE IF EXISTS t1;
drop database if exists mysqltest; drop database if exists mysqltest;
--enable_warnings --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 # Basic test to show that the ALTER TABLE
# is working # is working
@ -92,10 +99,6 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES (9410,9412); 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; ALTER TABLE t1 ADD COLUMN c int not null;
select * from t1 order by a; select * from t1 order by a;

View File

@ -2007,6 +2007,21 @@ CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b));
INSERT INTO t1 VALUES (0x8000000000000000); INSERT INTO t1 VALUES (0x8000000000000000);
SELECT b FROM t1 WHERE b=0x8000000000000000; SELECT b FROM t1 WHERE b=0x8000000000000000;
DROP TABLE t1; 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 # Test for bug #6474
# #

View File

@ -373,9 +373,13 @@ drop table t1;
# #
# Bug #6993: myisam_data_pointer_size # 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'; SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
# #

View File

@ -98,17 +98,16 @@ int check_if_legal_filename(const char *path)
for (reserved_name= reserved_names; *reserved_name; reserved_name++) for (reserved_name= reserved_names; *reserved_name; reserved_name++)
{ {
const char *reserved= *reserved_name; /* never empty */
const char *name= path; 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; break;
current_reserved_name++;
if (++name == end) if (++name == end)
DBUG_RETURN(1); /* Found wrong path */ DBUG_RETURN(1); /* Found wrong path */
} } while (*++reserved);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }

View File

@ -19,27 +19,36 @@
#include <errno.h> #include <errno.h>
#include "mysys_err.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) SYNOPSIS
/* Path-name of file */ my_fopen()
/* Read | write .. */ FileName Path-name of file
/* Special flags */ 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; FILE *fd;
char type[5]; char type[5];
DBUG_ENTER("my_fopen"); DBUG_ENTER("my_fopen");
DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d", DBUG_PRINT("my",("Name: '%s' flags: %d MyFlags: %d",
FileName, Flags, MyFlags)); filename, flags, MyFlags));
/* /*
if we are not creating, then we need to use my_access to make sure 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" the file exists since Windows doesn't handle files like "com1.sym"
very well very well
*/ */
#ifdef __WIN__ #ifdef __WIN__
if (check_if_legal_filename(FileName)) if (check_if_legal_filename(filename))
{ {
errno= EACCES; errno= EACCES;
fd= 0; fd= 0;
@ -47,8 +56,8 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags)
else else
#endif #endif
{ {
make_ftype(type,Flags); make_ftype(type,flags);
fd = fopen(FileName, type); fd = fopen(filename, type);
} }
if (fd != 0) if (fd != 0)
@ -65,7 +74,7 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags)
} }
pthread_mutex_lock(&THR_LOCK_open); pthread_mutex_lock(&THR_LOCK_open);
if ((my_file_info[fileno(fd)].name = (char*) if ((my_file_info[fileno(fd)].name = (char*)
my_strdup(FileName,MyFlags))) my_strdup(filename,MyFlags)))
{ {
my_stream_opened++; my_stream_opened++;
my_file_info[fileno(fd)].type = STREAM_BY_FOPEN; 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; my_errno=errno;
DBUG_PRINT("error",("Got error %d on open",my_errno)); DBUG_PRINT("error",("Got error %d on open",my_errno));
if (MyFlags & (MY_FFNF | MY_FAE | MY_WME)) 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, EE_CANTCREATEFILE,
MYF(ME_BELL+ME_WAITTANG), FileName,my_errno); MYF(ME_BELL+ME_WAITTANG), filename, my_errno);
DBUG_RETURN((FILE*) 0); DBUG_RETURN((FILE*) 0);
} /* my_fopen */ } /* my_fopen */
@ -158,33 +167,39 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
DBUG_RETURN(fd); DBUG_RETURN(fd);
} /* my_fdopen */ } /* my_fdopen */
/*
make_ftype
Make a filehandler-open-typestring from ordinary inputflags
Note: This routine attempts to find the best possible match /*
between a numeric option and a string option that could be Make a fopen() typestring from a open() type bitmap
fed to fopen. There is not a 1 to 1 mapping between the two.
SYNOPSIS
make_ftype()
to String for fopen() is stored here
flag Flag used by open()
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 NOTE
w == O_WRONLY|O_TRUNC|O_CREAT On Unix, O_RDONLY is usually 0
a == O_WRONLY|O_APPEND|O_CREAT
r+ == O_RDWR MAPPING
w+ == O_RDWR|O_TRUNC|O_CREAT r == O_RDONLY
a+ == O_RDWR|O_APPEND|O_CREAT 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) 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 */ /* 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'; *to++= (flag & O_APPEND) ? 'a' : 'w';
else if (flag & O_RDWR) else if (flag & O_RDWR)
{ {
@ -201,9 +216,8 @@ static void make_ftype(register my_string to, register int flag)
*to++= 'r'; *to++= 'r';
#if FILE_BINARY /* If we have binary-files */ #if FILE_BINARY /* If we have binary-files */
if (org_flag & FILE_BINARY) if (flag & FILE_BINARY)
*to++='b'; *to++='b';
#endif #endif
*to='\0'; *to='\0';
} /* make_ftype */ } /* make_ftype */

View File

@ -361,6 +361,9 @@ if [ -d $BASE/SSL/SCCS ]
then then
find $BASE/ -type d -name SCCS -printf " \"%p\"" | xargs rm -r -f find $BASE/ -type d -name SCCS -printf " \"%p\"" | xargs rm -r -f
fi 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 # Initialize the initial data directory

View File

@ -1444,6 +1444,7 @@ my_decimal *Field_str::val_decimal(my_decimal *decimal_value)
uint Field::fill_cache_field(CACHE_FIELD *copy) uint Field::fill_cache_field(CACHE_FIELD *copy)
{ {
uint store_length;
copy->str=ptr; copy->str=ptr;
copy->length=pack_length(); copy->length=pack_length();
copy->blob_field=0; copy->blob_field=0;
@ -1457,10 +1458,16 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
else if (!zero_pack() && else if (!zero_pack() &&
(type() == MYSQL_TYPE_STRING && copy->length >= 4 && (type() == MYSQL_TYPE_STRING && copy->length >= 4 &&
copy->length < 256)) copy->length < 256))
{
copy->strip=1; /* Remove end space */ copy->strip=1; /* Remove end space */
store_length= 2;
}
else else
{
copy->strip=0; copy->strip=0;
return copy->length+(int) copy->strip; store_length= 0;
}
return copy->length+ store_length;
} }

View File

@ -515,8 +515,10 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans)
if (m_rows_to_insert == 1) if (m_rows_to_insert == 1)
m_dupkey= table->s->primary_key; m_dupkey= table->s->primary_key;
else else
// We are batching inserts, offending key is not available {
/* We are batching inserts, offending key is not available */
m_dupkey= (uint) -1; m_dupkey= (uint) -1;
}
} }
DBUG_RETURN(res); DBUG_RETURN(res);
} }

View File

@ -1949,14 +1949,12 @@ int ha_create_table_from_engine(THD* thd,
HA_CREATE_INFO create_info; HA_CREATE_INFO create_info;
TABLE table; TABLE table;
DBUG_ENTER("ha_create_table_from_engine"); DBUG_ENTER("ha_create_table_from_engine");
DBUG_PRINT("enter", ("name '%s'.'%s'", DBUG_PRINT("enter", ("name '%s'.'%s'", db, name));
db, name));
bzero((char*) &create_info,sizeof(create_info)); 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); 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); (void)strxnmov(path,FN_REFLEN,mysql_data_home,"/",db,"/",name,NullS);
// Save the frm file // Save the frm file
if (writefrm(path, frmblob, frmlen)) error= writefrm(path, frmblob, frmlen);
{ my_free((char*) frmblob, MYF(0));
my_free((char*) frmblob, MYF(MY_ALLOW_ZERO_PTR)); if (error)
DBUG_RETURN(2); DBUG_RETURN(2);
}
if (openfrm(thd, path,"",0,(uint) READ_ALL, 0, &table)) if (openfrm(thd, path,"",0,(uint) READ_ALL, 0, &table))
DBUG_RETURN(3); DBUG_RETURN(3);
@ -1987,7 +1984,6 @@ int ha_create_table_from_engine(THD* thd,
} }
error=table.file->create(path,&table,&create_info); error=table.file->create(path,&table,&create_info);
VOID(closefrm(&table)); VOID(closefrm(&table));
my_free((char*) frmblob, MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN(error != 0); DBUG_RETURN(error != 0);
} }

View File

@ -338,7 +338,6 @@ Item::Item():
place == IN_HAVING) place == IN_HAVING)
thd->lex->current_select->select_n_having_items++; 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), unsigned_flag(item->unsigned_flag),
with_sum_func(item->with_sum_func), with_sum_func(item->with_sum_func),
fixed(item->fixed), fixed(item->fixed),
collation(item->collation), collation(item->collation)
item_flags(item->item_flags)
{ {
next= thd->free_list; // Put in free list next= thd->free_list; // Put in free list
thd->free_list= this; thd->free_list= this;

View File

@ -312,13 +312,8 @@ struct Name_resolution_context
typedef bool (Item::*Item_processor)(byte *arg); typedef bool (Item::*Item_processor)(byte *arg);
typedef Item* (Item::*Item_transformer) (byte *arg); typedef Item* (Item::*Item_transformer) (byte *arg);
typedef void (*Cond_traverser) (const Item *item, void *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 { class Item {
Item(const Item &); /* Prevent use of these */ Item(const Item &); /* Prevent use of these */
@ -369,7 +364,6 @@ public:
my_bool is_autogenerated_name; /* indicate was name of this Item my_bool is_autogenerated_name; /* indicate was name of this Item
autogenerated or set by user */ autogenerated or set by user */
DTCollation collation; DTCollation collation;
uint8 item_flags; /* Flags on how item should be processed */
// alloc & destruct is done as start of select using sql_alloc // alloc & destruct is done as start of select using sql_alloc
Item(); Item();
@ -684,11 +678,6 @@ public:
cleanup(); cleanup();
delete this; 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 */ virtual bool is_splocal() { return 0; } /* Needed for error checking */
}; };

View File

@ -849,6 +849,12 @@ class Item_func_in :public Item_int_func
bool nulls_in_row(); bool nulls_in_row();
bool is_bool_func() { return 1; } bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; } 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 */ /* Functions used by where clause */

View File

@ -371,8 +371,8 @@ String *Item_func_des_encrypt::val_str(String *str)
uint key_number, res_length, tail; uint key_number, res_length, tail;
String *res= args[0]->val_str(str); String *res= args[0]->val_str(str);
if ((null_value=args[0]->null_value)) if ((null_value= args[0]->null_value))
goto error; return 0; // ENCRYPT(NULL) == NULL
if ((res_length=res->length()) == 0) if ((res_length=res->length()) == 0)
return &my_empty_string; return &my_empty_string;
@ -464,7 +464,7 @@ String *Item_func_des_decrypt::val_str(String *str)
uint length= 0, tail; uint length= 0, tail;
if ((null_value=args[0]->null_value)) if ((null_value=args[0]->null_value))
goto error; return 0;
length=res->length(); length=res->length();
if (length < 9 || (length % 8) != 1 || !((*res)[0] & 128)) if (length < 9 || (length % 8) != 1 || !((*res)[0] & 128))
return res; // Skip decryption if not encrypted return res; // Skip decryption if not encrypted

View File

@ -95,6 +95,7 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "concat_ws"; } const char *func_name() const { return "concat_ws"; }
table_map not_null_tables() const { return 0; }
}; };
class Item_func_reverse :public Item_str_func class Item_func_reverse :public Item_str_func

View File

@ -717,7 +717,8 @@ bool mysql_multi_update(THD *thd, TABLE_LIST *table_list,
COND *conds, ulong options, COND *conds, ulong options,
enum enum_duplicates handle_duplicates, bool ignore, enum enum_duplicates handle_duplicates, bool ignore,
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex); 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> &fields, List_item *values,
List<Item> &update_fields, List<Item> &update_fields,
List<Item> &update_values, enum_duplicates duplic, List<Item> &update_values, enum_duplicates duplic,

View File

@ -5388,7 +5388,7 @@ The minimum value for this variable is 4096.",
"Default pointer size to be used for MyISAM tables.", "Default pointer size to be used for MyISAM tables.",
(gptr*) &myisam_data_pointer_size, (gptr*) &myisam_data_pointer_size,
(gptr*) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG, (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, {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
"Deprecated option", "Deprecated option",
(gptr*) &global_system_variables.myisam_max_extra_sort_file_size, (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: case (int) OPT_SLOW_QUERY_LOG:
opt_slow_log=1; opt_slow_log=1;
break; break;
case (int) OPT_LOG_SLOW_ADMIN_STATEMENTS:
opt_log_slow_admin_statements= 1;
break;
case (int) OPT_SKIP_NEW: case (int) OPT_SKIP_NEW:
opt_specialflag|= SPECIAL_NO_NEW_FUNC; opt_specialflag|= SPECIAL_NO_NEW_FUNC;
delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE; delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;

View File

@ -1617,7 +1617,7 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
{ {
if (!(res= var->value->val_str(&str))) if (!(res= var->value->val_str(&str)))
{ {
strmake(buff, "NULL", 4); strmov(buff, "NULL");
goto err; goto err;
} }
var->save_result.ulong_value= ((ulong) var->save_result.ulong_value= ((ulong)

View File

@ -2619,7 +2619,7 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
const char *name=item->field_name; const char *name=item->field_name;
uint length=(uint) strlen(name); uint length=(uint) strlen(name);
char name_buff[NAME_LEN+1]; char name_buff[NAME_LEN+1];
bool allow_rowid;
if (item->cached_table) if (item->cached_table)
{ {
/* /*
@ -2686,13 +2686,10 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
db= name_buff; db= name_buff;
} }
bool search_global= item->item_flags & MY_ITEM_PREFER_1ST_TABLE;
if (table_name && table_name[0]) if (table_name && table_name[0])
{ /* Qualified field */ { /* Qualified field */
bool found_table=0; bool found_table= 0;
uint table_idx= 0; for (; tables; tables= tables->next_local),
for (; tables; tables= search_global?tables->next_global:tables->next_local,
table_idx++)
{ {
/* TODO; Ensure that db and tables->db always points to something ! */ /* TODO; Ensure that db and tables->db always points to something ! */
if (!my_strcasecmp(table_alias_charset, tables->alias, table_name) && 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; return (Field*) 0;
} }
found=find; 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*) not_found_field;
return (Field*) 0; return (Field*) 0;
} }
bool allow_rowid= tables && !tables->next_local; // Only one table allow_rowid= tables && !tables->next_local; // Only one table
uint table_idx= 0; for (; tables ; tables= tables->next_local)
for (; tables ; tables= search_global?tables->next_global:tables->next_local,
table_idx++)
{ {
Field *field;
if (!tables->table && !tables->ancestor) if (!tables->table && !tables->ancestor)
{ {
if (report_error == REPORT_ALL_ERRORS || 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; return (Field*) not_found_field;
} }
Field *field= find_field_in_table(thd, tables, name, item->name, field= find_field_in_table(thd, tables, name, item->name,
length, ref, length, ref,
(tables->table && (tables->table &&
test(tables->table->grant. test(tables->table->grant.
want_privilege) && want_privilege) &&
check_privileges), check_privileges),
(test(tables->grant.want_privilege) && (test(tables->grant.want_privilege) &&
check_privileges), check_privileges),
allow_rowid, allow_rowid,
&(item->cached_field_index), &(item->cached_field_index),
register_tree_change); register_tree_change);
if (field) if (field)
{ {
if (field == WRONG_GRANT) if (field == WRONG_GRANT)
@ -2793,8 +2787,6 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
return (Field*) 0; return (Field*) 0;
} }
found= field; found= field;
if (table_idx == 0 && item->item_flags & MY_ITEM_PREFER_1ST_TABLE)
break;
} }
} }
if (found) if (found)

View File

@ -327,7 +327,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
thd->used_tables=0; thd->used_tables=0;
values= its++; 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, update_fields, update_values, duplic, &unused_conds,
FALSE)) FALSE))
goto abort; goto abort;
@ -734,28 +734,43 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
mysql_prepare_insert() mysql_prepare_insert()
thd Thread handler thd Thread handler
table_list Global/local table list table_list Global/local table list
table Table to insert into (can be NULL if table should be taken from dup_table_list Tables to be used in ON DUPLICATE KEY
table_list->table) 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) where Where clause (for insert ... select)
select_insert TRUE if INSERT ... SELECT statement 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 RETURN VALUE
FALSE OK FALSE OK
TRUE error 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> &fields, List_item *values,
List<Item> &update_fields, List<Item> &update_values, List<Item> &update_fields, List<Item> &update_values,
enum_duplicates duplic, enum_duplicates duplic,
COND **where, bool select_insert) 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 insert_into_view= (table_list->view != 0);
bool save_resolve_in_select_list= bool save_resolve_in_select_list;
thd->lex->select_lex.context.resolve_in_select_list;
bool res; bool res;
TABLE_LIST *next_local;
DBUG_ENTER("mysql_prepare_insert"); DBUG_ENTER("mysql_prepare_insert");
DBUG_PRINT("enter", ("table_list 0x%lx, table 0x%lx, view %d", DBUG_PRINT("enter", ("table_list 0x%lx, table 0x%lx, view %d",
(ulong)table_list, (ulong)table, (ulong)table_list, (ulong)table,
@ -768,7 +783,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
*/ */
if (!select_insert) 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= un->next_unit()) un= un->next_unit())
{ {
@ -792,23 +807,30 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
select_insert)) select_insert))
DBUG_RETURN(TRUE); 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; 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, if ((values && check_insert_fields(thd, table_list, fields, *values,
!insert_into_view)) || !insert_into_view)) ||
(values && setup_fields(thd, 0, *values, 0, 0, 0)) || (values && setup_fields(thd, 0, *values, 0, 0, 0)) ||
(duplic == DUP_UPDATE && setup_fields(thd, 0, update_values, 1, 0, 0))
((thd->lex->select_lex.no_wrap_view_item= TRUE, res= TRUE;
(res= check_update_fields(thd, table_list, update_fields)), else if (duplic == DUP_UPDATE)
thd->lex->select_lex.no_wrap_view_item= FALSE, {
res) || select_lex->context.resolve_in_table_list_only(dup_table_list);
setup_fields(thd, 0, update_values, 1, 0, 0)))) select_lex->no_wrap_view_item= TRUE;
DBUG_RETURN(TRUE); res= check_update_fields(thd, table_list, update_fields);
table_list->next_local= next_local; select_lex->no_wrap_view_item= FALSE;
thd->lex->select_lex.context.table_list= save_table_list; }
thd->lex->select_lex.context.resolve_in_select_list= table_list->next_local= save_next_local;
save_resolve_in_select_list; 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) if (!table)
table= table_list->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); my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
thd->lex->select_lex.fix_prepare_information(thd, &fake_conds); select_lex->fix_prepare_information(thd, &fake_conds);
thd->lex->select_lex.first_execution= 0; select_lex->first_execution= 0;
} }
if (duplic == DUP_UPDATE || duplic == DUP_REPLACE) if (duplic == DUP_UPDATE || duplic == DUP_REPLACE)
table->file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY); table->file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY);
@ -1992,12 +2014,25 @@ bool mysql_insert_select_prepare(THD *thd)
{ {
LEX *lex= thd->lex; LEX *lex= thd->lex;
TABLE_LIST *first_select_leaf_table; TABLE_LIST *first_select_leaf_table;
TABLE_LIST dup_tables;
DBUG_ENTER("mysql_insert_select_prepare"); DBUG_ENTER("mysql_insert_select_prepare");
/* /*
SELECT_LEX do not belong to INSERT statement, so we can't add WHERE SELECT_LEX do not belong to INSERT statement, so we can't add WHERE
clause if table is VIEW 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->query_tables->table, lex->field_list, 0,
lex->update_list, lex->value_list, lex->update_list, lex->value_list,
lex->duplicates, lex->duplicates,

View File

@ -3236,6 +3236,7 @@ end_with_restore_list:
case SQLCOM_REPLACE_SELECT: case SQLCOM_REPLACE_SELECT:
case SQLCOM_INSERT_SELECT: case SQLCOM_INSERT_SELECT:
{ {
select_result *result;
DBUG_ASSERT(first_table == all_tables && first_table != 0); DBUG_ASSERT(first_table == all_tables && first_table != 0);
if ((res= insert_precheck(thd, all_tables))) if ((res= insert_precheck(thd, all_tables)))
break; break;
@ -3247,9 +3248,7 @@ end_with_restore_list:
/* Don't unlock tables until command is written to binary log */ /* Don't unlock tables until command is written to binary log */
select_lex->options|= SELECT_NO_UNLOCK; select_lex->options|= SELECT_NO_UNLOCK;
select_result *result;
unit->set_limit(select_lex); unit->set_limit(select_lex);
if (!(res= open_and_lock_tables(thd, all_tables))) if (!(res= open_and_lock_tables(thd, all_tables)))
{ {
/* Skip first table, which is the table we are inserting in */ /* 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 Writing this command to the binlog may result in infinite loops
mysqlbinlog|mysql, and anyway it does not really make sense to log it when doing mysqlbinlog|mysql, and anyway it does not really make
automatically (would cause more trouble to users than it would help them) sense to log it automatically (would cause more trouble to users
than it would help them)
*/ */
tmp_write_to_binlog= 0; tmp_write_to_binlog= 0;
mysql_log.new_file(1); mysql_log.new_file(1);

View File

@ -939,7 +939,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
table_list->table->insert_values=(byte *)1; 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, values, update_fields, update_values, duplic,
&unused_conds, FALSE)) &unused_conds, FALSE))
goto error; goto error;

View File

@ -28,8 +28,6 @@
#include <hash.h> #include <hash.h>
#include <ft_global.h> #include <ft_global.h>
typedef uint32 cache_rec_length_type;
const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
"MAYBE_REF","ALL","range","index","fulltext", "MAYBE_REF","ALL","range","index","fulltext",
"ref_or_null","unique_subquery","index_subquery", "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 cmp_buffer_with_ref(JOIN_TAB *tab);
static bool setup_new_fields(THD *thd, List<Item> &fields, static bool setup_new_fields(THD *thd, List<Item> &fields,
List<Item> &all_fields, ORDER *new_order); List<Item> &all_fields, ORDER *new_order);
static ORDER *create_distinct_group(THD *thd, ORDER *order, static ORDER *create_distinct_group(THD *thd, Item **ref_pointer_array,
List<Item> &fields, ORDER *order, List<Item> &fields,
bool *all_order_by_fields_used); bool *all_order_by_fields_used);
static bool test_if_subpart(ORDER *a,ORDER *b); static bool test_if_subpart(ORDER *a,ORDER *b);
static TABLE *get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables); static TABLE *get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables);
@ -781,7 +779,8 @@ JOIN::optimize()
bool all_order_fields_used; bool all_order_fields_used;
if (order) if (order)
skip_sort_order= test_if_skip_sort_order(tab, order, select_limit, 1); 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))) &all_order_fields_used)))
{ {
bool skip_group= (skip_sort_order && bool skip_group= (skip_sort_order &&
@ -11638,7 +11637,7 @@ used_blob_length(CACHE_FIELD **ptr)
static bool static bool
store_record_in_cache(JOIN_CACHE *cache) store_record_in_cache(JOIN_CACHE *cache)
{ {
cache_rec_length_type length; uint length;
uchar *pos; uchar *pos;
CACHE_FIELD *copy,*end_field; CACHE_FIELD *copy,*end_field;
bool last_record; bool last_record;
@ -11683,9 +11682,9 @@ store_record_in_cache(JOIN_CACHE *cache)
end > str && end[-1] == ' ' ; end > str && end[-1] == ' ' ;
end--) ; end--) ;
length=(uint) (end-str); length=(uint) (end-str);
memcpy(pos+sizeof(length), str, length); memcpy(pos+2, str, length);
memcpy_fixed(pos, &length, sizeof(length)); int2store(pos, length);
pos+= length+sizeof(length); pos+= length+2;
} }
else else
{ {
@ -11719,7 +11718,7 @@ static void
read_cached_record(JOIN_TAB *tab) read_cached_record(JOIN_TAB *tab)
{ {
uchar *pos; uchar *pos;
cache_rec_length_type length; uint length;
bool last_record; bool last_record;
CACHE_FIELD *copy,*end_field; CACHE_FIELD *copy,*end_field;
@ -11748,10 +11747,10 @@ read_cached_record(JOIN_TAB *tab)
{ {
if (copy->strip) if (copy->strip)
{ {
memcpy_fixed(&length, pos, sizeof(length)); length= uint2korr(pos);
memcpy(copy->str, pos+sizeof(length), length); memcpy(copy->str, pos+2, length);
memset(copy->str+length, ' ', copy->length-length); memset(copy->str+length, ' ', copy->length-length);
pos+= sizeof(length)+length; pos+= 2 + length;
} }
else else
{ {
@ -11788,12 +11787,10 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref)
thd->count_cuted_fields= CHECK_FIELD_IGNORE; thd->count_cuted_fields= CHECK_FIELD_IGNORE;
for (store_key **copy=ref->key_copy ; *copy ; copy++) for (store_key **copy=ref->key_copy ; *copy ; copy++)
{ {
int res; if ((*copy)->copy() & 1)
if ((res= (*copy)->copy()))
{ {
thd->count_cuted_fields= save_count_cuted_fields; thd->count_cuted_fields= save_count_cuted_fields;
if ((res= res & 1)) return 1; // Something went wrong
return res; // Something went wrong
} }
} }
thd->count_cuted_fields= save_count_cuted_fields; thd->count_cuted_fields= save_count_cuted_fields;
@ -12093,12 +12090,14 @@ setup_new_fields(THD *thd, List<Item> &fields,
*/ */
static ORDER * 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) bool *all_order_by_fields_used)
{ {
List_iterator<Item> li(fields); List_iterator<Item> li(fields);
Item *item; Item *item;
ORDER *order,*group,**prev; ORDER *order,*group,**prev;
uint index= 0;
*all_order_by_fields_used= 1; *all_order_by_fields_used= 1;
while ((item=li++)) 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)); ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER));
if (!ord) if (!ord)
return 0; 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; ord->asc=1;
*prev=ord; *prev=ord;
prev= &ord->next; prev= &ord->next;
} }
index++;
} }
*prev=0; *prev=0;
return group; return group;

View File

@ -267,7 +267,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
table->table_name); table->table_name);
else else
error= 1; error= 1;
} }
else else
{ {

View File

@ -6148,24 +6148,9 @@ insert_update_elem:
simple_ident_nospvar equal expr_or_default simple_ident_nospvar equal expr_or_default
{ {
LEX *lex= Lex; LEX *lex= Lex;
uint8 tmp= MY_ITEM_PREFER_1ST_TABLE;
if (lex->update_list.push_back($1) || if (lex->update_list.push_back($1) ||
lex->value_list.push_back($3)) lex->value_list.push_back($3))
YYABORT; 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: opt_low_priority:

View File

@ -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; t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
if ( s_wc != t_wc ) if ( s_wc != t_wc )
{ {
return ((int) s_wc) - ((int) t_wc); return s_wc > t_wc ? 1 : -1;
} }
s+=s_res; 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_wc = uni_plane[t[0]] ? (int) uni_plane[t[0]][t[1]].sort :
(((int) t[0]) << 8) + (int) t[1]; (((int) t[0]) << 8) + (int) t[1];
if ( s_wc != t_wc ) if ( s_wc != t_wc )
return s_wc - t_wc; return s_wc > t_wc ? 1 : -1;
s+= 2; s+= 2;
t+= 2; t+= 2;
@ -1364,7 +1364,7 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO *cs,
} }
if ( s_wc != t_wc ) if ( s_wc != t_wc )
{ {
return ((int) s_wc) - ((int) t_wc); return s_wc > t_wc ? 1 : -1;
} }
s+=s_res; s+=s_res;

View File

@ -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; t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
if ( s_wc != t_wc ) if ( s_wc != t_wc )
{ {
return ((int) s_wc) - ((int) t_wc); return s_wc > t_wc ? 1 : -1;
} }
s+=s_res; 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; t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
if ( s_wc != t_wc ) if ( s_wc != t_wc )
{ {
return ((int) s_wc) - ((int) t_wc); return s_wc > t_wc ? 1 : -1;
} }
s+=s_res; s+=s_res;