Merge from mysql-5.1.63-release

This commit is contained in:
Sunanda Menon 2012-05-08 07:19:14 +02:00
commit 074ce71e90
33 changed files with 576 additions and 28 deletions

View file

@ -445,7 +445,12 @@ enum ha_base_keytype {
#define HA_ERR_FILE_TOO_SHORT 175 /* File too short */ #define HA_ERR_FILE_TOO_SHORT 175 /* File too short */
#define HA_ERR_WRONG_CRC 176 /* Wrong CRC on page */ #define HA_ERR_WRONG_CRC 176 /* Wrong CRC on page */
#define HA_ERR_TOO_MANY_CONCURRENT_TRXS 177 /*Too many active concurrent transactions */ #define HA_ERR_TOO_MANY_CONCURRENT_TRXS 177 /*Too many active concurrent transactions */
#define HA_ERR_LAST 177 /* Copy of last error nr */
/* The error codes from 178 to 180 is not used, because we need to
maintain forward compatibility with higher versions. */
#define HA_ERR_TABLE_IN_FK_CHECK 181 /* Table being used in foreign key check */
#define HA_ERR_LAST 181 /* Copy of last error nr */
/* Number of different errors */ /* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)

View file

@ -61,6 +61,9 @@ int vio_close_pipe(Vio * vio);
#define HANDLE void * #define HANDLE void *
#endif /* __WIN__ */ #endif /* __WIN__ */
/* backport from 5.6 where it is part of PSI, not vio_*() */
int mysql_socket_shutdown(my_socket mysql_socket, int how);
void vio_delete(Vio* vio); void vio_delete(Vio* vio);
int vio_close(Vio* vio); int vio_close(Vio* vio);
void vio_reset(Vio* vio, enum enum_vio_type type, void vio_reset(Vio* vio, enum enum_vio_type type,

View file

@ -468,4 +468,13 @@ NULL
Warnings: Warnings:
Warning 1301 Result of cast_as_char() was larger than max_allowed_packet (2048) - truncated Warning 1301 Result of cast_as_char() was larger than max_allowed_packet (2048) - truncated
SET @@GLOBAL.max_allowed_packet=default; SET @@GLOBAL.max_allowed_packet=default;
#
# Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET)
#
CREATE TABLE t1 (a VARCHAR(50));
SELECT a FROM t1
WHERE CAST(a as BINARY)=x'62736D697468'
AND CAST(a AS BINARY)=x'65736D697468';
a
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests

View file

@ -55,3 +55,17 @@ Error 1054 Unknown column 'b' in 'field list'
INSERT INTO t1 SELECT b FROM t1; INSERT INTO t1 SELECT b FROM t1;
ERROR 42S22: Unknown column 'b' in 'field list' ERROR 42S22: Unknown column 'b' in 'field list'
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a INT);
CREATE TABLE t2(a INT PRIMARY KEY, b INT);
SELECT '' AS b FROM t1 GROUP BY VALUES(b);
ERROR 42S22: Unknown column '' in 'VALUES() function'
REPLACE t2(b) SELECT '' AS b FROM t1 GROUP BY VALUES(b);
ERROR 42S22: Unknown column '' in 'VALUES() function'
UPDATE t2 SET a=(SELECT '' AS b FROM t1 GROUP BY VALUES(b));
ERROR 42S22: Unknown column '' in 'VALUES() function'
INSERT INTO t2 VALUES (1,0) ON DUPLICATE KEY UPDATE
b=(SELECT '' AS b FROM t1 GROUP BY VALUES(b));
ERROR 42S22: Unknown column '' in 'VALUES() function'
INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE
b=(SELECT VALUES(a)+2 FROM t1);
DROP TABLE t1, t2;

View file

@ -1075,4 +1075,16 @@ SPATIAL INDEX i1 (col1, col2)
); );
ERROR HY000: Incorrect arguments to SPATIAL INDEX ERROR HY000: Incorrect arguments to SPATIAL INDEX
DROP TABLE t0, t1, t2; DROP TABLE t0, t1, t2;
#
# BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
#
SELECT ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)));
ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)))
NULL
#
# BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN
# GEOMETRY FUNCTION ARGUMENTS
#
SELECT GEOMETRYCOLLECTION((SELECT @@OLD));
ERROR 22007: Illegal non geometric '' value found during parsing
End of 5.1 tests End of 5.1 tests

View file

