This commit is contained in:
serg@serg.mylan 2006-01-06 18:26:59 +01:00
commit 8dc77f267b
46 changed files with 437 additions and 300 deletions

View File

@ -22,6 +22,11 @@ functions */
#define _WIN32_WINNT 0x0500 #define _WIN32_WINNT 0x0500
#endif #endif
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Avoid endless warnings about sprintf() etc. being unsafe. */
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#include <sys/locking.h> #include <sys/locking.h>
#include <windows.h> #include <windows.h>
#include <math.h> /* Because of rint() */ #include <math.h> /* Because of rint() */
@ -329,6 +334,11 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_SETFILEPOINTER #define HAVE_SETFILEPOINTER
#define HAVE_VIO_READ_BUFF #define HAVE_VIO_READ_BUFF
#if defined(_WIN64) && defined(_M_X64)
/* Avoid type conflicts with built-in functions. */
#define HAVE_STRNLEN
#endif
#ifndef __NT__ #ifndef __NT__
#undef FILE_SHARE_DELETE #undef FILE_SHARE_DELETE
#define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */ #define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */

View File

@ -33,7 +33,7 @@ typedef void (*hash_free_key)(void *);
typedef struct st_hash { typedef struct st_hash {
uint key_offset,key_length; /* Length of key if const length */ uint key_offset,key_length; /* Length of key if const length */
uint records,blength,current_record; uint records, blength;
uint flags; uint flags;
DYNAMIC_ARRAY array; /* Place for hash_keys */ DYNAMIC_ARRAY array; /* Place for hash_keys */
hash_get_key get_key; hash_get_key get_key;
@ -41,6 +41,9 @@ typedef struct st_hash {
CHARSET_INFO *charset; CHARSET_INFO *charset;
} HASH; } HASH;
/* A search iterator state */
typedef uint HASH_SEARCH_STATE;
#define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,B,C,D,E,F,G, H CALLER_INFO) #define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,B,C,D,E,F,G, H CALLER_INFO)
my_bool _hash_init(HASH *hash, CHARSET_INFO *charset, my_bool _hash_init(HASH *hash, CHARSET_INFO *charset,
uint default_array_elements, uint key_offset, uint default_array_elements, uint key_offset,
@ -49,12 +52,15 @@ my_bool _hash_init(HASH *hash, CHARSET_INFO *charset,
void hash_free(HASH *tree); void hash_free(HASH *tree);
void my_hash_reset(HASH *hash); void my_hash_reset(HASH *hash);
byte *hash_element(HASH *hash,uint idx); byte *hash_element(HASH *hash,uint idx);
gptr hash_search(HASH *info,const byte *key,uint length); gptr hash_search(const HASH *info, const byte *key, uint length);
gptr hash_next(HASH *info,const byte *key,uint length); gptr hash_first(const HASH *info, const byte *key, uint length,
HASH_SEARCH_STATE *state);
gptr hash_next(const HASH *info, const byte *key, uint length,
HASH_SEARCH_STATE *state);
my_bool my_hash_insert(HASH *info,const byte *data); my_bool my_hash_insert(HASH *info,const byte *data);
my_bool hash_delete(HASH *hash,byte *record); my_bool hash_delete(HASH *hash,byte *record);
my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length); my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length);
void hash_replace(HASH *hash, uint idx, byte *new_row); void hash_replace(HASH *hash, HASH_SEARCH_STATE *state, byte *new_row);
my_bool hash_check(HASH *hash); /* Only in debug library */ my_bool hash_check(HASH *hash); /* Only in debug library */
#define hash_clear(H) bzero((char*) (H),sizeof(*(H))) #define hash_clear(H) bzero((char*) (H),sizeof(*(H)))

View File

@ -862,6 +862,7 @@ typedef off_t os_off_t;
#define SOCKET_EAGAIN WSAEINPROGRESS #define SOCKET_EAGAIN WSAEINPROGRESS
#define SOCKET_ETIMEDOUT WSAETIMEDOUT #define SOCKET_ETIMEDOUT WSAETIMEDOUT
#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
#define SOCKET_EADDRINUSE WSAEADDRINUSE
#define SOCKET_ENFILE ENFILE #define SOCKET_ENFILE ENFILE
#define SOCKET_EMFILE EMFILE #define SOCKET_EMFILE EMFILE
#elif defined(OS2) #elif defined(OS2)
@ -870,6 +871,7 @@ typedef off_t os_off_t;
#define SOCKET_EAGAIN SOCEINPROGRESS #define SOCKET_EAGAIN SOCEINPROGRESS
#define SOCKET_ETIMEDOUT SOCKET_EINTR #define SOCKET_ETIMEDOUT SOCKET_EINTR
#define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK #define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK
#define SOCKET_EADDRINUSE SOCEADDRINUSE
#define SOCKET_ENFILE SOCENFILE #define SOCKET_ENFILE SOCENFILE
#define SOCKET_EMFILE SOCEMFILE #define SOCKET_EMFILE SOCEMFILE
#define closesocket(A) soclose(A) #define closesocket(A) soclose(A)
@ -880,6 +882,7 @@ typedef off_t os_off_t;
#define SOCKET_EAGAIN EAGAIN #define SOCKET_EAGAIN EAGAIN
#define SOCKET_ETIMEDOUT SOCKET_EINTR #define SOCKET_ETIMEDOUT SOCKET_EINTR
#define SOCKET_EWOULDBLOCK EWOULDBLOCK #define SOCKET_EWOULDBLOCK EWOULDBLOCK
#define SOCKET_EADDRINUSE EADDRINUSE
#define SOCKET_ENFILE ENFILE #define SOCKET_ENFILE ENFILE
#define SOCKET_EMFILE EMFILE #define SOCKET_EMFILE EMFILE
#endif #endif

View File

@ -890,7 +890,14 @@ sub mtr_exit ($) {
# cluck("Called mtr_exit()"); # cluck("Called mtr_exit()");
mtr_timer_stop_all($::glob_timers); mtr_timer_stop_all($::glob_timers);
local $SIG{HUP} = 'IGNORE'; local $SIG{HUP} = 'IGNORE';
kill('HUP', -$$); # ToDo: Signalling -$$ will only work if we are the process group
# leader (in fact on QNX it will signal our session group leader,
# which might be Do-compile or Pushbuild, causing tests to be
# aborted). So we only do it if we are the group leader. We might
# set ourselves as the group leader at startup (with
# POSIX::setpgrp(0,0)), but then care must be needed to always do
# proper child process cleanup.
kill('HUP', -$$) if $$ == getpgrp();
sleep 2; sleep 2;
exit($code); exit($code);
} }

View File

@ -804,6 +804,12 @@ sub command_line_setup () {
} }
} }
# On QNX, /tmp/dir/master.sock and /tmp/dir//master.sock seem to be
# considered different, so avoid the extra slash (/) in the socket
# paths.
my $sockdir = $opt_tmpdir;
$sockdir =~ s|/+$||;
# Put this into a hash, will be a C struct # Put this into a hash, will be a C struct
$master->[0]= $master->[0]=
@ -812,7 +818,7 @@ sub command_line_setup () {
path_myerr => "$opt_vardir/log/master.err", path_myerr => "$opt_vardir/log/master.err",
path_mylog => "$opt_vardir/log/master.log", path_mylog => "$opt_vardir/log/master.log",
path_mypid => "$opt_vardir/run/master.pid", path_mypid => "$opt_vardir/run/master.pid",
path_mysock => "$opt_tmpdir/master.sock", path_mysock => "$sockdir/master.sock",
path_myport => $opt_master_myport, path_myport => $opt_master_myport,
start_timeout => 400, # enough time create innodb tables start_timeout => 400, # enough time create innodb tables
@ -825,7 +831,7 @@ sub command_line_setup () {
path_myerr => "$opt_vardir/log/master1.err", path_myerr => "$opt_vardir/log/master1.err",
path_mylog => "$opt_vardir/log/master1.log", path_mylog => "$opt_vardir/log/master1.log",
path_mypid => "$opt_vardir/run/master1.pid", path_mypid => "$opt_vardir/run/master1.pid",
path_mysock => "$opt_tmpdir/master1.sock", path_mysock => "$sockdir/master1.sock",
path_myport => $opt_master_myport + 1, path_myport => $opt_master_myport + 1,
start_timeout => 400, # enough time create innodb tables start_timeout => 400, # enough time create innodb tables
}; };
@ -836,7 +842,7 @@ sub command_line_setup () {
path_myerr => "$opt_vardir/log/slave.err", path_myerr => "$opt_vardir/log/slave.err",
path_mylog => "$opt_vardir/log/slave.log", path_mylog => "$opt_vardir/log/slave.log",
path_mypid => "$opt_vardir/run/slave.pid", path_mypid => "$opt_vardir/run/slave.pid",
path_mysock => "$opt_tmpdir/slave.sock", path_mysock => "$sockdir/slave.sock",
path_myport => $opt_slave_myport, path_myport => $opt_slave_myport,
start_timeout => 400, start_timeout => 400,
}; };
@ -847,7 +853,7 @@ sub command_line_setup () {
path_myerr => "$opt_vardir/log/slave1.err", path_myerr => "$opt_vardir/log/slave1.err",
path_mylog => "$opt_vardir/log/slave1.log", path_mylog => "$opt_vardir/log/slave1.log",
path_mypid => "$opt_vardir/run/slave1.pid", path_mypid => "$opt_vardir/run/slave1.pid",
path_mysock => "$opt_tmpdir/slave1.sock", path_mysock => "$sockdir/slave1.sock",
path_myport => $opt_slave_myport + 1, path_myport => $opt_slave_myport + 1,
start_timeout => 300, start_timeout => 300,
}; };
@ -858,7 +864,7 @@ sub command_line_setup () {
path_myerr => "$opt_vardir/log/slave2.err", path_myerr => "$opt_vardir/log/slave2.err",
path_mylog => "$opt_vardir/log/slave2.log", path_mylog => "$opt_vardir/log/slave2.log",
path_mypid => "$opt_vardir/run/slave2.pid", path_mypid => "$opt_vardir/run/slave2.pid",
path_mysock => "$opt_tmpdir/slave2.sock", path_mysock => "$sockdir/slave2.sock",
path_myport => $opt_slave_myport + 2, path_myport => $opt_slave_myport + 2,
start_timeout => 300, start_timeout => 300,
}; };
@ -868,7 +874,7 @@ sub command_line_setup () {
path_err => "$opt_vardir/log/im.err", path_err => "$opt_vardir/log/im.err",
path_log => "$opt_vardir/log/im.log", path_log => "$opt_vardir/log/im.log",
path_pid => "$opt_vardir/run/im.pid", path_pid => "$opt_vardir/run/im.pid",
path_sock => "$opt_tmpdir/im.sock", path_sock => "$sockdir/im.sock",
port => $im_port, port => $im_port,
start_timeout => $master->[0]->{'start_timeout'}, start_timeout => $master->[0]->{'start_timeout'},
admin_login => 'im_admin', admin_login => 'im_admin',
@ -883,7 +889,7 @@ sub command_line_setup () {
server_id => 1, server_id => 1,
port => $im_mysqld1_port, port => $im_mysqld1_port,
path_datadir => "$opt_vardir/im_mysqld_1.data", path_datadir => "$opt_vardir/im_mysqld_1.data",
path_sock => "$opt_tmpdir/mysqld_1.sock", path_sock => "$sockdir/mysqld_1.sock",
path_pid => "$opt_vardir/run/mysqld_1.pid", path_pid => "$opt_vardir/run/mysqld_1.pid",
}; };
@ -892,7 +898,7 @@ sub command_line_setup () {
server_id => 2, server_id => 2,
port => $im_mysqld2_port, port => $im_mysqld2_port,
path_datadir => "$opt_vardir/im_mysqld_2.data", path_datadir => "$opt_vardir/im_mysqld_2.data",
path_sock => "$opt_tmpdir/mysqld_2.sock", path_sock => "$sockdir/mysqld_2.sock",
path_pid => "$opt_vardir/run/mysqld_2.pid", path_pid => "$opt_vardir/run/mysqld_2.pid",
nonguarded => 1, nonguarded => 1,
}; };

