From 44fd241a22448f35b00249db567d529a8ae78e7c Mon Sep 17 00:00:00 2001 From: Annamalai Gurusami Date: Wed, 17 Sep 2014 10:42:31 +0530 Subject: Bug #17852083 PRINT A WARNING WHEN DDL HAS AN ERROR IN INNODB_STRICT_MODE = 1 Problem: Creation of a table fails when innodb_strict_mode is enabled, but the same table is created without any warning when innodb_strict_mode is enabled. Solution: If creation of a table fails with an error when innodb_strict_mode is enabled, it must issue a warning when innodb_strict_mode is disabled. rb#6723 approved by Krunal. --- storage/innobase/dict/dict0dict.c | 21 +++++++++++++++++---- storage/innobase/handler/ha_innodb.cc | 27 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) (limited to 'storage') diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index 0e4691658d5..2bf774ad039 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -42,6 +42,12 @@ UNIV_INTERN dict_index_t* dict_ind_compact; UNIV_INTERN uint ibuf_debug; #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ +/********************************************************************** +Issue a warning that the row is too big. */ +void +ib_warn_row_too_big(const dict_table_t* table); + + #ifndef UNIV_HOTBACKUP #include "buf0buf.h" #include "data0type.h" @@ -1765,11 +1771,18 @@ dict_index_add_to_cache( new_index->n_fields = new_index->n_def; - if (strict && dict_index_too_big_for_tree(table, new_index)) { + if (dict_index_too_big_for_tree(table, new_index)) { + + if (strict) { too_big: - dict_mem_index_free(new_index); - dict_mem_index_free(index); - return(DB_TOO_BIG_RECORD); + dict_mem_index_free(new_index); + dict_mem_index_free(index); + return(DB_TOO_BIG_RECORD); + } else { + + ib_warn_row_too_big(table); + + } } if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) { diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8f299aed213..28f7c95d243 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -12063,3 +12063,30 @@ innobase_convert_to_filename_charset( return(strconvert(cs_from, from, cs_to, to, len, &errors)); } + + +/********************************************************************** +Issue a warning that the row is too big. */ +extern "C" +void +ib_warn_row_too_big(const dict_table_t* table) +{ + /* If prefix is true then a 768-byte prefix is stored + locally for BLOB fields. Refer to dict_table_get_format() */ + const bool prefix = ((table->flags & DICT_TF_FORMAT_MASK) + >> DICT_TF_FORMAT_SHIFT) < UNIV_FORMAT_B; + + const ulint free_space = page_get_free_space_of_empty( + table->flags & DICT_TF_COMPACT) / 2; + + THD* thd = current_thd; + + push_warning_printf( + thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_ERR_TO_BIG_ROW, + "Row size too large (> %lu). Changing some columns to TEXT" + " or BLOB %smay help. In current row format, BLOB prefix of" + " %d bytes is stored inline.", free_space + , prefix ? "or using ROW_FORMAT=DYNAMIC or" + " ROW_FORMAT=COMPRESSED ": "" + , prefix ? DICT_MAX_FIXED_COL_LEN : 0); +} -- cgit v1.2.1