Merge quad.opbmk:/mnt/raid/alik/MySQL/devel/5.1

into  quad.opbmk:/mnt/raid/alik/MySQL/devel/5.1-rt-merged


sql/sql_delete.cc:
  Auto merged
This commit is contained in:
unknown 2008-03-25 14:54:08 +03:00
commit 6cd3a1503b
39 changed files with 875 additions and 227 deletions

View File

@ -4221,11 +4221,13 @@ int connect_n_handle_errors(struct st_command *command,
if (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
CLIENT_MULTI_STATEMENTS))
{
var_set_errno(mysql_errno(con));
handle_error(command, mysql_errno(con), mysql_error(con),
mysql_sqlstate(con), ds);
return 0; /* Not connected */
}
var_set_errno(0);
handle_no_error(command);
return 1; /* Connected */
}

View File

@ -47,8 +47,9 @@ typedef struct st_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)
my_bool _hash_init(HASH *hash, CHARSET_INFO *charset,
#define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,0,B,C,D,E,F,G,H CALLER_INFO)
#define hash_init2(A,B,C,D,E,F,G,H,I) _hash_init(A,B,C,D,E,F,G,H,I CALLER_INFO)
my_bool _hash_init(HASH *hash, uint growth_size,CHARSET_INFO *charset,
ulong default_array_elements, size_t key_offset,
size_t key_length, hash_get_key get_key,
void (*free_element)(void*), uint flags CALLER_INFO_PROTO);
@ -69,7 +70,7 @@ my_bool hash_check(HASH *hash); /* Only in debug library */
#define hash_clear(H) bzero((char*) (H),sizeof(*(H)))
#define hash_inited(H) ((H)->array.buffer != 0)
#define hash_init_opt(A,B,C,D,E,F,G,H) \
(!hash_inited(A) && _hash_init(A,B,C,D,E,F,G, H CALLER_INFO))
(!hash_inited(A) && _hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO))
#ifdef __cplusplus
}

View File

@ -161,7 +161,7 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
#define pthread_kill(A,B) pthread_dummy(ESRCH)
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
#define pthread_join(A,B) (WaitForSingleObject((A), INFINITE) != WAIT_OBJECT_0)
@ -343,14 +343,14 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res);
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
#define pthread_kill(A,B) pthread_dummy(ESRCH)
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
#undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
#endif
#ifdef HAVE_DARWIN5_THREADS
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
#define pthread_kill(A,B) pthread_dummy(ESRCH)
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
#define pthread_condattr_init(A) pthread_dummy(0)
#define pthread_condattr_destroy(A) pthread_dummy(0)
#undef pthread_detach_this_thread
@ -370,7 +370,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res);
#ifndef pthread_sigmask
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
#endif
#define pthread_kill(A,B) pthread_dummy(ESRCH)
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
#undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
#elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */

View File

