1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

MDEV-34679 ER_BAD_FIELD uses non-localizable substrings

This commit is contained in:
Sergei Golubchik
2024-07-18 15:20:42 +02:00
parent 99178311ac
commit 3a1cf2c85b
349 changed files with 1218 additions and 1796 deletions

View File

@@ -2473,7 +2473,7 @@ NULL
Warnings:
Warning 4042 Syntax error in JSON path in argument 6 to function 'json_search' at position 2
select json_search(a, b, c);
ERROR 42S22: Unknown column 'a' in 'field list'
ERROR 42S22: Unknown column 'a' in 'SELECT'
select json_search( '{ "a": "foobar" }', 'one', 'foo%' );
json_search( '{ "a": "foobar" }', 'one', 'foo%' )
"$.a"

View File

@@ -43,7 +43,7 @@ j2 [{"a": 3, "b": [11,111]}, {"a": 4, "b": [22,222]}, {"a": 5, "b": [22,222]}] 2
j2 [{"a": 3, "b": [11,111]}, {"a": 4, "b": [22,222]}, {"a": 5, "b": [22,222]}] 3 5 1 22
j2 [{"a": 3, "b": [11,111]}, {"a": 4, "b": [22,222]}, {"a": 5, "b": [22,222]}] 3 5 2 222
select * from t1, JSON_TABLE(t1.no_field, '$[*]' COLUMNS(js_id FOR ORDINALITY, a INT PATH '$.a', NESTED PATH '$.b[*]' COLUMNS (l_js_id FOR ORDINALITY, b INT PATH '$'))) as jt;
ERROR 42S22: Unknown column 't1.no_field' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1.no_field' in 'JSON_TABLE'
select * from t1, JSON_TABLE(t1.no_field, '$[*]' COLUMNS(js_id FOR ORDINALITY, a INT PATH '$.a', NESTED PATH '$.b[*]' COLUMNS (l_js_id FOR ORDINALITY, a INT PATH '$'))) as jt;
ERROR 42S21: Duplicate column name 'a'
DROP TABLE t1;
@@ -55,7 +55,7 @@ item_name item_props color
Laptop {"color": "black", "price": 1000} black
Jeans {"color": "blue", "price": 50} blue
select * from t1 right join json_table(t1.item_props,'$' columns( color varchar(100) path '$.color')) as T on 1;
ERROR 42S22: Unknown column 't1.item_props' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1.item_props' in 'JSON_TABLE'
DROP TABLE t1;
select * from JSON_TABLE( '[ {"xa": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a' default 101 on empty, NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$'))) as jt;
a b
@@ -249,14 +249,14 @@ CREATE TABLE t1 (x INT);
INSERT INTO t1 VALUES (1), (2), (3);
SELECT t1.x*2 m, jt.* FROM t1,
JSON_TABLE(m, '$[*]' COLUMNS (i INT PATH '$')) jt;
ERROR 42S22: Unknown column 'm' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'm' in 'JSON_TABLE'
DROP TABLE t1;
select *
from
json_table(JS3.size, '$' columns (size INT PATH '$.size')) as JS1,
json_table(JS1.size, '$' columns (size INT PATH '$.size')) as JS2,
json_table(JS1.size, '$' columns (size INT PATH '$.size')) as JS3 where 1;
ERROR 42S22: Unknown column 'JS3.size' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'JS3.size' in 'JSON_TABLE'
create table t1 (json varchar(100) character set utf8);
insert into t1 values ('{"value":"АБВ"}');
create table tj1 as
@@ -283,7 +283,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 'f1'
test.t1 analyze status OK
SELECT * FROM JSON_TABLE(tt3.f1, "$" COLUMNS (id FOR ORDINALITY)) AS tbl STRAIGHT_JOIN t1 AS tt3;
ERROR 42S22: Unknown column 'tt3.f1' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'tt3.f1' in 'JSON_TABLE'
SELECT * FROM t1 as jj1,
(SELECT tt2.*
FROM
@@ -293,7 +293,7 @@ STRAIGHT_JOIN
t1 AS tt3
) dt
ORDER BY 1,3 LIMIT 10;
ERROR 42S22: Unknown column 'tt3.f1' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'tt3.f1' in 'JSON_TABLE'
drop table t1;
select collation(x) from
JSON_TABLE('["abc"]', '$[*]' COLUMNS (x VARCHAR(10) CHARSET latin1 PATH '$')) tbl;
@@ -601,13 +601,13 @@ DROP TABLE t1;
#
CREATE TABLE t1 (a INT);
SELECT * FROM t1 RIGHT JOIN JSON_TABLE(t1.a,'$' COLUMNS(o FOR ORDINALITY)) jt ON TRUE;
ERROR 42S22: Unknown column 't1.a' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1.a' in 'JSON_TABLE'
CREATE VIEW v AS
SELECT * FROM t1 RIGHT JOIN JSON_TABLE(t1.a,'$' COLUMNS(o FOR ORDINALITY)) jt ON TRUE;
ERROR 42S22: Unknown column 't1.a' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1.a' in 'JSON_TABLE'
insert into t1 values (1),(2),(3);
SELECT * FROM t1 RIGHT JOIN JSON_TABLE(t1.a,'$' COLUMNS(o FOR ORDINALITY)) jt ON TRUE;
ERROR 42S22: Unknown column 't1.a' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1.a' in 'JSON_TABLE'
drop table t1;
#
# MDEV-25202: JSON_TABLE: Early table reference leads to unexpected result set, server crash
@@ -617,9 +617,9 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (a INT);
INSERT INTO t2 VALUES (3),(4);
SELECT * FROM JSON_TABLE(a, '$' COLUMNS(o FOR ORDINALITY)) AS jt1 NATURAL JOIN t1 JOIN t2;
ERROR 42S22: Unknown column 'a' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'a' in 'JSON_TABLE'
SELECT * FROM JSON_TABLE(a, '$' COLUMNS(o FOR ORDINALITY)) AS jt1 NATURAL JOIN t1 STRAIGHT_JOIN t2;
ERROR 42S22: Unknown column 'a' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'a' in 'JSON_TABLE'
drop table t1,t2;
# Now, try a JSON_TABLE that has a subquery that has an outside reference:
create table t1(a int, js varchar(32));
@@ -641,7 +641,7 @@ t1 right join
json_table(concat('',js),
'$' columns ( color varchar(32) path '$.color')
) as JT on 1;
ERROR 42S22: Unknown column 'js' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'js' in 'JSON_TABLE'
explain
select *
from
@@ -659,7 +659,7 @@ t1 right join
json_table((select concat(a,js) from t2),
'$' columns ( color varchar(32) path '$.color')
) as JT on 1;
ERROR 42S22: Unknown column 'js' in 'field list'
ERROR 42S22: Unknown column 'js' in 'SELECT'
drop table t1,t2;
#
# Now, a testcase with JSON_TABLEs inside NATURAL JOIN
@@ -676,7 +676,7 @@ natural join
json_table(JT.d, '$' COLUMNS (d for ordinality)) as JT2
)
);
ERROR 42S22: Unknown column 'JT2.d' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'JT2.d' in 'JSON_TABLE'
drop table t1, t2;
#
# MDEV-25352: JSON_TABLE: Inconsistent name resolution and ER_VIEW_INVALID ...
@@ -692,10 +692,10 @@ 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'
ERROR 42S22: Unknown column 't1.b' in 'JSON_TABLE'
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'
ERROR 42S22: Unknown column 't1.b' in 'JSON_TABLE'
drop table t1,t2;
#
# MDEV-25256: JSON_TABLE: Error ER_VIEW_INVALID upon running query via view
@@ -707,14 +707,14 @@ ON(1)
RIGHT JOIN JSON_TABLE('[]', '$' COLUMNS(o3 FOR ORDINALITY)) AS jt3
ON(1)
WHERE 0;
ERROR 42S22: Unknown column 'jt1.a' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'jt1.a' in 'JSON_TABLE'
#
# MDEV-25346: JSON_TABLE: Server crashes in Item_field::fix_outer_field upon subquery with unknown column
#
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT);
SELECT * FROM ( SELECT * FROM t1 JOIN t2 ON (b IN(SELECT x FROM (SELECT 1 AS c) AS sq1))) AS sq2;
ERROR 42S22: Unknown column 'x' in 'field list'
ERROR 42S22: Unknown column 'x' in 'SELECT'
DROP TABLE t1, t2;
#
# Another testcase

