From b4c28de045a72236c9a13a6cbe6eb0e7ffca4305 Mon Sep 17 00:00:00 2001 From: marko Date: Thu, 20 Nov 2008 10:22:40 +0000 Subject: [PATCH] branches/zip: Always check for "row too large" when executing SQL to create an index or table. We have to skip this check when loading table definitions from the data dictionary, because we could otherwise refuse to load old tables (even uncompressed ones). This addresses Issue #119. The first "row too large" check was implemented in MySQL 5.0.3 to address MySQL Bug #5682. In the InnoDB Plugin 1.0.2, a more accurate check was implemented in innodb_strict_mode. We now make the check unconditional. dict_create_index_step(): Pass strict=TRUE to dict_index_add_to_cache(). trx_is_strict(), thd_is_strict(): Remove. innodb-zip.test: Test in innodb_strict_mode=OFF. innodb_bug36169.test: Ensure that none of the tables can be created. rb://56 approved by Sunny Bains. --- dict/dict0crea.c | 2 +- handler/ha_innodb.cc | 12 ------------ include/ha_prototypes.h | 9 --------- include/trx0trx.h | 9 --------- mysql-test/innodb-zip.result | 2 +- mysql-test/innodb-zip.test | 3 ++- mysql-test/innodb_bug36169.test | 7 +++++++ trx/trx0trx.c | 16 ---------------- 8 files changed, 11 insertions(+), 49 deletions(-) diff --git a/dict/dict0crea.c b/dict/dict0crea.c index d4b3b3ae124..243cdbc03d5 100644 --- a/dict/dict0crea.c +++ b/dict/dict0crea.c @@ -1079,7 +1079,7 @@ dict_create_index_step( dulint index_id = node->index->id; err = dict_index_add_to_cache(node->table, node->index, - FIL_NULL, trx_is_strict(trx)); + FIL_NULL, TRUE); node->index = dict_index_get_if_in_cache_low(index_id); ut_a(!node->index == (err != DB_SUCCESS)); diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc index b6fe4c0a098..6beb0eb0ab4 100644 --- a/handler/ha_innodb.cc +++ b/handler/ha_innodb.cc @@ -621,18 +621,6 @@ thd_supports_xa( return(THDVAR((THD*) thd, support_xa)); } -/********************************************************************** -Returns true if the thread is executing in innodb_strict_mode. */ -extern "C" UNIV_INTERN -ibool -thd_is_strict( -/*==========*/ - /* out: true if thd is in strict mode */ - void* thd) /* in: thread handle (THD*) */ -{ - return(THDVAR((THD*) thd, strict_mode)); -} - /********************************************************************** Returns the lock wait timeout for the current connection. */ extern "C" UNIV_INTERN diff --git a/include/ha_prototypes.h b/include/ha_prototypes.h index 8fbb864f3d9..7c46c4de767 100644 --- a/include/ha_prototypes.h +++ b/include/ha_prototypes.h @@ -217,15 +217,6 @@ thd_supports_xa( void* thd); /* in: thread handle (THD*), or NULL to query the global innodb_supports_xa */ -/********************************************************************** -Returns true if the thread is executing in innodb_strict_mode. */ - -ibool -thd_is_strict( -/*==========*/ - /* out: true if thd is in strict mode */ - void* thd); /* in: thread handle (THD*) */ - /********************************************************************** Returns the lock wait timeout for the current connection. */ diff --git a/include/trx0trx.h b/include/trx0trx.h index f1bdd9cc979..f45d430f7ad 100644 --- a/include/trx0trx.h +++ b/include/trx0trx.h @@ -407,15 +407,6 @@ trx_is_interrupted( #define trx_is_interrupted(trx) FALSE #endif /* !UNIV_HOTBACKUP */ -/************************************************************************** -Determines if the currently running transaction is in innodb_strict_mode. */ -UNIV_INTERN -ibool -trx_is_strict( -/*==========*/ - /* out: TRUE if strict */ - trx_t* trx); /* in: transaction */ - /*********************************************************************** Calculates the "weight" of a transaction. The weight of one transaction is estimated as the number of altered rows + the number of locked rows. diff --git a/mysql-test/innodb-zip.result b/mysql-test/innodb-zip.result index ccbfb2b7c37..c81401743a5 100644 --- a/mysql-test/innodb-zip.result +++ b/mysql-test/innodb-zip.result @@ -122,7 +122,7 @@ table_schema table_name row_format test t1 Compressed test t2 Compact drop table t1,t2; -SET SESSION innodb_strict_mode = on; +SET SESSION innodb_strict_mode = off; CREATE TABLE t1( c TEXT NOT NULL, d TEXT NOT NULL, PRIMARY KEY (c(767),d(767))) diff --git a/mysql-test/innodb-zip.test b/mysql-test/innodb-zip.test index faa21b6e7b1..b1eb809edaa 100644 --- a/mysql-test/innodb-zip.test +++ b/mysql-test/innodb-zip.test @@ -84,7 +84,8 @@ SELECT table_schema, table_name, row_format FROM information_schema.tables WHERE engine='innodb'; drop table t1,t2; -SET SESSION innodb_strict_mode = on; +# The following should fail even in non-strict mode. +SET SESSION innodb_strict_mode = off; --error ER_TOO_BIG_ROWSIZE CREATE TABLE t1( c TEXT NOT NULL, d TEXT NOT NULL, diff --git a/mysql-test/innodb_bug36169.test b/mysql-test/innodb_bug36169.test index e7375900675..d3566d3eb39 100644 --- a/mysql-test/innodb_bug36169.test +++ b/mysql-test/innodb_bug36169.test @@ -22,6 +22,7 @@ SET GLOBAL innodb_file_per_table=ON; # Generating 10 tables # Creating a table with 94 columns and 24 indexes DROP TABLE IF EXISTS `table0`; +--error ER_TOO_BIG_ROWSIZE CREATE TABLE IF NOT EXISTS `table0` (`col0` BOOL, `col1` BOOL, @@ -145,6 +146,7 @@ KEY `idx23` (`col7`(163),`col31`,`col71`,`col14`) # Creating a table with 10 columns and 32 indexes DROP TABLE IF EXISTS `table1`; +--error ER_TOO_BIG_ROWSIZE CREATE TABLE IF NOT EXISTS `table1` (`col0` CHAR (113), `col1` FLOAT, @@ -192,6 +194,7 @@ KEY `idx31` (`col4`(1),`col0`) # Creating a table with 141 columns and 18 indexes DROP TABLE IF EXISTS `table2`; +--error ER_TOO_BIG_ROWSIZE CREATE TABLE IF NOT EXISTS `table2` (`col0` BOOL, `col1` MEDIUMINT, @@ -356,6 +359,7 @@ KEY `idx17` (`col24`(250),`col7`,`col92`,`col45`) # Creating a table with 199 columns and 1 indexes DROP TABLE IF EXISTS `table3`; +--error ER_TOO_BIG_ROWSIZE CREATE TABLE IF NOT EXISTS `table3` (`col0` SMALLINT, `col1` SET ('test1','test2','test3'), @@ -561,6 +565,7 @@ KEY `idx0` (`col39`,`col23`) # Creating a table with 133 columns and 16 indexes DROP TABLE IF EXISTS `table4`; +--error ER_TOO_BIG_ROWSIZE CREATE TABLE IF NOT EXISTS `table4` (`col0` VARCHAR (60), `col1` NUMERIC, @@ -715,6 +720,7 @@ KEY `idx15` (`col4`(246),`col130`,`col115`,`col3`(141)) # Creating a table with 176 columns and 13 indexes DROP TABLE IF EXISTS `table5`; +--error ER_TOO_BIG_ROWSIZE CREATE TABLE IF NOT EXISTS `table5` (`col0` MEDIUMTEXT, `col1` VARCHAR (90), @@ -910,6 +916,7 @@ KEY `idx12` (`col24`) # Creating a table with 179 columns and 46 indexes DROP TABLE IF EXISTS `table6`; -- error ER_TOO_BIG_ROWSIZE +--error ER_TOO_BIG_ROWSIZE CREATE TABLE IF NOT EXISTS `table6` (`col0` ENUM ('test1','test2','test3'), `col1` MEDIUMBLOB, diff --git a/trx/trx0trx.c b/trx/trx0trx.c index 821df266866..e529f460fb3 100644 --- a/trx/trx0trx.c +++ b/trx/trx0trx.c @@ -34,22 +34,6 @@ UNIV_INTERN sess_t* trx_dummy_sess = NULL; the kernel mutex */ UNIV_INTERN ulint trx_n_mysql_transactions = 0; -/************************************************************************** -Determines if the currently running transaction is in innodb_strict_mode. */ -UNIV_INTERN -ibool -trx_is_strict( -/*==========*/ - /* out: TRUE if strict */ - trx_t* trx) /* in: transaction */ -{ -#ifndef UNIV_HOTBACKUP - return(trx && trx->mysql_thd && thd_is_strict(trx->mysql_thd)); -#else /* UNIV_HOTBACKUP */ - return(FALSE); -#endif /* UNIV_HOTBACKUP */ -} - /***************************************************************** Set detailed error message for the transaction. */ UNIV_INTERN