diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-12-30 13:03:47 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-02-13 18:12:04 +0100 |
commit | cd4dd2b62dda31a4ea1da99ca6732ecb7ee0d628 (patch) | |
tree | de21f02863d5dfe94b65b92211f3c730216d9068 /mysql-test/t/default.test | |
parent | 588eca31e3c60a6778e59e618717396eb5293ebe (diff) | |
download | mariadb-git-cd4dd2b62dda31a4ea1da99ca6732ecb7ee0d628.tar.gz |
MDEV-10201 Bad results for CREATE TABLE t1 (a INT DEFAULT b, b INT DEFAULT 4)
Optionally do table->update_default_fields() even for INSERT
that supposedly provides values for all column. Because these
"values" might be DEFAULT, which would need table->update_default_fields()
at the end.
Also set Item_default_value::used_tables() from the default expression.
Non-zero used_field() means that mysql_insert() will initialize all
fields to their default values (with restore_record()) even if
all columns are later provided with values. Because default expressions
may refer to other columns and they must be initialized.
Diffstat (limited to 'mysql-test/t/default.test')
-rw-r--r-- | mysql-test/t/default.test | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/mysql-test/t/default.test b/mysql-test/t/default.test index d75966cd2dc..c96f8ac239b 100644 --- a/mysql-test/t/default.test +++ b/mysql-test/t/default.test @@ -1099,7 +1099,7 @@ SET time_zone=DEFAULT, timestamp= DEFAULT; # SYSDATE is evaluated during get_date() rather than fix_fields. CREATE TABLE t1 (a TIMESTAMP(6) DEFAULT SYSDATE(6), s INT, b TIMESTAMP(6) DEFAULT SYSDATE(6)); SHOW CREATE TABLE t1; -INSERT INTO t1 VALUES (DEFAULT, SLEEP(0.1), DEFAULT); +INSERT INTO t1 VALUES (DEFAULT(a), SLEEP(0.1), DEFAULT(b)); SELECT b>a FROM t1; DROP TABLE t1; @@ -2012,7 +2012,6 @@ INSERT INTO t1 VALUES (1),(2),(3); EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE ?+a<=>?+a' USING DEFAULT,DEFAULT; DROP TABLE t1; - --echo # --echo # MDEV-11134 Assertion `fixed' failed in Item::const_charset_converter(THD*, CHARSET_INFO*, bool, const char*) --echo # @@ -2041,10 +2040,6 @@ EXECUTE stmt USING @a; EXECUTE stmt USING @a; DEALLOCATE PREPARE stmt; - - ---echo # end of 10.2 test - # # ANSI_QUOTES # @@ -2062,3 +2057,16 @@ select * from t1; drop table t1; set sql_mode=default; +# +# MDEV-10201 Bad results for CREATE TABLE t1 (a INT DEFAULT b, b INT DEFAULT 4) +# +create table t1 (a int default b, b int default 4, t text); +insert into t1 (b, t) values (5, '1 column is omitted'); +insert into t1 values (default, 5, '2 column gets DEFAULT, keyword'); +insert into t1 values (default(a), 5, '3 column gets DEFAULT(a), expression'); +insert into t1 values (default(a)+0, 5, '4 also expression DEFAULT(0)+0'); +insert into t1 values (b, 5, '5 the value of the DEFAULT(a), that is b'); +select * from t1 order by t; +drop table t1; + +--echo # end of 10.2 test |