summaryrefslogtreecommitdiff
path: root/mysql-test/suite/vcol
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2010-07-15 16:51:05 -0700
committerIgor Babaev <igor@askmonty.org>2010-07-15 16:51:05 -0700
commit40901007434a30882e1f51171551ff287fbe540c (patch)
tree533145fe7464b9126586448d784c3fd9893807ca /mysql-test/suite/vcol
parent683154d1fa6249a8bfcde4bb9227570c452ea802 (diff)
downloadmariadb-git-40901007434a30882e1f51171551ff287fbe540c.tar.gz
Fixed bug #603186.
There were two problems that caused wrong results reported with this bug. 1. In some cases stored(persistent) virtual columns were not marked in the write_set and in the vcol_set bitmaps. 2. If the list of fields in an insert command was empty then the values of the stored virtual columns were set to default. To fix the first problem the function st_table::mark_virtual_columns_for_write was modified. Now the function has a parameter that says whether the virtual columns are to be marked for insert or for update. To fix the second problem a special handling of empty insert lists is added in the function fill_record().
Diffstat (limited to 'mysql-test/suite/vcol')
-rw-r--r--mysql-test/suite/vcol/r/vcol_misc.result17
-rw-r--r--mysql-test/suite/vcol/t/vcol_misc.test17
2 files changed, 34 insertions, 0 deletions
diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result
index fe41e7e65f3..1826bf2dd3e 100644
--- a/mysql-test/suite/vcol/r/vcol_misc.result
+++ b/mysql-test/suite/vcol/r/vcol_misc.result
@@ -45,3 +45,20 @@ C
1
1
DROP TABLE t1;
+CREATE TABLE t1(a int, b int DEFAULT 0, v INT AS (b+10) PERSISTENT);
+INSERT INTO t1(a) VALUES (1);
+SELECT b, v FROM t1;
+b v
+0 10
+DROP TABLE t1;
+CREATE TABLE t1(a int DEFAULT 100, v int AS (a+1) PERSISTENT);
+INSERT INTO t1 () VALUES ();
+CREATE TABLE t2(a int DEFAULT 100 , v int AS (a+1));
+INSERT INTO t2 () VALUES ();
+SELECT a, v FROM t1;
+a v
+100 101
+SELECT a, v FROM t2;
+a v
+100 101
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test
index 2ed08a69fa2..67e4b18d596 100644
--- a/mysql-test/suite/vcol/t/vcol_misc.test
+++ b/mysql-test/suite/vcol/t/vcol_misc.test
@@ -43,5 +43,22 @@ SELECT 1 AS C FROM t1 ORDER BY v;
DROP TABLE t1;
+#
+# Bug#603186: Insert for a table with stored vurtual columns
+#
+
+CREATE TABLE t1(a int, b int DEFAULT 0, v INT AS (b+10) PERSISTENT);
+INSERT INTO t1(a) VALUES (1);
+SELECT b, v FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1(a int DEFAULT 100, v int AS (a+1) PERSISTENT);
+INSERT INTO t1 () VALUES ();
+CREATE TABLE t2(a int DEFAULT 100 , v int AS (a+1));
+INSERT INTO t2 () VALUES ();
+SELECT a, v FROM t1;
+SELECT a, v FROM t2;
+DROP TABLE t1,t2;