From: Alex Ivanov Date: December 13 2005 1:49pm Subject: bk commit into 5.1 tree (aivanov:1.1971) List-Archive: http://lists.mysql.com/commits/109 Message-Id: <20051213134949.5966233FF91@mysql.creware.com> Below is the list of changes that have just been committed into a local 5.1 repository of alexi. When alexi does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.1971 05/12/13 16:49:24 aivanov@stripped +15 -0 Changes from the innodb-5.1-ss28 snapshot. Removed include/Makefile.am and the reference to it. Deleted db/db0err.h and db directory. Check index column sizes in a better way (bug 13315). Fixed comments for memory allocation functions and added some extra checks. Adapted callers. storage/innobase/mem/mem0mem.c 1.12 05/12/13 16:49:01 aivanov@stripped +9 -7 Changes from the innodb-5.1-ss28 snapshot. storage/innobase/lock/lock0lock.c 1.63 05/12/13 16:49:01 aivanov@stripped +3 -15 Changes from the innodb-5.1-ss28 snapshot. storage/innobase/include/mem0mem.ic 1.15 05/12/13 16:49:01 aivanov@stripped +21 -24 Changes from the innodb-5.1-ss28 snapshot. storage/innobase/include/mem0mem.h 1.14 05/12/13 16:49:01 aivanov@stripped +21 -17 Changes from the innodb-5.1-ss28 snapshot. storage/innobase/include/ha0ha.ic 1.9 05/12/13 16:49:00 aivanov@stripped +0 -27 Changes from the innodb-5.1-ss28 snapshot. storage/innobase/include/ha0ha.h 1.9 05/12/13 16:49:00 aivanov@stripped +0 -15 Changes from the innodb-5.1-ss28 snapshot. storage/innobase/ha/ha0ha.c 1.17 05/12/13 16:49:00 aivanov@stripped +5 -0 Changes from the innodb-5.1-ss28 snapshot. storage/innobase/configure.in 1.33 05/12/13 16:49:00 aivanov@stripped +1 -1 Changes from the innodb-5.1-ss28 snapshot. storage/innobase/Makefile.am 1.8 05/12/13 16:48:59 aivanov@stripped +1 -1 Changes from the innodb-5.1-ss28 snapshot. sql/ha_innodb.h 1.112 05/12/13 16:48:59 aivanov@stripped +1 -1 Changes from the innodb-5.1-ss28 snapshot. sql/ha_innodb.cc 1.242 05/12/13 16:48:59 aivanov@stripped +9 -0 Changes from the innodb-5.1-ss28 snapshot. mysql-test/t/innodb.test 1.120 05/12/13 16:48:57 aivanov@stripped +26 -12 Changes from the innodb-5.1-ss28 snapshot. mysql-test/r/innodb.result 1.151 05/12/13 16:48:57 aivanov@stripped +40 -11 Changes from the innodb-5.1-ss28 snapshot. BitKeeper/deleted/.del-db0err.h~bfeec2efe86ac48b 1.3 05/12/11 19:54:34 aivanov@stripped +0 -0 Delete: storage/innobase/db/db0err.h BitKeeper/deleted/.del-Makefile.am~ab5c84d46412dc2e 1.14 05/12/11 19:51:46 aivanov@stripped +0 -0 Delete: storage/innobase/include/Makefile.am # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: aivanov # Host: mysql.creware.com # Root: /home/alexi/innodb-ss/mysql-5.1-ss28 --- 1.7/storage/innobase/Makefile.am 2005-04-08 03:37:30 +04:00 +++ 1.8/storage/innobase/Makefile.am 2005-12-13 16:48:59 +03:00 @@ -23,7 +23,7 @@ noinst_HEADERS = ib_config.h SUBDIRS = os ut btr buf data dict dyn eval fil fsp fut \ - ha ibuf include lock log mach mem mtr page \ + ha ibuf lock log mach mem mtr page \ pars que read rem row srv sync thr trx usr # Don't update the files from bitkeeper --- 1.32/storage/innobase/configure.in 2005-07-12 21:23:29 +04:00 +++ 1.33/storage/innobase/configure.in 2005-12-13 16:49:00 +03:00 @@ -128,7 +128,7 @@ buf/Makefile data/Makefile dnl dict/Makefile dyn/Makefile dnl eval/Makefile fil/Makefile fsp/Makefile fut/Makefile dnl - ha/Makefile ibuf/Makefile include/Makefile dnl + ha/Makefile ibuf/Makefile dnl lock/Makefile log/Makefile dnl mach/Makefile mem/Makefile mtr/Makefile dnl page/Makefile pars/Makefile que/Makefile dnl --- 1.16/storage/innobase/ha/ha0ha.c 2005-04-08 03:37:31 +04:00 +++ 1.17/storage/innobase/ha/ha0ha.c 2005-12-13 16:49:00 +03:00 @@ -40,9 +40,13 @@ table->adaptive = FALSE; } + /* Creating MEM_HEAP_BTR_SEARCH type heaps can potentially fail, + but in practise it never should in this case, hence the asserts. */ + if (n_mutexes == 0) { if (in_btr_search) { table->heap = mem_heap_create_in_btr_search(4096); + ut_a(table->heap); } else { table->heap = mem_heap_create_in_buffer(4096); } @@ -57,6 +61,7 @@ for (i = 0; i < n_mutexes; i++) { if (in_btr_search) { table->heaps[i] = mem_heap_create_in_btr_search(4096); + ut_a(table->heaps[i]); } else { table->heaps[i] = mem_heap_create_in_buffer(4096); } --- 1.8/storage/innobase/include/ha0ha.h 2005-04-08 03:37:32 +04:00 +++ 1.9/storage/innobase/include/ha0ha.h 2005-12-13 16:49:00 +03:00 @@ -68,21 +68,6 @@ node is created! */ void* data); /* in: data, must not be NULL */ /***************************************************************** -Reserves the necessary hash table mutex and inserts an entry into the hash -table. */ -UNIV_INLINE -ibool -ha_insert_for_fold_mutex( -/*=====================*/ - /* out: TRUE if succeed, FALSE if no more - memory could be allocated */ - hash_table_t* table, /* in: hash table */ - ulint fold, /* in: folded value of data; if a node with - the same fold value already exists, it is - updated to point to the same data, and no new - node is created! */ - void* data); /* in: data, must not be NULL */ -/***************************************************************** Deletes an entry from a hash table. */ void --- 1.8/storage/innobase/include/ha0ha.ic 2005-04-08 03:37:32 +04:00 +++ 1.9/storage/innobase/include/ha0ha.ic 2005-12-13 16:49:00 +03:00 @@ -191,30 +191,3 @@ return(FALSE); } - -/***************************************************************** -Reserves the necessary hash table mutex and inserts an entry into the hash -table. */ -UNIV_INLINE -ibool -ha_insert_for_fold_mutex( -/*=====================*/ - /* out: TRUE if succeed, FALSE if no more - memory could be allocated */ - hash_table_t* table, /* in: hash table */ - ulint fold, /* in: folded value of data; if a node with - the same fold value already exists, it is - updated to point to the same data, and no new - node is created! */ - void* data) /* in: data, must not be NULL */ -{ - ibool ret; - - hash_mutex_enter(table, fold); - - ret = ha_insert_for_fold(table, fold, data); - - hash_mutex_exit(table, fold); - - return(ret); -} --- 1.13/storage/innobase/include/mem0mem.h 2005-10-06 12:26:04 +04:00 +++ 1.14/storage/innobase/include/mem0mem.h 2005-12-13 16:49:01 +03:00 @@ -31,13 +31,18 @@ typedef mem_block_t mem_heap_t; /* Types of allocation for memory heaps: DYNAMIC means allocation from the -dynamic memory pool of the C compiler, BUFFER means allocation from the index -page buffer pool; the latter method is used for very big heaps */ +dynamic memory pool of the C compiler, BUFFER means allocation from the +buffer pool; the latter method is used for very big heaps */ #define MEM_HEAP_DYNAMIC 0 /* the most common type */ #define MEM_HEAP_BUFFER 1 -#define MEM_HEAP_BTR_SEARCH 2 /* this flag can be ORed to the - previous */ +#define MEM_HEAP_BTR_SEARCH 2 /* this flag can optionally be + ORed to MEM_HEAP_BUFFER, in which + case heap->free_block is used in + some cases for memory allocations, + and if it's NULL, the memory + allocation functions can return + NULL. */ /* The following start size is used for the first block in the memory heap if the size is not specified, i.e., 0 is given as the parameter in the call of @@ -98,13 +103,15 @@ (heap), __FILE__, __LINE__) /********************************************************************* NOTE: Use the corresponding macros instead of this function. Creates a -memory heap which allocates memory from dynamic space. For debugging -purposes, takes also the file name and line as argument. */ +memory heap. For debugging purposes, takes also the file name and line as +arguments. */ UNIV_INLINE mem_heap_t* mem_heap_create_func( /*=================*/ - /* out, own: memory heap */ + /* out, own: memory heap, NULL if + did not succeed (only possible for + MEM_HEAP_BTR_SEARCH type heaps)*/ ulint n, /* in: desired start block size, this means that a single user buffer of size n will fit in the block, @@ -121,11 +128,9 @@ block is not unintentionally erased (if allocated in the stack), before the memory heap is explicitly freed. */ - ulint type, /* in: MEM_HEAP_DYNAMIC - or MEM_HEAP_BUFFER */ + ulint type, /* in: heap type */ const char* file_name, /* in: file name where created */ - ulint line /* in: line where created */ - ); + ulint line); /* in: line where created */ /********************************************************************* NOTE: Use the corresponding macro instead of this function. Frees the space occupied by a memory heap. In the debug version erases the heap memory @@ -143,8 +148,9 @@ void* mem_heap_alloc( /*===========*/ - /* out: allocated storage, NULL if - did not succeed */ + /* out: allocated storage, NULL if did not + succeed (only possible for + MEM_HEAP_BTR_SEARCH type heaps) */ mem_heap_t* heap, /* in: memory heap */ ulint n); /* in: number of bytes; if the heap is allowed to grow into the buffer pool, this must be @@ -220,8 +226,7 @@ void* mem_alloc_func( /*===========*/ - /* out, own: free storage, NULL - if did not succeed */ + /* out, own: free storage */ ulint n, /* in: desired number of bytes */ const char* file_name, /* in: file name where created */ ulint line /* in: line where created */ @@ -235,8 +240,7 @@ void* mem_alloc_func_noninline( /*=====================*/ - /* out, own: free storage, - NULL if did not succeed */ + /* out, own: free storage */ ulint n, /* in: desired number of bytes */ const char* file_name, /* in: file name where created */ ulint line /* in: line where created */ --- 1.14/storage/innobase/include/mem0mem.ic 2005-10-06 12:26:04 +04:00 +++ 1.15/storage/innobase/include/mem0mem.ic 2005-12-13 16:49:01 +03:00 @@ -16,8 +16,9 @@ mem_block_t* mem_heap_create_block( /*==================*/ - /* out, own: memory heap block, - NULL if did not succeed */ + /* out, own: memory heap block, NULL if + did not succeed (only possible for + MEM_HEAP_BTR_SEARCH type heaps) */ mem_heap_t* heap, /* in: memory heap or NULL if first block should be created */ ulint n, /* in: number of bytes needed for user data, or @@ -50,7 +51,8 @@ mem_heap_add_block( /*===============*/ /* out: created block, NULL if did not - succeed */ + succeed (only possible for + MEM_HEAP_BTR_SEARCH type heaps)*/ mem_heap_t* heap, /* in: memory heap */ ulint n); /* in: number of bytes user needs */ @@ -126,7 +128,9 @@ void* mem_heap_alloc( /*===========*/ - /* out: allocated storage */ + /* out: allocated storage, NULL if did not + succeed (only possible for + MEM_HEAP_BTR_SEARCH type heaps) */ mem_heap_t* heap, /* in: memory heap */ ulint n) /* in: number of bytes; if the heap is allowed to grow into the buffer pool, this must be @@ -370,13 +374,15 @@ /********************************************************************* NOTE: Use the corresponding macros instead of this function. Creates a -memory heap which allocates memory from dynamic space. For debugging -purposes, takes also the file name and line as argument. */ +memory heap. For debugging purposes, takes also the file name and line as +argument. */ UNIV_INLINE mem_heap_t* mem_heap_create_func( /*=================*/ - /* out, own: memory heap */ + /* out, own: memory heap, NULL if + did not succeed (only possible for + MEM_HEAP_BTR_SEARCH type heaps)*/ ulint n, /* in: desired start block size, this means that a single user buffer of size n will fit in the block, @@ -393,11 +399,9 @@ block is not unintentionally erased (if allocated in the stack), before the memory heap is explicitly freed. */ - ulint type, /* in: MEM_HEAP_DYNAMIC - or MEM_HEAP_BUFFER */ + ulint type, /* in: heap type */ const char* file_name, /* in: file name where created */ - ulint line /* in: line where created */ - ) + ulint line) /* in: line where created */ { mem_block_t* block; @@ -409,8 +413,11 @@ init_block, type, file_name, line); } - ut_ad(block); - + if (block == NULL) { + + return(NULL); + } + UT_LIST_INIT(block->base); /* Add the created block itself as the first block in the list */ @@ -418,11 +425,6 @@ #ifdef UNIV_MEM_DEBUG - if (block == NULL) { - - return(block); - } - mem_hash_insert(block, file_name, line); #endif @@ -484,8 +486,7 @@ void* mem_alloc_func( /*===========*/ - /* out, own: free storage, NULL - if did not succeed */ + /* out, own: free storage */ ulint n, /* in: desired number of bytes */ const char* file_name, /* in: file name where created */ ulint line /* in: line where created */ @@ -496,11 +497,7 @@ heap = mem_heap_create_func(n, NULL, MEM_HEAP_DYNAMIC, file_name, line); - if (heap == NULL) { - return(NULL); - } - /* Note that as we created the first block in the heap big enough for the buffer requested by the caller, the buffer will be in the first block and thus we can calculate the pointer to the heap from --- 1.62/storage/innobase/lock/lock0lock.c 2005-09-03 03:06:55 +04:00 +++ 1.63/storage/innobase/lock/lock0lock.c 2005-12-13 16:49:01 +03:00 @@ -1705,7 +1705,7 @@ lock_t* lock_rec_create( /*============*/ - /* out: created lock, NULL if out of memory */ + /* out: created lock */ ulint type_mode,/* in: lock mode and wait flag, type is ignored and replaced by LOCK_REC */ rec_t* rec, /* in: record on page */ @@ -1746,11 +1746,6 @@ n_bytes = 1 + n_bits / 8; lock = mem_heap_alloc(trx->lock_heap, sizeof(lock_t) + n_bytes); - - if (UNIV_UNLIKELY(lock == NULL)) { - - return(NULL); - } UT_LIST_ADD_LAST(trx_locks, trx->trx_locks, lock); @@ -1886,8 +1881,7 @@ lock_t* lock_rec_add_to_queue( /*==================*/ - /* out: lock where the bit was set, NULL if out - of memory */ + /* out: lock where the bit was set */ ulint type_mode,/* in: lock mode, wait, gap etc. flags; type is ignored and replaced by LOCK_REC */ rec_t* rec, /* in: record on page */ @@ -3405,8 +3399,7 @@ lock_t* lock_table_create( /*==============*/ - /* out, own: new lock object, or NULL if - out of memory */ + /* out, own: new lock object */ dict_table_t* table, /* in: database table in dictionary cache */ ulint type_mode,/* in: lock mode possibly ORed with LOCK_WAIT */ @@ -3430,11 +3423,6 @@ trx->auto_inc_lock = lock; } else { lock = mem_heap_alloc(trx->lock_heap, sizeof(lock_t)); - } - - if (lock == NULL) { - - return(NULL); } UT_LIST_ADD_LAST(trx_locks, trx->trx_locks, lock); --- 1.11/storage/innobase/mem/mem0mem.c 2005-10-06 12:26:04 +04:00 +++ 1.12/storage/innobase/mem/mem0mem.c 2005-12-13 16:49:01 +03:00 @@ -92,12 +92,10 @@ void* mem_alloc_func_noninline( /*=====================*/ - /* out, own: free storage, - NULL if did not succeed */ + /* out, own: free storage */ ulint n, /* in: desired number of bytes */ const char* file_name, /* in: file name where created */ - ulint line /* in: line where created */ - ) + ulint line) /* in: line where created */ { return(mem_alloc_func(n, file_name, line)); } @@ -122,8 +120,9 @@ mem_block_t* mem_heap_create_block( /*==================*/ - /* out, own: memory heap block, - NULL if did not succeed */ + /* out, own: memory heap block, NULL if + did not succeed (only possible for + MEM_HEAP_BTR_SEARCH type heaps) */ mem_heap_t* heap, /* in: memory heap or NULL if first block should be created */ ulint n, /* in: number of bytes needed for user data, or @@ -182,6 +181,8 @@ } if (block == NULL) { + /* Only MEM_HEAP_BTR_SEARCH allocation should ever fail. */ + ut_a(type & MEM_HEAP_BTR_SEARCH); return(NULL); } @@ -222,7 +223,8 @@ mem_heap_add_block( /*===============*/ /* out: created block, NULL if did not - succeed */ + succeed (only possible for + MEM_HEAP_BTR_SEARCH type heaps)*/ mem_heap_t* heap, /* in: memory heap */ ulint n) /* in: number of bytes user needs */ { --- 1.150/mysql-test/r/innodb.result 2005-12-08 15:00:07 +03:00 +++ 1.151/mysql-test/r/innodb.result 2005-12-13 16:48:57 +03:00 @@ -2437,7 +2437,9 @@ 20 NULL drop table t1; create table t1 (v varchar(65530), key(v)); -ERROR HY000: Can't create table 'test.t1' (errno: 139) +Warnings: +Warning 1071 Specified key was too long; max key length is 767 bytes +drop table t1; create table t1 (v varchar(65536)); Warnings: Note 1246 Converting column 'v' from VARCHAR to TEXT @@ -2577,22 +2579,49 @@ character set = latin1 engine = innodb; create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2)) character set = latin1 engine = innodb; +show create table t9; +Table Create Table +t9 CREATE TABLE `t9` ( + `col1` varchar(512) default NULL, + `col2` varchar(512) default NULL, + KEY `col1` (`col1`,`col2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1, t2, t3, t4, t5, t6, t7, t8, t9; -create table t1 (col1 varchar(768), index (col1)) +create table t1 (col1 varchar(768), index(col1)) +character set = latin1 engine = innodb; +Warnings: +Warning 1071 Specified key was too long; max key length is 767 bytes +create table t2 (col1 varbinary(768), index(col1)) +character set = latin1 engine = innodb; +Warnings: +Warning 1071 Specified key was too long; max key length is 767 bytes +create table t3 (col1 text, index(col1(768))) character set = latin1 engine = innodb; -ERROR HY000: Can't create table 'test.t1' (errno: 139) -create table t2 (col1 varchar(768) primary key) +Warnings: +Warning 1071 Specified key was too long; max key length is 767 bytes +create table t4 (col1 blob, index(col1(768))) +character set = latin1 engine = innodb; +Warnings: +Warning 1071 Specified key was too long; max key length is 767 bytes +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `col1` varchar(768) default NULL, + KEY `col1` (`col1`(767)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1, t2, t3, t4; +create table t1 (col1 varchar(768) primary key) character set = latin1 engine = innodb; -ERROR HY000: Can't create table 'test.t2' (errno: 139) -create table t3 (col1 varbinary(768) primary key) +ERROR 42000: Specified key was too long; max key length is 767 bytes +create table t2 (col1 varbinary(768) primary key) character set = latin1 engine = innodb; -ERROR HY000: Can't create table 'test.t3' (errno: 139) -create table t4 (col1 text, index(col1(768))) +ERROR 42000: Specified key was too long; max key length is 767 bytes +create table t3 (col1 text, primary key(col1(768))) character set = latin1 engine = innodb; -ERROR HY000: Can't create table 'test.t4' (errno: 139) -create table t5 (col1 blob, index(col1(768))) +ERROR 42000: Specified key was too long; max key length is 767 bytes +create table t4 (col1 blob, primary key(col1(768))) character set = latin1 engine = innodb; -ERROR HY000: Can't create table 'test.t5' (errno: 139) +ERROR 42000: Specified key was too long; max key length is 767 bytes CREATE TABLE t1 ( id INT PRIMARY KEY --- 1.119/mysql-test/t/innodb.test 2005-12-08 15:00:08 +03:00 +++ 1.120/mysql-test/t/innodb.test 2005-12-13 16:48:57 +03:00 @@ -1356,8 +1356,8 @@ # Clean up filename -- embedded server reports whole path without .frm, # regular server reports relative path with .frm (argh!) --replace_result \\ / $MYSQL_TEST_DIR . /var/master-data/ / t1.frm t1 ---error 1005 create table t1 (v varchar(65530), key(v)); +drop table t1; create table t1 (v varchar(65536)); show create table t1; drop table t1; @@ -1485,7 +1485,7 @@ DROP TABLE t1; # -# Test that index column max sizes are checked (bug #13315) +# Test that index column max sizes are honored (bug #13315) # # prefix index @@ -1512,22 +1512,36 @@ create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2)) character set = latin1 engine = innodb; +show create table t9; + drop table t1, t2, t3, t4, t5, t6, t7, t8, t9; ---error 1005 -create table t1 (col1 varchar(768), index (col1)) +# these should have their index length trimmed +create table t1 (col1 varchar(768), index(col1)) + character set = latin1 engine = innodb; +create table t2 (col1 varbinary(768), index(col1)) + character set = latin1 engine = innodb; +create table t3 (col1 text, index(col1(768))) + character set = latin1 engine = innodb; +create table t4 (col1 blob, index(col1(768))) character set = latin1 engine = innodb; ---error 1005 -create table t2 (col1 varchar(768) primary key) + +show create table t1; + +drop table t1, t2, t3, t4; + +# these should be refused +--error 1071 +create table t1 (col1 varchar(768) primary key) character set = latin1 engine = innodb; ---error 1005 -create table t3 (col1 varbinary(768) primary key) +--error 1071 +create table t2 (col1 varbinary(768) primary key) character set = latin1 engine = innodb; ---error 1005 -create table t4 (col1 text, index(col1(768))) +--error 1071 +create table t3 (col1 text, primary key(col1(768))) character set = latin1 engine = innodb; ---error 1005 -create table t5 (col1 blob, index(col1(768))) +--error 1071 +create table t4 (col1 blob, primary key(col1(768))) character set = latin1 engine = innodb; # --- 1.241/sql/ha_innodb.cc 2005-12-08 15:00:08 +03:00 +++ 1.242/sql/ha_innodb.cc 2005-12-13 16:48:59 +03:00 @@ -2540,6 +2540,12 @@ DBUG_RETURN(0); } +uint +ha_innobase::max_supported_key_part_length() const +{ + return(DICT_MAX_INDEX_COL_LEN - 1); +} + /********************************************************************** Closes a handle to an InnoDB table. */ @@ -4698,6 +4704,9 @@ 0, prefix_len); } + /* Even though we've defined max_supported_key_part_length, we + still do our own checking using field_lengths to be absolutely + sure we don't create too long indexes. */ error = row_create_index_for_mysql(index, trx, field_lengths); error = convert_error_code_to_mysql(error, NULL); --- 1.111/sql/ha_innodb.h 2005-12-08 15:00:08 +03:00 +++ 1.112/sql/ha_innodb.h 2005-12-13 16:48:59 +03:00 @@ -110,7 +110,7 @@ but currently MySQL does not work with keys whose size is > MAX_KEY_LENGTH */ uint max_supported_key_length() const { return 3500; } - uint max_supported_key_part_length() const { return 3500; } + uint max_supported_key_part_length() const; const key_map *keys_to_use_for_scanning() { return &key_map_full; } bool has_transactions() { return 1;}