diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result index 8789f4ced8d..619aeea985e 100644 --- a/mysql-test/suite/json/r/json_table.result +++ b/mysql-test/suite/json/r/json_table.result @@ -793,5 +793,15 @@ a b c o DROP VIEW v2; DROP TABLE t1, t2; # +# MDEV-25259 JSON_TABLE: Illegal mix of collations upon executing query with combination of charsets via view. +# +CREATE VIEW v AS +SELECT * FROM JSON_TABLE(CONVERT('[]' USING dec8), +'$' COLUMNS(b VARCHAR(8) CHARSET utf8 PATH '$')) AS jt2 +WHERE (CONVERT('[]' USING cp1256) = b); +SELECT * FROM v; +b +DROP VIEW v; +# # End of 10.6 tests # diff --git a/mysql-test/suite/json/t/json_table.test b/mysql-test/suite/json/t/json_table.test index e91e89ab72f..9b31ddeb3b6 100644 --- a/mysql-test/suite/json/t/json_table.test +++ b/mysql-test/suite/json/t/json_table.test @@ -685,6 +685,19 @@ FROM DROP VIEW v2; DROP TABLE t1, t2; +--echo # +--echo # MDEV-25259 JSON_TABLE: Illegal mix of collations upon executing query with combination of charsets via view. +--echo # + +CREATE VIEW v AS + SELECT * FROM JSON_TABLE(CONVERT('[]' USING dec8), + '$' COLUMNS(b VARCHAR(8) CHARSET utf8 PATH '$')) AS jt2 + WHERE (CONVERT('[]' USING cp1256) = b); + +SELECT * FROM v; + +DROP VIEW v; + --echo # --echo # End of 10.6 tests --echo # diff --git a/sql/json_table.cc b/sql/json_table.cc index e8e50347fa7..550209c804d 100644 --- a/sql/json_table.cc +++ b/sql/json_table.cc @@ -1098,6 +1098,8 @@ int Json_table_column::print(THD *thd, Field **f, String *str) (*f)->sql_type(column_type); if (str->append(column_type) || + (m_explicit_cs && + (str->append(" CHARSET ") || str->append(m_explicit_cs->csname))) || str->append(m_column_type == PATH ? " PATH " : " EXISTS PATH ") || print_path(str, &m_path)) return 1;