Skip to content

Unexpected result when using JSON_VALID #56293

Description

@suyZhong

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

DROP DATABASE IF EXISTS db0;
CREATE DATABASE db0;
USE db0;

CREATE  TABLE  t0(c0 VARCHAR(500) , c1 INT );
CREATE VIEW v0(c0) AS SELECT 'a' FROM t0;
INSERT INTO t0(c0) VALUES ('b');

SELECT * FROM t0 NATURAL RIGHT JOIN v0; -- a NULL
SELECT (JSON_VALID(t0.c1)=0) FROM t0 NATURAL RIGHT JOIN v0; -- 1
SELECT * FROM t0 NATURAL RIGHT JOIN v0 WHERE (JSON_VALID(t0.c1)=0);
-- Expected: a NULL
-- Actual: empty

This could be reproduced on MySQL also, but still, I suspect it is unexpected.

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

The second query returns a NULL value or the third query returns the row in the table after join.

3. What did you see instead (Required)

empty set

4. What is your TiDB version? (Required)

select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                       |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.4.0-alpha-244-ga5e07a2
Edition: Community
Git Commit Hash: a5e07a2ed360f29216c912775ce482f536f4102b
Git Branch: HEAD
UTC Build Time: 2024-09-25 05:10:21
GoVersion: go1.21.13
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Activity

  1. suyZhong commented on Sep 25, 2024

    @suyZhong
    Author

    /label fuzz/sqlancer

  2. self-assigned this
    on Sep 27, 2024
  3. YangKeao commented on Sep 27, 2024

    @YangKeao
    Member

    There is another case that the result is not compatible with MySQL:

    SELECT * FROM t0 WHERE (JSON_VALID(t0.c1)=0);

    TiDB (with TiKV) gives nothing, but TiDB (unistore) and MySQL gives one row. Maybe the implementation has some bugs in TiKV side.

  4. 3 remaining items

  5. added a commit that references this issue on Nov 19, 2024
    1b6d01b
  6. added a commit that references this issue on Nov 20, 2024
    5cf2682
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.fuzz/sqlancerimpact/wrong-resultseverity/moderatesig/sql-infraSIG: SQL Infratype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions