Commit 7fbc04fc authored by marko's avatar marko

branches/zip: Merge 1533:1553 from trunk.

parent 1d2284c3
......@@ -3004,8 +3004,11 @@ btr_index_rec_validate(
rec_get_nth_field_offs(offsets, i, &len);
/* Note that prefix indexes are not fixed size even when
their type is CHAR. */
/* Note that if fixed_size != 0, it equals the
length of a fixed-size column in the clustered index.
A prefix index of the column is of fixed, but different
length. When fixed_size == 0, prefix_len is the maximum
length of the prefix index column. */
if ((dict_index_get_nth_field(index, i)->prefix_len == 0
&& len != UNIV_SQL_NULL && fixed_size
......
......@@ -1542,6 +1542,12 @@ dict_index_add_col(
if (field->fixed_len > DICT_MAX_INDEX_COL_LEN) {
field->fixed_len = 0;
}
#if DICT_MAX_INDEX_COL_LEN != 768
/* The comparison limit above must be constant. If it were
changed, the disk format of some fixed-length columns would
change, which would be a disaster. */
# error "DICT_MAX_INDEX_COL_LEN != 768"
#endif
if (!(col->prtype & DATA_NOT_NULL)) {
index->n_nullable++;
......
......@@ -81,7 +81,7 @@ static handlerton *innodb_hton_ptr;
uses unsigned char; the header univ.i which we include next defines
'byte' as a macro which expands to 'unsigned char' */
typedef byte mysql_byte;
typedef uchar mysql_byte;
#define INSIDE_HA_INNOBASE_CC
......@@ -166,7 +166,7 @@ static HASH innobase_open_tables;
bool nw_panic = FALSE;
#endif
static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length,
static mysql_byte* innobase_get_key(INNOBASE_SHARE *share, size_t *length,
my_bool not_used __attribute__((unused)));
static INNOBASE_SHARE *get_share(const char *table_name);
static void free_share(INNOBASE_SHARE *share);
......@@ -1284,12 +1284,12 @@ innobase_print_identifier(
output strings buffers must not be shared. The function
only produces more output when the name contains other
characters than [0-9A-Z_a-z]. */
char* temp_name = my_malloc((uint) namelen + 1, MYF(MY_WME));
char* temp_name = (char*) my_malloc((uint) namelen + 1, MYF(MY_WME));
uint qnamelen = (uint) (namelen
+ (1 + sizeof srv_mysql50_table_name_prefix));
if (temp_name) {
qname = my_malloc(qnamelen, MYF(MY_WME));
qname = (char*) my_malloc(qnamelen, MYF(MY_WME));
if (qname) {
memcpy(temp_name, name, namelen);
temp_name[namelen] = 0;
......@@ -2440,7 +2440,7 @@ ha_innobase::open(
"how you can resolve the problem.\n",
norm_name);
free_share(share);
my_free((gptr) upd_buff, MYF(0));
my_free(upd_buff, MYF(0));
my_errno = ENOENT;
DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
......@@ -2457,7 +2457,7 @@ ha_innobase::open(
"how you can resolve the problem.\n",
norm_name);
free_share(share);
my_free((gptr) upd_buff, MYF(0));
my_free(upd_buff, MYF(0));
my_errno = ENOENT;
dict_table_decrement_handle_count(ib_table);
......@@ -2563,7 +2563,7 @@ ha_innobase::close(void)
row_prebuilt_free(prebuilt);
my_free((gptr) upd_buff, MYF(0));
my_free(upd_buff, MYF(0));
free_share(share);
/* Tell InnoDB server that there might be work for
......@@ -2586,7 +2586,7 @@ get_field_offset(
TABLE* table, /* in: MySQL table object */
Field* field) /* in: MySQL field object */
{
return((uint) (field->ptr - (char*) table->record[0]));
return((uint) (field->ptr - table->record[0]));
}
/******************************************************************
......@@ -4478,7 +4478,7 @@ ha_innobase::rnd_pos(
int error;
uint keynr = active_index;
DBUG_ENTER("rnd_pos");
DBUG_DUMP("key", (char*) pos, ref_length);
DBUG_DUMP("key", pos, ref_length);
ha_statistic_increment(&SSV::ha_read_rnd_count);
......@@ -4814,7 +4814,7 @@ create_index(
error = convert_error_code_to_mysql(error, NULL);
my_free((gptr) field_lengths, MYF(0));
my_free(field_lengths, MYF(0));
DBUG_RETURN(error);
}
......@@ -5259,7 +5259,7 @@ innobase_drop_database(
}
ptr++;
namebuf = my_malloc((uint) len + 2, MYF(0));
namebuf = (char*) my_malloc((uint) len + 2, MYF(0));
memcpy(namebuf, ptr, len);
namebuf[len] = '/';
......@@ -5516,7 +5516,7 @@ ha_innobase::records_in_range(
dtuple_free_for_mysql(heap1);
dtuple_free_for_mysql(heap2);
my_free((gptr) key_val_buff2, MYF(0));
my_free(key_val_buff2, MYF(0));
prebuilt->trx->op_info = (char*)"";
......@@ -5665,7 +5665,12 @@ ha_innobase::info(
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
DBUG_RETURN(HA_ERR_CRASHED);
/* We return success (0) instead of HA_ERR_CRASHED,
because we want MySQL to process this query and not
stop, like it would do if it received the error code
HA_ERR_CRASHED. */
DBUG_RETURN(0);
}
/* We do not know if MySQL can call this function before calling
......@@ -5986,7 +5991,7 @@ ha_innobase::update_table_comment(
/* allocate buffer for the full string, and
read the contents of the temporary file */
str = my_malloc(length + flen + 3, MYF(0));
str = (char*) my_malloc(length + flen + 3, MYF(0));
if (str) {
char* pos = str + length;
......@@ -6054,7 +6059,7 @@ ha_innobase::get_foreign_key_create_info(void)
/* allocate buffer for the string, and
read the contents of the temporary file */
str = my_malloc(flen + 1, MYF(0));
str = (char*) my_malloc(flen + 1, MYF(0));
if (str) {
rewind(srv_dict_tmpfile);
......@@ -6186,7 +6191,7 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
}
FOREIGN_KEY_INFO *pf_key_info = (FOREIGN_KEY_INFO *)
thd_memdup(thd, (gptr) &f_key_info, sizeof f_key_info);
thd_memdup(thd, &f_key_info, sizeof f_key_info);
f_key_list->push_back(pf_key_info);
foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
}
......@@ -6727,7 +6732,7 @@ innodb_show_status(
/* allocate buffer for the string, and
read the contents of the temporary file */
if (!(str = my_malloc(usable_len + 1, MYF(0)))) {
if (!(str = (char*) my_malloc(usable_len + 1, MYF(0)))) {
mutex_exit_noninline(&srv_monitor_file_mutex);
DBUG_RETURN(TRUE);
}
......@@ -6888,7 +6893,7 @@ bool innobase_show_status(handlerton *hton, THD* thd,
locking.
****************************************************************************/
static mysql_byte* innobase_get_key(INNOBASE_SHARE* share, uint* length,
static mysql_byte* innobase_get_key(INNOBASE_SHARE* share, size_t *length,
my_bool not_used __attribute__((unused)))
{
*length=share->table_name_length;
......@@ -6916,7 +6921,7 @@ static INNOBASE_SHARE* get_share(const char* table_name)
if (my_hash_insert(&innobase_open_tables,
(mysql_byte*) share)) {
pthread_mutex_unlock(&innobase_share_mutex);
my_free((gptr) share,0);
my_free(share,0);
return(0);
}
......@@ -6939,7 +6944,7 @@ static void free_share(INNOBASE_SHARE* share)
hash_delete(&innobase_open_tables, (mysql_byte*) share);
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
my_free((gptr) share, MYF(0));
my_free(share, MYF(0));
}
pthread_mutex_unlock(&innobase_share_mutex);
......@@ -7176,11 +7181,16 @@ ha_innobase::innobase_read_and_init_auto_inc(
longlong auto_inc;
ulint old_select_lock_type;
ibool trx_was_not_started = FALSE;
ibool stmt_start;
int error;
ut_a(prebuilt);
ut_a(prebuilt->table);
/* Remember if we are in the beginning of an SQL statement.
This function must not change that flag. */
stmt_start = prebuilt->sql_stat_start;
/* Prepare prebuilt->trx in the table handle */
update_thd(ha_thd());
......@@ -7302,6 +7312,8 @@ ha_innobase::innobase_read_and_init_auto_inc(
innobase_commit_low(prebuilt->trx);
}
prebuilt->sql_stat_start = stmt_start;
return(error);
}
......@@ -7435,9 +7447,8 @@ ha_innobase::cmp_ref(
ref1 += 2;
ref2 += 2;
result = ((Field_blob*)field)->cmp(
(const char*)ref1, len1,
(const char*)ref2, len2);
result = ((Field_blob*)field)->cmp( ref1, len1,
ref2, len2);
} else {
result = field->key_cmp(ref1, ref2);
}
......
......@@ -47,8 +47,8 @@ class ha_innobase: public handler
THR_LOCK_DATA lock;
INNOBASE_SHARE *share;
byte* upd_buff; /* buffer used in updates */
byte* key_val_buff; /* buffer used in converting
uchar* upd_buff; /* buffer used in updates */
uchar* key_val_buff; /* buffer used in converting
search key values from MySQL format
to Innodb format */
ulong upd_and_key_val_buff_len;
......@@ -65,10 +65,10 @@ class ha_innobase: public handler
uint num_write_row; /* number of write_row() calls */
uint store_key_val_for_row(uint keynr, char* buff, uint buff_len,
const byte* record);
const uchar* record);
int update_thd(THD* thd);
int change_active_index(uint keynr);
int general_fetch(byte* buf, uint direction, uint match_mode);
int general_fetch(uchar* buf, uint direction, uint match_mode);
int innobase_read_and_init_auto_inc(longlong* ret);
/* Init values for the class: */
......@@ -106,9 +106,9 @@ class ha_innobase: public handler
double scan_time();
double read_time(uint index, uint ranges, ha_rows rows);
int write_row(byte * buf);
int update_row(const byte * old_data, byte * new_data);
int delete_row(const byte * buf);
int write_row(uchar * buf);
int update_row(const uchar * old_data, uchar * new_data);
int delete_row(const uchar * buf);
bool was_semi_consistent_read();
void try_semi_consistent_read(bool yes);
void unlock_row();
......@@ -116,23 +116,23 @@ class ha_innobase: public handler
bool is_index_available(uint index);
int index_init(uint index, bool sorted);
int index_end();
int index_read(byte * buf, const byte * key,
int index_read(uchar * buf, const uchar * key,
uint key_len, enum ha_rkey_function find_flag);
int index_read_idx(byte * buf, uint index, const byte * key,
int index_read_idx(uchar * buf, uint index, const uchar * key,
uint key_len, enum ha_rkey_function find_flag);
int index_read_last(byte * buf, const byte * key, uint key_len);
int index_next(byte * buf);
int index_next_same(byte * buf, const byte *key, uint keylen);
int index_prev(byte * buf);
int index_first(byte * buf);
int index_last(byte * buf);
int index_read_last(uchar * buf, const uchar * key, uint key_len);
int index_next(uchar * buf);
int index_next_same(uchar * buf, const uchar *key, uint keylen);
int index_prev(uchar * buf);
int index_first(uchar * buf);
int index_last(uchar * buf);
int rnd_init(bool scan);
int rnd_end();
int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos);
int rnd_next(uchar *buf);
int rnd_pos(uchar * buf, uchar *pos);
void position(const byte *record);
void position(const uchar *record);
int info(uint);
int analyze(THD* thd,HA_CHECK_OPT* check_opt);
int optimize(THD* thd,HA_CHECK_OPT* check_opt);
......@@ -142,7 +142,7 @@ class ha_innobase: public handler
int external_lock(THD *thd, int lock_type);
int transactional_table_lock(THD *thd, int lock_type);
int start_stmt(THD *thd, thr_lock_type lock_type);
void position(byte *record);
void position(uchar *record);
ha_rows records_in_range(uint inx, key_range *min_key, key_range
*max_key);
ha_rows estimate_rows_upper_bound();
......@@ -182,7 +182,7 @@ class ha_innobase: public handler
static char *get_mysql_bin_log_name();
static ulonglong get_mysql_bin_log_pos();
bool primary_key_is_clustered() { return true; }
int cmp_ref(const byte *ref1, const byte *ref2);
int cmp_ref(const uchar *ref1, const uchar *ref2);
int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys);
int prepare_drop_index(TABLE *table_arg, uint *key_num,
uint num_of_keys);
......
......@@ -1473,6 +1473,9 @@ ibuf_entry_build(
*buf2++ = 0; /* write the compact format indicator */
}
for (i = 0; i < n_fields; i++) {
ulint fixed_len;
const dict_field_t* ifield;
/* We add 4 below because we have the 4 extra fields at the
start of an ibuf record */
......@@ -1480,10 +1483,30 @@ ibuf_entry_build(
entry_field = dtuple_get_nth_field(entry, i);
dfield_copy(field, entry_field);
ifield = dict_index_get_nth_field(index, i);
/* Prefix index columns of fixed-length columns are of
fixed length. However, in the function call below,
dfield_get_type(entry_field) contains the fixed length
of the column in the clustered index. Replace it with
the fixed length of the secondary index column. */
fixed_len = ifield->fixed_len;
#ifdef UNIV_DEBUG
if (fixed_len) {
/* dict_index_add_col() should guarantee these */
ut_ad(fixed_len <= (ulint) entry_field->type.len);
if (ifield->prefix_len) {
ut_ad(ifield->prefix_len == fixed_len);
} else {
ut_ad(fixed_len
== (ulint) entry_field->type.len);
}
}
#endif /* UNIV_DEBUG */
dtype_new_store_for_order_and_null_size(
buf2 + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE,
dfield_get_type(entry_field),
dict_index_get_nth_field(index, i)->prefix_len);
dfield_get_type(entry_field), fixed_len);
}
/* Store the type info in buf2 to field 3 of tuple */
......
......@@ -101,6 +101,17 @@ dict_col_copy_type_noninline(
/*=========================*/
const dict_col_t* col, /* in: column */
dtype_t* type); /* out: data type */
#ifdef UNIV_DEBUG
/*************************************************************************
Assert that a column and a data type match. */
UNIV_INLINE
ibool
dict_col_type_assert_equal(
/*=======================*/
/* out: TRUE */
const dict_col_t* col, /* in: column */
const dtype_t* type); /* in: data type */
#endif /* UNIV_DEBUG */
/***************************************************************************
Returns the minimum size of the column. */
UNIV_INLINE
......
......@@ -28,6 +28,30 @@ dict_col_copy_type(
type->mbmaxlen = col->mbmaxlen;
}
#ifdef UNIV_DEBUG
/*************************************************************************
Assert that a column and a data type match. */
UNIV_INLINE
ibool
dict_col_type_assert_equal(
/*=======================*/
/* out: TRUE */
const dict_col_t* col, /* in: column */
const dtype_t* type) /* in: data type */
{
ut_ad(col);
ut_ad(type);
ut_ad(col->mtype == type->mtype);
ut_ad(col->prtype == type->prtype);
ut_ad(col->len == type->len);
ut_ad(col->mbminlen == type->mbminlen);
ut_ad(col->mbmaxlen == type->mbmaxlen);
return(TRUE);
}
#endif /* UNIV_DEBUG */
/***************************************************************************
Returns the minimum size of the column. */
UNIV_INLINE
......
......@@ -164,6 +164,14 @@ struct dict_col_struct{
of an index */
};
/* DICT_MAX_INDEX_COL_LEN is measured in bytes and is the maximum
indexed column length (or indexed prefix length). It is set to 3*256,
so that one can create a column prefix index on 256 characters of a
TEXT or VARCHAR column also in the UTF-8 charset. In that charset,
a character may take at most 3 bytes.
This constant MUST NOT BE CHANGED, or the compatibility of InnoDB data
files would be at risk! */
#define DICT_MAX_INDEX_COL_LEN REC_MAX_INDEX_COL_LEN
/* Data structure for a field in an index */
......
......@@ -17,10 +17,13 @@ typedef byte rec_t;
#define REC_MAX_HEAP_NO (2 * 8192 - 1)
#define REC_MAX_N_OWNED (16 - 1)
/* REC_MAX_INDEX_COL_LEN is measured in bytes and is the max index column
length + 1. Starting from 4.1.6, we set it to 3 * 256, so that one can
create a column prefix index on 255 characters of a TEXT field also in the
UTF-8 charset. Under MySQL, a UTF-8 character may take at most 3 bytes. */
/* REC_MAX_INDEX_COL_LEN is measured in bytes and is the maximum
indexed column length (or indexed prefix length). It is set to 3*256,
so that one can create a column prefix index on 256 characters of a
TEXT or VARCHAR column also in the UTF-8 charset. In that charset,
a character may take at most 3 bytes.
This constant MUST NOT BE CHANGED, or the compatibility of InnoDB data
files would be at risk! */
#define REC_MAX_INDEX_COL_LEN 768
#endif
......@@ -742,7 +742,7 @@ rec_get_converted_size_comp(
case REC_STATUS_INFIMUM:
case REC_STATUS_SUPREMUM:
/* infimum or supremum record, 8 bytes */
return(size + 8); /* no extra data needed */
return(8); /* no extra data needed */
default:
ut_error;
return(ULINT_UNDEFINED);
......@@ -758,10 +758,13 @@ rec_get_converted_size_comp(
len = dtuple_get_nth_field(dtuple, i)->len;
col = dict_field_get_col(field);
ut_ad(len != UNIV_SQL_NULL || !(col->prtype & DATA_NOT_NULL));
ut_ad(dict_col_type_assert_equal(
col, dfield_get_type(dtuple_get_nth_field(
dtuple, i))));
if (len == UNIV_SQL_NULL) {
/* No length is stored for NULL fields. */
ut_ad(!(col->prtype & DATA_NOT_NULL));
continue;
}
......@@ -769,6 +772,9 @@ rec_get_converted_size_comp(
if (field->fixed_len) {
ut_ad(len == field->fixed_len);
/* dict_index_add_col() should guarantee this */
ut_ad(!field->prefix_len
|| field->fixed_len == field->prefix_len);
} else if (UNIV_UNLIKELY(j < n_ext) && i == ext[j]) {
j++;
size += 2;
......@@ -776,6 +782,10 @@ rec_get_converted_size_comp(
|| (col->len < 256 && col->mtype != DATA_BLOB)) {
size++;
} else {
/* For variable-length columns, we look up the
maximum length from the column itself. If this
is a prefix index column shorter than 256 bytes,
this will waste one byte. */
size += 2;
}
size += len;
......@@ -1046,6 +1056,11 @@ rec_convert_dtuple_to_rec_comp(
len = dfield_get_len(field);
fixed_len = dict_index_get_nth_field(index, i)->fixed_len;
ut_ad(dict_col_type_assert_equal(
dict_field_get_col(dict_index_get_nth_field(
index, i)),
dfield_get_type(field)));
if (!(dtype_get_prtype(type) & DATA_NOT_NULL)) {
if (len == UNIV_SQL_NULL)
continue;
......
......@@ -1144,7 +1144,7 @@ srv_conc_force_enter_innodb(
srv_conc_n_threads++;
trx->declared_to_be_inside_innodb = TRUE;
trx->n_tickets_to_enter_innodb = 0;
trx->n_tickets_to_enter_innodb = 1;
os_fast_mutex_unlock(&srv_conc_mutex);
}
......
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