View File

@ -272,7 +272,6 @@ a b
create table if not exists t1 select 3 as 'a',4 as 'b'; create table if not exists t1 select 3 as 'a',4 as 'b';
Warnings: Warnings:
Note 1050 Table 't1' already exists Note 1050 Table 't1' already exists
Warning 1364 Field 'a' doesn't have a default value
create table if not exists t1 select 3 as 'a',3 as 'b'; create table if not exists t1 select 3 as 'a',3 as 'b';
ERROR 23000: Duplicate entry '3' for key 1 ERROR 23000: Duplicate entry '3' for key 1
select * from t1; select * from t1;
@ -630,8 +629,6 @@ create table t1 (
a varchar(112) charset utf8 collate utf8_bin not null, a varchar(112) charset utf8 collate utf8_bin not null,
primary key (a) primary key (a)
) select 'test' as a ; ) select 'test' as a ;
Warnings:
Warning 1364 Field 'a' doesn't have a default value
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
@ -647,9 +644,6 @@ create table t1 (
a varchar(12) charset utf8 collate utf8_bin not null, a varchar(12) charset utf8 collate utf8_bin not null,
b int not null, primary key (a) b int not null, primary key (a)
) select a, 1 as b from t2 ; ) select a, 1 as b from t2 ;
Warnings:
Warning 1364 Field 'a' doesn't have a default value
Warning 1364 Field 'b' doesn't have a default value
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
@ -661,12 +655,37 @@ drop table t1;
create table t1 ( create table t1 (
a varchar(12) charset utf8 collate utf8_bin not null, a varchar(12) charset utf8 collate utf8_bin not null,
b int not null, primary key (a) b int not null, primary key (a)
) select 'a' as a , 1 as b from t2 ; ) select a, 1 as c from t2 ;
Warnings: Warnings:
Warning 1364 Field 'a' doesn't have a default value
Warning 1364 Field 'b' doesn't have a default value Warning 1364 Field 'b' doesn't have a default value
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` (
`b` int(11) NOT NULL,
`a` varchar(12) character set utf8 collate utf8_bin NOT NULL,
`c` bigint(1) NOT NULL default '0',
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (
a varchar(12) charset utf8 collate utf8_bin not null,
b int null, primary key (a)
) select a, 1 as c from t2 ;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`b` int(11) default NULL,
`a` varchar(12) character set utf8 collate utf8_bin NOT NULL,
`c` bigint(1) NOT NULL default '0',
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (
a varchar(12) charset utf8 collate utf8_bin not null,
b int not null, primary key (a)
) select 'a' as a , 1 as b from t2 ;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` varchar(12) character set utf8 collate utf8_bin NOT NULL, `a` varchar(12) character set utf8 collate utf8_bin NOT NULL,
`b` int(11) NOT NULL, `b` int(11) NOT NULL,
@ -677,8 +696,6 @@ create table t1 (
a varchar(12) charset utf8 collate utf8_bin, a varchar(12) charset utf8 collate utf8_bin,
b int not null, primary key (a) b int not null, primary key (a)
) select 'a' as a , 1 as b from t2 ; ) select 'a' as a , 1 as b from t2 ;
Warnings:
Warning 1364 Field 'b' doesn't have a default value
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
@ -697,8 +714,6 @@ a1 varchar(12) charset utf8 collate utf8_bin not null,
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
primary key (a1) primary key (a1)
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; ) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
Warnings:
Warning 1364 Field 'a1' doesn't have a default value
drop table t2; drop table t2;
create table t2 ( create table t2 (
a1 varchar(12) charset utf8 collate utf8_bin, a1 varchar(12) charset utf8 collate utf8_bin,
@ -714,8 +729,6 @@ a1 varchar(12) charset utf8 collate utf8_bin not null,
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
primary key (a1) primary key (a1)
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; ) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
Warnings:
Warning 1364 Field 'a1' doesn't have a default value
drop table t2; drop table t2;
create table t2 ( a int default 3, b int default 3) create table t2 ( a int default 3, b int default 3)
select a1,a2 from t1; select a1,a2 from t1;

View File

@ -1,4 +1,4 @@
drop table if exists t1; drop table if exists t1,t3,t4,t5;
create table t1 (a int, b char(10), key a(a), key b(a,b)); create table t1 (a int, b char(10), key a(a), key b(a,b));
insert into t1 values insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), (17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),

View File

@ -5,8 +5,6 @@ select ((@id := kill_id) - kill_id) from t1;
((@id := kill_id) - kill_id) ((@id := kill_id) - kill_id)
0 0
kill @id; kill @id;
select 1;
Got one of the listed errors
select ((@id := kill_id) - kill_id) from t1; select ((@id := kill_id) - kill_id) from t1;
((@id := kill_id) - kill_id) ((@id := kill_id) - kill_id)
0 0

View File

@ -1,4 +1,4 @@
DROP TABLE IF EXISTS t1,t2; DROP TABLE IF EXISTS t1,t2,test1,test2;
CREATE TABLE t1 (a int); CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t1 VALUES (1),(2),(3);
CREATE TABLE t2 (a int, b int); CREATE TABLE t2 (a int, b int);

View File

@ -57,6 +57,9 @@ insert into t1 values (15);
grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1; grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1;
grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1; grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1;
grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1; grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1;
SELECT 1;
1
1
create procedure foo4() create procedure foo4()
deterministic deterministic
begin begin

View File

@ -767,8 +767,7 @@ deallocate prepare stmt1;
drop procedure p1; drop procedure p1;
drop table t1, t2, t3; drop table t1, t2, t3;
create table t1 (a int); create table t1 (a int);
drop procedure if exists p2; CREATE PROCEDURE `p1`()
CREATE PROCEDURE `p2`()
begin begin
insert into t1 values (1); insert into t1 values (1);
end// end//
@ -777,8 +776,8 @@ begin
declare done int default 0; declare done int default 0;
set done= not done; set done= not done;
end// end//
CALL p2(); CALL p1();
drop procedure p2; drop procedure p1;
drop table t1; drop table t1;
create trigger t1_bi before insert on test.t1 for each row set @a:=0; create trigger t1_bi before insert on test.t1 for each row set @a:=0;
ERROR 3D000: No database selected ERROR 3D000: No database selected

View File

@ -2423,6 +2423,9 @@ drop view v1;
drop table t1; drop table t1;
create table t1(f1 int, f2 int); create table t1(f1 int, f2 int);
insert into t1 values (null, 10), (null,2); insert into t1 values (null, 10), (null,2);
select f1, sum(f2) from t1 group by f1;
f1 sum(f2)
NULL 12
create view v1 as select * from t1; create view v1 as select * from t1;
select f1, sum(f2) from v1 group by f1; select f1, sum(f2) from v1 group by f1;
f1 sum(f2) f1 sum(f2)

View File

