1086.10.2
by Devananda
added test case |
1 |
CREATE TABLE t1 (a int auto_increment primary key, v varchar(255)); |
2 |
INSERT INTO t1 (v) VALUES |
|
3 |
(NULL), |
|
4 |
(''), |
|
5 |
(0), |
|
6 |
('abc'), |
|
7 |
('你好'), |
|
8 |
('☃'); |
|
9 |
SELECT LENGTH(NULL), OCTET_LENGTH(NULL); |
|
10 |
LENGTH(NULL) OCTET_LENGTH(NULL) |
|
11 |
NULL NULL |
|
12 |
SELECT LENGTH(''), OCTET_LENGTH(''); |
|
13 |
LENGTH('') OCTET_LENGTH('') |
|
14 |
0 0 |
|
15 |
SELECT LENGTH('0'), OCTET_LENGTH('0'); |
|
16 |
LENGTH('0') OCTET_LENGTH('0') |
|
17 |
1 1 |
|
18 |
SELECT LENGTH('abc'), OCTET_LENGTH('abc'); |
|
19 |
LENGTH('abc') OCTET_LENGTH('abc') |
|
20 |
3 3 |
|
21 |
SELECT LENGTH('你好'), OCTET_LENGTH('你好'); |
|
22 |
LENGTH('你好') OCTET_LENGTH('你好') |
|
23 |
6 6 |
|
24 |
SELECT LENGTH('☃'), OCTET_LENGTH('☃'); |
|
25 |
LENGTH('☃') OCTET_LENGTH('☃') |
|
26 |
3 3 |
|
27 |
SELECT a, v, LENGTH(v), OCTET_LENGTH(v) FROM t1; |
|
28 |
a v LENGTH(v) OCTET_LENGTH(v) |
|
29 |
1 NULL NULL NULL |
|
30 |
2 0 0 |
|
31 |
3 0 1 1 |
|
32 |
4 abc 3 3 |
|
33 |
5 你好 6 6 |
|
34 |
6 ☃ 3 3 |
|
35 |
SELECT CHAR_LENGTH(NULL), CHARACTER_LENGTH(NULL); |
|
36 |
CHAR_LENGTH(NULL) CHARACTER_LENGTH(NULL) |
|
37 |
NULL NULL |
|
38 |
SELECT CHAR_LENGTH(''), CHARACTER_LENGTH(''); |
|
39 |
CHAR_LENGTH('') CHARACTER_LENGTH('') |
|
40 |
0 0 |
|
41 |
SELECT CHAR_LENGTH('0'), CHARACTER_LENGTH('0'); |
|
42 |
CHAR_LENGTH('0') CHARACTER_LENGTH('0') |
|
43 |
1 1 |
|
44 |
SELECT CHAR_LENGTH('abc'), CHARACTER_LENGTH('abc'); |
|
45 |
CHAR_LENGTH('abc') CHARACTER_LENGTH('abc') |
|
46 |
3 3 |
|
47 |
SELECT CHAR_LENGTH('你好'), CHARACTER_LENGTH('你好'); |
|
48 |
CHAR_LENGTH('你好') CHARACTER_LENGTH('你好') |
|
49 |
2 2 |
|
50 |
SELECT CHAR_LENGTH('☃'), CHARACTER_LENGTH('☃'); |
|
51 |
CHAR_LENGTH('☃') CHARACTER_LENGTH('☃') |
|
52 |
1 1 |
|
53 |
SELECT A, V, CHAR_LENGTH(V), CHARACTER_LENGTH(v) from t1; |
|
54 |
A V CHAR_LENGTH(V) CHARACTER_LENGTH(v) |
|
55 |
1 NULL NULL NULL |
|
56 |
2 0 0 |
|
57 |
3 0 1 1 |
|
58 |
4 abc 3 3 |
|
59 |
5 你好 2 2 |
|
60 |
6 ☃ 1 1 |
|
61 |
DROP TABLE IF EXISTS t1; |