summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2021-04-08 20:46:49 +0300
committerAlexey Botchkov <holyfoot@askmonty.org>2021-04-21 10:21:46 +0400
commitbd1d6ee4b19a6adb45898ce5cb113235dbb64746 (patch)
tree1da52980386442bdc1959201c5389e43c3c8a155
parent74895090b39041af76b42402a989ea493ab1d8ef (diff)
downloadmariadb-git-bd1d6ee4b19a6adb45898ce5cb113235dbb64746.tar.gz
MDEV-25352: JSON_TABLE: Inconsistent name resolution and ER_VIEW_INVALID
Add testcase
-rw-r--r--mysql-test/suite/json/r/json_table.result19
-rw-r--r--mysql-test/suite/json/t/json_table.test25
2 files changed, 44 insertions, 0 deletions
diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result
index da4eed6150e..3910a5977a2 100644
--- a/mysql-test/suite/json/r/json_table.result
+++ b/mysql-test/suite/json/r/json_table.result
@@ -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
diff --git a/mysql-test/suite/json/t/json_table.test b/mysql-test/suite/json/t/json_table.test
index 37a88f1d1ee..f8198322d7d 100644
--- a/mysql-test/suite/json/t/json_table.test
+++ b/mysql-test/suite/json/t/json_table.test
@@ -564,6 +564,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 #