← Back to team overview

maria-developers team mailing list archive

MDEV-17399: JSON_TABLE: Crash with nested path

 

Hi Alexey,

I was looking at Json_table_nested_path::set_position(), wondering why does 
it have an assignment 
  
  np->m_null= TRUE;

but doesn't clear the NULL values and trying to come up with an example of this
going wrong when I've hit this crash:

select * from
json_table(
'[ 
  {"name": "X", 
    "colors":["blue"], "sizes": [1,2,3,4],  "prices" : [10,20]},
  {"name": "Y", 
    "colors":["red"], "sizes": [10,11],  "prices" : [100,200,300]}
]',
'$[*]' columns
(
  seq0 for ordinality,
  name varchar(4) path '$.name',
  nested path '$.colors[*]' columns (
    seq1 for ordinality,
    color text path '$'
  ),
  nested path '$.sizes[*]' columns (
    seq2 for ordinality,
    size int path '$'
  ),
  nested path '$.prices[*]' columns (
    seq3 for ordinality, 
    price int path '$'
  )
)
) as T order by seq0, name;

Note this==NULL:

(gdb) wher
  #0  0x00005555560edf72 in Json_table_nested_path::set_position (this=0x0, j_start=0x7ffeb0016e68 "[ \n  {\"name\": \"X\", \n    \"colors\":[\"blue\"], \"sizes\": [1,2,3,4],  \"prices\" : [10,20]},\n  {\"name\": \"Y\", \n    \"colors\":[\"red\"], \"sizes\": [10,11],  \"prices\" : [100,200,300]}\n]", j_end=0x7ffeb0016f12 "", pos=0x7ffeb0035e51 "\245\245\245\245\245\245\245\245\006") at /home/psergey/dev-git2/10.6-hf-review6/sql/table_function.cc:239
  #1  0x00005555560ee12f in Json_table_nested_path::set_position (this=0x7ffeb0017060, j_start=0x7ffeb0016e68 "[ \n  {\"name\": \"X\", \n    \"colors\":[\"blue\"], \"sizes\": [1,2,3,4],  \"prices\" : [10,20]},\n  {\"name\": \"Y\", \n    \"colors\":[\"red\"], \"sizes\": [10,11],  \"prices\" : [100,200,300]}\n]", j_end=0x7ffeb0016f12 "", pos=0x7ffeb0035e48 "") at /home/psergey/dev-git2/10.6-hf-review6/sql/table_function.cc:262
  #2  0x00005555560ee9f0 in ha_json_table::rnd_pos (this=0x7ffeb0014f00, buf=0x7ffeb0025570 "\377", pos=0x7ffeb0035e48 "") at /home/psergey/dev-git2/10.6-hf-review6/sql/table_function.cc:434
  #3  0x00005555561ca6a4 in handler::ha_rnd_pos (this=0x7ffeb0014f00, buf=0x7ffeb0025570 "\377", pos=0x7ffeb0035e48 "") at /home/psergey/dev-git2/10.6-hf-review6/sql/handler.cc:3101
  #4  0x00005555563852e3 in rr_from_pointers (info=0x7ffeb001f9e0) at /home/psergey/dev-git2/10.6-hf-review6/sql/records.cc:615
  #5  0x0000555555da4a75 in READ_RECORD::read_record (this=0x7ffeb001f9e0) at /home/psergey/dev-git2/10.6-hf-review6/sql/records.h:81
  #6  0x0000555555ee1876 in join_init_read_record (tab=0x7ffeb001f918) at /home/psergey/dev-git2/10.6-hf-review6/sql/sql_select.cc:21644
  #7  0x0000555555edf35a in sub_select (join=0x7ffeb001d948, join_tab=0x7ffeb001f918, end_of_records=false) at /home/psergey/dev-git2/10.6-hf-review6/sql/sql_select.cc:20666
  #8  0x0000555555ede8e6 in do_select (join=0x7ffeb001d948, procedure=0x0) at /home/psergey/dev-git2/10.6-hf-review6/sql/sql_select.cc:20216
  #9  0x0000555555eb24e7 in JOIN::exec_inner (this=0x7ffeb001d948) at /home/psergey/dev-git2/10.6-hf-review6/sql/sql_select.cc:4484
  #10 0x0000555555eb1613 in JOIN::exec (this=0x7ffeb001d948) at /home/psergey/dev-git2/10.6-hf-review6/sql/sql_select.cc:4264

Please fix.

BR
 Sergei
-- 
Sergei Petrunia, Software Developer
MariaDB Corporation | Skype: sergefp | Blog: http://petrunia.net




Follow ups