@ -564,6 +564,22 @@ create table t1 (
show create table t1; show create table t1;
drop table t1; drop table t1;
--warning 1364
create table t1 (
a varchar(12) charset utf8 collate utf8_bin not null,
b int not null, primary key (a)
) select a, 1 as c from t2 ;
show create table t1;
drop table t1;
--warning 1364
create table t1 (
a varchar(12) charset utf8 collate utf8_bin not null,
b int null, primary key (a)
) select a, 1 as c from t2 ;
show create table t1;
drop table t1;
--warning 1364 --warning 1364
create table t1 ( create table t1 (
a varchar(12) charset utf8 collate utf8_bin not null, a varchar(12) charset utf8 collate utf8_bin not null,

View File

@ -11,6 +11,5 @@
############################################################################## ##############################################################################
sp-goto : GOTO is currently is disabled - will be fixed in the future sp-goto : GOTO is currently is disabled - will be fixed in the future
kill : Unstable test case, bug#9712
subselect : Bug#15706 subselect : Bug#15706
type_time : Bug#15805 type_time : Bug#15805

View File

@ -3,7 +3,7 @@
# #
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1,t3,t4,t5;
--enable_warnings --enable_warnings
create table t1 (a int, b char(10), key a(a), key b(a,b)); create table t1 (a int, b char(10), key a(a), key b(a,b));

View File

@ -25,11 +25,18 @@ select ((@id := kill_id) - kill_id) from t1;
kill @id; kill @id;
connection con1; connection con1;
--sleep 1 --sleep 2
# this statement should fail --disable_query_log
--error 2006,2013 --disable_result_log
# One of the following statements should fail
--error 0,2006,2013
select 1; select 1;
--error 0,2006,2013
select 1;
--enable_query_log
--enable_result_log
--enable_reconnect --enable_reconnect
# this should work, and we should have a new connection_id() # this should work, and we should have a new connection_id()
select ((@id := kill_id) - kill_id) from t1; select ((@id := kill_id) - kill_id) from t1;

View File

@ -2,7 +2,7 @@
-- source include/not_embedded.inc -- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1,t2; DROP TABLE IF EXISTS t1,t2,test1,test2;
--enable_warnings --enable_warnings
# #

View File

@ -87,6 +87,14 @@ grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1;
grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1; grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1;
grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1; grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1;
# ToDo: BUG#14931: There is a race between the last grant binlogging, and
# the binlogging in the new connection made below, causing sporadic test
# failures due to switched statement order in binlog. To fix this we do
# SELECT 1 in the first connection before starting the second, ensuring
# that binlogging is done in the expected order.
# Please remove this SELECT 1 when BUG#14931 is fixed.
SELECT 1;
connect (con1,127.0.0.1,zedjzlcsjhd,,mysqltest1,$MASTER_MYPORT,); connect (con1,127.0.0.1,zedjzlcsjhd,,mysqltest1,$MASTER_MYPORT,);
connection con1; connection con1;

View File

@ -930,11 +930,8 @@ drop table t1, t2, t3;
# operator. # operator.
# #
create table t1 (a int); create table t1 (a int);
--disable_warnings
drop procedure if exists p2;
--enable_warnings
DELIMITER //; DELIMITER //;
CREATE PROCEDURE `p2`() CREATE PROCEDURE `p1`()
begin begin
insert into t1 values (1); insert into t1 values (1);
end// end//
@ -944,8 +941,8 @@ begin
set done= not done; set done= not done;
end// end//
DELIMITER ;// DELIMITER ;//
CALL p2(); CALL p1();
drop procedure p2; drop procedure p1;
drop table t1; drop table t1;
# #

View File

@ -2275,6 +2275,7 @@ drop table t1;
# #
create table t1(f1 int, f2 int); create table t1(f1 int, f2 int);
insert into t1 values (null, 10), (null,2); insert into t1 values (null, 10), (null,2);
select f1, sum(f2) from t1 group by f1;
create view v1 as select * from t1; create view v1 as select * from t1;
select f1, sum(f2) from v1 group by f1; select f1, sum(f2) from v1 group by f1;
drop view v1; drop view v1;

View File

@ -36,9 +36,10 @@ typedef struct st_hash_info {
static uint hash_mask(uint hashnr,uint buffmax,uint maxlength); static uint hash_mask(uint hashnr,uint buffmax,uint maxlength);
static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink); static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink);
static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length); static int hashcmp(const HASH *hash, HASH_LINK *pos, const byte *key,
uint length);
static uint calc_hash(HASH *hash,const byte *key,uint length) static uint calc_hash(const HASH *hash, const byte *key, uint length)
{ {
ulong nr1=1, nr2=4; ulong nr1=1, nr2=4;
hash->charset->coll->hash_sort(hash->charset,(uchar*) key,length,&nr1,&nr2); hash->charset->coll->hash_sort(hash->charset,(uchar*) key,length,&nr1,&nr2);
@ -63,7 +64,6 @@ _hash_init(HASH *hash,CHARSET_INFO *charset,
hash->key_offset=key_offset; hash->key_offset=key_offset;
hash->key_length=key_length; hash->key_length=key_length;
hash->blength=1; hash->blength=1;
hash->current_record= NO_RECORD; /* For the future */
hash->get_key=get_key; hash->get_key=get_key;
hash->free=free_element; hash->free=free_element;
hash->flags=flags; hash->flags=flags;
@ -135,7 +135,6 @@ void my_hash_reset(HASH *hash)
reset_dynamic(&hash->array); reset_dynamic(&hash->array);
/* Set row pointers so that the hash can be reused at once */ /* Set row pointers so that the hash can be reused at once */
hash->blength= 1; hash->blength= 1;
hash->current_record= NO_RECORD;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -147,7 +146,8 @@ void my_hash_reset(HASH *hash)
*/ */
static inline char* static inline char*
hash_key(HASH *hash,const byte *record,uint *length,my_bool first) hash_key(const HASH *hash, const byte *record, uint *length,
my_bool first)
{ {
if (hash->get_key) if (hash->get_key)
return (*hash->get_key)(record,length,first); return (*hash->get_key)(record,length,first);
@ -163,8 +163,8 @@ static uint hash_mask(uint hashnr,uint buffmax,uint maxlength)
return (hashnr & ((buffmax >> 1) -1)); return (hashnr & ((buffmax >> 1) -1));
} }
static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax, static uint hash_rec_mask(const HASH *hash, HASH_LINK *pos,
uint maxlength) uint buffmax, uint maxlength)
{ {
uint length; uint length;
byte *key= (byte*) hash_key(hash,pos->data,&length,0); byte *key= (byte*) hash_key(hash,pos->data,&length,0);
@ -186,14 +186,25 @@ unsigned int rec_hashnr(HASH *hash,const byte *record)
} }
/* Search after a record based on a key */ gptr hash_search(const HASH *hash, const byte *key, uint length)
/* Sets info->current_ptr to found record */ {
HASH_SEARCH_STATE state;
return hash_first(hash, key, length, &state);
}
gptr hash_search(HASH *hash,const byte *key,uint length) /*
Search after a record based on a key
NOTE
Assigns the number of the found record to HASH_SEARCH_STATE state
*/
gptr hash_first(const HASH *hash, const byte *key, uint length,
HASH_SEARCH_STATE *current_record)
{ {
HASH_LINK *pos; HASH_LINK *pos;
uint flag,idx; uint flag,idx;
DBUG_ENTER("hash_search"); DBUG_ENTER("hash_first");
flag=1; flag=1;
if (hash->records) if (hash->records)
@ -206,7 +217,7 @@ gptr hash_search(HASH *hash,const byte *key,uint length)
if (!hashcmp(hash,pos,key,length)) if (!hashcmp(hash,pos,key,length))
{ {
DBUG_PRINT("exit",("found key at %d",idx)); DBUG_PRINT("exit",("found key at %d",idx));
hash->current_record= idx; *current_record= idx;
DBUG_RETURN (pos->data); DBUG_RETURN (pos->data);
} }
if (flag) if (flag)
@ -218,31 +229,32 @@ gptr hash_search(HASH *hash,const byte *key,uint length)
} }
while ((idx=pos->next) != NO_RECORD); while ((idx=pos->next) != NO_RECORD);
} }
hash->current_record= NO_RECORD; *current_record= NO_RECORD;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/* Get next record with identical key */ /* Get next record with identical key */
/* Can only be called if previous calls was hash_search */ /* Can only be called if previous calls was hash_search */
gptr hash_next(HASH *hash,const byte *key,uint length) gptr hash_next(const HASH *hash, const byte *key, uint length,
HASH_SEARCH_STATE *current_record)
{ {
HASH_LINK *pos; HASH_LINK *pos;
uint idx; uint idx;
if (hash->current_record != NO_RECORD) if (*current_record != NO_RECORD)
{ {
HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*); HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*);
for (idx=data[hash->current_record].next; idx != NO_RECORD ; idx=pos->next) for (idx=data[*current_record].next; idx != NO_RECORD ; idx=pos->next)
{ {
pos=data+idx; pos=data+idx;
if (!hashcmp(hash,pos,key,length)) if (!hashcmp(hash,pos,key,length))
{ {
hash->current_record= idx; *current_record= idx;
return pos->data; return pos->data;
} }
} }
hash->current_record=NO_RECORD; *current_record= NO_RECORD;
} }
return 0; return 0;
} }
@ -281,7 +293,8 @@ static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink)
!= 0 key of record != key != 0 key of record != key
*/ */
static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length) static int hashcmp(const HASH *hash, HASH_LINK *pos, const byte *key,
uint length)
{ {
uint rec_keylength; uint rec_keylength;
byte *rec_key= (byte*) hash_key(hash,pos->data,&rec_keylength,1); byte *rec_key= (byte*) hash_key(hash,pos->data,&rec_keylength,1);
@ -307,7 +320,6 @@ my_bool my_hash_insert(HASH *info,const byte *record)
if (!(empty=(HASH_LINK*) alloc_dynamic(&info->array))) if (!(empty=(HASH_LINK*) alloc_dynamic(&info->array)))
return(TRUE); /* No more memory */ return(TRUE); /* No more memory */
info->current_record= NO_RECORD;
data=dynamic_element(&info->array,0,HASH_LINK*); data=dynamic_element(&info->array,0,HASH_LINK*);
halfbuff= info->blength >> 1; halfbuff= info->blength >> 1;
@ -450,7 +462,6 @@ my_bool hash_delete(HASH *hash,byte *record)
} }
if ( --(hash->records) < hash->blength >> 1) hash->blength>>=1; if ( --(hash->records) < hash->blength >> 1) hash->blength>>=1;
hash->current_record= NO_RECORD;
lastpos=data+hash->records; lastpos=data+hash->records;
/* Remove link to record */ /* Remove link to record */
@ -543,7 +554,6 @@ my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length)
if ((idx=pos->next) == NO_RECORD) if ((idx=pos->next) == NO_RECORD)
DBUG_RETURN(1); /* Not found in links */ DBUG_RETURN(1); /* Not found in links */
} }
hash->current_record= NO_RECORD;
org_link= *pos; org_link= *pos;
empty=idx; empty=idx;
@ -593,10 +603,10 @@ byte *hash_element(HASH *hash,uint idx)
isn't changed isn't changed
*/ */
void hash_replace(HASH *hash, uint idx, byte *new_row) void hash_replace(HASH *hash, HASH_SEARCH_STATE *current_record, byte *new_row)
{ {
if (idx != NO_RECORD) /* Safety */ if (*current_record != NO_RECORD) /* Safety */
dynamic_element(&hash->array,idx,HASH_LINK*)->data=new_row; dynamic_element(&hash->array, *current_record, HASH_LINK*)->data= new_row;
} }

View File

@ -74,7 +74,7 @@ static int do_test()
bzero((char*) key1,sizeof(key1[0])*1000); bzero((char*) key1,sizeof(key1[0])*1000);
printf("- Creating hash\n"); printf("- Creating hash\n");
if (hash_init(&hash,recant/2,0,6,0,free_record,0)) if (hash_init(&hash, default_charset_info, recant/2, 0, 6, 0, free_record, 0))
goto err; goto err;
printf("- Writing records:\n"); printf("- Writing records:\n");
@ -172,15 +172,16 @@ static int do_test()
break; break;
if (key1[j] > 1) if (key1[j] > 1)
{ {
HASH_SEARCH_STATE state;
printf("- Testing identical read\n"); printf("- Testing identical read\n");
sprintf(key,"%6d",j); sprintf(key,"%6d",j);
pos=1; pos=1;
if (!(recpos=hash_search(&hash,key,0))) if (!(recpos= hash_first(&hash, key, 0, &state)))
{ {
printf("can't find key1: \"%s\"\n",key); printf("can't find key1: \"%s\"\n",key);
goto err; goto err;
} }
while (hash_next(&hash,key,0) && pos < (ulong) (key1[j]+10)) while (hash_next(&hash, key, 0, &state) && pos < (ulong) (key1[j]+10))
pos++; pos++;
if (pos != (ulong) key1[j]) if (pos != (ulong) key1[j])
{ {
@ -189,7 +190,7 @@ static int do_test()
} }
} }
printf("- Creating output heap-file 2\n"); printf("- Creating output heap-file 2\n");
if (hash_init(&hash2,hash.records,0,0,hash2_key,free_record,0)) if (hash_init(&hash2, default_charset_info, hash.records, 0, 0, hash2_key, free_record,0))
goto err; goto err;
printf("- Copying and removing records\n"); printf("- Copying and removing records\n");

View File

@ -447,7 +447,7 @@ All benchmarks takes the following options:
--create-options=# --create-options=#
Extra argument to all create statements. If you for example want to Extra argument to all create statements. If you for example want to
create all MySQL tables as BDB tables use: create all MySQL tables as BDB tables use:
--create-options=TYPE=BDB --create-options=ENGINE=BDB
--database (Default $opt_database) --database (Default $opt_database)
In which database the test tables are created. In which database the test tables are created.

View File

