1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-30879 Add support for up to BASE 62 to CONV()

BASE 62 uses 0-9, A-Z and then a-z to give the numbers 0-61. This patch
increases the range of the string functions to cover this.

Based on ideas and tests in PR #2589, but re-written into the charset
functions.

Includes fix by Sergei, UBSAN complained:
ctype-simple.c:683:38: runtime error: negation of -9223372036854775808
cannot be represented in type 'long long int'; cast to an unsigned
type to negate this value to itself

Co-authored-by: Weijun Huang <huangweijun1001@gmail.com>
Co-authored-by: Sergei Golubchik <serg@mariadb.org>
This commit is contained in:
Andrew Hutchings
2023-11-17 17:41:23 +00:00
committed by Andrew Hutchings
parent be6d48fd53
commit f552febe43
10 changed files with 160 additions and 22 deletions

View File

@ -1078,8 +1078,8 @@ lpad(12345, 5, "#")
SELECT conv(71, 10, 36), conv('1Z', 36, 10);
conv(71, 10, 36) conv('1Z', 36, 10)
1Z 71
SELECT conv(71, 10, 37), conv('1Z', 37, 10), conv(0,1,10),conv(0,0,10), conv(0,-1,10);
conv(71, 10, 37) conv('1Z', 37, 10) conv(0,1,10) conv(0,0,10) conv(0,-1,10)
SELECT conv(71, 10, 63), conv('1Z', 63, 10), conv(0,1,10),conv(0,0,10), conv(0,-1,10);
conv(71, 10, 63) conv('1Z', 63, 10) conv(0,1,10) conv(0,0,10) conv(0,-1,10)
NULL NULL NULL NULL NULL
create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb');
@ -5535,3 +5535,63 @@ aes_encrypt(a,a) is null
#
# End of 11.2 tests
#
#
# MDEV-30879 Add conversion to based 62 for CONV function
#
SELECT CONV('1z', 62, 10);
CONV('1z', 62, 10)
123
SELECT CONV('1Z', 62, 10);
CONV('1Z', 62, 10)
97
SELECT CONV('-1Z', 62, 10);
CONV('-1Z', 62, 10)
18446744073709551519
SELECT CONV('-1Z', -62, 10);
CONV('-1Z', -62, 10)
18446744073709551519
SELECT CONV('-1Z', 62, -10);
CONV('-1Z', 62, -10)
-97
SELECT CONV('-1Z', -62, -10);
CONV('-1Z', -62, -10)
-97
SELECT CONV('AzL8n0Y58m7', 62, 10);
CONV('AzL8n0Y58m7', 62, 10)
9223372036854775807
SELECT CONV('LygHa16AHYE', 62, 10);
CONV('LygHa16AHYE', 62, 10)
18446744073709551614
SELECT CONV('LygHa16AHYF', 62, 10);
CONV('LygHa16AHYF', 62, 10)
18446744073709551615
SELECT CONV('LygHa16AHZ0', 62, 10);
CONV('LygHa16AHZ0', 62, 10)
18446744073709551615
SELECT CONV('-AzL8n0Y58m7', -62, -10);
CONV('-AzL8n0Y58m7', -62, -10)
-9223372036854775807
SELECT CONV('-AzL8n0Y58m8', -62, -10);
CONV('-AzL8n0Y58m8', -62, -10)
-9223372036854775808
SELECT CONV('-AzL8n0Y58m9', -62, -10);
CONV('-AzL8n0Y58m9', -62, -10)
-9223372036854775808
SELECT CONV('-LygHa16AHZ0', -62, -10);
CONV('-LygHa16AHZ0', -62, -10)
-9223372036854775808
SELECT CONV('LygHa16AHYF', 63, 10);
CONV('LygHa16AHYF', 63, 10)
NULL
SELECT CONV(18446744073709551615, 10, 63);
CONV(18446744073709551615, 10, 63)
NULL
SELECT CONV(18446744073709551615, 10, 62);
CONV(18446744073709551615, 10, 62)
LygHa16AHYF
SELECT CONV(-9223372036854775808, -10, -62);
CONV(-9223372036854775808, -10, -62)
-AzL8n0Y58m8
#
# End of 11.4 tests
#