You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.9 KiB
106 lines
2.9 KiB
# The function should return NULL if any of its arguments are NULL.
|
|
SELECT RPAD(NULL, 5, 'x') AS result;
|
|
result
|
|
NULL
|
|
SELECT RPAD(NULL, NULL, 'x') AS result;
|
|
result
|
|
NULL
|
|
SELECT RPAD(NULL, NULL, NULL) AS result;
|
|
result
|
|
NULL
|
|
SELECT RPAD('a', NULL, 'x') AS result;
|
|
result
|
|
NULL
|
|
SELECT RPAD('a', NULL, NULL) AS result;
|
|
result
|
|
NULL
|
|
SELECT RPAD('a', 5, NULL) AS result;
|
|
result
|
|
NULL
|
|
SELECT RPAD(NULL, 5, NULL) AS result;
|
|
result
|
|
NULL
|
|
# The function should return an empty string if len is 0.
|
|
SELECT RPAD('a', 0, 'x') AS result;
|
|
result
|
|
|
|
SELECT RPAD('a', 0, '') AS result;
|
|
result
|
|
|
|
SELECT RPAD('', 0, 'x') AS result;
|
|
result
|
|
|
|
SELECT RPAD('', 0, '') AS result;
|
|
result
|
|
|
|
# The function should return NULL if len is negative.
|
|
SELECT RPAD('a', -1, 'x');
|
|
RPAD('a', -1, 'x')
|
|
NULL
|
|
# Min signed long long int:
|
|
SELECT RPAD('a', -9223372036854775808, 'x');
|
|
RPAD('a', -9223372036854775808, 'x')
|
|
NULL
|
|
# Min signed long long int - 1
|
|
SELECT RPAD('a', -9223372036854775809, 'x');
|
|
RPAD('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 RPAD('a', 9223372036854775807, 'x');
|
|
RPAD('a', 9223372036854775807, 'x')
|
|
NULL
|
|
Warnings:
|
|
Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated
|
|
# Max signed long long int + 1:
|
|
SELECT RPAD('a', 9223372036854775808, 'x');
|
|
RPAD('a', 9223372036854775808, 'x')
|
|
NULL
|
|
Warnings:
|
|
Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated
|
|
# Max unsigned long long int:
|
|
SELECT RPAD('a', 18446744073709551615, 'x');
|
|
RPAD('a', 18446744073709551615, 'x')
|
|
NULL
|
|
Warnings:
|
|
Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated
|
|
# Max unsigned long long int + 1:
|
|
SELECT RPAD('a', 18446744073709551616, 'x');
|
|
RPAD('a', 18446744073709551616, 'x')
|
|
NULL
|
|
Warnings:
|
|
Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616'
|
|
Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616'
|
|
Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated
|
|
# The function should return an empty string if padstr is empty.
|
|
SELECT RPAD('a', 5, '') AS result;
|
|
result
|
|
|
|
SELECT RPAD('a', 5, '') AS result;
|
|
result
|
|
|
|
# The function should do nothing if str is of length len.
|
|
SELECT RPAD('12345', 5, 'x');
|
|
RPAD('12345', 5, 'x')
|
|
12345
|
|
# The function should chop the string if len is shorter than the length
|
|
# of str.
|
|
SELECT RPAD('123456787890', 1, 'x');
|
|
RPAD('123456787890', 1, 'x')
|
|
1
|
|
SELECT RPAD('123456787890', 5, 'x');
|
|
RPAD('123456787890', 5, 'x')
|
|
12345
|
|
# The function should right pad with padstr so that the string is len
|
|
# bytes long if str is shorter than len.
|
|
SELECT RPAD('123', 5, 'x');
|
|
RPAD('123', 5, 'x')
|
|
123xx
|
|
# The function should repeat padstr also if it has mulitplie characters.
|
|
SELECT RPAD('a', 5, 'xy');
|
|
RPAD('a', 5, 'xy')
|
|
axyxy
|
|
|