@ -174,29 +174,29 @@ sub new
# Some fixes that depends on the environment # Some fixes that depends on the environment
if (defined($main::opt_create_options) && if (defined($main::opt_create_options) &&
$main::opt_create_options =~ /type=heap/i) $main::opt_create_options =~ /engine=heap/i)
{ {
$limits{'working_blobs'} = 0; # HEAP tables can't handle BLOB's $limits{'working_blobs'} = 0; # HEAP tables can't handle BLOB's
} }
if (defined($main::opt_create_options) && if (defined($main::opt_create_options) &&
$main::opt_create_options =~ /type=innodb/i) $main::opt_create_options =~ /engine=innodb/i)
{ {
$self->{'transactions'} = 1; # Transactions enabled $self->{'transactions'} = 1; # Transactions enabled
} }
if (defined($main::opt_create_options) && if (defined($main::opt_create_options) &&
$main::opt_create_options =~ /type=ndb/i) $main::opt_create_options =~ /engine=ndb/i)
{ {
$self->{'transactions'} = 1; # Transactions enabled $self->{'transactions'} = 1; # Transactions enabled
$limits{'max_columns'} = 90; # Max number of columns in table $limits{'max_columns'} = 90; # Max number of columns in table
$limits{'max_tables'} = 32; # No comments $limits{'max_tables'} = 32; # No comments
} }
if (defined($main::opt_create_options) && if (defined($main::opt_create_options) &&
$main::opt_create_options =~ /type=bdb/i) $main::opt_create_options =~ /engine=bdb/i)
{ {
$self->{'transactions'} = 1; # Transactions enabled $self->{'transactions'} = 1; # Transactions enabled
} }
if (defined($main::opt_create_options) && if (defined($main::opt_create_options) &&
$main::opt_create_options =~ /type=gemini/i) $main::opt_create_options =~ /engine=gemini/i)
{ {
$limits{'working_blobs'} = 0; # Blobs not implemented yet $limits{'working_blobs'} = 0; # Blobs not implemented yet
$limits{'max_tables'} = 500; $limits{'max_tables'} = 500;

View File

@ -6209,8 +6209,8 @@ Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table)
This is done to ensure that ALTER TABLE will convert old VARCHAR fields This is done to ensure that ALTER TABLE will convert old VARCHAR fields
to now VARCHAR fields. to now VARCHAR fields.
*/ */
if (new_field= new Field_varstring(field_length, maybe_null(), if ((new_field= new Field_varstring(field_length, maybe_null(),
field_name, new_table, charset())) field_name, new_table, charset())))
{ {
/* /*
delayed_insert::get_local_table() needs a ptr copied from old table. delayed_insert::get_local_table() needs a ptr copied from old table.

View File

@ -2616,8 +2616,7 @@ int ha_federated::stash_remote_error()
{ {
DBUG_ENTER("ha_federated::stash_remote_error()"); DBUG_ENTER("ha_federated::stash_remote_error()");
remote_error_number= mysql_errno(mysql); remote_error_number= mysql_errno(mysql);
my_snprintf(remote_error_buf, sizeof(remote_error_buf), "%s", strmake(remote_error_buf, mysql_error(mysql), sizeof(remote_error_buf)-1);
mysql_error(mysql));
DBUG_RETURN(HA_FEDERATED_ERROR_WITH_REMOTE_SYSTEM); DBUG_RETURN(HA_FEDERATED_ERROR_WITH_REMOTE_SYSTEM);
} }

View File

@ -300,7 +300,8 @@ Thd_ndb::~Thd_ndb()
if (ndb) if (ndb)
{ {
#ifndef DBUG_OFF #ifndef DBUG_OFF
Ndb::Free_list_usage tmp; tmp.m_name= 0; Ndb::Free_list_usage tmp;
tmp.m_name= 0;
while (ndb->get_free_list_usage(&tmp)) while (ndb->get_free_list_usage(&tmp))
{ {
uint leaked= (uint) tmp.m_created - tmp.m_free; uint leaked= (uint) tmp.m_created - tmp.m_free;
@ -312,8 +313,8 @@ Thd_ndb::~Thd_ndb()
} }
#endif #endif
delete ndb; delete ndb;
}
ndb= NULL; ndb= NULL;
}
changed_tables.empty(); changed_tables.empty();
} }
@ -4903,7 +4904,8 @@ bool ndbcluster_end()
if (g_ndb) if (g_ndb)
{ {
#ifndef DBUG_OFF #ifndef DBUG_OFF
Ndb::Free_list_usage tmp; tmp.m_name= 0; Ndb::Free_list_usage tmp;
tmp.m_name= 0;
while (g_ndb->get_free_list_usage(&tmp)) while (g_ndb->get_free_list_usage(&tmp))
{ {
uint leaked= (uint) tmp.m_created - tmp.m_free; uint leaked= (uint) tmp.m_created - tmp.m_free;
@ -4915,9 +4917,8 @@ bool ndbcluster_end()
} }
#endif #endif
delete g_ndb; delete g_ndb;
}
g_ndb= NULL; g_ndb= NULL;
if (g_ndb_cluster_connection) }
delete g_ndb_cluster_connection; delete g_ndb_cluster_connection;
g_ndb_cluster_connection= NULL; g_ndb_cluster_connection= NULL;
@ -7463,7 +7464,8 @@ ndbcluster_show_status(THD* thd)
if (have_ndbcluster != SHOW_OPTION_YES) if (have_ndbcluster != SHOW_OPTION_YES)
{ {
my_message(ER_NOT_SUPPORTED_YET, my_message(ER_NOT_SUPPORTED_YET,
"Cannot call SHOW NDBCLUSTER STATUS because skip-ndbcluster is defined", "Cannot call SHOW NDBCLUSTER STATUS because skip-ndbcluster is "
"defined",
MYF(0)); MYF(0));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -7474,13 +7476,15 @@ ndbcluster_show_status(THD* thd)
field_list.push_back(new Item_return_int("free", 10,MYSQL_TYPE_LONG)); field_list.push_back(new Item_return_int("free", 10,MYSQL_TYPE_LONG));
field_list.push_back(new Item_return_int("sizeof", 10,MYSQL_TYPE_LONG)); field_list.push_back(new Item_return_int("sizeof", 10,MYSQL_TYPE_LONG));
if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (get_thd_ndb(thd) && get_thd_ndb(thd)->ndb) if (get_thd_ndb(thd) && get_thd_ndb(thd)->ndb)
{ {
Ndb* ndb= (get_thd_ndb(thd))->ndb; Ndb* ndb= (get_thd_ndb(thd))->ndb;
Ndb::Free_list_usage tmp; tmp.m_name= 0; Ndb::Free_list_usage tmp;
tmp.m_name= 0;
while (ndb->get_free_list_usage(&tmp)) while (ndb->get_free_list_usage(&tmp))
{ {
protocol->prepare_for_resend(); protocol->prepare_for_resend();

View File

@ -300,39 +300,56 @@ handler *get_new_handler(TABLE *table, MEM_ROOT *alloc, enum db_type db_type)
case DB_TYPE_HASH: case DB_TYPE_HASH:
return new (alloc) ha_hash(table); return new (alloc) ha_hash(table);
#endif #endif
case DB_TYPE_MRG_MYISAM:
case DB_TYPE_MRG_ISAM: case DB_TYPE_MRG_ISAM:
return new (alloc) ha_myisammrg(table); return new (alloc) ha_myisammrg(table);
#ifdef HAVE_BERKELEY_DB #ifdef HAVE_BERKELEY_DB
case DB_TYPE_BERKELEY_DB: case DB_TYPE_BERKELEY_DB:
if (have_berkeley_db == SHOW_OPTION_YES)
return new (alloc) ha_berkeley(table); return new (alloc) ha_berkeley(table);
return NULL;
#endif #endif
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
case DB_TYPE_INNODB: case DB_TYPE_INNODB:
if (have_innodb == SHOW_OPTION_YES)
return new (alloc) ha_innobase(table); return new (alloc) ha_innobase(table);
return NULL;
#endif #endif
#ifdef HAVE_EXAMPLE_DB #ifdef HAVE_EXAMPLE_DB
case DB_TYPE_EXAMPLE_DB: case DB_TYPE_EXAMPLE_DB:
if (have_example_db == SHOW_OPTION_YES)
return new (alloc) ha_example(table); return new (alloc) ha_example(table);
return NULL;
#endif #endif
#if defined(HAVE_ARCHIVE_DB) #if defined(HAVE_ARCHIVE_DB)
case DB_TYPE_ARCHIVE_DB: case DB_TYPE_ARCHIVE_DB:
if (have_archive_db == SHOW_OPTION_YES)
return new (alloc) ha_archive(table); return new (alloc) ha_archive(table);
return NULL;
#endif #endif
#ifdef HAVE_BLACKHOLE_DB #ifdef HAVE_BLACKHOLE_DB
case DB_TYPE_BLACKHOLE_DB: case DB_TYPE_BLACKHOLE_DB:
if (have_blackhole_db == SHOW_OPTION_YES)
return new (alloc) ha_blackhole(table); return new (alloc) ha_blackhole(table);
return NULL;
#endif #endif
#ifdef HAVE_FEDERATED_DB #ifdef HAVE_FEDERATED_DB
case DB_TYPE_FEDERATED_DB: case DB_TYPE_FEDERATED_DB:
if (have_federated_db == SHOW_OPTION_YES)
return new (alloc) ha_federated(table); return new (alloc) ha_federated(table);
return NULL;
#endif #endif
#ifdef HAVE_CSV_DB #ifdef HAVE_CSV_DB
case DB_TYPE_CSV_DB: case DB_TYPE_CSV_DB:
if (have_csv_db == SHOW_OPTION_YES)
return new (alloc) ha_tina(table); return new (alloc) ha_tina(table);
return NULL;
#endif #endif
#ifdef HAVE_NDBCLUSTER_DB #ifdef HAVE_NDBCLUSTER_DB
case DB_TYPE_NDBCLUSTER: case DB_TYPE_NDBCLUSTER:
if (have_ndbcluster == SHOW_OPTION_YES)
return new (alloc) ha_ndbcluster(table); return new (alloc) ha_ndbcluster(table);
return NULL;
#endif #endif
case DB_TYPE_HEAP: case DB_TYPE_HEAP:
return new (alloc) ha_heap(table); return new (alloc) ha_heap(table);
@ -346,8 +363,6 @@ handler *get_new_handler(TABLE *table, MEM_ROOT *alloc, enum db_type db_type)
/* Fall back to MyISAM */ /* Fall back to MyISAM */
case DB_TYPE_MYISAM: case DB_TYPE_MYISAM:
return new (alloc) ha_myisam(table); return new (alloc) ha_myisam(table);
case DB_TYPE_MRG_MYISAM:
return new (alloc) ha_myisammrg(table);
} }
} }

View File

