| 1 |
INSTALL COMPONENT "file://component_test_udf_services"; |
| 2 |
CREATE TABLE test.country (utf varchar(40) CHARACTER SET utf8mb4, |
| 3 |
cp12 varchar(40) CHARACTER SET cp1251, |
| 4 |
lt1 VARCHAR(40) CHARACTER SET latin1); |
| 5 |
INSERT INTO test.country(utf, cp12, lt1) VALUES |
| 6 |
(UNHEX('E0A4ADE0A4BEE0A4B0E0A4A4'), UNHEX('C1FAEBE3E0F0E8FF'), |
| 7 |
UNHEX('D6737465727265696368')), |
| 8 |
(UNHEX('D0A0D0BED181D181D0B8D18F'), UNHEX('D1F0E1E8BCE0'), |
| 9 |
UNHEX('42656C6769EB')), |
| 10 |
(UNHEX('496E646961'), UNHEX('F3EAF0E0BFEDE0'), UNHEX('526F6DE26E6961')); |
| 11 |
CREATE TABLE test.names(utf_name varchar(40), eng_name varchar(40)) |
| 12 |
CHARACTER SET utf8mb4; |
| 13 |
INSERT INTO test.names(utf_name, eng_name) VALUES |
| 14 |
(UNHEX('E0A4ADE0A4BEE0A4B0E0A4A4'), 'India'), |
| 15 |
(UNHEX('D091D18AD0BBD0B3D0B0D180D0B8D18F'), 'Bulgaria'), |
| 16 |
(UNHEX('C396737465727265696368'), 'Austria'), |
| 17 |
(UNHEX('D0A0D0BED181D181D0B8D18F'), 'Russia'), |
| 18 |
(UNHEX('D0A1D180D0B1D0B8D198D0B0'), 'Serbia'), |
| 19 |
(UNHEX('42656C6769C3AB'), 'Belgium'), |
| 20 |
(UNHEX('D183D0BAD180D0B0D197D0BDD0B0'), 'Ukraine'), |
| 21 |
(UNHEX('526F6DC3A26E6961'), 'Romania'); |
| 22 |
#------------------------------------------------------------------------ |
| 23 |
# Tests that fetch the charset of second argument and apply that to the |
| 24 |
# return value. This UDF returns first argument. |
| 25 |
#------------------------------------------------------------------------ |
| 26 |
# |
| 27 |
# 1.1 Without conversion the return values of UDF should not match with |
| 28 |
# ut8mb4 values. |
| 29 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as latin1_hex, eng_name |
| 30 |
FROM test.names INNER JOIN test.country ON |
| 31 |
HEX(test_result_charset(lt1, lt1)) = HEX(utf_name) ORDER BY eng_name; |
| 32 |
utf8_hex latin1_hex eng_name |
| 33 |
|
| 34 |
SELECT HEX(utf_name) AS utf8_hex, HEX(cp12) as cp1251_hex, eng_name |
| 35 |
FROM test.names INNER JOIN test.country ON |
| 36 |
HEX(test_result_charset(cp12, cp12)) = HEX(utf_name) ORDER BY eng_name; |
| 37 |
utf8_hex cp1251_hex eng_name |
| 38 |
# |
| 39 |
# 1.2 After conversion the return values should match with ut8mb4 values |
| 40 |
# |
| 41 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as latin1_hex, eng_name |
| 42 |
FROM test.names INNER JOIN test.country ON |
| 43 |
HEX(test_result_charset(lt1, utf)) = HEX(utf_name) ORDER BY eng_name; |
| 44 |
utf8_hex latin1_hex eng_name |
| 45 |
C396737465727265696368 D6737465727265696368 Austria |
| 46 |
42656C6769C3AB 42656C6769EB Belgium |
| 47 |
526F6DC3A26E6961 526F6DE26E6961 Romania |
| 48 |
|
| 49 |
SELECT HEX(utf_name) AS utf8_hex, HEX(cp12) as cp1251_hex, eng_name |
| 50 |
FROM test.names INNER JOIN test.country ON |
| 51 |
HEX(test_result_charset(cp12, utf)) = HEX(utf_name) ORDER BY eng_name; |
| 52 |
utf8_hex cp1251_hex eng_name |
| 53 |
D091D18AD0BBD0B3D0B0D180D0B8D18F C1FAEBE3E0F0E8FF Bulgaria |
| 54 |
D0A1D180D0B1D0B8D198D0B0 D1F0E1E8BCE0 Serbia |
| 55 |
D183D0BAD180D0B0D197D0BDD0B0 F3EAF0E0BFEDE0 Ukraine |
| 56 |
# |
| 57 |
# 1.3 Check the charset of the return value. |
| 58 |
# |
| 59 |
SELECT CHARSET(test_result_charset(cp12, cp12))FROM test.country; |
| 60 |
CHARSET(test_result_charset(cp12, cp12)) |
| 61 |
cp1251 |
| 62 |
cp1251 |
| 63 |
cp1251 |
| 64 |
SELECT CHARSET(test_result_charset(lt1, lt1))FROM test.country; |
| 65 |
CHARSET(test_result_charset(lt1, lt1)) |
| 66 |
latin1 |
| 67 |
latin1 |
| 68 |
latin1 |
| 69 |
# Should be changed to ut8mb4 charset |
| 70 |
SELECT CHARSET(test_result_charset(cp12, utf))FROM test.country; |
| 71 |
CHARSET(test_result_charset(cp12, utf)) |
| 72 |
utf8mb4 |
| 73 |
utf8mb4 |
| 74 |
utf8mb4 |
| 75 |
SELECT CHARSET(test_result_charset(lt1, utf))FROM test.country; |
| 76 |
CHARSET(test_result_charset(lt1, utf)) |
| 77 |
utf8mb4 |
| 78 |
utf8mb4 |
| 79 |
utf8mb4 |
| 80 |
#------------------------------------------------------------------------ |
| 81 |
# Tests that fetch the collation of second argument and apply that to the |
| 82 |
# return value. This UDF returns first argument. |
| 83 |
#------------------------------------------------------------------------ |
| 84 |
# |
| 85 |
# 2.1 Without conversion the return values of UDF should not match with |
| 86 |
# ut8mb4 values. |
| 87 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as lt1_hex, eng_name |
| 88 |
FROM test.names INNER JOIN test.country ON |
| 89 |
HEX(test_result_collation(lt1, lt1)) = HEX(utf_name) ORDER BY eng_name; |
| 90 |
utf8_hex lt1_hex eng_name |
| 91 |
|
| 92 |
SELECT HEX(utf_name) AS utf8_hex, HEX(cp12) as cp12_hex, eng_name |
| 93 |
FROM test.names INNER JOIN test.country ON |
| 94 |
HEX(test_result_collation(cp12, cp12)) = HEX(utf_name) ORDER BY eng_name; |
| 95 |
utf8_hex cp12_hex eng_name |
| 96 |
# |
| 97 |
# 2.2 After conversion the return values should match with ut8mb4 values |
| 98 |
# |
| 99 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as lt1_hex, eng_name |
| 100 |
FROM test.names INNER JOIN test.country ON |
| 101 |
HEX(test_result_collation(lt1, utf)) = HEX(utf_name) ORDER BY eng_name; |
| 102 |
utf8_hex lt1_hex eng_name |
| 103 |
C396737465727265696368 D6737465727265696368 Austria |
| 104 |
42656C6769C3AB 42656C6769EB Belgium |
| 105 |
526F6DC3A26E6961 526F6DE26E6961 Romania |
| 106 |
|
| 107 |
SELECT HEX(utf_name) AS utf8_hex, HEX(cp12) as cp12_hex, eng_name |
| 108 |
FROM test.names INNER JOIN test.country ON |
| 109 |
HEX(test_result_collation(cp12, utf)) = HEX(utf_name) ORDER BY eng_name; |
| 110 |
utf8_hex cp12_hex eng_name |
| 111 |
D091D18AD0BBD0B3D0B0D180D0B8D18F C1FAEBE3E0F0E8FF Bulgaria |
| 112 |
D0A1D180D0B1D0B8D198D0B0 D1F0E1E8BCE0 Serbia |
| 113 |
D183D0BAD180D0B0D197D0BDD0B0 F3EAF0E0BFEDE0 Ukraine |
| 114 |
|
| 115 |
# 2.3 Check the charset of the value returned by the UDF |
| 116 |
# |
| 117 |
SELECT CHARSET(test_result_collation(cp12, cp12)) from test.country; |
| 118 |
CHARSET(test_result_collation(cp12, cp12)) |
| 119 |
cp1251 |
| 120 |
cp1251 |
| 121 |
cp1251 |
| 122 |
SELECT CHARSET(test_result_collation(lt1, lt1)) from test.country; |
| 123 |
CHARSET(test_result_collation(lt1, lt1)) |
| 124 |
latin1 |
| 125 |
latin1 |
| 126 |
latin1 |
| 127 |
# Should be changed to utf8mb4 charset |
| 128 |
SELECT CHARSET(test_result_collation(cp12, utf)) from test.country; |
| 129 |
CHARSET(test_result_collation(cp12, utf)) |
| 130 |
utf8mb4 |
| 131 |
utf8mb4 |
| 132 |
utf8mb4 |
| 133 |
SELECT CHARSET(test_result_collation(lt1, utf)) from test.country; |
| 134 |
CHARSET(test_result_collation(lt1, utf)) |
| 135 |
utf8mb4 |
| 136 |
utf8mb4 |
| 137 |
utf8mb4 |
| 138 |
# 2.6 Check the collation of the value returned by the UDF |
| 139 |
SELECT COLLATION(test_result_collation(cp12, cp12)) from test.country; |
| 140 |
COLLATION(test_result_collation(cp12, cp12)) |
| 141 |
cp1251_general_ci |
| 142 |
cp1251_general_ci |
| 143 |
cp1251_general_ci |
| 144 |
SELECT COLLATION(test_result_collation(lt1, lt1)) from test.country; |
| 145 |
COLLATION(test_result_collation(lt1, lt1)) |
| 146 |
latin1_swedish_ci |
| 147 |
latin1_swedish_ci |
| 148 |
latin1_swedish_ci |
| 149 |
# Should be changed to default utf8mb4 collation. |
| 150 |
SELECT COLLATION(test_result_collation(cp12, utf)) from test.country; |
| 151 |
COLLATION(test_result_collation(cp12, utf)) |
| 152 |
utf8mb4_0900_ai_ci |
| 153 |
utf8mb4_0900_ai_ci |
| 154 |
utf8mb4_0900_ai_ci |
| 155 |
SELECT COLLATION(test_result_collation(lt1, utf)) from test.country; |
| 156 |
COLLATION(test_result_collation(lt1, utf)) |
| 157 |
utf8mb4_0900_ai_ci |
| 158 |
utf8mb4_0900_ai_ci |
| 159 |
utf8mb4_0900_ai_ci |
| 160 |
|
| 161 |
#------------------------------------------------------------------------ |
| 162 |
# Tests that fetch charset of second argument, apply that to first |
| 163 |
# argument and return the same. |
| 164 |
#------------------------------------------------------------------------ |
| 165 |
# |
| 166 |
# 3.1 Without conversion the return values of UDF should not match with |
| 167 |
# ut8mb4 values. |
| 168 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as lt1_hex, eng_name |
| 169 |
FROM test.names INNER JOIN test.country ON |
| 170 |
HEX(test_args_charset(lt1, lt1)) = HEX(utf_name) ORDER BY eng_name; |
| 171 |
utf8_hex lt1_hex eng_name |
| 172 |
|
| 173 |
SELECT HEX(utf_name) AS utf8_hex, HEX(cp12) as cp12_hex, eng_name |
| 174 |
FROM test.names INNER JOIN test.country ON |
| 175 |
HEX(test_args_charset(cp12, cp12)) = HEX(utf_name) ORDER BY eng_name; |
| 176 |
utf8_hex cp12_hex eng_name |
| 177 |
# |
| 178 |
# 3.2 After conversion the return values should match with ut8mb4 values |
| 179 |
# |
| 180 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as lt1_hex, eng_name |
| 181 |
FROM test.names INNER JOIN test.country ON |
| 182 |
HEX(test_args_charset(lt1, utf)) = HEX(utf_name) ORDER BY eng_name; |
| 183 |
utf8_hex lt1_hex eng_name |
| 184 |
C396737465727265696368 D6737465727265696368 Austria |
| 185 |
42656C6769C3AB 42656C6769EB Belgium |
| 186 |
526F6DC3A26E6961 526F6DE26E6961 Romania |
| 187 |
|
| 188 |
SELECT HEX(utf_name) AS utf8_hex, HEX(cp12) as cp12_hex, eng_name |
| 189 |
FROM test.names INNER JOIN test.country ON |
| 190 |
HEX(test_args_charset(cp12, utf)) = HEX(utf_name) ORDER BY eng_name; |
| 191 |
utf8_hex cp12_hex eng_name |
| 192 |
D091D18AD0BBD0B3D0B0D180D0B8D18F C1FAEBE3E0F0E8FF Bulgaria |
| 193 |
D0A1D180D0B1D0B8D198D0B0 D1F0E1E8BCE0 Serbia |
| 194 |
D183D0BAD180D0B0D197D0BDD0B0 F3EAF0E0BFEDE0 Ukraine |
| 195 |
|
| 196 |
# 3.3 Check that charset of returning value is same as |
| 197 |
# default(i.e. binary) |
| 198 |
SELECT CHARSET(test_args_charset(cp12, utf)) from test.country; |
| 199 |
CHARSET(test_args_charset(cp12, utf)) |
| 200 |
binary |
| 201 |
binary |
| 202 |
binary |
| 203 |
SELECT CHARSET(test_args_charset(lt1, utf)) from test.country; |
| 204 |
CHARSET(test_args_charset(lt1, utf)) |
| 205 |
binary |
| 206 |
binary |
| 207 |
binary |
| 208 |
|
| 209 |
#------------------------------------------------------------------------ |
| 210 |
# Tests that fetch collation of second argument, apply that to first |
| 211 |
# argument and return the same. |
| 212 |
#------------------------------------------------------------------------ |
| 213 |
# |
| 214 |
# 4.1 Without conversion the return values of UDF should not match with |
| 215 |
# ut8mb4 values. |
| 216 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as lt1_hex, eng_name |
| 217 |
FROM test.names INNER JOIN test.country ON |
| 218 |
HEX(test_args_collation(lt1, lt1)) = HEX(utf_name) ORDER BY eng_name; |
| 219 |
utf8_hex lt1_hex eng_name |
| 220 |
|
| 221 |
SELECT HEX(utf_name) AS utf8_hex, HEX(cp12) as cp12_hex, eng_name |
| 222 |
FROM test.names INNER JOIN test.country ON |
| 223 |
HEX(test_args_collation(cp12, cp12)) = HEX(utf_name) ORDER BY eng_name; |
| 224 |
utf8_hex cp12_hex eng_name |
| 225 |
# |
| 226 |
# 4.2 After conversion the return values should match with ut8mb4 values |
| 227 |
# |
| 228 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as lt1_hex, eng_name |
| 229 |
FROM test.names INNER JOIN test.country ON |
| 230 |
HEX(test_args_collation(lt1, utf)) = HEX(utf_name) ORDER BY eng_name; |
| 231 |
utf8_hex lt1_hex eng_name |
| 232 |
C396737465727265696368 D6737465727265696368 Austria |
| 233 |
42656C6769C3AB 42656C6769EB Belgium |
| 234 |
526F6DC3A26E6961 526F6DE26E6961 Romania |
| 235 |
|
| 236 |
SELECT HEX(utf_name) AS utf8_hex, HEX(cp12) as cp12_hex, eng_name |
| 237 |
FROM test.names INNER JOIN test.country ON |
| 238 |
HEX(test_args_collation(cp12, utf)) = HEX(utf_name) ORDER BY eng_name; |
| 239 |
utf8_hex cp12_hex eng_name |
| 240 |
D091D18AD0BBD0B3D0B0D180D0B8D18F C1FAEBE3E0F0E8FF Bulgaria |
| 241 |
D0A1D180D0B1D0B8D198D0B0 D1F0E1E8BCE0 Serbia |
| 242 |
D183D0BAD180D0B0D197D0BDD0B0 F3EAF0E0BFEDE0 Ukraine |
| 243 |
|
| 244 |
# 4.3 Check that charset of returning value is same as |
| 245 |
# default(i.e. binary) |
| 246 |
SELECT CHARSET(test_args_collation(cp12, utf)) from test.country; |
| 247 |
CHARSET(test_args_collation(cp12, utf)) |
| 248 |
binary |
| 249 |
binary |
| 250 |
binary |
| 251 |
SELECT CHARSET(test_args_collation(lt1, utf)) from test.country; |
| 252 |
CHARSET(test_args_collation(lt1, utf)) |
| 253 |
binary |
| 254 |
binary |
| 255 |
binary |
| 256 |
|
| 257 |
# 4.4 Check that collation of returning value is same as default |
| 258 |
# |
| 259 |
SELECT CHARSET(test_args_collation(cp12, utf)) from test.country; |
| 260 |
CHARSET(test_args_collation(cp12, utf)) |
| 261 |
binary |
| 262 |
binary |
| 263 |
binary |
| 264 |
SELECT CHARSET(test_args_collation(lt1, utf)) from test.country; |
| 265 |
CHARSET(test_args_collation(lt1, utf)) |
| 266 |
binary |
| 267 |
binary |
| 268 |
binary |
| 269 |
#------------------------------------------------------------------------ |
| 270 |
# Tests that check the Charset conversion happens through constant value. |
| 271 |
# UDFs pick the first argument as return value. |
| 272 |
#------------------------------------------------------------------------ |
| 273 |
# |
| 274 |
# 5.1 Without conversion the return values of UDF should not match with |
| 275 |
# ut8mb4 values. |
| 276 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as lt1_hex, eng_name |
| 277 |
FROM test.names INNER JOIN test.country ON |
| 278 |
HEX(test_result_charset_with_value(lt1, 'latin1')) = HEX(utf_name) |
| 279 |
ORDER BY eng_name; |
| 280 |
utf8_hex lt1_hex eng_name |
| 281 |
|
| 282 |
SELECT HEX(utf_name) AS utf8_hex, HEX(cp12) as cp12_hex, eng_name |
| 283 |
FROM test.names INNER JOIN test.country ON |
| 284 |
HEX(test_result_charset_with_value(cp12, 'cp1251')) = HEX(utf_name) |
| 285 |
ORDER BY eng_name; |
| 286 |
utf8_hex cp12_hex eng_name |
| 287 |
# |
| 288 |
# 5.2 After conversion the return values should match with ut8mb4 values |
| 289 |
# |
| 290 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as lt1_hex, eng_name |
| 291 |
FROM test.names INNER JOIN test.country ON |
| 292 |
HEX(test_result_charset_with_value(lt1, 'utf8mb4')) = HEX(utf_name) |
| 293 |
ORDER BY eng_name; |
| 294 |
utf8_hex lt1_hex eng_name |
| 295 |
C396737465727265696368 D6737465727265696368 Austria |
| 296 |
42656C6769C3AB 42656C6769EB Belgium |
| 297 |
526F6DC3A26E6961 526F6DE26E6961 Romania |
| 298 |
|
| 299 |
SELECT HEX(utf_name) AS utf8_hex, HEX(cp12) as cp12_hex, eng_name |
| 300 |
FROM test.names INNER JOIN test.country ON |
| 301 |
HEX(test_result_charset_with_value(cp12, 'utf8mb4')) = HEX(utf_name) |
| 302 |
ORDER BY eng_name; |
| 303 |
utf8_hex cp12_hex eng_name |
| 304 |
D091D18AD0BBD0B3D0B0D180D0B8D18F C1FAEBE3E0F0E8FF Bulgaria |
| 305 |
D0A1D180D0B1D0B8D198D0B0 D1F0E1E8BCE0 Serbia |
| 306 |
D183D0BAD180D0B0D197D0BDD0B0 F3EAF0E0BFEDE0 Ukraine |
| 307 |
# |
| 308 |
# 5.3 Check the charset of the return value. |
| 309 |
# |
| 310 |
SELECT CHARSET(test_result_charset_with_value(cp12, 'cp1251'))FROM test.country; |
| 311 |
CHARSET(test_result_charset_with_value(cp12, 'cp1251')) |
| 312 |
cp1251 |
| 313 |
cp1251 |
| 314 |
cp1251 |
| 315 |
SELECT CHARSET(test_result_charset_with_value(lt1, 'latin1'))FROM test.country; |
| 316 |
CHARSET(test_result_charset_with_value(lt1, 'latin1')) |
| 317 |
latin1 |
| 318 |
latin1 |
| 319 |
latin1 |
| 320 |
# Should be changed to ut8mb4 charset |
| 321 |
SELECT CHARSET(test_result_charset_with_value(cp12, 'utf8mb4'))FROM test.country; |
| 322 |
CHARSET(test_result_charset_with_value(cp12, 'utf8mb4')) |
| 323 |
utf8mb4 |
| 324 |
utf8mb4 |
| 325 |
utf8mb4 |
| 326 |
SELECT CHARSET(test_result_charset_with_value(lt1, 'utf8mb4'))FROM test.country; |
| 327 |
CHARSET(test_result_charset_with_value(lt1, 'utf8mb4')) |
| 328 |
utf8mb4 |
| 329 |
utf8mb4 |
| 330 |
utf8mb4 |
| 331 |
#------------------------------------------------------------------------ |
| 332 |
# Tests that check the Charset conversion happens through constant value. |
| 333 |
# We specify the collation name of return value. UDF converts the return |
| 334 |
# value into the valid charset for that collation. |
| 335 |
# This UDF picks the first argument as return value. |
| 336 |
#------------------------------------------------------------------------ |
| 337 |
# |
| 338 |
# 5.4 After conversion the return values should match with ut8mb4 values |
| 339 |
# |
| 340 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as lt1_hex, eng_name |
| 341 |
FROM test.names INNER JOIN test.country ON |
| 342 |
HEX(test_result_collation_with_value(lt1, 'utf8mb4_0900_ai_ci')) = |
| 343 |
HEX(utf_name) ORDER BY eng_name; |
| 344 |
utf8_hex lt1_hex eng_name |
| 345 |
C396737465727265696368 D6737465727265696368 Austria |
| 346 |
42656C6769C3AB 42656C6769EB Belgium |
| 347 |
526F6DC3A26E6961 526F6DE26E6961 Romania |
| 348 |
# |
| 349 |
# 5.5 First column has charset as 'cp1251' that is changed to 'utf8mb4' |
| 350 |
# |
| 351 |
SELECT CHARSET(test_result_collation_with_value(cp12, 'utf8mb4_0900_ai_ci')) FROM test.country; |
| 352 |
CHARSET(test_result_collation_with_value(cp12, 'utf8mb4_0900_ai_ci')) |
| 353 |
utf8mb4 |
| 354 |
utf8mb4 |
| 355 |
utf8mb4 |
| 356 |
SELECT CHARSET(test_result_collation_with_value(cp12, 'utf8mb4_0900_bin')) FROM test.country; |
| 357 |
CHARSET(test_result_collation_with_value(cp12, 'utf8mb4_0900_bin')) |
| 358 |
utf8mb4 |
| 359 |
utf8mb4 |
| 360 |
utf8mb4 |
| 361 |
SELECT CHARSET(test_result_collation_with_value(cp12, 'utf8mb4_general_ci')) FROM test.country; |
| 362 |
CHARSET(test_result_collation_with_value(cp12, 'utf8mb4_general_ci')) |
| 363 |
utf8mb4 |
| 364 |
utf8mb4 |
| 365 |
utf8mb4 |
| 366 |
# |
| 367 |
# 5.6 Collation of the return string is also updated as specified |
| 368 |
# |
| 369 |
SELECT COLLATION(test_result_collation_with_value(cp12, 'utf8mb4_0900_ai_ci')) FROM test.country; |
| 370 |
COLLATION(test_result_collation_with_value(cp12, 'utf8mb4_0900_ai_ci')) |
| 371 |
utf8mb4_0900_ai_ci |
| 372 |
utf8mb4_0900_ai_ci |
| 373 |
utf8mb4_0900_ai_ci |
| 374 |
SELECT COLLATION(test_result_collation_with_value(cp12, 'utf8mb4_0900_bin')) FROM test.country; |
| 375 |
COLLATION(test_result_collation_with_value(cp12, 'utf8mb4_0900_bin')) |
| 376 |
utf8mb4_0900_bin |
| 377 |
utf8mb4_0900_bin |
| 378 |
utf8mb4_0900_bin |
| 379 |
SELECT COLLATION(test_result_collation_with_value(cp12, 'utf8mb4_general_ci')) FROM test.country; |
| 380 |
COLLATION(test_result_collation_with_value(cp12, 'utf8mb4_general_ci')) |
| 381 |
utf8mb4_general_ci |
| 382 |
utf8mb4_general_ci |
| 383 |
utf8mb4_general_ci |
| 384 |
#------------------------------------------------------------------------ |
| 385 |
# Tests that check the Charset conversion happens through constant value. |
| 386 |
# We specify the collation name of first argument. UDF returns converted |
| 387 |
# first argument value into the valid charset for that collation. |
| 388 |
#------------------------------------------------------------------------ |
| 389 |
|
| 390 |
# |
| 391 |
# 6.1 After conversion the return values should match with ut8mb4 values |
| 392 |
# |
| 393 |
SELECT HEX(utf_name) AS utf8_hex, HEX(lt1) as lt1_hex, eng_name |
| 394 |
FROM test.names INNER JOIN test.country ON |
| 395 |
HEX(test_args_collation_with_value(lt1, 'utf8mb4_0900_ai_ci')) = |
| 396 |
HEX(utf_name) ORDER BY eng_name; |
| 397 |
utf8_hex lt1_hex eng_name |
| 398 |
C396737465727265696368 D6737465727265696368 Austria |
| 399 |
42656C6769C3AB 42656C6769EB Belgium |
| 400 |
526F6DC3A26E6961 526F6DE26E6961 Romania |
| 401 |
# 6.2 Convert the charset of first argument according to second arg |
| 402 |
SELECT CHARSET(test_args_collation_with_value(cp12, 'utf8mb4_0900_ai_ci')) FROM test.country; |
| 403 |
CHARSET(test_args_collation_with_value(cp12, 'utf8mb4_0900_ai_ci')) |
| 404 |
binary |
| 405 |
binary |
| 406 |
binary |
| 407 |
SELECT CHARSET(test_args_collation_with_value(cp12, 'utf8mb4_0900_bin')) FROM test.country; |
| 408 |
CHARSET(test_args_collation_with_value(cp12, 'utf8mb4_0900_bin')) |
| 409 |
binary |
| 410 |
binary |
| 411 |
binary |
| 412 |
SELECT CHARSET(test_args_collation_with_value(cp12, 'utf8mb4_general_ci')) FROM test.country; |
| 413 |
CHARSET(test_args_collation_with_value(cp12, 'utf8mb4_general_ci')) |
| 414 |
binary |
| 415 |
binary |
| 416 |
binary |
| 417 |
# 6.3 Check the collation of converted charset |
| 418 |
SELECT COLLATION(test_args_collation_with_value(cp12, 'utf8mb4_0900_ai_ci')) FROM test.country; |
| 419 |
COLLATION(test_args_collation_with_value(cp12, 'utf8mb4_0900_ai_ci')) |
| 420 |
binary |
| 421 |
binary |
| 422 |
binary |
| 423 |
SELECT COLLATION(test_args_collation_with_value(cp12, 'utf8mb4_0900_bin')) FROM test.country; |
| 424 |
COLLATION(test_args_collation_with_value(cp12, 'utf8mb4_0900_bin')) |
| 425 |
binary |
| 426 |
binary |
| 427 |
binary |
| 428 |
SELECT COLLATION(test_args_collation_with_value(cp12, 'utf8mb4_general_ci')) FROM test.country; |
| 429 |
COLLATION(test_args_collation_with_value(cp12, 'utf8mb4_general_ci')) |
| 430 |
binary |
| 431 |
binary |
| 432 |
binary |
| 433 |
#------------------------------------------------------------------------ |
| 434 |
# Negative test scenarios |
| 435 |
#------------------------------------------------------------------------ |
| 436 |
SELECT test_result_charset_with_value(cp12, 'utf8mb4_invalid') FROM test.country; |
| 437 |
ERROR HY000: Invalid character set 'utf8mb4_invalid' was specified. It must be a character set name as supported by server. |
| 438 |
SELECT test_args_charset_with_value(cp12, 'utf8mb4_invalid') FROM test.country; |
| 439 |
ERROR HY000: Invalid character set 'utf8mb4_invalid' was specified. It must be a character set name as supported by server. |
| 440 |
SELECT test_result_collation_with_value(cp12, 'utf8mb4_invalid') FROM test.country; |
| 441 |
ERROR HY000: Invalid collation 'utf8mb4_invalid' was specified. It must be a collation name as supported by server. |
| 442 |
SELECT test_result_charset_with_value(cp12, '') FROM test.country; |
| 443 |
ERROR HY000: Invalid character set '' was specified. It must be a character set name as supported by server. |
| 444 |
SELECT test_args_charset_with_value('', 'utf8mb4') FROM test.country; |
| 445 |
test_args_charset_with_value('', 'utf8mb4') |
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
SELECT test_args_charset_with_value(utf, '') FROM test.country; |
| 450 |
ERROR HY000: Invalid character set '' was specified. It must be a character set name as supported by server. |
| 451 |
SELECT test_result_collation_with_value('cp12', '') FROM test.country; |
| 452 |
ERROR HY000: Invalid collation '' was specified. It must be a collation name as supported by server. |
| 453 |
# cleanup |
| 454 |
DROP TABLE test.country; |
| 455 |
DROP TABLE test.names; |
| 456 |
# |
| 457 |
# Verify Bug#31701219. Must not crash. |
| 458 |
# |
| 459 |
SELECT test_args_without_init_deinit_methods("Meow"); |
| 460 |
test_args_without_init_deinit_methods("Meow") |
| 461 |
Meow |
| 462 |
UNINSTALL COMPONENT "file://component_test_udf_services"; |