summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@sun.com>2010-05-05 15:00:59 +0400
committerAlexander Nozdrin <alik@sun.com>2010-05-05 15:00:59 +0400
commit0a032dea1f6af01dea7de96572b097b7c3c883dc (patch)
tree98979042674c76c67ccc89aa5bfb10cedc8d16b6 /mysql-test
parent3c93a784d415efad81065bb5dcb3f3c897374019 (diff)
downloadmariadb-git-0a032dea1f6af01dea7de96572b097b7c3c883dc.tar.gz
Patch for Bug#50511 (Sometimes wrong handling of user variables containing NULL).
The bug happened under the following condition: - there was a user variable of type REAL, containing NULL value - there was a table with a NOT_NULL column of any type but REAL, having default value (or auto increment); - a row was inserted into the table with the user variable as value. A warning was emitted here. The problem was that handling of NULL values of REAL type was not properly implemented: it didn't expect that REAL NULL value can be assigned to other data type. Basically, the problem was that set_field_to_null() was used instead of set_field_to_null_with_conversions(). The fix is to use the right function, or more generally, to allow conversion of REAL NULL values to other data types.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/null.result2
-rw-r--r--mysql-test/r/user_var.result31
-rw-r--r--mysql-test/t/user_var.test41
3 files changed, 73 insertions, 1 deletions
diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result
index 1cdc48e6552..585d7a14ce9 100644
--- a/mysql-test/r/null.result
+++ b/mysql-test/r/null.result
@@ -94,7 +94,7 @@ Warnings:
Warning 1265 Data truncated for column 'd' at row 1
UPDATE t1 SET d=1/NULL;
Warnings:
-Warning 1265 Data truncated for column 'd' at row 1
+Warning 1048 Column 'd' cannot be null
UPDATE t1 SET d=NULL;
Warnings:
Warning 1048 Column 'd' cannot be null
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index c73d2e64540..29c05a60166 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -429,3 +429,34 @@ INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (1);
DROP TABLE t1;
End of 5.1 tests
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(f1 INT AUTO_INCREMENT, PRIMARY KEY(f1));
+INSERT INTO t1 SET f1 = NULL ;
+SET @aux = NULL ;
+INSERT INTO t1 SET f1 = @aux ;
+SET @aux1 = 0.123E-1;
+SET @aux1 = NULL;
+INSERT INTO t1 SET f1 = @aux1 ;
+SELECT * FROM t1;
+f1
+1
+2
+3
+DROP TABLE t1;
+CREATE TABLE t1(f1 VARCHAR(257) , f2 INT, PRIMARY KEY(f2));
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
+SET @aux = 1;
+SET @aux = NULL;
+INSERT INTO test.t1 (f1, f2) VALUES (1, 1), (@aux, 2);
+SET @aux = 'text';
+SET @aux = NULL;
+INSERT INTO t1(f1, f2) VALUES (1, 3), (@aux, 4);
+SELECT f1, f2 FROM t1 ORDER BY f2;
+f1 f2
+1 1
+1 2
+1 3
+1 4
+DROP TRIGGER trg1;
+DROP TABLE t1;
+End of 5.5 tests
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index 5147b098ae0..fc4bc61f526 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -327,3 +327,44 @@ INSERT INTO t1 VALUES (1);
DROP TABLE t1;
--echo End of 5.1 tests
+
+#
+# Bug#50511: Sometimes wrong handling of user variables containing NULL.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(f1 INT AUTO_INCREMENT, PRIMARY KEY(f1));
+
+INSERT INTO t1 SET f1 = NULL ;
+
+SET @aux = NULL ;
+INSERT INTO t1 SET f1 = @aux ;
+
+SET @aux1 = 0.123E-1;
+SET @aux1 = NULL;
+INSERT INTO t1 SET f1 = @aux1 ;
+
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1(f1 VARCHAR(257) , f2 INT, PRIMARY KEY(f2));
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
+
+SET @aux = 1; # INT
+SET @aux = NULL;
+INSERT INTO test.t1 (f1, f2) VALUES (1, 1), (@aux, 2);
+
+SET @aux = 'text'; # STRING
+SET @aux = NULL;
+INSERT INTO t1(f1, f2) VALUES (1, 3), (@aux, 4);
+
+SELECT f1, f2 FROM t1 ORDER BY f2;
+
+DROP TRIGGER trg1;
+DROP TABLE t1;
+
+--echo End of 5.5 tests