Commit 27f9f14e authored by serg@serg.mylan's avatar serg@serg.mylan

Merge bk-internal.mysql.com:/home/bk/mysql-4.1/

into serg.mylan:/usr/home/serg/Abk/mysql-4.1
parents c9656ba5 5f346183
...@@ -171,6 +171,17 @@ info("PATH is $ENV{PATH}"); ...@@ -171,6 +171,17 @@ info("PATH is $ENV{PATH}");
log_timestamp(); log_timestamp();
$md5_result= safe_system("perl $ENV{HOME}/my_md5sum -c ${opt_distribution}.md5");
if ($md5_result != 0)
{
abort("MD5 check failed for $opt_distribution!");
}
else
{
info("SUCCESS: MD5 checks for $opt_distribution");
}
if (-x "$host/bin/mysqladmin") if (-x "$host/bin/mysqladmin")
{ {
log_system("$host/bin/mysqladmin $mysqladmin_args -S $mysql_unix_port -s shutdown"); log_system("$host/bin/mysqladmin $mysqladmin_args -S $mysql_unix_port -s shutdown");
...@@ -204,17 +215,6 @@ if ($opt_stage == 0) ...@@ -204,17 +215,6 @@ if ($opt_stage == 0)
safe_cd($host); safe_cd($host);
if ($opt_stage == 0 && ! $opt_use_old_distribution) if ($opt_stage == 0 && ! $opt_use_old_distribution)
{ {
$md5_result= safe_system("./my_md5sum -c ${opt_distribution}.md5");
if ($md5_result != 0)
{
abort("MD5 failed for $opt_distribution!");
}
else
{
info("SUCCESS: MD5 checks for $opt_distribution");
}
safe_system("gunzip < $opt_distribution | $tar xf -"); safe_system("gunzip < $opt_distribution | $tar xf -");
# Fix file times; This is needed because the time for files may be # Fix file times; This is needed because the time for files may be
...@@ -343,7 +343,9 @@ $tar_file=<$pwd/$host/mysql*.t*gz>; ...@@ -343,7 +343,9 @@ $tar_file=<$pwd/$host/mysql*.t*gz>;
abort ("Could not find tarball!") unless ($tar_file); abort ("Could not find tarball!") unless ($tar_file);
# Generate the MD5 for the binary distribution # Generate the MD5 for the binary distribution
safe_system("./my_md5sum $tar_file > ${tar_file}.md5}"); $tar_file=~ /(mysql[^\/]*)\.(tar\.gz|tgz)/;
$tar_file_lite= "$1.$2";
system("cd $pwd/$host; perl $ENV{HOME}/my_md5sum $tar_file_lite > ${tar_file_lite}.md5");
# #
# Unpack the binary distribution # Unpack the binary distribution
......
...@@ -2717,8 +2717,11 @@ btr_estimate_number_of_different_key_vals( ...@@ -2717,8 +2717,11 @@ btr_estimate_number_of_different_key_vals(
rec = page_rec_get_next(rec); rec = page_rec_get_next(rec);
} }
if (n_cols == dict_index_get_n_unique_in_tree(index)) { if (n_cols == dict_index_get_n_unique_in_tree(index)) {
/* We add one because we know that the first record
/* If there is more than one leaf page in the tree,
we add one because we know that the first record
on the page certainly had a different prefix than the on the page certainly had a different prefix than the
last record on the previous index page in the last record on the previous index page in the
alphabetical order. Before this fix, if there was alphabetical order. Before this fix, if there was
...@@ -2726,8 +2729,12 @@ btr_estimate_number_of_different_key_vals( ...@@ -2726,8 +2729,12 @@ btr_estimate_number_of_different_key_vals(
algorithm grossly underestimated the number of rows algorithm grossly underestimated the number of rows
in the table. */ in the table. */
if (btr_page_get_prev(page, &mtr) != FIL_NULL
|| btr_page_get_next(page, &mtr) != FIL_NULL) {
n_diff[n_cols]++; n_diff[n_cols]++;
} }
}
total_external_size += total_external_size +=
btr_rec_get_externally_stored_len(rec); btr_rec_get_externally_stored_len(rec);
......
...@@ -418,7 +418,8 @@ lock_release_off_kernel( ...@@ -418,7 +418,8 @@ lock_release_off_kernel(
/*====================*/ /*====================*/
trx_t* trx); /* in: transaction */ trx_t* trx); /* in: transaction */
/************************************************************************* /*************************************************************************
Releases table locks, and releases possible other transactions waiting Releases table locks explicitly requested with LOCK TABLES (indicated by
lock type LOCK_TABLE_EXP), and releases possible other transactions waiting
because of these locks. */ because of these locks. */
void void
...@@ -548,7 +549,7 @@ extern lock_sys_t* lock_sys; ...@@ -548,7 +549,7 @@ extern lock_sys_t* lock_sys;
/* Lock types */ /* Lock types */
#define LOCK_TABLE 16 /* these type values should be so high that */ #define LOCK_TABLE 16 /* these type values should be so high that */
#define LOCK_REC 32 /* they can be ORed to the lock mode */ #define LOCK_REC 32 /* they can be ORed to the lock mode */
#define LOCK_TABLE_EXP 80 /* explicit table lock */ #define LOCK_TABLE_EXP 80 /* explicit table lock (80 = 16 + 64) */
#define LOCK_TYPE_MASK 0xF0UL /* mask used to extract lock type from the #define LOCK_TYPE_MASK 0xF0UL /* mask used to extract lock type from the
type_mode field in a lock */ type_mode field in a lock */
/* Waiting lock flag */ /* Waiting lock flag */
......
...@@ -161,11 +161,12 @@ row_lock_table_autoinc_for_mysql( ...@@ -161,11 +161,12 @@ row_lock_table_autoinc_for_mysql(
row_prebuilt_t* prebuilt); /* in: prebuilt struct in the MySQL row_prebuilt_t* prebuilt); /* in: prebuilt struct in the MySQL
table handle */ table handle */
/************************************************************************* /*************************************************************************
Unlocks a table lock possibly reserved by trx. */ Unlocks all table locks explicitly requested by trx (with LOCK TABLES,
lock type LOCK_TABLE_EXP). */
void void
row_unlock_table_for_mysql( row_unlock_tables_for_mysql(
/*=======================*/ /*========================*/
trx_t* trx); /* in: transaction */ trx_t* trx); /* in: transaction */
/************************************************************************* /*************************************************************************
Sets a table lock on the table mentioned in prebuilt. */ Sets a table lock on the table mentioned in prebuilt. */
......
...@@ -157,6 +157,7 @@ extern ulint srv_test_n_mutexes; ...@@ -157,6 +157,7 @@ extern ulint srv_test_n_mutexes;
extern ulint srv_test_array_size; extern ulint srv_test_array_size;
extern ulint srv_activity_count; extern ulint srv_activity_count;
extern ulint srv_fatal_semaphore_wait_threshold;
extern mutex_t* kernel_mutex_temp;/* mutex protecting the server, trx structs, extern mutex_t* kernel_mutex_temp;/* mutex protecting the server, trx structs,
query threads, and lock table: we allocate query threads, and lock table: we allocate
......
...@@ -95,7 +95,7 @@ void ...@@ -95,7 +95,7 @@ void
sync_arr_wake_threads_if_sema_free(void); sync_arr_wake_threads_if_sema_free(void);
/*====================================*/ /*====================================*/
/************************************************************************** /**************************************************************************
Prints warnings of long semaphore waits to stderr. Currently > 120 sec. */ Prints warnings of long semaphore waits to stderr. */
void void
sync_array_print_long_waits(void); sync_array_print_long_waits(void);
......
...@@ -423,8 +423,9 @@ struct trx_struct{ ...@@ -423,8 +423,9 @@ struct trx_struct{
lock_t* auto_inc_lock; /* possible auto-inc lock reserved by lock_t* auto_inc_lock; /* possible auto-inc lock reserved by
the transaction; note that it is also the transaction; note that it is also
in the lock list trx_locks */ in the lock list trx_locks */
ulint n_tables_locked;/* number of table locks reserved by ulint n_lock_table_exp;/* number of explicit table locks
the transaction, stored in trx_locks */ (LOCK TABLES) reserved by the
transaction, stored in trx_locks */
UT_LIST_NODE_T(trx_t) UT_LIST_NODE_T(trx_t)
trx_list; /* list of transactions */ trx_list; /* list of transactions */
UT_LIST_NODE_T(trx_t) UT_LIST_NODE_T(trx_t)
......
...@@ -2023,9 +2023,8 @@ lock_grant( ...@@ -2023,9 +2023,8 @@ lock_grant(
lock->trx->auto_inc_lock = lock; lock->trx->auto_inc_lock = lock;
} else if (lock_get_type(lock) == LOCK_TABLE_EXP) { } else if (lock_get_type(lock) == LOCK_TABLE_EXP) {
ut_ad(lock_get_mode(lock) == LOCK_S ut_a(lock_get_mode(lock) == LOCK_S
|| lock_get_mode(lock) == LOCK_X); || lock_get_mode(lock) == LOCK_X);
lock->trx->n_tables_locked++;
} }
if (lock_print_waits) { if (lock_print_waits) {
...@@ -3203,6 +3202,10 @@ lock_table_create( ...@@ -3203,6 +3202,10 @@ lock_table_create(
lock->type_mode = type_mode | LOCK_TABLE; lock->type_mode = type_mode | LOCK_TABLE;
lock->trx = trx; lock->trx = trx;
if (lock_get_type(lock) == LOCK_TABLE_EXP) {
lock->trx->n_lock_table_exp++;
}
lock->un_member.tab_lock.table = table; lock->un_member.tab_lock.table = table;
UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock);
...@@ -3239,6 +3242,10 @@ lock_table_remove_low( ...@@ -3239,6 +3242,10 @@ lock_table_remove_low(
trx->auto_inc_lock = NULL; trx->auto_inc_lock = NULL;
} }
if (lock_get_type(lock) == LOCK_TABLE_EXP) {
lock->trx->n_lock_table_exp--;
}
UT_LIST_REMOVE(trx_locks, trx->trx_locks, lock); UT_LIST_REMOVE(trx_locks, trx->trx_locks, lock);
UT_LIST_REMOVE(un_member.tab_lock.locks, table->locks, lock); UT_LIST_REMOVE(un_member.tab_lock.locks, table->locks, lock);
} }
...@@ -3386,7 +3393,7 @@ lock_table( ...@@ -3386,7 +3393,7 @@ lock_table(
return(DB_SUCCESS); return(DB_SUCCESS);
} }
ut_ad(flags == 0 || flags == LOCK_TABLE_EXP); ut_a(flags == 0 || flags == LOCK_TABLE_EXP);
trx = thr_get_trx(thr); trx = thr_get_trx(thr);
...@@ -3418,10 +3425,7 @@ lock_table( ...@@ -3418,10 +3425,7 @@ lock_table(
lock_table_create(table, mode | flags, trx); lock_table_create(table, mode | flags, trx);
if (flags) { ut_a(!flags || mode == LOCK_S || mode == LOCK_X);
ut_ad(mode == LOCK_S || mode == LOCK_X);
trx->n_tables_locked++;
}
lock_mutex_exit_kernel(); lock_mutex_exit_kernel();
...@@ -3502,7 +3506,7 @@ lock_table_dequeue( ...@@ -3502,7 +3506,7 @@ lock_table_dequeue(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex)); ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_ad(lock_get_type(in_lock) == LOCK_TABLE || ut_a(lock_get_type(in_lock) == LOCK_TABLE ||
lock_get_type(in_lock) == LOCK_TABLE_EXP); lock_get_type(in_lock) == LOCK_TABLE_EXP);
lock = UT_LIST_GET_NEXT(un_member.tab_lock.locks, in_lock); lock = UT_LIST_GET_NEXT(un_member.tab_lock.locks, in_lock);
...@@ -3608,9 +3612,8 @@ lock_release_off_kernel( ...@@ -3608,9 +3612,8 @@ lock_release_off_kernel(
lock_table_dequeue(lock); lock_table_dequeue(lock);
if (lock_get_type(lock) == LOCK_TABLE_EXP) { if (lock_get_type(lock) == LOCK_TABLE_EXP) {
ut_ad(lock_get_mode(lock) == LOCK_S ut_a(lock_get_mode(lock) == LOCK_S
|| lock_get_mode(lock) == LOCK_X); || lock_get_mode(lock) == LOCK_X);
trx->n_tables_locked--;
} }
} }
...@@ -3631,11 +3634,12 @@ lock_release_off_kernel( ...@@ -3631,11 +3634,12 @@ lock_release_off_kernel(
mem_heap_empty(trx->lock_heap); mem_heap_empty(trx->lock_heap);
ut_a(trx->auto_inc_lock == NULL); ut_a(trx->auto_inc_lock == NULL);
ut_a(trx->n_tables_locked == 0); ut_a(trx->n_lock_table_exp == 0);
} }
/************************************************************************* /*************************************************************************
Releases table locks, and releases possible other transactions waiting Releases table locks explicitly requested with LOCK TABLES (indicated by
lock type LOCK_TABLE_EXP), and releases possible other transactions waiting
because of these locks. */ because of these locks. */
void void
...@@ -3660,7 +3664,7 @@ lock_release_tables_off_kernel( ...@@ -3660,7 +3664,7 @@ lock_release_tables_off_kernel(
count++; count++;
if (lock_get_type(lock) == LOCK_TABLE_EXP) { if (lock_get_type(lock) == LOCK_TABLE_EXP) {
ut_ad(lock_get_mode(lock) == LOCK_S ut_a(lock_get_mode(lock) == LOCK_S
|| lock_get_mode(lock) == LOCK_X); || lock_get_mode(lock) == LOCK_X);
if (trx->insert_undo || trx->update_undo) { if (trx->insert_undo || trx->update_undo) {
...@@ -3676,7 +3680,7 @@ lock_release_tables_off_kernel( ...@@ -3676,7 +3680,7 @@ lock_release_tables_off_kernel(
} }
lock_table_dequeue(lock); lock_table_dequeue(lock);
trx->n_tables_locked--;
lock = UT_LIST_GET_LAST(trx->trx_locks); lock = UT_LIST_GET_LAST(trx->trx_locks);
continue; continue;
} }
...@@ -3695,9 +3699,7 @@ lock_release_tables_off_kernel( ...@@ -3695,9 +3699,7 @@ lock_release_tables_off_kernel(
lock = UT_LIST_GET_PREV(trx_locks, lock); lock = UT_LIST_GET_PREV(trx_locks, lock);
} }
mem_heap_empty(trx->lock_heap); ut_a(trx->n_lock_table_exp == 0);
ut_a(trx->n_tables_locked == 0);
} }
/************************************************************************* /*************************************************************************
......
...@@ -370,6 +370,32 @@ row_ins_cascade_ancestor_updates_table( ...@@ -370,6 +370,32 @@ row_ins_cascade_ancestor_updates_table(
return(FALSE); return(FALSE);
} }
/*************************************************************************
Returns the number of ancestor UPDATE or DELETE nodes of a
cascaded update/delete node. */
static
ulint
row_ins_cascade_n_ancestors(
/*========================*/
/* out: number of ancestors */
que_node_t* node) /* in: node in a query graph */
{
que_node_t* parent;
ulint n_ancestors = 0;
parent = que_node_get_parent(node);
while (que_node_get_type(parent) == QUE_NODE_UPDATE) {
n_ancestors++;
parent = que_node_get_parent(parent);
ut_a(parent);
}
return(n_ancestors);
}
/********************************************************************** /**********************************************************************
Calculates the update vector node->cascade->update for a child table in Calculates the update vector node->cascade->update for a child table in
a cascaded update. */ a cascaded update. */
...@@ -615,6 +641,34 @@ row_ins_foreign_report_add_err( ...@@ -615,6 +641,34 @@ row_ins_foreign_report_add_err(
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
} }
/*************************************************************************
Invalidate the query cache for the given table. */
static
void
row_ins_invalidate_query_cache(
/*===========================*/
que_thr_t* thr, /* in: query thread whose run_node
is an update node */
const char* name) /* in: table name prefixed with
database name and a '/' character */
{
char* buf;
char* ptr;
ulint len = strlen(name) + 1;
buf = mem_strdupl(name, len);
ptr = strchr(buf, '/');
ut_a(ptr);
*ptr = '\0';
/* We call a function in ha_innodb.cc */
#ifndef UNIV_HOTBACKUP
innobase_invalidate_query_cache(thr_get_trx(thr), buf, len);
#endif
mem_free(buf);
}
/************************************************************************* /*************************************************************************
Perform referential actions or checks when a parent row is deleted or updated Perform referential actions or checks when a parent row is deleted or updated
and the constraint had an ON DELETE or ON UPDATE condition which was not and the constraint had an ON DELETE or ON UPDATE condition which was not
...@@ -650,26 +704,15 @@ row_ins_foreign_check_on_constraint( ...@@ -650,26 +704,15 @@ row_ins_foreign_check_on_constraint(
ulint n_to_update; ulint n_to_update;
ulint err; ulint err;
ulint i; ulint i;
char* ptr;
char* table_name_buf;
ut_a(thr && foreign && pcur && mtr); ut_a(thr && foreign && pcur && mtr);
/* Since we are going to delete or update a row, we have to invalidate /* Since we are going to delete or update a row, we have to invalidate
the MySQL query cache for table */ the MySQL query cache for table */
table_name_buf = mem_strdup(table->name); row_ins_invalidate_query_cache(thr, table->name);
ptr = strchr(table_name_buf, '/');
ut_a(ptr);
*ptr = '\0';
#ifndef UNIV_HOTBACKUP
/* We call a function in ha_innodb.cc */
innobase_invalidate_query_cache(thr_get_trx(thr), table_name_buf,
strlen(table->name) + 1);
#endif
mem_free(table_name_buf);
node = thr->run_node; node = thr->run_node;
...@@ -757,6 +800,16 @@ row_ins_foreign_check_on_constraint( ...@@ -757,6 +800,16 @@ row_ins_foreign_check_on_constraint(
goto nonstandard_exit_func; goto nonstandard_exit_func;
} }
if (row_ins_cascade_n_ancestors(cascade) >= 15) {
err = DB_ROW_IS_REFERENCED;
row_ins_foreign_report_err(
(char*)"Trying a too deep cascaded delete or update\n",
thr, foreign, btr_pcur_get_rec(pcur), entry);
goto nonstandard_exit_func;
}
index = btr_pcur_get_btr_cur(pcur)->index; index = btr_pcur_get_btr_cur(pcur)->index;
ut_a(index == foreign->foreign_index); ut_a(index == foreign->foreign_index);
......
...@@ -741,14 +741,15 @@ run_again: ...@@ -741,14 +741,15 @@ run_again:
} }
/************************************************************************* /*************************************************************************
Unlocks a table lock possibly reserved by trx. */ Unlocks all table locks explicitly requested by trx (with LOCK TABLES,
lock type LOCK_TABLE_EXP). */
void void
row_unlock_table_for_mysql( row_unlock_tables_for_mysql(
/*=======================*/ /*========================*/
trx_t* trx) /* in: transaction */ trx_t* trx) /* in: transaction */
{ {
if (!trx->n_tables_locked) { if (!trx->n_lock_table_exp) {
return; return;
} }
...@@ -3176,6 +3177,11 @@ row_check_table_for_mysql( ...@@ -3176,6 +3177,11 @@ row_check_table_for_mysql(
prebuilt->trx->isolation_level = TRX_ISO_REPEATABLE_READ; prebuilt->trx->isolation_level = TRX_ISO_REPEATABLE_READ;
/* Enlarge the fatal lock wait timeout during CHECK TABLE. */
mutex_enter(&kernel_mutex);
srv_fatal_semaphore_wait_threshold += 7200; /* 2 hours */
mutex_exit(&kernel_mutex);
index = dict_table_get_first_index(table); index = dict_table_get_first_index(table);
while (index != NULL) { while (index != NULL) {
...@@ -3223,6 +3229,11 @@ row_check_table_for_mysql( ...@@ -3223,6 +3229,11 @@ row_check_table_for_mysql(
ret = DB_ERROR; ret = DB_ERROR;
} }
/* Restore the fatal lock wait timeout after CHECK TABLE. */
mutex_enter(&kernel_mutex);
srv_fatal_semaphore_wait_threshold -= 7200; /* 2 hours */
mutex_exit(&kernel_mutex);
prebuilt->trx->op_info = ""; prebuilt->trx->op_info = "";
return(ret); return(ret);
......
...@@ -55,6 +55,9 @@ ibool srv_lower_case_table_names = FALSE; ...@@ -55,6 +55,9 @@ ibool srv_lower_case_table_names = FALSE;
in the server */ in the server */
ulint srv_activity_count = 0; ulint srv_activity_count = 0;
/* The following is the maximum allowed duration of a lock wait. */
ulint srv_fatal_semaphore_wait_threshold = 600;
ibool srv_lock_timeout_and_monitor_active = FALSE; ibool srv_lock_timeout_and_monitor_active = FALSE;
ibool srv_error_monitor_active = FALSE; ibool srv_error_monitor_active = FALSE;
......
...@@ -1115,7 +1115,7 @@ NetWare. */ ...@@ -1115,7 +1115,7 @@ NetWare. */
srv_monitor_file_name = mem_alloc( srv_monitor_file_name = mem_alloc(
strlen(fil_path_to_mysql_datadir) + strlen(fil_path_to_mysql_datadir) +
20 + sizeof "/innodb_status."); 20 + sizeof "/innodb_status.");
sprintf(srv_monitor_file_name, "%s/innodb.status.%lu", sprintf(srv_monitor_file_name, "%s/innodb_status.%lu",
fil_path_to_mysql_datadir, os_proc_get_number()); fil_path_to_mysql_datadir, os_proc_get_number());
srv_monitor_file = fopen(srv_monitor_file_name, "w+"); srv_monitor_file = fopen(srv_monitor_file_name, "w+");
if (!srv_monitor_file) { if (!srv_monitor_file) {
......
...@@ -895,7 +895,7 @@ sync_arr_wake_threads_if_sema_free(void) ...@@ -895,7 +895,7 @@ sync_arr_wake_threads_if_sema_free(void)
} }
/************************************************************************** /**************************************************************************
Prints warnings of long semaphore waits to stderr. Currently > 120 sec. */ Prints warnings of long semaphore waits to stderr. */
void void
sync_array_print_long_waits(void) sync_array_print_long_waits(void)
...@@ -905,6 +905,7 @@ sync_array_print_long_waits(void) ...@@ -905,6 +905,7 @@ sync_array_print_long_waits(void)
ibool old_val; ibool old_val;
ibool noticed = FALSE; ibool noticed = FALSE;
ulint i; ulint i;
ulint fatal_timeout = srv_fatal_semaphore_wait_threshold;
for (i = 0; i < sync_primary_wait_array->n_cells; i++) { for (i = 0; i < sync_primary_wait_array->n_cells; i++) {
...@@ -919,12 +920,13 @@ sync_array_print_long_waits(void) ...@@ -919,12 +920,13 @@ sync_array_print_long_waits(void)
} }
if (cell->wait_object != NULL if (cell->wait_object != NULL
&& difftime(time(NULL), cell->reservation_time) > 600) { && difftime(time(NULL), cell->reservation_time)
> fatal_timeout) {
fputs( fprintf(stderr,
"InnoDB: Error: semaphore wait has lasted > 600 seconds\n" "InnoDB: Error: semaphore wait has lasted > %lu seconds\n"
"InnoDB: We intentionally crash the server, because it appears to be hung.\n", "InnoDB: We intentionally crash the server, because it appears to be hung.\n",
stderr); fatal_timeout);
ut_error; ut_error;
} }
......
...@@ -151,7 +151,7 @@ trx_create( ...@@ -151,7 +151,7 @@ trx_create(
trx->n_tickets_to_enter_innodb = 0; trx->n_tickets_to_enter_innodb = 0;
trx->auto_inc_lock = NULL; trx->auto_inc_lock = NULL;
trx->n_tables_locked = 0; trx->n_lock_table_exp = 0;
trx->read_view_heap = mem_heap_create(256); trx->read_view_heap = mem_heap_create(256);
trx->read_view = NULL; trx->read_view = NULL;
...@@ -279,7 +279,7 @@ trx_free( ...@@ -279,7 +279,7 @@ trx_free(
ut_a(!trx->has_search_latch); ut_a(!trx->has_search_latch);
ut_a(!trx->auto_inc_lock); ut_a(!trx->auto_inc_lock);
ut_a(!trx->n_tables_locked); ut_a(!trx->n_lock_table_exp);
ut_a(trx->dict_operation_lock_mode == 0); ut_a(trx->dict_operation_lock_mode == 0);
......
drop table if exists t1, t2;
CREATE TABLE t1 ( a int );
INSERT INTO t1 VALUES (1),(2),(1);
CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1;
ERROR 23000: Duplicate entry '1' for key 1
select * from t2;
ERROR 42S02: Table 'test.t2' doesn't exist
CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1;
ERROR 23000: Duplicate entry '1' for key 1
select * from t2;
ERROR 42S02: Table 'test.t2' doesn't exist
CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1;
ERROR 23000: Duplicate entry '1' for key 1
select * from t2;
ERROR 42S02: Table 'test.t2' doesn't exist
CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1;
ERROR 23000: Duplicate entry '1' for key 1
select * from t2;
ERROR 42S02: Table 'test.t2' doesn't exist
...@@ -157,7 +157,7 @@ teststring ...@@ -157,7 +157,7 @@ teststring
teststring teststring
explain select * from t1 order by text1; explain select * from t1 order by text1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL key1 32 NULL 4 Using index 1 SIMPLE t1 index NULL key1 32 NULL 3 Using index
alter table t1 modify text1 char(32) binary not null; alter table t1 modify text1 char(32) binary not null;
select * from t1 order by text1; select * from t1 order by text1;
text1 text1
......
...@@ -1345,6 +1345,18 @@ ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fail ...@@ -1345,6 +1345,18 @@ ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fail
update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
ERROR 42S02: Unknown table 't1' in where clause ERROR 42S02: Unknown table 't1' in where clause
drop table t3,t2,t1; drop table t3,t2,t1;
create table t1(
id int primary key,
pid int,
index(pid),
foreign key(pid) references t1(id) on delete cascade) engine=innodb;
insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
delete from t1 where id=0;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
delete from t1 where id=15;
delete from t1 where id=0;
drop table t1;
CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB; CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
(stamp))ENGINE=InnoDB; (stamp))ENGINE=InnoDB;
......
...@@ -302,18 +302,18 @@ ERROR HY000: This command is not supported in the prepared statement protocol ye ...@@ -302,18 +302,18 @@ ERROR HY000: This command is not supported in the prepared statement protocol ye
prepare stmt4 from ' show storage engines '; prepare stmt4 from ' show storage engines ';
execute stmt4; execute stmt4;
Engine Support Comment Engine Support Comment
MyISAM YES/NO Default type from 3.23 with great performance MyISAM YES/NO Default engine as of MySQL 3.23 with great performance
HEAP YES/NO Hash based, stored in memory, useful for temporary tables HEAP YES/NO Alias for MEMORY
MEMORY YES/NO Alias for HEAP MEMORY YES/NO Hash based, stored in memory, useful for temporary tables
MERGE YES/NO Collection of identical MyISAM tables MERGE YES/NO Collection of identical MyISAM tables
MRG_MYISAM YES/NO Alias for MERGE MRG_MYISAM YES/NO Alias for MERGE
ISAM YES/NO Obsolete table type; Is replaced by MyISAM ISAM YES/NO Obsolete storage engine, now replaced by MyISAM
MRG_ISAM YES/NO Obsolete table type; Is replaced by MRG_MYISAM MRG_ISAM YES/NO Obsolete storage engine, now replaced by MERGE
InnoDB YES/NO Supports transactions, row-level locking and foreign keys InnoDB YES/NO Supports transactions, row-level locking, and foreign keys
INNOBASE YES/NO Alias for INNODB INNOBASE YES/NO Alias for INNODB
BDB YES/NO Supports transactions and page-level locking BDB YES/NO Supports transactions and page-level locking
BERKELEYDB YES/NO Alias for BDB BERKELEYDB YES/NO Alias for BDB
NDBCLUSTER YES/NO Clustered, fault tolerant memory based tables NDBCLUSTER YES/NO Clustered, fault-tolerant, memory-based tables
NDB YES/NO Alias for NDBCLUSTER NDB YES/NO Alias for NDBCLUSTER
EXAMPLE YES/NO Example storage engine EXAMPLE YES/NO Example storage engine
ARCHIVE YES/NO Archive storage engine ARCHIVE YES/NO Archive storage engine
......
...@@ -572,7 +572,7 @@ def ref 253 1024 0 Y 0 31 63 ...@@ -572,7 +572,7 @@ def ref 253 1024 0 Y 0 31 63
def rows 8 10 1 N 32801 0 8 def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 63 def Extra 253 255 44 N 1 31 63
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2 6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
...@@ -581,7 +581,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -581,7 +581,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 ; execute stmt1 ;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2 6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
...@@ -643,7 +643,7 @@ def ref 253 1024 0 Y 0 31 63 ...@@ -643,7 +643,7 @@ def ref 253 1024 0 Y 0 31 63
def rows 8 10 1 N 32801 0 8 def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 63 def Extra 253 255 44 N 1 31 63
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2 6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
...@@ -653,7 +653,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -653,7 +653,7 @@ id select_type table type possible_keys key key_len ref rows Extra
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ; @arg07, @arg08, @arg09 ;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 3 1 PRIMARY t_many_col_types ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2 6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
......
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop table if exists t1, t2;
create table t1 (a int);
drop table t1, t2;
ERROR 42S02: Unknown table 't2'
...@@ -120,9 +120,9 @@ DOCID DOCNAME DOCTYPEID FOLDERID AUTHOR CREATED TITLE SUBTITLE DOCABSTRACT PUBLI ...@@ -120,9 +120,9 @@ DOCID DOCNAME DOCTYPEID FOLDERID AUTHOR CREATED TITLE SUBTITLE DOCABSTRACT PUBLI
c373e9f5ad07993f3859444553544200 Last Discussion c373e9f5ad079174ff17444553544200 c373e9f5ad0796c0eca4444553544200 Goldilocks 2003-06-09 11:21:06 Title: Last Discussion NULL Setting new abstract and keeping doc checked out 2003-06-09 10:51:26 2003-06-09 10:51:26 NULL NULL NULL 03eea05112b845949f3fd03278b5fe43 2003-06-09 11:21:06 admin 0 NULL Discussion NULL NULL c373e9f5ad07993f3859444553544200 Last Discussion c373e9f5ad079174ff17444553544200 c373e9f5ad0796c0eca4444553544200 Goldilocks 2003-06-09 11:21:06 Title: Last Discussion NULL Setting new abstract and keeping doc checked out 2003-06-09 10:51:26 2003-06-09 10:51:26 NULL NULL NULL 03eea05112b845949f3fd03278b5fe43 2003-06-09 11:21:06 admin 0 NULL Discussion NULL NULL
EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion'; EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL DDOCTYPEID_IDX NULL NULL NULL 10 Using where 1 PRIMARY t1 system PRIMARY NULL NULL NULL 0 const row not found
1 PRIMARY t2 ALL DDOCTYPEID_IDX NULL NULL NULL 9 Using where
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 32 test.t2.DOCTYPEID 1 1 PRIMARY t4 eq_ref PRIMARY PRIMARY 32 test.t2.DOCTYPEID 1
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 32 test.t2.DOCID 1
2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where 2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
3 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where 3 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
4 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where 4 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
......
# Testcase for BUG#4551
# The bug was that when the table was TEMPORARY, it was not deleted if
# the CREATE SELECT failed (the code intended too, but it actually
# didn't). And as the CREATE TEMPORARY TABLE was not written to the
# binlog if it was a transactional table, it resulted in an
# inconsistency between binlog and the internal list of temp tables.
-- source include/have_innodb.inc
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
CREATE TABLE t1 ( a int );
INSERT INTO t1 VALUES (1),(2),(1);
--error 1062;
CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1;
--error 1146;
select * from t2;
--error 1062;
CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1;
--error 1146;
select * from t2;
--error 1062;
CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1;
--error 1146;
select * from t2;
--error 1062;
CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1;
--error 1146;
select * from t2;
...@@ -959,6 +959,23 @@ update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id ...@@ -959,6 +959,23 @@ update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id
update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
drop table t3,t2,t1; drop table t3,t2,t1;
#
# test for recursion depth limit
#
create table t1(
id int primary key,
pid int,
index(pid),
foreign key(pid) references t1(id) on delete cascade) engine=innodb;
insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
-- error 1217
delete from t1 where id=0;
delete from t1 where id=15;
delete from t1 where id=0;
drop table t1;
# #
# Test timestamps # Test timestamps
# #
......
# Testcase for BUG#4552 (DROP on two tables, one of which does not
# exist, must be binlogged with a non-zero error code)
source include/master-slave.inc;
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
create table t1 (a int);
--error 1051;
drop table t1, t2;
save_master_pos;
connection slave;
sync_with_master;
...@@ -4783,8 +4783,8 @@ ha_innobase::external_lock( ...@@ -4783,8 +4783,8 @@ ha_innobase::external_lock(
trx->n_mysql_tables_in_use--; trx->n_mysql_tables_in_use--;
prebuilt->mysql_has_locked = FALSE; prebuilt->mysql_has_locked = FALSE;
auto_inc_counter_for_this_stat = 0; auto_inc_counter_for_this_stat = 0;
if (trx->n_tables_locked) { if (trx->n_lock_table_exp) {
row_unlock_table_for_mysql(trx); row_unlock_tables_for_mysql(trx);
} }
/* If the MySQL lock count drops to zero we know that the current SQL /* If the MySQL lock count drops to zero we know that the current SQL
......
...@@ -1696,9 +1696,13 @@ void select_create::abort() ...@@ -1696,9 +1696,13 @@ void select_create::abort()
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
enum db_type table_type=table->db_type; enum db_type table_type=table->db_type;
if (!table->tmp_table) if (!table->tmp_table)
{
hash_delete(&open_cache,(byte*) table); hash_delete(&open_cache,(byte*) table);
if (!create_info->table_existed) if (!create_info->table_existed)
quick_rm_table(table_type,db,name); quick_rm_table(table_type, db, name);
}
else if (!create_info->table_existed)
close_temporary_table(thd, db, name);
table=0; table=0;
} }
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
......
...@@ -310,6 +310,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -310,6 +310,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
{ {
if (transactional_table) if (transactional_table)
ha_autocommit_or_rollback(thd,error); ha_autocommit_or_rollback(thd,error);
if (read_file_from_client)
while (!read_info.next_line())
;
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
......
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