Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into  mysql.com:/home/my/mysql-5.0
This commit is contained in:
monty@mysql.com 2006-01-06 01:08:48 +02:00
commit b0a5ea01ef
34 changed files with 283 additions and 229 deletions

View File

@ -272,7 +272,6 @@ a b
create table if not exists t1 select 3 as 'a',4 as 'b';
Warnings:
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';
ERROR 23000: Duplicate entry '3' for key 1
select * from t1;
@ -630,8 +629,6 @@ create table t1 (
a varchar(112) charset utf8 collate utf8_bin not null,
primary key (a)
) select 'test' as a ;
Warnings:
Warning 1364 Field 'a' doesn't have a default value
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -647,9 +644,6 @@ create table t1 (
a varchar(12) charset utf8 collate utf8_bin not null,
b int not null, primary key (a)
) 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;
Table Create Table
t1 CREATE TABLE `t1` (
@ -659,12 +653,37 @@ t1 CREATE TABLE `t1` (
) 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, 1 as c from t2 ;
Warnings:
Warning 1364 Field 'b' doesn't have a default value
show create table t1;
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 ;
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;
Table Create Table
t1 CREATE TABLE `t1` (
@ -677,8 +696,6 @@ create table t1 (
a varchar(12) charset utf8 collate utf8_bin,
b int not null, primary key (a)
) select 'a' as a , 1 as b from t2 ;
Warnings:
Warning 1364 Field 'b' doesn't have a default value
show create table t1;
Table Create Table
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,
primary key (a1)
) 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;
create table t2 (
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,
primary key (a1)
) 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;
create table t2 ( a int default 3, b int default 3)
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));
insert into t1 values
(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)
0
kill @id;
select 1;
Got one of the listed errors
select ((@id := kill_id) - kill_id) from t1;
((@id := kill_id) - kill_id)
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);
INSERT INTO t1 VALUES (1),(2),(3);
CREATE TABLE t2 (a int, b int);

View File

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

View File

@ -2423,6 +2423,9 @@ drop view v1;
drop table t1;
create table t1(f1 int, f2 int);
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;
select f1, sum(f2) from v1 group by f1;
f1 sum(f2)

View File

@ -564,6 +564,22 @@ create table t1 (
show create 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
create table t1 (
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
kill : Unstable test case, bug#9712
subselect : Bug#15706
type_time : Bug#15805

View File

@ -3,7 +3,7 @@
#
--disable_warnings
drop table if exists t1;
drop table if exists t1,t3,t4,t5;
--enable_warnings
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;
connection con1;
--sleep 1
--sleep 2
# this statement should fail
--error 2006,2013
--disable_query_log
--disable_result_log
# One of the following statements should fail
--error 0,2006,2013
select 1;
--error 0,2006,2013
select 1;
--enable_query_log
--enable_result_log
--enable_reconnect
# this should work, and we should have a new connection_id()
select ((@id := kill_id) - kill_id) from t1;

View File

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

View File

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

View File

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

View File

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

View File

@ -174,29 +174,29 @@ sub new
# Some fixes that depends on the environment
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
}
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
}
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
$limits{'max_columns'} = 90; # Max number of columns in table
$limits{'max_tables'} = 32; # No comments
}
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
}
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{'max_tables'} = 500;

View File

