1# 2# Test some error conditions 3# 4--source include/have_sequence.inc 5 6--disable_warnings 7drop table if exists t1; 8--enable_warnings 9--error 1146 10insert into t1 values(1); 11--error 1146 12delete from t1; 13--error 1146 14update t1 set a=1; 15create table t1 (a int); 16--error 1054 17select count(test.t1.b) from t1; 18--error 1054 19select count(not_existing_database.t1) from t1; 20--error 1054 21select count(not_existing_database.t1.a) from t1; 22--error 1044,1146 23select count(not_existing_database.t1.a) from not_existing_database.t1; 24--error 1054 25select 1 from t1 order by 2; 26--error 1054 27select 1 from t1 group by 2; 28--error 1054 29select 1 from t1 order by t1.b; 30--error 1054 31select count(*),b from t1; 32drop table t1; 33 34# End of 4.1 tests 35 36# 37# Bug #6080: Error message for a field with a display width that is too long 38# 39--error 1439 40create table t1 (a int(256)); 41set sql_mode='traditional'; 42--error 1074 43create table t1 (a varchar(66000)); 44set sql_mode=default; 45 46# 47# Bug #27513: mysql 5.0.x + NULL pointer DoS 48# 49CREATE TABLE t1 (a INT); 50SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); 51INSERT INTO t1 VALUES(1); 52SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); 53INSERT INTO t1 VALUES(2),(3); 54SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); 55DROP TABLE t1; 56 57# 58# Bug #28677: SELECT on missing column gives extra error 59# 60CREATE TABLE t1( a INT ); 61--error ER_BAD_FIELD_ERROR 62SELECT b FROM t1; 63SHOW ERRORS; 64--error ER_BAD_FIELD_ERROR 65CREATE TABLE t2 SELECT b FROM t1; 66SHOW ERRORS; 67--error ER_BAD_FIELD_ERROR 68INSERT INTO t1 SELECT b FROM t1; 69DROP TABLE t1; 70# End of 5.0 tests 71 72flush status; 73--disable_warnings 74drop table if exists t1, t2; 75--enable_warnings 76create table t1 (a int unique); 77create table t2 (a int); 78drop function if exists f1; 79drop function if exists f2; 80 81delimiter |; 82 83create function f1() returns int 84begin 85 insert into t1 (a) values (1); 86 insert into t1 (a) values (1); 87 return 1; 88end| 89create function f2() returns int 90begin 91 insert into t2 (a) values (1); 92 return 2; 93end| 94delimiter ;| 95 96flush status; 97--error 1062 98select f1(), f2(); 99show status like 'Com_insert'; 100select * from t1; 101select * from t2; 102drop table t1; 103drop table t2; 104drop function f1; 105drop function f2; 106 107# 108# testing the value encoding in the error messages 109# 110# should be TR\xC3\x9CE, TR�E, TR�E 111# 112SET NAMES utf8; 113--error ER_WRONG_VALUE_FOR_VAR 114SET sql_quote_show_create= _binary x'5452C39C45'; 115--error ER_WRONG_VALUE_FOR_VAR 116SET sql_quote_show_create= _utf8 x'5452C39C45'; 117--error ER_WRONG_VALUE_FOR_VAR 118SET sql_quote_show_create=_latin1 x'5452DC45'; 119--error ER_WRONG_VALUE_FOR_VAR 120SET sql_quote_show_create='TRÜE'; 121--error ER_WRONG_VALUE_FOR_VAR 122SET sql_quote_show_create=TRÜE; 123 124SET NAMES latin1; 125--error ER_WRONG_VALUE_FOR_VAR 126SET sql_quote_show_create= _binary x'5452C39C45'; 127--error ER_WRONG_VALUE_FOR_VAR 128SET sql_quote_show_create= _utf8 x'5452C39C45'; 129--error ER_WRONG_VALUE_FOR_VAR 130SET sql_quote_show_create=_latin1 x'5452DC45'; 131--error ER_WRONG_VALUE_FOR_VAR 132SET sql_quote_show_create='TR�E'; 133--error ER_WRONG_VALUE_FOR_VAR 134SET sql_quote_show_create=TR�E; 135 136SET NAMES binary; 137--error ER_WRONG_VALUE_FOR_VAR 138SET sql_quote_show_create= _binary x'5452C39C45'; 139--error ER_WRONG_VALUE_FOR_VAR 140SET sql_quote_show_create= _utf8 x'5452C39C45'; 141--error ER_WRONG_VALUE_FOR_VAR 142SET sql_quote_show_create=_latin1 x'5452DC45'; 143 144--echo # 145--echo # Bug#52430 Incorrect key in the error message for duplicate key error involving BINARY type 146--echo # 147CREATE TABLE t1(c1 BINARY(10), c2 BINARY(10), c3 BINARY(10), 148PRIMARY KEY(c1,c2,c3)); 149INSERT INTO t1 (c1,c2,c3) VALUES('abc','abc','abc'); 150--error ER_DUP_ENTRY 151INSERT INTO t1 (c1,c2,c3) VALUES('abc','abc','abc'); 152DROP TABLE t1; 153 154CREATE TABLE t1 (f1 VARBINARY(19) PRIMARY KEY); 155INSERT INTO t1 VALUES ('abc\0\0'); 156--error ER_DUP_ENTRY 157INSERT INTO t1 VALUES ('abc\0\0'); 158DROP TABLE t1; 159 160--echo # 161--echo # Bug#57882: Item_func_conv_charset::val_str(String*): 162--echo # Assertion `fixed == 1' failed 163--echo # 164 165--error ER_DATA_OUT_OF_RANGE 166SELECT (CONVERT('0' USING latin1) IN (CHAR(COT('v') USING utf8),'')); 167 168SET NAMES utf8 COLLATE utf8_latvian_ci ; 169--error ER_DATA_OUT_OF_RANGE 170SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,null); 171 172--echo # 173--echo # End Bug#57882 174--echo # 175 176# 177# Bug #13031606 VALUES() IN A SELECT STATEMENT CRASHES SERVER 178# 179CREATE TABLE t1 (a INT); 180CREATE TABLE t2(a INT PRIMARY KEY, b INT); 181--error ER_BAD_FIELD_ERROR 182SELECT '' AS b FROM t1 GROUP BY VALUE(b); 183--error ER_BAD_FIELD_ERROR 184REPLACE t2(b) SELECT '' AS b FROM t1 GROUP BY VALUE(b); 185--error ER_BAD_FIELD_ERROR 186UPDATE t2 SET a=(SELECT '' AS b FROM t1 GROUP BY VALUE(b)); 187--error ER_BAD_FIELD_ERROR 188INSERT INTO t2 VALUES (1,0) ON DUPLICATE KEY UPDATE 189 b=(SELECT '' AS b FROM t1 GROUP BY VALUE(b)); 190INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE 191 b=(SELECT VALUE(a)+2 FROM t1); 192DROP TABLE t1, t2; 193 194--echo # 195--echo # MDEV-492: incorrect error check before sending OK in mysql_update 196--echo # 197CREATE TABLE t1 (a CHAR(3), b BLOB); 198--error ER_DYN_COL_DATA 199UPDATE t1 SET a = 'new' 200WHERE COLUMN_CREATE( 1, 'v', 1, 'w' ) IS NULL; 201drop table t1; 202 203# 204# errors caused by max_session_mem_used 205# 206set @max_session_mem_used_save= @@max_session_mem_used; 207 208--disable_result_log 209set max_session_mem_used = 50000; 210--error 0,ER_OPTION_PREVENTS_STATEMENT 211select * from seq_1_to_1000; 212set max_session_mem_used = 8192; 213--error 0,ER_OPTION_PREVENTS_STATEMENT 214select * from seq_1_to_1000; 215--enable_result_log 216# We may not be able to execute any more queries with this connection 217# because of too little memory# 218 219set max_session_mem_used = @max_session_mem_used_save; 220 221--echo # 222--echo # MDEV-20604: Duplicate key value is silently truncated to 64 223--echo # characters in print_keydup_error 224--echo # 225 226create table t1 (a varchar(100), UNIQUE KEY akey (a)); 227 228insert into t1 values ("1234567890123456789012345678901234567890123456789012345678901234567890_end"); 229--echo # The value in the error message should show truncation with "..." 230--error ER_DUP_ENTRY 231insert into t1 values ("1234567890123456789012345678901234567890123456789012345678901234567890_end"); 232 233drop table t1; 234 235 236--echo # End of 10.2 tests 237 238--echo # 239--echo # MDEV-14269 errors.test fails with valgrind (Conditional jump or move depends on uninitialised value) 240--echo # 241 242SET NAMES utf8; 243--error ER_DATA_OUT_OF_RANGE 244SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,null); 245--error ER_DATA_OUT_OF_RANGE 246SELECT UPDATEXML(-73 * -2465717823867977728,@@global.long_query_time,null); 247 248-- echo # End of 10.3 tests 249 250--echo # 251--echo # MDEV-23518: Syntax error in ond SP results in misleading 252--echo # message on SHOW CREATE PROCEDURE 253--echo # 254 255DELIMITER $$; 256 257CREATE PROCEDURE P1 () 258BEGIN NOT ATOMIC 259 IF (SELECT 2) THEN 260 SELECT 4; 261 END IF ; 262END; 263$$ 264 265DELIMITER ;$$ 266 267select name,db,body from mysql.proc where name = "P1"; 268update mysql.proc set body_utf8="BEGIN NOT ATOMIC 269IF (SELECT 2) OR foo = 3 THEN 270SELECT 4; 271END IF ; 272END", body="BEGIN NOT ATOMIC 273IF (SELECT 2) OR foo = 3 THEN 274SELECT 4; 275END IF ; 276END"where name = "P1"; 277 278--error ER_SP_UNDECLARED_VAR 279show create procedure P1; 280show warnings; 281 282drop procedure P1; 283 284-- echo # End of 10.4 tests 285