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

Incompatible with MySQL 8.0 about the CAST string to JSON #10390

Closed
lonng opened this issue May 8, 2019 · 7 comments
Closed

Incompatible with MySQL 8.0 about the CAST string to JSON #10390

lonng opened this issue May 8, 2019 · 7 comments
Assignees

Comments

@lonng
Copy link
Contributor

lonng commented May 8, 2019

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.
➜  ~ tidiff 'select cast("2018-01-02 01:01:01.111111" as json)'
MySQL(127.0.0.1:3306)> select cast("2018-01-02 01:01:01.111111" as json)
Error 3141: Invalid JSON text in argument 1 to function cast_as_json: "The document root must not be followed by other values." at position 4.

TiDB(127.0.0.1:4000)> select cast("2018-01-02 01:01:01.111111" as json)
+--------------------------------------------+
| cast("2018-01-02 01:01:01.111111" as json) |
+--------------------------------------------+
| 2018                                       |
+--------------------------------------------+
1 row in set (0.003 sec)
  1. What did you expect to see?

The error should be produced.

  1. What did you see instead?

Returns an unexpected result.

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
TiDB(127.0.0.1:4000)> select tidb_version()
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                                            |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v2.1.8-24-g7b36cdfb6-dirty
Git Commit Hash: 7b36cdfb6e8a4c279fc360ed79cf1c499b553688
Git Branch: failpoint-2.1
UTC Build Time: 2019-04-30 08:26:17
GoVersion: go version go1.12 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.003 sec)
@lonng lonng added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. type/bug The issue is confirmed as a bug. type/compatibility labels May 8, 2019
@lonng lonng changed the title Incompatible issue: CAST function has not the same behavior with MySQL 8.0 Incompatible with MySQL 8.0 about the CAST function behavior May 8, 2019
@lonng lonng changed the title Incompatible with MySQL 8.0 about the CAST function behavior Incompatible with MySQL 8.0 about the CAST string to JSON May 8, 2019
@zz-jason zz-jason removed the good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. label Jun 7, 2019
@wjhuang2016
Copy link
Member

Now, the master:

mysql> select cast("2018-01-02 01:01:01.111111" as json);
ERROR 3140 (22032): Invalid JSON text: The document root must not be followed by other values.

@ghost
Copy link

ghost commented Jul 15, 2020

I have verified this against master. TiDB now correctly returns an error with the correct code. It is only the message that differs:

select cast("2018-01-02 01:01:01.111111" as json);

..

mysql> select cast("2018-01-02 01:01:01.111111" as json);
ERROR 3140 (22032): Invalid JSON text: The document root must not be followed by other values.

mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-771-gca41972fb
Edition: Community
Git Commit Hash: ca41972fbac068c8a5de107d9075f09ac68842ac
Git Branch: master
UTC Build Time: 2020-07-14 02:41:21
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)


vs MySQL:

mysql [localhost:5731] {msandbox} (test) > select cast("2018-01-02 01:01:01.111111" as json);
ERROR 3141 (22032): Invalid JSON text in argument 1 to function cast_as_json: "The document root must not be followed by other values." at position 4.

@lonng
Copy link
Contributor Author

lonng commented Jul 16, 2020

@nullnotnil Then, can we close this issue?

@ghost
Copy link

ghost commented Jul 16, 2020

I agree. Message parity is less important here because it gets very specific about the json parser.

We can re-open if it is discovered applications depend on it.

@HimanshuChugh2
Copy link

i am saving json value which includes base64 text of 3mn characters, i am getting the below error while inserting in mysql.

The document root must not be followed by other values." at position 2725979 in value for column 'create_content.data'.

this is how my table looks like

image

the base64 text is an image.

how can this error be resolved ?

@ghost
Copy link

ghost commented Jul 31, 2020

@HimanshuChugh2 can you provide an example INSERT statement which fails? I would recommend creating a new issue, but I would be happy to take a look at it for you.

@HimanshuChugh2
Copy link

Hey buddy @nullnotnil , thanks for your response, i have created a new issue, please take a look and help me,
Thank you

issue link: #18922 @nullnotnil

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants