Commit 6cb4731f authored by Alexander Barkov's avatar Alexander Barkov Committed by Sergei Golubchik

More test for MDEV-10134 Add full support for DEFAULT

- INT result functions
- CAST variants: COLLATE, BINARY, CONVERT(..USING)
parent 778a1a4a
......@@ -1187,6 +1187,47 @@ a b c
3.141592653589793 180 3.141592653589793
DROP TABLE t1;
#
# INT result functions
#
CREATE TABLE t1 (a INT, b INT DEFAULT INTERVAL(a, 10, 20, 30, 40));
INSERT INTO t1 (a) VALUES (34);
SELECT * FROM t1;
a b
34 3
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, c INT DEFAULT a DIV b);
INSERT INTO t1 (a, b) VALUES (13, 3);
SELECT * FROM t1;
a b c
13 3 4
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT DEFAULT SIGN(a));
INSERT INTO t1 (a) VALUES (-10),(0), (10);
SELECT * FROM t1;
a b
-10 -1
0 0
10 1
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(30), b INT DEFAULT FIELD(a, 'Hej', 'ej', 'Heja', 'hej', 'foo'));
INSERT INTO t1 (a) VALUES ('ej');
SELECT * FROM t1;
a b
ej 2
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(30), b INT DEFAULT FIND_IN_SET(a, 'Hej,ej,Heja,hej,foo'));
INSERT INTO t1 (a) VALUES ('ej');
SELECT * FROM t1;
a b
ej 2
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(30), b INT DEFAULT ASCII(a), c INT DEFAULT ORD(a));
INSERT INTO t1 (a) VALUES ('a');
SELECT * FROM t1;
a b c
a 97 97
DROP TABLE t1;
#
# Temporal functions
#
# Item_temporal_hybrid_func
......@@ -1613,6 +1654,17 @@ SELECT * FROM t1;
a b
18446744073709551615 -1
DROP TABLE t1;
CREATE TABLE t1 (
a VARCHAR(10) CHARACTER SET latin1,
b VARCHAR(10) CHARACTER SET latin1 DEFAULT a COLLATE latin1_bin,
c VARCHAR(10) CHARACTER SET utf8 DEFAULT CONVERT(a USING utf8),
d VARBINARY(10) DEFAULT BINARY(a)
);
INSERT INTO t1 (a) VALUES ('a');
SELECT * FROM t1;
a b c d
a a a a
DROP TABLE t1;
#
# Bit functions
#
......
......@@ -913,6 +913,40 @@ DROP TABLE t1;
#SELECT * FROM t1;
#DROP TABLE t1;
--echo #
--echo # INT result functions
--echo #
CREATE TABLE t1 (a INT, b INT DEFAULT INTERVAL(a, 10, 20, 30, 40));
INSERT INTO t1 (a) VALUES (34);
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, c INT DEFAULT a DIV b);
INSERT INTO t1 (a, b) VALUES (13, 3);
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT DEFAULT SIGN(a));
INSERT INTO t1 (a) VALUES (-10),(0), (10);
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(30), b INT DEFAULT FIELD(a, 'Hej', 'ej', 'Heja', 'hej', 'foo'));
INSERT INTO t1 (a) VALUES ('ej');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(30), b INT DEFAULT FIND_IN_SET(a, 'Hej,ej,Heja,hej,foo'));
INSERT INTO t1 (a) VALUES ('ej');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(30), b INT DEFAULT ASCII(a), c INT DEFAULT ORD(a));
INSERT INTO t1 (a) VALUES ('a');
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Temporal functions
......@@ -1278,6 +1312,17 @@ INSERT INTO t1 (a) VALUES (0xFFFFFFFFFFFFFFFF);
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (
a VARCHAR(10) CHARACTER SET latin1,
b VARCHAR(10) CHARACTER SET latin1 DEFAULT a COLLATE latin1_bin,
c VARCHAR(10) CHARACTER SET utf8 DEFAULT CONVERT(a USING utf8),
d VARBINARY(10) DEFAULT BINARY(a)
);
INSERT INTO t1 (a) VALUES ('a');
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Bit functions
--echo #
......
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