[Maria-developers] Review for: MDEV-17399 Add support for JSON_TABLE, part #7
Hi Alexey, On Thu, Jul 16, 2020 at 04:34:46PM +0400, Alexey Botchkov wrote:
In the new patch i think i addressed most of your comments. https://github.com/MariaDB/server/commit/d3a311a8e9508ef94dddb6b7f4d366337a9...
...
The above doesn't do proper quoting, which is wrong. Testcase:
select * from json_table('[{"co\\\\lor": "blue", "price": 50}]', '$[*]' columns( color varchar(100) path '$.co\\\\lor') ) as T; +-------+ | color | +-------+ | blue | +-------+
create view v2 as select * from json_table('[{"co\\\\lor": "blue", "price": 50}]', '$[*]' columns( color varchar(100) path '$.co\\\\lor') ) as T; select * from v2;
Quoting is still an issue apparently: create view v1 as select * from json_table('[{"color": "blue", "price": 50}]', '$[*]' columns(color text path '$.nonexistent', seq for ordinality ) ) as `ALIAS NOT QUOTED`; select * from v1; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT QUOTED' at line 1 create view v2 as select * from json_table('[{"color": "blue", "price": 50}, {"color": "red", "price": 100}]', '$[*]' columns(color text path '$.QUOTES " HERE "', seq for ordinality ) ) as T; select * from v2; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'HERE "", `seq` FOR ORDINALITY)) T' at line 1 Could you please go through the printout functions and make sure all printed literals are properly escaped/quoted? Printout code for other functions can be used as an example. BR Sergei -- Sergei Petrunia, Software Developer MariaDB Corporation | Skype: sergefp | Blog: http://s.petrunia.net/blog
Hi Alexey, Did you try running MySQL's test? It needs some adjustments to run, but these can be done. I've found four crashes: --echo # --echo # Bug#26500384: ASSERT FAILURE IN QUERY WITH WINDOW FUNCTION AND --echo # JSON_TABLE --echo # --disable_parsing ## psergey: crash! CREATE TABLE t (x INT); INSERT INTO t VALUES (1), (2), (3); --error ER_BAD_FIELD_ERROR SELECT MAX(t.x) OVER () m, jt.* FROM t, JSON_TABLE(JSON_ARRAY(m), '$[*]' COLUMNS (i INT PATH '$')) jt; DROP TABLE t; --enable_parsing --echo # --echo # Bug#26679671: SIG 11 IN JSON_BINARY::PARSE_BINARY() --echo # CREATE TABLE t1(id INT, f1 JSON); INSERT INTO t1 VALUES (1, '{\"1\": 1}'), (2, '{\"1\": 2}'), (3, '{\"1\": 3}'), (4, '{\"1\": 4}'), (5, '{\"1\": 5}'), (6, '{\"1\": 6}'); ANALYZE TABLE t1; # ... SELECT * FROM t1 WHERE id IN (SELECT id FROM t1 as tt2, JSON_TABLE(f1, "$" COLUMNS (jf FOR ORDINALITY)) AS tbl); EXPLAIN SELECT * FROM t1 WHERE id IN (SELECT id FROM t1 as tt2, JSON_TABLE(f1, "$" COLUMNS (jf FOR ORDINALITY)) AS tbl); --echo # --echo # Bug#26500384: ASSERT FAILURE IN QUERY WITH WINDOW FUNCTION AND --echo # JSON_TABLE --echo # --disable_parsing ## psergey: crash! CREATE TABLE t (x INT); INSERT INTO t VALUES (1), (2), (3); --error ER_BAD_FIELD_ERROR SELECT MAX(t.x) OVER () m, jt.* FROM t, JSON_TABLE(JSON_ARRAY(m), '$[*]' COLUMNS (i INT PATH '$')) jt; DROP TABLE t; --enable_parsing There are some interesting non-crash issues, too. Here's the file I've ended up with: https://gist.github.com/spetrunia/6e567f77a42bd0df3a3c9bae0b4f3a9c BR Sergei -- Sergei Petrunia, Software Developer MariaDB Corporation | Skype: sergefp | Blog: http://s.petrunia.net/blog
participants (1)
-
Sergey Petrunia