Skip to content

Commit

Permalink
MDEV-25352: JSON_TABLE: Inconsistent name resolution and ER_VIEW_INVALID
Browse files Browse the repository at this point in the history
Add testcase
  • Loading branch information
spetrunia authored and Alexey Botchkov committed Apr 21, 2021
1 parent 7489509 commit bd1d6ee
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mysql-test/suite/json/r/json_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,25 @@ json_table(JT.d, '$' COLUMNS (d for ordinality)) as JT2
ERROR 42S22: Unknown column 'JT2.d' in 'JSON_TABLE argument'
drop table t1, t2;
#
# MDEV-25352: JSON_TABLE: Inconsistent name resolution and ER_VIEW_INVALID ...
# (Just the testcase)
#
CREATE TABLE t1 (a INT, b VARCHAR(8));
INSERT INTO t1 VALUES (1,'{}'),(2,'[]');
CREATE TABLE t2 (a INT);
INSERT INTO t2 VALUES (2),(3);
SELECT t1.*
FROM
t1 NATURAL JOIN t2
RIGHT JOIN
JSON_TABLE (t1.b, '$' COLUMNS(o FOR ORDINALITY)) AS jt ON (t1.a = jt.o)
WHERE t1.a = 1;
ERROR 42S22: Unknown column 't1.b' in 'JSON_TABLE argument'
CREATE OR REPLACE VIEW v AS
SELECT t1.* FROM t1 NATURAL JOIN t2 RIGHT JOIN JSON_TABLE (t1.b, '$' COLUMNS(o FOR ORDINALITY)) AS jt ON (t1.a = jt.o) WHERE t1.a = 1;
ERROR 42S22: Unknown column 't1.b' in 'JSON_TABLE argument'
drop table t1,t2;
#
# MDEV-25256: JSON_TABLE: Error ER_VIEW_INVALID upon running query via view
#
SELECT * FROM
Expand Down
25 changes: 25 additions & 0 deletions mysql-test/suite/json/t/json_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,31 @@ select * from

drop table t1, t2;

--echo #
--echo # MDEV-25352: JSON_TABLE: Inconsistent name resolution and ER_VIEW_INVALID ...
--echo # (Just the testcase)
--echo #

CREATE TABLE t1 (a INT, b VARCHAR(8));
INSERT INTO t1 VALUES (1,'{}'),(2,'[]');

CREATE TABLE t2 (a INT);
INSERT INTO t2 VALUES (2),(3);

--error ER_BAD_FIELD_ERROR
SELECT t1.*
FROM
t1 NATURAL JOIN t2
RIGHT JOIN
JSON_TABLE (t1.b, '$' COLUMNS(o FOR ORDINALITY)) AS jt ON (t1.a = jt.o)
WHERE t1.a = 1;

--error ER_BAD_FIELD_ERROR
CREATE OR REPLACE VIEW v AS
SELECT t1.* FROM t1 NATURAL JOIN t2 RIGHT JOIN JSON_TABLE (t1.b, '$' COLUMNS(o FOR ORDINALITY)) AS jt ON (t1.a = jt.o) WHERE t1.a = 1;

drop table t1,t2;

--echo #
--echo # MDEV-25256: JSON_TABLE: Error ER_VIEW_INVALID upon running query via view
--echo #
Expand Down

0 comments on commit bd1d6ee

Please sign in to comment.