View File

@@ -575,7 +575,7 @@ NULL
# Bug#25413069: SIG11 IN CHECK_COLUMN_GRANT_IN_TABLE_REF
#
SELECT a FROM JSON_TABLE(abc, '$[*]' COLUMNS ( a int path '$.a')) AS jt;
ERROR 42S22: Unknown column 'abc' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'abc' in 'JSON_TABLE'
#
# Bug#25420680: ASSERTION `THD->IS_ERROR()' FAILED IN SQL/SQL_SELECT.CC
#
@@ -663,10 +663,10 @@ DEALLOCATE PREPARE stmt;
CREATE TABLE t1 (id INT, jc JSON);
SELECT * FROM t1 RIGHT JOIN JSON_TABLE(t1.jc, '$' COLUMNS
(id FOR ORDINALITY)) as jt ON t1.jc=jt.id;
ERROR 42S22: Unknown column 't1.jc' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1.jc' in 'JSON_TABLE'
SELECT * FROM JSON_TABLE(t1.jc, '$' COLUMNS
(id FOR ORDINALITY)) as jt LEFT JOIN t1 ON t1.jc=jt.id;
ERROR 42S22: Unknown column 't1.jc' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1.jc' in 'JSON_TABLE'
SELECT * FROM JSON_TABLE(t1.jc, '$' COLUMNS
(id FOR ORDINALITY)) as jt RIGHT JOIN t1 ON t1.jc=jt.id;
id id jc
@@ -690,33 +690,33 @@ SELECT * FROM t1 AS t1o RIGHT JOIN
(t1 AS t1i JOIN JSON_TABLE(t1o.jc, '$' COLUMNS
(id FOR ORDINALITY)) as jt ON t1i.jc=jt.id)
ON t1o.id=t1i.id;
ERROR 42S22: Unknown column 't1o.jc' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1o.jc' in 'JSON_TABLE'
SELECT * FROM t1 AS t1o RIGHT JOIN
(t1 AS t1i RIGHT JOIN JSON_TABLE(t1o.jc, '$' COLUMNS
(id FOR ORDINALITY)) as jt ON t1i.jc=jt.id)
ON t1o.id=t1i.id;
ERROR 42S22: Unknown column 't1o.jc' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1o.jc' in 'JSON_TABLE'
WITH qn AS
(SELECT jt.* FROM t1 RIGHT JOIN JSON_TABLE(t1.jc, '$' COLUMNS
(id FOR ORDINALITY)) as jt ON t1.jc=jt.id)
SELECT * from qn;
ERROR 42S22: Unknown column 't1.jc' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1.jc' in 'JSON_TABLE'
WITH qn AS
(SELECT 1 UNION
SELECT jt.id FROM t1 RIGHT JOIN JSON_TABLE(t1.jc, '$' COLUMNS
(id FOR ORDINALITY)) as jt ON t1.jc=jt.id)
SELECT * from qn;
ERROR 42S22: Unknown column 't1.jc' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1.jc' in 'JSON_TABLE'
SELECT * FROM t1 AS t1o RIGHT JOIN
(t1 AS t1i JOIN JSON_TABLE(t1o.jc, '$' COLUMNS
(id FOR ORDINALITY)) as jt ON t1i.jc=jt.id)
ON t1o.id=t1i.id;
ERROR 42S22: Unknown column 't1o.jc' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1o.jc' in 'JSON_TABLE'
SELECT * FROM t1 AS t1o RIGHT JOIN
(t1 AS t1i RIGHT JOIN JSON_TABLE(t1o.jc, '$' COLUMNS
(id FOR ORDINALITY)) as jt ON t1i.jc=jt.id)
ON t1o.id=t1i.id;
ERROR 42S22: Unknown column 't1o.jc' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 't1o.jc' in 'JSON_TABLE'
INSERT INTO t1 VALUES(1,"1"),(2,"4"),(3,"3");
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
@@ -739,14 +739,14 @@ LEFT JOIN
JSON_TABLE(t1.jc, '$' COLUMNS (id FOR ORDINALITY)) as jt ON t1.jc=jt.id
RIGHT JOIN
JSON_TABLE(jt.id, '$' COLUMNS (id FOR ORDINALITY)) as jt1 ON jt.id=jt1.id;
ERROR 42S22: Unknown column 'jt.id' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'jt.id' in 'JSON_TABLE'
DROP TABLE t1;
#
# Bug#25525409: ASSERTION `TABLE_LIST->TABLE' FAILED IN SQL/SQL_BASE.CC
#
SELECT * FROM JSON_TABLE( ( SELECT a ) , '$.*' COLUMNS (col1 FOR ORDINALITY) )
AS alias1;
ERROR 42S22: Unknown column 'a' in 'field list'
ERROR 42S22: Unknown column 'a' in 'SELECT'
SELECT * FROM JSON_TABLE( ( SELECT 1 ) , '$.*' COLUMNS (col1 FOR ORDINALITY) )
AS alias1;
col1
@@ -1046,7 +1046,7 @@ CREATE TABLE t (x INT);
INSERT INTO t VALUES (1), (2), (3);
SELECT MAX(t.x) OVER () m, jt.* FROM t,
JSON_TABLE(JSON_ARRAY(m), '$[*]' COLUMNS (i INT PATH '$')) jt;
ERROR 42S22: Unknown column 'm' in 'JSON_TABLE argument'
ERROR 42S22: Unknown column 'm' in 'JSON_TABLE'
DROP TABLE t;
#
# Bug#26583283: ASSERTION `!THD->IS_ERROR()' FAILED IN SQL_RESOLVER.CC