Commit a9640809 authored by Sergei Petrunia's avatar Sergei Petrunia Committed by Alexey Botchkov

MDEV-25397: JSON_TABLE: Unexpected ER_MIX_OF_GROUP_FUNC_AND_FIELDS

When doing name resolution, do the same what WHERE/ON clauses do:
they don't count in select_lex->non_agg_field_used().
parent f82947e4
...@@ -803,5 +803,16 @@ SELECT * FROM v; ...@@ -803,5 +803,16 @@ SELECT * FROM v;
b b
DROP VIEW v; DROP VIEW v;
# #
# MDEV-25397: JSON_TABLE: Unexpected ER_MIX_OF_GROUP_FUNC_AND_FIELDS upon query with JOIN
#
set @save_sql_mode= @@sql_mode;
SET sql_mode='ONLY_FULL_GROUP_BY';
CREATE TABLE t1 (a TEXT);
SELECT SUM(o) FROM t1 JOIN JSON_TABLE(t1.a, '$' COLUMNS(o FOR ORDINALITY)) jt;
SUM(o)
NULL
set sql_mode=@save_sql_mode;
drop table t1;
#
# End of 10.6 tests # End of 10.6 tests
# #
...@@ -698,6 +698,17 @@ SELECT * FROM v; ...@@ -698,6 +698,17 @@ SELECT * FROM v;
DROP VIEW v; DROP VIEW v;
--echo #
--echo # MDEV-25397: JSON_TABLE: Unexpected ER_MIX_OF_GROUP_FUNC_AND_FIELDS upon query with JOIN
--echo #
set @save_sql_mode= @@sql_mode;
SET sql_mode='ONLY_FULL_GROUP_BY';
CREATE TABLE t1 (a TEXT);
SELECT SUM(o) FROM t1 JOIN JSON_TABLE(t1.a, '$' COLUMNS(o FOR ORDINALITY)) jt;
set sql_mode=@save_sql_mode;
drop table t1;
--echo # --echo #
--echo # End of 10.6 tests --echo # End of 10.6 tests
--echo # --echo #
...@@ -1055,9 +1055,15 @@ int Table_function_json_table::setup(THD *thd, TABLE_LIST *sql_table, ...@@ -1055,9 +1055,15 @@ int Table_function_json_table::setup(THD *thd, TABLE_LIST *sql_table,
// table function reference // table function reference
m_context->ignored_tables= get_disallowed_table_deps(s_lex->join, t->map); m_context->ignored_tables= get_disallowed_table_deps(s_lex->join, t->map);
// Do the same what setup_without_group() does: do not count the referred
// fields in non_agg_field_used:
const bool saved_non_agg_field_used= s_lex->non_agg_field_used();
res= m_json->fix_fields_if_needed(thd, &m_json); res= m_json->fix_fields_if_needed(thd, &m_json);
thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
s_lex->set_non_agg_field_used(saved_non_agg_field_used);
if (res) if (res)
return TRUE; return TRUE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment