1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
|
SET @@session.storage_engine = 'InnoDB';
# RAND()
create table t1 (b double as (rand()));
ERROR HY000: Function or expression is not allowed for column 'b'
# LOAD_FILE()
create table t1 (a varchar(64), b varchar(1024) as (load_file(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# CURDATE()
create table t1 (a datetime as (curdate()));
ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_DATE(), CURRENT_DATE
create table t1 (a datetime as (current_date));
ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a datetime as (current_date()));
ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_TIME(), CURRENT_TIME
create table t1 (a datetime as (current_time));
ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a datetime as (current_time()));
ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
create table t1 (a datetime as (current_timestamp()));
ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a datetime as (current_timestamp));
ERROR HY000: Function or expression is not allowed for column 'a'
# CURTIME()
create table t1 (a datetime as (curtime()));
ERROR HY000: Function or expression is not allowed for column 'a'
# LOCALTIME(), LOCALTIME
create table t1 (a datetime, b varchar(10) as (localtime()));
ERROR HY000: Function or expression is not allowed for column 'b'
create table t1 (a datetime, b varchar(10) as (localtime));
ERROR HY000: Function or expression is not allowed for column 'b'
# LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6)
create table t1 (a datetime, b varchar(10) as (localtimestamp()));
ERROR HY000: Function or expression is not allowed for column 'b'
create table t1 (a datetime, b varchar(10) as (localtimestamp));
ERROR HY000: Function or expression is not allowed for column 'b'
# NOW()
create table t1 (a datetime, b varchar(10) as (now()));
ERROR HY000: Function or expression is not allowed for column 'b'
# SYSDATE()
create table t1 (a int, b varchar(10) as (sysdate()));
ERROR HY000: Function or expression is not allowed for column 'b'
# UNIX_TIMESTAMP()
create table t1 (a datetime, b datetime as (unix_timestamp()));
ERROR HY000: Function or expression is not allowed for column 'b'
# UTC_DATE()
create table t1 (a datetime, b datetime as (utc_date()));
ERROR HY000: Function or expression is not allowed for column 'b'
# UTC_TIME()
create table t1 (a datetime, b datetime as (utc_time()));
ERROR HY000: Function or expression is not allowed for column 'b'
# UTC_TIMESTAMP()
create table t1 (a datetime, b datetime as (utc_timestamp()));
ERROR HY000: Function or expression is not allowed for column 'b'
# MATCH()
# BENCHMARK()
create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3)));
ERROR HY000: Function or expression is not allowed for column 'b'
# CONNECTION_ID()
create table t1 (a int as (connection_id()));
ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_USER(), CURRENT_USER
create table t1 (a varchar(32) as (current_user()));
ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a varchar(32) as (current_user));
ERROR HY000: Function or expression is not allowed for column 'a'
# DATABASE()
create table t1 (a varchar(1024), b varchar(1024) as (database()));
ERROR HY000: Function or expression is not allowed for column 'b'
# FOUND_ROWS()
create table t1 (a varchar(1024), b varchar(1024) as (found_rows()));
ERROR HY000: Function or expression is not allowed for column 'b'
# GET_LOCK()
create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10)));
ERROR HY000: Function or expression is not allowed for column 'b'
# IS_FREE_LOCK()
create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# IS_USED_LOCK()
create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# LAST_INSERT_ID()
create table t1 (a int as (last_insert_id()));
ERROR HY000: Function or expression is not allowed for column 'a'
# MASTER_POS_WAIT()
create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2)));
ERROR HY000: Function or expression is not allowed for column 'b'
# NAME_CONST()
create table t1 (a varchar(32) as (name_const('test',1)));
ERROR HY000: Function or expression is not allowed for column 'a'
# RELEASE_LOCK()
create table t1 (a varchar(32), b int as (release_lock(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# ROW_COUNT()
create table t1 (a int as (row_count()));
ERROR HY000: Function or expression is not allowed for column 'a'
# SCHEMA()
create table t1 (a varchar(32) as (schema()));
ERROR HY000: Function or expression is not allowed for column 'a'
# SESSION_USER()
create table t1 (a varchar(32) as (session_user()));
ERROR HY000: Function or expression is not allowed for column 'a'
# SLEEP()
create table t1 (a int, b int as (sleep(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# SYSTEM_USER()
create table t1 (a varchar(32) as (system_user()));
ERROR HY000: Function or expression is not allowed for column 'a'
# USER()
create table t1 (a varchar(1024), b varchar(1024) as (user()));
ERROR HY000: Function or expression is not allowed for column 'b'
# UUID_SHORT()
create table t1 (a varchar(1024) as (uuid_short()));
ERROR HY000: Function or expression is not allowed for column 'a'
# UUID()
create table t1 (a varchar(1024) as (uuid()));
ERROR HY000: Function or expression is not allowed for column 'a'
# VALUES()
create table t1 (a varchar(1024), b varchar(1024) as (values(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# VERSION()
create table t1 (a varchar(1024), b varchar(1024) as (version()));
ERROR HY000: Function or expression is not allowed for column 'b'
# ENCRYPT()
create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# Stored procedures
create procedure p1()
begin
select current_user();
end //
create function f1()
returns int
begin
return 1;
end //
create table t1 (a int as (p1()));
ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a int as (f1()));
ERROR HY000: Function or expression is not allowed for column 'a'
drop procedure p1;
drop function f1;
# Unknown functions
create table t1 (a int as (f1()));
ERROR HY000: Function or expression is not allowed for column 'a'
#
# GROUP BY FUNCTIONS
#
# AVG()
create table t1 (a int, b int as (avg(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# BIT_AND()
create table t1 (a int, b int as (bit_and(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# BIT_OR()
create table t1 (a int, b int as (bit_or(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# BIT_XOR()
create table t1 (a int, b int as (bit_xor(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# COUNT(DISTINCT)
create table t1 (a int, b int as (count(distinct a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# COUNT()
create table t1 (a int, b int as (count(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# GROUP_CONCAT()
create table t1 (a varchar(32), b int as (group_concat(a,'')));
ERROR HY000: Function or expression is not allowed for column 'b'
# MAX()
create table t1 (a int, b int as (max(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# MIN()
create table t1 (a int, b int as (min(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# STD()
create table t1 (a int, b int as (std(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# STDDEV_POP()
create table t1 (a int, b int as (stddev_pop(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# STDDEV_SAMP()
create table t1 (a int, b int as (stddev_samp(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# STDDEV()
create table t1 (a int, b int as (stddev(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# SUM()
create table t1 (a int, b int as (sum(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# VAR_POP()
create table t1 (a int, b int as (var_pop(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# VAR_SAMP()
create table t1 (a int, b int as (var_samp(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
# VARIANCE()
create table t1 (a int, b int as (variance(a)));
ERROR HY000: Function or expression is not allowed for column 'b'
#
# XML FUNCTIONS
#
# ExtractValue()
create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]')));
ERROR HY000: Function or expression is not allowed for column 'b'
# UpdateXML()
create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>')));
ERROR HY000: Function or expression is not allowed for column 'b'
#
# Sub-selects
#
create table t1 (a int);
create table t2 (a int, b int as (select count(*) from t1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'select count(*) from t1))' at line 1
drop table t1;
create table t1 (a int, b int as ((select 1)));
ERROR HY000: Function or expression is not allowed for column 'b'
create table t1 (a int, b int as (a+(select 1)));
ERROR HY000: Function or expression is not allowed for column 'b'
#
# SP functions
#
drop function if exists sub1;
create function sub1(i int) returns int deterministic
return i+1;
select sub1(1);
sub1(1)
2
create table t1 (a int, b int as (a+sub3(1)));
ERROR HY000: Function or expression is not allowed for column 'b'
drop function sub1;
#
# Long expression
create table t1 (a int, b varchar(300) as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')));
drop table t1;
create table t1 (a int, b varchar(300) as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')));
ERROR HY000: String 'concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long for VIRTUAL COLUMN EXPRESSION (should be no longer than 252)
#
# Constant expression
create table t1 (a int as (PI()));
ERROR HY000: Constant expression in computed column function is not allowed
|