Commit faec4797 authored by marko's avatar marko

branches/zip: Merge 1664:1783 from trunk.

parent fac65f0b
This diff is collapsed.
...@@ -1189,11 +1189,6 @@ ibuf_dummy_index_free( ...@@ -1189,11 +1189,6 @@ ibuf_dummy_index_free(
dict_mem_table_free(table); dict_mem_table_free(table);
} }
void
dict_index_print_low(
/*=================*/
dict_index_t* index); /* in: index */
/************************************************************************* /*************************************************************************
Builds the entry to insert into a non-clustered index when we have the Builds the entry to insert into a non-clustered index when we have the
corresponding record in an ibuf index. */ corresponding record in an ibuf index. */
......
...@@ -340,11 +340,11 @@ struct dict_table_struct{ ...@@ -340,11 +340,11 @@ struct dict_table_struct{
unsigned n_cols:10;/* number of columns */ unsigned n_cols:10;/* number of columns */
dict_col_t* cols; /* array of column descriptions */ dict_col_t* cols; /* array of column descriptions */
const char* col_names; const char* col_names;
/* n_def column names packed in an /* Column names packed in a character string
"name1\0name2\0...nameN\0" array. until "name1\0name2\0...nameN\0". Until
n_def reaches n_cols, this is allocated with the string contains n_cols, it will be
ut_malloc, and the final size array is allocated from a temporary heap. The final
allocated through the table's heap. */ string will be allocated from table->heap. */
hash_node_t name_hash; /* hash chain node */ hash_node_t name_hash; /* hash chain node */
hash_node_t id_hash; /* hash chain node */ hash_node_t id_hash; /* hash chain node */
UT_LIST_BASE_NODE_T(dict_index_t) UT_LIST_BASE_NODE_T(dict_index_t)
...@@ -444,6 +444,16 @@ struct dict_table_struct{ ...@@ -444,6 +444,16 @@ struct dict_table_struct{
UT_LIST_BASE_NODE_T(row_prebuilt_t) prebuilts; UT_LIST_BASE_NODE_T(row_prebuilt_t) prebuilts;
/* base node for the prebuilts defined /* base node for the prebuilts defined
for the table */ for the table */
ulong n_waiting_or_granted_auto_inc_locks;
/* This counter is used to track the number
of granted and pending autoinc locks on this
table. This value is set after acquiring the
kernel mutex but we peek the contents to
determine whether other transactions have
acquired the AUTOINC lock or not. Of course
only one transaction can be granted the
lock but there can be multiple waiters. */
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
ulint magic_n;/* magic number */ ulint magic_n;/* magic number */
# define DICT_TABLE_MAGIC_N 76333786 # define DICT_TABLE_MAGIC_N 76333786
......
...@@ -364,6 +364,17 @@ mach_write_to_2_little_endian( ...@@ -364,6 +364,17 @@ mach_write_to_2_little_endian(
byte* dest, /* in: where to write */ byte* dest, /* in: where to write */
ulint n); /* in: unsigned long int to write */ ulint n); /* in: unsigned long int to write */
/*************************************************************
Convert integral type from storage byte order (big endian) to
host byte order. */
UNIV_INLINE
void
mach_read_int_type(
/*===============*/
byte* dest, /* out: where to write */
const byte* src, /* in: where to read from */
ulint len, /* in: length of src */
ibool unsigned_type); /* in: signed or unsigned flag */
#ifndef UNIV_NONINL #ifndef UNIV_NONINL
#include "mach0data.ic" #include "mach0data.ic"
#endif #endif
......
...@@ -7,6 +7,8 @@ to the machine format. ...@@ -7,6 +7,8 @@ to the machine format.
Created 11/28/1995 Heikki Tuuri Created 11/28/1995 Heikki Tuuri
***********************************************************************/ ***********************************************************************/
#include "ut0mem.h"
/*********************************************************** /***********************************************************
The following function is used to store data in one byte. */ The following function is used to store data in one byte. */
UNIV_INLINE UNIV_INLINE
...@@ -723,3 +725,38 @@ mach_write_to_2_little_endian( ...@@ -723,3 +725,38 @@ mach_write_to_2_little_endian(
*dest = (byte)(n & 0xFFUL); *dest = (byte)(n & 0xFFUL);
} }
/*************************************************************
Convert integral type from storage byte order (big endian) to
host byte order. */
UNIV_INLINE
void
mach_read_int_type(
/*===============*/
byte* dest, /* out: where to write */
const byte* src, /* in: where to read from */
ulint len, /* in: length of src */
ibool unsigned_type) /* in: signed or unsigned flag */
{
#ifdef WORDS_BIGENDIAN
memcpy(dest, src, len);
if (!unsigned_type) {
dest[0] ^= 128;
}
#else
byte* ptr;
/* Convert integer data from Innobase to a little-endian format,
sign bit restored to normal. */
for (ptr = dest + len; ptr != dest; ++src) {
--ptr;
*ptr = *src;
}
if (!unsigned_type) {
dest[len - 1] ^= 128;
}
#endif
}
...@@ -340,9 +340,11 @@ row_mysql_unfreeze_data_dictionary( ...@@ -340,9 +340,11 @@ row_mysql_unfreeze_data_dictionary(
trx_t* trx); /* in: transaction */ trx_t* trx); /* in: transaction */
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
/************************************************************************* /*************************************************************************
Does a table creation operation for MySQL. If the name of the created Drops a table for MySQL. If the name of the table ends in
table ends to characters INNODB_MONITOR, then this also starts one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
printing of monitor output by the master thread. */ "innodb_table_monitor", then this will also start the printing of monitor
output by the master thread. If the table name ends in "innodb_mem_validate",
InnoDB will try to invoke mem_validate(). */
int int
row_create_table_for_mysql( row_create_table_for_mysql(
...@@ -420,8 +422,9 @@ row_truncate_table_for_mysql( ...@@ -420,8 +422,9 @@ row_truncate_table_for_mysql(
dict_table_t* table, /* in: table handle */ dict_table_t* table, /* in: table handle */
trx_t* trx); /* in: transaction handle */ trx_t* trx); /* in: transaction handle */
/************************************************************************* /*************************************************************************
Drops a table for MySQL. If the name of the dropped table ends to Drops a table for MySQL. If the name of the dropped table ends in
characters INNODB_MONITOR, then this also stops printing of monitor one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
"innodb_table_monitor", then this will also stop the printing of monitor
output by the master thread. */ output by the master thread. */
int int
......
...@@ -101,6 +101,7 @@ void ...@@ -101,6 +101,7 @@ void
rw_lock_free( rw_lock_free(
/*=========*/ /*=========*/
rw_lock_t* lock); /* in: rw-lock */ rw_lock_t* lock); /* in: rw-lock */
#ifdef UNIV_DEBUG
/********************************************************************** /**********************************************************************
Checks that the rw-lock has been initialized and that there are no Checks that the rw-lock has been initialized and that there are no
simultaneous shared and exclusive locks. */ simultaneous shared and exclusive locks. */
...@@ -109,6 +110,7 @@ ibool ...@@ -109,6 +110,7 @@ ibool
rw_lock_validate( rw_lock_validate(
/*=============*/ /*=============*/
rw_lock_t* lock); rw_lock_t* lock);
#endif /* UNIV_DEBUG */
/****************************************************************** /******************************************************************
NOTE! The following macros should be used in rw s-locking, not the NOTE! The following macros should be used in rw s-locking, not the
corresponding function. */ corresponding function. */
......
...@@ -231,7 +231,7 @@ rw_lock_s_lock_func( ...@@ -231,7 +231,7 @@ rw_lock_s_lock_func(
owns an s-lock here, it may end up in a deadlock with another thread owns an s-lock here, it may end up in a deadlock with another thread
which requests an x-lock here. Therefore, we will forbid recursive which requests an x-lock here. Therefore, we will forbid recursive
s-locking of a latch: the following assert will warn the programmer s-locking of a latch: the following assert will warn the programmer
of the possibility of a tjis kind of deadlock. If we want to implement of the possibility of this kind of a deadlock. If we want to implement
safe recursive s-locking, we should keep in a list the thread ids of safe recursive s-locking, we should keep in a list the thread ids of
the threads which have s-locked a latch. This would use some CPU the threads which have s-locked a latch. This would use some CPU
time. */ time. */
......
...@@ -510,31 +510,6 @@ struct trx_struct{ ...@@ -510,31 +510,6 @@ struct trx_struct{
ib_longlong mysql_log_offset;/* if MySQL binlog is used, this field ib_longlong mysql_log_offset;/* if MySQL binlog is used, this field
contains the end offset of the binlog contains the end offset of the binlog
entry */ entry */
const char* mysql_master_log_file_name;
/* if the database server is a MySQL
replication slave, we have here the
master binlog name up to which
replication has processed; otherwise
this is a pointer to a null
character */
ib_longlong mysql_master_log_pos;
/* if the database server is a MySQL
replication slave, this is the
position in the log file up to which
replication has processed */
/* A MySQL variable mysql_thd->synchronous_repl tells if we have
to use synchronous replication. See ha_innodb.cc. */
char* repl_wait_binlog_name;/* NULL, or if synchronous MySQL
replication is used, the binlog name
up to which we must communicate the
binlog to the slave, before returning
from a commit; this is the same as
mysql_log_file_name, but we allocate
and copy the name to a separate buffer
here */
ib_longlong repl_wait_binlog_pos;/* see above at
repl_wait_binlog_name */
os_thread_id_t mysql_thread_id;/* id of the MySQL thread associated os_thread_id_t mysql_thread_id;/* id of the MySQL thread associated
with this transaction object */ with this transaction object */
ulint mysql_process_no;/* since in Linux, 'top' reports ulint mysql_process_no;/* since in Linux, 'top' reports
......
...@@ -63,7 +63,7 @@ ut_test_malloc( ...@@ -63,7 +63,7 @@ ut_test_malloc(
/* out: TRUE if succeeded */ /* out: TRUE if succeeded */
ulint n); /* in: try to allocate this many bytes */ ulint n); /* in: try to allocate this many bytes */
/************************************************************************** /**************************************************************************
Frees a memory bloock allocated with ut_malloc. */ Frees a memory block allocated with ut_malloc. */
void void
ut_free( ut_free(
......
...@@ -3544,6 +3544,10 @@ lock_table_create( ...@@ -3544,6 +3544,10 @@ lock_table_create(
ut_ad(table && trx); ut_ad(table && trx);
ut_ad(mutex_own(&kernel_mutex)); ut_ad(mutex_own(&kernel_mutex));
if ((type_mode & LOCK_MODE_MASK) == LOCK_AUTO_INC) {
++table->n_waiting_or_granted_auto_inc_locks;
}
if (type_mode == LOCK_AUTO_INC) { if (type_mode == LOCK_AUTO_INC) {
/* Only one trx can have the lock on the table /* Only one trx can have the lock on the table
at a time: we may use the memory preallocated at a time: we may use the memory preallocated
...@@ -3594,6 +3598,9 @@ lock_table_remove_low( ...@@ -3594,6 +3598,9 @@ lock_table_remove_low(
if (lock == trx->auto_inc_lock) { if (lock == trx->auto_inc_lock) {
trx->auto_inc_lock = NULL; trx->auto_inc_lock = NULL;
ut_a(table->n_waiting_or_granted_auto_inc_locks > 0);
--table->n_waiting_or_granted_auto_inc_locks;
} }
UT_LIST_REMOVE(trx_locks, trx->trx_locks, lock); UT_LIST_REMOVE(trx_locks, trx->trx_locks, lock);
......
...@@ -479,6 +479,7 @@ passwd varchar(32) binary DEFAULT '' NOT NULL, ...@@ -479,6 +479,7 @@ passwd varchar(32) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE ggid (ggid) UNIQUE ggid (ggid)
) ENGINE=innodb; ) ENGINE=innodb;
set global innodb_autoinc_lock_mode = 0;
insert into t1 (ggid,passwd) values ('test1','xxx'); insert into t1 (ggid,passwd) values ('test1','xxx');
insert into t1 (ggid,passwd) values ('test2','yyy'); insert into t1 (ggid,passwd) values ('test2','yyy');
insert into t1 (ggid,passwd) values ('test2','this will fail'); insert into t1 (ggid,passwd) values ('test2','this will fail');
......
...@@ -345,6 +345,9 @@ CREATE TABLE t1 ( ...@@ -345,6 +345,9 @@ CREATE TABLE t1 (
UNIQUE ggid (ggid) UNIQUE ggid (ggid)
) ENGINE=innodb; ) ENGINE=innodb;
# Set to old style locking
set global innodb_autoinc_lock_mode = 0;
insert into t1 (ggid,passwd) values ('test1','xxx'); insert into t1 (ggid,passwd) values ('test1','xxx');
insert into t1 (ggid,passwd) values ('test2','yyy'); insert into t1 (ggid,passwd) values ('test2','yyy');
-- error ER_DUP_ENTRY -- error ER_DUP_ENTRY
......
...@@ -1793,10 +1793,11 @@ row_mysql_unlock_data_dictionary( ...@@ -1793,10 +1793,11 @@ row_mysql_unlock_data_dictionary(
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
/************************************************************************* /*************************************************************************
Does a table creation operation for MySQL. If the name of the table Drops a table for MySQL. If the name of the table ends in
to be created is equal with one of the predefined magic table names, one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
then this also starts printing the corresponding monitor output by "innodb_table_monitor", then this will also start the printing of monitor
the master thread. */ output by the master thread. If the table name ends in "innodb_mem_validate",
InnoDB will try to invoke mem_validate(). */
int int
row_create_table_for_mysql( row_create_table_for_mysql(
...@@ -3032,9 +3033,10 @@ funct_exit: ...@@ -3032,9 +3033,10 @@ funct_exit:
} }
/************************************************************************* /*************************************************************************
Drops a table for MySQL. If the name of the table to be dropped is equal Drops a table for MySQL. If the name of the dropped table ends in
with one of the predefined magic table names, then this also stops printing one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
the corresponding monitor output by the master thread. */ "innodb_table_monitor", then this will also stop the printing of monitor
output by the master thread. */
int int
row_drop_table_for_mysql( row_drop_table_for_mysql(
......
...@@ -4591,10 +4591,10 @@ row_search_autoinc_read_column( ...@@ -4591,10 +4591,10 @@ row_search_autoinc_read_column(
ibool unsigned_type) /* in: signed or unsigned flag */ ibool unsigned_type) /* in: signed or unsigned flag */
{ {
ulint len; ulint len;
byte* ptr;
const byte* data; const byte* data;
ib_longlong value; ib_longlong value;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
/* Our requirement is that dest should be word aligned. */
byte dest[sizeof(value)]; byte dest[sizeof(value)];
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_; ulint* offsets = offsets_;
...@@ -4613,34 +4613,25 @@ row_search_autoinc_read_column( ...@@ -4613,34 +4613,25 @@ row_search_autoinc_read_column(
ut_a(len != UNIV_SQL_NULL); ut_a(len != UNIV_SQL_NULL);
ut_a(len <= sizeof value); ut_a(len <= sizeof value);
/* Convert integer data from Innobase to a little-endian format, mach_read_int_type(dest, data, len, unsigned_type);
sign bit restored to normal */
for (ptr = dest + len; ptr != dest; ++data) {
--ptr;
*ptr = *data;
}
if (!unsigned_type) {
dest[len - 1] ^= 128;
}
/* The assumption here is that the AUTOINC value can't be negative.*/ /* The assumption here is that the AUTOINC value can't be negative
and that dest is word aligned. */
switch (len) { switch (len) {
case 8: case 8:
value = *(ib_longlong*) ptr; value = *(ib_longlong*) dest;
break; break;
case 4: case 4:
value = *(ib_uint32_t*) ptr; value = *(ib_uint32_t*) dest;
break; break;
case 2: case 2:
value = *(uint16 *) ptr; value = *(uint16 *) dest;
break; break;
case 1: case 1:
value = *ptr; value = *dest;
break; break;
default: default:
......
...@@ -174,9 +174,7 @@ rw_lock_free( ...@@ -174,9 +174,7 @@ rw_lock_free(
/*=========*/ /*=========*/
rw_lock_t* lock) /* in: rw-lock */ rw_lock_t* lock) /* in: rw-lock */
{ {
#ifdef UNIV_DEBUG ut_ad(rw_lock_validate(lock));
ut_a(rw_lock_validate(lock));
#endif /* UNIV_DEBUG */
ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED); ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
ut_a(rw_lock_get_waiters(lock) == 0); ut_a(rw_lock_get_waiters(lock) == 0);
ut_a(rw_lock_get_reader_count(lock) == 0); ut_a(rw_lock_get_reader_count(lock) == 0);
...@@ -199,6 +197,7 @@ rw_lock_free( ...@@ -199,6 +197,7 @@ rw_lock_free(
mutex_exit(&rw_lock_list_mutex); mutex_exit(&rw_lock_list_mutex);
} }
#ifdef UNIV_DEBUG
/********************************************************************** /**********************************************************************
Checks that the rw-lock has been initialized and that there are no Checks that the rw-lock has been initialized and that there are no
simultaneous shared and exclusive locks. */ simultaneous shared and exclusive locks. */
...@@ -226,6 +225,7 @@ rw_lock_validate( ...@@ -226,6 +225,7 @@ rw_lock_validate(
return(TRUE); return(TRUE);
} }
#endif /* UNIV_DEBUG */
/********************************************************************** /**********************************************************************
Lock an rw-lock in shared mode for the current thread. If the rw-lock is Lock an rw-lock in shared mode for the current thread. If the rw-lock is
......
...@@ -656,6 +656,7 @@ trx_sys_update_mysql_binlog_offset( ...@@ -656,6 +656,7 @@ trx_sys_update_mysql_binlog_offset(
MLOG_4BYTES, mtr); MLOG_4BYTES, mtr);
} }
#ifdef UNIV_HOTBACKUP
/********************************************************************* /*********************************************************************
Prints to stderr the MySQL binlog info in the system header if the Prints to stderr the MySQL binlog info in the system header if the
magic number shows it valid. */ magic number shows it valid. */
...@@ -688,6 +689,7 @@ trx_sys_print_mysql_binlog_offset_from_page( ...@@ -688,6 +689,7 @@ trx_sys_print_mysql_binlog_offset_from_page(
+ TRX_SYS_MYSQL_LOG_NAME); + TRX_SYS_MYSQL_LOG_NAME);
} }
} }
#endif /* UNIV_HOTBACKUP */
/********************************************************************* /*********************************************************************
Stores the MySQL binlog offset info in the trx system header if Stores the MySQL binlog offset info in the trx system header if
......
...@@ -112,11 +112,6 @@ trx_create( ...@@ -112,11 +112,6 @@ trx_create(
trx->mysql_log_file_name = NULL; trx->mysql_log_file_name = NULL;
trx->mysql_log_offset = 0; trx->mysql_log_offset = 0;
trx->mysql_master_log_file_name = "";
trx->mysql_master_log_pos = 0;
trx->repl_wait_binlog_name = NULL;
trx->repl_wait_binlog_pos = 0;
mutex_create(&trx->undo_mutex, SYNC_TRX_UNDO); mutex_create(&trx->undo_mutex, SYNC_TRX_UNDO);
...@@ -287,11 +282,6 @@ trx_free( ...@@ -287,11 +282,6 @@ trx_free(
trx_undo_arr_free(trx->undo_no_arr); trx_undo_arr_free(trx->undo_no_arr);
} }
if (trx->repl_wait_binlog_name != NULL) {
mem_free(trx->repl_wait_binlog_name);
}
ut_a(UT_LIST_GET_LEN(trx->signals) == 0); ut_a(UT_LIST_GET_LEN(trx->signals) == 0);
ut_a(UT_LIST_GET_LEN(trx->reply_signals) == 0); ut_a(UT_LIST_GET_LEN(trx->reply_signals) == 0);
...@@ -774,14 +764,6 @@ trx_commit_off_kernel( ...@@ -774,14 +764,6 @@ trx_commit_off_kernel(
trx->mysql_log_file_name = NULL; trx->mysql_log_file_name = NULL;
} }
if (trx->mysql_master_log_file_name[0] != '\0') {
/* This database server is a MySQL replication slave */
trx_sys_update_mysql_binlog_offset(
trx->mysql_master_log_file_name,
trx->mysql_master_log_pos,
TRX_SYS_MYSQL_MASTER_LOG_INFO, &mtr);
}
/* The following call commits the mini-transaction, making the /* The following call commits the mini-transaction, making the
whole transaction committed in the file-based world, at this whole transaction committed in the file-based world, at this
log sequence number. The transaction becomes 'durable' when log sequence number. The transaction becomes 'durable' when
......
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