@ -245,3 +245,63 @@ x
NULL NULL
drop procedure p1; drop procedure p1;
drop tables t1,t2,t3; drop tables t1,t2,t3;
#
# Bug #11766300 59387: FAILING ASSERTION: CURSOR->POS_STATE == 1997660512 (BTR_PCUR_IS_POSITIONE
#
CREATE TABLE t1 (a INT) ENGINE=INNODB;
INSERT INTO t1 VALUES (0);
CREATE TABLE t2 (d BINARY(2), PRIMARY KEY (d(1)), UNIQUE KEY (d)) ENGINE=INNODB;
SELECT 1 FROM t1 WHERE NOT EXISTS
(SELECT 1 FROM t2 WHERE d = (SELECT d FROM t2 WHERE a >= 1) ORDER BY d);
1
1
EXPLAIN SELECT 1 FROM t1 WHERE NOT EXISTS
(SELECT 1 FROM t2 WHERE d = (SELECT d FROM t2 WHERE a >= 1) ORDER BY d);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 1 Using where
2 DEPENDENT SUBQUERY t2 eq_ref PRIMARY,d d 2 func 1 Using where
3 DEPENDENT SUBQUERY t2 index NULL d 2 NULL 1 Using where; Using index
DROP TABLE t2;
CREATE TABLE t2 (b INT, c INT, UNIQUE KEY (b), UNIQUE KEY (b, c )) ENGINE=INNODB;
INSERT INTO t2 VALUES (1, 1);
SELECT 1 FROM t1
WHERE a != (SELECT 1 FROM t2 WHERE a <=> b OR a > '' AND 6 = 7 ORDER BY b, c);
1
DROP TABLE t1, t2;
#
# Bug #13639204 64111: CRASH ON SELECT SUBQUERY WITH NON UNIQUE
# INDEX
#
CREATE TABLE t1 (
id int
) ENGINE=InnoDB;
INSERT INTO t1 (id) VALUES (11);
CREATE TABLE t2 (
t1_id int,
position int,
KEY t1_id (t1_id),
KEY t1_id_position (t1_id,position)
) ENGINE=InnoDB;
EXPLAIN SELECT
(SELECT position FROM t2
WHERE t2.t1_id = t1.id
ORDER BY t2.t1_id , t2.position
LIMIT 10,1
) AS maxkey
FROM t1
LIMIT 1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t2 ref t1_id,t1_id_position t1_id_position 5 test.t1.id 1 Using where
SELECT
(SELECT position FROM t2
WHERE t2.t1_id = t1.id
ORDER BY t2.t1_id , t2.position
LIMIT 10,1
) AS maxkey
FROM t1
LIMIT 1;
maxkey
NULL
DROP TABLE t1,t2;
End of 5.1 tests

View file

@ -0,0 +1,45 @@
SET DEBUG_SYNC='reset';
create table t1 (f1 integer, key k1 (f1)) engine=innodb;
create table t2 (f1 int, f2 int, key(f1), key(f2)) engine=innodb;
create table t3 (f2 int, key(f2)) engine=innodb;
insert into t1 values (10);
insert into t2 values (10, 20);
insert into t3 values (20);
alter table t2 add constraint c1 foreign key (f1)
references t1(f1) on update cascade;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) DEFAULT NULL,
KEY `k1` (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`f1` int(11) DEFAULT NULL,
`f2` int(11) DEFAULT NULL,
KEY `f1` (`f1`),
KEY `f2` (`f2`),
CONSTRAINT `c1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`f2` int(11) DEFAULT NULL,
KEY `f2` (`f2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SET DEBUG_SYNC='alter_table_before_rename_result_table
SIGNAL update_can_proceed WAIT_FOR dict_unfreeze';
alter table t2 add constraint z1 foreign key (f2)
references t3(f2) on update cascade;
SET DEBUG_SYNC='innodb_row_update_for_mysql_begin
WAIT_FOR update_can_proceed';
SET DEBUG_SYNC='innodb_dml_cascade_dict_unfreeze SIGNAL dict_unfreeze
WAIT_FOR foreign_free_cache';
update ignore t1 set f1 = 20;
ERROR HY000: Error on rename of './test/t2' to '#sql2-temporary' (errno: 181)
SET DEBUG_SYNC='now SIGNAL foreign_free_cache';
drop table t2;
drop table t1;
drop table t3;
SET DEBUG_SYNC='reset';

View file

@ -0,0 +1,64 @@
--source include/have_innodb.inc
--source include/have_debug_sync.inc
--source include/not_embedded.inc
SET DEBUG_SYNC='reset';
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
create table t1 (f1 integer, key k1 (f1)) engine=innodb;
create table t2 (f1 int, f2 int, key(f1), key(f2)) engine=innodb;
create table t3 (f2 int, key(f2)) engine=innodb;
insert into t1 values (10);
insert into t2 values (10, 20);
insert into t3 values (20);
alter table t2 add constraint c1 foreign key (f1)
references t1(f1) on update cascade;
show create table t1;
show create table t2;
show create table t3;
SET DEBUG_SYNC='alter_table_before_rename_result_table
SIGNAL update_can_proceed WAIT_FOR dict_unfreeze';
--send
alter table t2 add constraint z1 foreign key (f2)
references t3(f2) on update cascade;
connect (thr2,localhost,root,,);
connection thr2;
SET DEBUG_SYNC='innodb_row_update_for_mysql_begin
WAIT_FOR update_can_proceed';
SET DEBUG_SYNC='innodb_dml_cascade_dict_unfreeze SIGNAL dict_unfreeze
WAIT_FOR foreign_free_cache';
--send
update ignore t1 set f1 = 20;
connection default;
--replace_regex /'[^']*test\/#sql2-[0-9a-f-]*'/'#sql2-temporary'/
--error ER_ERROR_ON_RENAME
reap;
SET DEBUG_SYNC='now SIGNAL foreign_free_cache';
connection thr2;
reap;
disconnect thr2;
--source include/wait_until_disconnected.inc
connection default;
drop table t2;
drop table t1;
drop table t3;
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
SET DEBUG_SYNC='reset';

View file

