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

A minor compatible issue when binary string is used for json_unquote #25580

Open
Tracked by #36993
guo-shaoge opened this issue Jun 19, 2021 · 3 comments
Open
Tracked by #36993
Assignees
Labels
component/json severity/minor sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@guo-shaoge
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

SELECT JSON_UNQUOTE(CAST('ABCD' AS BINARY));

2. What did you expect to see? (Required)

mysql> SELECT JSON_UNQUOTE(CAST('ABCD' AS BINARY));
ERROR 3144 (22032): Cannot create a JSON value from a string with CHARACTER SET 'binary'.

3. What did you see instead (Required)

mysql> SELECT JSON_UNQUOTE(CAST('ABCD' AS BINARY));
+--------------------------------------+
| JSON_UNQUOTE(CAST('ABCD' AS BINARY)) |
+--------------------------------------+
| ABCD                                 |
+--------------------------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

master

@YangKeao
Copy link
Member

YangKeao commented Sep 7, 2022

@xiongjiwei tells it's expected to implicitly cast the string to json opaque. However, the implementation of TiDB is still different:

mysql> SELECT JSON_UNQUOTE(CAST(CAST('ABCD' AS BINARY) AS JSON));
+----------------------------------------------------+
| JSON_UNQUOTE(CAST(CAST('ABCD' AS BINARY) AS JSON)) |
+----------------------------------------------------+
| base64:type253:QUJDRA==                            |
+----------------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT JSON_UNQUOTE(CAST('ABCD' AS BINARY));
+--------------------------------------+
| JSON_UNQUOTE(CAST('ABCD' AS BINARY)) |
+--------------------------------------+
| ABCD                                 |
+--------------------------------------+
1 row in set (0.00 sec)

It's actually not implicitly casted to json, but return the string directly. @xiongjiwei How do you think about it?

@xiongjiwei
Copy link
Contributor

I will take a look and fix it

@dveeden
Copy link
Contributor

dveeden commented Jun 12, 2024

@xiongjiwei is this still something you're working on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/json severity/minor sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

5 participants