Hi Bar,
Nice Work. Sergey has already done a fairly extensive review,
so there is nothing much for me to say. I just have two small
requests for clarification below...
... and sorry for taking sometime to finish this review.
STATUS
------
Approved after consideration of some minor issues.
REQUIRED CHANGES
----------------
n/a
REQUESTS
--------
R1. In my_base64_decoder_getch(MY_BASE64_DECODER *decoder)
The 'switch (decoder->state)' only asserts when the server
is built with debug info. What about production binaries ?
Shouldn't we at least return an error here (just to be
safe)?
R2. Why not make the base64_decode/encode signatures different?
So that they work similarly to other buffer handling/copying
functions like memcpy, strcpy (and like our own functions,
strmake, ...):
- first parameter : dest
- second parameter: source
- third parameter : len
- ...
+base64_decode(const char *src_base, size_t len,
+ void *dst, const char **end_ptr)
I know that you haven't touched in base64_encode function
in this patch, but is something for you to consider anyway.
NOTE: this is not a required change, it's a request for
clarification. So I am not considering this a show
stopper.
SUGGESTIONS
-----------
n/a
DETAILS
-------
n/a
Regards,
Luís
On 11/25/2010 11:54 AM, Alexander Barkov wrote:
> #At file:///home/bar/mysql-bzr/mysql-next-mr.w5510/ based on
> revid:alexander.nozdrin@stripped
>
> 3201 Alexander Barkov 2010-11-25
> WL#5510 Functions to_base64 and from_base64
>
> @ mysql-test/include/ctype_numconv.inc
> @ mysql-test/r/ctype_binary.result
> @ mysql-test/r/ctype_cp1251.result
> @ mysql-test/r/ctype_latin1.result
> @ mysql-test/r/ctype_ucs.result
> @ mysql-test/r/ctype_utf8.result
> @ mysql-test/r/func_str.result
> @ mysql-test/t/func_str.test
> Adding tests
>
> @ include/base64.h
> Adding prototypes for *_max_arg_length() functions.
>
> @ mysys/base64.c
> Rewriting base64_decode, it's now 30% faster
> (using array instead of of strchr helps with that),
> and rejects garbage in input.
> Adding *_max_arg_length() functions.
>
> @ sql/item_create.cc
> Adding creators
>
> @ sql/item_strfunc.cc
> Implementing Item_func_to_base64 and Item_func_from_base64
>
> @ sql/item_strfunc.h
> Adding prototype for Item_func_to_base64 and Item_func_from_base64
>
> modified:
> include/base64.h
> mysql-test/include/ctype_numconv.inc
> mysql-test/r/ctype_binary.result
> mysql-test/r/ctype_cp1251.result
> mysql-test/r/ctype_latin1.result
> mysql-test/r/ctype_ucs.result
> mysql-test/r/ctype_utf8.result
> mysql-test/r/func_str.result
> mysql-test/t/func_str.test
> mysys/base64.c
> sql/item_create.cc
> sql/item_strfunc.cc
> sql/item_strfunc.h
> === modified file 'include/base64.h'
> --- a/include/base64.h 2006-12-23 19:20:40 +0000
> +++ b/include/base64.h 2010-11-25 11:53:11 +0000
> @@ -26,11 +26,21 @@ extern "C" {
> int base64_needed_encoded_length(int length_of_data);
>
> /*
> + Maximum length base64_encode_needed_length() can accept with no overflow.
> +*/
> +int base64_encode_max_arg_length(void);
> +
> +/*
> Calculate how much memory needed for dst of base64_decode()
> */
> int base64_needed_decoded_length(int length_of_encoded_data);
>
> /*
> + Maximum length base64_decode_needed_length() can accept with no overflow.
> +*/
> +int base64_decode_max_arg_length();
> +
> +/*
> Encode data as a base64 string
> */
> int base64_encode(const void *src, size_t src_len, char *dst);
>
> === modified file 'mysql-test/include/ctype_numconv.inc'
> --- a/mysql-test/include/ctype_numconv.inc 2010-08-19 11:55:35 +0000
> +++ b/mysql-test/include/ctype_numconv.inc 2010-11-25 11:53:11 +0000
> @@ -1726,6 +1726,18 @@ DROP TABLE t1;
> --echo # End of Bug#54916
> --echo #
>
> +--echo #
> +--echo # WL#5510 Functions to_base64 and from_base64
> +--echo #
> +CREATE TABLE t1 AS SELECT TO_BASE64('test') AS to_base64;
> +SHOW CREATE TABLE t1;
> +SELECT to_base64, LENGTH(to_base64), HEX(to_base64) FROM t1;
> +CREATE TABLE t2 AS SELECT FROM_BASE64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +SELECT CAST(from_base64 AS CHAR), LENGTH(from_base64), HEX(from_base64) FROM t2;
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
>
> --echo #
> --echo # Bug#52159 returning time type from function and empty left join causes
> debug assertion
>
> === modified file 'mysql-test/r/ctype_binary.result'
> --- a/mysql-test/r/ctype_binary.result 2010-08-19 11:55:35 +0000
> +++ b/mysql-test/r/ctype_binary.result 2010-11-25 11:53:11 +0000
> @@ -2748,6 +2748,29 @@ DROP TABLE t1;
> # End of Bug#54916
> #
> #
> +# WL#5510 Functions to_base64 and from_base64
> +#
> +CREATE TABLE t1 AS SELECT TO_BASE64('test') AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varbinary(8) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64), HEX(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64) HEX(to_base64)
> +dGVzdA== 8 6447567A64413D3D
> +CREATE TABLE t2 AS SELECT FROM_BASE64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(6) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT CAST(from_base64 AS CHAR), LENGTH(from_base64), HEX(from_base64) FROM t2;
> +CAST(from_base64 AS CHAR) LENGTH(from_base64) HEX(from_base64)
> +test 4 74657374
> +DROP TABLE t2;
> +DROP TABLE t1;
> +#
> # Bug#52159 returning time type from function and empty left join causes debug
> assertion
> #
> CREATE FUNCTION f1() RETURNS TIME RETURN 1;
>
> === modified file 'mysql-test/r/ctype_cp1251.result'
> --- a/mysql-test/r/ctype_cp1251.result 2010-08-19 12:54:22 +0000
> +++ b/mysql-test/r/ctype_cp1251.result 2010-11-25 11:53:11 +0000
> @@ -2830,6 +2830,29 @@ DROP TABLE t1;
> # End of Bug#54916
> #
> #
> +# WL#5510 Functions to_base64 and from_base64
> +#
> +CREATE TABLE t1 AS SELECT TO_BASE64('test') AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(8) CHARACTER SET cp1251 NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64), HEX(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64) HEX(to_base64)
> +dGVzdA== 8 6447567A64413D3D
> +CREATE TABLE t2 AS SELECT FROM_BASE64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(6) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT CAST(from_base64 AS CHAR), LENGTH(from_base64), HEX(from_base64) FROM t2;
> +CAST(from_base64 AS CHAR) LENGTH(from_base64) HEX(from_base64)
> +test 4 74657374
> +DROP TABLE t2;
> +DROP TABLE t1;
> +#
> # Bug#52159 returning time type from function and empty left join causes debug
> assertion
> #
> CREATE FUNCTION f1() RETURNS TIME RETURN 1;
>
> === modified file 'mysql-test/r/ctype_latin1.result'
> --- a/mysql-test/r/ctype_latin1.result 2010-08-19 12:17:24 +0000
> +++ b/mysql-test/r/ctype_latin1.result 2010-11-25 11:53:11 +0000
> @@ -3158,6 +3158,29 @@ DROP TABLE t1;
> # End of Bug#54916
> #
> #
> +# WL#5510 Functions to_base64 and from_base64
> +#
> +CREATE TABLE t1 AS SELECT TO_BASE64('test') AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(8) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64), HEX(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64) HEX(to_base64)
> +dGVzdA== 8 6447567A64413D3D
> +CREATE TABLE t2 AS SELECT FROM_BASE64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(6) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT CAST(from_base64 AS CHAR), LENGTH(from_base64), HEX(from_base64) FROM t2;
> +CAST(from_base64 AS CHAR) LENGTH(from_base64) HEX(from_base64)
> +test 4 74657374
> +DROP TABLE t2;
> +DROP TABLE t1;
> +#
> # Bug#52159 returning time type from function and empty left join causes debug
> assertion
> #
> CREATE FUNCTION f1() RETURNS TIME RETURN 1;
>
> === modified file 'mysql-test/r/ctype_ucs.result'
> --- a/mysql-test/r/ctype_ucs.result 2010-08-19 12:54:22 +0000
> +++ b/mysql-test/r/ctype_ucs.result 2010-11-25 11:53:11 +0000
> @@ -4053,6 +4053,29 @@ DROP TABLE t1;
> # End of Bug#54916
> #
> #
> +# WL#5510 Functions to_base64 and from_base64
> +#
> +CREATE TABLE t1 AS SELECT TO_BASE64('test') AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(12) CHARACTER SET ucs2 NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64), HEX(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64) HEX(to_base64)
> +AHQAZQBzAHQ= 24 0041004800510041005A00510042007A004100480051003D
> +CREATE TABLE t2 AS SELECT FROM_BASE64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(18) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT CAST(from_base64 AS CHAR), LENGTH(from_base64), HEX(from_base64) FROM t2;
> +CAST(from_base64 AS CHAR) LENGTH(from_base64) HEX(from_base64)
> +test 8 0074006500730074
> +DROP TABLE t2;
> +DROP TABLE t1;
> +#
> # Bug#52159 returning time type from function and empty left join causes debug
> assertion
> #
> CREATE FUNCTION f1() RETURNS TIME RETURN 1;
>
> === modified file 'mysql-test/r/ctype_utf8.result'
> --- a/mysql-test/r/ctype_utf8.result 2010-08-30 06:38:09 +0000
> +++ b/mysql-test/r/ctype_utf8.result 2010-11-25 11:53:11 +0000
> @@ -4925,6 +4925,29 @@ DROP TABLE t1;
> # End of Bug#54916
> #
> #
> +# WL#5510 Functions to_base64 and from_base64
> +#
> +CREATE TABLE t1 AS SELECT TO_BASE64('test') AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(16) CHARACTER SET utf8 NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64), HEX(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64) HEX(to_base64)
> +dGVzdA== 8 6447567A64413D3D
> +CREATE TABLE t2 AS SELECT FROM_BASE64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(36) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT CAST(from_base64 AS CHAR), LENGTH(from_base64), HEX(from_base64) FROM t2;
> +CAST(from_base64 AS CHAR) LENGTH(from_base64) HEX(from_base64)
> +test 4 74657374
> +DROP TABLE t2;
> +DROP TABLE t1;
> +#
> # Bug#52159 returning time type from function and empty left join causes debug
> assertion
> #
> CREATE FUNCTION f1() RETURNS TIME RETURN 1;
>
> === modified file 'mysql-test/r/func_str.result'
> --- a/mysql-test/r/func_str.result 2010-08-20 11:52:40 +0000
> +++ b/mysql-test/r/func_str.result 2010-11-25 11:53:11 +0000
> @@ -2759,3 +2759,1483 @@ DROP TABLE t1;
> #
> # End of 5.5 tests
> #
> +#
> +# Start of 5.6 tests
> +#
> +#
> +# WL#5510 Functions to_base64 and from_base64
> +#
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',63)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(85) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh
> +YWFhYWFh 85
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(63) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 63
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',62)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(85) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh
> +YWFhYWE= 85
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(63) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 62
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',61)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(85) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh
> +YWFhYQ== 85
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(63) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 61
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',60)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(81) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh
> +YWFh 81
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(60) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 60
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',59)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(81) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh
> +YWE= 81
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(60) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 59
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',58)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(81) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh
> +YQ== 81
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(60) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 58
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',57)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(76) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 76
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(57) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 57
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',56)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(76) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 76
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(57) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 56
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',55)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(76) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 76
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(57) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 55
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',54)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(72) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 72
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(54) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 54
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',53)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(72) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 72
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(54) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 53
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',52)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(72) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 72
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(54) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 52
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',51)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(68) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 68
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(51) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 51
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',50)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(68) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 68
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(51) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 50
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',49)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(68) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 68
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(51) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 49
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',48)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(64) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 64
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(48) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 48
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',47)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(64) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 64
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(48) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 47
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',46)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(64) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 64
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(48) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 46
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',45)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(60) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 60
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(45) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 45
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',44)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(60) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 60
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(45) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 44
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',43)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(60) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 60
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(45) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 43
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',42)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(56) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 56
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(42) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 42
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',41)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(56) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 56
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(42) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 41
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',40)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(56) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 56
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(42) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 40
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',39)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(52) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 52
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(39) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 39
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',38)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(52) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 52
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(39) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 38
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',37)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(52) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 52
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(39) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 37
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',36)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(48) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 48
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(36) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 36
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',35)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(48) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 48
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(36) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 35
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',34)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(48) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 48
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(36) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 34
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',33)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(44) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 44
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(33) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 33
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',32)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(44) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 44
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(33) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 32
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',31)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(44) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 44
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(33) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 31
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',30)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(40) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 40
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(30) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 30
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',29)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(40) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 40
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(30) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaaa 29
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',28)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(40) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 40
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(30) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaaa 28
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',27)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(36) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 36
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(27) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaaa 27
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',26)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(36) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 36
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(27) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaaa 26
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',25)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(36) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 36
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(27) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaaa 25
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',24)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(32) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 32
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(24) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaaa 24
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',23)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(32) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 32
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(24) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaaa 23
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',22)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(32) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 32
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(24) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaaa 22
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',21)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(28) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWFh 28
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(21) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaaa 21
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',20)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(28) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYWE= 28
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(21) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaaa 20
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',19)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(28) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFhYQ== 28
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(21) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaaa 19
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',18)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(24) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWFh 24
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(18) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaaa 18
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',17)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(24) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYWE= 24
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(18) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaaa 17
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',16)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(24) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFhYQ== 24
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(18) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaaa 16
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',15)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(20) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWFh 20
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(15) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaaa 15
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',14)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(20) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYWE= 20
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(15) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaaa 14
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',13)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(20) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFhYQ== 20
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(15) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaaa 13
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',12)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(16) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWFh 16
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(12) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaaa 12
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',11)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(16) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYWE= 16
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(12) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaaa 11
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',10)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(16) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFhYQ== 16
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(12) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaaa 10
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',9)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(12) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWFh 12
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(9) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaaa 9
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',8)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(12) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYWE= 12
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(9) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaaa 8
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',7)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(12) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFhYQ== 12
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(9) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaaa 7
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',6)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(8) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWFh 8
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(6) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaaa 6
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',5)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(8) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYWE= 8
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(6) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaaa 5
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',4)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(8) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFhYQ== 8
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(6) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaaa 4
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',3)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(4) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWFh 4
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(3) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aaa 3
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',2)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(4) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YWE= 4
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(3) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +aa 2
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',1)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` varchar(4) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> +YQ== 4
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` varbinary(3) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> +a 1
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',0)) AS to_base64;
> +SHOW CREATE TABLE t1;
> +Table Create Table
> +t1 CREATE TABLE `t1` (
> + `to_base64` char(0) NOT NULL DEFAULT ''
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT to_base64, LENGTH(to_base64) FROM t1;
> +to_base64 LENGTH(to_base64)
> + 0
> +CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> +SHOW CREATE TABLE t2;
> +Table Create Table
> +t2 CREATE TABLE `t2` (
> + `from_base64` binary(0) DEFAULT NULL
> +) ENGINE=MyISAM DEFAULT CHARSET=latin1
> +SELECT from_base64, LENGTH(from_base64) FROM t2;
> +from_base64 LENGTH(from_base64)
> + 0
> +DROP TABLE t2;
> +DROP TABLE t1;
> +
> +CREATE TABLE t1 (a VARBINARY(64));
> +INSERT INTO t1 VALUES (0x00), (0x0000), (0x000000), (0x00000000);
> +INSERT INTO t1 VALUES (0x00010203040506070809);
> +SELECT TO_BASE64(a), hex(a) FROM t1 ORDER BY a;
> +TO_BASE64(a) hex(a)
> +AA== 00
> +AAA= 0000
> +AAAA 000000
> +AAAAAA== 00000000
> +AAECAwQFBgcICQ== 00010203040506070809
> +DROP TABLE t1;
> +#
> +# Test NULL output for NULL input
> +#
> +SELECT TO_BASE64(NULL);
> +TO_BASE64(NULL)
> +NULL
> +SELECT FROM_BASE64(NULL);
> +FROM_BASE64(NULL)
> +NULL
> +#
> +# RFC4648 test vectors
> +#
> +SELECT @b:= TO_BASE64(''), FROM_BASE64(@b);
> +@b:= TO_BASE64('') FROM_BASE64(@b)
> +
> +SELECT @b:= TO_BASE64('f'), FROM_BASE64(@b);
> +@b:= TO_BASE64('f') FROM_BASE64(@b)
> +Zg== f
> +SELECT @b:= TO_BASE64('fo'), FROM_BASE64(@b);
> +@b:= TO_BASE64('fo') FROM_BASE64(@b)
> +Zm8= fo
> +SELECT @b:= TO_BASE64('foo'), FROM_BASE64(@b);
> +@b:= TO_BASE64('foo') FROM_BASE64(@b)
> +Zm9v foo
> +SELECT @b:= TO_BASE64('foob'), FROM_BASE64(@b);
> +@b:= TO_BASE64('foob') FROM_BASE64(@b)
> +Zm9vYg== foob
> +SELECT @b:= TO_BASE64('fooba'), FROM_BASE64(@b);
> +@b:= TO_BASE64('fooba') FROM_BASE64(@b)
> +Zm9vYmE= fooba
> +SELECT @b:= TO_BASE64('foobar'), FROM_BASE64(@b);
> +@b:= TO_BASE64('foobar') FROM_BASE64(@b)
> +Zm9vYmFy foobar
> +#
> +# Invalid characters - return NULL
> +#
> +SELECT hex(FROM_BASE64('#'));
> +hex(FROM_BASE64('#'))
> +NULL
> +SELECT hex(FROM_BASE64('A#'));
> +hex(FROM_BASE64('A#'))
> +NULL
> +SELECT hex(FROM_BASE64('AB#'));
> +hex(FROM_BASE64('AB#'))
> +NULL
> +SELECT hex(FROM_BASE64('ABC#'));
> +hex(FROM_BASE64('ABC#'))
> +NULL
> +SELECT hex(FROM_BASE64('ABCD#'));
> +hex(FROM_BASE64('ABCD#'))
> +NULL
> +#
> +# "=" is not valid on the first and second positions of a quadruple
> +#
> +SELECT hex(FROM_BASE64('='));
> +hex(FROM_BASE64('='))
> +NULL
> +SELECT hex(FROM_BASE64('A='));
> +hex(FROM_BASE64('A='))
> +NULL
> +SELECT hex(FROM_BASE64('ABCD='));
> +hex(FROM_BASE64('ABCD='))
> +NULL
> +SELECT hex(FROM_BASE64('ABCDE='));
> +hex(FROM_BASE64('ABCDE='))
> +NULL
> +#
> +# Incomplete sequences - return NULL
> +#
> +SELECT hex(FROM_BASE64('A'));
> +hex(FROM_BASE64('A'))
> +NULL
> +SELECT hex(FROM_BASE64('AB'));
> +hex(FROM_BASE64('AB'))
> +NULL
> +SELECT hex(FROM_BASE64('ABC'));
> +hex(FROM_BASE64('ABC'))
> +NULL
> +#
> +# Unexpected input after pad characters - return NULL
> +#
> +SELECT hex(FROM_BASE64('AAA=x'));
> +hex(FROM_BASE64('AAA=x'))
> +NULL
> +SELECT hex(FROM_BASE64('AA==x'));
> +hex(FROM_BASE64('AA==x'))
> +NULL
> +#
> +# Delimiters are allowed at any position
> +#
> +SELECT hex(FROM_BASE64(' A B C D '));
> +hex(FROM_BASE64(' A B C D '))
> +001083
> +SELECT hex(FROM_BASE64(' A A = = '));
> +hex(FROM_BASE64(' A A = = '))
> +NULL
> +SELECT hex(FROM_BASE64(' A A A = '));
> +hex(FROM_BASE64(' A A A = '))
> +NULL
> +SELECT hex(FROM_BASE64(' A \n B \r C \t D '));
> +hex(FROM_BASE64(' A \n B \r C \t D '))
> +001083
> +#
> +# Testing that to_base64 respects max_allowed_packet
> +#
> +SELECT LENGTH(TO_BASE64(REPEAT('a', @@max_allowed_packet-10)));
> +LENGTH(TO_BASE64(REPEAT('a', @@max_allowed_packet-10)))
> +NULL
> +Warnings:
> +Warning 1301 Result of to_base64() was larger than max_allowed_packet (1048576) -
> truncated
> +#
> +# End of 5.6 tests
> +#
>
> === modified file 'mysql-test/t/func_str.test'
> --- a/mysql-test/t/func_str.test 2010-08-20 11:14:11 +0000
> +++ b/mysql-test/t/func_str.test 2010-11-25 11:53:11 +0000
> @@ -1421,3 +1421,97 @@ DROP TABLE t1;
> --echo #
> --echo # End of 5.5 tests
> --echo #
> +
> +
> +--echo #
> +--echo # Start of 5.6 tests
> +--echo #
> +
> +--echo #
> +--echo # WL#5510 Functions to_base64 and from_base64
> +--echo #
> +let $1=64;
> +while($1)
> +{
> + dec $1;
> + eval CREATE TABLE t1 AS SELECT TO_BASE64(REPEAT('a',$1)) AS to_base64;
> + SHOW CREATE TABLE t1;
> + SELECT to_base64, LENGTH(to_base64) FROM t1;
> + CREATE TABLE t2 AS SELECT from_base64(to_base64) AS from_base64 FROM t1;
> + SHOW CREATE TABLE t2;
> + SELECT from_base64, LENGTH(from_base64) FROM t2;
> + DROP TABLE t2;
> + DROP TABLE t1;
> + --echo
> +}
> +CREATE TABLE t1 (a VARBINARY(64));
> +INSERT INTO t1 VALUES (0x00), (0x0000), (0x000000), (0x00000000);
> +INSERT INTO t1 VALUES (0x00010203040506070809);
> +SELECT TO_BASE64(a), hex(a) FROM t1 ORDER BY a;
> +DROP TABLE t1;
> +
> +--echo #
> +--echo # Test NULL output for NULL input
> +--echo #
> +SELECT TO_BASE64(NULL);
> +SELECT FROM_BASE64(NULL);
> +
> +--echo #
> +--echo # RFC4648 test vectors
> +--echo #
> +SELECT @b:= TO_BASE64(''), FROM_BASE64(@b); # ""
> +SELECT @b:= TO_BASE64('f'), FROM_BASE64(@b); # "Zg=="
> +SELECT @b:= TO_BASE64('fo'), FROM_BASE64(@b); # "Zm8="
> +SELECT @b:= TO_BASE64('foo'), FROM_BASE64(@b); # "Zm9v"
> +SELECT @b:= TO_BASE64('foob'), FROM_BASE64(@b); # "Zm9vYg=="
> +SELECT @b:= TO_BASE64('fooba'), FROM_BASE64(@b); # "Zm9vYmE="
> +SELECT @b:= TO_BASE64('foobar'), FROM_BASE64(@b); # "Zm9vYmFy"
> +
> +
> +--echo #
> +--echo # Invalid characters - return NULL
> +--echo #
> +SELECT hex(FROM_BASE64('#'));
> +SELECT hex(FROM_BASE64('A#'));
> +SELECT hex(FROM_BASE64('AB#'));
> +SELECT hex(FROM_BASE64('ABC#'));
> +SELECT hex(FROM_BASE64('ABCD#'));
> +
> +--echo #
> +--echo # "=" is not valid on the first and second positions of a quadruple
> +--echo #
> +SELECT hex(FROM_BASE64('='));
> +SELECT hex(FROM_BASE64('A='));
> +SELECT hex(FROM_BASE64('ABCD='));
> +SELECT hex(FROM_BASE64('ABCDE='));
> +
> +--echo #
> +--echo # Incomplete sequences - return NULL
> +--echo #
> +SELECT hex(FROM_BASE64('A'));
> +SELECT hex(FROM_BASE64('AB'));
> +SELECT hex(FROM_BASE64('ABC'));
> +
> +--echo #
> +--echo # Unexpected input after pad characters - return NULL
> +--echo #
> +SELECT hex(FROM_BASE64('AAA=x'));
> +SELECT hex(FROM_BASE64('AA==x'));
> +
> +
> +--echo #
> +--echo # Delimiters are allowed at any position
> +--echo #
> +SELECT hex(FROM_BASE64(' A B C D '));
> +SELECT hex(FROM_BASE64(' A A = = '));
> +SELECT hex(FROM_BASE64(' A A A = '));
> +SELECT hex(FROM_BASE64(' A \n B \r C \t D '));
> +
> +--echo #
> +--echo # Testing that to_base64 respects max_allowed_packet
> +--echo #
> +SELECT LENGTH(TO_BASE64(REPEAT('a', @@max_allowed_packet-10)));
> +
> +--echo #
> +--echo # End of 5.6 tests
> +--echo #
>
> === modified file 'mysys/base64.c'
> --- a/mysys/base64.c 2009-03-20 14:27:53 +0000
> +++ b/mysys/base64.c 2010-11-25 11:53:11 +0000
> @@ -24,6 +24,28 @@ static char base64_table[] = "ABCDEFGHIJ
> "abcdefghijklmnopqrstuvwxyz"
> "0123456789+/";
>
> +/**
> + * Maximum length base64_needed_encoded_length()
> + * can handle without overflow.
> + */
> +int
> +base64_encode_max_arg_length()
> +{
> +#if (SIZEOF_INT == 8)
> + /*
> + 6827690988321067803 -> 9223372036854775805
> + 6827690988321067804 -> -9223372036854775807
> + */
> + return 0x5EC0D4C77B03531BLL
> +#else
> + /*
> + 1589695686 -> 2147483646
> + 1589695687 -> -2147483645
> + */
> + return 0x5EC0D4C6;
> +#endif
> +}
> +
>
> int
> base64_needed_encoded_length(int length_of_data)
> @@ -38,6 +60,21 @@ base64_needed_encoded_length(int length_
> }
>
>
> +/**
> + * Maximum length base64_needed_decoded_length()
> + * can handle without overflow.
> + */
> +int
> +base64_decode_max_arg_length()
> +{
> +#if (SIZEOF_INT == 8)
> + return 0x2AAAAAAAAAAAAAAALL;
> +#else
> + return 0x2AAAAAAA;
> +#endif
> +}
> +
> +
> int
> base64_needed_decoded_length(int length_of_encoded_data)
> {
> @@ -100,130 +137,219 @@ base64_encode(const void *src, size_t sr
> }
>
>
> -static inline uint
> -pos(unsigned char c)
> +/*
> + Base64 decoder stream
> +*/
> +typedef struct my_base64_decoder_t
> {
> - return (uint) (strchr(base64_table, c) - base64_table);
> -}
> -
> -
> -#define SKIP_SPACE(src, i, size) \
> -{ \
> - while (i< size&& my_isspace(&my_charset_latin1, * src)) \
> - { \
> - i++; \
> - src++; \
> - } \
> - if (i == size) \
> - { \
> - break; \
> - } \
> -}
> + const char *src; /* Pointer to the current input position */
> + const char *end; /* Pointer to the end of input buffer */
> + uint c; /* Collect bits into this number */
> + int error; /* Error code */
> + uchar state; /* Character number in the current group of 4 */
> + uchar mark; /* Number of padding marks in the current group */
> +} MY_BASE64_DECODER;
>
>
> /*
> - Decode a base64 string
> + Helper table for decoder.
> + -2 means "space character"
> + -1 means "bad character"
> + Non-negative values mean valid base64 encoding character.
> +*/
> +static int8
> +from_base64_table[]=
> +{
> +/*00*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-1,-1,
> +/*10*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
> +/*20*/ -2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, /* !"#$%&'()*+,-./ */
> +/*30*/ 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, /* 0123456789:;<=>?
> */
> +/*40*/ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* @ABCDEFGHIJKLMNO */
> +/*50*/ 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, /* PQRSTUVWXYZ[\]^_ */
> +/*60*/ -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* `abcdefghijklmno */
> +/*70*/ 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, /* pqrstuvwxyz{|}~ */
> +/*80*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
> +/*90*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
> +/*A0*/ -2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
> +/*B0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
> +/*C0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
> +/*D0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
> +/*E0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
> +/*F0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
> +};
> +
> +
> +/**
> + * Skip leading spaces in a base64 encoded stream
> + * and stop on the first non-space character.
> + * decoder->src will point to the first non-space character,
> + * or to the end of the input string.
> + * In case when end-of-input met on unexpected position,
> + * decoder->error is also set to 1.
> + *
> + * @param decoder Pointer to MY_BASE64_DECODER
> + *
> + * @return
> + * FALSE on success (there are some more non-space input characters)
> + * TRUE on error (end-of-input found)
> + */
> +static inline my_bool
> +my_base64_decoder_skip_spaces(MY_BASE64_DECODER *decoder)
> +{
> + for ( ; decoder->src< decoder->end; decoder->src++)
> + {
> + if (from_base64_table[(uchar) *decoder->src] != -2)
> + return FALSE;
> + }
> + if (decoder->state> 0)
> + decoder->error= 1; /* Unexpected end-of-input found */
> + return TRUE;
> +}
>
> - SYNOPSIS
> - base64_decode()
> - src Pointer to base64-encoded string
> - len Length of string at 'src'
> - dst Pointer to location where decoded data will be stored
> - end_ptr Pointer to variable that will refer to the character
> - after the end of the encoded data that were decoded. Can
> - be NULL.
> -
> - DESCRIPTION
> -
> - The base64-encoded data in the range ['src','*end_ptr') will be
> - decoded and stored starting at 'dst'. The decoding will stop
> - after 'len' characters have been read from 'src', or when padding
> - occurs in the base64-encoded data. In either case: if 'end_ptr' is
> - non-null, '*end_ptr' will be set to point to the character after
> - the last read character, even in the presence of error.
>
> - NOTE
> - We require that 'dst' is pre-allocated to correct size.
> +/**
> + * Convert the next character in a base64 encoded stream
> + * to a number in the range [0..63]
> + * and mix it with the previously collected value in decoder->c.
> + *
> + * @param decode base64 decoding stream
> + *
> + * @return
> + * FALSE on success
> + * TRUE on error (invalid base64 character found)
> + */
> +static inline my_bool
> +my_base64_add(MY_BASE64_DECODER *decoder)
> +{
> + int res;
> + decoder->c<<= 6;
> + if ((res= from_base64_table[(uchar) *decoder->src++])< 0)
> + return (decoder->error= TRUE);
> + decoder->c+= (uint) res;
> + return FALSE;
> +}
>
> - SEE ALSO
> - base64_needed_decoded_length().
>
> - RETURN VALUE
> - Number of bytes written at 'dst' or -1 in case of failure
> -*/
> -int
> -base64_decode(const char *src_base, size_t len,
> - void *dst, const char **end_ptr)
> +/**
> + * Get the next character from a base64 encoded stream.
> + * Skip spaces, then scan the next base64 character or a pad character
> + * and collect bits into decoder->c.
> + *
> + * @param decoder Pointer to MY_BASE64_DECODER
> + * @return
> + * FALSE on success (a valid base64 encoding character found)
> + * TRUE on error (unexpected character or unexpected end-of-input found)
> + */
> +static inline my_bool
> +my_base64_decoder_getch(MY_BASE64_DECODER *decoder)
> {
> - char b[3];
> - size_t i= 0;
> - char *dst_base= (char *)dst;
> - char const *src= src_base;
> - char *d= dst_base;
> - size_t j;
> + if (my_base64_decoder_skip_spaces(decoder))
> + return TRUE; /* End-of-input */
>
> - while (i< len)
> + if (!my_base64_add(decoder)) /* Valid base64 character found */
> {
> - unsigned c= 0;
> - size_t mark= 0;
> + if (decoder->mark)
> + {
> + /* If we have scanned '=' already, then only '=' is valid */
> + DBUG_ASSERT(decoder->state == 3);
> + decoder->error= 1;
> + decoder->src--;
> + return TRUE; /* expected '=', but encoding character found */
> + }
> + decoder->state++;
> + return FALSE;
> + }
>
> - SKIP_SPACE(src, i, len);
> + /* Process error */
> + switch (decoder->state)
> + {
> + case 0:
> + case 1:
> + decoder->src--;
> + return TRUE; /* base64 character expected */
> + break;
> +
> + case 2:
> + case 3:
> + if (decoder->src[-1] == '=')
> + {
> + decoder->error= 0; /* Not an error - it's a pad character */
> + decoder->mark++;
> + }
> + else
> + {
> + decoder->src--;
> + return TRUE; /* base64 character or '=' expected */
> + }
> + break;
>
> - c += pos(*src++);
> - c<<= 6;
> - i++;
> + default:
> + DBUG_ASSERT(0);
> + }
>
> - SKIP_SPACE(src, i, len);
> + decoder->state++;
> + return FALSE;
> +}
>
> - c += pos(*src++);
> - c<<= 6;
> - i++;
>
> - SKIP_SPACE(src, i, len);
> +/**
> + * Decode a base64 string
> + * The base64-encoded data in the range ['src','*end_ptr') will be
> + * decoded and stored starting at 'dst'. The decoding will stop
> + * after 'len' characters have been read from 'src', or when padding
> + * occurs in the base64-encoded data. In either case: if 'end_ptr' is
> + * non-null, '*end_ptr' will be set to point to the character after
> + * the last read character, even in the presence of error.
> + *
> + * Note: We require that 'dst' is pre-allocated to correct size.
> + *
> + * @param src Pointer to base64-encoded string
> + * @param len Length of string at 'src'
> + * @param dst Pointer to location where decoded data will be stored
> + * @param end_ptr Pointer to variable that will refer to the character
> + * after the end of the encoded data that were decoded.
> + * Can be NULL.
> + *
> + * @return Number of bytes written at 'dst', or -1 in case of failure
> + */
> +int
> +base64_decode(const char *src_base, size_t len,
> + void *dst, const char **end_ptr)
> +{
> + char *d= (char*) dst;
> + MY_BASE64_DECODER decoder;
>
> - if (*src != '=')
> - c += pos(*src++);
> - else
> - {
> - src += 2; /* There should be two bytes padding */
> - i= len;
> - mark= 2;
> - c<<= 6;
> - goto end;
> - }
> - c<<= 6;
> - i++;
> + decoder.src= src_base;
> + decoder.end= src_base + len;
> + decoder.error= 0;
> + decoder.mark= 0;
>
> - SKIP_SPACE(src, i, len);
> + for ( ; ; )
> + {
> + decoder.c= 0;
> + decoder.state= 0;
>
> - if (*src != '=')
> - c += pos(*src++);
> - else
> + if (my_base64_decoder_getch(&decoder) ||
> + my_base64_decoder_getch(&decoder) ||
> + my_base64_decoder_getch(&decoder) ||
> + my_base64_decoder_getch(&decoder))
> + break;
> +
> + *d++= (decoder.c>> 16)& 0xff;
> + *d++= (decoder.c>> 8)& 0xff;
> + *d++= (decoder.c>> 0)& 0xff;
> +
> + if (decoder.mark)
> {
> - src += 1; /* There should be one byte padding */
> - i= len;
> - mark= 1;
> - goto end;
> + d-= decoder.mark;
> + break;
> }
> - i++;
> -
> - end:
> - b[0]= (c>> 16)& 0xff;
> - b[1]= (c>> 8)& 0xff;
> - b[2]= (c>> 0)& 0xff;
> -
> - for (j=0; j<3-mark; j++)
> - *d++= b[j];
> }
>
> if (end_ptr != NULL)
> - *end_ptr= src;
> + *end_ptr= decoder.src;
>
> - /*
> - The variable 'i' is set to 'len' when padding has been read, so it
> - does not actually reflect the number of bytes read from 'src'.
> - */
> - return i != len ? -1 : (int) (d - dst_base);
> + return decoder.error ? -1 : (int) (d - (char*) dst);
> }
>
>
>
> === modified file 'sql/item_create.cc'
> --- a/sql/item_create.cc 2010-07-16 21:00:50 +0000
> +++ b/sql/item_create.cc 2010-11-25 11:53:11 +0000
> @@ -959,6 +959,19 @@ protected:
> };
>
>
> +class Create_func_from_base64 : public Create_func_arg1
> +{
> +public:
> + virtual Item *create(THD *thd, Item *arg1);
> +
> + static Create_func_from_base64 s_singleton;
> +
> +protected:
> + Create_func_from_base64() {}
> + virtual ~Create_func_from_base64() {}
> +};
> +
> +
> class Create_func_from_days : public Create_func_arg1
> {
> public:
> @@ -2059,6 +2072,19 @@ protected:
> };
>
>
> +class Create_func_to_base64 : public Create_func_arg1
> +{
> +public:
> + virtual Item *create(THD *thd, Item *arg1);
> +
> + static Create_func_to_base64 s_singleton;
> +
> +protected:
> + Create_func_to_base64() {}
> + virtual ~Create_func_to_base64() {}
> +};
> +
> +
> class Create_func_to_days : public Create_func_arg1
> {
> public:
> @@ -3425,6 +3451,15 @@ Create_func_found_rows::create(THD *thd)
> }
>
>
> +Create_func_from_base64 Create_func_from_base64::s_singleton;
> +
> +Item*
> +Create_func_from_base64::create(THD *thd, Item *arg1)
> +{
> + return new (thd->mem_root) Item_func_from_base64(arg1);
> +}
> +
> +
> Create_func_from_days Create_func_from_days::s_singleton;
>
> Item*
> @@ -4555,6 +4590,15 @@ Create_func_timediff::create(THD *thd, I
> }
>
>
> +Create_func_to_base64 Create_func_to_base64::s_singleton;
> +
> +Item*
> +Create_func_to_base64::create(THD *thd, Item *arg1)
> +{
> + return new (thd->mem_root) Item_func_to_base64(arg1);
> +}
> +
> +
> Create_func_to_days Create_func_to_days::s_singleton;
>
> Item*
> @@ -4891,6 +4935,7 @@ static Native_func_registry func_array[]
> { { C_STRING_WITH_LEN("FLOOR") }, BUILDER(Create_func_floor)},
> { { C_STRING_WITH_LEN("FORMAT") }, BUILDER(Create_func_format)},
> { { C_STRING_WITH_LEN("FOUND_ROWS") }, BUILDER(Create_func_found_rows)},
> + { { C_STRING_WITH_LEN("FROM_BASE64") }, BUILDER(Create_func_from_base64)},
> { { C_STRING_WITH_LEN("FROM_DAYS") }, BUILDER(Create_func_from_days)},
> { { C_STRING_WITH_LEN("FROM_UNIXTIME") }, BUILDER(Create_func_from_unixtime)},
> { { C_STRING_WITH_LEN("GEOMCOLLFROMTEXT") },
> GEOM_BUILDER(Create_func_geometry_from_text)},
> @@ -5013,6 +5058,7 @@ static Native_func_registry func_array[]
> { { C_STRING_WITH_LEN("TIME_FORMAT") }, BUILDER(Create_func_time_format)},
> { { C_STRING_WITH_LEN("TIME_TO_SEC") }, BUILDER(Create_func_time_to_sec)},
> { { C_STRING_WITH_LEN("TOUCHES") }, GEOM_BUILDER(Create_func_touches)},
> + { { C_STRING_WITH_LEN("TO_BASE64") }, BUILDER(Create_func_to_base64)},
> { { C_STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
> { { C_STRING_WITH_LEN("TO_SECONDS") }, BUILDER(Create_func_to_seconds)},
> { { C_STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
>
> === modified file 'sql/item_strfunc.cc'
> --- a/sql/item_strfunc.cc 2010-08-20 11:52:40 +0000
> +++ b/sql/item_strfunc.cc 2010-11-25 11:53:11 +0000
> @@ -48,6 +48,7 @@
> #include "password.h" // my_make_scrambled_password,
> // my_make_scrambled_password_323
> #include<m_ctype.h>
> +#include<base64.h>
> #include "my_md5.h"
> #include "sha1.h"
> #include "my_aes.h"
> @@ -464,6 +465,91 @@ void Item_func_aes_decrypt::fix_length_a
> }
>
>
> +void Item_func_to_base64::fix_length_and_dec()
> +{
> + maybe_null= args[0]->maybe_null;
> + collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
> + if (args[0]->max_length> (uint) base64_encode_max_arg_length())
> + {
> + maybe_null= 1;
> + fix_char_length_ulonglong((ulonglong) base64_encode_max_arg_length());
> + }
> + else
> + {
> + int length= base64_needed_encoded_length((int) args[0]->max_length);
> + DBUG_ASSERT(length> 0);
> + fix_char_length_ulonglong((ulonglong) length - 1);
> + }
> +}
> +
> +
> +String *Item_func_to_base64::val_str_ascii(String *str)
> +{
> + String *res= args[0]->val_str(str);
> + bool too_long= 0;
> + int length;
> + if (!res ||
> + res->length()> (uint) base64_encode_max_arg_length() ||
> + (too_long=
> + ((uint) (length= base64_needed_encoded_length(res->length()))>
> + current_thd->variables.max_allowed_packet)) ||
> + tmp_value.alloc((uint) length))
> + {
> + null_value= 1; // NULL input, too long input, or OOM.
> + if (too_long)
> + {
> + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
> + ER_WARN_ALLOWED_PACKET_OVERFLOWED,
> + ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED), func_name(),
> + current_thd->variables.max_allowed_packet);
> + }
> + return 0;
> + }
> + base64_encode(res->ptr(), (int) res->length(), (char*) tmp_value.ptr());
> + DBUG_ASSERT(length> 0);
> + tmp_value.length((uint) length - 1); // Without trailing '\0'
> + null_value= 0;
> + return&tmp_value;
> +}
> +
> +
> +void Item_func_from_base64::fix_length_and_dec()
> +{
> + if (args[0]->max_length> (uint) base64_decode_max_arg_length())
> + {
> + fix_char_length_ulonglong((ulonglong) base64_decode_max_arg_length());
> + }
> + else
> + {
> + int length= base64_needed_decoded_length((int) args[0]->max_length);
> + fix_char_length_ulonglong((ulonglong) length);
> + }
> + maybe_null= 1; // Can be NULL, e.g. in case of badly formed input string
> +}
> +
> +
> +String *Item_func_from_base64::val_str(String *str)
> +{
> + String *res= args[0]->val_str_ascii(str);
> + int length;
> + const char *end_ptr;
> +
> + if (!res ||
> + res->length()> (uint) base64_decode_max_arg_length() ||
> + tmp_value.alloc((uint) base64_needed_decoded_length((int)
> + res->length())) ||
> + (length= base64_decode(res->ptr(), (int) res->length(),
> + (char *) tmp_value.ptr(),&end_ptr))< 0 ||
> + end_ptr< res->ptr() + res->length())
> + {
> + null_value= 1; // NULL input, too long input, OOM, or badly formed input
> + return 0;
> + }
> + tmp_value.length((uint) length);
> + return&tmp_value;
> +}
> +
> +
> /**
> Concatenate args with the following premises:
> If only one arg (which is ok), return value of arg;
>
> === modified file 'sql/item_strfunc.h'
> --- a/sql/item_strfunc.h 2010-08-20 11:52:40 +0000
> +++ b/sql/item_strfunc.h 2010-11-25 11:53:11 +0000
> @@ -91,6 +91,27 @@ public:
> const char *func_name() const { return "sha2"; }
> };
>
> +class Item_func_to_base64 :public Item_str_ascii_func
> +{
> + String tmp_value;
> +public:
> + Item_func_to_base64(Item *a) :Item_str_ascii_func(a) {}
> + String *val_str_ascii(String *);
> + void fix_length_and_dec();
> + const char *func_name() const { return "to_base64"; }
> +};
> +
> +class Item_func_from_base64 :public Item_str_func
> +{
> + String tmp_value;
> +public:
> + Item_func_from_base64(Item *a) :Item_str_func(a) {}
> + String *val_str(String *);
> + void fix_length_and_dec();
> + const char *func_name() const { return "from_base64"; }
> +};
> +
> +
> class Item_func_aes_encrypt :public Item_str_func
> {
> public:
>
>
>
>
>