mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
ad031d5110
Problem: Grouping results by VALUES(alias for string literal) causes the server to crash. Item_insert_values is not constructed to handle other types of arguments than field and reference to field. In this case, the argument is an Item_string, and this causes Item_insert_values::fix_fields() to crash. Fix: Issue an error message when the argument to Item_insert_values is not a field or a reference to a field. This is slightly in breach with documentation, which states that VALUES should return NULL, but the error message is only issued in cases where the server otherwise would crash, so there is no change in behavior for queries that already work. Future versions will restrict syntax so that using VALUES in this way is illegal. mysql-test/r/errors.result: Add test case for bug #13031606. mysql-test/t/errors.test: Add test case for bug #13031606. sql/item.cc: Issue error message if argument is not field or reference to field.
87 lines
2.1 KiB
Text
87 lines
2.1 KiB
Text
#
|
|
# Test some error conditions
|
|
#
|
|
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
--error 1146
|
|
insert into t1 values(1);
|
|
--error 1146
|
|
delete from t1;
|
|
--error 1146
|
|
update t1 set a=1;
|
|
create table t1 (a int);
|
|
--error 1054
|
|
select count(test.t1.b) from t1;
|
|
--error 1054
|
|
select count(not_existing_database.t1) from t1;
|
|
--error 1054
|
|
select count(not_existing_database.t1.a) from t1;
|
|
--error 1044,1146
|
|
select count(not_existing_database.t1.a) from not_existing_database.t1;
|
|
--error 1054
|
|
select 1 from t1 order by 2;
|
|
--error 1054
|
|
select 1 from t1 group by 2;
|
|
--error 1054
|
|
select 1 from t1 order by t1.b;
|
|
--error 1054
|
|
select count(*),b from t1;
|
|
drop table t1;
|
|
|
|
# End of 4.1 tests
|
|
|
|
#
|
|
# Bug #6080: Error message for a field with a display width that is too long
|
|
#
|
|
--error 1439
|
|
create table t1 (a int(256));
|
|
set sql_mode='traditional';
|
|
--error 1074
|
|
create table t1 (a varchar(66000));
|
|
set sql_mode=default;
|
|
|
|
#
|
|
# Bug #27513: mysql 5.0.x + NULL pointer DoS
|
|
#
|
|
CREATE TABLE t1 (a INT);
|
|
SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
|
|
INSERT INTO t1 VALUES(1);
|
|
SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
|
|
INSERT INTO t1 VALUES(2),(3);
|
|
SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
|
|
DROP TABLE t1;
|
|
|
|
#
|
|
# Bug #28677: SELECT on missing column gives extra error
|
|
#
|
|
CREATE TABLE t1( a INT );
|
|
--error ER_BAD_FIELD_ERROR
|
|
SELECT b FROM t1;
|
|
SHOW ERRORS;
|
|
--error ER_BAD_FIELD_ERROR
|
|
CREATE TABLE t2 SELECT b FROM t1;
|
|
SHOW ERRORS;
|
|
--error ER_BAD_FIELD_ERROR
|
|
INSERT INTO t1 SELECT b FROM t1;
|
|
DROP TABLE t1;
|
|
# 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;
|