@ -2467,7 +2467,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
int4store(buff+5, 1); /* iteration count */
res= test(cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff),
(uchar*) packet, length, 1, NULL) ||
(uchar*) packet, length, 1, stmt) ||
(*mysql->methods->read_query_result)(mysql));
stmt->affected_rows= mysql->affected_rows;
stmt->server_status= mysql->server_status;
@ -2683,7 +2683,7 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row)
int4store(buff + 4, stmt->prefetch_rows); /* number of rows to fetch */
if ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH,
buff, sizeof(buff), (uchar*) 0, 0,
1, NULL))
1, stmt))
{
set_stmt_errmsg(stmt, net);
return 1;
@ -3350,7 +3350,7 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
*/
if ((*mysql->methods->advanced_command)(mysql, COM_STMT_SEND_LONG_DATA,
buff, sizeof(buff), (uchar*) data,
length, 1, NULL))
length, 1, stmt))
{
set_stmt_errmsg(stmt, &mysql->net);
DBUG_RETURN(1);
@ -4748,6 +4748,13 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
MYSQL_DATA *result= &stmt->result;
DBUG_ENTER("mysql_stmt_store_result");
if (!mysql)
{
/* mysql can be reset in mysql_close called from mysql_reconnect */
set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate, NULL);
DBUG_RETURN(1);
}
mysql= mysql->last_used_con;
if (!stmt->field_count)
@ -4773,7 +4780,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
int4store(buff, stmt->stmt_id);
int4store(buff + 4, (int)~0); /* number of rows to fetch */
if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff),
(uchar*) 0, 0, 1, NULL))
(uchar*) 0, 0, 1, stmt))
{
set_stmt_errmsg(stmt, net);
DBUG_RETURN(1);
@ -4960,7 +4967,7 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags)
uchar buff[MYSQL_STMT_HEADER]; /* packet header: 4 bytes for stmt id */
int4store(buff, stmt->stmt_id);
if ((*mysql->methods->advanced_command)(mysql, COM_STMT_RESET, buff,
sizeof(buff), 0, 0, 0, NULL))
sizeof(buff), 0, 0, 0, stmt))
{
set_stmt_errmsg(stmt, &mysql->net);
stmt->state= MYSQL_STMT_INIT_DONE;

View File

@ -0,0 +1,56 @@
# include/connect2.inc
#
# SUMMARY
#
# Make several attempts to connect.
#
# USAGE
#
# EXAMPLE
#
# connect.test
#
--disable_query_log
let $wait_counter= 300;
if ($wait_timeout)
{
let $wait_counter= `SELECT $wait_timeout * 10`;
}
# Reset $wait_timeout so that its value won't be used on subsequent
# calls, and default will be used instead.
let $wait_timeout= 0;
--echo # -- Establishing connection '$con_name' (user: $con_user_name)...
while ($wait_counter)
{
--disable_abort_on_error
--disable_result_log
--connect ($con_name,localhost,$con_user_name)
--enable_result_log
--enable_abort_on_error
let $error = $mysql_errno;
if (!$error)
{
let $wait_counter= 0;
}
if ($error)
{
real_sleep 0.1;
dec $wait_counter;
}
}
if ($error)
{
--echo # -- Error: can not establish connection '$con_name'.
}
if (!$error)
{
--echo # -- Connection '$con_name' has been established.
}
--enable_query_log

View File

@ -115,3 +115,106 @@ create temporary table t2(id integer not null auto_increment primary key);
set @id := 1;
delete from t1 where id like @id;
drop table t1;
# ------------------------------------------------------------------
# -- End of 4.1 tests
# ------------------------------------------------------------------
# -- Bug#33507: Event scheduler creates more threads than max_connections
# -- which results in user lockout.
GRANT USAGE ON *.* TO mysqltest_u1@localhost;
SET GLOBAL max_connections = 3;
SET GLOBAL event_scheduler = ON;
# -- Waiting for Event Scheduler to start...
# -- Disconnecting default connection...
# -- Check that we allow exactly three user connections, no matter how
# -- many threads are running.
# -- Connecting (1)...
# -- Establishing connection 'con_1' (user: mysqltest_u1)...
# -- Connection 'con_1' has been established.
# -- Connecting (2)...
# -- Establishing connection 'con_2' (user: mysqltest_u1)...
# -- Connection 'con_2' has been established.
# -- Connecting (3)...
# -- Establishing connection 'con_3' (user: mysqltest_u1)...
# -- Connection 'con_3' has been established.
# -- Connecting (4) [should fail]...
# -- Establishing connection 'con_4' (user: mysqltest_u1)...
# -- Error: can not establish connection 'con_4'.
# -- Check that we allow one extra SUPER-user connection.
# -- Connecting super (1)...
# -- Establishing connection 'con_super_1' (user: root)...
# -- Connection 'con_super_1' has been established.
# -- Connecting super (2) [should fail]...
# -- Establishing connection 'con_super_2' (user: root)...
# -- Error: can not establish connection 'con_super_2'.
# -- Ensure that we have Event Scheduler thread, 3 ordinary user
# -- connections and one extra super-user connection.
SELECT user FROM information_schema.processlist ORDER BY id;
user
event_scheduler
mysqltest_u1
mysqltest_u1
mysqltest_u1
root
# -- Resetting variables...
SET GLOBAL max_connections = 151;
# -- Stopping Event Scheduler...
SET GLOBAL event_scheduler = OFF;
# -- Waiting for Event Scheduler to stop...
# -- That's it. Closing connections...
# -- Restoring default connection...
# -- Waiting for connections to close...
DROP USER mysqltest_u1@localhost;
# -- End of Bug#33507.
# -- Bug#35074: max_used_connections is not correct.
FLUSH STATUS;
SHOW STATUS LIKE 'max_used_connections';
Variable_name Value
Max_used_connections 1
# -- Starting Event Scheduler...
SET GLOBAL event_scheduler = ON;
# -- Waiting for Event Scheduler to start...
# -- Opening a new connection to check max_used_connections...
# -- Check that max_used_connections hasn't changed.
SHOW STATUS LIKE 'max_used_connections';
Variable_name Value
Max_used_connections 2
# -- Closing new connection...
# -- Stopping Event Scheduler...
SET GLOBAL event_scheduler = OFF;
# -- Waiting for Event Scheduler to stop...
# -- End of Bug#35074.
# ------------------------------------------------------------------
# -- End of 5.1 tests
# ------------------------------------------------------------------

View File

@ -1847,4 +1847,45 @@ DROP TABLE t3;
# -- End of Bug#18834.
# --
# -- Bug#34274: Invalid handling of 'DEFAULT 0' for YEAR data type.
# --
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(c1 YEAR DEFAULT 2008, c2 YEAR DEFAULT 0);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` year(4) DEFAULT '2008',
`c2` year(4) DEFAULT '0000'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES();
SELECT * FROM t1;
c1 c2
2008 0000
ALTER TABLE t1 MODIFY c1 YEAR DEFAULT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` year(4) DEFAULT '0000',
`c2` year(4) DEFAULT '0000'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES();
SELECT * FROM t1;
c1 c2
2008 0000
0000 0000
DROP TABLE t1;
# -- End of Bug#34274
End of 5.1 tests

View File

@ -91,4 +91,20 @@ create table mysql_test.`#sql-347f_7` (f1 int);
create table mysql_test.`#sql-347f_8` (f1 int);
drop table mysql_test.`#sql-347f_8`;
drop database mysql_test;
# --
# -- Bug#29958: Weird message on DROP DATABASE if mysql.proc does not
# -- exist.
# --
DROP DATABASE IF EXISTS mysql_test;
CREATE DATABASE mysql_test;
DROP TABLE mysql.proc;
DROP DATABASE mysql_test;
Warnings:
Error 1146 Table 'mysql.proc' doesn't exist
# --
# -- End of Bug#29958.
# --
End of 5.1 tests

View File

@ -1,3 +1,4 @@
set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
drop table if exists t1;
create table t1 (kill_id int);
@ -8,3 +9,4 @@ select ((@id := kill_id) - kill_id) from t1;
0
kill connection @id;
drop table t1;
set @@global.concurrent_insert= @old_concurrent_insert;

View File

@ -128,7 +128,7 @@ grant show view on v6 to testdb_2@localhost;
create table t2 (f1 char(4));
create definer=`no_such_user`@`no_such_host` view v7 as select * from t2;
Warnings:
Note 1449 There is no 'no_such_user'@'no_such_host' registered
Note 1449 The user specified as a definer ('no_such_user'@'no_such_host') does not exist
show fields from testdb_1.v6;
Field Type Null Key Default Extra
f1 char(4) YES NULL
@ -144,7 +144,7 @@ show fields from testdb_1.v7;
Field Type Null Key Default Extra
f1 char(4) YES NULL
Warnings:
Note 1449 There is no 'no_such_user'@'no_such_host' registered
Note 1449 The user specified as a definer ('no_such_user'@'no_such_host') does not exist
create table t3 (f1 char(4), f2 char(4));
create view v3 as select f1,f2 from t3;
grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
@ -164,7 +164,7 @@ show fields from testdb_1.v7;
Field Type Null Key Default Extra
f1 char(4) YES NULL
Warnings:
Note 1449 There is no 'no_such_user'@'no_such_host' registered
Note 1449 The user specified as a definer ('no_such_user'@'no_such_host') does not exist
show create view testdb_1.v7;
View Create View character_set_client collation_connection
v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2` latin1 latin1_swedish_ci

View File

@ -1,3 +1,4 @@
set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
drop table if exists t1, t2, t3;
create table t1 (kill_id int);
@ -137,3 +138,4 @@ KILL CONNECTION_ID();
# of close of the connection socket
SELECT 1;
Got one of the listed errors
set @@global.concurrent_insert= @old_concurrent_insert;

View File

@ -1650,6 +1650,16 @@ a (select count(*) from t2)
3 0
4 0
drop table t1,t2;
#
# Bug#25132 disabled query cache: Qcache_free_blocks = 1
#
set global query_cache_size=100000;
set global query_cache_size=0;
set global query_cache_type=0;
show status like 'Qcache_free_blocks';
Variable_name Value
Qcache_free_blocks 0
Restore default values.
set GLOBAL query_cache_type=default;
set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;

View File

@ -357,10 +357,10 @@ ERROR 42000: Access denied; you need the SUPER privilege for this operation
use mysqltest;
CREATE DEFINER='a @ b @ c'@localhost PROCEDURE wl2897_p3() SELECT 3;
Warnings:
Note 1449 There is no 'a @ b @ c'@'localhost' registered
Note 1449 The user specified as a definer ('a @ b @ c'@'localhost') does not exist
CREATE DEFINER='a @ b @ c'@localhost FUNCTION wl2897_f3() RETURNS INT RETURN 3;
Warnings:
Note 1449 There is no 'a @ b @ c'@'localhost' registered
Note 1449 The user specified as a definer ('a @ b @ c'@'localhost') does not exist
---> connection: con1root
use mysqltest;
@ -420,9 +420,9 @@ DROP USER mysqltest_1@localhost;
---> connection: mysqltest_2_con
use mysqltest;
CALL bug13198_p1();
ERROR HY000: There is no 'mysqltest_1'@'localhost' registered
ERROR HY000: The user specified as a definer ('mysqltest_1'@'localhost') does not exist
SELECT bug13198_f1();
ERROR HY000: There is no 'mysqltest_1'@'localhost' registered
ERROR HY000: The user specified as a definer ('mysqltest_1'@'localhost') does not exist
---> connection: root
DROP USER mysqltest_2@localhost;

View File

@ -1,3 +1,5 @@
set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
drop table if exists t1,t3;
drop procedure if exists bug4902|
create procedure bug4902()
@ -17,11 +19,11 @@ begin
show processlist;
end|
call bug4902_2()|
Id User Host db Command Time State Info
# root localhost test Query # NULL show processlist
show warnings|
Level Code Message
call bug4902_2()|
Id User Host db Command Time State Info
# root localhost test Query # NULL show processlist
show warnings|
Level Code Message
drop procedure bug4902_2|
drop table if exists t1|
create table t1 (
@ -68,7 +70,7 @@ c
2
show status like 'Qcache_hits'|
Variable_name Value
Qcache_hits 2
Qcache_hits 0
set global query_cache_size = @x|
flush status|
flush query cache|
@ -208,3 +210,27 @@ GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
drop user mysqltest_1@localhost;
drop procedure 15298_1;
drop procedure 15298_2;
drop table if exists t1;
drop procedure if exists p1;
create table t1 (value varchar(15));
create procedure p1() update t1 set value='updated' where value='old';
call p1();
insert into t1 (value) values ("old");
select get_lock('b26162',120);
get_lock('b26162',120)
1
select 'rl_acquirer', value from t1 where get_lock('b26162',120);;
set session low_priority_updates=on;
call p1();;
select 'rl_contender', value from t1;
rl_contender value
rl_contender old
select release_lock('b26162');
release_lock('b26162')
1
rl_acquirer value
rl_acquirer old
drop procedure p1;
drop table t1;
set session low_priority_updates=default;
set @@global.concurrent_insert= @old_concurrent_insert;

View File

@ -140,4 +140,23 @@ select * from t3;
c
1
drop table t1, t2, t3;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE t2(b INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=innodb;
INSERT INTO t1 VALUES (1);
CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW SET @a = 1;
CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW SET @b = 1;
SET @a = 0;
SET @b = 0;
TRUNCATE t1;
SELECT @a, @b;
@a @b
0 0
INSERT INTO t1 VALUES (1);
DELETE FROM t1;
SELECT @a, @b;
@a @b
1 1
DROP TABLE t2, t1;
End of 5.0 tests

View File

@ -133,9 +133,9 @@ CREATE DEFINER='mysqltest_nonexs'@'localhost'
FOR EACH ROW
SET @new_sum = 0;
Warnings:
Note 1449 There is no 'mysqltest_nonexs'@'localhost' registered
Note 1449 The user specified as a definer ('mysqltest_nonexs'@'localhost') does not exist
INSERT INTO t1 VALUES(6);
ERROR HY000: There is no 'mysqltest_nonexs'@'localhost' registered
ERROR HY000: The user specified as a definer ('mysqltest_nonexs'@'localhost') does not exist
SHOW TRIGGERS;
Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
trg1 INSERT t1 SET @new_sum = 0 BEFORE NULL mysqltest_inv@localhost latin1 latin1_swedish_ci latin1_swedish_ci

View File

@ -515,10 +515,10 @@ drop user mysqltest_1@localhost;
drop database mysqltest;
create definer=some_user@`` sql security invoker view v1 as select 1;
Warnings:
Note 1449 There is no 'some_user'@'' registered
Note 1449 The user specified as a definer ('some_user'@'') does not exist
create definer=some_user@localhost sql security invoker view v2 as select 1;
Warnings:
Note 1449 There is no 'some_user'@'localhost' registered
Note 1449 The user specified as a definer ('some_user'@'localhost') does not exist
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` latin1 latin1_swedish_ci
@ -601,14 +601,14 @@ CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE DEFINER = 'no-such-user'@localhost VIEW v AS SELECT a from t1;
Warnings:
Note 1449 There is no 'no-such-user'@'localhost' registered
Note 1449 The user specified as a definer ('no-such-user'@'localhost') does not exist
SHOW CREATE VIEW v;
View Create View character_set_client collation_connection
v CREATE ALGORITHM=UNDEFINED DEFINER=`no-such-user`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `test`.`t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
SELECT * FROM v;
ERROR HY000: There is no 'no-such-user'@'localhost' registered
ERROR HY000: The user specified as a definer ('no-such-user'@'localhost') does not exist
DROP VIEW v;
DROP TABLE t1;
USE test;
@ -722,7 +722,7 @@ SELECT * FROM v1;
ERROR 42000: SELECT command denied to user 'inv_17254'@'localhost' for table 'v1'
for a superuser
SELECT * FROM v1;
ERROR HY000: There is no 'def_17254'@'localhost' registered
ERROR HY000: The user specified as a definer ('def_17254'@'localhost') does not exist
DROP USER inv_17254@localhost;
DROP DATABASE db17254;
DROP DATABASE IF EXISTS mysqltest_db1;
@ -932,7 +932,7 @@ View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1;
Warnings:
Note 1449 There is no 'no_such'@'user_1' registered
Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
@ -940,7 +940,7 @@ Warnings:
Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
Warnings:
Note 1449 There is no 'no_such'@'user_1' registered
Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
@ -948,7 +948,7 @@ Warnings:
Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1;
Warnings:
Note 1449 There is no 'no_such'@'user_2' registered
Note 1449 The user specified as a definer ('no_such'@'user_2') does not exist
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`no_such`@`user_2` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci

View File

@ -102,4 +102,192 @@ disconnect con7;
connection default;
drop table t1;
# End of 4.1 tests
--disconnect con1
--disconnect con2
--disconnect con3
--disconnect con4
--disconnect con5
--disconnect con6
--disconnect con10
--echo # ------------------------------------------------------------------
--echo # -- End of 4.1 tests
--echo # ------------------------------------------------------------------
###########################################################################
--echo
--echo # -- Bug#33507: Event scheduler creates more threads than max_connections
--echo # -- which results in user lockout.
--echo
GRANT USAGE ON *.* TO mysqltest_u1@localhost;
# NOTE: if the test case fails sporadically due to spurious connections,
# consider disabling all users.
--echo
let $saved_max_connections = `SELECT @@global.max_connections`;
SET GLOBAL max_connections = 3;
SET GLOBAL event_scheduler = ON;
--echo
--echo # -- Waiting for Event Scheduler to start...
let $wait_condition =
SELECT COUNT(*) = 1
FROM information_schema.processlist
WHERE user = 'event_scheduler';
--source include/wait_condition.inc
--echo
--echo # -- Disconnecting default connection...
--disconnect default
--echo
--echo # -- Check that we allow exactly three user connections, no matter how
--echo # -- many threads are running.
--echo
--echo # -- Connecting (1)...
let $con_name = con_1;
let $con_user_name = mysqltest_u1;
--source include/connect2.inc
--echo
--echo # -- Connecting (2)...
let $con_name = con_2;
let $con_user_name = mysqltest_u1;
--source include/connect2.inc
--echo
--echo # -- Connecting (3)...
let $con_name = con_3;
let $con_user_name = mysqltest_u1;
--source include/connect2.inc
--echo
--echo # -- Connecting (4) [should fail]...
let $con_name = con_4;
let $con_user_name = mysqltest_u1;
let $wait_timeout = 5;
--source include/connect2.inc
--echo
--echo # -- Check that we allow one extra SUPER-user connection.
--echo
--echo # -- Connecting super (1)...
let $con_name = con_super_1;
let $con_user_name = root;
--source include/connect2.inc
--echo
--echo # -- Connecting super (2) [should fail]...
let $con_name = con_super_2;
let $con_user_name = root;
let $wait_timeout = 5;
--source include/connect2.inc
--echo
--echo # -- Ensure that we have Event Scheduler thread, 3 ordinary user
--echo # -- connections and one extra super-user connection.
SELECT user FROM information_schema.processlist ORDER BY id;
--echo
--echo # -- Resetting variables...
--eval SET GLOBAL max_connections = $saved_max_connections
--echo
--echo # -- Stopping Event Scheduler...
SET GLOBAL event_scheduler = OFF;
--echo
--echo # -- Waiting for Event Scheduler to stop...
let $wait_condition =
SELECT COUNT(*) = 0
FROM information_schema.processlist
WHERE user = 'event_scheduler';
--source include/wait_condition.inc
--echo
--echo # -- That's it. Closing connections...
--disconnect con_1
--disconnect con_2
--disconnect con_3
--disconnect con_super_1
--echo
--echo # -- Restoring default connection...
--connect (default,localhost,root,,test)
--echo
--echo # -- Waiting for connections to close...
let $wait_condition =
SELECT COUNT(*) = 1
FROM information_schema.processlist
WHERE db = 'test';
--source include/wait_condition.inc
--echo
DROP USER mysqltest_u1@localhost;
--echo
--echo # -- End of Bug#33507.
--echo
###########################################################################
--echo # -- Bug#35074: max_used_connections is not correct.
--echo
FLUSH STATUS;
--echo
SHOW STATUS LIKE 'max_used_connections';
--echo
--echo # -- Starting Event Scheduler...
SET GLOBAL event_scheduler = ON;
--echo # -- Waiting for Event Scheduler to start...
let $wait_condition =
SELECT COUNT(*) = 1
FROM information_schema.processlist
WHERE user = 'event_scheduler';
--source include/wait_condition.inc
# NOTE: We should use a new connection here instead of reconnect in order to
# avoid races (we can not for sure when the connection being disconnected is
# actually disconnected on the server).
--echo
--echo # -- Opening a new connection to check max_used_connections...
--connect (con_1,localhost,root)
--echo
--echo # -- Check that max_used_connections hasn't changed.
SHOW STATUS LIKE 'max_used_connections';
--echo
--echo # -- Closing new connection...
--disconnect con_1
--connection default
--echo
--echo # -- Stopping Event Scheduler...
SET GLOBAL event_scheduler = OFF;
--echo # -- Waiting for Event Scheduler to stop...
let $wait_condition =
SELECT COUNT(*) = 0
FROM information_schema.processlist
WHERE user = 'event_scheduler';
--source include/wait_condition.inc
--echo
--echo # -- End of Bug#35074.
--echo
--echo # ------------------------------------------------------------------
--echo # -- End of 5.1 tests
--echo # ------------------------------------------------------------------

View File

@ -1365,6 +1365,8 @@ create table t1 like information_schema.character_sets;
show create table t1;
drop table t1;
###########################################################################
--echo
--echo # --
--echo # -- Bug#21380: DEFAULT definition not always transfered by CREATE
@ -1407,8 +1409,10 @@ DROP TABLE t2;
--echo
--echo # -- End of test case for Bug#21380.
--echo
###########################################################################
--echo
--echo # --
--echo # -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields
--echo # --
@ -1471,6 +1475,50 @@ DROP TABLE t3;
--echo
--echo # -- End of Bug#18834.
###########################################################################
--echo
--echo # --
--echo # -- Bug#34274: Invalid handling of 'DEFAULT 0' for YEAR data type.
--echo # --
--echo
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--echo
CREATE TABLE t1(c1 YEAR DEFAULT 2008, c2 YEAR DEFAULT 0);
--echo
SHOW CREATE TABLE t1;
--echo
INSERT INTO t1 VALUES();
--echo
SELECT * FROM t1;
--echo
ALTER TABLE t1 MODIFY c1 YEAR DEFAULT 0;
--echo
SHOW CREATE TABLE t1;
--echo
INSERT INTO t1 VALUES();
--echo
SELECT * FROM t1;
--echo
DROP TABLE t1;
--echo
--echo # -- End of Bug#34274
###########################################################################
--echo
--echo End of 5.1 tests

View File

@ -134,4 +134,38 @@ drop table mysql_test.`#sql-347f_8`;
copy_file $MYSQLTEST_VARDIR/master-data/mysql_test/t1.frm $MYSQLTEST_VARDIR/master-data/mysql_test/#sql-347f_6.frm;
drop database mysql_test;
###########################################################################
--echo
--echo # --
--echo # -- Bug#29958: Weird message on DROP DATABASE if mysql.proc does not
--echo # -- exist.
--echo # --
--disable_warnings
DROP DATABASE IF EXISTS mysql_test;
--enable_warnings
CREATE DATABASE mysql_test;
--copy_file $MYSQLTEST_VARDIR/master-data/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/bug29958.proc.frm
--copy_file $MYSQLTEST_VARDIR/master-data/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYD
--copy_file $MYSQLTEST_VARDIR/master-data/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYI
DROP TABLE mysql.proc;
DROP DATABASE mysql_test;
--copy_file $MYSQLTEST_VARDIR/tmp/bug29958.proc.frm $MYSQLTEST_VARDIR/master-data/mysql/proc.frm
--copy_file $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYD $MYSQLTEST_VARDIR/master-data/mysql/proc.MYD
--copy_file $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYI $MYSQLTEST_VARDIR/master-data/mysql/proc.MYI
--echo
--echo # --
--echo # -- End of Bug#29958.
--echo # --
###########################################################################
--echo
--echo End of 5.1 tests

View File

@ -14,6 +14,7 @@
# Disable concurrent inserts to avoid test failures when reading the
# connection id which was inserted into a table by another thread.
set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
connect (con1,localhost,root,,);
@ -58,3 +59,7 @@ reap;
connection con2;
drop table t1;
connection default;
# Restore global concurrent_insert value
set @@global.concurrent_insert= @old_concurrent_insert;

View File

@ -8,6 +8,7 @@
# Disable concurrent inserts to avoid test failures when reading the
# connection id which was inserted into a table by another thread.
set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
connect (con1, localhost, root,,);
@ -326,3 +327,9 @@ KILL CONNECTION_ID();
--echo # of close of the connection socket
--error 2013, 2006
SELECT 1;
--connection default
###########################################################################
# Restore global concurrent_insert value. Keep in the end of the test file.
set @@global.concurrent_insert= @old_concurrent_insert;

View File

@ -1251,6 +1251,15 @@ disconnect user2;
disconnect user3;
#
--echo #
--echo # Bug#25132 disabled query cache: Qcache_free_blocks = 1
--echo #
set global query_cache_size=100000;
set global query_cache_size=0;
set global query_cache_type=0;
show status like 'Qcache_free_blocks';
--echo Restore default values.
# Bug #28211 RENAME DATABASE and query cache don't play nicely together
#
# TODO: enable these tests when RENAME DATABASE is implemented.

View File

@ -1,7 +1,9 @@
# Can't test with embedded server
-- source include/not_embedded.inc
# Disable concurrent inserts to avoid test failures
set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
--sleep 2
--disable_warnings
drop table if exists t1,t3;
--enable_warnings
@ -39,10 +41,14 @@ create procedure bug4902_2()
begin
show processlist;
end|
--replace_column 1 # 6 # 3 localhost
--disable_result_log
call bug4902_2()|
--replace_column 1 # 6 # 3 localhost
--enable_result_log
show warnings|
--disable_result_log
call bug4902_2()|
--enable_result_log
show warnings|
drop procedure bug4902_2|
#
@ -268,69 +274,72 @@ drop procedure 15298_1;
drop procedure 15298_2;
#
# Test case disabled due to Bug#34891: sp_notembedded.test fails sporadically.
# Bug#29936 Stored Procedure DML ignores low_priority_updates setting
#
# #
# # Bug#29936 Stored Procedure DML ignores low_priority_updates setting
# #
--disable_warnings
drop table if exists t1;
drop procedure if exists p1;
--enable_warnings
create table t1 (value varchar(15));
create procedure p1() update t1 set value='updated' where value='old';
# load the procedure into sp cache and execute once
call p1();
insert into t1 (value) values ("old");
connect (rl_holder, localhost, root,,);
connect (rl_acquirer, localhost, root,,);
connect (rl_contender, localhost, root,,);
connect (rl_wait, localhost, root,,);
connection rl_holder;
select get_lock('b26162',120);
connection rl_acquirer;
--send select 'rl_acquirer', value from t1 where get_lock('b26162',120);
# we must wait till this select opens and locks the tables
connection rl_wait;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "User lock" and
info = "select 'rl_acquirer', value from t1 where get_lock('b26162',120)";
--source include/wait_condition.inc
connection default;
set session low_priority_updates=on;
--send call p1();
connection rl_wait;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and
info = "update t1 set value='updated' where value='old'";
--source include/wait_condition.inc
connection rl_contender;
select 'rl_contender', value from t1;
connection rl_holder;
select release_lock('b26162');
connection rl_acquirer;
--reap
connection default;
--reap
disconnect rl_holder;
disconnect rl_acquirer;
disconnect rl_wait;
drop procedure p1;
drop table t1;
set session low_priority_updates=default;
#
# --disable_warnings
# drop table if exists t1;
# drop procedure if exists p1;
# --enable_warnings
# Restore global concurrent_insert value. Keep in the end of the test file.
#
# create table t1 (value varchar(15));
# create procedure p1() update t1 set value='updated' where value='old';
#
# # load the procedure into sp cache and execute once
# call p1();
#
# insert into t1 (value) values ("old");
#
# connect (rl_holder, localhost, root,,);
# connect (rl_acquirer, localhost, root,,);
# connect (rl_contender, localhost, root,,);
# connect (rl_wait, localhost, root,,);
#
# connection rl_holder;
# select get_lock('b26162',120);
#
# connection rl_acquirer;
# --send select 'rl_acquirer', value from t1 where get_lock('b26162',120);
#
# # we must wait till this select opens and locks the tables
# connection rl_wait;
# let $wait_condition=
# select count(*) = 1 from information_schema.processlist
# where state = "User lock" and
# info = "select 'rl_acquirer', value from t1 where get_lock('b26162',120)";
# --source include/wait_condition.inc
#
# connection default;
# set session low_priority_updates=on;
# --send call p1();
#
# connection rl_wait;
# let $wait_condition=
# select count(*) = 1 from information_schema.processlist
# where state = "Locked" and
# info = "update t1 set value='updated' where value='old'";
# --source include/wait_condition.inc
#
# connection rl_contender;
# select 'rl_contender', value from t1;
#
# connection rl_holder;
# select release_lock('b26162');
#
# connection rl_acquirer;
# --reap
# connection default;
# --reap
#
# disconnect rl_holder;
# disconnect rl_acquirer;
# disconnect rl_wait;
# drop procedure p1;
# drop table t1;
# set session low_priority_updates=default;
set @@global.concurrent_insert= @old_concurrent_insert;

View File

@ -128,5 +128,37 @@ drop table t1, t2, t3;
disconnect connection_update;
disconnect connection_aux;
#
# Bug#34643: TRUNCATE crash if trigger and foreign key.
#
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
--enable_warnings
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE t2(b INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=innodb;
INSERT INTO t1 VALUES (1);
CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW SET @a = 1;
CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW SET @b = 1;
SET @a = 0;
SET @b = 0;
TRUNCATE t1;
SELECT @a, @b;
INSERT INTO t1 VALUES (1);
DELETE FROM t1;
SELECT @a, @b;
DROP TABLE t2, t1;
--echo End of 5.0 tests

View File

@ -46,7 +46,7 @@ static uint calc_hash(const HASH *hash, const uchar *key, size_t length)
}
my_bool
_hash_init(HASH *hash,CHARSET_INFO *charset,
_hash_init(HASH *hash,uint growth_size, CHARSET_INFO *charset,
ulong size, size_t key_offset, size_t key_length,
hash_get_key get_key,
void (*free_element)(void*),uint flags CALLER_INFO_PROTO)
@ -55,7 +55,8 @@ _hash_init(HASH *hash,CHARSET_INFO *charset,
DBUG_PRINT("enter",("hash: 0x%lx size: %u", (long) hash, (uint) size));
hash->records=0;
if (my_init_dynamic_array_ci(&hash->array,sizeof(HASH_LINK),size,0))
if (my_init_dynamic_array_ci(&hash->array, sizeof(HASH_LINK), size,
growth_size))
{
hash->free=0; /* Allow call to hash_free */
DBUG_RETURN(1);

View File

@ -695,6 +695,16 @@ cli_safe_read(MYSQL *mysql)
strmake(net->sqlstate, pos+1, SQLSTATE_LENGTH);
pos+= SQLSTATE_LENGTH+1;
}
else
{
/*
The SQL state hasn't been received -- it should be reset to HY000
(unknown error sql state).
*/
strmov(net->sqlstate, unknown_sqlstate);
}
(void) strmake(net->last_error,(char*) pos,
min((uint) len,(uint) sizeof(net->last_error)-1));
}
@ -733,11 +743,12 @@ my_bool
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const uchar *header, ulong header_length,
const uchar *arg, ulong arg_length, my_bool skip_check,
MYSQL_STMT *stmt __attribute__((unused)))
MYSQL_STMT *stmt)
{
NET *net= &mysql->net;
my_bool result= 1;
init_sigpipe_variables
my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE;
DBUG_ENTER("cli_advanced_command");
/* Don't give sigpipe errors if the client doesn't want them */
@ -745,7 +756,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
if (mysql->net.vio == 0)
{ /* Do reconnect if possible */
if (mysql_reconnect(mysql))
if (mysql_reconnect(mysql) || stmt_skip)
DBUG_RETURN(1);
}
if (mysql->status != MYSQL_STATUS_READY ||
@ -777,7 +788,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
goto end;
}
end_server(mysql);
if (mysql_reconnect(mysql))
if (mysql_reconnect(mysql) || stmt_skip)
goto end;
if (net_write_command(net,(uchar) command, header, header_length,
arg, arg_length))
@ -1911,7 +1922,13 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
(int) have_tcpip));
if (mysql->options.protocol == MYSQL_PROTOCOL_MEMORY)
goto error;
/* Try also with PIPE or TCP/IP */
/*
Try also with PIPE or TCP/IP. Clear the error from
create_shared_memory().
*/
net_clear_error(net);
}
else
{
@ -2521,6 +2538,9 @@ my_bool mysql_reconnect(MYSQL *mysql)
if (stmt->state != MYSQL_STMT_INIT_DONE)
{
stmt->mysql= 0;
stmt->last_errno= CR_SERVER_LOST;
strmov(stmt->last_error, ER(CR_SERVER_LOST));
strmov(stmt->sqlstate, unknown_sqlstate);
}
else
{

View File

@ -975,8 +975,6 @@ void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
void decrease_user_connections(USER_CONN *uc);
void thd_init_client_charset(THD *thd, uint cs_number);
bool setup_connection_thread_globals(THD *thd);
bool login_connection(THD *thd);
void end_connection(THD *thd);
bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
@ -1897,6 +1895,7 @@ extern bool opt_disable_networking, opt_skip_show_db;
extern my_bool opt_character_set_client_handshake;
extern bool volatile abort_loop, shutdown_in_progress;
extern uint volatile thread_count, thread_running, global_read_lock;
extern uint connection_count;
extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
extern my_bool opt_slave_compressed_protocol, use_temp_pool;
@ -1935,7 +1934,7 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db,
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
LOCK_global_system_variables, LOCK_user_conn,
LOCK_prepared_stmt_count,
LOCK_bytes_sent, LOCK_bytes_received;
LOCK_bytes_sent, LOCK_bytes_received, LOCK_connection_count;
#ifdef HAVE_OPENSSL
extern pthread_mutex_t LOCK_des_key_file;
#endif

View File

@ -585,7 +585,8 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count,
LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create,
LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
LOCK_global_system_variables,
LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
LOCK_connection_count;
/**
The below lock protects access to two global server variables:
max_prepared_stmt_count and prepared_stmt_count. These variables
@ -721,6 +722,11 @@ char *des_key_file;
struct st_VioSSLFd *ssl_acceptor_fd;
#endif /* HAVE_OPENSSL */
/**
Number of currently active user connections. The variable is protected by
LOCK_connection_count.
*/
uint connection_count= 0;
/* Function declarations */
@ -1342,6 +1348,7 @@ static void clean_up_mutexes()
(void) pthread_mutex_destroy(&LOCK_bytes_sent);
(void) pthread_mutex_destroy(&LOCK_bytes_received);
(void) pthread_mutex_destroy(&LOCK_user_conn);
(void) pthread_mutex_destroy(&LOCK_connection_count);
Events::destroy_mutexes();
#ifdef HAVE_OPENSSL
(void) pthread_mutex_destroy(&LOCK_des_key_file);
@ -1784,6 +1791,11 @@ void unlink_thd(THD *thd)
DBUG_ENTER("unlink_thd");
DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
thd->cleanup();
pthread_mutex_lock(&LOCK_connection_count);
--connection_count;
pthread_mutex_unlock(&LOCK_connection_count);
(void) pthread_mutex_lock(&LOCK_thread_count);
thread_count--;
delete thd;
@ -3452,6 +3464,7 @@ static int init_thread_environment()
(void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_prepared_stmt_count, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_uuid_generator, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_connection_count, MY_MUTEX_INIT_FAST);
#ifdef HAVE_OPENSSL
(void) pthread_mutex_init(&LOCK_des_key_file,MY_MUTEX_INIT_FAST);
#ifndef HAVE_YASSL
@ -4699,6 +4712,11 @@ void create_thread_to_handle_connection(THD *thd)
thread_count--;
thd->killed= THD::KILL_CONNECTION; // Safety
(void) pthread_mutex_unlock(&LOCK_thread_count);
pthread_mutex_lock(&LOCK_connection_count);
--connection_count;
pthread_mutex_unlock(&LOCK_connection_count);
statistic_increment(aborted_connects,&LOCK_status);
/* Can't use my_error() since store_globals has not been called. */
my_snprintf(error_message_buff, sizeof(error_message_buff),
@ -4738,15 +4756,34 @@ static void create_new_thread(THD *thd)
if (protocol_version > 9)
net->return_errno=1;
/* don't allow too many connections */
if (thread_count - delayed_insert_threads >= max_connections+1 || abort_loop)
/*
Don't allow too many connections. We roughly check here that we allow
only (max_connections + 1) connections.
*/
pthread_mutex_lock(&LOCK_connection_count);
if (connection_count >= max_connections + 1 || abort_loop)
{
pthread_mutex_unlock(&LOCK_connection_count);
DBUG_PRINT("error",("Too many connections"));
close_connection(thd, ER_CON_COUNT_ERROR, 1);
delete thd;
DBUG_VOID_RETURN;
}
++connection_count;
if (connection_count > max_used_connections)
max_used_connections= connection_count;
pthread_mutex_unlock(&LOCK_connection_count);
/* Start a new thread to handle connection. */
pthread_mutex_lock(&LOCK_thread_count);
/*
The initialization of thread_id is done in create_embedded_thd() for
the embedded library.
@ -4754,13 +4791,10 @@ static void create_new_thread(THD *thd)
*/
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
/* Start a new thread to handle connection */
thread_count++;
if (thread_count - delayed_insert_threads > max_used_connections)
max_used_connections= thread_count - delayed_insert_threads;
thread_scheduler.add_connection(thd);
DBUG_VOID_RETURN;
}
#endif /* EMBEDDED_LIBRARY */

View File

@ -5584,8 +5584,7 @@ ER_VIEW_OTHER_USER
eng "You need the SUPER privilege for creation view with '%-.192s'@'%-.192s' definer"
ger "Sie brauchen die SUPER-Berechtigung, um einen View mit dem Definierer '%-.192s'@'%-.192s' zu erzeugen"
ER_NO_SUCH_USER
eng "There is no '%-.64s'@'%-.64s' registered"
ger "'%-.64s'@'%-.64s' ist nicht registriert"
eng "The user specified as a definer ('%-.64s'@'%-.64s') does not exist"
ER_FORBID_SCHEMA_CHANGE
eng "Changing schema from '%-.192s' to '%-.192s' is not allowed."
ger "Wechsel des Schemas von '%-.192s' auf '%-.192s' ist nicht erlaubt"

View File

@ -2287,7 +2287,7 @@ GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u,
const char *t, ulong p, ulong c)
:GRANT_NAME(h,d,u,t,p), cols(c)
{
(void) hash_init(&hash_columns,system_charset_info,
(void) hash_init2(&hash_columns,4,system_charset_info,
0,0,0, (hash_get_key) get_key_column,0,0);
}
@ -2335,7 +2335,7 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
cols= (ulong) form->field[7]->val_int();
cols = fix_rights_for_column(cols);
(void) hash_init(&hash_columns,system_charset_info,
(void) hash_init2(&hash_columns,4,system_charset_info,
0,0,0, (hash_get_key) get_key_column,0,0);
if (cols)
{

View File

@ -1998,6 +1998,7 @@ void Query_cache::make_disabled()
query_cache_size= 0;
queries_blocks= 0;
free_memory= 0;
free_memory_blocks= 0;
bins= 0;
steps= 0;
cache= 0;

View File

@ -395,8 +395,11 @@ Diagnostics_area::set_ok_status(THD *thd, ha_rows affected_rows_arg,
{
DBUG_ASSERT(! is_set());
#ifdef DBUG_OFF
/* In production, refuse to overwrite an error with an OK packet. */
if (is_error())
/*
In production, refuse to overwrite an error or a custom response
with an OK packet.
*/
if (is_error() || is_disabled())
return;
#endif
/** Only allowed to report success if has not yet reported an error */
@ -424,8 +427,11 @@ Diagnostics_area::set_eof_status(THD *thd)
DBUG_ASSERT(! is_set());
#ifdef DBUG_OFF
/* In production, refuse to overwrite an error with an EOF packet. */
if (is_error())
/*
In production, refuse to overwrite an error or a custom response
with an EOF packet.
*/
if (is_error() || is_disabled())
return;
#endif
@ -454,6 +460,14 @@ Diagnostics_area::set_error_status(THD *thd, uint sql_errno_arg,
an error can happen during the flush.
*/
DBUG_ASSERT(! is_set() || can_overwrite_status);
#ifdef DBUG_OFF
/*
In production, refuse to overwrite a custom response with an
ERROR packet.
*/
if (is_disabled())
return;
#endif
m_sql_errno= sql_errno_arg;
strmake(m_message, message_arg, sizeof(m_message) - 1);

View File

@ -402,10 +402,11 @@ check_user(THD *thd, enum enum_server_command command,
if (check_count)
{
VOID(pthread_mutex_lock(&LOCK_thread_count));
bool count_ok= thread_count <= max_connections + delayed_insert_threads
|| (thd->main_security_ctx.master_access & SUPER_ACL);
VOID(pthread_mutex_unlock(&LOCK_thread_count));
pthread_mutex_lock(&LOCK_connection_count);
bool count_ok= connection_count <= max_connections ||
(thd->main_security_ctx.master_access & SUPER_ACL);
VOID(pthread_mutex_unlock(&LOCK_connection_count));
if (!count_ok)
{ // too many connections
my_error(ER_CON_COUNT_ERROR, MYF(0));
@ -930,7 +931,7 @@ bool setup_connection_thread_globals(THD *thd)
*/
bool login_connection(THD *thd)
static bool login_connection(THD *thd)
{
NET *net= &thd->net;
int error;
@ -968,7 +969,7 @@ bool login_connection(THD *thd)
This mainly updates status variables
*/
void end_connection(THD *thd)
static void end_connection(THD *thd)
{
NET *net= &thd->net;
plugin_thdvar_cleanup(thd);

View File

@ -45,6 +45,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
bool transactional_table, safe_update, const_cond;
bool const_cond_result;
ha_rows deleted= 0;
bool triggers_applicable;
uint usable_index= MAX_KEY;
SELECT_LEX *select_lex= &thd->lex->select_lex;
THD::killed_state killed_status= THD::NOT_KILLED;
@ -102,6 +103,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
/* Error evaluating val_int(). */
DBUG_RETURN(TRUE);
}
/*
Test if the user wants to delete all rows and deletion doesn't have
any side-effects (because of triggers), so we can use optimized
@ -249,7 +251,13 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
init_ftfuncs(thd, select_lex, 1);
thd_proc_info(thd, "updating");
if (table->triggers &&
/* NOTE: TRUNCATE must not invoke triggers. */
triggers_applicable= table->triggers &&
thd->lex->sql_command != SQLCOM_TRUNCATE;
if (triggers_applicable &&
table->triggers->has_triggers(TRG_EVENT_DELETE,
TRG_ACTION_AFTER))
{
@ -274,7 +282,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (!(select && select->skip_record())&& ! thd->is_error() )
{
if (table->triggers &&
if (triggers_applicable &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_BEFORE, FALSE))
{
@ -285,7 +293,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (!(error= table->file->ha_delete_row(table->record[0])))
{
deleted++;
if (table->triggers &&
if (triggers_applicable &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_AFTER, FALSE))
{

View File

@ -2555,6 +2555,8 @@ void mysql_stmt_close(THD *thd, char *packet)
Prepared_statement *stmt;
DBUG_ENTER("mysql_stmt_close");
thd->main_da.disable_status();
if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_close")))
DBUG_VOID_RETURN;
@ -2566,8 +2568,6 @@ void mysql_stmt_close(THD *thd, char *packet)
(void) stmt->deallocate();
general_log_print(thd, thd->command, NullS);
thd->main_da.disable_status();
DBUG_VOID_RETURN;
}

View File

@ -979,9 +979,7 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
type= (Field::utype) MTYP_TYPENR(field->unireg_check);
if (field->def &&
(regfield->real_type() != MYSQL_TYPE_YEAR ||
field->def->val_int() != 0))
if (field->def)
{
int res= field->def->save_in_field(regfield, 1);
/* If not ok or warning of level 'note' */

View File

@ -181,7 +181,6 @@ struct TsmanChunk
Vector<Uint32> bitmask;
};
template class Vector<TsmanChunk>;
template class Vector<Uint32>;
#endif
void

View File

@ -12016,6 +12016,7 @@ static void test_bug5194()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
mysql_stmt_reset(stmt);
}
mysql_stmt_close(stmt);
@ -13232,6 +13233,40 @@ static void test_bug15518()
}
static void disable_general_log()
{
int rc;
rc= mysql_query(mysql, "set @@global.general_log=off");
myquery(rc);
}
static void enable_general_log(int truncate)
{
int rc;
rc= mysql_query(mysql, "set @save_global_general_log=@@global.general_log");
myquery(rc);
rc= mysql_query(mysql, "set @@global.general_log=on");
myquery(rc);
if (truncate)
{
rc= mysql_query(mysql, "truncate mysql.general_log");
myquery(rc);
}
}
static void restore_general_log()
{
int rc;
rc= mysql_query(mysql, "set @@global.general_log=@save_global_general_log");
myquery(rc);
}
static void test_view_sp_list_fields()
{
int rc;
@ -15396,6 +15431,8 @@ static void test_bug17667()
return;
}
enable_general_log(1);
for (statement_cursor= statements; statement_cursor->buffer != NULL;
statement_cursor++)
{
@ -15474,6 +15511,8 @@ static void test_bug17667()
statement_cursor->buffer);
}
restore_general_log();
if (!opt_silent)
printf("success. All queries found intact in the log.\n");
@ -16610,80 +16649,6 @@ static void test_bug27592()
DBUG_VOID_RETURN;
}
static void test_bug29948()
{
MYSQL *dbc=NULL;
MYSQL_STMT *stmt=NULL;
MYSQL_BIND bind;
int res=0;
my_bool auto_reconnect=1, error=0, is_null=0;
char kill_buf[20];
const char *query;
int buf;
unsigned long length, cursor_type;
dbc = mysql_init(NULL);
DIE_UNLESS(dbc);
mysql_options(dbc, MYSQL_OPT_RECONNECT, (char*)&auto_reconnect);
if (!mysql_real_connect(dbc, opt_host, opt_user,
opt_password, current_db, opt_port,
opt_unix_socket,
(CLIENT_FOUND_ROWS | CLIENT_MULTI_STATEMENTS |
CLIENT_MULTI_RESULTS)))
{
printf("connection failed: %s (%d)", mysql_error(dbc),
mysql_errno(dbc));
exit(1);
}
bind.buffer_type= MYSQL_TYPE_LONG;
bind.buffer= (char *)&buf;
bind.is_null= &is_null;
bind.error= &error;
bind.length= &length;
res= mysql_query(dbc, "DROP TABLE IF EXISTS t1");
myquery(res);
res= mysql_query(dbc, "CREATE TABLE t1 (a INT)");
myquery(res);
res= mysql_query(dbc, "INSERT INTO t1 VALUES(1)");
myquery(res);
stmt= mysql_stmt_init(dbc);
check_stmt(stmt);
cursor_type= CURSOR_TYPE_READ_ONLY;
res= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void *)&cursor_type);
myquery(res);
query= "SELECT * from t1 where a=?";
res= mysql_stmt_prepare(stmt, query, strlen(query));
myquery(res);
res= mysql_stmt_bind_param(stmt, &bind);
myquery(res);
res= mysql_stmt_execute(stmt);
check_execute(stmt, res);
res= mysql_stmt_bind_result(stmt,&bind);
check_execute(stmt, res);
sprintf(kill_buf, "kill %ld", dbc->thread_id);
mysql_query(dbc, kill_buf);
res= mysql_stmt_store_result(stmt);
DIE_UNLESS(res);
mysql_stmt_free_result(stmt);
mysql_stmt_close(stmt);
mysql_query(dbc, "DROP TABLE t1");
mysql_close(dbc);
}
/*
Bug#29687 mysql_stmt_store_result memory leak in libmysqld
*/
@ -17374,14 +17339,7 @@ static void test_bug28386()
}
mysql_free_result(result);
rc= mysql_query(mysql, "set @save_global_general_log=@@global.general_log");
myquery(rc);
rc= mysql_query(mysql, "set @@global.general_log=on");
myquery(rc);
rc= mysql_query(mysql, "truncate mysql.general_log");
myquery(rc);
enable_general_log(1);
stmt= mysql_simple_prepare(mysql, "SELECT ?");
check_stmt(stmt);
@ -17420,8 +17378,7 @@ static void test_bug28386()
mysql_free_result(result);
rc= mysql_query(mysql, "set @@global.general_log=@save_global_general_log");
myquery(rc);
restore_general_log();
DBUG_VOID_RETURN;
}
@ -17502,7 +17459,8 @@ and you are welcome to modify and redistribute it under the GPL license\n");
static struct my_tests_st my_tests[]= {
{ "test_view_sp_list_fields", test_view_sp_list_fields},
{ "disable_general_log", disable_general_log },
{ "test_view_sp_list_fields", test_view_sp_list_fields },
{ "client_query", client_query },
{ "test_prepare_insert_update", test_prepare_insert_update},
#if NOT_YET_WORKING
@ -17722,7 +17680,6 @@ static struct my_tests_st my_tests[]= {
{ "test_bug28505", test_bug28505 },
{ "test_bug28934", test_bug28934 },
{ "test_bug27592", test_bug27592 },
{ "test_bug29948", test_bug29948 },
{ "test_bug29687", test_bug29687 },
{ "test_bug29692", test_bug29692 },
{ "test_bug29306", test_bug29306 },