Commit 15fd02cb authored by Satya B's avatar Satya B

Applying InnoDB Plugin 1.0.5 snapshot , part 9

r5888 - plug.in related changes skipped
r5889 - skipped(plug.in related changes)
r5916 - innodb_bug4600.test and innodb_bug44369.test
        already exists in main suite

Detailed revision comments:

r5875 | vasil | 2009-09-12 07:11:25 -0500 (Sat, 12 Sep 2009) | 4 lines
branches/zip:

Remove unnecessary macro.

r5888 | vasil | 2009-09-14 03:38:45 -0500 (Mon, 14 Sep 2009) | 40 lines
branches/zip:

Back-merge c5880 and c5881 from branches/embedded-1.0:

  ------------------------------------------------------------------------
  r5880 | vasil | 2009-09-12 17:28:44 +0300 (Sat, 12 Sep 2009) | 18 lines
  Changed paths:
     M /branches/embedded-1.0/configure.in
     M /branches/embedded-1.0/include/os0sync.h
     M /branches/embedded-1.0/srv/srv0start.c
  
  branches/embedded-1.0:
  
  Clean up and simplify the code that surrounds the atomic ops:
  
  * Simplify the code that prints what atomics are used:
  Instead of repeating the same conditions on which each atomics are used
  use just one printf that prints a variable defined by the code which
  chooses what atomics to use.
  
  * In os0sync.h pick up each atomic variant only if it has been selected
  by autoconf (based on IB_ATOMIC_MODE_* macros). Define the startup message
  to be printed.
  
  * In configure.in: check what user has chosen and if he has chosen
  something that is not available, emit an error. If nothing has been chosen
  explicitly by the user, auto select an option according to the described
  logic in configure.in.
  
  ------------------------------------------------------------------------
  r5881 | vasil | 2009-09-12 20:08:27 +0300 (Sat, 12 Sep 2009) | 4 lines
  Changed paths:
     M /branches/embedded-1.0/configure.in
  
  branches/embedded-1.0:
  
  Fix syntax error in test program.
r5910 | marko | 2009-09-16 03:07:21 -0500 (Wed, 16 Sep 2009) | 9 lines
branches/zip: Introduce UNIV_LOG_LSN_DEBUG and MLOG_LSN for redo log
diagnostics.  This was written in order to better track down
Issue #313 in InnoDB Hot Backup.

MLOG_LSN: A new redo log entry type, for recording the current log
sequence number (LSN).  This will be checked in an assertion in
recv_parse_log_rec().

