|
| 1 | +drop table if exists t0, t1, t2, t3; |
| 2 | +create table t0 (c int(10), c1 BLOB default (date_format(now(),'%Y-%m-%d'))); |
| 3 | +create table t1 (c int(10), c1 JSON default (date_format(now(),'%Y-%m-%d'))); |
| 4 | +create table t2 (c int(10), c1 ENUM('y','n') default (date_format(now(),'%Y-%m-%d'))); |
| 5 | +create table t3 (c int(10), c1 SET('y','n') default (date_format(now(),'%Y-%m-%d'))); |
| 6 | +INSERT INTO t0 values (); |
| 7 | +INSERT INTO t0 values (1, DEFAULT); |
| 8 | +select count(1) from t0 where c1 = date_format(now(), '%Y-%m-%d'); |
| 9 | +count(1) |
| 10 | +2 |
| 11 | +INSERT INTO t1 values (); |
| 12 | +Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values. |
| 13 | +INSERT INTO t1 values (1, DEFAULT); |
| 14 | +Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values. |
| 15 | +SELECT * from t1; |
| 16 | +c c1 |
| 17 | +INSERT INTO t2 values (); |
| 18 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 19 | +INSERT INTO t2 values (1, DEFAULT); |
| 20 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 21 | +SELECT * from t2; |
| 22 | +c c1 |
| 23 | +INSERT INTO t3 values (); |
| 24 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 25 | +INSERT INTO t3 values (1, DEFAULT); |
| 26 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 27 | +SELECT * from t3; |
| 28 | +c c1 |
| 29 | +show create table t0; |
| 30 | +Table Create Table |
| 31 | +t0 CREATE TABLE `t0` ( |
| 32 | + `c` int(10) DEFAULT NULL, |
| 33 | + `c1` blob DEFAULT date_format(now(), _utf8mb4'%Y-%m-%d') |
| 34 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 35 | +show create table t1; |
| 36 | +Table Create Table |
| 37 | +t1 CREATE TABLE `t1` ( |
| 38 | + `c` int(10) DEFAULT NULL, |
| 39 | + `c1` json DEFAULT date_format(now(), _utf8mb4'%Y-%m-%d') |
| 40 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 41 | +show create table t2; |
| 42 | +Table Create Table |
| 43 | +t2 CREATE TABLE `t2` ( |
| 44 | + `c` int(10) DEFAULT NULL, |
| 45 | + `c1` enum('y','n') DEFAULT date_format(now(), _utf8mb4'%Y-%m-%d') |
| 46 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 47 | +show create table t3; |
| 48 | +Table Create Table |
| 49 | +t3 CREATE TABLE `t3` ( |
| 50 | + `c` int(10) DEFAULT NULL, |
| 51 | + `c1` set('y','n') DEFAULT date_format(now(), _utf8mb4'%Y-%m-%d') |
| 52 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 53 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1'; |
| 54 | +column_default extra |
| 55 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1'; |
| 56 | +column_default extra |
| 57 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1'; |
| 58 | +column_default extra |
| 59 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1'; |
| 60 | +column_default extra |
| 61 | +drop table t0, t1, t2, t3; |
| 62 | +create table t0 (c int(10), c1 BLOB default (REPLACE(UPPER(UUID()), '-', ''))); |
| 63 | +create table t1 (c int(10), c1 JSON default (REPLACE(UPPER(UUID()), '-', ''))); |
| 64 | +create table t2 (c int(10), c1 ENUM('y','n') default (REPLACE(UPPER(UUID()), '-', ''))); |
| 65 | +create table t3 (c int(10), c1 SET('y','n') default (REPLACE(UPPER(UUID()), '-', ''))); |
| 66 | +INSERT INTO t0 values (); |
| 67 | +INSERT INTO t0 values (1, DEFAULT); |
| 68 | +SELECT count(1) FROM t0 WHERE c1 REGEXP '^[A-Z0-9]+$'; |
| 69 | +count(1) |
| 70 | +2 |
| 71 | +INSERT INTO t1 values (); |
| 72 | +Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values. |
| 73 | +INSERT INTO t1 values (1, DEFAULT); |
| 74 | +Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values. |
| 75 | +SELECT * from t1; |
| 76 | +c c1 |
| 77 | +INSERT INTO t2 values (); |
| 78 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 79 | +INSERT INTO t2 values (1, DEFAULT); |
| 80 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 81 | +SELECT * from t2; |
| 82 | +c c1 |
| 83 | +INSERT INTO t3 values (); |
| 84 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 85 | +INSERT INTO t3 values (1, DEFAULT); |
| 86 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 87 | +SELECT * from t3; |
| 88 | +c c1 |
| 89 | +show create table t0; |
| 90 | +Table Create Table |
| 91 | +t0 CREATE TABLE `t0` ( |
| 92 | + `c` int(10) DEFAULT NULL, |
| 93 | + `c1` blob DEFAULT replace(upper(uuid()), _utf8mb4'-', _utf8mb4'') |
| 94 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 95 | +show create table t1; |
| 96 | +Table Create Table |
| 97 | +t1 CREATE TABLE `t1` ( |
| 98 | + `c` int(10) DEFAULT NULL, |
| 99 | + `c1` json DEFAULT replace(upper(uuid()), _utf8mb4'-', _utf8mb4'') |
| 100 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 101 | +show create table t2; |
| 102 | +Table Create Table |
| 103 | +t2 CREATE TABLE `t2` ( |
| 104 | + `c` int(10) DEFAULT NULL, |
| 105 | + `c1` enum('y','n') DEFAULT replace(upper(uuid()), _utf8mb4'-', _utf8mb4'') |
| 106 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 107 | +show create table t3; |
| 108 | +Table Create Table |
| 109 | +t3 CREATE TABLE `t3` ( |
| 110 | + `c` int(10) DEFAULT NULL, |
| 111 | + `c1` set('y','n') DEFAULT replace(upper(uuid()), _utf8mb4'-', _utf8mb4'') |
| 112 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 113 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1'; |
| 114 | +column_default extra |
| 115 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1'; |
| 116 | +column_default extra |
| 117 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1'; |
| 118 | +column_default extra |
| 119 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1'; |
| 120 | +column_default extra |
| 121 | +drop table t0, t1, t2, t3; |
| 122 | +create table t0 (c int(10), c1 BLOB default (str_to_date('1980-01-01','%Y-%m-%d'))); |
| 123 | +create table t1 (c int(10), c1 JSON default (str_to_date('1980-01-01','%Y-%m-%d'))); |
| 124 | +create table t2 (c int(10), c1 ENUM('y','n') default (str_to_date('1980-01-01','%Y-%m-%d'))); |
| 125 | +create table t3 (c int(10), c1 SET('y','n') default (str_to_date('1980-01-01','%Y-%m-%d'))); |
| 126 | +INSERT INTO t0 values (); |
| 127 | +INSERT INTO t0 values (1, DEFAULT); |
| 128 | +SELECT * from t0; |
| 129 | +c c1 |
| 130 | +NULL 1980-01-01 |
| 131 | +1 1980-01-01 |
| 132 | +INSERT INTO t1 values (); |
| 133 | +INSERT INTO t1 values (1, DEFAULT); |
| 134 | +SELECT * from t1; |
| 135 | +c c1 |
| 136 | +NULL "1980-01-01" |
| 137 | +1 "1980-01-01" |
| 138 | +INSERT INTO t2 values (); |
| 139 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 140 | +INSERT INTO t2 values (1, DEFAULT); |
| 141 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 142 | +SELECT * from t2; |
| 143 | +c c1 |
| 144 | +INSERT INTO t3 values (); |
| 145 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 146 | +INSERT INTO t3 values (1, DEFAULT); |
| 147 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 148 | +SELECT * from t3; |
| 149 | +c c1 |
| 150 | +show create table t0; |
| 151 | +Table Create Table |
| 152 | +t0 CREATE TABLE `t0` ( |
| 153 | + `c` int(10) DEFAULT NULL, |
| 154 | + `c1` blob DEFAULT str_to_date(_utf8mb4'1980-01-01', _utf8mb4'%Y-%m-%d') |
| 155 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 156 | +show create table t1; |
| 157 | +Table Create Table |
| 158 | +t1 CREATE TABLE `t1` ( |
| 159 | + `c` int(10) DEFAULT NULL, |
| 160 | + `c1` json DEFAULT str_to_date(_utf8mb4'1980-01-01', _utf8mb4'%Y-%m-%d') |
| 161 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 162 | +show create table t2; |
| 163 | +Table Create Table |
| 164 | +t2 CREATE TABLE `t2` ( |
| 165 | + `c` int(10) DEFAULT NULL, |
| 166 | + `c1` enum('y','n') DEFAULT str_to_date(_utf8mb4'1980-01-01', _utf8mb4'%Y-%m-%d') |
| 167 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 168 | +show create table t3; |
| 169 | +Table Create Table |
| 170 | +t3 CREATE TABLE `t3` ( |
| 171 | + `c` int(10) DEFAULT NULL, |
| 172 | + `c1` set('y','n') DEFAULT str_to_date(_utf8mb4'1980-01-01', _utf8mb4'%Y-%m-%d') |
| 173 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 174 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1'; |
| 175 | +column_default extra |
| 176 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1'; |
| 177 | +column_default extra |
| 178 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1'; |
| 179 | +column_default extra |
| 180 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1'; |
| 181 | +column_default extra |
| 182 | +drop table t0, t1, t2, t3; |
| 183 | +create table t0 (c int(10), c1 BLOB default (upper(substring_index(user(),'@',1)))); |
| 184 | +create table t1 (c int(10), c1 JSON default (upper(substring_index(user(),'@',1)))); |
| 185 | +create table t2 (c int(10), c1 ENUM('y','n') default (upper(substring_index(user(),'@',1)))); |
| 186 | +create table t3 (c int(10), c1 SET('y','n') default (upper(substring_index(user(),'@',1)))); |
| 187 | +INSERT INTO t0 values (); |
| 188 | +INSERT INTO t0 values (1, DEFAULT); |
| 189 | +SELECT * from t0; |
| 190 | +c c1 |
| 191 | +NULL ROOT |
| 192 | +1 ROOT |
| 193 | +INSERT INTO t1 values (); |
| 194 | +Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values. |
| 195 | +INSERT INTO t1 values (1, DEFAULT); |
| 196 | +Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values. |
| 197 | +SELECT * from t1; |
| 198 | +c c1 |
| 199 | +INSERT INTO t2 values (); |
| 200 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 201 | +INSERT INTO t2 values (1, DEFAULT); |
| 202 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 203 | +SELECT * from t2; |
| 204 | +c c1 |
| 205 | +INSERT INTO t3 values (); |
| 206 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 207 | +INSERT INTO t3 values (1, DEFAULT); |
| 208 | +Error 1265 (01000): Data truncated for column '%s' at row %d |
| 209 | +SELECT * from t3; |
| 210 | +c c1 |
| 211 | +show create table t0; |
| 212 | +Table Create Table |
| 213 | +t0 CREATE TABLE `t0` ( |
| 214 | + `c` int(10) DEFAULT NULL, |
| 215 | + `c1` blob DEFAULT upper(substring_index(user(), _utf8mb4'@', 1)) |
| 216 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 217 | +show create table t1; |
| 218 | +Table Create Table |
| 219 | +t1 CREATE TABLE `t1` ( |
| 220 | + `c` int(10) DEFAULT NULL, |
| 221 | + `c1` json DEFAULT upper(substring_index(user(), _utf8mb4'@', 1)) |
| 222 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 223 | +show create table t2; |
| 224 | +Table Create Table |
| 225 | +t2 CREATE TABLE `t2` ( |
| 226 | + `c` int(10) DEFAULT NULL, |
| 227 | + `c1` enum('y','n') DEFAULT upper(substring_index(user(), _utf8mb4'@', 1)) |
| 228 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 229 | +show create table t3; |
| 230 | +Table Create Table |
| 231 | +t3 CREATE TABLE `t3` ( |
| 232 | + `c` int(10) DEFAULT NULL, |
| 233 | + `c1` set('y','n') DEFAULT upper(substring_index(user(), _utf8mb4'@', 1)) |
| 234 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
| 235 | +drop table t0, t1, t2, t3; |
| 236 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1'; |
| 237 | +column_default extra |
| 238 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1'; |
| 239 | +column_default extra |
| 240 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1'; |
| 241 | +column_default extra |
| 242 | +SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1'; |
| 243 | +column_default extra |
0 commit comments