From 641f81baf45212569ec8a98072d62fd29e3fc8f0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 1 Aug 2020 13:19:59 +0200 Subject: cleanup: use my_multi_malloc(), etc --- sql/sql_select.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 738e1912994..461c7b18363 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -17490,8 +17490,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List &fields, No need to change table name to lower case as we are only creating MyISAM, Aria or HEAP tables here */ - fn_format(path, path, mysql_tmpdir, "", - MY_REPLACE_EXT|MY_UNPACK_FILENAME); + fn_format(path, path, mysql_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME); if (group) { @@ -18673,14 +18672,10 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, } } - if (unlikely((error= maria_create(share->path.str, - file_type, - share->keys, &keydef, - (uint) (*recinfo-start_recinfo), - start_recinfo, - share->uniques, &uniquedef, - &create_info, - create_flags)))) + if (unlikely((error= maria_create(share->path.str, file_type, share->keys, + &keydef, (uint) (*recinfo-start_recinfo), + start_recinfo, share->uniques, &uniquedef, + &create_info, create_flags)))) { table->file->print_error(error,MYF(0)); /* purecov: inspected */ table->db_stat=0; @@ -18881,8 +18876,7 @@ create_internal_tmp_table_from_heap(THD *thd, TABLE *table, if (is_duplicate) *is_duplicate= FALSE; - if (table->s->db_type() != heap_hton || - error != HA_ERR_RECORD_FILE_FULL) + if (table->s->db_type() != heap_hton || error != HA_ERR_RECORD_FILE_FULL) { /* We don't want this error to be converted to a warning, e.g. in case of -- cgit v1.2.1 From e64084d5a3a72462fa6263d1d0a86e72c0ba0d47 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 1 Aug 2020 13:12:50 +0200 Subject: MDEV-21201 No records produced in information_schema query, depending on projection Reimplement MDEV-14275 Improving memory utilization for information schema Postpone temp table instantiation until after setup_fields(). Replace all unused (not marked in read_set) columns in an I_S table with CHAR(0). This can drastically reduce the footprint of a MEMORY table (a TABLE_CATALOG alone is 1538 bytes per row). This does not change the engine. If the table was decided to be Aria (because of, say, blobs) then after optimization it'll stay Aria even if all blobs were removed. Note 1: when transforming table structure, share->blob_fields is preserved, otherwise Aria might switch from DYNAMIC to STATIC row format and expect a special field for a deleted mark, which create_tmp_tabe didn't provide. Note 2: optimizer was doing handler::info() (to know the number of rows) before the temp table is populated. That didn't make much sense. Now it's done before the table is even instantiated. Preserve the old behavior and report 0 rows. This reverts e2664ee8362 and a8458a2345e --- sql/sql_select.cc | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 461c7b18363..37755387dda 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2468,6 +2468,10 @@ int JOIN::optimize_stage2() (select_options & (SELECT_DESCRIBE | SELECT_NO_JOIN_CACHE)) | (select_lex->ftfunc_list->elements ? SELECT_NO_JOIN_CACHE : 0); + if (select_lex->options & OPTION_SCHEMA_TABLE && + optimize_schema_tables_reads(this)) + DBUG_RETURN(1); + if (make_join_readinfo(this, select_opts_for_readinfo, no_jbuf_after)) DBUG_RETURN(1); @@ -2644,10 +2648,6 @@ int JOIN::optimize_stage2() having_is_correlated= MY_TEST(having->used_tables() & OUTER_REF_TABLE_BIT); tmp_having= having; - if ((select_lex->options & OPTION_SCHEMA_TABLE) && - optimize_schema_tables_reads(this)) - DBUG_RETURN(TRUE); - if (unlikely(thd->is_error())) DBUG_RETURN(TRUE); @@ -17138,15 +17138,11 @@ Field *Item::create_field_for_schema(THD *thd, TABLE *table) { Field *field; if (max_length > MAX_FIELD_VARCHARLENGTH) - field= new (thd->mem_root) Field_blob(max_length, maybe_null, &name, - collation.collation); - else if (max_length > 0) - field= new (thd->mem_root) Field_varstring(max_length, maybe_null, &name, - table->s, - collation.collation); - else - field= new Field_null((uchar*) 0, 0, Field::NONE, &name, + field= new Field_blob(max_length, maybe_null, &name, collation.collation); + else + field= new Field_varstring(max_length, maybe_null, &name, + table->s, collation.collation); if (field) field->init(table); return field; -- cgit v1.2.1