← Back to team overview

maria-developers team mailing list archive

Re: 99e2a49acfc: MDEV-27018 IF and COALESCE lose "json" property

 

Hi Sergei,


Here's a new patch:

https://github.com/MariaDB/server/commit/0478f474020466c16bfcbc9c7d0ed582a40e4fb8


Please also see comments below. Thanks.


On 1/17/22 8:09 PM, Sergei Golubchik wrote:
Hi, Alexander!



We cannot have auto-generated nested CONVERT().

The new code just reproduces the old behavior:
Item_func_conv_charset::is_json_type() traversed
through all Item_func_conv_charset's recursively.

As the comment says, this is probably not correct.
Let's fix it under terms of a separate MDEV.
I can file an MDEV about this.

please, do


MDEV-27533 The result of `CONVERT(json USING ...)` is erroneously treated as JSON



diff --git a/sql/sql_type.cc b/sql/sql_type.cc
class Type_handler_pair
{
    const Type_handler *m_a;
    const Type_handler *m_b;
...
};

why did you do it this way? You create an object. Then in the loop you
create a new object, copying the old one. Then you conditionally assign
m_a->type_handler_base(). Then you diff then to see if any condition
from the previous step has succeeded.

Why not, like

   class Type_handler_pair {
     bool up() {
       bool r=false;
       n_a=m_a->type_handler_base();
       n_b=m_b->type_handler_base();
       if (n_a) { m_a=n_a; r=true; }
       if (n_b) { m_a=n_b; r=true; }
       return r;
     }

and later

    do {
       ...
    } while (tp.up());

Thanks for the suggestion. I did it your way.


also don't forget to update the commit comment, it still says
"Recursive_type_pair_iterator".


Updated.


+  }

Regards,
Sergei
VP of MariaDB Server Engineering
and security@xxxxxxxxxxx



Follow ups

References