@ -6212,8 +6212,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
to now VARCHAR fields.
*/
if (new_field= new Field_varstring(field_length, maybe_null(),
field_name, new_table, charset()))
if ((new_field= new Field_varstring(field_length, maybe_null(),
field_name, new_table, charset())))
{
/*
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()");
remote_error_number= mysql_errno(mysql);
my_snprintf(remote_error_buf, sizeof(remote_error_buf), "%s",
mysql_error(mysql));
strmake(remote_error_buf, mysql_error(mysql), sizeof(remote_error_buf)-1);
DBUG_RETURN(HA_FEDERATED_ERROR_WITH_REMOTE_SYSTEM);
}

View File

@ -300,7 +300,8 @@ Thd_ndb::~Thd_ndb()
if (ndb)
{
#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))
{
uint leaked= (uint) tmp.m_created - tmp.m_free;
@ -312,8 +313,8 @@ Thd_ndb::~Thd_ndb()
}
#endif
delete ndb;
ndb= NULL;
}
ndb= NULL;
changed_tables.empty();
}
@ -4903,7 +4904,8 @@ bool ndbcluster_end()
if (g_ndb)
{
#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))
{
uint leaked= (uint) tmp.m_created - tmp.m_free;
@ -4915,10 +4917,9 @@ bool ndbcluster_end()
}
#endif
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;
hash_free(&ndbcluster_open_tables);
@ -7463,7 +7464,8 @@ ndbcluster_show_status(THD* thd)
if (have_ndbcluster != SHOW_OPTION_YES)
{
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));
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("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);
if (get_thd_ndb(thd) && 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))
{
protocol->prepare_for_resend();

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)
{
(*ref)->make_field(field);

View File

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

View File

@ -114,13 +114,24 @@ static char *pretty_print_str(char *packet, char *str, int len)
/*
slave_load_file_stem()
Creates a temporary name for load data infile:
SYNOPSIS
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)
static inline char* slave_load_file_stem(char*buf, uint file_id,
int event_server_id)
static char *slave_load_file_stem(char *buf, uint file_id,
int event_server_id, const char *ext)
{
char *res;
fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", MY_UNPACK_FILENAME);
to_unix_path(buf);
@ -129,7 +140,9 @@ static inline char* slave_load_file_stem(char*buf, uint file_id,
*buf++ = '-';
buf = int10_to_str(event_server_id, buf, 10);
*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
@ -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 */
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 "
"Size Master Pos Flags \n");
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)
{
DBUG_ASSERT(hexdump_from == (unsigned long) hexdump_from);
fprintf(file, "# %8.8lx %-48.48s |%16s|\n",
(unsigned long) (hexdump_from + (i & 0xfffffff0)),
hex_string, char_string);
@ -941,12 +952,10 @@ void Log_event::print_header(FILE* file, PRINT_EVENT_INFO* print_event_info)
*c= '\0';
/* Non-full last line */
if (hex_string[0]) {
DBUG_ASSERT(hexdump_from == (unsigned long) hexdump_from);
if (hex_string[0])
fprintf(file, "# %8.8lx %-48.48s |%s|\n# ",
(unsigned long) (hexdump_from + (i & 0xfffffff0)),
hex_string, char_string);
}
}
}
@ -4160,16 +4169,15 @@ void Create_file_log_event::pack_info(Protocol *protocol)
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
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 *p;
char proc_info[17+FN_REFLEN+10], *fname_buf;
char *ext;
int fd = -1;
IO_CACHE file;
int error = 1;
bzero((char*)&file, sizeof(file));
p = slave_load_file_stem(fname_buf, file_id, server_id);
strmov(p, ".info"); // strmov takes less code than memcpy
strnmov(proc_info, STRING_WITH_LEN("Making temp file ")); // no end 0
fname_buf= strmov(proc_info, "Making temp file ");
ext= slave_load_file_stem(fname_buf, file_id, server_id, ".info");
thd->proc_info= proc_info;
my_delete(fname_buf, MYF(0)); // old copy may exist already
if ((fd= my_create(fname_buf, CREATE_MODE,
@ -4178,19 +4186,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,
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;
}
// a trick to avoid allocating another buffer
strmov(p, ".data");
fname = fname_buf;
fname_len = (uint)(p-fname) + 5;
fname= fname_buf;
fname_len= (uint) (strmov(ext, ".data") - fname);
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,
"Error in Create_file event: could not write to file '%s'",
"Error in Create_file event: could not write to file "
"'%s'",
fname_buf);
goto err;
}
@ -4203,12 +4213,16 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
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;
}
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;
}
error=0; // Everything is ok
@ -4332,13 +4346,12 @@ int Append_block_log_event::get_create_or_append() const
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 *p= slave_load_file_stem(fname, file_id, server_id);
int fd;
int error = 1;
DBUG_ENTER("Append_block_log_event::exec_event");
memcpy(p, ".data", 6);
strnmov(proc_info, STRING_WITH_LEN("Making temp file ")); // no end 0
fname= strmov(proc_info, "Making temp file ");
slave_load_file_stem(fname, file_id, server_id, ".data");
thd->proc_info= proc_info;
if (get_create_or_append())
{
@ -4464,10 +4477,9 @@ void Delete_file_log_event::pack_info(Protocol *protocol)
int Delete_file_log_event::exec_event(struct st_relay_log_info* rli)
{
char fname[FN_REFLEN+10];
char *p= slave_load_file_stem(fname, file_id, server_id);
memcpy(p, ".data", 6);
char *ext= slave_load_file_stem(fname, file_id, server_id, ".data");
(void) my_delete(fname, MYF(MY_WME));
memcpy(p, ".info", 6);
strmov(ext, ".info");
(void) my_delete(fname, MYF(MY_WME));
return Log_event::exec_event(rli);
}
@ -4560,19 +4572,21 @@ void Execute_load_log_event::pack_info(Protocol *protocol)
int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
{
char fname[FN_REFLEN+10];
char *p= slave_load_file_stem(fname, file_id, server_id);
char *ext;
int fd;
int error = 1;
int error= 1;
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,
MYF(MY_WME))) < 0 ||
init_io_cache(&file, fd, IO_SIZE, READ_CACHE, (my_off_t)0, 0,
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;
}
if (!(lev = (Load_log_event*)Log_event::read_log_event(&file,
@ -4580,7 +4594,9 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
rli->relay_log.description_event_for_exec)) ||
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;
}
@ -4625,7 +4641,7 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
fd= -1;
}
(void) my_delete(fname, MYF(MY_WME));
memcpy(p, ".data", 6);
memcpy(ext, ".data", 6);
(void) my_delete(fname, MYF(MY_WME));
error = 0;
@ -4823,11 +4839,10 @@ Execute_load_query_log_event::exec_event(struct st_relay_log_info* rli)
memcpy(p, query, fn_pos_start);
p+= fn_pos_start;
fname= (p= strmake(p, STRING_WITH_LEN(" INFILE \'")));
p= slave_load_file_stem(p, file_id, server_id);
fname_end= (p= strmake(p, STRING_WITH_LEN(".data")));
p= slave_load_file_stem(p, file_id, server_id, ".data");
fname_end= p= strend(p); // Safer than p=p+5
*(p++)='\'';
switch (dup_handling)
{
switch (dup_handling) {
case LOAD_DUP_IGNORE:
p= strmake(p, STRING_WITH_LEN(" IGNORE"));
break;

View File

@ -1613,7 +1613,7 @@ void end_thread(THD *thd, bool put_in_cache)
wake_thread--;
thd=thread_cache.get();
thd->real_id=pthread_self();
thd->thread_stack= (char *) &thd;
thd->thread_stack= (char*) &thd; // For store_globals
(void) thd->store_globals();
thd->thr_create_time= time(NULL);
threads.append(thd);

View File

@ -5738,6 +5738,7 @@ bool QUICK_ROR_UNION_SELECT::check_if_keys_used(List<Item> *fields)
/*
Create quick select from ref/ref_or_null scan.
SYNOPSIS
get_quick_select_for_ref()
thd Thread handle
@ -5757,15 +5758,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,
TABLE_REF *ref, ha_rows records)
{
MEM_ROOT *old_root= thd->mem_root;
/* The following call may change thd->mem_root */
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;
MEM_ROOT *old_root, *alloc;
QUICK_RANGE_SELECT *quick;
KEY *key_info = &table->key_info[ref->key];
KEY_PART *key_part;
QUICK_RANGE *range;
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
QUICK_RANGE_SELECT constructor

View File

@ -944,6 +944,6 @@ File_parser_dummy_hook::process_unknown_string(char *&unknown_key,
char *end)
{
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);
}

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 *definer, longlong created, longlong modified)
{
LEX *oldlex= thd->lex, newlex;
sp_rcontext *save_spcont= thd->spcont;
LEX *old_lex= thd->lex, newlex;
String defstr;
char olddb[128];
bool dbchanged;
ulong old_sql_mode= thd->variables.sql_mode;
ha_rows select_limit= thd->variables.select_limit;
int ret= SP_INTERNAL_ERROR;
ha_rows old_select_limit= thd->variables.select_limit;
sp_rcontext *old_spcont= thd->spcont;
int ret;
thd->variables.sql_mode= sql_mode;
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),
body, strlen(body),
&chistics))
{
ret= SP_INTERNAL_ERROR;
goto end;
}
dbchanged= FALSE;
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();
}
end:
thd->spcont= save_spcont;
thd->spcont= old_spcont;
thd->variables.sql_mode= old_sql_mode;
thd->variables.select_limit= select_limit;
thd->lex= oldlex;
thd->variables.select_limit= old_select_limit;
thd->lex= old_lex;
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 ?
thd->variables.max_sp_recursion_depth :
0);
DBUG_ENTER("sp_find_routine");
DBUG_PRINT("enter", ("name: %.*s.%.*s, type: %d, cache only %d",
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)))
{
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));
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));
if (sp->m_first_free_instance->m_recursion_level > depth)
{
sp->recursion_level_error();
sp->recursion_level_error(thd);
DBUG_RETURN(0);
}
DBUG_RETURN(sp->m_first_free_instance);
@ -954,37 +961,32 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp,
level= sp->m_last_cached_sp->m_recursion_level + 1;
if (level > depth)
{
sp->recursion_level_error();
sp->recursion_level_error(thd);
DBUG_RETURN(0);
}
strxmov(definer, sp->m_definer_user.str, "@",
sp->m_definer_host.str, NullS);
if (type == TYPE_ENUM_FUNCTION)
{
sp_head *new_sp;
const char *returns= "";
char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2];
String retstr(64);
strxmov(definer, sp->m_definer_user.str, "@",
sp->m_definer_host.str, NullS);
if (type == TYPE_ENUM_FUNCTION)
{
sp_returns_type(thd, retstr, sp);
returns= retstr.ptr();
}
if (db_load_routine(thd, type, name, &new_sp,
sp->m_sql_mode, sp->m_params.str, returns,
sp->m_body.str, *sp->m_chistics, definer,
sp->m_created, sp->m_modified) == SP_OK)
{
sp->m_last_cached_sp->m_next_cached_sp= new_sp;
new_sp->m_recursion_level= level;
new_sp->m_first_instance= sp;
sp->m_last_cached_sp= sp->m_first_free_instance= new_sp;
DBUG_PRINT("info", ("added level: 0x%lx, level: %lu, flags %x",
sp_returns_type(thd, retstr, sp);
returns= retstr.ptr();
}
if (db_load_routine(thd, type, name, &new_sp,
sp->m_sql_mode, sp->m_params.str, returns,
sp->m_body.str, *sp->m_chistics, definer,
sp->m_created, sp->m_modified) == SP_OK)
{
sp->m_last_cached_sp->m_next_cached_sp= new_sp;
new_sp->m_recursion_level= level;
new_sp->m_first_instance= sp;
sp->m_last_cached_sp= sp->m_first_free_instance= new_sp;
DBUG_PRINT("info", ("added level: 0x%lx, level: %lu, flags %x",
(ulong)new_sp, new_sp->m_recursion_level,
new_sp->m_flags));
DBUG_RETURN(new_sp);
}
DBUG_RETURN(0);
DBUG_RETURN(new_sp);
}
DBUG_RETURN(0);
}
if (!cache_only)
{

View File

@ -24,6 +24,13 @@
#include "sp_rcontext.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
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
sp_head::recursion_level_error()
thd Thread handle
NOTE
For functions and triggers we return error about prohibited recursion.
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)
{
THD *thd= current_thd;
my_error(ER_SP_RECURSION_LIMIT, MYF(0),
thd->variables.max_sp_recursion_depth,
m_name.str);
@ -928,14 +935,15 @@ sp_head::execute(THD *thd)
DBUG_ASSERT(!(m_flags & IS_INVOKED));
m_flags|= IS_INVOKED;
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",
(ulong)m_first_instance, this, m_next_cached_sp,
(m_next_cached_sp ?
m_next_cached_sp->m_recursion_level :
0),
(m_next_cached_sp ?
m_next_cached_sp->m_flags :
0)));
if (m_next_cached_sp)
{
DBUG_PRINT("info",
("first free for 0x%lx ++: 0x%lx->0x%lx level: %lu flags %x",
(ulong)m_first_instance, (ulong) this,
(ulong) m_next_cached_sp,
m_next_cached_sp->m_recursion_level,
m_next_cached_sp->m_flags));
}
/*
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
@ -1103,13 +1111,15 @@ sp_head::execute(THD *thd)
state= EXECUTED;
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));
if (thd->killed)
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)
{
/*
@ -1120,10 +1130,11 @@ sp_head::execute(THD *thd)
err_status|= mysql_change_db(thd, olddb, 1);
}
m_flags&= ~IS_INVOKED;
DBUG_PRINT("info", ("first free for 0x%lx --: 0x%lx->0x%lx, level: %lu, flags %x",
(ulong)m_first_instance,
m_first_instance->m_first_free_instance, this,
m_recursion_level, m_flags));
DBUG_PRINT("info",
("first free for 0x%lx --: 0x%lx->0x%lx, level: %lu, flags %x",
(ulong) m_first_instance,
(ulong) m_first_instance->m_first_free_instance,
(ulong) this, m_recursion_level, m_flags));
/*
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
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 &&
this == m_first_instance->m_last_cached_sp &&
@ -1741,16 +1752,16 @@ sp_head::set_info(longlong created, longlong modified,
void
sp_head::set_definer(char *definer, uint definerlen)
sp_head::set_definer(const char *definer, uint definerlen)
{
char *p= strrchr(definer, '@');
if (!p)
{
m_definer_user.str= strmake_root(mem_root, "", 0);
m_definer_user.str= (char*) "";
m_definer_user.length= 0;
m_definer_host.str= strmake_root(mem_root, "", 0);
m_definer_host.str= (char*) "";
m_definer_host.length= 0;
}
else
@ -1845,9 +1856,9 @@ sp_head::show_create_procedure(THD *thd)
byte *sql_mode_str;
ulong sql_mode_len;
bool full_access;
DBUG_ENTER("sp_head::show_create_procedure");
DBUG_PRINT("info", ("procedure %s", m_name.str));
LINT_INIT(sql_mode_str);
LINT_INIT(sql_mode_len);
@ -2200,12 +2211,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
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
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 */
for (i= 0 ; i < len ; i++)
{
if (m_query.str[i] == '\n')
str->qs_append(' ');
else
str->qs_append(m_query.str[i]);
char c= m_query.str[i];
if (c == '\n')
c= ' ';
str->qs_append(c);
}
if (m_query.length > SP_STMT_PRINT_MAXLEN)
str->qs_append(STRING_WITH_LEN("...")); /* Indicate truncated string */
str->qs_append('"');
}
#undef SP_STMT_PRINT_MAXLEN
int
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);
}
void
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(' ');
str->qs_append(m_frame);
switch (m_type)
{
switch (m_type) {
case SP_HANDLER_NONE:
str->qs_append(STRING_WITH_LEN(" NONE")); // This would be a bug
break;
@ -2627,11 +2633,13 @@ sp_instr_hpush_jump::print(String *str)
str->qs_append(STRING_WITH_LEN(" UNDO"));
break;
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);
}
}
uint
sp_instr_hpush_jump::opt_mark(sp_head *sp)
{

View File

@ -285,7 +285,7 @@ public:
void set_info(longlong created, longlong modified,
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);
@ -294,7 +294,7 @@ public:
void optimize();
void opt_mark(uint ip);
void recursion_level_error();
void recursion_level_error(THD *thd);
inline sp_instr *
get_instr(uint i)

View File

@ -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.
*/
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++)
{
/* Remove SHOW_VIEW_ACL, because it will be checked during making view */

View File

@ -5064,7 +5064,6 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
bool result=0, signalled= 0;
DBUG_ENTER("remove_table_from_cache");
key_length=(uint) (strmov(strmov(key,db)+1,table_name)-key)+1;
for (;;)
{

View File

@ -227,6 +227,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
/* add to hash */
if (my_hash_insert(&thd->handler_tables_hash, (byte*) hash_tables))
{
my_free((char*) hash_tables, MYF(0));
mysql_ha_close(thd, tables);
goto err;
}
@ -369,28 +370,6 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
DBUG_PRINT("info-in-hash",("'%s'.'%s' as '%s' tab %p",
hash_tables->db, hash_tables->table_name,
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_ptr != table);
table_ptr= &(*table_ptr)->next)
{}
(*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)
{
/*
@ -448,12 +427,6 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
}
}
if (insert_fields(thd, &thd->lex->select_lex.context,
tables->db, tables->alias, &it, 0))
goto err0;
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);
@ -461,6 +434,12 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
if (!lock)
goto err0; // mysql_lock_tables() printed error message already
if (insert_fields(thd, &thd->lex->select_lex.context,
tables->db, tables->alias, &it, 0))
goto err0;
protocol->send_fields(&list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
/*
In ::external_lock InnoDB resets the fields which tell it that
the handle is used in the HANDLER interface. Tell it again that

View File

@ -2434,7 +2434,11 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
}
/* 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 */
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
*/
thd= current_thd;
thd->thread_stack= (char*) &thd;
} while (!(test_flags & TEST_NO_THREADS));
/* The following is only executed if we are not using --one-thread */
return(0); /* purecov: deadcode */
@ -4848,7 +4849,6 @@ end_with_restore_list:
if (thd->one_shot_set && lex->sql_command != SQLCOM_SET_OPTION)
reset_one_shot_variables(thd);
/*
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
@ -4860,13 +4860,10 @@ end_with_restore_list:
if (lex->sql_command != SQLCOM_CALL && lex->sql_command != SQLCOM_EXECUTE &&
uc_update_queries[lex->sql_command]<2)
thd->row_count_func= -1;
goto cleanup;
DBUG_RETURN(res || thd->net.report_error);
error:
res= 1;
cleanup:
DBUG_RETURN(res || thd->net.report_error);
DBUG_RETURN(1);
}
@ -5089,7 +5086,7 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *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.
*/
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 &&
(want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
@ -7252,7 +7249,7 @@ LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name)
/* Create and initialize. */
if (! (definer= (LEX_USER*) thd->alloc(sizeof (LEX_USER))))
if (! (definer= (LEX_USER*) thd->alloc(sizeof(LEX_USER))))
return 0;
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);
/* Store in the used key if the field was 0 */
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],
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 }
};
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
above, as it specifies the number of required parameters of the trigger in
@ -436,7 +443,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!is_acl_user(lex->definer->host.str,
lex->definer->user.str))
lex->definer->user.str))
{
push_warning_printf(thd,
MYSQL_ERROR::WARN_LEVEL_NOTE,
@ -779,7 +786,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
sizeof(LEX_STRING))))
DBUG_RETURN(1); // EOM
trg_definer->str= "";
trg_definer->str= (char*) "";
trg_definer->length= 0;
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))
{
TABLE_LIST table_list;
TABLE_LIST table_list, **save_query_tables_own_last;
bzero((char *) &table_list, sizeof (table_list));
table_list.db= (char *) table->s->db;
table_list.db_length= strlen(table_list.db);
@ -1179,8 +1186,12 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
table_list.table_name_length= strlen(table_list.table_name);
table_list.alias= (char *) table->alias;
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))
res= check_table_access(thd, SELECT_ACL | UPDATE_ACL, &table_list, 0);
thd->lex->query_tables_own_last= save_query_tables_own_last;
if (res)
{
sp_restore_security_context(thd, save_ctx);
return TRUE;
@ -1222,32 +1233,29 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
TRUE Error
*/
#define INVALID_SQL_MODES_LENGTH 13
bool
Handle_old_incorrect_sql_modes_hook::process_unknown_string(char *&unknown_key,
gptr base,
MEM_ROOT *mem_root,
char *end)
{
#define INVALID_SQL_MODES_LENGTH 13
DBUG_ENTER("handle_old_incorrect_sql_modes");
DBUG_PRINT("info", ("unknown key:%60s", unknown_key));
if (unknown_key + INVALID_SQL_MODES_LENGTH + 1 < end &&
unknown_key[INVALID_SQL_MODES_LENGTH] == '=' &&
!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"));
push_warning_printf(current_thd,
MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_OLD_FILE_FORMAT,
ER(ER_OLD_FILE_FORMAT),
(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,
&sql_modes_parameters, mem_root))
{