@ -0,0 +1,45 @@
SET DEBUG_SYNC='reset';
create table t1 (f1 integer, key k1 (f1)) engine=innodb;
create table t2 (f1 int, f2 int, key(f1), key(f2)) engine=innodb;
create table t3 (f2 int, key(f2)) engine=innodb;
insert into t1 values (10);
insert into t2 values (10, 20);
insert into t3 values (20);
alter table t2 add constraint c1 foreign key (f1)
references t1(f1) on update cascade;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) DEFAULT NULL,
KEY `k1` (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`f1` int(11) DEFAULT NULL,
`f2` int(11) DEFAULT NULL,
KEY `f1` (`f1`),
KEY `f2` (`f2`),
CONSTRAINT `c1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`f2` int(11) DEFAULT NULL,
KEY `f2` (`f2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SET DEBUG_SYNC='alter_table_before_rename_result_table
SIGNAL update_can_proceed WAIT_FOR dict_unfreeze';
alter table t2 add constraint z1 foreign key (f2)
references t3(f2) on update cascade;
SET DEBUG_SYNC='innodb_row_update_for_mysql_begin
WAIT_FOR update_can_proceed';
SET DEBUG_SYNC='innodb_dml_cascade_dict_unfreeze SIGNAL dict_unfreeze
WAIT_FOR foreign_free_cache';
update ignore t1 set f1 = 20;
ERROR HY000: Error on rename of './test/t2' to '#sql2-temporary' (errno: 181)
SET DEBUG_SYNC='now SIGNAL foreign_free_cache';
drop table t2;
drop table t1;
drop table t3;
SET DEBUG_SYNC='reset';

View file

@ -0,0 +1,66 @@
--source include/have_innodb_plugin.inc
--source include/have_debug_sync.inc
--source include/not_embedded.inc
# InnoDB Plugin cannot use DEBUG_SYNC on Windows
--source include/not_windows.inc
SET DEBUG_SYNC='reset';
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
create table t1 (f1 integer, key k1 (f1)) engine=innodb;
create table t2 (f1 int, f2 int, key(f1), key(f2)) engine=innodb;
create table t3 (f2 int, key(f2)) engine=innodb;
insert into t1 values (10);
insert into t2 values (10, 20);
insert into t3 values (20);
alter table t2 add constraint c1 foreign key (f1)
references t1(f1) on update cascade;
show create table t1;
show create table t2;
show create table t3;
SET DEBUG_SYNC='alter_table_before_rename_result_table
SIGNAL update_can_proceed WAIT_FOR dict_unfreeze';
--send
alter table t2 add constraint z1 foreign key (f2)
references t3(f2) on update cascade;
connect (thr2,localhost,root,,);
connection thr2;
SET DEBUG_SYNC='innodb_row_update_for_mysql_begin
WAIT_FOR update_can_proceed';
SET DEBUG_SYNC='innodb_dml_cascade_dict_unfreeze SIGNAL dict_unfreeze
WAIT_FOR foreign_free_cache';
--send
update ignore t1 set f1 = 20;
connection default;
--replace_regex /'[^']*test\/#sql2-[0-9a-f-]*'/'#sql2-temporary'/
--error ER_ERROR_ON_RENAME
reap;
SET DEBUG_SYNC='now SIGNAL foreign_free_cache';
connection thr2;
reap;
disconnect thr2;
--source include/wait_until_disconnected.inc
connection default;
drop table t2;
drop table t1;
drop table t3;
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
SET DEBUG_SYNC='reset';

View file

@ -297,4 +297,16 @@ connection default;
disconnect newconn; disconnect newconn;
SET @@GLOBAL.max_allowed_packet=default; SET @@GLOBAL.max_allowed_packet=default;
--echo #
--echo # Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET)
--echo #
CREATE TABLE t1 (a VARCHAR(50));
SELECT a FROM t1
WHERE CAST(a as BINARY)=x'62736D697468'
AND CAST(a AS BINARY)=x'65736D697468';
DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests

View file

@ -67,3 +67,21 @@ SHOW ERRORS;
INSERT INTO t1 SELECT b FROM t1; INSERT INTO t1 SELECT b FROM t1;
DROP TABLE t1; DROP TABLE t1;
# End of 5.0 tests # End of 5.0 tests
#
# Bug #13031606 VALUES() IN A SELECT STATEMENT CRASHES SERVER
#
CREATE TABLE t1 (a INT);
CREATE TABLE t2(a INT PRIMARY KEY, b INT);
--error ER_BAD_FIELD_ERROR
SELECT '' AS b FROM t1 GROUP BY VALUES(b);
--error ER_BAD_FIELD_ERROR
REPLACE t2(b) SELECT '' AS b FROM t1 GROUP BY VALUES(b);
--error ER_BAD_FIELD_ERROR
UPDATE t2 SET a=(SELECT '' AS b FROM t1 GROUP BY VALUES(b));
--error ER_BAD_FIELD_ERROR
INSERT INTO t2 VALUES (1,0) ON DUPLICATE KEY UPDATE
b=(SELECT '' AS b FROM t1 GROUP BY VALUES(b));
INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE
b=(SELECT VALUES(a)+2 FROM t1);
DROP TABLE t1, t2;

View file

@ -812,4 +812,19 @@ CREATE TABLE t3 (
# cleanup # cleanup
DROP TABLE t0, t1, t2; DROP TABLE t0, t1, t2;
--echo #
--echo # BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
--echo #
SELECT ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)));
--echo #
--echo # BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN
--echo # GEOMETRY FUNCTION ARGUMENTS
--echo #
--replace_regex /non geometric .* value/non geometric '' value/
--error ER_ILLEGAL_VALUE_FOR_TYPE
SELECT GEOMETRYCOLLECTION((SELECT @@OLD));
--echo End of 5.1 tests --echo End of 5.1 tests

