diff --git a/client/client_priv.h b/client/client_priv.h index 832589f015c..c205d07c34c 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -80,6 +80,6 @@ enum options_client OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID, OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT, OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, - OPT_DUMP_DATE, - OPT_WRITE_BINLOG, OPT_MAX_CLIENT_OPTION + OPT_WRITE_BINLOG, OPT_DUMP_DATE, + OPT_MAX_CLIENT_OPTION }; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index cd0f9a7a172..2d8ff8d433f 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1470,6 +1470,10 @@ f7 datetime NO NULL f8 datetime YES 2006-01-01 00:00:00 drop table t1; End of 5.0 tests. +show fields from information_schema.TABLE_NAMES; +ERROR 42S02: Unknown table 'TABLE_NAMES' in information_schema +show keys from information_schema.TABLE_NAMES; +ERROR 42S02: Unknown table 'TABLE_NAMES' in information_schema select * from information_schema.engines WHERE ENGINE="MyISAM"; ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS MyISAM DEFAULT Default engine as of MySQL 3.23 with great performance NO NO NO diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 67c45b698ce..63c9590401c 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -715,3 +715,14 @@ a SUM(a) 4 4 NULL 14 DROP TABLE t1; +# +# Bug#31095: Unexpected NULL constant caused server crash. +# +create table t1(a int); +insert into t1 values (1),(2),(3); +select count(a) from t1 group by null with rollup; +count(a) +3 +3 +drop table t1; +############################################################## diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index c2c0f79d66b..6edc2353fc0 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1090,6 +1090,15 @@ show columns from t1; drop table t1; --echo End of 5.0 tests. + +# +# Bug#30079 A check for "hidden" I_S tables is flawed +# +--error 1109 +show fields from information_schema.TABLE_NAMES; +--error 1109 +show keys from information_schema.TABLE_NAMES; + # # Show engines # diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 05934bff492..1ac99d9c39f 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -358,3 +358,12 @@ SELECT * FROM (SELECT a, SUM(a) FROM t1 GROUP BY a WITH ROLLUP) as t; DROP TABLE t1; +--echo # +--echo # Bug#31095: Unexpected NULL constant caused server crash. +--echo # +create table t1(a int); +insert into t1 values (1),(2),(3); +select count(a) from t1 group by null with rollup; +drop table t1; +--echo ############################################################## + diff --git a/sql/item_func.h b/sql/item_func.h index 602c1c86f01..8800692f192 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -756,6 +756,8 @@ public: collation= args[0]->collation; max_length= args[0]->max_length; decimals=args[0]->decimals; + /* The item could be a NULL constant. */ + null_value= args[0]->null_value; } }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ae347bebb47..4204e9ec881 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5766,7 +5766,12 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->table_name); if (!schema_table || (schema_table->hidden && - (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0)) + ((sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0 || + /* + this check is used for show columns|keys from I_S hidden table + */ + lex->sql_command == SQLCOM_SHOW_FIELDS || + lex->sql_command == SQLCOM_SHOW_KEYS))) { my_error(ER_UNKNOWN_TABLE, MYF(0), ptr->table_name, INFORMATION_SCHEMA_NAME.str); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 50e0511ae96..267b8aff699 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -16035,13 +16035,15 @@ static void test_bug21635() { field= mysql_fetch_field_direct(result, i); if (!opt_silent) - printf("%s -> %s ... ", expr[i * 2], field->name); + if (!opt_silent) + printf("%s -> %s ... ", expr[i * 2], field->name); fflush(stdout); DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 && field->table[0] == 0 && field->org_name[0] == 0); DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0); if (!opt_silent) - puts("OK"); + if (!opt_silent) + puts("OK"); } mysql_free_result(result);