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

dml: insert constant into json column should report some errors #25020

Closed
AilinKid opened this issue Jun 1, 2021 · 3 comments
Closed

dml: insert constant into json column should report some errors #25020

AilinKid opened this issue Jun 1, 2021 · 3 comments
Assignees
Labels
affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 component/json help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@AilinKid
Copy link
Contributor

AilinKid commented Jun 1, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `tbl_1` (
  `col_5` json NOT NULL,
  `col_25` json DEFAULT NULL,
  `col_7` json DEFAULT NULL,
  `col_8` json NOT NULL,
  `col_9` json NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin 
insert into tbl_1 values(1, "\"a\"" ,false  , 1 ,77);

MySQL8.0

ERROR 3140 (22032): Invalid JSON text: "not a JSON text, may need CAST" at position 0 in value for column 'tbl_1.col_5'.

TiDB

mysql> insert into tbl_1 values(1, "\"a\"" ,false  , 1 ,77);
Query OK, 1 row affected (0.00 sec)

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

should it be the same?

3. What did you see instead (Required)

as you see above

4. What is your TiDB version? (Required)

master

@AilinKid AilinKid added type/bug The issue is confirmed as a bug. sig/community-infra sig/sql-infra SIG: SQL Infra labels Jun 1, 2021
@AilinKid AilinKid changed the title insert constant into json column should report some errors dml: insert constant into json column should report some errors Jun 1, 2021
@xiongjiwei xiongjiwei added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Jun 4, 2021
@zimulala zimulala self-assigned this Aug 2, 2021
@bb7133 bb7133 added sig/execution SIG execution and removed sig/sql-infra SIG: SQL Infra labels Aug 9, 2021
@bb7133
Copy link
Member

bb7133 commented Aug 9, 2021

I changed the SIG to 'sig/execution' since it is related to JSON.

@jebter jebter added affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. labels Jan 11, 2022
@windtalker windtalker assigned windtalker and unassigned zimulala Jul 7, 2022
@windtalker
Copy link
Contributor

In MySQL, when the target type is not the same as the input type, MySQL usually will implicitly convert the input to target type(both for insert into table and function call), but for Json type, it explicitly defines that only some types can be implicit convert to Json. In TiDB, it allows implicitly convert between all types. I think it is kind of unreasonable for MySQL's special restriction for Json type, I'm not sure if we need to follow MySQL's behavior @zanmato1984 ?

@zanmato1984
Copy link
Contributor

In MySQL, when the target type is not the same as the input type, MySQL usually will implicitly convert the input to target type(both for insert into table and function call), but for Json type, it explicitly defines that only some types can be implicit convert to Json. In TiDB, it allows implicitly convert between all types. I think it is kind of unreasonable for MySQL's special restriction for Json type, I'm not sure if we need to follow MySQL's behavior @zanmato1984 ?

Yeah this makes sense. Besides, json is not fully GA in TiDB, so I don't think we'll cover as much details as this issue. I'm closing it temporarily until we have done more investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 component/json help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

10 participants