View file

@ -238,3 +238,59 @@ call p1();
call p1(); call p1();
drop procedure p1; drop procedure p1;
drop tables t1,t2,t3; drop tables t1,t2,t3;
--echo #
--echo # Bug #11766300 59387: FAILING ASSERTION: CURSOR->POS_STATE == 1997660512 (BTR_PCUR_IS_POSITIONE
--echo #
CREATE TABLE t1 (a INT) ENGINE=INNODB;
INSERT INTO t1 VALUES (0);
CREATE TABLE t2 (d BINARY(2), PRIMARY KEY (d(1)), UNIQUE KEY (d)) ENGINE=INNODB;
SELECT 1 FROM t1 WHERE NOT EXISTS
(SELECT 1 FROM t2 WHERE d = (SELECT d FROM t2 WHERE a >= 1) ORDER BY d);
EXPLAIN SELECT 1 FROM t1 WHERE NOT EXISTS
(SELECT 1 FROM t2 WHERE d = (SELECT d FROM t2 WHERE a >= 1) ORDER BY d);
DROP TABLE t2;
CREATE TABLE t2 (b INT, c INT, UNIQUE KEY (b), UNIQUE KEY (b, c )) ENGINE=INNODB;
INSERT INTO t2 VALUES (1, 1);
SELECT 1 FROM t1
WHERE a != (SELECT 1 FROM t2 WHERE a <=> b OR a > '' AND 6 = 7 ORDER BY b, c);
DROP TABLE t1, t2;
--echo #
--echo # Bug #13639204 64111: CRASH ON SELECT SUBQUERY WITH NON UNIQUE
--echo # INDEX
--echo #
CREATE TABLE t1 (
id int
) ENGINE=InnoDB;
INSERT INTO t1 (id) VALUES (11);
CREATE TABLE t2 (
t1_id int,
position int,
KEY t1_id (t1_id),
KEY t1_id_position (t1_id,position)
) ENGINE=InnoDB;
let $query=SELECT
(SELECT position FROM t2
WHERE t2.t1_id = t1.id
ORDER BY t2.t1_id , t2.position
LIMIT 10,1
) AS maxkey
FROM t1
LIMIT 1;
eval EXPLAIN $query;
eval $query;
DROP TABLE t1,t2;
--echo End of 5.1 tests

View file

@ -78,6 +78,10 @@ static const char *handler_error_messages[]=
"Got a fatal error during initialzaction of handler", "Got a fatal error during initialzaction of handler",
"File to short; Expected more data in file", "File to short; Expected more data in file",
"Read page with wrong checksum", "Read page with wrong checksum",
"Too many active concurrent transactions" "Too many active concurrent transactions",
"",
"",
"",
"Table is being used in foreign key check" /* HA_ERR_TABLE_IN_FK_CHECK */
}; };

View file

