Commit 3205da71 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup default.test

parent 519e244b
......@@ -221,7 +221,7 @@ a
NULL
10
drop table t1, t2;
End of 5.0 tests.
# End of 5.0 tests
#
# Start of 10.1 tests
#
......@@ -239,9 +239,10 @@ DROP TABLE IF EXISTS t1;
#
# Start of 10.2 tests
#
Check that CURRENT_TIMESTAMP works as before
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
#
# Check that CURRENT_TIMESTAMP works as before
#
CREATE or replace TABLE t1 (event_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
SHOW CREATE TABLE t1;
Table Create Table
......@@ -261,9 +262,9 @@ t1 CREATE TABLE `t1` (
`event_time` timestamp(6) NOT NULL DEFAULT SYSDATE(2) ON UPDATE CURRENT_TIMESTAMP(6)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
Check default expressions
#
# Check default expressions
#
create or replace table t1 (a int default 1, b int default (a+1), c int default (a+b)) engine myisam;
show create table t1;
Table Create Table
......@@ -275,26 +276,26 @@ t1 CREATE TABLE `t1` (
insert into t1 values ();
insert into t1 (a) values (2);
insert into t1 (a,b) values (10,20);
insert into t1 (a,b,c) values (100,200,300);
insert into t1 (a,b,c) values (100,200,400);
select * from t1;
a b c
1 2 3
2 3 5
10 20 30
100 200 300
100 200 400
truncate table t1;
insert delayed into t1 values ();
insert delayed into t1 (a) values (2);
insert delayed into t1 (a,b) values (10,20);
insert delayed into t1 (a,b,c) values (100,200,300);
insert delayed into t1 (a,b,c) values (100,200,400);
flush tables t1;
select * from t1;
a b c
1 2 3
2 3 5
10 20 30
100 200 300
create or replace table t1 (a int, b blob default (1), c blob default ("hello"), t text default (concat(a,b,c))) engine=myisam;
100 200 400
create or replace table t1 (a int, b blob default (1), c blob default "hello", t text default concat(a,b,c)) engine=myisam;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -329,15 +330,15 @@ drop table t1;
create table t1 (a int);
insert into t1 values(-1);
alter table t1 add b int default 1, add c int default -1, add d int default (1+1), add e timestamp;
select a,b,c,d,e > 0 from t1;
a b c d e > 0
-1 1 -1 2 1
select a,b,c,d,e from t1;
a b c d e
-1 1 -1 2 2001-01-01 10:20:30
insert into t1 values(10,10,10,10,0);
alter table t1 add f int default (1+1+1) null, add g int default (1+1+1+1) not null,add h int default (2+2+2+2);
select a,b,c,d,e > 0,f,g,h from t1;
a b c d e > 0 f g h
-1 1 -1 2 1 3 4 8
10 10 10 10 0 3 4 8
select a,b,c,d,e,f,g,h from t1;
a b c d e f g h
-1 1 -1 2 2001-01-01 10:20:30 3 4 8
10 10 10 10 0000-00-00 00:00:00 3 4 8
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -364,9 +365,9 @@ t2 CREATE TABLE `t2` (
`h` int(11) DEFAULT (2+2+2+2)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t2 (a) values (100);
select a,b,c,d,e > 0,f,g,h from t2;
a b c d e > 0 f g h
100 1 -1 2 1 3 4 8
select a,b,c,d,e,f,g,h from t2;
a b c d e f g h
100 1 -1 2 2001-01-01 10:20:30 3 4 8
drop table t1,t2;
create table t1 (a int default (1----1), b int default - 1, c int default +1, e int default (--1));
show create table t1;
......@@ -384,17 +385,17 @@ a b c e
2 -1 1 1
2 -1 1 1
drop table t1;
create or replace can delete a table on error
#
# Create or replace can delete a table on error
#
create table t1 (a int);
create or replace table t1 (a int default b, b int default a);
ERROR 01000: Expression for field `a` is refering to uninitialized field `b`
show create table t1;
ERROR 42S02: Table 'test.t1' doesn't exist
Refering to other columns
#
# Refering to other columns
#
create or replace table t1 (a int default 1, b int default a);
create or replace table t1 (a int default 1, b int as (a));
create or replace table t1 (a int default b, b int default 1);
......@@ -411,42 +412,34 @@ create or replace table t1 (a int default b, b int default (1+1));
ERROR 01000: Expression for field `a` is refering to uninitialized field `b`
create or replace table t1 (a int default 1, b int as (c), c int as (a+1));
ERROR 01000: Expression for field `b` is refering to uninitialized field `c`
CREATE TABLE t1 (a INT DEFAULT a);
ERROR 01000: Expression for field `a` is refering to uninitialized field `a`
CREATE TABLE t1 (a INT DEFAULT (DEFAULT(a)));
ERROR HY000: Field 'a' doesn't have a default value
CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a)));
ERROR HY000: Field 'b' doesn't have a default value
CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL);
ERROR HY000: Field 'b' doesn't have a default value
drop table if exists t1;
Warnings:
Note 1051 Unknown table 'test.t1'
Allow defaults to refer to not default fields
create or replace table t1 (a int as (b), b int not null);
#
# Allow defaults to refer to not default fields
#
create or replace table t1 (a int default b, b int not null);
insert into t1 values();
Warnings:
Warning 1364 Field 'b' doesn't have a default value
insert into t1 (a) values(1);
Warnings:
Warning 1364 Field 'b' doesn't have a default value
Warning 1906 The value specified for computed column 'a' in table 't1' ignored
insert into t1 (b) values(2);
insert into t1 (a,b) values(3,4);
Warnings:
Warning 1906 The value specified for computed column 'a' in table 't1' ignored
select * from t1;
a b
0 0
0 0
1 0
2 2
4 4
3 4
drop table t1;
Error handling
#
# Error handling
#
create or replace table t1 (a bigint default xxx());
ERROR HY000: Function or expression '`xxx`' is not allowed for 'DEFAULT' of column/constraint 'a'
create or replace table t1 (a bigint default (select (1)));
......@@ -459,9 +452,6 @@ CREATE TABLE t1 (a INT, b INT, c INT DEFAULT a DIV b);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DIV b)' at line 1
CREATE TABLE t1 (a INT, b INT DEFAULT -a);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a)' at line 1
drop table if exists t1;
Warnings:
Note 1051 Unknown table 'test.t1'
#
# Invalid DEFAULT expressions
#
......@@ -1044,7 +1034,6 @@ DROP TABLE t1;
#
# DECIMAL + CURRENT_TIMESTAMP, no truncation
#
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
CREATE TABLE t1 (a DECIMAL(30,6) DEFAULT CURRENT_TIMESTAMP(6));
SHOW CREATE TABLE t1;
Table Create Table
......@@ -1073,11 +1062,9 @@ INSERT INTO t1 VALUES();
ERROR 01000: Data truncated for column 'a' at row 1
SET sql_mode = DEFAULT;
DROP TABLE t1;
SET timestamp=DEFAULT;
#
# DECIMAL + CURRENT_TIME, no truncation
#
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
CREATE TABLE t1 (a DECIMAL(30,6) DEFAULT COALESCE(CURRENT_TIME(6)));
SHOW CREATE TABLE t1;
Table Create Table
......@@ -1088,11 +1075,9 @@ INSERT INTO t1 VALUES();
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
DROP TABLE t1;
SET timestamp=DEFAULT;
#
# DECIMAL + CURRENT_DATE, no truncation
#
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
CREATE TABLE t1 (a DECIMAL(30,6) DEFAULT COALESCE(CURRENT_DATE));
SHOW CREATE TABLE t1;
Table Create Table
......@@ -1103,7 +1088,6 @@ INSERT INTO t1 VALUES();
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
DROP TABLE t1;
SET timestamp=DEFAULT;
#
# COALESCE for SQL Standard <datetime value function>
#
......@@ -1128,7 +1112,6 @@ t1 CREATE TABLE `t1` (
`a` time DEFAULT COALESCE(CURRENT_TIME)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
CREATE TABLE t1 (
a TIMESTAMP DEFAULT CURRENT_TIMESTAMP(6),
b TIMESTAMP DEFAULT COALESCE(CURRENT_TIMESTAMP(6))
......@@ -1147,8 +1130,6 @@ SELECT * FROM t1;
a b
2001-01-01 10:20:30 2001-01-01 10:20:30
DROP TABLE t1;
SET timestamp=DEFAULT;
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
CREATE TABLE t1 (
a DECIMAL(30,0) DEFAULT CURRENT_TIMESTAMP(6),
b DECIMAL(30,0) DEFAULT COALESCE(CURRENT_TIMESTAMP(6))
......@@ -3120,18 +3101,6 @@ SELECT * FROM t1;
a b
notagoodpwd *3A70EE9FC6594F88CE9E959CD51C5A1C002DC937
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(30) DEFAULT ENCRYPT(a,123));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(10) DEFAULT NULL,
`b` varchar(30) DEFAULT ENCRYPT(a,123)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 (a) VALUES ('hello');
SELECT * FROM t1;
a b
hello 12NKz5XM5JeKI
DROP TABLE t1;
CREATE TABLE t1 (
a VARCHAR(30),
b BLOB DEFAULT AES_ENCRYPT(a, 'passwd'),
......
......@@ -106,3 +106,16 @@ OLD_PASSWORD(c1) PASSWORD(c1)
77023ffe214c04ff *82E58A2C08AAFE72C8EB523069CD8ADB33F78F58
DROP TABLE t1;
End of 5.0 tests
Start of 10.2 tests
CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(30) DEFAULT ENCRYPT(a,123));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(10) DEFAULT NULL,
`b` varchar(30) DEFAULT ENCRYPT(a,123)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 (a) VALUES ('hello');
SELECT * FROM t1;
a b
hello 12NKz5XM5JeKI
DROP TABLE t1;
......@@ -166,7 +166,7 @@ select * from t1;
drop table t1, t2;
--echo End of 5.0 tests.
--echo # End of 5.0 tests
--echo #
--echo # Start of 10.1 tests
......@@ -188,9 +188,11 @@ DROP TABLE IF EXISTS t1;
--echo # Start of 10.2 tests
--echo #
--echo
--echo Check that CURRENT_TIMESTAMP works as before
--echo
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
--echo #
--echo # Check that CURRENT_TIMESTAMP works as before
--echo #
CREATE or replace TABLE t1 (event_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
SHOW CREATE TABLE t1;
......@@ -203,26 +205,26 @@ SHOW CREATE TABLE t1;
drop table t1;
--echo
--echo Check default expressions
--echo
--echo #
--echo # Check default expressions
--echo #
create or replace table t1 (a int default 1, b int default (a+1), c int default (a+b)) engine myisam;
show create table t1;
insert into t1 values ();
insert into t1 (a) values (2);
insert into t1 (a,b) values (10,20);
insert into t1 (a,b,c) values (100,200,300);
insert into t1 (a,b,c) values (100,200,400);
select * from t1;
truncate table t1;
insert delayed into t1 values ();
insert delayed into t1 (a) values (2);
insert delayed into t1 (a,b) values (10,20);
insert delayed into t1 (a,b,c) values (100,200,300);
insert delayed into t1 (a,b,c) values (100,200,400);
flush tables t1;
select * from t1;
create or replace table t1 (a int, b blob default (1), c blob default ("hello"), t text default (concat(a,b,c))) engine=myisam;
create or replace table t1 (a int, b blob default (1), c blob default "hello", t text default concat(a,b,c)) engine=myisam;
show create table t1;
insert into t1 (a) values (2);
insert into t1 (a,b) values (10,"test1");
......@@ -247,16 +249,16 @@ drop table t1;
create table t1 (a int);
insert into t1 values(-1);
alter table t1 add b int default 1, add c int default -1, add d int default (1+1), add e timestamp;
select a,b,c,d,e > 0 from t1;
select a,b,c,d,e from t1;
insert into t1 values(10,10,10,10,0);
alter table t1 add f int default (1+1+1) null, add g int default (1+1+1+1) not null,add h int default (2+2+2+2);
select a,b,c,d,e > 0,f,g,h from t1;
select a,b,c,d,e,f,g,h from t1;
show create table t1;
create table t2 like t1;
show create table t2;
insert into t2 (a) values (100);
select a,b,c,d,e > 0,f,g,h from t2;
select a,b,c,d,e,f,g,h from t2;
drop table t1,t2;
create table t1 (a int default (1----1), b int default - 1, c int default +1, e int default (--1));
......@@ -266,18 +268,18 @@ insert into t1 values();
select * from t1;
drop table t1;
--echo
--echo create or replace can delete a table on error
--echo
--echo #
--echo # Create or replace can delete a table on error
--echo #
create table t1 (a int);
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
create or replace table t1 (a int default b, b int default a);
--error ER_NO_SUCH_TABLE
show create table t1;
--echo
--echo Refering to other columns
--echo
--echo #
--echo # Refering to other columns
--echo #
create or replace table t1 (a int default 1, b int default a);
create or replace table t1 (a int default 1, b int as (a));
......@@ -297,21 +299,18 @@ create or replace table t1 (a int default a);
create or replace table t1 (a int default b, b int default (1+1));
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
create or replace table t1 (a int default 1, b int as (c), c int as (a+1));
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
CREATE TABLE t1 (a INT DEFAULT a);
--error ER_NO_DEFAULT_FOR_FIELD
CREATE TABLE t1 (a INT DEFAULT (DEFAULT(a)));
--error ER_NO_DEFAULT_FOR_FIELD
CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a)));
--error ER_NO_DEFAULT_FOR_FIELD
CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL);
drop table if exists t1;
--echo
--echo Allow defaults to refer to not default fields
--echo
--echo #
--echo # Allow defaults to refer to not default fields
--echo #
create or replace table t1 (a int as (b), b int not null);
create or replace table t1 (a int default b, b int not null);
insert into t1 values();
insert into t1 (a) values(1);
insert into t1 (b) values(2);
......@@ -319,9 +318,9 @@ insert into t1 (a,b) values(3,4);
select * from t1;
drop table t1;
--echo
--echo Error handling
--echo
--echo #
--echo # Error handling
--echo #
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a bigint default xxx());
......@@ -336,9 +335,6 @@ CREATE TABLE t1 (a INT, b INT, c INT DEFAULT a DIV b);
--error ER_PARSE_ERROR
CREATE TABLE t1 (a INT, b INT DEFAULT -a);
# Cleanup
drop table if exists t1;
--echo #
--echo # Invalid DEFAULT expressions
--echo #
......@@ -782,7 +778,6 @@ DROP TABLE t1;
--echo #
--echo # DECIMAL + CURRENT_TIMESTAMP, no truncation
--echo #
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
CREATE TABLE t1 (a DECIMAL(30,6) DEFAULT CURRENT_TIMESTAMP(6));
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ();
......@@ -800,27 +795,21 @@ INSERT INTO t1 VALUES();
SET sql_mode = DEFAULT;
DROP TABLE t1;
SET timestamp=DEFAULT;
--echo #
--echo # DECIMAL + CURRENT_TIME, no truncation
--echo #
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
CREATE TABLE t1 (a DECIMAL(30,6) DEFAULT COALESCE(CURRENT_TIME(6)));
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES();
DROP TABLE t1;
SET timestamp=DEFAULT;
--echo #
--echo # DECIMAL + CURRENT_DATE, no truncation
--echo #
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
CREATE TABLE t1 (a DECIMAL(30,6) DEFAULT COALESCE(CURRENT_DATE));
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES();
DROP TABLE t1;
SET timestamp=DEFAULT;
--echo #
......@@ -839,7 +828,6 @@ CREATE TABLE t1 (a TIME DEFAULT COALESCE(CURRENT_TIME));
SHOW CREATE TABLE t1;
DROP TABLE t1;
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
CREATE TABLE t1 (
a TIMESTAMP DEFAULT CURRENT_TIMESTAMP(6),
b TIMESTAMP DEFAULT COALESCE(CURRENT_TIMESTAMP(6))
......@@ -849,9 +837,7 @@ INSERT INTO t1 VALUES ();
SELECT CURRENT_TIMESTAMP(6);
SELECT * FROM t1;
DROP TABLE t1;
SET timestamp=DEFAULT;
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123456');
CREATE TABLE t1 (
a DECIMAL(30,0) DEFAULT CURRENT_TIMESTAMP(6),
b DECIMAL(30,0) DEFAULT COALESCE(CURRENT_TIMESTAMP(6))
......@@ -1866,12 +1852,6 @@ INSERT INTO t1 (a) VALUES ('notagoodpwd');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(30) DEFAULT ENCRYPT(a,123));
SHOW CREATE TABLE t1;
INSERT INTO t1 (a) VALUES ('hello');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (
a VARCHAR(30),
b BLOB DEFAULT AES_ENCRYPT(a, 'passwd'),
......
......@@ -70,3 +70,10 @@ SELECT OLD_PASSWORD(c1), PASSWORD(c1) FROM t1;
DROP TABLE t1;
--echo End of 5.0 tests
--echo Start of 10.2 tests
CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(30) DEFAULT ENCRYPT(a,123));
SHOW CREATE TABLE t1;
INSERT INTO t1 (a) VALUES ('hello');
SELECT * FROM t1;
DROP TABLE t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment