Skip to content

Unexpected result when using JSON_VALID #56293

@suyZhong

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)

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