Commit 0bf7f4bd authored by marko's avatar marko

branches/zip: Merge revisions 9:72 from trunk.

parent 541fcfcd
......@@ -23,7 +23,7 @@ TAR = gtar
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
......
......@@ -889,7 +889,8 @@ Drops a page hash index. */
void
btr_search_drop_page_hash_index(
/*============================*/
page_t* page) /* in: index page, s- or x-latched */
page_t* page) /* in: index page, s- or x-latched, or an index page
for which we know that block->buf_fix_count == 0 */
{
hash_table_t* table;
buf_block_t* block;
......@@ -904,6 +905,7 @@ btr_search_drop_page_hash_index(
ulint* folds;
ulint i;
mem_heap_t* heap;
dict_index_t* index;
ulint* offsets;
#ifdef UNIV_SYNC_DEBUG
......@@ -932,11 +934,16 @@ btr_search_drop_page_hash_index(
n_fields = block->curr_n_fields;
n_bytes = block->curr_n_bytes;
index = block->index;
ut_a(n_fields + n_bytes > 0);
/* NOTE: The fields of block must not be accessed after
releasing btr_search_latch, as the index page might only
be s-latched! */
rw_lock_s_unlock(&btr_search_latch);
ut_a(n_fields + n_bytes > 0);
n_recs = page_get_n_recs(page);
/* Calculate and cache fold values into an array for fast deletion
......@@ -949,14 +956,6 @@ btr_search_drop_page_hash_index(
rec = page_get_infimum_rec(page);
rec = page_rec_get_next(rec);
if (!page_rec_is_supremum(rec)) {
ut_a(n_fields <= rec_get_n_fields(rec, block->index));
if (n_bytes > 0) {
ut_a(n_fields < rec_get_n_fields(rec, block->index));
}
}
tree_id = btr_page_get_index_id(page);
prev_fold = 0;
......@@ -964,18 +963,12 @@ btr_search_drop_page_hash_index(
heap = NULL;
offsets = NULL;
if (block->index == NULL) {
mem_analyze_corruption((byte*)block);
ut_a(block->index != NULL);
}
while (!page_rec_is_supremum(rec)) {
/* FIXME: in a mixed tree, not all records may have enough
ordering fields: */
offsets = rec_get_offsets(rec, block->index,
offsets, n_fields + (n_bytes > 0), &heap);
offsets = rec_get_offsets(rec, index, offsets,
n_fields + (n_bytes > 0), &heap);
ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id);
if (fold == prev_fold && prev_fold != 0) {
......
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh" $@ --with-debug=full
extra_flags="$pentium_cflags $debug_cflags"
c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$pentium_configs $debug_configs "
extra_configs="$extra_configs --with-innodb"
. "$path/FINISH.sh"
......@@ -128,7 +128,7 @@ AC_OUTPUT(Makefile os/Makefile ut/Makefile btr/Makefile dnl
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
......
/******************************************************
Global error codes for the database
(c) 1996 Innobase Oy
Created 5/24/1996 Heikki Tuuri
*******************************************************/
#ifndef db0err_h
#define db0err_h
#define DB_SUCCESS 10
/* The following are error codes */
#define DB_ERROR 11
#define DB_OUT_OF_MEMORY 12
#define DB_OUT_OF_FILE_SPACE 13
#define DB_LOCK_WAIT 14
#define DB_DEADLOCK 15
#define DB_ROLLBACK 16
#define DB_DUPLICATE_KEY 17
#define DB_QUE_THR_SUSPENDED 18
#define DB_MISSING_HISTORY 19 /* required history data has been
deleted due to lack of space in
rollback segment */
#define DB_CLUSTER_NOT_FOUND 30
#define DB_TABLE_NOT_FOUND 31
#define DB_MUST_GET_MORE_FILE_SPACE 32 /* the database has to be stopped
and restrated with more file space */
#define DB_TABLE_IS_BEING_USED 33
#define DB_TOO_BIG_RECORD 34 /* a record in an index would become
bigger than 1/2 free space in a page
frame */
/* The following are partial failure codes */
#define DB_FAIL 1000
#define DB_OVERFLOW 1001
#define DB_UNDERFLOW 1002
#define DB_STRONG_FAIL 1003
#define DB_RECORD_NOT_FOUND 1500
#define DB_END_OF_INDEX 1501
#endif
......@@ -2104,8 +2104,11 @@ dict_foreign_find_index(
dict_table_t* table, /* in: table */
const char** columns,/* in: array of column names */
ulint n_cols, /* in: number of columns */
dict_index_t* types_idx)/* in: NULL or an index to whose types the
column types must match */
dict_index_t* types_idx, /* in: NULL or an index to whose types the
column types must match */
ibool check_charsets) /* in: whether to check charsets.
only has an effect if types_idx !=
NULL. */
{
#ifndef UNIV_HOTBACKUP
dict_index_t* index;
......@@ -2135,7 +2138,8 @@ dict_foreign_find_index(
if (types_idx && !cmp_types_are_equal(
dict_index_get_nth_type(index, i),
dict_index_get_nth_type(types_idx, i))) {
dict_index_get_nth_type(types_idx, i),
check_charsets)) {
break;
}
......@@ -2212,7 +2216,8 @@ dict_foreign_add_to_cache(
/*======================*/
/* out: DB_SUCCESS or error code */
dict_foreign_t* foreign, /* in, own: foreign key constraint */
ibool check_types) /* in: TRUE=check type compatibility */
ibool check_charsets) /* in: TRUE=check charset
compatibility */
{
dict_table_t* for_table;
dict_table_t* ref_table;
......@@ -2248,16 +2253,10 @@ dict_foreign_add_to_cache(
}
if (for_in_cache->referenced_table == NULL && ref_table) {
dict_index_t* types_idx;
if (check_types) {
types_idx = for_in_cache->foreign_index;
} else {
types_idx = NULL;
}
index = dict_foreign_find_index(ref_table,
(const char**) for_in_cache->referenced_col_names,
for_in_cache->n_fields,
types_idx);
for_in_cache->foreign_index, check_charsets);
if (index == NULL) {
dict_foreign_error_report(ef, for_in_cache,
......@@ -2281,16 +2280,10 @@ dict_foreign_add_to_cache(
}
if (for_in_cache->foreign_table == NULL && for_table) {
dict_index_t* types_idx;
if (check_types) {
types_idx = for_in_cache->referenced_index;
} else {
types_idx = NULL;
}
index = dict_foreign_find_index(for_table,
(const char**) for_in_cache->foreign_col_names,
for_in_cache->n_fields,
types_idx);
for_in_cache->referenced_index, check_charsets);
if (index == NULL) {
dict_foreign_error_report(ef, for_in_cache,
......@@ -3097,7 +3090,7 @@ dict_create_foreign_constraints_low(
/* Try to find an index which contains the columns
as the first fields and in the right order */
index = dict_foreign_find_index(table, column_names, i, NULL);
index = dict_foreign_find_index(table, column_names, i, NULL, TRUE);
if (!index) {
mutex_enter(&dict_foreign_err_mutex);
......@@ -3362,8 +3355,7 @@ dict_create_foreign_constraints_low(
if (referenced_table) {
index = dict_foreign_find_index(referenced_table,
column_names, i,
foreign->foreign_index);
column_names, i, foreign->foreign_index, TRUE);
if (!index) {
dict_foreign_free(foreign);
mutex_enter(&dict_foreign_err_mutex);
......
......@@ -1091,7 +1091,7 @@ dict_load_foreign(
/* out: DB_SUCCESS or error code */
const char* id, /* in: foreign constraint id as a
null-terminated string */
ibool check_types)/* in: TRUE=check type compatibility */
ibool check_charsets)/* in: TRUE=check charset compatibility */
{
dict_foreign_t* foreign;
dict_table_t* sys_foreign;
......@@ -1204,7 +1204,7 @@ dict_load_foreign(
a new foreign key constraint but loading one from the data
dictionary. */
return(dict_foreign_add_to_cache(foreign, check_types));
return(dict_foreign_add_to_cache(foreign, check_charsets));
}
/***************************************************************************
......@@ -1219,7 +1219,8 @@ dict_load_foreigns(
/*===============*/
/* out: DB_SUCCESS or error code */
const char* table_name, /* in: table name */
ibool check_types) /* in: TRUE=check type compatibility */
ibool check_charsets) /* in: TRUE=check charset
compatibility */
{
btr_pcur_t pcur;
mem_heap_t* heap;
......@@ -1319,7 +1320,7 @@ dict_load_foreigns(
/* Load the foreign constraint definition to the dictionary cache */
err = dict_load_foreign(id, check_types);
err = dict_load_foreign(id, check_charsets);
if (err != DB_SUCCESS) {
btr_pcur_close(&pcur);
......
......@@ -3,21 +3,29 @@
# export current working directory in a format suitable for sending to
# MySQL as a snapshot.
set -eu
if [ $# -ne 1 ] ; then
echo "Usage: export.sh revision-number-of-last-snapshot"
exit 1
fi
rm -rf to-mysql
svn export . to-mysql
mkdir -p to-mysql/storage/
svn log -v -r "$1:BASE" > to-mysql/log
svn export . to-mysql/storage/innobase
cd to-mysql
mkdir innobase
mv * innobase
mkdir -p sql mysql-test/t mysql-test/r mysql-test/include
cd innobase
cd storage/innobase
mv handler/* ../sql
mv handler/* ../../sql
rmdir handler
mv mysql-test/*.test mysql-test/*.opt ../mysql-test/t
mv mysql-test/*.result ../mysql-test/r
mv mysql-test/*.inc ../mysql-test/include
mv mysql-test/*.test mysql-test/*.opt ../../mysql-test/t
mv mysql-test/*.result ../../mysql-test/r
mv mysql-test/*.inc ../../mysql-test/include
rmdir mysql-test
rm setup.sh export.sh
rm setup.sh export.sh compile-innodb-debug
......@@ -40,9 +40,13 @@ ha_create(
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 @@ ha_create(
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);
}
......
......@@ -141,15 +141,16 @@ uint innobase_init_flags = 0;
ulong innobase_cache_size = 0;
ulong innobase_large_page_size = 0;
/* The default values for the following, type long, start-up parameters
are declared in mysqld.cc: */
/* The default values for the following, type long or longlong, start-up
parameters are declared in mysqld.cc: */
long innobase_mirrored_log_groups, innobase_log_files_in_group,
innobase_log_file_size, innobase_log_buffer_size,
innobase_buffer_pool_awe_mem_mb,
innobase_buffer_pool_size, innobase_additional_mem_pool_size,
innobase_file_io_threads, innobase_lock_wait_timeout,
innobase_force_recovery, innobase_open_files;
innobase_log_buffer_size, innobase_buffer_pool_awe_mem_mb,
innobase_additional_mem_pool_size, innobase_file_io_threads,
innobase_lock_wait_timeout, innobase_force_recovery,
innobase_open_files;
longlong innobase_buffer_pool_size, innobase_log_file_size;
/* The default values for the following char* start-up parameters
are determined in innobase_init below: */
......@@ -1230,6 +1231,25 @@ innobase_init(void)
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
/* Check that values don't overflow on 32-bit systems. */
if (sizeof(ulint) == 4) {
if (innobase_buffer_pool_size > UINT_MAX32) {
sql_print_error(
"innobase_buffer_pool_size can't be over 4GB"
" on 32-bit systems");
DBUG_RETURN(0);
}
if (innobase_log_file_size > UINT_MAX32) {
sql_print_error(
"innobase_log_file_size can't be over 4GB"
" on 32-bit systems");
DBUG_RETURN(0);
}
}
os_innodb_umask = (ulint)my_umask;
/* First calculate the default path for innodb_data_home_dir etc.,
......@@ -2517,6 +2537,12 @@ ha_innobase::open(
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. */
......@@ -4674,6 +4700,9 @@ create_index(
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);
......
......@@ -110,7 +110,7 @@ class ha_innobase: public handler
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;}
......@@ -218,8 +218,9 @@ extern ulong innobase_large_page_size;
extern char *innobase_home, *innobase_tmpdir, *innobase_logdir;
extern long innobase_lock_scan_time;
extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
extern long innobase_log_file_size, innobase_log_buffer_size;
extern long innobase_buffer_pool_size, innobase_additional_mem_pool_size;
extern longlong innobase_buffer_pool_size, innobase_log_file_size;
extern long innobase_log_buffer_size;
extern long innobase_additional_mem_pool_size;
extern long innobase_buffer_pool_awe_mem_mb;
extern long innobase_file_io_threads, innobase_lock_wait_timeout;
extern long innobase_force_recovery;
......
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
# & Innobase Oy
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
noinst_HEADERS = btr0btr.h btr0btr.ic btr0cur.h btr0cur.ic \
btr0pcur.h btr0pcur.ic btr0sea.h btr0sea.ic btr0types.h \
buf0buf.h buf0buf.ic buf0flu.h buf0flu.ic buf0lru.h \
buf0lru.ic buf0rea.h buf0types.h data0data.h data0data.ic data0type.h \
data0type.ic data0types.h db0err.h dict0boot.h \
dict0boot.ic dict0crea.h dict0crea.ic dict0dict.h \
dict0dict.ic dict0load.h dict0load.ic dict0mem.h \
dict0mem.ic dict0types.h dyn0dyn.h dyn0dyn.ic eval0eval.h \
eval0eval.ic eval0proc.h eval0proc.ic fil0fil.h fsp0fsp.h \
fsp0fsp.ic fut0fut.h fut0fut.ic fut0lst.h fut0lst.ic \
ha0ha.h ha0ha.ic hash0hash.h hash0hash.ic \
ibuf0ibuf.h ibuf0ibuf.ic ibuf0types.h lock0lock.h \
lock0lock.ic lock0types.h log0log.h log0log.ic log0recv.h \
log0recv.ic mach0data.h mach0data.ic \
mem0dbg.h mem0dbg.ic mem0mem.h mem0mem.ic mem0pool.h \
mem0pool.ic mtr0log.h mtr0log.ic mtr0mtr.h mtr0mtr.ic \
mtr0types.h os0file.h os0proc.h os0proc.ic \
os0sync.h os0sync.ic os0thread.h \
os0thread.ic page0cur.h page0cur.ic page0page.h \
page0page.ic page0types.h pars0grm.h pars0opt.h \
pars0opt.ic pars0pars.h pars0pars.ic pars0sym.h \
pars0sym.ic pars0types.h que0que.h que0que.ic que0types.h \
read0read.h read0read.ic read0types.h rem0cmp.h \
rem0cmp.ic rem0rec.h rem0rec.ic rem0types.h row0ins.h \
row0ins.ic row0mysql.h row0mysql.ic row0purge.h \
row0purge.ic row0row.h row0row.ic row0sel.h row0sel.ic \
row0types.h row0uins.h row0uins.ic row0umod.h row0umod.ic \
row0undo.h row0undo.ic row0upd.h row0upd.ic row0vers.h \
row0vers.ic srv0que.h srv0srv.h srv0srv.ic srv0start.h \
sync0arr.h sync0arr.ic sync0rw.h \
sync0rw.ic sync0sync.h sync0sync.ic sync0types.h \
thr0loc.h thr0loc.ic trx0purge.h trx0purge.ic trx0rec.h \
trx0rec.ic trx0roll.h trx0roll.ic trx0rseg.h trx0rseg.ic \
trx0sys.h trx0sys.ic trx0trx.h trx0trx.ic trx0types.h \
trx0undo.h trx0undo.ic trx0xa.h univ.i \
usr0sess.h usr0sess.ic usr0types.h ut0byte.h ut0byte.ic \
ut0dbg.h ut0lst.h ut0mem.h ut0mem.ic ut0rnd.h ut0rnd.ic \
ut0sort.h ut0ut.h ut0ut.ic
EXTRA_DIST = Makefile.i
# Don't update the files from bitkeeper
%::SCCS/s.%
......@@ -754,8 +754,6 @@ struct buf_block_struct{
buffer pool which are index pages,
but this flag is not set because
we do not keep track of all pages */
dict_index_t* index; /* index for which the adaptive
hash index has been created */
/* 2. Page flushing fields */
UT_LIST_NODE_T(buf_block_t) flush_list;
......@@ -842,7 +840,13 @@ struct buf_block_struct{
records with the same prefix should be
indexed in the hash index */
/* The following 4 fields are protected by btr_search_latch: */
/* These 6 fields may only be modified when we have
an x-latch on btr_search_latch AND
a) we are holding an s-latch or x-latch on block->lock or
b) we know that block->buf_fix_count == 0.
An exception to this is when we init or create a page
in the buffer pool in buf0buf.c. */
ibool is_hashed; /* TRUE if hash index has already been
built on this page; note that it does
......@@ -860,6 +864,8 @@ struct buf_block_struct{
BTR_SEARCH_RIGHT_SIDE in hash
indexing */
page_zip_des_t page_zip; /* compressed page info */
dict_index_t* index; /* Index for which the adaptive
hash index has been created. */
/* 6. Debug fields */
#ifdef UNIV_SYNC_DEBUG
rw_lock_t debug_latch; /* in the debug version, each thread
......
......@@ -197,7 +197,8 @@ dict_foreign_add_to_cache(
/*======================*/
/* out: DB_SUCCESS or error code */
dict_foreign_t* foreign, /* in, own: foreign key constraint */
ibool check_types); /* in: TRUE=check type compatibility */
ibool check_charsets);/* in: TRUE=check charset
compatibility */
/*************************************************************************
Checks if a table is referenced by foreign keys. */
......
......@@ -82,7 +82,8 @@ dict_load_foreigns(
/*===============*/
/* out: DB_SUCCESS or error code */
const char* table_name, /* in: table name */
ibool check_types); /* in: TRUE=check type compatibility */
ibool check_charsets);/* in: TRUE=check charsets
compatibility */
/************************************************************************
Prints to the standard output information on all tables found in the data
dictionary system table. */
......
......@@ -68,21 +68,6 @@ ha_insert_for_fold(
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
......
......@@ -191,30 +191,3 @@ ha_search_and_delete_if_found(
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);
}
......@@ -31,13 +31,18 @@ typedef mem_block_info_t mem_block_t;
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 freeing. */
(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 @@ mem_heap_create_func(
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 @@ UNIV_INLINE
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 @@ UNIV_INLINE
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 @@ with mem_free. */
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 */
......
......@@ -16,8 +16,9 @@ Creates a memory heap block where data can be allocated. */
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_block_t*
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 @@ UNIV_INLINE
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 @@ mem_heap_free_top(
/*********************************************************************
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 @@ mem_heap_create_func(
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 @@ mem_heap_create_func(
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 @@ mem_heap_create_func(
#ifdef UNIV_MEM_DEBUG
if (block == NULL) {
return(block);
}
mem_hash_insert(block, file_name, line);
#endif
......@@ -484,8 +486,7 @@ UNIV_INLINE
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 @@ mem_alloc_func(
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
......
......@@ -24,7 +24,8 @@ cmp_types_are_equal(
/* out: TRUE if the types are considered
equal in comparisons */
dtype_t* type1, /* in: type 1 */
dtype_t* type2); /* in: type 2 */
dtype_t* type2, /* in: type 2 */
ibool check_charsets); /* in: whether to check charsets */
/*****************************************************************
This function is used to compare two data fields for which we know the
data type. */
......
......@@ -1708,7 +1708,7 @@ static
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 */
......@@ -1748,11 +1748,6 @@ lock_rec_create(
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);
......@@ -1895,8 +1890,7 @@ static
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 */
......@@ -3487,8 +3481,7 @@ UNIV_INLINE
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 */
......@@ -3514,11 +3507,6 @@ lock_table_create(
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);
lock->type_mode = type_mode | LOCK_TABLE;
......
......@@ -92,12 +92,10 @@ with mem_free. */
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 @@ Creates a memory heap block where data can be allocated. */
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 @@ mem_heap_create_block(
}
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_block_t*
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 */
{
......
......@@ -2437,7 +2437,9 @@ a b
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 @@ create table t8 (col1 blob, index(col1(767)))
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;
ERROR HY000: Can't create table './test/t1.frm' (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 t2 (col1 varbinary(768), index(col1))
character set = latin1 engine = innodb;
ERROR HY000: Can't create table './test/t2.frm' (errno: 139)
create table t3 (col1 varbinary(768) primary key)
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/t3.frm' (errno: 139)
create table t4 (col1 text, index(col1(768)))
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;
ERROR HY000: Can't create table './test/t4.frm' (errno: 139)
create table t5 (col1 blob, index(col1(768)))
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 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 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 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.frm' (errno: 139)
ERROR 42000: Specified key was too long; max key length is 767 bytes
CREATE TABLE t1
(
id INT PRIMARY KEY
......@@ -2772,3 +2801,35 @@ insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
drop table t1;
drop table t2;
commit;
set foreign_key_checks=0;
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
ERROR HY000: Can't create table './test/t1.frm' (errno: 150)
set foreign_key_checks=1;
drop table t2;
set foreign_key_checks=0;
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
ERROR HY000: Can't create table './test/t2.frm' (errno: 150)
set foreign_key_checks=1;
drop table t1;
set foreign_key_checks=0;
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
create table t1(a varchar(10) primary key) engine = innodb;
alter table t1 modify column a int;
Got one of the listed errors
set foreign_key_checks=1;
drop table t2,t1;
set foreign_key_checks=0;
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
alter table t1 convert to character set utf8;
set foreign_key_checks=1;
drop table t2,t1;
set foreign_key_checks=0;
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
rename table t3 to t1;
ERROR HY000: Error on rename of './test/t3' to './test/t1' (errno: 150)
set foreign_key_checks=1;
drop table t2,t3;
......@@ -1356,8 +1356,8 @@ source include/varchar.inc;
# 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 @@ CREATE TEMPORARY TABLE t2
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 t8 (col1 blob, index(col1(767)))
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;
--error 1005
create table t2 (col1 varchar(768) primary key)
create table t2 (col1 varbinary(768), index(col1))
character set = latin1 engine = innodb;
--error 1005
create table t3 (col1 varbinary(768) primary key)
create table t3 (col1 text, index(col1(768)))
character set = latin1 engine = innodb;
--error 1005
create table t4 (col1 text, index(col1(768)))
create table t4 (col1 blob, index(col1(768)))
character set = latin1 engine = innodb;
--error 1005
create table t5 (col1 blob, index(col1(768)))
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 1071
create table t2 (col1 varbinary(768) primary key)
character set = latin1 engine = innodb;
--error 1071
create table t3 (col1 text, primary key(col1(768)))
character set = latin1 engine = innodb;
--error 1071
create table t4 (col1 blob, primary key(col1(768)))
character set = latin1 engine = innodb;
#
......@@ -1751,3 +1765,53 @@ insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
drop table t1;
drop table t2;
commit;
# tests for bugs #9802 and #13778
# test that FKs between invalid types are not accepted
set foreign_key_checks=0;
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
-- error 1005
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
set foreign_key_checks=1;
drop table t2;
# test that FKs between different charsets are not accepted in CREATE even
# when f_k_c is 0
set foreign_key_checks=0;
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
-- error 1005
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
set foreign_key_checks=1;
drop table t1;
# test that invalid datatype conversions with ALTER are not allowed
set foreign_key_checks=0;
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
create table t1(a varchar(10) primary key) engine = innodb;
-- error 1025,1025
alter table t1 modify column a int;
set foreign_key_checks=1;
drop table t2,t1;
# test that charset conversions with ALTER are allowed when f_k_c is 0
set foreign_key_checks=0;
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
alter table t1 convert to character set utf8;
set foreign_key_checks=1;
drop table t2,t1;
# test that RENAME does not allow invalid charsets when f_k_c is 0
set foreign_key_checks=0;
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
-- error 1025
rename table t3 to t1;
set foreign_key_checks=1;
drop table t2,t3;
......@@ -99,7 +99,8 @@ cmp_types_are_equal(
/* out: TRUE if the types are considered
equal in comparisons */
dtype_t* type1, /* in: type 1 */
dtype_t* type2) /* in: type 2 */
dtype_t* type2, /* in: type 2 */
ibool check_charsets) /* in: whether to check charsets */
{
if (dtype_is_non_binary_string_type(type1->mtype, type1->prtype)
&& dtype_is_non_binary_string_type(type2->mtype, type2->prtype)) {
......@@ -107,12 +108,12 @@ cmp_types_are_equal(
/* Both are non-binary string types: they can be compared if
and only if the charset-collation is the same */
if (dtype_get_charset_coll(type1->prtype)
== dtype_get_charset_coll(type2->prtype)) {
if (check_charsets) {
return(dtype_get_charset_coll(type1->prtype)
== dtype_get_charset_coll(type2->prtype));
} else {
return(TRUE);
}
return(FALSE);
}
if (dtype_is_binary_string_type(type1->mtype, type1->prtype)
......
......@@ -2132,7 +2132,7 @@ row_table_add_foreign_constraints(
if (err == DB_SUCCESS) {
/* Check that also referencing constraints are ok */
err = dict_load_foreigns(name, trx->check_foreigns);
err = dict_load_foreigns(name, TRUE);
}
if (err != DB_SUCCESS) {
......@@ -3590,7 +3590,8 @@ row_rename_table_for_mysql(
mem_heap_t* heap = NULL;
const char** constraints_to_drop = NULL;
ulint n_constraints_to_drop = 0;
ibool recovering_temp_table = FALSE;
ibool recovering_temp_table = FALSE;
ibool old_is_tmp, new_is_tmp;
ulint len;
ulint i;
ibool success;
......@@ -3630,6 +3631,9 @@ row_rename_table_for_mysql(
trx->op_info = "renaming table";
trx_start_if_not_started(trx);
old_is_tmp = row_is_mysql_tmp_table_name(old_name);
new_is_tmp = row_is_mysql_tmp_table_name(new_name);
if (row_mysql_is_recovered_tmp_table(new_name)) {
recovering_temp_table = TRUE;
......@@ -3676,7 +3680,7 @@ row_rename_table_for_mysql(
len = (sizeof str1) + (sizeof str2) + (sizeof str3) + (sizeof str5) - 4
+ ut_strlenq(new_name, '\'') + ut_strlenq(old_name, '\'');
if (row_is_mysql_tmp_table_name(new_name)) {
if (new_is_tmp) {
db_name_len = dict_get_db_name_len(old_name) + 1;
/* MySQL is doing an ALTER TABLE command and it renames the
......@@ -3829,7 +3833,7 @@ row_rename_table_for_mysql(
the table is stored in a single-table tablespace */
success = dict_table_rename_in_cache(table, new_name,
!row_is_mysql_tmp_table_name(new_name));
!new_is_tmp);
if (!success) {
trx->error_state = DB_SUCCESS;
trx_general_rollback_for_mysql(trx, FALSE, NULL);
......@@ -3846,19 +3850,16 @@ row_rename_table_for_mysql(
goto funct_exit;
}
err = dict_load_foreigns(new_name, trx->check_foreigns);
if (row_is_mysql_tmp_table_name(old_name)) {
/* We only want to switch off some of the type checking in
an ALTER, not in a RENAME. */
err = dict_load_foreigns(new_name,
old_is_tmp ? trx->check_foreigns : TRUE);
/* MySQL is doing an ALTER TABLE command and it
renames the created temporary table to the name
of the original table. In the ALTER TABLE we maybe
created some FOREIGN KEY constraints for the temporary
table. But we want to load also the foreign key
constraint definitions for the original table name. */
if (err != DB_SUCCESS) {
ut_print_timestamp(stderr);
if (err != DB_SUCCESS) {
ut_print_timestamp(stderr);
if (old_is_tmp) {
fputs(" InnoDB: Error: in ALTER TABLE ",
stderr);
ut_print_name(stderr, trx, new_name);
......@@ -3866,36 +3867,23 @@ row_rename_table_for_mysql(
"InnoDB: has or is referenced in foreign key constraints\n"
"InnoDB: which are not compatible with the new table definition.\n",
stderr);
ut_a(dict_table_rename_in_cache(table,
old_name, FALSE));
trx->error_state = DB_SUCCESS;
trx_general_rollback_for_mysql(trx, FALSE,
NULL);
trx->error_state = DB_SUCCESS;
}
} else {
if (err != DB_SUCCESS) {
ut_print_timestamp(stderr);
} else {
fputs(
" InnoDB: Error: in RENAME TABLE table ",
stderr);
ut_print_name(stderr, trx, new_name);
fputs("\n"
"InnoDB: is referenced in foreign key constraints\n"
"InnoDB: which are not compatible with the new table definition.\n",
"InnoDB: is referenced in foreign key constraints\n"
"InnoDB: which are not compatible with the new table definition.\n",
stderr);
ut_a(dict_table_rename_in_cache(table,
old_name, FALSE));
trx->error_state = DB_SUCCESS;
trx_general_rollback_for_mysql(trx, FALSE,
NULL);
trx->error_state = DB_SUCCESS;
}
ut_a(dict_table_rename_in_cache(table,
old_name, FALSE));
trx->error_state = DB_SUCCESS;
trx_general_rollback_for_mysql(trx, FALSE,
NULL);
trx->error_state = DB_SUCCESS;
}
}
funct_exit:
......
......@@ -12,6 +12,9 @@ TARGETDIR=../storage/innobase
rm -fr "$TARGETDIR"
mkdir "$TARGETDIR"
# copy the build script
cp compile-innodb-debug ../BUILD
# create the directories
for dir in */
do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment