File: lpad.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (106 lines) | stat: -rw-r--r-- 3,017 bytes parent folder | download
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
# The function should return NULL if any of its arguments are NULL.
SELECT LPAD(NULL, 5, 'x') AS result;
result
NULL
SELECT LPAD(NULL, NULL, 'x') AS result;
result
NULL
SELECT LPAD(NULL, NULL, NULL) AS result;
result
NULL
SELECT LPAD('a', NULL, 'x') AS result;
result
NULL
SELECT LPAD('a', NULL, NULL) AS result;
result
NULL
SELECT LPAD('a', 5, NULL) AS result;
result
NULL
SELECT LPAD(NULL, 5, NULL) AS result;
result
NULL
# The function should return an empty string if len is 0.
SELECT LPAD('a', 0, 'x') AS result;
result

SELECT LPAD('a', 0, '') AS result;
result

SELECT LPAD('', 0, 'x') AS result;
result

SELECT LPAD('', 0, '') AS result;
result

# The function should return NULL if len is negative.
SELECT LPAD('a', -1, 'x');
LPAD('a', -1, 'x')
NULL
# Min signed long long int:
SELECT LPAD('a', -9223372036854775808, 'x');
LPAD('a', -9223372036854775808, 'x')
NULL
# Min signed long long int - 1
SELECT LPAD('a', -9223372036854775809, 'x');
LPAD('a', -9223372036854775809, 'x')
NULL
Warnings:
Warning	1292	Truncated incorrect DECIMAL value: '-9223372036854775809'
Warning	1292	Truncated incorrect DECIMAL value: '-9223372036854775809'
# The function should return NULL with a warning if len is larger than
# max_allowed_packet.
# Max signed long long int:
SELECT LPAD('a', 9223372036854775807, 'x');
LPAD('a', 9223372036854775807, 'x')
NULL
Warnings:
Warning	1301	Result of lpad() was larger than max_allowed_packet (67108864) - truncated
# Max signed long long int + 1:
SELECT LPAD('a', 9223372036854775808, 'x');
LPAD('a', 9223372036854775808, 'x')
NULL
Warnings:
Warning	1301	Result of lpad() was larger than max_allowed_packet (67108864) - truncated
# Max unsigned long long int:
SELECT LPAD('a', 18446744073709551615, 'x');
LPAD('a', 18446744073709551615, 'x')
NULL
Warnings:
Warning	1301	Result of lpad() was larger than max_allowed_packet (67108864) - truncated
# Max unsigned long long int + 1:
SELECT LPAD('a', 18446744073709551616, 'x');
LPAD('a', 18446744073709551616, 'x')
NULL
Warnings:
Warning	1292	Truncated incorrect DECIMAL value: '18446744073709551616'
Warning	1292	Truncated incorrect DECIMAL value: '18446744073709551616'
Warning	1301	Result of lpad() was larger than max_allowed_packet (67108864) - truncated
# The function should return an empty string if padstr is empty.
SELECT LPAD('a', 5, '') AS result;
result

SELECT LPAD('a', 5, '') AS result;
result

# The function should do nothing if str is of length len.
SELECT LPAD('12345', 5, 'x');
LPAD('12345', 5, 'x')
12345
# The function should chop the string if len is shorter than the length
# of str.
SELECT LPAD('123456787890', 1, 'x');
LPAD('123456787890', 1, 'x')
1
SELECT LPAD('123456787890', 5, 'x');
LPAD('123456787890', 5, 'x')
12345
# The function should left pad with padstr so that the string is len
# bytes long if str is shorter than len.
SELECT LPAD('123', 5, 'x');
LPAD('123', 5, 'x')
xx123
# The function should repeat padstr also if it has mulitplie characters.
SELECT LPAD('a', 5, 'xy');
LPAD('a', 5, 'xy')
xyxya