@ -4890,6 +4890,12 @@ int Item_ref::save_in_field(Field *to, bool no_conversions)
} }
void Item_ref::save_org_in_field(Field *field)
{
(*ref)->save_org_in_field(field);
}
void Item_ref::make_field(Send_field *field) void Item_ref::make_field(Send_field *field)
{ {
(*ref)->make_field(field); (*ref)->make_field(field);

View File

@ -1745,11 +1745,7 @@ public:
void make_field(Send_field *field); void make_field(Send_field *field);
bool fix_fields(THD *, Item **); bool fix_fields(THD *, Item **);
int save_in_field(Field *field, bool no_conversions); int save_in_field(Field *field, bool no_conversions);
void save_org_in_field(Field *field) void save_org_in_field(Field *field);
{
(*ref)->save_org_in_field(field);
null_value= (*ref)->null_value;
}
enum Item_result result_type () const { return (*ref)->result_type(); } enum Item_result result_type () const { return (*ref)->result_type(); }
enum_field_types field_type() const { return (*ref)->field_type(); } enum_field_types field_type() const { return (*ref)->field_type(); }
Field *get_tmp_table_field() Field *get_tmp_table_field()

View File

@ -723,6 +723,7 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
char key[MAX_DBKEY_LENGTH]; char key[MAX_DBKEY_LENGTH];
char *db= table_list->db; char *db= table_list->db;
uint key_length; uint key_length;
HASH_SEARCH_STATE state;
DBUG_ENTER("lock_table_name"); DBUG_ENTER("lock_table_name");
DBUG_PRINT("enter",("db: %s name: %s", db, table_list->table_name)); DBUG_PRINT("enter",("db: %s name: %s", db, table_list->table_name));
@ -733,9 +734,9 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
/* Only insert the table if we haven't insert it already */ /* Only insert the table if we haven't insert it already */
for (table=(TABLE*) hash_search(&open_cache,(byte*) key,key_length) ; for (table=(TABLE*) hash_first(&open_cache, (byte*)key, key_length, &state);
table ; table ;
table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length)) table = (TABLE*) hash_next(&open_cache, (byte*)key, key_length, &state))
if (table->in_use == thd) if (table->in_use == thd)
DBUG_RETURN(0); DBUG_RETURN(0);

View File

@ -114,13 +114,24 @@ static char *pretty_print_str(char *packet, char *str, int len)
/* /*
Creates a temporary name for load data infile:
SYNOPSIS
slave_load_file_stem() slave_load_file_stem()
buf Store new filename here
file_id File_id (part of file name)
event_server_id Event_id (part of file name)
ext Extension for file name
RETURN
Pointer to start of extension
*/ */
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
static inline char* slave_load_file_stem(char*buf, uint file_id, static char *slave_load_file_stem(char *buf, uint file_id,
int event_server_id) int event_server_id, const char *ext)
{ {
char *res;
fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", MY_UNPACK_FILENAME); fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", MY_UNPACK_FILENAME);
to_unix_path(buf); to_unix_path(buf);
@ -129,7 +140,9 @@ static inline char* slave_load_file_stem(char*buf, uint file_id,
*buf++ = '-'; *buf++ = '-';
buf = int10_to_str(event_server_id, buf, 10); buf = int10_to_str(event_server_id, buf, 10);
*buf++ = '-'; *buf++ = '-';
return int10_to_str(file_id, buf, 10); res= int10_to_str(file_id, buf, 10);
strmov(res, ext); // Add extension last
return res; // Pointer to extension
} }
#endif #endif
@ -901,7 +914,6 @@ void Log_event::print_header(FILE* file, PRINT_EVENT_INFO* print_event_info)
/* Pretty-print event common header if header is exactly 19 bytes */ /* Pretty-print event common header if header is exactly 19 bytes */
if (print_event_info->common_header_len == LOG_EVENT_MINIMAL_HEADER_LEN) if (print_event_info->common_header_len == LOG_EVENT_MINIMAL_HEADER_LEN)
{ {
DBUG_ASSERT(hexdump_from == (unsigned long) hexdump_from);
fprintf(file, "# Position Timestamp Type Master ID " fprintf(file, "# Position Timestamp Type Master ID "
"Size Master Pos Flags \n"); "Size Master Pos Flags \n");
fprintf(file, "# %8.8lx %02x %02x %02x %02x %02x " fprintf(file, "# %8.8lx %02x %02x %02x %02x %02x "
@ -927,7 +939,6 @@ void Log_event::print_header(FILE* file, PRINT_EVENT_INFO* print_event_info)
if (i % 16 == 15) if (i % 16 == 15)
{ {
DBUG_ASSERT(hexdump_from == (unsigned long) hexdump_from);
fprintf(file, "# %8.8lx %-48.48s |%16s|\n", fprintf(file, "# %8.8lx %-48.48s |%16s|\n",
(unsigned long) (hexdump_from + (i & 0xfffffff0)), (unsigned long) (hexdump_from + (i & 0xfffffff0)),
hex_string, char_string); hex_string, char_string);
@ -941,13 +952,11 @@ void Log_event::print_header(FILE* file, PRINT_EVENT_INFO* print_event_info)
*c= '\0'; *c= '\0';
/* Non-full last line */ /* Non-full last line */
if (hex_string[0]) { if (hex_string[0])
DBUG_ASSERT(hexdump_from == (unsigned long) hexdump_from);
fprintf(file, "# %8.8lx %-48.48s |%s|\n# ", fprintf(file, "# %8.8lx %-48.48s |%s|\n# ",
(unsigned long) (hexdump_from + (i & 0xfffffff0)), (unsigned long) (hexdump_from + (i & 0xfffffff0)),
hex_string, char_string); hex_string, char_string);
} }
}
} }
@ -4164,16 +4173,15 @@ void Create_file_log_event::pack_info(Protocol *protocol)
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Create_file_log_event::exec_event(struct st_relay_log_info* rli) int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
{ {
char proc_info[17+FN_REFLEN+10], *fname_buf= proc_info+17; char proc_info[17+FN_REFLEN+10], *fname_buf;
char *p; char *ext;
int fd = -1; int fd = -1;
IO_CACHE file; IO_CACHE file;
int error = 1; int error = 1;
bzero((char*)&file, sizeof(file)); bzero((char*)&file, sizeof(file));
p = slave_load_file_stem(fname_buf, file_id, server_id); fname_buf= strmov(proc_info, "Making temp file ");
strmov(p, ".info"); // strmov takes less code than memcpy ext= slave_load_file_stem(fname_buf, file_id, server_id, ".info");
strnmov(proc_info, STRING_WITH_LEN("Making temp file ")); // no end 0
thd->proc_info= proc_info; thd->proc_info= proc_info;
my_delete(fname_buf, MYF(0)); // old copy may exist already my_delete(fname_buf, MYF(0)); // old copy may exist already
if ((fd= my_create(fname_buf, CREATE_MODE, if ((fd= my_create(fname_buf, CREATE_MODE,
@ -4182,19 +4190,21 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0, init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0,
MYF(MY_WME|MY_NABP))) MYF(MY_WME|MY_NABP)))
{ {
slave_print_error(rli,my_errno, "Error in Create_file event: could not open file '%s'", fname_buf); slave_print_error(rli,my_errno,
"Error in Create_file event: could not open file '%s'",
fname_buf);
goto err; goto err;
} }
// a trick to avoid allocating another buffer // a trick to avoid allocating another buffer
strmov(p, ".data"); fname= fname_buf;
fname = fname_buf; fname_len= (uint) (strmov(ext, ".data") - fname);
fname_len = (uint)(p-fname) + 5;
if (write_base(&file)) if (write_base(&file))
{ {
strmov(p, ".info"); // to have it right in the error message strmov(ext, ".info"); // to have it right in the error message
slave_print_error(rli,my_errno, slave_print_error(rli,my_errno,
"Error in Create_file event: could not write to file '%s'", "Error in Create_file event: could not write to file "
"'%s'",
fname_buf); fname_buf);
goto err; goto err;
} }
@ -4207,12 +4217,16 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
{ {
slave_print_error(rli,my_errno, "Error in Create_file event: could not open file '%s'", fname_buf); slave_print_error(rli,my_errno,
"Error in Create_file event: could not open file '%s'",
fname_buf);
goto err; goto err;
} }
if (my_write(fd, (byte*) block, block_len, MYF(MY_WME+MY_NABP))) if (my_write(fd, (byte*) block, block_len, MYF(MY_WME+MY_NABP)))
{ {
slave_print_error(rli,my_errno, "Error in Create_file event: write to '%s' failed", fname_buf); slave_print_error(rli,my_errno,
"Error in Create_file event: write to '%s' failed",
fname_buf);
goto err; goto err;
} }
error=0; // Everything is ok error=0; // Everything is ok
@ -4336,13 +4350,12 @@ int Append_block_log_event::get_create_or_append() const
int Append_block_log_event::exec_event(struct st_relay_log_info* rli) int Append_block_log_event::exec_event(struct st_relay_log_info* rli)
{ {
char proc_info[17+FN_REFLEN+10], *fname= proc_info+17; char proc_info[17+FN_REFLEN+10], *fname= proc_info+17;
char *p= slave_load_file_stem(fname, file_id, server_id);
int fd; int fd;
int error = 1; int error = 1;
DBUG_ENTER("Append_block_log_event::exec_event"); DBUG_ENTER("Append_block_log_event::exec_event");
memcpy(p, ".data", 6); fname= strmov(proc_info, "Making temp file ");
strnmov(proc_info, STRING_WITH_LEN("Making temp file ")); // no end 0 slave_load_file_stem(fname, file_id, server_id, ".data");
thd->proc_info= proc_info; thd->proc_info= proc_info;
if (get_create_or_append()) if (get_create_or_append())
{ {
@ -4468,10 +4481,9 @@ void Delete_file_log_event::pack_info(Protocol *protocol)
int Delete_file_log_event::exec_event(struct st_relay_log_info* rli) int Delete_file_log_event::exec_event(struct st_relay_log_info* rli)
{ {
char fname[FN_REFLEN+10]; char fname[FN_REFLEN+10];
char *p= slave_load_file_stem(fname, file_id, server_id); char *ext= slave_load_file_stem(fname, file_id, server_id, ".data");
memcpy(p, ".data", 6);
(void) my_delete(fname, MYF(MY_WME)); (void) my_delete(fname, MYF(MY_WME));
memcpy(p, ".info", 6); strmov(ext, ".info");
(void) my_delete(fname, MYF(MY_WME)); (void) my_delete(fname, MYF(MY_WME));
return Log_event::exec_event(rli); return Log_event::exec_event(rli);
} }
@ -4564,19 +4576,21 @@ void Execute_load_log_event::pack_info(Protocol *protocol)
int Execute_load_log_event::exec_event(struct st_relay_log_info* rli) int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
{ {
char fname[FN_REFLEN+10]; char fname[FN_REFLEN+10];
char *p= slave_load_file_stem(fname, file_id, server_id); char *ext;
int fd; int fd;
int error = 1; int error= 1;
IO_CACHE file; IO_CACHE file;
Load_log_event* lev = 0; Load_log_event *lev= 0;
memcpy(p, ".info", 6); ext= slave_load_file_stem(fname, file_id, server_id, ".info");
if ((fd = my_open(fname, O_RDONLY | O_BINARY | O_NOFOLLOW, if ((fd = my_open(fname, O_RDONLY | O_BINARY | O_NOFOLLOW,
MYF(MY_WME))) < 0 || MYF(MY_WME))) < 0 ||
init_io_cache(&file, fd, IO_SIZE, READ_CACHE, (my_off_t)0, 0, init_io_cache(&file, fd, IO_SIZE, READ_CACHE, (my_off_t)0, 0,
MYF(MY_WME|MY_NABP))) MYF(MY_WME|MY_NABP)))
{ {
slave_print_error(rli,my_errno, "Error in Exec_load event: could not open file '%s'", fname); slave_print_error(rli,my_errno,
"Error in Exec_load event: could not open file '%s'",
fname);
goto err; goto err;
} }
if (!(lev = (Load_log_event*)Log_event::read_log_event(&file, if (!(lev = (Load_log_event*)Log_event::read_log_event(&file,
@ -4584,7 +4598,9 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
rli->relay_log.description_event_for_exec)) || rli->relay_log.description_event_for_exec)) ||
lev->get_type_code() != NEW_LOAD_EVENT) lev->get_type_code() != NEW_LOAD_EVENT)
{ {
slave_print_error(rli,0, "Error in Exec_load event: file '%s' appears corrupted", fname); slave_print_error(rli,0,
"Error in Exec_load event: file '%s' appears corrupted",
fname);
goto err; goto err;
} }
@ -4629,7 +4645,7 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
fd= -1; fd= -1;
} }
(void) my_delete(fname, MYF(MY_WME)); (void) my_delete(fname, MYF(MY_WME));
memcpy(p, ".data", 6); memcpy(ext, ".data", 6);
(void) my_delete(fname, MYF(MY_WME)); (void) my_delete(fname, MYF(MY_WME));
error = 0; error = 0;
@ -4827,11 +4843,10 @@ Execute_load_query_log_event::exec_event(struct st_relay_log_info* rli)
memcpy(p, query, fn_pos_start); memcpy(p, query, fn_pos_start);
p+= fn_pos_start; p+= fn_pos_start;
fname= (p= strmake(p, STRING_WITH_LEN(" INFILE \'"))); fname= (p= strmake(p, STRING_WITH_LEN(" INFILE \'")));
p= slave_load_file_stem(p, file_id, server_id); p= slave_load_file_stem(p, file_id, server_id, ".data");
fname_end= (p= strmake(p, STRING_WITH_LEN(".data"))); fname_end= p= strend(p); // Safer than p=p+5
*(p++)='\''; *(p++)='\'';
switch (dup_handling) switch (dup_handling) {
{
case LOAD_DUP_IGNORE: case LOAD_DUP_IGNORE:
p= strmake(p, STRING_WITH_LEN(" IGNORE")); p= strmake(p, STRING_WITH_LEN(" IGNORE"));
break; break;

View File

@ -1401,7 +1401,7 @@ static void network_init(void)
{ {
if (((ret= bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr), if (((ret= bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr),
sizeof(IPaddr))) >= 0) || sizeof(IPaddr))) >= 0) ||
(socket_errno != EADDRINUSE) || (socket_errno != SOCKET_EADDRINUSE) ||
(waited >= mysqld_port_timeout)) (waited >= mysqld_port_timeout))
break; break;
sql_print_information("Retrying bind on TCP/IP port %u", mysqld_port); sql_print_information("Retrying bind on TCP/IP port %u", mysqld_port);
@ -1613,7 +1613,7 @@ void end_thread(THD *thd, bool put_in_cache)
wake_thread--; wake_thread--;
thd=thread_cache.get(); thd=thread_cache.get();
thd->real_id=pthread_self(); thd->real_id=pthread_self();
thd->thread_stack= (char *) &thd; thd->thread_stack= (char*) &thd; // For store_globals
(void) thd->store_globals(); (void) thd->store_globals();
thd->thr_create_time= time(NULL); thd->thr_create_time= time(NULL);
threads.append(thd); threads.append(thd);

View File

@ -5737,6 +5737,7 @@ bool QUICK_ROR_UNION_SELECT::check_if_keys_used(List<Item> *fields)
/* /*
Create quick select from ref/ref_or_null scan. Create quick select from ref/ref_or_null scan.
SYNOPSIS SYNOPSIS
get_quick_select_for_ref() get_quick_select_for_ref()
thd Thread handle thd Thread handle
@ -5756,15 +5757,18 @@ bool QUICK_ROR_UNION_SELECT::check_if_keys_used(List<Item> *fields)
QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
TABLE_REF *ref, ha_rows records) TABLE_REF *ref, ha_rows records)
{ {
MEM_ROOT *old_root= thd->mem_root; MEM_ROOT *old_root, *alloc;
/* The following call may change thd->mem_root */ QUICK_RANGE_SELECT *quick;
QUICK_RANGE_SELECT *quick= new QUICK_RANGE_SELECT(thd, table, ref->key, 0);
/* save mem_root set by QUICK_RANGE_SELECT constructor */
MEM_ROOT *alloc= thd->mem_root;
KEY *key_info = &table->key_info[ref->key]; KEY *key_info = &table->key_info[ref->key];
KEY_PART *key_part; KEY_PART *key_part;
QUICK_RANGE *range; QUICK_RANGE *range;
uint part; uint part;
old_root= thd->mem_root;
/* The following call may change thd->mem_root */
quick= new QUICK_RANGE_SELECT(thd, table, ref->key, 0);
/* save mem_root set by QUICK_RANGE_SELECT constructor */
alloc= thd->mem_root;
/* /*
return back default mem_root (thd->mem_root) changed by return back default mem_root (thd->mem_root) changed by
QUICK_RANGE_SELECT constructor QUICK_RANGE_SELECT constructor

View File

@ -944,6 +944,6 @@ File_parser_dummy_hook::process_unknown_string(char *&unknown_key,
char *end) char *end)
{ {
DBUG_ENTER("file_parser_dummy_hook::process_unknown_string"); DBUG_ENTER("file_parser_dummy_hook::process_unknown_string");
DBUG_PRINT("info", ("unknown key:%60s", unknown_key)); DBUG_PRINT("info", ("Unknown key: '%60s'", unknown_key));
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }

View File

@ -399,14 +399,14 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
const char *body, st_sp_chistics &chistics, const char *body, st_sp_chistics &chistics,
const char *definer, longlong created, longlong modified) const char *definer, longlong created, longlong modified)
{ {
LEX *oldlex= thd->lex, newlex; LEX *old_lex= thd->lex, newlex;
sp_rcontext *save_spcont= thd->spcont;
String defstr; String defstr;
char olddb[128]; char olddb[128];
bool dbchanged; bool dbchanged;
ulong old_sql_mode= thd->variables.sql_mode; ulong old_sql_mode= thd->variables.sql_mode;
ha_rows select_limit= thd->variables.select_limit; ha_rows old_select_limit= thd->variables.select_limit;
int ret= SP_INTERNAL_ERROR; sp_rcontext *old_spcont= thd->spcont;
int ret;
thd->variables.sql_mode= sql_mode; thd->variables.sql_mode= sql_mode;
thd->variables.select_limit= HA_POS_ERROR; thd->variables.select_limit= HA_POS_ERROR;
@ -422,7 +422,10 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
returns, strlen(returns), returns, strlen(returns),
body, strlen(body), body, strlen(body),
&chistics)) &chistics))
{
ret= SP_INTERNAL_ERROR;
goto end; goto end;
}
dbchanged= FALSE; dbchanged= FALSE;
if ((ret= sp_use_new_db(thd, name->m_db.str, olddb, sizeof(olddb), if ((ret= sp_use_new_db(thd, name->m_db.str, olddb, sizeof(olddb),
@ -451,10 +454,10 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
(*sphp)->optimize(); (*sphp)->optimize();
} }
end: end:
thd->spcont= save_spcont; thd->spcont= old_spcont;
thd->variables.sql_mode= old_sql_mode; thd->variables.sql_mode= old_sql_mode;
thd->variables.select_limit= select_limit; thd->variables.select_limit= old_select_limit;
thd->lex= oldlex; thd->lex= old_lex;
return ret; return ret;
} }
@ -926,7 +929,6 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp,
ulong depth= (type == TYPE_ENUM_PROCEDURE ? ulong depth= (type == TYPE_ENUM_PROCEDURE ?
thd->variables.max_sp_recursion_depth : thd->variables.max_sp_recursion_depth :
0); 0);
DBUG_ENTER("sp_find_routine"); DBUG_ENTER("sp_find_routine");
DBUG_PRINT("enter", ("name: %.*s.%.*s, type: %d, cache only %d", DBUG_PRINT("enter", ("name: %.*s.%.*s, type: %d, cache only %d",
name->m_db.length, name->m_db.str, name->m_db.length, name->m_db.str,
@ -936,6 +938,11 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp,
if ((sp= sp_cache_lookup(cp, name))) if ((sp= sp_cache_lookup(cp, name)))
{ {
ulong level; ulong level;
sp_head *new_sp;
const char *returns= "";
char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2];
String retstr(64);
DBUG_PRINT("info", ("found: 0x%lx", (ulong)sp)); DBUG_PRINT("info", ("found: 0x%lx", (ulong)sp));
if (sp->m_first_free_instance) if (sp->m_first_free_instance)
{ {
@ -946,7 +953,7 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp,
DBUG_ASSERT(!(sp->m_first_free_instance->m_flags & sp_head::IS_INVOKED)); DBUG_ASSERT(!(sp->m_first_free_instance->m_flags & sp_head::IS_INVOKED));
if (sp->m_first_free_instance->m_recursion_level > depth) if (sp->m_first_free_instance->m_recursion_level > depth)
{ {
sp->recursion_level_error(); sp->recursion_level_error(thd);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
DBUG_RETURN(sp->m_first_free_instance); DBUG_RETURN(sp->m_first_free_instance);
@ -954,14 +961,10 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp,
level= sp->m_last_cached_sp->m_recursion_level + 1; level= sp->m_last_cached_sp->m_recursion_level + 1;
if (level > depth) if (level > depth)
{ {
sp->recursion_level_error(); sp->recursion_level_error(thd);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
{
sp_head *new_sp;
const char *returns= "";
char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2];
String retstr(64);
strxmov(definer, sp->m_definer_user.str, "@", strxmov(definer, sp->m_definer_user.str, "@",
sp->m_definer_host.str, NullS); sp->m_definer_host.str, NullS);
if (type == TYPE_ENUM_FUNCTION) if (type == TYPE_ENUM_FUNCTION)
@ -985,7 +988,6 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp,
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
}
if (!cache_only) if (!cache_only)
{ {
if (db_find_routine(thd, type, name, &sp) == SP_OK) if (db_find_routine(thd, type, name, &sp) == SP_OK)

View File

@ -24,6 +24,13 @@
#include "sp_rcontext.h" #include "sp_rcontext.h"
#include "sp_cache.h" #include "sp_cache.h"
/*
Sufficient max length of printed destinations and frame offsets (all uints).
*/
#define SP_INSTR_UINT_MAXLEN 8
#define SP_STMT_PRINT_MAXLEN 40
Item_result Item_result
sp_map_result_type(enum enum_field_types type) sp_map_result_type(enum enum_field_types type)
{ {
@ -867,17 +874,17 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
SYNOPSIS SYNOPSIS
sp_head::recursion_level_error() sp_head::recursion_level_error()
thd Thread handle
NOTE NOTE
For functions and triggers we return error about prohibited recursion. For functions and triggers we return error about prohibited recursion.
For stored procedures we return about reaching recursion limit. For stored procedures we return about reaching recursion limit.
*/ */
void sp_head::recursion_level_error() void sp_head::recursion_level_error(THD *thd)
{ {
if (m_type == TYPE_ENUM_PROCEDURE) if (m_type == TYPE_ENUM_PROCEDURE)
{ {
THD *thd= current_thd;
my_error(ER_SP_RECURSION_LIMIT, MYF(0), my_error(ER_SP_RECURSION_LIMIT, MYF(0),
thd->variables.max_sp_recursion_depth, thd->variables.max_sp_recursion_depth,
m_name.str); m_name.str);
@ -928,14 +935,15 @@ sp_head::execute(THD *thd)
DBUG_ASSERT(!(m_flags & IS_INVOKED)); DBUG_ASSERT(!(m_flags & IS_INVOKED));
m_flags|= IS_INVOKED; m_flags|= IS_INVOKED;
m_first_instance->m_first_free_instance= m_next_cached_sp; m_first_instance->m_first_free_instance= m_next_cached_sp;
DBUG_PRINT("info", ("first free for 0x%lx ++: 0x%lx->0x%lx, level: %lu, flags %x", if (m_next_cached_sp)
(ulong)m_first_instance, this, m_next_cached_sp, {
(m_next_cached_sp ? DBUG_PRINT("info",
m_next_cached_sp->m_recursion_level : ("first free for 0x%lx ++: 0x%lx->0x%lx level: %lu flags %x",
0), (ulong)m_first_instance, (ulong) this,
(m_next_cached_sp ? (ulong) m_next_cached_sp,
m_next_cached_sp->m_flags : m_next_cached_sp->m_recursion_level,
0))); m_next_cached_sp->m_flags));
}
/* /*
Check that if there are not any instances after this one then Check that if there are not any instances after this one then
pointer to the last instance points on this instance or if there are pointer to the last instance points on this instance or if there are
@ -1103,13 +1111,15 @@ sp_head::execute(THD *thd)
state= EXECUTED; state= EXECUTED;
done: done:
DBUG_PRINT("info", ("err_status=%d killed=%d query_error=%d", DBUG_PRINT("info", ("err_status: %d killed: %d query_error: %d",
err_status, thd->killed, thd->query_error)); err_status, thd->killed, thd->query_error));
if (thd->killed) if (thd->killed)
err_status= TRUE; err_status= TRUE;
/* If the DB has changed, the pointer has changed too, but the /*
original thd->db will then have been freed */ If the DB has changed, the pointer has changed too, but the
original thd->db will then have been freed
*/
if (dbchanged) if (dbchanged)
{ {
/* /*
@ -1120,10 +1130,11 @@ sp_head::execute(THD *thd)
err_status|= mysql_change_db(thd, olddb, 1); err_status|= mysql_change_db(thd, olddb, 1);
} }
m_flags&= ~IS_INVOKED; m_flags&= ~IS_INVOKED;
DBUG_PRINT("info", ("first free for 0x%lx --: 0x%lx->0x%lx, level: %lu, flags %x", DBUG_PRINT("info",
(ulong)m_first_instance, ("first free for 0x%lx --: 0x%lx->0x%lx, level: %lu, flags %x",
m_first_instance->m_first_free_instance, this, (ulong) m_first_instance,
m_recursion_level, m_flags)); (ulong) m_first_instance->m_first_free_instance,
(ulong) this, m_recursion_level, m_flags));
/* /*
Check that we have one of following: Check that we have one of following:
@ -1133,7 +1144,7 @@ sp_head::execute(THD *thd)
2) There are some free instances which mean that first free instance 2) There are some free instances which mean that first free instance
should go just after this one and recursion level of that free instance should go just after this one and recursion level of that free instance
should be on 1 more then recursion leven of this instance. should be on 1 more then recursion level of this instance.
*/ */
DBUG_ASSERT((m_first_instance->m_first_free_instance == 0 && DBUG_ASSERT((m_first_instance->m_first_free_instance == 0 &&
this == m_first_instance->m_last_cached_sp && this == m_first_instance->m_last_cached_sp &&
@ -1741,16 +1752,16 @@ sp_head::set_info(longlong created, longlong modified,
void void
sp_head::set_definer(char *definer, uint definerlen)
sp_head::set_definer(const char *definer, uint definerlen)
{ {
char *p= strrchr(definer, '@'); const char *p= strrchr(definer, '@');
if (!p) if (!p)
{ {
m_definer_user.str= strmake_root(mem_root, "", 0); m_definer_user.str= (char*) "";
m_definer_user.length= 0; m_definer_user.length= 0;
m_definer_host.str= (char*) "";
m_definer_host.str= strmake_root(mem_root, "", 0);
m_definer_host.length= 0; m_definer_host.length= 0;
} }
else else
@ -1845,9 +1856,9 @@ sp_head::show_create_procedure(THD *thd)
byte *sql_mode_str; byte *sql_mode_str;
ulong sql_mode_len; ulong sql_mode_len;
bool full_access; bool full_access;
DBUG_ENTER("sp_head::show_create_procedure"); DBUG_ENTER("sp_head::show_create_procedure");
DBUG_PRINT("info", ("procedure %s", m_name.str)); DBUG_PRINT("info", ("procedure %s", m_name.str));
LINT_INIT(sql_mode_str); LINT_INIT(sql_mode_str);
LINT_INIT(sql_mode_len); LINT_INIT(sql_mode_len);
@ -2200,12 +2211,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
DBUG_RETURN(res); DBUG_RETURN(res);
} }
/*
Sufficient max length of printed destinations and frame offsets (all uints).
*/
#define SP_INSTR_UINT_MAXLEN 8
#define SP_STMT_PRINT_MAXLEN 40
void void
sp_instr_stmt::print(String *str) sp_instr_stmt::print(String *str)
{ {
@ -2227,16 +2233,16 @@ sp_instr_stmt::print(String *str)
/* Copy the query string and replace '\n' with ' ' in the process */ /* Copy the query string and replace '\n' with ' ' in the process */
for (i= 0 ; i < len ; i++) for (i= 0 ; i < len ; i++)
{ {
if (m_query.str[i] == '\n') char c= m_query.str[i];
str->qs_append(' '); if (c == '\n')
else c= ' ';
str->qs_append(m_query.str[i]); str->qs_append(c);
} }
if (m_query.length > SP_STMT_PRINT_MAXLEN) if (m_query.length > SP_STMT_PRINT_MAXLEN)
str->qs_append(STRING_WITH_LEN("...")); /* Indicate truncated string */ str->qs_append(STRING_WITH_LEN("...")); /* Indicate truncated string */
str->qs_append('"'); str->qs_append('"');
} }
#undef SP_STMT_PRINT_MAXLEN
int int
sp_instr_stmt::exec_core(THD *thd, uint *nextp) sp_instr_stmt::exec_core(THD *thd, uint *nextp)
@ -2602,6 +2608,7 @@ sp_instr_hpush_jump::execute(THD *thd, uint *nextp)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
void void
sp_instr_hpush_jump::print(String *str) sp_instr_hpush_jump::print(String *str)
{ {
@ -2612,8 +2619,7 @@ sp_instr_hpush_jump::print(String *str)
str->qs_append(m_dest); str->qs_append(m_dest);
str->qs_append(' '); str->qs_append(' ');
str->qs_append(m_frame); str->qs_append(m_frame);
switch (m_type) switch (m_type) {
{
case SP_HANDLER_NONE: case SP_HANDLER_NONE:
str->qs_append(STRING_WITH_LEN(" NONE")); // This would be a bug str->qs_append(STRING_WITH_LEN(" NONE")); // This would be a bug
break; break;
@ -2627,11 +2633,13 @@ sp_instr_hpush_jump::print(String *str)
str->qs_append(STRING_WITH_LEN(" UNDO")); str->qs_append(STRING_WITH_LEN(" UNDO"));
break; break;
default: default:
str->qs_append(STRING_WITH_LEN(" UNKNOWN:")); // This would be a bug as well // This would be a bug as well
str->qs_append(STRING_WITH_LEN(" UNKNOWN:"));
str->qs_append(m_type); str->qs_append(m_type);
} }
} }
uint uint
sp_instr_hpush_jump::opt_mark(sp_head *sp) sp_instr_hpush_jump::opt_mark(sp_head *sp)
{ {

View File

@ -285,7 +285,7 @@ public:
void set_info(longlong created, longlong modified, void set_info(longlong created, longlong modified,
st_sp_chistics *chistics, ulong sql_mode); st_sp_chistics *chistics, ulong sql_mode);
void set_definer(char *definer, uint definerlen); void set_definer(const char *definer, uint definerlen);
void reset_thd_mem_root(THD *thd); void reset_thd_mem_root(THD *thd);
@ -294,7 +294,7 @@ public:
void optimize(); void optimize();
void opt_mark(uint ip); void opt_mark(uint ip);
void recursion_level_error(); void recursion_level_error(THD *thd);
inline sp_instr * inline sp_instr *
get_instr(uint i) get_instr(uint i)

View File

@ -2244,14 +2244,14 @@ static GRANT_NAME *name_hash_search(HASH *name_hash,
char helping [NAME_LEN*2+USERNAME_LENGTH+3]; char helping [NAME_LEN*2+USERNAME_LENGTH+3];
uint len; uint len;
GRANT_NAME *grant_name,*found=0; GRANT_NAME *grant_name,*found=0;
HASH_SEARCH_STATE state;
len = (uint) (strmov(strmov(strmov(helping,user)+1,db)+1,tname)-helping)+ 1; len = (uint) (strmov(strmov(strmov(helping,user)+1,db)+1,tname)-helping)+ 1;
for (grant_name=(GRANT_NAME*) hash_search(name_hash, for (grant_name= (GRANT_NAME*) hash_first(name_hash, (byte*) helping,
(byte*) helping, len, &state);
len) ;
grant_name ; grant_name ;
grant_name= (GRANT_NAME*) hash_next(name_hash,(byte*) helping, grant_name= (GRANT_NAME*) hash_next(name_hash,(byte*) helping,
len)) len, &state))
{ {
if (exact) if (exact)
{ {
@ -3553,7 +3553,7 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
of other queries). For simple queries first_not_own_table is 0. of other queries). For simple queries first_not_own_table is 0.
*/ */
for (i= 0, table= tables; for (i= 0, table= tables;
table && table != first_not_own_table && i < number; table != first_not_own_table && i < number;
table= table->next_global, i++) table= table->next_global, i++)
{ {
/* Remove SHOW_VIEW_ACL, because it will be checked during making view */ /* Remove SHOW_VIEW_ACL, because it will be checked during making view */

View File

@ -1085,6 +1085,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
char key[MAX_DBKEY_LENGTH]; char key[MAX_DBKEY_LENGTH];
uint key_length; uint key_length;
char *alias= table_list->alias; char *alias= table_list->alias;
HASH_SEARCH_STATE state;
DBUG_ENTER("open_table"); DBUG_ENTER("open_table");
/* find a unused table in the open table cache */ /* find a unused table in the open table cache */
@ -1247,9 +1248,11 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
if (thd->handler_tables) if (thd->handler_tables)
mysql_ha_flush(thd, (TABLE_LIST*) NULL, MYSQL_HA_REOPEN_ON_USAGE, TRUE); mysql_ha_flush(thd, (TABLE_LIST*) NULL, MYSQL_HA_REOPEN_ON_USAGE, TRUE);
for (table=(TABLE*) hash_search(&open_cache,(byte*) key,key_length) ; for (table= (TABLE*) hash_first(&open_cache, (byte*) key, key_length,
&state);
table && table->in_use ; table && table->in_use ;
table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length)) table= (TABLE*) hash_next(&open_cache, (byte*) key, key_length,
&state))
{ {
if (table->s->version != refresh_version) if (table->s->version != refresh_version)
{ {
@ -1621,10 +1624,12 @@ bool table_is_used(TABLE *table, bool wait_for_name_lock)
{ {
char *key= table->s->table_cache_key; char *key= table->s->table_cache_key;
uint key_length= table->s->key_length; uint key_length= table->s->key_length;
for (TABLE *search=(TABLE*) hash_search(&open_cache, HASH_SEARCH_STATE state;
(byte*) key,key_length) ; for (TABLE *search= (TABLE*) hash_first(&open_cache, (byte*) key,
key_length, &state);
search ; search ;
search = (TABLE*) hash_next(&open_cache,(byte*) key,key_length)) search= (TABLE*) hash_next(&open_cache, (byte*) key,
key_length, &state))
{ {
if (search->locked_by_flush || if (search->locked_by_flush ||
search->locked_by_name && wait_for_name_lock || search->locked_by_name && wait_for_name_lock ||
@ -5059,15 +5064,17 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
bool result=0, signalled= 0; bool result=0, signalled= 0;
DBUG_ENTER("remove_table_from_cache"); DBUG_ENTER("remove_table_from_cache");
key_length=(uint) (strmov(strmov(key,db)+1,table_name)-key)+1; key_length=(uint) (strmov(strmov(key,db)+1,table_name)-key)+1;
for (;;) for (;;)
{ {
HASH_SEARCH_STATE state;
result= signalled= 0; result= signalled= 0;
for (table=(TABLE*) hash_search(&open_cache,(byte*) key,key_length) ; for (table= (TABLE*) hash_first(&open_cache, (byte*) key, key_length,
&state);
table; table;
table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length)) table= (TABLE*) hash_next(&open_cache, (byte*) key, key_length,
&state))
{ {
THD *in_use; THD *in_use;
table->s->version=0L; /* Free when thread is ready */ table->s->version=0L; /* Free when thread is ready */

View File

@ -3050,6 +3050,7 @@ my_bool Query_cache::move_by_type(byte **border,
} }
case Query_cache_block::TABLE: case Query_cache_block::TABLE:
{ {
HASH_SEARCH_STATE record_idx;
DBUG_PRINT("qcache", ("block 0x%lx TABLE", (ulong) block)); DBUG_PRINT("qcache", ("block 0x%lx TABLE", (ulong) block));
if (*border == 0) if (*border == 0)
break; break;
@ -3067,7 +3068,7 @@ my_bool Query_cache::move_by_type(byte **border,
byte *key; byte *key;
uint key_length; uint key_length;
key=query_cache_table_get_key((byte*) block, &key_length, 0); key=query_cache_table_get_key((byte*) block, &key_length, 0);
hash_search(&tables, (byte*) key, key_length); hash_first(&tables, (byte*) key, key_length, &record_idx);
block->destroy(); block->destroy();
new_block->init(len); new_block->init(len);
@ -3101,7 +3102,7 @@ my_bool Query_cache::move_by_type(byte **border,
/* Fix pointer to table name */ /* Fix pointer to table name */
new_block->table()->table(new_block->table()->db() + tablename_offset); new_block->table()->table(new_block->table()->db() + tablename_offset);
/* Fix hash to point at moved block */ /* Fix hash to point at moved block */
hash_replace(&tables, tables.current_record, (byte*) new_block); hash_replace(&tables, &record_idx, (byte*) new_block);
DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx", DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx",
len, (ulong) new_block, (ulong) *border)); len, (ulong) new_block, (ulong) *border));
@ -3109,6 +3110,7 @@ my_bool Query_cache::move_by_type(byte **border,
} }
case Query_cache_block::QUERY: case Query_cache_block::QUERY:
{ {
HASH_SEARCH_STATE record_idx;
DBUG_PRINT("qcache", ("block 0x%lx QUERY", (ulong) block)); DBUG_PRINT("qcache", ("block 0x%lx QUERY", (ulong) block));
if (*border == 0) if (*border == 0)
break; break;
@ -3126,7 +3128,7 @@ my_bool Query_cache::move_by_type(byte **border,
byte *key; byte *key;
uint key_length; uint key_length;
key=query_cache_query_get_key((byte*) block, &key_length, 0); key=query_cache_query_get_key((byte*) block, &key_length, 0);
hash_search(&queries, (byte*) key, key_length); hash_first(&queries, (byte*) key, key_length, &record_idx);
// Move table of used tables // Move table of used tables
memmove((char*) new_block->table(0), (char*) block->table(0), memmove((char*) new_block->table(0), (char*) block->table(0),
ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table))); ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table)));
@ -3194,7 +3196,7 @@ my_bool Query_cache::move_by_type(byte **border,
net->query_cache_query= (gptr) new_block; net->query_cache_query= (gptr) new_block;
} }
/* Fix hash to point at moved block */ /* Fix hash to point at moved block */
hash_replace(&queries, queries.current_record, (byte*) new_block); hash_replace(&queries, &record_idx, (byte*) new_block);
DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx", DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx",
len, (ulong) new_block, (ulong) *border)); len, (ulong) new_block, (ulong) *border));
break; break;

View File

@ -227,6 +227,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
/* add to hash */ /* add to hash */
if (my_hash_insert(&thd->handler_tables_hash, (byte*) hash_tables)) if (my_hash_insert(&thd->handler_tables_hash, (byte*) hash_tables))
{ {
my_free((char*) hash_tables, MYF(0));
mysql_ha_close(thd, tables); mysql_ha_close(thd, tables);
goto err; goto err;
} }
@ -369,26 +370,6 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
DBUG_PRINT("info-in-hash",("'%s'.'%s' as '%s' tab %p", DBUG_PRINT("info-in-hash",("'%s'.'%s' as '%s' tab %p",
hash_tables->db, hash_tables->table_name, hash_tables->db, hash_tables->table_name,
hash_tables->alias, table)); hash_tables->alias, table));
/* Table might have been flushed. */
if (table && (table->s->version != refresh_version))
{
/*
We must follow the thd->handler_tables chain, as we need the
address of the 'next' pointer referencing this table
for close_thread_table().
*/
for (table_ptr= &(thd->handler_tables); *table_ptr != table;
table_ptr= &(*table_ptr)->next) /* no-op */ ;
(*table_ptr)->file->ha_index_or_rnd_end();
VOID(pthread_mutex_lock(&LOCK_open));
if (close_thread_table(thd, table_ptr))
{
/* Tell threads waiting for refresh that something has happened */
VOID(pthread_cond_broadcast(&COND_refresh));
}
VOID(pthread_mutex_unlock(&LOCK_open));
table= hash_tables->table= NULL;
}
if (!table) if (!table)
{ {
/* /*
@ -433,6 +414,13 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
} }
tables->table=table; tables->table=table;
HANDLER_TABLES_HACK(thd);
lock= mysql_lock_tables(thd, &tables->table, 1, 0, &not_used);
HANDLER_TABLES_HACK(thd);
if (!lock)
goto err0; // mysql_lock_tables() printed error message already
if (cond && ((!cond->fixed && if (cond && ((!cond->fixed &&
cond->fix_fields(thd, &cond)) || cond->check_cols(1))) cond->fix_fields(thd, &cond)) || cond->check_cols(1)))
goto err0; goto err0;
@ -452,13 +440,6 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
protocol->send_fields(&list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); protocol->send_fields(&list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
HANDLER_TABLES_HACK(thd);
lock= mysql_lock_tables(thd, &tables->table, 1, 0, &not_used);
HANDLER_TABLES_HACK(thd);
if (!lock)
goto err0; // mysql_lock_tables() printed error message already
/* /*
In ::external_lock InnoDB resets the fields which tell it that In ::external_lock InnoDB resets the fields which tell it that
the handle is used in the HANDLER interface. Tell it again that the handle is used in the HANDLER interface. Tell it again that

View File

@ -2435,7 +2435,11 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
} }
/* First field to copy */ /* First field to copy */
field=table->field+table->s->fields - values.elements; field= table->field+table->s->fields - values.elements;
/* Mark all fields that are given values */
for (Field **f= field ; *f ; f++)
(*f)->query_id= thd->query_id;
/* Don't set timestamp if used */ /* Don't set timestamp if used */
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;

View File

@ -1185,6 +1185,7 @@ end_thread:
or this thread has been schedule to handle the next query or this thread has been schedule to handle the next query
*/ */
thd= current_thd; thd= current_thd;
thd->thread_stack= (char*) &thd;
} while (!(test_flags & TEST_NO_THREADS)); } while (!(test_flags & TEST_NO_THREADS));
/* The following is only executed if we are not using --one-thread */ /* The following is only executed if we are not using --one-thread */
return(0); /* purecov: deadcode */ return(0); /* purecov: deadcode */
@ -4853,7 +4854,6 @@ end_with_restore_list:
if (thd->one_shot_set && lex->sql_command != SQLCOM_SET_OPTION) if (thd->one_shot_set && lex->sql_command != SQLCOM_SET_OPTION)
reset_one_shot_variables(thd); reset_one_shot_variables(thd);
/* /*
The return value for ROW_COUNT() is "implementation dependent" if the The return value for ROW_COUNT() is "implementation dependent" if the
statement is not DELETE, INSERT or UPDATE, but -1 is what JDBC and ODBC statement is not DELETE, INSERT or UPDATE, but -1 is what JDBC and ODBC
@ -4865,13 +4865,10 @@ end_with_restore_list:
if (lex->sql_command != SQLCOM_CALL && lex->sql_command != SQLCOM_EXECUTE && if (lex->sql_command != SQLCOM_CALL && lex->sql_command != SQLCOM_EXECUTE &&
uc_update_queries[lex->sql_command]<2) uc_update_queries[lex->sql_command]<2)
thd->row_count_func= -1; thd->row_count_func= -1;
goto cleanup; DBUG_RETURN(res || thd->net.report_error);
error: error:
res= 1; DBUG_RETURN(1);
cleanup:
DBUG_RETURN(res || thd->net.report_error);
} }
@ -5094,7 +5091,7 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables,
the given table list refers to the list for prelocking (contains tables the given table list refers to the list for prelocking (contains tables
of other queries). For simple queries first_not_own_table is 0. of other queries). For simple queries first_not_own_table is 0.
*/ */
for (; tables && tables != first_not_own_table; tables= tables->next_global) for (; tables != first_not_own_table; tables= tables->next_global)
{ {
if (tables->schema_table && if (tables->schema_table &&
(want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL))) (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
@ -7258,7 +7255,7 @@ LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name)
/* Create and initialize. */ /* Create and initialize. */
if (! (definer= (LEX_USER*) thd->alloc(sizeof (LEX_USER)))) if (! (definer= (LEX_USER*) thd->alloc(sizeof(LEX_USER))))
return 0; return 0;
definer->user= *user_name; definer->user= *user_name;

View File

@ -10700,7 +10700,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
item->save_org_in_field(group->field); item->save_org_in_field(group->field);
/* Store in the used key if the field was 0 */ /* Store in the used key if the field was 0 */
if (item->maybe_null) if (item->maybe_null)
group->buff[-1]=item->null_value ? 1 : 0; group->buff[-1]= (char) group->field->is_null();
} }
if (!table->file->index_read(table->record[1], if (!table->file->index_read(table->record[1],
join->tmp_table_param.group_buff,0, join->tmp_table_param.group_buff,0,

View File

@ -51,6 +51,13 @@ static File_option triggers_file_parameters[]=
{ { 0, 0 }, 0, FILE_OPTIONS_STRING } { { 0, 0 }, 0, FILE_OPTIONS_STRING }
}; };
File_option sql_modes_parameters=
{
{(char*) STRING_WITH_LEN("sql_modes") },
offsetof(class Table_triggers_list, definition_modes_list),
FILE_OPTIONS_ULLLIST
};
/* /*
This must be kept up to date whenever a new option is added to the list This must be kept up to date whenever a new option is added to the list
above, as it specifies the number of required parameters of the trigger in above, as it specifies the number of required parameters of the trigger in
@ -779,7 +786,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
sizeof(LEX_STRING)))) sizeof(LEX_STRING))))
DBUG_RETURN(1); // EOM DBUG_RETURN(1); // EOM
trg_definer->str= ""; trg_definer->str= (char*) "";
trg_definer->length= 0; trg_definer->length= 0;
while (it++) while (it++)
@ -1171,7 +1178,7 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
if (is_special_var_used(event, time_type)) if (is_special_var_used(event, time_type))
{ {
TABLE_LIST table_list; TABLE_LIST table_list, **save_query_tables_own_last;
bzero((char *) &table_list, sizeof (table_list)); bzero((char *) &table_list, sizeof (table_list));
table_list.db= (char *) table->s->db; table_list.db= (char *) table->s->db;
table_list.db_length= strlen(table_list.db); table_list.db_length= strlen(table_list.db);
@ -1179,8 +1186,13 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
table_list.table_name_length= strlen(table_list.table_name); table_list.table_name_length= strlen(table_list.table_name);
table_list.alias= (char *) table->alias; table_list.alias= (char *) table->alias;
table_list.table= table; table_list.table= table;
save_query_tables_own_last= thd->lex->query_tables_own_last;
thd->lex->query_tables_own_last= 0;
if (check_table_access(thd, SELECT_ACL | UPDATE_ACL, &table_list, 0)) err_status= check_table_access(thd, SELECT_ACL | UPDATE_ACL,
&table_list, 0);
thd->lex->query_tables_own_last= save_query_tables_own_last;
if (err_status)
{ {
sp_restore_security_context(thd, save_ctx); sp_restore_security_context(thd, save_ctx);
return TRUE; return TRUE;
@ -1222,32 +1234,29 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
TRUE Error TRUE Error
*/ */
#define INVALID_SQL_MODES_LENGTH 13
bool bool
Handle_old_incorrect_sql_modes_hook::process_unknown_string(char *&unknown_key, Handle_old_incorrect_sql_modes_hook::process_unknown_string(char *&unknown_key,
gptr base, gptr base,
MEM_ROOT *mem_root, MEM_ROOT *mem_root,
char *end) char *end)
{ {
#define INVALID_SQL_MODES_LENGTH 13
DBUG_ENTER("handle_old_incorrect_sql_modes"); DBUG_ENTER("handle_old_incorrect_sql_modes");
DBUG_PRINT("info", ("unknown key:%60s", unknown_key)); DBUG_PRINT("info", ("unknown key:%60s", unknown_key));
if (unknown_key + INVALID_SQL_MODES_LENGTH + 1 < end && if (unknown_key + INVALID_SQL_MODES_LENGTH + 1 < end &&
unknown_key[INVALID_SQL_MODES_LENGTH] == '=' && unknown_key[INVALID_SQL_MODES_LENGTH] == '=' &&
!memcmp(unknown_key, STRING_WITH_LEN("sql_modes"))) !memcmp(unknown_key, STRING_WITH_LEN("sql_modes")))
{ {
char *ptr= unknown_key + INVALID_SQL_MODES_LENGTH + 1;
DBUG_PRINT("info", ("sql_modes affected by BUG#14090 detected")); DBUG_PRINT("info", ("sql_modes affected by BUG#14090 detected"));
push_warning_printf(current_thd, push_warning_printf(current_thd,
MYSQL_ERROR::WARN_LEVEL_NOTE, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_OLD_FILE_FORMAT, ER_OLD_FILE_FORMAT,
ER(ER_OLD_FILE_FORMAT), ER(ER_OLD_FILE_FORMAT),
(char *)path, "TRIGGER"); (char *)path, "TRIGGER");
File_option sql_modes_parameters=
{
{(char *) STRING_WITH_LEN("sql_modes") },
offsetof(class Table_triggers_list, definition_modes_list),
FILE_OPTIONS_ULLLIST
};
char *ptr= unknown_key + INVALID_SQL_MODES_LENGTH + 1;
if (get_file_options_ulllist(ptr, end, unknown_key, base, if (get_file_options_ulllist(ptr, end, unknown_key, base,
&sql_modes_parameters, mem_root)) &sql_modes_parameters, mem_root))
{ {