Bug #121143 Correlated usage of json_table function does not seem to produce values

Submitted: 20 Aug 9:40 Modified: 26 Aug 8:50
Reporter: Christian Beikov Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: JSON Severity:S3 (Non-critical)
Version:8.0.46 OS:Any
Assigned to: CPU Architecture:Any

[20 Aug 9:40] Christian Beikov
Description:
Correlated usage of json_table function does not seem to produce values.
The following query works fine:

    select
        ewa1_0.id 
    from
        EntityWithArrays ewa1_0 
    join
        json_table(ewa1_0.the_array, '$[*]' columns(v varchar(255) path '$')) t1_0 
            on true 
    where
        t1_0.v='abc'

but when using a correlation style, it fails.

How to repeat:
Consider the following model:

    create table EntityWithArrays (
        id bigint not null,
        the_array json,
        primary key (id)
    ) engine=InnoDB;

    insert 
    into
        EntityWithArrays
        (the_array, id) 
    values
        (cast('[]' as json), 1);
    insert 
    into
        EntityWithArrays
        (the_array, id) 
    values
        (cast('["abc",null,"def"]' as json), 2);
    insert 
    into
        EntityWithArrays
        (the_array, id) 
    values
        (cast(null as json), 3);

Run the query:

    select
        ewa1_0.id 
    from
        EntityWithArrays ewa1_0 
    where
        'abc' in (
          select t1_0.v
          from json_table(ewa1_0.the_array, '$[*]' columns(
            v varchar(255) path '$'
          )) t1_0
        )

or

    select
        ewa1_0.id 
    from
        EntityWithArrays ewa1_0 
    where
        exists (
          select 1 
          from json_table(ewa1_0.the_array, '$[*]' columns(
            v varchar(255) path '$'
          )) t1_0 
          where t1_0.v='abc'
        )

It should produce a result, but doesn't.
[20 Aug 10:48] Chaithra Marsur Gopala Reddy
Hi Christian Beikov,

Thank you for the test case. We see that this problem has been fixed in 9.3+ with the patch for Bug#114897. So we are marking this as duplicate.

Thanks,
Chaithra
[20 Aug 10:51] Christian Beikov
Are you going to backport the fix to MySQL 8 also?
[26 Aug 7:15] Chaithra Marsur Gopala Reddy
Hi,

MySQL-8.0 is end-of-life. So we will not be backporting it to that release.

Thanks,
Chaithra
[26 Aug 8:50] Christian Beikov
Yes, but what about MySQL 8.4? That is not yet EOL, right?
[30 Sep 8:23] Chaithra Marsur Gopala Reddy
This bug is now back ported to 8.4. It will be available in MySQL-8.4.14 version.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.