Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json_array with base64 is not same with MySQL #9996

Closed
xiekeyi98 opened this issue Apr 2, 2019 · 3 comments · Fixed by #37200
Closed

json_array with base64 is not same with MySQL #9996

xiekeyi98 opened this issue Apr 2, 2019 · 3 comments · Fixed by #37200
Labels
component/expression component/json priority/P4 Minor issue, awaiting more evidence before prioritizing type/compatibility

Comments

@xiekeyi98
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
select json_array(b'0', b'1', b'10');
  1. What did you expect to see?

In MySQL

mysql> select version();
+-------------------------+
| version()               |
+-------------------------+
| 5.7.25-0ubuntu0.18.04.2 |
+-------------------------+
1 row in set (0.00 sec)

mysql> select json_array(b'0', b'1', b'10');
+--------------------------------------------------------------------+
| json_array(b'0', b'1', b'10')                                      |
+--------------------------------------------------------------------+
| ["base64:type16:AA==", "base64:type16:AQ==", "base64:type16:Ag=="] |
+--------------------------------------------------------------------+
1 row in set (0.00 sec)
  1. What did you see instead?

In TIDB

mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v3.0.0-beta-321-gc6a757b24
Git Commit Hash: c6a757b2435965a72ada9d61ea8b7a367bd89b5f
Git Branch: master
UTC Build Time: 2019-04-02 02:38:04
GoVersion: go version go1.12.1 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
1 row in set (0.01 sec)

mysql> select json_array(b'0', b'1', b'10');
+--------------------------------+
| json_array(b'0', b'1', b'10')  |
+--------------------------------+
| ["\u0000", "\u0001", "\u0002"] |
+--------------------------------+
1 row in set (0.00 sec)
@wjhuang2016
Copy link
Member

base64:type16:AA==

type16 here is special in MySQL to distinguish binary literal from other opaque types.
Since we didn't introduce these types from MySQL, we can only hard code it to 16 presently.
Besides, in MySQL 8.0.15, its type is 15.

@kodeine
Copy link

kodeine commented Oct 4, 2019

So how exactly we decode base64:type16:AA==?

@ghost
Copy link

ghost commented Aug 3, 2020

Confirming this issue still exists:

mysql> select json_array(b'0', b'1', b'10');
+--------------------------------+
| json_array(b'0', b'1', b'10')  |
+--------------------------------+
| ["\u0000", "\u0001", "\u0002"] |
+--------------------------------+
1 row in set (0.00 sec)

mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-870-g2a8b96845
Edition: Community
Git Commit Hash: 2a8b968453520e4fcf9d6ff46c9f23b4ad23feee
Git Branch: master
UTC Build Time: 2020-07-31 08:45:35
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@ghost ghost added the priority/P4 Minor issue, awaiting more evidence before prioritizing label Aug 12, 2020
ti-chi-bot pushed a commit that referenced this issue Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression component/json priority/P4 Minor issue, awaiting more evidence before prioritizing type/compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants