Skip to content

Commit

Permalink
More test for MDEV-10134 Add full support for DEFAULT
Browse files Browse the repository at this point in the history
Functions DATABASE() and USER().
  • Loading branch information
Alexander Barkov authored and vuvova committed Jun 30, 2016
1 parent 5ba196c commit b5870a5
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mysql-test/r/default.result
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
25 changes: 25 additions & 0 deletions mysql-test/r/grant.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
12 changes: 12 additions & 0 deletions mysql-test/t/default.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
26 changes: 26 additions & 0 deletions mysql-test/t/grant.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 #

0 comments on commit b5870a5

Please sign in to comment.