rb://161, discussed with Sunny and Vasil.
r5916 | marko | 2009-09-16 04:54:43 -0500 (Wed, 16 Sep 2009) | 128 lines
branches/zip: Merge revisions 5622:5912 from branches/5.1, except r5700
(changes to CMakeLists.txt)

  ------------------------------------------------------------------------
  r5622 | vasil | 2009-08-03 15:27:00 +0300 (Mon, 03 Aug 2009) | 20 lines
  Changed paths:
     M /branches/5.1/Makefile.am

  branches/5.1:

  Merge a change from MySQL:

    ------------------------------------------------------------
    revno: 2988
    committer: Satya B <satya.bn@sun.com>
    branch nick: mysql-5.1-bugteam
    timestamp: Wed 2009-07-01 11:06:05 +0530
    message:
      Fix build failure after applying Innodb snapshot 5.1-ss5282

      After applying Innodb snapshot 5.1-ss5282, build was broken
      because of missing header file.

      Adding the header file to Makefile.am after informing the
      innodb developers.
    modified:
      storage/innobase/Makefile.am
  ------------------------------------------------------------------------
  r5740 | jyang | 2009-09-03 06:33:47 +0300 (Thu, 03 Sep 2009) | 5 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/include/db0err.h
     A /branches/5.1/mysql-test/innodb_bug46000.result
     A /branches/5.1/mysql-test/innodb_bug46000.test

  branches/5.1: Disallow creating index with the name of
  "GEN_CLUST_INDEX" which is reserved for the default system
  primary index. (Bug #46000) rb://149 approved by Sunny Bains.
  ------------------------------------------------------------------------
  r5741 | jyang | 2009-09-03 07:16:01 +0300 (Thu, 03 Sep 2009) | 5 lines
  Changed paths:
     M /branches/5.1/dict/dict0dict.c
     M /branches/5.1/handler/ha_innodb.cc
     A /branches/5.1/mysql-test/innodb_bug44369.result
     A /branches/5.1/mysql-test/innodb_bug44369.test
     M /branches/5.1/row/row0mysql.c

  branches/5.1: Block creating table with column name conflicting
  with Innodb reserved key words. (Bug #44369) rb://151 approved
  by Sunny Bains.
  ------------------------------------------------------------------------
  r5757 | jyang | 2009-09-04 04:26:13 +0300 (Fri, 04 Sep 2009) | 3 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/include/db0err.h
     D /branches/5.1/mysql-test/innodb_bug46000.result
     D /branches/5.1/mysql-test/innodb_bug46000.test

  branches/5.1: Revert change in 5740. Making the fix in a subsequent
  check in.
  ------------------------------------------------------------------------
  r5760 | jyang | 2009-09-04 07:07:34 +0300 (Fri, 04 Sep 2009) | 3 lines
  Changed paths:
     M /branches/5.1/dict/dict0dict.c
     M /branches/5.1/handler/ha_innodb.cc
     D /branches/5.1/mysql-test/innodb_bug44369.result
     D /branches/5.1/mysql-test/innodb_bug44369.test
     M /branches/5.1/row/row0mysql.c

  branches/5.1: This is to revert change 5741. A return status for
  create_table_def() needs to be fixed.
  ------------------------------------------------------------------------
  r5797 | calvin | 2009-09-09 18:26:29 +0300 (Wed, 09 Sep 2009) | 3 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc

  branches/5.1: merge change from 5.1.38

  HA_ERR_TOO_MANY_CONCURRENT_TRXS is added in 5.1.38.
  ------------------------------------------------------------------------
  r5799 | calvin | 2009-09-09 20:47:31 +0300 (Wed, 09 Sep 2009) | 10 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc

  branches/5.1: fix bug#46256

  Allow tables to be dropped even if the collation is not found,
  but issue a warning.

  Could not find an easy way to add mysql-test since it requires
  changes to charsets and restarting the server. Tests were
  executed manually.

  Approved by: Heikki (on IM)
  ------------------------------------------------------------------------
  r5805 | vasil | 2009-09-10 08:41:48 +0300 (Thu, 10 Sep 2009) | 7 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc

  branches/5.1:

  Fix a compilation warning caused by c5799:

  handler/ha_innodb.cc: In function 'void innobase_get_cset_width(ulint, ulint*, ulint*)':
  handler/ha_innodb.cc:830: warning: format '%d' expects type 'int', but argument 2 has type 'ulint'
  ------------------------------------------------------------------------
  r5834 | jyang | 2009-09-11 00:43:05 +0300 (Fri, 11 Sep 2009) | 5 lines
  Changed paths:
     M /branches/5.1/dict/dict0dict.c
     M /branches/5.1/handler/ha_innodb.cc
     A /branches/5.1/mysql-test/innodb_bug44369.result
     A /branches/5.1/mysql-test/innodb_bug44369.test
     M /branches/5.1/row/row0mysql.c

  branches/5.1: Block creating table with column name conflicting
  with Innodb reserved key words. (Bug #44369) rb://151 approved
  by Sunny Bains.
  ------------------------------------------------------------------------
  r5895 | jyang | 2009-09-15 03:39:21 +0300 (Tue, 15 Sep 2009) | 5 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     A /branches/5.1/mysql-test/innodb_bug46000.result
     A /branches/5.1/mysql-test/innodb_bug46000.test

  branches/5.1: Disallow creating index with the name of
  "GEN_CLUST_INDEX" which is reserved for the default system
  primary index. (Bug #46000) rb://149 approved by Marko Makela.
  ------------------------------------------------------------------------
parent 913f8903
......@@ -1170,7 +1170,7 @@ dict_col_name_is_reserved(
ulint i;
for (i = 0; i < UT_ARR_SIZE(reserved_names); i++) {
if (strcmp(name, reserved_names[i]) == 0) {
if (innobase_strcasecmp(name, reserved_names[i]) == 0) {
return(TRUE);
}
......
......@@ -226,6 +226,25 @@ static handler *innobase_create_handler(handlerton *hton,
TABLE_SHARE *table,
MEM_ROOT *mem_root);
/***********************************************************************
This function checks each index name for a table against reserved
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
this function pushes an error message to the client, and returns true. */
static
bool
innobase_index_name_is_reserved(
/*============================*/
/* out: true if index name matches a
reserved name */
const trx_t* trx, /* in: InnoDB transaction handle */
const TABLE* form, /* in: information on table
columns and indexes */
const char* norm_name); /* in: table name */
/* "GEN_CLUST_INDEX" is the name reserved for Innodb default
system primary index. */
static const char innobase_index_reserve_name[]= "GEN_CLUST_INDEX";
/** @brief Initialize the default value of innodb_commit_concurrency.
Once InnoDB is running, the innodb_commit_concurrency must not change
......@@ -949,7 +968,22 @@ innobase_get_cset_width(
*mbminlen = cs->mbminlen;
*mbmaxlen = cs->mbmaxlen;
} else {
if (current_thd
&& (thd_sql_command(current_thd) == SQLCOM_DROP_TABLE)) {
/* Fix bug#46256: allow tables to be dropped if the
collation is not found, but issue a warning. */
if ((global_system_variables.log_warnings)
&& (cset != 0)){
sql_print_warning(
"Unknown collation #%lu.", cset);
}
} else {
ut_a(cset == 0);
}
*mbminlen = *mbmaxlen = 0;
}
}
......@@ -5660,6 +5694,28 @@ create_table_def(
}
}
/* First check whether the column to be added has a
system reserved name. */
if (dict_col_name_is_reserved(field->field_name)){
push_warning_printf(
(THD*) trx->mysql_thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_CANT_CREATE_TABLE,
"Error creating table '%s' with "
"column name '%s'. '%s' is a "
"reserved name. Please try to "
"re-create the table with a "
"different column name.",
table->name, (char*) field->field_name,
(char*) field->field_name);
dict_mem_table_free(table);
trx_commit_for_mysql(trx);
error = DB_ERROR;
goto error_ret;
}
dict_mem_table_add_col(table, table->heap,
(char*) field->field_name,
col_type,
......@@ -5673,6 +5729,7 @@ create_table_def(
error = row_create_table_for_mysql(table, trx);
error_ret:
error = convert_error_code_to_mysql(error, flags, NULL);
DBUG_RETURN(error);
......@@ -5711,6 +5768,9 @@ create_index(
n_fields = key->key_parts;
/* Assert that "GEN_CLUST_INDEX" cannot be used as non-primary index */
ut_a(innobase_strcasecmp(key->name, innobase_index_reserve_name) != 0);
ind_type = 0;
if (key_num == form->s->primary_key) {
......@@ -5819,8 +5879,8 @@ create_clustered_index_when_no_primary(
/* We pass 0 as the space id, and determine at a lower level the space
id where to store the table */
index = dict_mem_index_create(table_name, "GEN_CLUST_INDEX",
index = dict_mem_index_create(table_name,
innobase_index_reserve_name,
0, DICT_CLUSTERED, 0);
error = row_create_index_for_mysql(index, trx, NULL);
......@@ -6246,14 +6306,6 @@ ha_innobase::create(
flags = DICT_TF_COMPACT;
}
error = create_table_def(trx, form, norm_name,
create_info->options & HA_LEX_CREATE_TMP_TABLE ? name2 : NULL,
flags);
if (error) {
goto cleanup;
}
/* Look for a primary key */
primary_key_no= (form->s->primary_key != MAX_KEY ?
......@@ -6265,6 +6317,22 @@ ha_innobase::create(
ut_a(primary_key_no == -1 || primary_key_no == 0);
/* Check for name conflicts (with reserved name) for
any user indices to be created. */
if (innobase_index_name_is_reserved(trx, form, norm_name)) {
error = -1;
goto cleanup;
}
error = create_table_def(trx, form, norm_name,
create_info->options & HA_LEX_CREATE_TMP_TABLE ? name2 : NULL,
flags);
if (error) {
goto cleanup;
}
/* Create the keys */
if (form->s->keys == 0 || primary_key_no == -1) {
......@@ -9707,6 +9775,46 @@ static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
/***********************************************************************
This function checks each index name for a table against reserved
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
this function pushes an error message to the client, and returns true. */
static
bool
innobase_index_name_is_reserved(
/*============================*/
/* out: true if an index name
matches the reserved name */
const trx_t* trx, /* in: InnoDB transaction handle */
const TABLE* form, /* in: information on table
columns and indexes */
const char* norm_name) /* in: table name */
{
KEY* key;
uint key_num; /* index number */
for (key_num = 0; key_num < form->s->keys; key_num++) {
key = form->key_info + key_num;
if (innobase_strcasecmp(key->name,
innobase_index_reserve_name) == 0) {
/* Push warning to mysql */
push_warning_printf((THD*) trx->mysql_thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_CANT_CREATE_TABLE,
"Cannot Create Index with name "
"'%s'. The name is reserved "
"for the system default primary "
"index.",
innobase_index_reserve_name);
return(true);
}
}
return(false);
}
static SHOW_VAR innodb_status_variables_export[]= {
{"Innodb", (char*) &show_innodb_vars, SHOW_FUNC},
{NullS, NullS, SHOW_LONG}
......
......@@ -312,11 +312,20 @@ log_reserve_and_write_fast(
ib_uint64_t* start_lsn)/*!< out: start lsn of the log record */
{
ulint data_len;
ib_uint64_t lsn;
#ifdef UNIV_LOG_LSN_DEBUG
/* length of the LSN pseudo-record */
ulint lsn_len = 1
+ mach_get_compressed_size(log_sys->lsn >> 32)
+ mach_get_compressed_size(log_sys->lsn & 0xFFFFFFFFUL);
#endif /* UNIV_LOG_LSN_DEBUG */
mutex_enter(&log_sys->mutex);
data_len = len + log_sys->buf_free % OS_FILE_LOG_BLOCK_SIZE;
data_len = len
#ifdef UNIV_LOG_LSN_DEBUG
+ lsn_len
#endif /* UNIV_LOG_LSN_DEBUG */
+ log_sys->buf_free % OS_FILE_LOG_BLOCK_SIZE;
if (data_len >= OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE) {
......@@ -330,7 +339,23 @@ log_reserve_and_write_fast(
*start_lsn = log_sys->lsn;
ut_memcpy(log_sys->buf + log_sys->buf_free, str, len);
#ifdef UNIV_LOG_LSN_DEBUG
{
/* Write the LSN pseudo-record. */
byte* b = &log_sys->buf[log_sys->buf_free];
*b++ = MLOG_LSN | (MLOG_SINGLE_REC_FLAG & *(const byte*) str);
/* Write the LSN in two parts,
as a pseudo page number and space id. */
b += mach_write_compressed(b, log_sys->lsn >> 32);
b += mach_write_compressed(b, log_sys->lsn & 0xFFFFFFFFUL);
ut_a(b - lsn_len == &log_sys->buf[log_sys->buf_free]);
memcpy(b, str, len);
len += lsn_len;
}
#else /* UNIV_LOG_LSN_DEBUG */
memcpy(log_sys->buf + log_sys->buf_free, str, len);
#endif /* UNIV_LOG_LSN_DEBUG */
log_block_set_data_len((byte*) ut_align_down(log_sys->buf
+ log_sys->buf_free,
......@@ -344,14 +369,14 @@ log_reserve_and_write_fast(
ut_ad(log_sys->buf_free <= log_sys->buf_size);
lsn = log_sys->lsn += len;
log_sys->lsn += len;
#ifdef UNIV_LOG_DEBUG
log_check_log_recs(log_sys->buf + log_sys->old_buf_free,
log_sys->buf_free - log_sys->old_buf_free,
log_sys->old_lsn);
#endif
return(lsn);
return(log_sys->lsn);
}
/***********************************************************************//**
......
......@@ -106,6 +106,9 @@ For 1 - 8 bytes, the flag value must give the length also! @{ */
#define MLOG_IBUF_BITMAP_INIT ((byte)27) /*!< initialize an
ibuf bitmap page */
/*#define MLOG_FULL_PAGE ((byte)28) full contents of a page */
#ifdef UNIV_LOG_LSN_DEBUG
# define MLOG_LSN ((byte)28) /* current LSN */
#endif
#define MLOG_INIT_FILE_PAGE ((byte)29) /*!< this means that a
file page is taken
into use and the prior
......
......@@ -398,10 +398,9 @@ compare to, new_val is the value to swap in. */
# define os_compare_and_swap_lint(ptr, old_val, new_val) \
(win_cmp_and_xchg(ptr, new_val, old_val) == old_val)
/* windows thread objects can always be passed to windows atomic functions */
# define os_compare_and_swap_thread_id(ptr, old_val, new_val) \
(InterlockedCompareExchange(ptr, new_val, old_val) == old_val)
/* windows thread objects can always be passed to windows atomic functions */
# define HAVE_IB_ATOMIC_PTHREAD_T_WINDOWS
/**********************************************************//**
Returns the resulting value, ptr is pointer to target, amount is the
......
......@@ -185,6 +185,9 @@ command. Not tested on Windows. */
#define UNIV_LRU_DEBUG /* debug the buffer pool LRU */
#define UNIV_HASH_DEBUG /* debug HASH_ macros */
#define UNIV_LIST_DEBUG /* debug UT_LIST_ macros */
#define UNIV_LOG_LSN_DEBUG /* write LSN to the redo log;
this will break redo log file compatibility, but it may be useful when
debugging redo log application problems. */
#define UNIV_MEM_DEBUG /* detect memory leaks etc */
#define UNIV_IBUF_DEBUG /* debug the insert buffer */
#define UNIV_IBUF_COUNT_DEBUG /* debug the insert buffer;
......
......@@ -853,6 +853,11 @@ recv_parse_or_apply_log_rec_body(
}
switch (type) {
#ifdef UNIV_LOG_LSN_DEBUG
case MLOG_LSN:
/* The LSN is checked in recv_parse_log_rec(). */
break;
#endif /* UNIV_LOG_LSN_DEBUG */
case MLOG_1BYTE: case MLOG_2BYTES: case MLOG_4BYTES: case MLOG_8BYTES:
#ifdef UNIV_DEBUG
if (page && page_type == FIL_PAGE_TYPE_ALLOCATED
......@@ -1924,6 +1929,17 @@ recv_parse_log_rec(
return(0);
}
#ifdef UNIV_LOG_LSN_DEBUG
if (*type == MLOG_LSN) {
ib_uint64_t lsn = (ib_uint64_t) *space << 32 | *page_no;
# ifdef UNIV_LOG_DEBUG
ut_a(lsn == log_sys->old_lsn);
# else /* UNIV_LOG_DEBUG */
ut_a(lsn == recv_sys->recovered_lsn);
# endif /* UNIV_LOG_DEBUG */
}
#endif /* UNIV_LOG_LSN_DEBUG */
/* Check that page_no is sensible */
if (UNIV_UNLIKELY(*page_no > 0x8FFFFFFFUL)) {
......@@ -2181,6 +2197,12 @@ loop:
#endif
/* In normal mysqld crash recovery we do not try to
replay file operations */
#ifdef UNIV_LOG_LSN_DEBUG
} else if (type == MLOG_LSN) {
/* Do not add these records to the hash table.
The page number and space id fields are misused
for something else. */
#endif /* UNIV_LOG_LSN_DEBUG */
} else {
recv_add_to_hash_table(type, space, page_no, body,
ptr + len, old_lsn,
......@@ -2212,11 +2234,11 @@ loop:
= recv_sys->recovered_offset + total_len;
recv_previous_parsed_rec_is_multi = 1;
if ((!store_to_hash) && (type != MLOG_MULTI_REC_END)) {
#ifdef UNIV_LOG_DEBUG
if ((!store_to_hash) && (type != MLOG_MULTI_REC_END)) {
recv_check_incomplete_log_recs(ptr, len);
#endif /* UNIV_LOG_DEBUG */
}
#endif /* UNIV_LOG_DEBUG */
#ifdef UNIV_DEBUG
if (log_debug_writes) {
......@@ -2280,7 +2302,11 @@ loop:
break;
}
if (store_to_hash) {
if (store_to_hash
#ifdef UNIV_LOG_LSN_DEBUG
&& type != MLOG_LSN
#endif /* UNIV_LOG_LSN_DEBUG */
) {
recv_add_to_hash_table(type, space, page_no,
body, ptr + len,
old_lsn,
......
......@@ -1771,7 +1771,6 @@ row_create_table_for_mysql(
const char* table_name;
ulint table_name_len;
ulint err;
ulint i;
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
#ifdef UNIV_SYNC_DEBUG
......@@ -1806,15 +1805,6 @@ err_exit:
goto err_exit;
}
/* Check that no reserved column names are used. */
for (i = 0; i < dict_table_get_n_user_cols(table); i++) {
if (dict_col_name_is_reserved(
dict_table_get_col_name(table, i))) {
goto err_exit;
}
}
trx_start_if_not_started(trx);
/* The table name is prefixed with the database name and a '/'.
......
......@@ -1097,6 +1097,10 @@ innobase_start_or_create_for_mysql(void)
"InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n");
#endif
#ifdef UNIV_LOG_LSN_DEBUG
fprintf(stderr,
"InnoDB: !!!!!!!! UNIV_LOG_LSN_DEBUG switched on !!!!!!!!!\n");
#endif /* UNIV_LOG_LSN_DEBUG */
#ifdef UNIV_MEM_DEBUG
fprintf(stderr,
"InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
......
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