Commit b5870a5d authored by Alexander Barkov's avatar Alexander Barkov Committed by Sergei Golubchik

More test for MDEV-10134 Add full support for DEFAULT

Functions DATABASE() and USER().
parent 5ba196c4
......@@ -1118,6 +1118,21 @@ ERROR HY000: Function or expression 'current_user()' is not allowed for 'DEFAULT
CREATE TABLE t1 (a VARCHAR(30) DEFAULT CURRENT_ROLE);
ERROR HY000: Function or expression 'current_role()' is not allowed for 'DEFAULT' of column/constraint 'a'
#
# Other Item_func_sysconst derived functions
#
CREATE TABLE t1 (a VARCHAR(30) DEFAULT DATABASE());
INSERT INTO t1 VALUES ();
USE INFORMATION_SCHEMA;
INSERT INTO test.t1 VALUES ();
USE test;
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
a
test
information_schema
test
DROP TABLE t1;
#
# Check DEFAULT() function
#
CREATE TABLE `t1` (`a` int(11) DEFAULT 3+3,`b` int(11) DEFAULT '1000');
......
......@@ -2665,3 +2665,28 @@ GRANT USAGE ON *.* TO 'mysqltest_u1'@'%'
drop database mysqltest_db1;
drop user mysqltest_u1;
set GLOBAL sql_mode=default;
#
# Start of 10.2 tests
#
#
# MDEV-10134 Add full support for DEFAULT
#
CREATE TABLE t1 (a VARCHAR(30) DEFAULT USER());
INSERT INTO t1 VALUES ();
GRANT ALL PRIVILEGES ON test.* TO dummy@localhost IDENTIFIED BY 'pwd';
connect conn1,localhost,dummy,pwd,test;
connection conn1;
INSERT INTO t1 VALUES ();
connection default;
disconnect conn1;
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
a
root@localhost
dummy@localhost
root@localhost
DROP TABLE t1;
DROP USER dummy@localhost;
#
# End of 10.2 tests
#
......@@ -848,6 +848,18 @@ CREATE TABLE t1 (a VARCHAR(30) DEFAULT CURRENT_USER);
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a VARCHAR(30) DEFAULT CURRENT_ROLE);
--echo #
--echo # Other Item_func_sysconst derived functions
--echo #
CREATE TABLE t1 (a VARCHAR(30) DEFAULT DATABASE());
INSERT INTO t1 VALUES ();
USE INFORMATION_SCHEMA;
INSERT INTO test.t1 VALUES ();
USE test;
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Check DEFAULT() function
--echo #
......
......@@ -2172,3 +2172,29 @@ drop user mysqltest_u1;
set GLOBAL sql_mode=default;
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
--echo #
--echo # Start of 10.2 tests
--echo #
--echo #
--echo # MDEV-10134 Add full support for DEFAULT
--echo #
CREATE TABLE t1 (a VARCHAR(30) DEFAULT USER());
INSERT INTO t1 VALUES ();
GRANT ALL PRIVILEGES ON test.* TO dummy@localhost IDENTIFIED BY 'pwd';
connect (conn1,localhost,dummy,pwd,test);
connection conn1;
INSERT INTO t1 VALUES ();
connection default;
disconnect conn1;
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
DROP TABLE t1;
DROP USER dummy@localhost;
--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