Commit 31d63cd0 authored by marko's avatar marko

branches/zip: Merge 1664:1783 from trunk.

parent 94eee936
This diff is collapsed.
......@@ -1189,11 +1189,6 @@ ibuf_dummy_index_free(
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
corresponding record in an ibuf index. */
......
......@@ -340,11 +340,11 @@ struct dict_table_struct{
unsigned n_cols:10;/* number of columns */
dict_col_t* cols; /* array of column descriptions */
const char* col_names;
/* n_def column names packed in an
"name1\0name2\0...nameN\0" array. until
n_def reaches n_cols, this is allocated with
ut_malloc, and the final size array is
allocated through the table's heap. */
/* Column names packed in a character string
"name1\0name2\0...nameN\0". Until
the string contains n_cols, it will be
allocated from a temporary heap. The final
string will be allocated from table->heap. */
hash_node_t name_hash; /* hash chain node */
hash_node_t id_hash; /* hash chain node */
UT_LIST_BASE_NODE_T(dict_index_t)
......@@ -444,6 +444,16 @@ struct dict_table_struct{
UT_LIST_BASE_NODE_T(row_prebuilt_t) prebuilts;
/* base node for the prebuilts defined
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
ulint magic_n;/* magic number */
# define DICT_TABLE_MAGIC_N 76333786
......
......@@ -364,6 +364,17 @@ mach_write_to_2_little_endian(
byte* dest, /* in: where 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
#include "mach0data.ic"
#endif
......
......@@ -7,6 +7,8 @@ to the machine format.
Created 11/28/1995 Heikki Tuuri
***********************************************************************/
#include "ut0mem.h"
/***********************************************************
The following function is used to store data in one byte. */
UNIV_INLINE
......@@ -723,3 +725,38 @@ mach_write_to_2_little_endian(
*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(
trx_t* trx); /* in: transaction */
#ifndef UNIV_HOTBACKUP
/*************************************************************************
Does a table creation operation for MySQL. If the name of the created
table ends to characters INNODB_MONITOR, then this also starts
printing of monitor output by the master thread. */
Drops a table for MySQL. If the name of the table ends in
one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
"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
row_create_table_for_mysql(
......@@ -420,8 +422,9 @@ row_truncate_table_for_mysql(
dict_table_t* table, /* in: table handle */
trx_t* trx); /* in: transaction handle */
/*************************************************************************
Drops a table for MySQL. If the name of the dropped table ends to
characters INNODB_MONITOR, then this also stops printing of monitor
Drops a table for MySQL. If the name of the dropped table ends in
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. */
int
......
......@@ -101,6 +101,7 @@ void
rw_lock_free(
/*=========*/
rw_lock_t* lock); /* in: rw-lock */
#ifdef UNIV_DEBUG
/**********************************************************************
Checks that the rw-lock has been initialized and that there are no
simultaneous shared and exclusive locks. */
......@@ -109,6 +110,7 @@ ibool
rw_lock_validate(
/*=============*/
rw_lock_t* lock);
#endif /* UNIV_DEBUG */
/******************************************************************
NOTE! The following macros should be used in rw s-locking, not the
corresponding function. */
......
......@@ -231,7 +231,7 @@ rw_lock_s_lock_func(
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
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
the threads which have s-locked a latch. This would use some CPU
time. */
......
......@@ -510,31 +510,6 @@ struct trx_struct{
ib_longlong mysql_log_offset;/* if MySQL binlog is used, this field
contains the end offset of the binlog
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
with this transaction object */
ulint mysql_process_no;/* since in Linux, 'top' reports
......
......@@ -63,7 +63,7 @@ ut_test_malloc(
/* out: TRUE if succeeded */
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
ut_free(
......
......@@ -3544,6 +3544,10 @@ lock_table_create(
ut_ad(table && trx);
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) {
/* Only one trx can have the lock on the table
at a time: we may use the memory preallocated
......@@ -3594,6 +3598,9 @@ lock_table_remove_low(
if (lock == trx->auto_inc_lock) {
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);
......
......@@ -479,6 +479,7 @@ passwd varchar(32) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id),
UNIQUE ggid (ggid)
) ENGINE=innodb;
set global innodb_autoinc_lock_mode = 0;
insert into t1 (ggid,passwd) values ('test1','xxx');
insert into t1 (ggid,passwd) values ('test2','yyy');
insert into t1 (ggid,passwd) values ('test2','this will fail');
......
......@@ -345,6 +345,9 @@ CREATE TABLE t1 (
UNIQUE ggid (ggid)
) 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 ('test2','yyy');
-- error ER_DUP_ENTRY
......
......@@ -1793,10 +1793,11 @@ row_mysql_unlock_data_dictionary(
#ifndef UNIV_HOTBACKUP
/*************************************************************************
Does a table creation operation for MySQL. If the name of the table
to be created is equal with one of the predefined magic table names,
then this also starts printing the corresponding monitor output by
the master thread. */
Drops a table for MySQL. If the name of the table ends in
one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
"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
row_create_table_for_mysql(
......@@ -3032,9 +3033,10 @@ funct_exit:
}
/*************************************************************************
Drops a table for MySQL. If the name of the table to be dropped is equal
with one of the predefined magic table names, then this also stops printing
the corresponding monitor output by the master thread. */
Drops a table for MySQL. If the name of the dropped table ends in
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. */
int
row_drop_table_for_mysql(
......
......@@ -4591,10 +4591,10 @@ row_search_autoinc_read_column(
ibool unsigned_type) /* in: signed or unsigned flag */
{
ulint len;
byte* ptr;
const byte* data;
ib_longlong value;
mem_heap_t* heap = NULL;
/* Our requirement is that dest should be word aligned. */
byte dest[sizeof(value)];
ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_;
......@@ -4613,34 +4613,25 @@ row_search_autoinc_read_column(
ut_a(len != UNIV_SQL_NULL);
ut_a(len <= sizeof value);
/* Convert integer data from Innobase to a little-endian format,
sign bit restored to normal */
for (ptr = dest + len; ptr != dest; ++data) {
--ptr;
*ptr = *data;
}
if (!unsigned_type) {
dest[len - 1] ^= 128;
}
mach_read_int_type(dest, data, len, unsigned_type);
/* 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) {
case 8:
value = *(ib_longlong*) ptr;
value = *(ib_longlong*) dest;
break;
case 4:
value = *(ib_uint32_t*) ptr;
value = *(ib_uint32_t*) dest;
break;
case 2:
value = *(uint16 *) ptr;
value = *(uint16 *) dest;
break;
case 1:
value = *ptr;
value = *dest;
break;
default:
......
......@@ -174,9 +174,7 @@ rw_lock_free(
/*=========*/
rw_lock_t* lock) /* in: rw-lock */
{
#ifdef UNIV_DEBUG
ut_a(rw_lock_validate(lock));
#endif /* UNIV_DEBUG */
ut_ad(rw_lock_validate(lock));
ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
ut_a(rw_lock_get_waiters(lock) == 0);
ut_a(rw_lock_get_reader_count(lock) == 0);
......@@ -199,6 +197,7 @@ rw_lock_free(
mutex_exit(&rw_lock_list_mutex);
}
#ifdef UNIV_DEBUG
/**********************************************************************
Checks that the rw-lock has been initialized and that there are no
simultaneous shared and exclusive locks. */
......@@ -226,6 +225,7 @@ rw_lock_validate(
return(TRUE);
}
#endif /* UNIV_DEBUG */
/**********************************************************************
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(
MLOG_4BYTES, mtr);
}
#ifdef UNIV_HOTBACKUP
/*********************************************************************
Prints to stderr the MySQL binlog info in the system header if the
magic number shows it valid. */
......@@ -688,6 +689,7 @@ trx_sys_print_mysql_binlog_offset_from_page(
+ TRX_SYS_MYSQL_LOG_NAME);
}
}
#endif /* UNIV_HOTBACKUP */
/*********************************************************************
Stores the MySQL binlog offset info in the trx system header if
......
......@@ -112,11 +112,6 @@ trx_create(
trx->mysql_log_file_name = NULL;
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);
......@@ -287,11 +282,6 @@ trx_free(
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->reply_signals) == 0);
......@@ -774,14 +764,6 @@ trx_commit_off_kernel(
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
whole transaction committed in the file-based world, at this
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