Commit 8f65d7a6 authored by marko's avatar marko

branches/zip: Merge revisions 1165:1206 from trunk.

parent f116afa7
# Copyright (C) 2006 MySQL AB
#
# 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; version 2 of the License.
#
# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#SET(CMAKE_CXX_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") #SET(CMAKE_CXX_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX")
#SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") #SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX")
ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -DWIN32 -D_LIB) ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -DWIN32 -D_LIB)
......
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2004, 2006 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
......
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libbtr.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libbtr.a
libbtr_a_SOURCES = btr0btr.c btr0cur.c btr0pcur.c btr0sea.c libbtr_a_SOURCES = btr0btr.c btr0cur.c btr0pcur.c btr0sea.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libbuf.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libbuf.a
libbuf_a_SOURCES = buf0buf.c buf0buddy.c buf0flu.c buf0lru.c buf0rea.c libbuf_a_SOURCES = buf0buf.c buf0buddy.c buf0flu.c buf0lru.c buf0rea.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
...@@ -1147,9 +1147,7 @@ flush_next: ...@@ -1147,9 +1147,7 @@ flush_next:
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
if (page_count != ULINT_UNDEFINED) {
srv_buf_pool_flushed += page_count; srv_buf_pool_flushed += page_count;
}
return(page_count); return(page_count);
} }
......
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libdata.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libdata.a
libdata_a_SOURCES = data0data.c data0type.c libdata_a_SOURCES = data0data.c data0type.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -23,3 +21,6 @@ libdict_a_SOURCES = dict0boot.c dict0crea.c dict0dict.c dict0load.c\ ...@@ -23,3 +21,6 @@ libdict_a_SOURCES = dict0boot.c dict0crea.c dict0dict.c dict0load.c\
dict0mem.c dict0mem.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
...@@ -1164,6 +1164,7 @@ dict_load_foreign( ...@@ -1164,6 +1164,7 @@ dict_load_foreign(
const rec_t* rec; const rec_t* rec;
const byte* field; const byte* field;
ulint len; ulint len;
ulint n_fields_and_type;
mtr_t mtr; mtr_t mtr;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
...@@ -1226,15 +1227,15 @@ dict_load_foreign( ...@@ -1226,15 +1227,15 @@ dict_load_foreign(
foreign = dict_mem_foreign_create(); foreign = dict_mem_foreign_create();
foreign->n_fields = mach_read_from_4( n_fields_and_type = mach_read_from_4(
rec_get_nth_field_old(rec, 5, &len)); rec_get_nth_field_old(rec, 5, &len));
ut_a(len == 4); ut_a(len == 4);
/* We store the type to the bits 24-31 of n_fields */ /* We store the type in the bits 24..29 of n_fields_and_type. */
foreign->type = foreign->n_fields >> 24; foreign->type = n_fields_and_type >> 24;
foreign->n_fields = foreign->n_fields & 0xFFFFFFUL; foreign->n_fields = n_fields_and_type & 0x3FFUL;
foreign->id = mem_heap_strdup(foreign->heap, id); foreign->id = mem_heap_strdup(foreign->heap, id);
......
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libdyn.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libdyn.a
libdyn_a_SOURCES = dyn0dyn.c libdyn_a_SOURCES = dyn0dyn.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libeval.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libeval.a
libeval_a_SOURCES = eval0eval.c eval0proc.c libeval_a_SOURCES = eval0eval.c eval0proc.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libfil.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libfil.a
libfil_a_SOURCES = fil0fil.c libfil_a_SOURCES = fil0fil.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -23,3 +21,6 @@ noinst_LIBRARIES = libfsp.a ...@@ -23,3 +21,6 @@ noinst_LIBRARIES = libfsp.a
libfsp_a_SOURCES = fsp0fsp.c libfsp_a_SOURCES = fsp0fsp.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libfut.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libfut.a
libfut_a_SOURCES = fut0fut.c fut0lst.c libfut_a_SOURCES = fut0fut.c fut0lst.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libha.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libha.a
libha_a_SOURCES = ha0ha.c hash0hash.c libha_a_SOURCES = ha0ha.c hash0hash.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; version 2 of the License.
(at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -178,6 +177,7 @@ my_bool innobase_use_large_pages = FALSE; ...@@ -178,6 +177,7 @@ my_bool innobase_use_large_pages = FALSE;
my_bool innobase_use_native_aio = FALSE; my_bool innobase_use_native_aio = FALSE;
my_bool innobase_file_per_table = FALSE; my_bool innobase_file_per_table = FALSE;
my_bool innobase_locks_unsafe_for_binlog = FALSE; my_bool innobase_locks_unsafe_for_binlog = FALSE;
my_bool innobase_rollback_on_timeout = FALSE;
my_bool innobase_create_status_file = FALSE; my_bool innobase_create_status_file = FALSE;
static char *internal_innobase_data_file_path = NULL; static char *internal_innobase_data_file_path = NULL;
...@@ -470,6 +470,10 @@ convert_error_code_to_mysql( ...@@ -470,6 +470,10 @@ convert_error_code_to_mysql(
latest SQL statement in a lock wait timeout. Previously, we latest SQL statement in a lock wait timeout. Previously, we
rolled back the whole transaction. */ rolled back the whole transaction. */
if (thd && row_rollback_on_timeout) {
ha_rollback(thd);
}
return(HA_ERR_LOCK_WAIT_TIMEOUT); return(HA_ERR_LOCK_WAIT_TIMEOUT);
} else if (error == (int) DB_NO_REFERENCED_ROW) { } else if (error == (int) DB_NO_REFERENCED_ROW) {
...@@ -922,7 +926,6 @@ ha_innobase::update_thd( ...@@ -922,7 +926,6 @@ ha_innobase::update_thd(
/* out: 0 or error code */ /* out: 0 or error code */
THD* thd) /* in: thd to use the handle */ THD* thd) /* in: thd to use the handle */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx; trx_t* trx;
trx = check_trx_exists(ht, thd); trx = check_trx_exists(ht, thd);
...@@ -1265,8 +1268,6 @@ void ...@@ -1265,8 +1268,6 @@ void
ha_innobase::init_table_handle_for_HANDLER(void) ha_innobase::init_table_handle_for_HANDLER(void)
/*============================================*/ /*============================================*/
{ {
row_prebuilt_t* prebuilt;
/* If current thd does not yet have a trx struct, create one. /* If current thd does not yet have a trx struct, create one.
If the current handle does not yet have a prebuilt struct, create If the current handle does not yet have a prebuilt struct, create
one. Update the trx pointers in the prebuilt struct. Normally one. Update the trx pointers in the prebuilt struct. Normally
...@@ -1277,8 +1278,6 @@ ha_innobase::init_table_handle_for_HANDLER(void) ...@@ -1277,8 +1278,6 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/* Initialize the prebuilt struct much like it would be inited in /* Initialize the prebuilt struct much like it would be inited in
external_lock */ external_lock */
prebuilt = (row_prebuilt_t*)innobase_prebuilt;
innobase_release_stat_resources(prebuilt->trx); innobase_release_stat_resources(prebuilt->trx);
/* If the transaction is not started yet, start it */ /* If the transaction is not started yet, start it */
...@@ -1531,6 +1530,8 @@ innobase_init(void *p) ...@@ -1531,6 +1530,8 @@ innobase_init(void *p)
os_use_large_pages = (ibool) innobase_use_large_pages; os_use_large_pages = (ibool) innobase_use_large_pages;
os_large_page_size = (ulint) innobase_large_page_size; os_large_page_size = (ulint) innobase_large_page_size;
row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout;
srv_file_per_table = (ibool) innobase_file_per_table; srv_file_per_table = (ibool) innobase_file_per_table;
srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog; srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog;
...@@ -2186,8 +2187,6 @@ ha_innobase::get_row_type() const ...@@ -2186,8 +2187,6 @@ ha_innobase::get_row_type() const
/*=============================*/ /*=============================*/
/* out: ROW_TYPE_REDUNDANT or ROW_TYPE_COMPACT */ /* out: ROW_TYPE_REDUNDANT or ROW_TYPE_COMPACT */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
if (prebuilt && prebuilt->table) { if (prebuilt && prebuilt->table) {
if (dict_table_is_comp_noninline(prebuilt->table)) { if (dict_table_is_comp_noninline(prebuilt->table)) {
return(ROW_TYPE_COMPACT); return(ROW_TYPE_COMPACT);
...@@ -2352,10 +2351,9 @@ ha_innobase::open( ...@@ -2352,10 +2351,9 @@ ha_innobase::open(
DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
} }
innobase_prebuilt = row_create_prebuilt(ib_table); prebuilt = row_create_prebuilt(ib_table);
((row_prebuilt_t*)innobase_prebuilt)->mysql_row_len = prebuilt->mysql_row_len = table->s->reclength;
table->s->reclength;
/* Looks like MySQL-3.23 sometimes has primary key number != 0 */ /* Looks like MySQL-3.23 sometimes has primary key number != 0 */
...@@ -2374,8 +2372,8 @@ ha_innobase::open( ...@@ -2374,8 +2372,8 @@ ha_innobase::open(
"dictionary, but not in MySQL!", name); "dictionary, but not in MySQL!", name);
} }
((row_prebuilt_t*)innobase_prebuilt) prebuilt->clust_index_was_generated = FALSE;
->clust_index_was_generated = FALSE;
/* MySQL allocates the buffer for ref. key_info->key_length /* MySQL allocates the buffer for ref. key_info->key_length
includes space for all key columns + one byte for each column includes space for all key columns + one byte for each column
that may be NULL. ref_length must be as exact as possible to that may be NULL. ref_length must be as exact as possible to
...@@ -2396,8 +2394,7 @@ ha_innobase::open( ...@@ -2396,8 +2394,7 @@ ha_innobase::open(
"of the table.", name); "of the table.", name);
} }
((row_prebuilt_t*)innobase_prebuilt) prebuilt->clust_index_was_generated = TRUE;
->clust_index_was_generated = TRUE;
ref_length = DATA_ROW_ID_LEN; ref_length = DATA_ROW_ID_LEN;
...@@ -2444,7 +2441,7 @@ ha_innobase::close(void) ...@@ -2444,7 +2441,7 @@ ha_innobase::close(void)
{ {
DBUG_ENTER("ha_innobase::close"); DBUG_ENTER("ha_innobase::close");
row_prebuilt_free((row_prebuilt_t*) innobase_prebuilt); row_prebuilt_free(prebuilt);
my_free((gptr) upd_buff, MYF(0)); my_free((gptr) upd_buff, MYF(0));
free_share(share); free_share(share);
...@@ -3231,7 +3228,6 @@ ha_innobase::write_row( ...@@ -3231,7 +3228,6 @@ ha_innobase::write_row(
/* out: error code */ /* out: error code */
mysql_byte* record) /* in: a row in MySQL format */ mysql_byte* record) /* in: a row in MySQL format */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
int error; int error;
longlong auto_inc; longlong auto_inc;
longlong dummy; longlong dummy;
...@@ -3622,7 +3618,6 @@ ha_innobase::update_row( ...@@ -3622,7 +3618,6 @@ ha_innobase::update_row(
const mysql_byte* old_row,/* in: old row in MySQL format */ const mysql_byte* old_row,/* in: old row in MySQL format */
mysql_byte* new_row)/* in: new row in MySQL format */ mysql_byte* new_row)/* in: new row in MySQL format */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
upd_t* uvect; upd_t* uvect;
int error = 0; int error = 0;
...@@ -3684,7 +3679,6 @@ ha_innobase::delete_row( ...@@ -3684,7 +3679,6 @@ ha_innobase::delete_row(
/* out: error number or 0 */ /* out: error number or 0 */
const mysql_byte* record) /* in: a row in MySQL format */ const mysql_byte* record) /* in: a row in MySQL format */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
int error = 0; int error = 0;
DBUG_ENTER("ha_innobase::delete_row"); DBUG_ENTER("ha_innobase::delete_row");
...@@ -3732,8 +3726,6 @@ void ...@@ -3732,8 +3726,6 @@ void
ha_innobase::unlock_row(void) ha_innobase::unlock_row(void)
/*=========================*/ /*=========================*/
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
DBUG_ENTER("ha_innobase::unlock_row"); DBUG_ENTER("ha_innobase::unlock_row");
if (UNIV_UNLIKELY(last_query_id != user_thd->query_id)) { if (UNIV_UNLIKELY(last_query_id != user_thd->query_id)) {
...@@ -3775,8 +3767,6 @@ bool ...@@ -3775,8 +3767,6 @@ bool
ha_innobase::was_semi_consistent_read(void) ha_innobase::was_semi_consistent_read(void)
/*=======================================*/ /*=======================================*/
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
return(prebuilt->row_read_type == ROW_READ_DID_SEMI_CONSISTENT); return(prebuilt->row_read_type == ROW_READ_DID_SEMI_CONSISTENT);
} }
...@@ -3785,8 +3775,6 @@ void ...@@ -3785,8 +3775,6 @@ void
ha_innobase::try_semi_consistent_read(bool yes) ha_innobase::try_semi_consistent_read(bool yes)
/*===========================================*/ /*===========================================*/
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[ht->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
...@@ -3945,7 +3933,6 @@ ha_innobase::index_read( ...@@ -3945,7 +3933,6 @@ ha_innobase::index_read(
uint key_len,/* in: key value length */ uint key_len,/* in: key value length */
enum ha_rkey_function find_flag)/* in: search flags from my_base.h */ enum ha_rkey_function find_flag)/* in: search flags from my_base.h */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
ulint mode; ulint mode;
dict_index_t* index; dict_index_t* index;
ulint match_mode = 0; ulint match_mode = 0;
...@@ -4062,7 +4049,6 @@ ha_innobase::change_active_index( ...@@ -4062,7 +4049,6 @@ ha_innobase::change_active_index(
index, even if it was internally generated by index, even if it was internally generated by
InnoDB */ InnoDB */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
KEY* key=0; KEY* key=0;
statistic_increment(current_thd->status_var.ha_read_key_count, statistic_increment(current_thd->status_var.ha_read_key_count,
&LOCK_status); &LOCK_status);
...@@ -4153,7 +4139,6 @@ ha_innobase::general_fetch( ...@@ -4153,7 +4139,6 @@ ha_innobase::general_fetch(
uint match_mode) /* in: 0, ROW_SEL_EXACT, or uint match_mode) /* in: 0, ROW_SEL_EXACT, or
ROW_SEL_EXACT_PREFIX */ ROW_SEL_EXACT_PREFIX */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
ulint ret; ulint ret;
int error = 0; int error = 0;
...@@ -4307,8 +4292,6 @@ ha_innobase::rnd_init( ...@@ -4307,8 +4292,6 @@ ha_innobase::rnd_init(
{ {
int err; int err;
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
/* Store the active index value so that we can restore the original /* Store the active index value so that we can restore the original
value after a scan */ value after a scan */
...@@ -4386,7 +4369,6 @@ ha_innobase::rnd_pos( ...@@ -4386,7 +4369,6 @@ ha_innobase::rnd_pos(
the length of data in pos has to be the length of data in pos has to be
ref_length */ ref_length */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
int error; int error;
uint keynr = active_index; uint keynr = active_index;
DBUG_ENTER("rnd_pos"); DBUG_ENTER("rnd_pos");
...@@ -4442,7 +4424,6 @@ ha_innobase::position( ...@@ -4442,7 +4424,6 @@ ha_innobase::position(
/*==================*/ /*==================*/
const mysql_byte* record) /* in: row in MySQL format */ const mysql_byte* record) /* in: row in MySQL format */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
uint len; uint len;
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
...@@ -4946,7 +4927,6 @@ ha_innobase::discard_or_import_tablespace( ...@@ -4946,7 +4927,6 @@ ha_innobase::discard_or_import_tablespace(
/* out: 0 == success, -1 == error */ /* out: 0 == success, -1 == error */
my_bool discard) /* in: TRUE if discard, else import */ my_bool discard) /* in: TRUE if discard, else import */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
dict_table_t* dict_table; dict_table_t* dict_table;
trx_t* trx; trx_t* trx;
int err; int err;
...@@ -4979,7 +4959,6 @@ ha_innobase::delete_all_rows(void) ...@@ -4979,7 +4959,6 @@ ha_innobase::delete_all_rows(void)
/*==============================*/ /*==============================*/
/* out: error number */ /* out: error number */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
int error; int error;
THD* thd = current_thd; THD* thd = current_thd;
...@@ -5264,7 +5243,6 @@ ha_innobase::records_in_range( ...@@ -5264,7 +5243,6 @@ ha_innobase::records_in_range(
key_range *max_key) /* in: range end key val, may key_range *max_key) /* in: range end key val, may
also be 0 */ also be 0 */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
KEY* key; KEY* key;
dict_index_t* index; dict_index_t* index;
mysql_byte* key_val_buff2 = (mysql_byte*) my_malloc( mysql_byte* key_val_buff2 = (mysql_byte*) my_malloc(
...@@ -5358,7 +5336,6 @@ ha_innobase::estimate_rows_upper_bound(void) ...@@ -5358,7 +5336,6 @@ ha_innobase::estimate_rows_upper_bound(void)
/*======================================*/ /*======================================*/
/* out: upper bound of rows */ /* out: upper bound of rows */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
dict_index_t* index; dict_index_t* index;
ulonglong estimate; ulonglong estimate;
ulonglong local_data_file_length; ulonglong local_data_file_length;
...@@ -5407,8 +5384,6 @@ ha_innobase::scan_time() ...@@ -5407,8 +5384,6 @@ ha_innobase::scan_time()
/*====================*/ /*====================*/
/* out: estimated time measured in disk seeks */ /* out: estimated time measured in disk seeks */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
/* Since MySQL seems to favor table scans too much over index /* Since MySQL seems to favor table scans too much over index
searches, we pretend that a sequential read takes the same time searches, we pretend that a sequential read takes the same time
as a random disk read, that is, we do not divide the following as a random disk read, that is, we do not divide the following
...@@ -5464,7 +5439,6 @@ ha_innobase::info( ...@@ -5464,7 +5439,6 @@ ha_innobase::info(
/*==============*/ /*==============*/
uint flag) /* in: what information MySQL requests */ uint flag) /* in: what information MySQL requests */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
dict_table_t* ib_table; dict_table_t* ib_table;
dict_index_t* index; dict_index_t* index;
ha_rows rec_per_key; ha_rows rec_per_key;
...@@ -5715,7 +5689,6 @@ ha_innobase::check( ...@@ -5715,7 +5689,6 @@ ha_innobase::check(
HA_CHECK_OPT* check_opt) /* in: check options, currently HA_CHECK_OPT* check_opt) /* in: check options, currently
ignored */ ignored */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
ulint ret; ulint ret;
ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N); ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
...@@ -5752,7 +5725,6 @@ ha_innobase::update_table_comment( ...@@ -5752,7 +5725,6 @@ ha_innobase::update_table_comment(
{ {
uint length = (uint) strlen(comment); uint length = (uint) strlen(comment);
char* str; char* str;
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
long flen; long flen;
/* We do not know if MySQL can call this function before calling /* We do not know if MySQL can call this function before calling
...@@ -5825,7 +5797,6 @@ ha_innobase::get_foreign_key_create_info(void) ...@@ -5825,7 +5797,6 @@ ha_innobase::get_foreign_key_create_info(void)
can be inserted to the CREATE TABLE statement, can be inserted to the CREATE TABLE statement,
MUST be freed with ::free_foreign_key_create_info */ MUST be freed with ::free_foreign_key_create_info */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
char* str = 0; char* str = 0;
long flen; long flen;
...@@ -5883,7 +5854,6 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) ...@@ -5883,7 +5854,6 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
dict_foreign_t* foreign; dict_foreign_t* foreign;
DBUG_ENTER("get_foreign_key_list"); DBUG_ENTER("get_foreign_key_list");
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
ut_a(prebuilt != NULL); ut_a(prebuilt != NULL);
update_thd(current_thd); update_thd(current_thd);
prebuilt->trx->op_info = (char*)"getting list of foreign keys"; prebuilt->trx->op_info = (char*)"getting list of foreign keys";
...@@ -5998,7 +5968,6 @@ bool ...@@ -5998,7 +5968,6 @@ bool
ha_innobase::can_switch_engines(void) ha_innobase::can_switch_engines(void)
/*=================================*/ /*=================================*/
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
bool can_switch; bool can_switch;
DBUG_ENTER("ha_innobase::can_switch_engines"); DBUG_ENTER("ha_innobase::can_switch_engines");
...@@ -6030,8 +5999,6 @@ ha_innobase::referenced_by_foreign_key(void) ...@@ -6030,8 +5999,6 @@ ha_innobase::referenced_by_foreign_key(void)
/*========================================*/ /*========================================*/
/* out: > 0 if referenced by a FOREIGN KEY */ /* out: > 0 if referenced by a FOREIGN KEY */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
if (dict_table_referenced_by_foreign_key(prebuilt->table)) { if (dict_table_referenced_by_foreign_key(prebuilt->table)) {
return(1); return(1);
...@@ -6064,8 +6031,6 @@ ha_innobase::extra( ...@@ -6064,8 +6031,6 @@ ha_innobase::extra(
enum ha_extra_function operation) enum ha_extra_function operation)
/* in: HA_EXTRA_FLUSH or some other flag */ /* in: HA_EXTRA_FLUSH or some other flag */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
/* Warning: since it is not sure that MySQL calls external_lock /* Warning: since it is not sure that MySQL calls external_lock
before calling this function, the trx field in prebuilt can be before calling this function, the trx field in prebuilt can be
obsolete! */ obsolete! */
...@@ -6098,7 +6063,6 @@ ha_innobase::extra( ...@@ -6098,7 +6063,6 @@ ha_innobase::extra(
int ha_innobase::reset() int ha_innobase::reset()
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
if (prebuilt->blob_heap) { if (prebuilt->blob_heap) {
row_mysql_prebuilt_free_blob_heap(prebuilt); row_mysql_prebuilt_free_blob_heap(prebuilt);
} }
...@@ -6127,7 +6091,6 @@ ha_innobase::start_stmt( ...@@ -6127,7 +6091,6 @@ ha_innobase::start_stmt(
THD* thd, /* in: handle to the user thread */ THD* thd, /* in: handle to the user thread */
thr_lock_type lock_type) thr_lock_type lock_type)
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx; trx_t* trx;
update_thd(thd); update_thd(thd);
...@@ -6226,7 +6189,6 @@ ha_innobase::external_lock( ...@@ -6226,7 +6189,6 @@ ha_innobase::external_lock(
THD* thd, /* in: handle to the user thread */ THD* thd, /* in: handle to the user thread */
int lock_type) /* in: lock type */ int lock_type) /* in: lock type */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx; trx_t* trx;
DBUG_ENTER("ha_innobase::external_lock"); DBUG_ENTER("ha_innobase::external_lock");
...@@ -6368,7 +6330,6 @@ ha_innobase::transactional_table_lock( ...@@ -6368,7 +6330,6 @@ ha_innobase::transactional_table_lock(
THD* thd, /* in: handle to the user thread */ THD* thd, /* in: handle to the user thread */
int lock_type) /* in: lock type */ int lock_type) /* in: lock type */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx; trx_t* trx;
DBUG_ENTER("ha_innobase::transactional_table_lock"); DBUG_ENTER("ha_innobase::transactional_table_lock");
...@@ -6756,7 +6717,6 @@ ha_innobase::store_lock( ...@@ -6756,7 +6717,6 @@ ha_innobase::store_lock(
'lock'; this may also be 'lock'; this may also be
TL_IGNORE */ TL_IGNORE */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx; trx_t* trx;
/* Note that trx in this function is NOT necessarily prebuilt->trx /* Note that trx in this function is NOT necessarily prebuilt->trx
...@@ -6948,7 +6908,6 @@ ha_innobase::innobase_read_and_init_auto_inc( ...@@ -6948,7 +6908,6 @@ ha_innobase::innobase_read_and_init_auto_inc(
timeout */ timeout */
longlong* ret) /* out: auto-inc value */ longlong* ret) /* out: auto-inc value */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
longlong auto_inc; longlong auto_inc;
ulint old_select_lock_type; ulint old_select_lock_type;
ibool trx_was_not_started = FALSE; ibool trx_was_not_started = FALSE;
...@@ -7128,7 +7087,6 @@ ha_innobase::reset_auto_increment(ulonglong value) ...@@ -7128,7 +7087,6 @@ ha_innobase::reset_auto_increment(ulonglong value)
{ {
DBUG_ENTER("ha_innobase::reset_auto_increment"); DBUG_ENTER("ha_innobase::reset_auto_increment");
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
int error; int error;
update_thd(current_thd); update_thd(current_thd);
...@@ -7173,7 +7131,6 @@ ha_innobase::cmp_ref( ...@@ -7173,7 +7131,6 @@ ha_innobase::cmp_ref(
const mysql_byte* ref2) /* in: an (internal) primary key value in the const mysql_byte* ref2) /* in: an (internal) primary key value in the
MySQL key value format */ MySQL key value format */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
enum_field_types mysql_type; enum_field_types mysql_type;
Field* field; Field* field;
KEY_PART_INFO* key_part; KEY_PART_INFO* key_part;
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; version 2 of the License.
(at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -34,6 +33,7 @@ typedef struct st_innobase_share { ...@@ -34,6 +33,7 @@ typedef struct st_innobase_share {
struct row_prebuilt_struct; struct row_prebuilt_struct;
typedef struct row_prebuilt_struct row_prebuilt_t;
my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name, my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name,
uint full_name_len, uint full_name_len,
...@@ -42,9 +42,8 @@ my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name, ...@@ -42,9 +42,8 @@ my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name,
/* The class defining a handle to an Innodb table */ /* The class defining a handle to an Innodb table */
class ha_innobase: public handler class ha_innobase: public handler
{ {
void* innobase_prebuilt;/* (row_prebuilt_t*) prebuilt row_prebuilt_t* prebuilt; /* prebuilt struct in InnoDB, used
struct in InnoDB, used to save to save CPU time with prebuilt data
CPU time with prebuilt data
structures*/ structures*/
THD* user_thd; /* the thread handle of the user THD* user_thd; /* the thread handle of the user
currently using the handle; this is currently using the handle; this is
...@@ -223,6 +222,7 @@ extern my_bool innobase_log_archive, ...@@ -223,6 +222,7 @@ extern my_bool innobase_log_archive,
innobase_use_large_pages, innobase_use_large_pages,
innobase_use_native_aio, innobase_use_native_aio,
innobase_file_per_table, innobase_locks_unsafe_for_binlog, innobase_file_per_table, innobase_locks_unsafe_for_binlog,
innobase_rollback_on_timeout,
innobase_create_status_file; innobase_create_status_file;
extern "C" { extern "C" {
extern ulong srv_buf_pool_curr_size; extern ulong srv_buf_pool_curr_size;
......
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
......
...@@ -19,6 +19,8 @@ Created 9/17/2000 Heikki Tuuri ...@@ -19,6 +19,8 @@ Created 9/17/2000 Heikki Tuuri
#include "btr0pcur.h" #include "btr0pcur.h"
#include "trx0types.h" #include "trx0types.h"
extern ibool row_rollback_on_timeout;
typedef struct row_prebuilt_struct row_prebuilt_t; typedef struct row_prebuilt_struct row_prebuilt_t;
/*********************************************************************** /***********************************************************************
......
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = liblock.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = liblock.a
liblock_a_SOURCES = lock0lock.c liblock_a_SOURCES = lock0lock.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = liblog.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = liblog.a
liblog_a_SOURCES = log0log.c log0recv.c liblog_a_SOURCES = log0log.c log0recv.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libmach.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libmach.a
libmach_a_SOURCES = mach0data.c libmach_a_SOURCES = mach0data.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -24,3 +22,6 @@ libmem_a_SOURCES = mem0mem.c mem0pool.c ...@@ -24,3 +22,6 @@ libmem_a_SOURCES = mem0mem.c mem0pool.c
EXTRA_DIST = mem0dbg.c EXTRA_DIST = mem0dbg.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libmtr.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libmtr.a
libmtr_a_SOURCES = mtr0mtr.c mtr0log.c libmtr_a_SOURCES = mtr0mtr.c mtr0log.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
...@@ -3456,3 +3456,20 @@ OPTIMIZE TABLE t1; ...@@ -3456,3 +3456,20 @@ OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id)
ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON
DELETE CASCADE ON UPDATE CASCADE;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`id` int(11) NOT NULL,
`f` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `f` (`f`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t2, t1;
...@@ -2503,6 +2503,22 @@ INSERT INTO t1 VALUES (1); ...@@ -2503,6 +2503,22 @@ INSERT INTO t1 VALUES (1);
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #24741 (existing cascade clauses disappear when adding foreign keys)
#
CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id)
ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON
DELETE CASCADE ON UPDATE CASCADE;
SHOW CREATE TABLE t2;
DROP TABLE t2, t1;
####################################################################### #######################################################################
# # # #
# Please, DO NOT TOUCH this file as well as the innodb.result file. # # Please, DO NOT TOUCH this file as well as the innodb.result file. #
......
SET SESSION STORAGE_ENGINE = InnoDB;
drop table if exists t1,t2,t1m,t1i,t2m,t2i,t4;
create table t1 (
c_id int(11) not null default '0',
org_id int(11) default null,
unique key contacts$c_id (c_id),
key contacts$org_id (org_id)
);
insert into t1 values
(2,null),(120,null),(141,null),(218,7), (128,1),
(151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3),
(246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4);
create table t2 (
slai_id int(11) not null default '0',
owner_tbl int(11) default null,
owner_id int(11) default null,
sla_id int(11) default null,
inc_web int(11) default null,
inc_email int(11) default null,
inc_chat int(11) default null,
inc_csr int(11) default null,
inc_total int(11) default null,
time_billed int(11) default null,
activedate timestamp null default null,
expiredate timestamp null default null,
state int(11) default null,
sla_set int(11) default null,
unique key t2$slai_id (slai_id),
key t2$owner_id (owner_id),
key t2$sla_id (sla_id)
);
insert into t2(slai_id, owner_tbl, owner_id, sla_id) values
(1,3,1,1), (3,3,10,2), (4,3,3,6), (5,3,2,5), (6,3,8,3), (7,3,9,7),
(8,3,6,8), (9,3,4,9), (10,3,5,10), (11,3,11,11), (12,3,7,12);
flush tables;
select si.slai_id
from t1 c join t2 si on
((si.owner_tbl = 3 and si.owner_id = c.org_id) or
( si.owner_tbl = 2 and si.owner_id = c.c_id))
where
c.c_id = 218 and expiredate is null;
slai_id
12
select * from t1 where org_id is null;
c_id org_id
2 NULL
120 NULL
141 NULL
select si.slai_id
from t1 c join t2 si on
((si.owner_tbl = 3 and si.owner_id = c.org_id) or
( si.owner_tbl = 2 and si.owner_id = c.c_id))
where
c.c_id = 218 and expiredate is null;
slai_id
12
drop table t1, t2;
CREATE TABLE t1 (a int, b int, KEY b (b));
CREATE TABLE t2 (a int, b int, PRIMARY KEY (a,b));
CREATE TABLE t3 (a int, b int, c int, PRIMARY KEY (a),
UNIQUE KEY b (b,c), KEY a (a,b,c));
INSERT INTO t1 VALUES (1, 1);
INSERT INTO t1 SELECT a + 1, b + 1 FROM t1;
INSERT INTO t1 SELECT a + 2, b + 2 FROM t1;
INSERT INTO t2 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8);
INSERT INTO t2 SELECT a + 1, b FROM t2;
DELETE FROM t2 WHERE a = 1 AND b < 2;
INSERT INTO t3 VALUES (1,1,1),(2,1,2);
INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3;
INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3;
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
ORDER BY t1.b LIMIT 2;
b a
1 1
2 2
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
ORDER BY t1.b LIMIT 5;
b a
1 1
2 2
2 2
3 3
3 3
DROP TABLE t1, t2, t3;
CREATE TABLE `t1` (`id1` INT) ;
INSERT INTO `t1` (`id1`) VALUES (1),(5),(2);
CREATE TABLE `t2` (
`id1` INT,
`id2` INT NOT NULL,
`id3` INT,
`id4` INT NOT NULL,
UNIQUE (`id2`,`id4`),
KEY (`id1`)
);
INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES
(1,1,1,0),
(1,1,2,1),
(5,1,2,2),
(6,1,2,3),
(1,2,2,2),
(1,2,1,1);
SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2);
id1
2
DROP TABLE t1, t2;
create table t1 (c1 int) engine=innodb;
handler t1 open;
handler t1 read first;
c1
Before and after comparison
0
drop table t1;
End of 4.1 tests
create table t1m (a int) engine = MEMORY;
create table t1i (a int);
create table t2m (a int) engine = MEMORY;
create table t2i (a int);
insert into t2m values (5);
insert into t2i values (5);
select min(a) from t1i;
min(a)
NULL
select min(7) from t1i;
min(7)
NULL
select min(7) from DUAL;
min(7)
7
explain select min(7) from t2i join t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
select min(7) from t2i join t1i;
min(7)
NULL
select max(a) from t1i;
max(a)
NULL
select max(7) from t1i;
max(7)
NULL
select max(7) from DUAL;
max(7)
7
explain select max(7) from t2i join t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
select max(7) from t2i join t1i;
max(7)
NULL
select 1, min(a) from t1i where a=99;
1 min(a)
1 NULL
select 1, min(a) from t1i where 1=99;
1 min(a)
1 NULL
select 1, min(1) from t1i where a=99;
1 min(1)
1 NULL
select 1, min(1) from t1i where 1=99;
1 min(1)
1 NULL
select 1, max(a) from t1i where a=99;
1 max(a)
1 NULL
select 1, max(a) from t1i where 1=99;
1 max(a)
1 NULL
select 1, max(1) from t1i where a=99;
1 max(1)
1 NULL
select 1, max(1) from t1i where 1=99;
1 max(1)
1 NULL
explain select count(*), min(7), max(7) from t1m, t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
select count(*), min(7), max(7) from t1m, t1i;
count(*) min(7) max(7)
0 NULL NULL
explain select count(*), min(7), max(7) from t1m, t2i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
select count(*), min(7), max(7) from t1m, t2i;
count(*) min(7) max(7)
0 NULL NULL
explain select count(*), min(7), max(7) from t2m, t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2m system NULL NULL NULL NULL 1
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
select count(*), min(7), max(7) from t2m, t1i;
count(*) min(7) max(7)
0 NULL NULL
drop table t1m, t1i, t2m, t2i;
create table t1 (
a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
) ENGINE = MEMORY;
insert into t1 (a1, a2, b, c, d) values
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'),
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
create table t4 (
pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
);
insert into t4 (a1, a2, b, c, d, dummy) select * from t1;
create index idx12672_0 on t4 (a1);
create index idx12672_1 on t4 (a1,a2,b,c);
create index idx12672_2 on t4 (a1,a2,b);
analyze table t4;
Table Op Msg_type Msg_text
test.t4 analyze status OK
select distinct a1 from t4 where pk_col not in (1,2,3,4);
a1
a
b
c
d
drop table t1,t4;
DROP TABLE IF EXISTS t2, t1;
CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE= InnoDB;
CREATE TABLE t2 (
i INT NOT NULL,
FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION
) ENGINE= InnoDB;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
DELETE IGNORE FROM t1 WHERE i = 1;
Warnings:
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
SELECT * FROM t1, t2;
i i
1 1
DROP TABLE t2, t1;
End of 4.1 tests.
create table t1 (
a varchar(30), b varchar(30), primary key(a), key(b)
);
select distinct a from t1;
a
drop table t1;
create table t1(a int, key(a));
insert into t1 values(1);
select a, count(a) from t1 group by a with rollup;
a count(a)
1 1
NULL 1
drop table t1;
create table t1 (f1 int, f2 char(1), primary key(f1,f2));
insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
alter table t1 drop primary key, add primary key (f2, f1);
explain select distinct f1 a, f1 b from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 5 NULL 4 Using index; Using temporary
explain select distinct f1, f2 from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL PRIMARY 5 NULL 3 Using index for group-by; Using temporary
drop table t1;
CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
INDEX (name));
CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11));
ALTER TABLE t2 ADD FOREIGN KEY (fkey) REFERENCES t2(id);
INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
EXPLAIN
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
WHERE t1.name LIKE 'A%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using where; Using index
EXPLAIN
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
WHERE t1.name LIKE 'A%' OR FALSE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
DROP TABLE t1,t2;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB;
INSERT INTO t1 VALUES ( 1 , 1 , 1);
INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1;
EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 5 NULL 128
EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort
DROP TABLE t1;
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,1),(1,2);
CREATE TABLE t2 (primary key (a)) select * from t1;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
drop table if exists t2;
Warnings:
Note 1051 Unknown table 't2'
CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
drop table if exists t2;
Warnings:
Note 1051 Unknown table 't2'
CREATE TABLE t2 (a int, b int, primary key (a));
BEGIN;
INSERT INTO t2 values(100,100);
CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
SELECT * from t2;
a b
100 100
ROLLBACK;
SELECT * from t2;
a b
100 100
TRUNCATE table t2;
INSERT INTO t2 select * from t1;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
SELECT * from t2;
a b
drop table t2;
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
BEGIN;
INSERT INTO t2 values(100,100);
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
SELECT * from t2;
a b
100 100
COMMIT;
BEGIN;
INSERT INTO t2 values(101,101);
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
SELECT * from t2;
a b
100 100
101 101
ROLLBACK;
SELECT * from t2;
a b
100 100
TRUNCATE table t2;
INSERT INTO t2 select * from t1;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
SELECT * from t2;
a b
drop table t1,t2;
create table t1(f1 varchar(800) binary not null, key(f1))
character set utf8 collate utf8_general_ci;
Warnings:
Warning 1071 Specified key was too long; max key length is 765 bytes
insert into t1 values('aaa');
drop table t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB;
INSERT INTO t1 VALUES ( 1 , 1 , 1);
INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1;
INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1;
EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 5 NULL 128
EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort
DROP TABLE t1;
End of 5.0 tests
CREATE TABLE `t2` (
`k` int(11) NOT NULL auto_increment,
`a` int(11) default NULL,
`c` int(11) default NULL,
PRIMARY KEY (`k`),
UNIQUE KEY `idx_1` (`a`)
);
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
insert into t2 ( a ) values ( 7 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
last_insert_id()
2
select * from t2;
k a c
1 6 NULL
2 7 NULL
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
last_insert_id()
2
select last_insert_id(0);
last_insert_id(0)
0
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1;
select last_insert_id();
last_insert_id()
0
select * from t2;
k a c
1 6 2
2 7 NULL
insert ignore into t2 values (null,6,1),(10,8,1);
select last_insert_id();
last_insert_id()
0
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
select last_insert_id();
last_insert_id()
11
select * from t2;
k a c
1 6 2
2 7 NULL
10 8 1
11 15 1
12 20 1
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
ifnull( c,
0 ) + 1, k=last_insert_id(k);
select last_insert_id();
last_insert_id()
1
select * from t2;
k a c
1 6 3
2 7 NULL
10 8 1
11 15 1
12 20 1
drop table t2;
End of 5.1 tests
# t/innodb_mysql.test
#
# Last update:
# 2006-07-26 ML test refactored (MySQL 5.1)
# main testing code t/innodb_mysql.test -> include/mix1.inc
#
-- source include/have_innodb.inc
let $engine_type= InnoDB;
let $other_engine_type= MEMORY;
# InnoDB does support FOREIGN KEYFOREIGN KEYs
let $test_foreign_keys= 1;
--source include/mix1.inc
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003-2004 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
......
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libpage.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libpage.a
libpage_a_SOURCES = page0page.c page0cur.c page0zip.c libpage_a_SOURCES = page0page.c page0cur.c page0zip.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -24,3 +22,6 @@ noinst_HEADERS = pars0grm.h ...@@ -24,3 +22,6 @@ noinst_HEADERS = pars0grm.h
libpars_a_SOURCES = pars0grm.c lexyy.c pars0opt.c pars0pars.c pars0sym.c libpars_a_SOURCES = pars0grm.c lexyy.c pars0opt.c pars0pars.c pars0sym.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libque.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libque.a
libque_a_SOURCES = que0que.c libque_a_SOURCES = que0que.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libread.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libread.a
libread_a_SOURCES = read0read.c libread_a_SOURCES = read0read.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = librem.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = librem.a
librem_a_SOURCES = rem0rec.c rem0cmp.c librem_a_SOURCES = rem0rec.c rem0cmp.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -24,3 +22,6 @@ librow_a_SOURCES = row0ext.c\ ...@@ -24,3 +22,6 @@ librow_a_SOURCES = row0ext.c\
row0uins.c row0umod.c row0undo.c row0upd.c row0vers.c row0uins.c row0umod.c row0undo.c row0upd.c row0vers.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
...@@ -35,6 +35,9 @@ Created 9/17/2000 Heikki Tuuri ...@@ -35,6 +35,9 @@ Created 9/17/2000 Heikki Tuuri
/* A dummy variable used to fool the compiler */ /* A dummy variable used to fool the compiler */
ibool row_mysql_identically_false = FALSE; ibool row_mysql_identically_false = FALSE;
/* Provide optional 4.x backwards compatibility for 5.0 and above */
ibool row_rollback_on_timeout = FALSE;
/* List of tables we should drop in background. ALTER TABLE in MySQL requires /* List of tables we should drop in background. ALTER TABLE in MySQL requires
that the table handler can drop the table in background when there are no that the table handler can drop the table in background when there are no
queries to it any more. Protected by the kernel mutex. */ queries to it any more. Protected by the kernel mutex. */
...@@ -498,7 +501,9 @@ handle_new_error: ...@@ -498,7 +501,9 @@ handle_new_error:
return(TRUE); return(TRUE);
} else if (err == DB_DEADLOCK } else if (err == DB_DEADLOCK
|| err == DB_LOCK_TABLE_FULL) { || err == DB_LOCK_TABLE_FULL
|| (err == DB_LOCK_WAIT_TIMEOUT
&& row_rollback_on_timeout)) {
/* Roll back the whole transaction; this resolution was added /* Roll back the whole transaction; this resolution was added
to version 3.23.43 */ to version 3.23.43 */
...@@ -506,6 +511,10 @@ handle_new_error: ...@@ -506,6 +511,10 @@ handle_new_error:
} else if (err == DB_OUT_OF_FILE_SPACE } else if (err == DB_OUT_OF_FILE_SPACE
|| err == DB_LOCK_WAIT_TIMEOUT) { || err == DB_LOCK_WAIT_TIMEOUT) {
ut_ad(!(err == DB_LOCK_WAIT_TIMEOUT
&& row_rollback_on_timeout));
if (savept) { if (savept) {
/* Roll back the latest, possibly incomplete /* Roll back the latest, possibly incomplete
insertion or update */ insertion or update */
......
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003-2004 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libsrv.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libsrv.a
libsrv_a_SOURCES = srv0srv.c srv0que.c srv0start.c libsrv_a_SOURCES = srv0srv.c srv0que.c srv0start.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003-2004 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libsync.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libsync.a
libsync_a_SOURCES = sync0arr.c sync0rw.c sync0sync.c libsync_a_SOURCES = sync0arr.c sync0rw.c sync0sync.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libthr.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libthr.a
libthr_a_SOURCES = thr0loc.c libthr_a_SOURCES = thr0loc.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -23,3 +21,6 @@ libtrx_a_SOURCES = trx0purge.c trx0rec.c trx0roll.c trx0rseg.c\ ...@@ -23,3 +21,6 @@ libtrx_a_SOURCES = trx0purge.c trx0rec.c trx0roll.c trx0rseg.c\
trx0sys.c trx0trx.c trx0undo.c trx0sys.c trx0trx.c trx0undo.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libusr.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libusr.a
libusr_a_SOURCES = usr0sess.c libusr_a_SOURCES = usr0sess.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2001, 2003 MySQL AB & Innobase Oy
# & Innobase Oy
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; version 2 of the License.
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libut.a ...@@ -22,3 +20,6 @@ noinst_LIBRARIES = libut.a
libut_a_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c ut0vec.c ut0list.c ut0wqueue.c libut_a_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c ut0vec.c ut0list.c ut0wqueue.c
EXTRA_PROGRAMS = EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
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