Commit 2654eabb authored by Alexander Barkov's avatar Alexander Barkov Committed by Sergei Golubchik

More test for MDEV-10134 Add full support for DEFAULT

Miscelaneous functions:
LIKE_RANGE_MIN(), LIKE_RANGE_MAX(), WEIGHT_STRING(),
GET_FORMAT(), FORMAT(), LOAD_FILE().
parent 111c0f14
......@@ -3298,3 +3298,24 @@ id name val
32 sp --------------------------------
DROP VIEW v1;
DROP TABLE t1;
#
# Start of 10.2 tests
#
#
# MDEV-10134 Add full support for DEFAULT
#
CREATE TABLE t1 (
a VARCHAR(10),
mn VARCHAR(10) DEFAULT LIKE_RANGE_MIN(a,10),
mx VARCHAR(10) DEFAULT LIKE_RANGE_MAX(a,10)
);
INSERT INTO t1 (a) VALUES ('a'),('a_'),('a%');
SELECT a, HEX(mn), HEX(mx) FROM t1;
a HEX(mn) HEX(mx)
a 61 61
a_ 6100 61FF
a% 61000000000000000000 61FFFFFFFFFFFFFFFFFF
DROP TABLE t1;
#
# End of 10.2 tests
#
......@@ -1848,6 +1848,47 @@ SELECT * FROM t1;
a b
64 40
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, c VARCHAR(30) DEFAULT FORMAT(a,b));
INSERT INTO t1 (a,b) VALUES (10000,3);
SELECT * FROM t1;
a b c
10000 3 10,000.000
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, l VARCHAR(10), c VARCHAR(30) DEFAULT FORMAT(a,b,l));
INSERT INTO t1 (a,b,l) VALUES (10000,2,'no_NO'),(10000,2,'ru_RU'),(10000,2,'ar_BH');
SELECT * FROM t1;
a b l c
10000 2 no_NO 10.000,00
10000 2 ru_RU 10 000,00
10000 2 ar_BH 10,000.00
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(20) DEFAULT GET_FORMAT(DATE,a));
INSERT INTO t1 (a) VALUES ('EUR'),('USA'),('JIS'),('ISO'),('INTERNAL');
SELECT * FROM t1;
a b
EUR %d.%m.%Y
USA %m.%d.%Y
JIS %Y-%m-%d
ISO %Y-%m-%d
INTERNAL %Y%m%d
DROP TABLE t1;
CREATE TABLE t1 (
bits INT,
v_on VARCHAR(10),
v_off VARCHAR(10),
v_separator VARCHAR(10),
number_of_bits INT,
x VARCHAR(30) DEFAULT EXPORT_SET(bits, v_on, v_off, v_separator, number_of_bits)
);
INSERT INTO t1 VALUES (0x50006,'Y','N','',64,DEFAULT);
Warnings:
Warning 1265 Data truncated for column 'x' at row 1
SELECT * FROM t1;
bits v_on v_off v_separator number_of_bits x
327686 Y N 64 NYYNNNNNNNNNNNNNYNYNNNNNNNNNNN
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(30), b BLOB DEFAULT LOAD_FILE(a));
ERROR HY000: Function or expression 'load_file' is not allowed for 'DEFAULT' of column/constraint 'b'
#
# Predicates
#
......
......@@ -144,3 +144,18 @@ DROP TABLE t1;
#
# End of 10.1 tests
#
#
# Start of 10.2 tests
#
#
# MDEV-10134 Add full support for DEFAULT
#
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1, b VARBINARY(10) DEFAULT WEIGHT_STRING(a AS CHAR(10)));
INSERT INTO t1 (a) VALUES ('a');
SELECT a, HEX(b) FROM t1;
a HEX(b)
a 41202020202020202020
DROP TABLE t1;
#
# End of 10.2 tests
#
......@@ -117,3 +117,23 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
--echo #
--echo # Start of 10.2 tests
--echo #
--echo #
--echo # MDEV-10134 Add full support for DEFAULT
--echo #
CREATE TABLE t1 (
a VARCHAR(10),
mn VARCHAR(10) DEFAULT LIKE_RANGE_MIN(a,10),
mx VARCHAR(10) DEFAULT LIKE_RANGE_MAX(a,10)
);
INSERT INTO t1 (a) VALUES ('a'),('a_'),('a%');
SELECT a, HEX(mn), HEX(mx) FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 10.2 tests
--echo #
......@@ -1474,6 +1474,37 @@ INSERT INTO t1 (a) VALUES (64);
SELECT * FROM t1;
DROP TABLE t1;
# QQ: this depends on @@lc_time_names
CREATE TABLE t1 (a INT, b INT, c VARCHAR(30) DEFAULT FORMAT(a,b));
INSERT INTO t1 (a,b) VALUES (10000,3);
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, l VARCHAR(10), c VARCHAR(30) DEFAULT FORMAT(a,b,l));
INSERT INTO t1 (a,b,l) VALUES (10000,2,'no_NO'),(10000,2,'ru_RU'),(10000,2,'ar_BH');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(20) DEFAULT GET_FORMAT(DATE,a));
INSERT INTO t1 (a) VALUES ('EUR'),('USA'),('JIS'),('ISO'),('INTERNAL');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (
bits INT,
v_on VARCHAR(10),
v_off VARCHAR(10),
v_separator VARCHAR(10),
number_of_bits INT,
x VARCHAR(30) DEFAULT EXPORT_SET(bits, v_on, v_off, v_separator, number_of_bits)
);
INSERT INTO t1 VALUES (0x50006,'Y','N','',64,DEFAULT);
SELECT * FROM t1;
DROP TABLE t1;
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a VARCHAR(30), b BLOB DEFAULT LOAD_FILE(a));
--echo #
--echo # Predicates
--echo #
......
......@@ -147,3 +147,19 @@ DROP TABLE t1;
--echo #
--echo # End of 10.1 tests
--echo #
--echo #
--echo # Start of 10.2 tests
--echo #
--echo #
--echo # MDEV-10134 Add full support for DEFAULT
--echo #
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1, b VARBINARY(10) DEFAULT WEIGHT_STRING(a AS CHAR(10)));
INSERT INTO t1 (a) VALUES ('a');
SELECT a, HEX(b) FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 10.2 tests
--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