@ -345,6 +345,7 @@ int ha_init_errors(void)
SETMSG(HA_ERR_AUTOINC_READ_FAILED, ER(ER_AUTOINC_READ_FAILED)); SETMSG(HA_ERR_AUTOINC_READ_FAILED, ER(ER_AUTOINC_READ_FAILED));
SETMSG(HA_ERR_AUTOINC_ERANGE, ER(ER_WARN_DATA_OUT_OF_RANGE)); SETMSG(HA_ERR_AUTOINC_ERANGE, ER(ER_WARN_DATA_OUT_OF_RANGE));
SETMSG(HA_ERR_TOO_MANY_CONCURRENT_TRXS, ER(ER_TOO_MANY_CONCURRENT_TRXS)); SETMSG(HA_ERR_TOO_MANY_CONCURRENT_TRXS, ER(ER_TOO_MANY_CONCURRENT_TRXS));
SETMSG(HA_ERR_TABLE_IN_FK_CHECK, "Table being used in foreign key check");
/* Register the error messages for use with my_error(). */ /* Register the error messages for use with my_error(). */
return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST); return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST);
@ -2820,6 +2821,7 @@ void handler::print_error(int error, myf errflag)
case HA_ERR_TOO_MANY_CONCURRENT_TRXS: case HA_ERR_TOO_MANY_CONCURRENT_TRXS:
textno= ER_TOO_MANY_CONCURRENT_TRXS; textno= ER_TOO_MANY_CONCURRENT_TRXS;
break; break;
case HA_ERR_TABLE_IN_FK_CHECK:
default: default:
{ {
/* The error was "unknown" to this function. /* The error was "unknown" to this function.

View file

@ -6657,20 +6657,12 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items)
} }
if (arg->type() == REF_ITEM) if (arg->type() == REF_ITEM)
arg= static_cast<Item_ref *>(arg)->ref[0];
if (arg->type() != FIELD_ITEM)
{ {
Item_ref *ref= (Item_ref *)arg; my_error(ER_BAD_FIELD_ERROR, MYF(0), "", "VALUES() function");
if (ref->ref[0]->type() != FIELD_ITEM) return TRUE;
{
my_error(ER_BAD_FIELD_ERROR, MYF(0), "", "VALUES() function");
return TRUE;
}
arg= ref->ref[0];
} }
/*
According to our SQL grammar, VALUES() function can reference
only to a column.
*/
DBUG_ASSERT(arg->type() == FIELD_ITEM);
Item_field *field_arg= (Item_field *)arg; Item_field *field_arg= (Item_field *)arg;

View file

@ -173,6 +173,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
(*ref)= substitution; (*ref)= substitution;
substitution->name= name; substitution->name= name;
substitution->name_length= name_length;
if (have_to_be_excluded) if (have_to_be_excluded)
engine->exclude(); engine->exclude();
substitution= 0; substitution= 0;

View file

@ -932,7 +932,7 @@ static void close_connections(void)
{ {
if (ip_sock != INVALID_SOCKET) if (ip_sock != INVALID_SOCKET)
{ {
(void) shutdown(ip_sock, SHUT_RDWR); (void) mysql_socket_shutdown(ip_sock, SHUT_RDWR);
(void) closesocket(ip_sock); (void) closesocket(ip_sock);
ip_sock= INVALID_SOCKET; ip_sock= INVALID_SOCKET;
} }
@ -964,7 +964,7 @@ static void close_connections(void)
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
if (unix_sock != INVALID_SOCKET) if (unix_sock != INVALID_SOCKET)
{ {
(void) shutdown(unix_sock, SHUT_RDWR); (void) mysql_socket_shutdown(unix_sock, SHUT_RDWR);
(void) closesocket(unix_sock); (void) closesocket(unix_sock);
(void) unlink(mysqld_unix_port); (void) unlink(mysqld_unix_port);
unix_sock= INVALID_SOCKET; unix_sock= INVALID_SOCKET;
@ -1069,7 +1069,7 @@ static void close_server_sock()
{ {
ip_sock=INVALID_SOCKET; ip_sock=INVALID_SOCKET;
DBUG_PRINT("info",("calling shutdown on TCP/IP socket")); DBUG_PRINT("info",("calling shutdown on TCP/IP socket"));
VOID(shutdown(tmp_sock, SHUT_RDWR)); VOID(mysql_socket_shutdown(tmp_sock, SHUT_RDWR));
#if defined(__NETWARE__) #if defined(__NETWARE__)
/* /*
The following code is disabled for normal systems as it causes MySQL The following code is disabled for normal systems as it causes MySQL
@ -1084,7 +1084,7 @@ static void close_server_sock()
{ {
unix_sock=INVALID_SOCKET; unix_sock=INVALID_SOCKET;
DBUG_PRINT("info",("calling shutdown on unix socket")); DBUG_PRINT("info",("calling shutdown on unix socket"));
VOID(shutdown(tmp_sock, SHUT_RDWR)); VOID(mysql_socket_shutdown(tmp_sock, SHUT_RDWR));
#if defined(__NETWARE__) #if defined(__NETWARE__)
/* /*
The following code is disabled for normal systems as it may cause MySQL The following code is disabled for normal systems as it may cause MySQL
@ -5087,7 +5087,7 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
if (req.sink) if (req.sink)
((void (*)(int))req.sink)(req.fd); ((void (*)(int))req.sink)(req.fd);
(void) shutdown(new_sock, SHUT_RDWR); (void) mysql_socket_shutdown(new_sock, SHUT_RDWR);
(void) closesocket(new_sock); (void) closesocket(new_sock);
continue; continue;
} }
@ -5102,7 +5102,7 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
if (getsockname(new_sock,&dummy, &dummyLen) < 0) if (getsockname(new_sock,&dummy, &dummyLen) < 0)
{ {
sql_perror("Error on new connection socket"); sql_perror("Error on new connection socket");
(void) shutdown(new_sock, SHUT_RDWR); (void) mysql_socket_shutdown(new_sock, SHUT_RDWR);
(void) closesocket(new_sock); (void) closesocket(new_sock);
continue; continue;
} }
@ -5114,7 +5114,7 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
if (!(thd= new THD)) if (!(thd= new THD))
{ {
(void) shutdown(new_sock, SHUT_RDWR); (void) mysql_socket_shutdown(new_sock, SHUT_RDWR);
VOID(closesocket(new_sock)); VOID(closesocket(new_sock));
continue; continue;
} }
@ -5133,7 +5133,7 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
vio_delete(vio_tmp); vio_delete(vio_tmp);
else else
{ {
(void) shutdown(new_sock, SHUT_RDWR); (void) mysql_socket_shutdown(new_sock, SHUT_RDWR);
(void) closesocket(new_sock); (void) closesocket(new_sock);
} }
delete thd; delete thd;

View file

@ -531,7 +531,7 @@ check_scramble(const char *scramble_arg, const char *message,
mysql_sha1_reset(&sha1_context); mysql_sha1_reset(&sha1_context);
mysql_sha1_input(&sha1_context, buf, SHA1_HASH_SIZE); mysql_sha1_input(&sha1_context, buf, SHA1_HASH_SIZE);
mysql_sha1_result(&sha1_context, hash_stage2_reassured); mysql_sha1_result(&sha1_context, hash_stage2_reassured);
return memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE); return test(memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE));
} }

View file

@ -627,7 +627,8 @@ int Gis_line_string::is_closed(int *closed) const
return 0; return 0;
} }
data+= 4; data+= 4;
if (no_data(data, SIZEOF_STORED_DOUBLE * 2 * n_points)) if (n_points == 0 ||
no_data(data, SIZEOF_STORED_DOUBLE * 2 * n_points))
return 1; return 1;
/* Get first point */ /* Get first point */

View file

@ -5793,6 +5793,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
} }
keyuse++; keyuse++;
} while (keyuse->table == table && keyuse->key == key); } while (keyuse->table == table && keyuse->key == key);
DBUG_ASSERT(length > 0 && keyparts != 0);
} /* not ftkey */ } /* not ftkey */
/* set up fieldref */ /* set up fieldref */
@ -8546,10 +8547,10 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
left_item->collation.collation == value->collation.collation)) left_item->collation.collation == value->collation.collation))
{ {
Item *tmp=value->clone_item(); Item *tmp=value->clone_item();
tmp->collation.set(right_item->collation);
if (tmp) if (tmp)
{ {
tmp->collation.set(right_item->collation);
thd->change_item_tree(args + 1, tmp); thd->change_item_tree(args + 1, tmp);
func->update_used_tables(); func->update_used_tables();
if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC) if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)
@ -8570,10 +8571,10 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
right_item->collation.collation == value->collation.collation)) right_item->collation.collation == value->collation.collation))
{ {
Item *tmp= value->clone_item(); Item *tmp= value->clone_item();
tmp->collation.set(left_item->collation);
if (tmp) if (tmp)
{ {
tmp->collation.set(left_item->collation);
thd->change_item_tree(args, tmp); thd->change_item_tree(args, tmp);
value= tmp; value= tmp;
func->update_used_tables(); func->update_used_tables();
@ -13426,6 +13427,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
DBUG_ENTER("test_if_skip_sort_order"); DBUG_ENTER("test_if_skip_sort_order");
LINT_INIT(ref_key_parts); LINT_INIT(ref_key_parts);
/* Check that we are always called with first non-const table */
DBUG_ASSERT(tab == tab->join->join_tab + tab->join->const_tables);
/* /*
Keys disabled by ALTER TABLE ... DISABLE KEYS should have already Keys disabled by ALTER TABLE ... DISABLE KEYS should have already
been taken into account. been taken into account.
@ -13507,7 +13511,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
while (keyuse->key != new_ref_key && keyuse->table == tab->table) while (keyuse->key != new_ref_key && keyuse->table == tab->table)
keyuse++; keyuse++;
if (create_ref_for_key(tab->join, tab, keyuse, if (create_ref_for_key(tab->join, tab, keyuse,
tab->join->const_table_map)) (tab->join->const_table_map |
OUTER_REF_TABLE_BIT)))
DBUG_RETURN(0); DBUG_RETURN(0);
pick_table_access_method(tab); pick_table_access_method(tab);

View file

@ -26,6 +26,8 @@ Created 1/8/1996 Heikki Tuuri
#include "pars0sym.h" #include "pars0sym.h"
#include "que0que.h" #include "que0que.h"
#include "rem0cmp.h" #include "rem0cmp.h"
#include "m_string.h"
#include "my_sys.h"
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
# include "m_ctype.h" /* my_isspace() */ # include "m_ctype.h" /* my_isspace() */
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
@ -1889,6 +1891,8 @@ dict_foreign_free(
/*==============*/ /*==============*/
dict_foreign_t* foreign) /* in, own: foreign key struct */ dict_foreign_t* foreign) /* in, own: foreign key struct */
{ {
ut_a(foreign->foreign_table->n_foreign_key_checks_running == 0);
mem_heap_free(foreign->heap); mem_heap_free(foreign->heap);
} }

View file

@ -746,6 +746,10 @@ convert_error_code_to_mysql(
return(HA_ERR_RECORD_FILE_FULL); return(HA_ERR_RECORD_FILE_FULL);
} else if (error == (int) DB_TABLE_IN_FK_CHECK) {
return(HA_ERR_TABLE_IN_FK_CHECK);
} else if (error == (int) DB_TABLE_IS_BEING_USED) { } else if (error == (int) DB_TABLE_IS_BEING_USED) {
return(HA_ERR_WRONG_COMMAND); return(HA_ERR_WRONG_COMMAND);
@ -4867,6 +4871,7 @@ ha_innobase::index_read(
DBUG_ENTER("index_read"); DBUG_ENTER("index_read");
ut_a(prebuilt->trx == thd_to_trx(user_thd)); ut_a(prebuilt->trx == thd_to_trx(user_thd));
ut_ad(key_len != 0 || find_flag != HA_READ_KEY_EXACT);
ha_statistic_increment(&SSV::ha_read_key_count); ha_statistic_increment(&SSV::ha_read_key_count);

View file

@ -82,6 +82,8 @@ Created 5/24/1996 Heikki Tuuri
#define DB_REFERENCING_NO_INDEX 52 /* the parent (referencing) table does #define DB_REFERENCING_NO_INDEX 52 /* the parent (referencing) table does
not have an index that contains the not have an index that contains the
foreign keys as its prefix columns */ foreign keys as its prefix columns */
#define DB_TABLE_IN_FK_CHECK 53 /* table is being used in foreign
key check */
/* The following are partial failure codes */ /* The following are partial failure codes */
#define DB_FAIL 1000 #define DB_FAIL 1000

View file

@ -1074,6 +1074,9 @@ row_ins_foreign_check_on_constraint(
release the latch. */ release the latch. */
row_mysql_unfreeze_data_dictionary(thr_get_trx(thr)); row_mysql_unfreeze_data_dictionary(thr_get_trx(thr));
DEBUG_SYNC_C("innodb_dml_cascade_dict_unfreeze");
row_mysql_freeze_data_dictionary(thr_get_trx(thr)); row_mysql_freeze_data_dictionary(thr_get_trx(thr));
mtr_start(mtr); mtr_start(mtr);

View file

@ -31,6 +31,8 @@ Created 9/17/2000 Heikki Tuuri
#include "btr0sea.h" #include "btr0sea.h"
#include "fil0fil.h" #include "fil0fil.h"
#include "ibuf0ibuf.h" #include "ibuf0ibuf.h"
#include "m_string.h"
#include "my_sys.h"
/* A dummy variable used to fool the compiler */ /* A dummy variable used to fool the compiler */
ibool row_mysql_identically_false = FALSE; ibool row_mysql_identically_false = FALSE;
@ -1373,6 +1375,8 @@ row_update_for_mysql(
return(DB_ERROR); return(DB_ERROR);
} }
DEBUG_SYNC_C("innodb_row_update_for_mysql_begin");
trx->op_info = "updating or deleting"; trx->op_info = "updating or deleting";
row_mysql_delay_if_needed(); row_mysql_delay_if_needed();
@ -3652,6 +3656,7 @@ row_rename_table_for_mysql(
ulint n_constraints_to_drop = 0; ulint n_constraints_to_drop = 0;
ibool old_is_tmp, new_is_tmp; ibool old_is_tmp, new_is_tmp;
pars_info_t* info = NULL; pars_info_t* info = NULL;
ulint retry = 0;
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
ut_a(old_name != NULL); ut_a(old_name != NULL);
@ -3750,6 +3755,25 @@ row_rename_table_for_mysql(
} }
} }
/* Is a foreign key check running on this table? */
for (retry = 0; retry < 100
&& table->n_foreign_key_checks_running > 0; ++retry) {
row_mysql_unlock_data_dictionary(trx);
os_thread_yield();
row_mysql_lock_data_dictionary(trx);
}
if (table->n_foreign_key_checks_running > 0) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Error: in ALTER TABLE ", stderr);
ut_print_name(stderr, trx, TRUE, old_name);
fprintf(stderr, "\n"
"InnoDB: a FOREIGN KEY check is running.\n"
"InnoDB: Cannot rename table.\n");
err = DB_TABLE_IN_FK_CHECK;
goto funct_exit;
}
/* We use the private SQL parser of Innobase to generate the query /* We use the private SQL parser of Innobase to generate the query
graphs needed in deleting the dictionary data from system tables in graphs needed in deleting the dictionary data from system tables in
Innobase. Deleting a row from SYS_INDEXES table also frees the file Innobase. Deleting a row from SYS_INDEXES table also frees the file

View file

@ -24,6 +24,8 @@ Created 1/8/1996 Heikki Tuuri
***********************************************************************/ ***********************************************************************/
#include "dict0dict.h" #include "dict0dict.h"
#include "m_string.h"
#include "my_sys.h"
#ifdef UNIV_NONINL #ifdef UNIV_NONINL
#include "dict0dict.ic" #include "dict0dict.ic"
@ -2272,6 +2274,8 @@ dict_foreign_free(
/*==============*/ /*==============*/
dict_foreign_t* foreign) /*!< in, own: foreign key struct */ dict_foreign_t* foreign) /*!< in, own: foreign key struct */
{ {
ut_a(foreign->foreign_table->n_foreign_key_checks_running == 0);
mem_heap_free(foreign->heap); mem_heap_free(foreign->heap);
} }

View file

@ -868,6 +868,9 @@ convert_error_code_to_mysql(
case DB_OUT_OF_FILE_SPACE: case DB_OUT_OF_FILE_SPACE:
return(HA_ERR_RECORD_FILE_FULL); return(HA_ERR_RECORD_FILE_FULL);
case DB_TABLE_IN_FK_CHECK:
return(HA_ERR_TABLE_IN_FK_CHECK);
case DB_TABLE_IS_BEING_USED: case DB_TABLE_IS_BEING_USED:
return(HA_ERR_WRONG_COMMAND); return(HA_ERR_WRONG_COMMAND);
@ -5572,6 +5575,7 @@ ha_innobase::index_read(
DBUG_ENTER("index_read"); DBUG_ENTER("index_read");
ut_a(prebuilt->trx == thd_to_trx(user_thd)); ut_a(prebuilt->trx == thd_to_trx(user_thd));
ut_ad(key_len != 0 || find_flag != HA_READ_KEY_EXACT);
ha_statistic_increment(&SSV::ha_read_key_count); ha_statistic_increment(&SSV::ha_read_key_count);

View file

@ -97,6 +97,8 @@ enum db_err {
DB_FOREIGN_EXCEED_MAX_CASCADE, /* Foreign key constraint related DB_FOREIGN_EXCEED_MAX_CASCADE, /* Foreign key constraint related
cascading delete/update exceeds cascading delete/update exceeds
maximum allowed depth */ maximum allowed depth */
DB_TABLE_IN_FK_CHECK, /* table is being used in foreign
key check */
/* The following are partial failure codes */ /* The following are partial failure codes */
DB_FAIL = 1000, DB_FAIL = 1000,

View file

@ -1102,6 +1102,9 @@ row_ins_foreign_check_on_constraint(
release the latch. */ release the latch. */
row_mysql_unfreeze_data_dictionary(thr_get_trx(thr)); row_mysql_unfreeze_data_dictionary(thr_get_trx(thr));
DEBUG_SYNC_C("innodb_dml_cascade_dict_unfreeze");
row_mysql_freeze_data_dictionary(thr_get_trx(thr)); row_mysql_freeze_data_dictionary(thr_get_trx(thr));
mtr_start(mtr); mtr_start(mtr);

View file

@ -52,6 +52,14 @@ Created 9/17/2000 Heikki Tuuri
#include "fil0fil.h" #include "fil0fil.h"
#include "ibuf0ibuf.h" #include "ibuf0ibuf.h"
#ifdef __WIN__
/* error LNK2001: unresolved external symbol _debug_sync_C_callback_ptr */
# define DEBUG_SYNC_C(dummy) ((void) 0)
#else
# include "m_string.h" /* for my_sys.h */
# include "my_sys.h" /* DEBUG_SYNC_C */
#endif
/** Provide optional 4.x backwards compatibility for 5.0 and above */ /** Provide optional 4.x backwards compatibility for 5.0 and above */
UNIV_INTERN ibool row_rollback_on_timeout = FALSE; UNIV_INTERN ibool row_rollback_on_timeout = FALSE;
@ -1350,6 +1358,8 @@ row_update_for_mysql(
return(DB_ERROR); return(DB_ERROR);
} }
DEBUG_SYNC_C("innodb_row_update_for_mysql_begin");
trx->op_info = "updating or deleting"; trx->op_info = "updating or deleting";
row_mysql_delay_if_needed(); row_mysql_delay_if_needed();
@ -3765,6 +3775,7 @@ row_rename_table_for_mysql(
ulint n_constraints_to_drop = 0; ulint n_constraints_to_drop = 0;
ibool old_is_tmp, new_is_tmp; ibool old_is_tmp, new_is_tmp;
pars_info_t* info = NULL; pars_info_t* info = NULL;
ulint retry = 0;
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
ut_a(old_name != NULL); ut_a(old_name != NULL);
@ -3848,6 +3859,25 @@ row_rename_table_for_mysql(
} }
} }
/* Is a foreign key check running on this table? */
for (retry = 0; retry < 100
&& table->n_foreign_key_checks_running > 0; ++retry) {
row_mysql_unlock_data_dictionary(trx);
os_thread_yield();
row_mysql_lock_data_dictionary(trx);
}
if (table->n_foreign_key_checks_running > 0) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Error: in ALTER TABLE ", stderr);
ut_print_name(stderr, trx, TRUE, old_name);
fprintf(stderr, "\n"
"InnoDB: a FOREIGN KEY check is running.\n"
"InnoDB: Cannot rename table.\n");
err = DB_TABLE_IN_FK_CHECK;
goto funct_exit;
}
/* We use the private SQL parser of Innobase to generate the query /* We use the private SQL parser of Innobase to generate the query
graphs needed in updating the dictionary data from system tables. */ graphs needed in updating the dictionary data from system tables. */

View file

@ -23,8 +23,15 @@
the file descriptior. the file descriptior.
*/ */
#ifdef __WIN__
#include <winsock2.h>
#include <MSWSock.h>
#pragma comment(lib, "ws2_32.lib")
#endif
#include "vio_priv.h" #include "vio_priv.h"
int vio_errno(Vio *vio __attribute__((unused))) int vio_errno(Vio *vio __attribute__((unused)))
{ {
return socket_errno; /* On Win32 this mapped to WSAGetLastError() */ return socket_errno; /* On Win32 this mapped to WSAGetLastError() */
@ -260,6 +267,37 @@ vio_was_interrupted(Vio *vio __attribute__((unused)))
} }
int
mysql_socket_shutdown(my_socket mysql_socket, int how)
{
int result;
#ifdef __WIN__
static LPFN_DISCONNECTEX DisconnectEx = NULL;
if (DisconnectEx == NULL)
{
DWORD dwBytesReturned;
GUID guidDisconnectEx = WSAID_DISCONNECTEX;
WSAIoctl(mysql_socket, SIO_GET_EXTENSION_FUNCTION_POINTER,
&guidDisconnectEx, sizeof(GUID),
&DisconnectEx, sizeof(DisconnectEx),
&dwBytesReturned, NULL, NULL);
}
#endif
/* Non instrumented code */
#ifdef __WIN__
if (DisconnectEx)
result= (DisconnectEx(mysql_socket, (LPOVERLAPPED) NULL,
(DWORD) 0, (DWORD) 0) == TRUE) ? 0 : -1;
else
#endif
result= shutdown(mysql_socket, how);
return result;
}
int vio_close(Vio * vio) int vio_close(Vio * vio)
{ {
int r=0; int r=0;
@ -272,7 +310,7 @@ int vio_close(Vio * vio)
vio->type == VIO_TYPE_SSL); vio->type == VIO_TYPE_SSL);
DBUG_ASSERT(vio->sd >= 0); DBUG_ASSERT(vio->sd >= 0);
if (shutdown(vio->sd, SHUT_RDWR)) if (mysql_socket_shutdown(vio->sd, SHUT_RDWR))
r= -1; r= -1;
if (closesocket(vio->sd)) if (closesocket(vio->sd))
r= -1; r= -1;