Skip to content

Commit b5870a5

Browse files
Alexander Barkovvuvova
authored andcommitted
More test for MDEV-10134 Add full support for DEFAULT
Functions DATABASE() and USER().
1 parent 5ba196c commit b5870a5

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

mysql-test/r/default.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,21 @@ ERROR HY000: Function or expression 'current_user()' is not allowed for 'DEFAULT
11181118
CREATE TABLE t1 (a VARCHAR(30) DEFAULT CURRENT_ROLE);
11191119
ERROR HY000: Function or expression 'current_role()' is not allowed for 'DEFAULT' of column/constraint 'a'
11201120
#
1121+
# Other Item_func_sysconst derived functions
1122+
#
1123+
CREATE TABLE t1 (a VARCHAR(30) DEFAULT DATABASE());
1124+
INSERT INTO t1 VALUES ();
1125+
USE INFORMATION_SCHEMA;
1126+
INSERT INTO test.t1 VALUES ();
1127+
USE test;
1128+
INSERT INTO t1 VALUES ();
1129+
SELECT * FROM t1;
1130+
a
1131+
test
1132+
information_schema
1133+
test
1134+
DROP TABLE t1;
1135+
#
11211136
# Check DEFAULT() function
11221137
#
11231138
CREATE TABLE `t1` (`a` int(11) DEFAULT 3+3,`b` int(11) DEFAULT '1000');

mysql-test/r/grant.result

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,3 +2665,28 @@ GRANT USAGE ON *.* TO 'mysqltest_u1'@'%'
26652665
drop database mysqltest_db1;
26662666
drop user mysqltest_u1;
26672667
set GLOBAL sql_mode=default;
2668+
#
2669+
# Start of 10.2 tests
2670+
#
2671+
#
2672+
# MDEV-10134 Add full support for DEFAULT
2673+
#
2674+
CREATE TABLE t1 (a VARCHAR(30) DEFAULT USER());
2675+
INSERT INTO t1 VALUES ();
2676+
GRANT ALL PRIVILEGES ON test.* TO dummy@localhost IDENTIFIED BY 'pwd';
2677+
connect conn1,localhost,dummy,pwd,test;
2678+
connection conn1;
2679+
INSERT INTO t1 VALUES ();
2680+
connection default;
2681+
disconnect conn1;
2682+
INSERT INTO t1 VALUES ();
2683+
SELECT * FROM t1;
2684+
a
2685+
root@localhost
2686+
dummy@localhost
2687+
root@localhost
2688+
DROP TABLE t1;
2689+
DROP USER dummy@localhost;
2690+
#
2691+
# End of 10.2 tests
2692+
#

mysql-test/t/default.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,18 @@ CREATE TABLE t1 (a VARCHAR(30) DEFAULT CURRENT_USER);
848848
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
849849
CREATE TABLE t1 (a VARCHAR(30) DEFAULT CURRENT_ROLE);
850850

851+
--echo #
852+
--echo # Other Item_func_sysconst derived functions
853+
--echo #
854+
CREATE TABLE t1 (a VARCHAR(30) DEFAULT DATABASE());
855+
INSERT INTO t1 VALUES ();
856+
USE INFORMATION_SCHEMA;
857+
INSERT INTO test.t1 VALUES ();
858+
USE test;
859+
INSERT INTO t1 VALUES ();
860+
SELECT * FROM t1;
861+
DROP TABLE t1;
862+
851863
--echo #
852864
--echo # Check DEFAULT() function
853865
--echo #

mysql-test/t/grant.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,3 +2172,29 @@ drop user mysqltest_u1;
21722172
set GLOBAL sql_mode=default;
21732173
# Wait till we reached the initial number of concurrent sessions
21742174
--source include/wait_until_count_sessions.inc
2175+
2176+
--echo #
2177+
--echo # Start of 10.2 tests
2178+
--echo #
2179+
2180+
--echo #
2181+
--echo # MDEV-10134 Add full support for DEFAULT
2182+
--echo #
2183+
2184+
2185+
CREATE TABLE t1 (a VARCHAR(30) DEFAULT USER());
2186+
INSERT INTO t1 VALUES ();
2187+
GRANT ALL PRIVILEGES ON test.* TO dummy@localhost IDENTIFIED BY 'pwd';
2188+
connect (conn1,localhost,dummy,pwd,test);
2189+
connection conn1;
2190+
INSERT INTO t1 VALUES ();
2191+
connection default;
2192+
disconnect conn1;
2193+
INSERT INTO t1 VALUES ();
2194+
SELECT * FROM t1;
2195+
DROP TABLE t1;
2196+
DROP USER dummy@localhost;
2197+
2198+
--echo #
2199+
--echo # End of 10.2 tests
2200+
--echo #

0 commit comments

Comments
 (0)