diff options
author | Michael Widenius <monty@askmonty.org> | 2013-05-21 22:00:08 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2013-05-21 22:00:08 +0300 |
commit | 3143ad589a24ac7581e2195ba0dc13576cb3c9da (patch) | |
tree | 9c02baa18cdca6f60d80e2f7ee7f3f792c293ab9 | |
parent | 068c61978e3a81836d52b8caf11e044290159ad1 (diff) | |
download | mariadb-git-3143ad589a24ac7581e2195ba0dc13576cb3c9da.tar.gz |
Push a lot of small fixes to get larger parts to compile
31 files changed, 145 insertions, 155 deletions
diff --git a/include/m_string.h b/include/m_string.h index 9efa0376942..e3127720df4 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -159,7 +159,7 @@ size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to, (DBL_DIG + 2) significant digits + sign + "." + ("e-NNN" or MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used). */ -#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + max(5, MAX_DECPT_FOR_F_FORMAT)) \ +#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + MY_MAX(5, MAX_DECPT_FOR_F_FORMAT)) \ extern char *llstr(longlong value,char *buff); extern char *ullstr(longlong value,char *buff); diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 6d718a6baa6..6f8f9ddcfd5 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -885,7 +885,7 @@ write_eof_packet(THD *thd, uint server_status, uint statement_warn_count) is cleared between substatements, and mysqltest gets confused */ thd->cur_data->embedded_info->warning_count= - (thd->spcont ? 0 : min(statement_warn_count, 65535)); + (thd->spcont ? 0 : MY_MIN(statement_warn_count, 65535)); return FALSE; } diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc index f7f962deaca..c0227cf1292 100644 --- a/plugin/feedback/utils.cc +++ b/plugin/feedback/utils.cc @@ -389,7 +389,6 @@ int calculate_server_uid(char *dest) { uchar rawbuf[2 + 6]; uchar shabuf[SHA1_HASH_SIZE]; - SHA1_CONTEXT ctx; int2store(rawbuf, mysqld_port); if (my_gethwaddr(rawbuf + 2)) @@ -398,9 +397,7 @@ int calculate_server_uid(char *dest) return 1; } - mysql_sha1_reset(&ctx); - mysql_sha1_input(&ctx, rawbuf, sizeof(rawbuf)); - mysql_sha1_result(&ctx, shabuf); + compute_sha1_hash((uint8*) shabuf, (char*) rawbuf, sizeof(rawbuf)); assert(base64_needed_encoded_length(sizeof(shabuf)) <= SERVER_UID_SIZE); base64_encode(shabuf, sizeof(shabuf), dest); diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 9a943d8bb59..2413a0e57ea 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -429,7 +429,7 @@ Event_db_repository::index_read_for_db_for_i_s(THD *thd, TABLE *schema_table, key_info= event_table->key_info; - if (key_info->key_parts == 0 || + if (key_info->user_defined_key_parts == 0 || key_info->key_part[0].field != event_table->field[ET_FIELD_DB]) { /* Corrupted table: no index or index on a wrong column */ diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 3c0bdc724c1..cc46219ccb8 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1245,8 +1245,8 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data, } KEY_PART_INFO* key_part= key_info->key_part; - KEY_PART_INFO* end= key_part+key_info->key_parts; - DBUG_ASSERT(key_info->key_parts == sz); + KEY_PART_INFO* end= key_part+key_info->user_defined_key_parts; + DBUG_ASSERT(key_info->user_defined_key_parts == sz); for (unsigned i= 0; key_part != end; key_part++, i++) { const char *field_name= key_part->field->field_name; @@ -1576,7 +1576,7 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_key(uint inx, bool ha_ndbcluster::check_index_fields_not_null(KEY* key_info) { KEY_PART_INFO* key_part= key_info->key_part; - KEY_PART_INFO* end= key_part+key_info->key_parts; + KEY_PART_INFO* end= key_part+key_info->user_defined_key_parts; DBUG_ENTER("ha_ndbcluster::check_index_fields_not_null"); for (; key_part != end; key_part++) @@ -1733,7 +1733,7 @@ int ha_ndbcluster::set_primary_key(NdbOperation *op, const uchar *key) { KEY* key_info= table->key_info + table_share->primary_key; KEY_PART_INFO* key_part= key_info->key_part; - KEY_PART_INFO* end= key_part+key_info->key_parts; + KEY_PART_INFO* end= key_part+key_info->user_defined_key_parts; DBUG_ENTER("set_primary_key"); for (; key_part != end; key_part++) @@ -1755,7 +1755,7 @@ int ha_ndbcluster::set_primary_key_from_record(NdbOperation *op, const uchar *re { KEY* key_info= table->key_info + table_share->primary_key; KEY_PART_INFO* key_part= key_info->key_part; - KEY_PART_INFO* end= key_part+key_info->key_parts; + KEY_PART_INFO* end= key_part+key_info->user_defined_key_parts; DBUG_ENTER("set_primary_key_from_record"); for (; key_part != end; key_part++) @@ -1772,7 +1772,7 @@ bool ha_ndbcluster::check_index_fields_in_write_set(uint keyno) { KEY* key_info= table->key_info + keyno; KEY_PART_INFO* key_part= key_info->key_part; - KEY_PART_INFO* end= key_part+key_info->key_parts; + KEY_PART_INFO* end= key_part+key_info->user_defined_key_parts; uint i; DBUG_ENTER("check_index_fields_in_write_set"); @@ -1793,7 +1793,7 @@ int ha_ndbcluster::set_index_key_from_record(NdbOperation *op, { KEY* key_info= table->key_info + keyno; KEY_PART_INFO* key_part= key_info->key_part; - KEY_PART_INFO* end= key_part+key_info->key_parts; + KEY_PART_INFO* end= key_part+key_info->user_defined_key_parts; uint i; DBUG_ENTER("set_index_key_from_record"); @@ -1815,7 +1815,7 @@ ha_ndbcluster::set_index_key(NdbOperation *op, DBUG_ENTER("ha_ndbcluster::set_index_key"); uint i; KEY_PART_INFO* key_part= key_info->key_part; - KEY_PART_INFO* end= key_part+key_info->key_parts; + KEY_PART_INFO* end= key_part+key_info->user_defined_key_parts; for (i= 0; key_part != end; key_part++, i++) { @@ -2083,7 +2083,7 @@ check_null_in_record(const KEY* key_info, const uchar *record) { KEY_PART_INFO *curr_part, *end_part; curr_part= key_info->key_part; - end_part= curr_part + key_info->key_parts; + end_part= curr_part + key_info->user_defined_key_parts; while (curr_part != end_part) { @@ -2177,7 +2177,7 @@ int ha_ndbcluster::peek_indexed_rows(const uchar *record, NdbIndexOperation *iop; const NDBINDEX *unique_index = m_index[i].unique_index; key_part= key_info->key_part; - end= key_part + key_info->key_parts; + end= key_part + key_info->user_defined_key_parts; if (!(iop= trans->getNdbIndexOperation(unique_index, m_table)) || iop->readTuple(lm) != 0) ERR_RETURN(trans->getNdbError()); @@ -2405,7 +2405,7 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, uint range_no) { const KEY *const key_info= table->key_info + inx; - const uint key_parts= key_info->key_parts; + const uint key_parts= key_info->user_defined_key_parts; uint key_tot_len[2]; uint tot_len; uint i, j; @@ -3708,7 +3708,7 @@ check_null_in_key(const KEY* key_info, const uchar *key, uint key_len) KEY_PART_INFO *curr_part, *end_part; const uchar* end_ptr= key + key_len; curr_part= key_info->key_part; - end_part= curr_part + key_info->key_parts; + end_part= curr_part + key_info->user_defined_key_parts; for (; curr_part != end_part && key < end_ptr; curr_part++) { @@ -4079,7 +4079,7 @@ void ha_ndbcluster::position(const uchar *record) key_length= ref_length; key_info= table->key_info + table_share->primary_key; key_part= key_info->key_part; - end= key_part + key_info->key_parts; + end= key_part + key_info->user_defined_key_parts; buff= ref; for (; key_part != end; key_part++) @@ -5500,7 +5500,7 @@ int ha_ndbcluster::create(const char *name, for (i= 0, key_info= form->key_info; i < form->s->keys; i++, key_info++) { KEY_PART_INFO *key_part= key_info->key_part; - KEY_PART_INFO *end= key_part + key_info->key_parts; + KEY_PART_INFO *end= key_part + key_info->user_defined_key_parts; for (; key_part != end; key_part++) tab.getColumn(key_part->fieldnr-1)->setStorageType( NdbDictionary::Column::StorageTypeMemory); @@ -5860,7 +5860,7 @@ int ha_ndbcluster::create_ndb_index(const char *name, Ndb *ndb= get_ndb(); NdbDictionary::Dictionary *dict= ndb->getDictionary(); KEY_PART_INFO *key_part= key_info->key_part; - KEY_PART_INFO *end= key_part + key_info->key_parts; + KEY_PART_INFO *end= key_part + key_info->user_defined_key_parts; DBUG_ENTER("ha_ndbcluster::create_index"); DBUG_PRINT("enter", ("name: %s ", name)); diff --git a/sql/ha_ndbcluster_cond.cc b/sql/ha_ndbcluster_cond.cc index 9ab7fb6208d..85dca73c046 100644 --- a/sql/ha_ndbcluster_cond.cc +++ b/sql/ha_ndbcluster_cond.cc @@ -1431,7 +1431,7 @@ int ha_ndbcluster_cond::generate_scan_filter_from_key(NdbScanOperation *op, uchar *buf) { KEY_PART_INFO* key_part= key_info->key_part; - KEY_PART_INFO* end= key_part+key_info->key_parts; + KEY_PART_INFO* end= key_part+key_info->user_defined_key_parts; NdbScanFilter filter(op, true); // abort on too large int res; DBUG_ENTER("generate_scan_filter_from_key"); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 148a2329660..a77909ffea0 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1154,7 +1154,7 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, when ALTER TABLE <CMD> PARTITION ... it should only do named partitions, otherwise all partitions */ - if (!(thd->lex->alter_info.flags & ALTER_ADMIN_PARTITION) || + if (!(thd->lex->alter_info.flags & Alter_info::ALTER_ADMIN_PARTITION) || part_elem->part_state == PART_ADMIN) { if (m_is_sub_partitioned) @@ -4536,7 +4536,7 @@ int ha_partition::index_init(uint inx, bool sorted) KEY **key_info= m_curr_key_info; do { - for (i= 0; i < (*key_info)->key_parts; i++) + for (i= 0; i < (*key_info)->user_defined_key_parts; i++) bitmap_set_bit(table->read_set, (*key_info)->key_part[i].field->field_index); } while (*(++key_info)); @@ -6990,7 +6990,7 @@ void ha_partition::print_error(int error, myf errflag) DBUG_PRINT("enter", ("error: %d", error)); if ((error == HA_ERR_NO_PARTITION_FOUND) && - ! (thd->lex->alter_info.flags & ALTER_TRUNCATE_PARTITION)) + ! (thd->lex->alter_info.flags & Alter_info::ALTER_TRUNCATE_PARTITION)) m_part_info->print_no_partition_found(table); else { diff --git a/sql/handler.cc b/sql/handler.cc index 2e0ccc5e1e5..e8b1fca1651 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -61,7 +61,7 @@ static handlerton *installed_htons[128]; #define BITMAP_STACKBUF_SIZE (128/8) KEY_CREATE_INFO default_key_create_info= - { HA_KEY_ALG_UNDEF, 0, {NullS, 0}, {NullS, 0} }; +{ HA_KEY_ALG_UNDEF, 0, {NullS, 0}, {NullS, 0}, 0 }; /* number of entries in handlertons[] */ ulong total_ha= 0; @@ -2222,8 +2222,8 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, if (likely(error == 0)) { my_bool temp_table= (my_bool)is_prefix(alias, tmp_file_prefix); - PSI_CALL(drop_table_share)(temp_table, db, strlen(db), - alias, strlen(alias)); + PSI_TABLE_CALL(drop_table_share)(temp_table, db, strlen(db), + alias, strlen(alias)); } #endif @@ -2301,7 +2301,7 @@ void handler::unbind_psi() Notify the instrumentation that this table is not owned by this thread any more. */ - PSI_CALL(unbind_table)(m_psi); + PSI_TABLE_CALL(unbind_table)(m_psi); #endif } @@ -2313,7 +2313,7 @@ void handler::rebind_psi() by this thread. */ PSI_table_share *share_psi= ha_table_share_psi(table_share); - m_psi= PSI_CALL(rebind_table)(share_psi, this, m_psi); + m_psi= PSI_TABLE_CALL(rebind_table)(share_psi, this, m_psi); #endif } @@ -2364,7 +2364,7 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode, DBUG_ASSERT(table_share != NULL); #ifdef HAVE_PSI_TABLE_INTERFACE PSI_table_share *share_psi= ha_table_share_psi(table_share); - m_psi= PSI_CALL(open_table)(share_psi, this); + m_psi= PSI_TABLE_CALL(open_table)(share_psi, this); #endif if (table->s->db_options_in_use & HA_OPTION_READ_ONLY_DATA) @@ -2397,7 +2397,7 @@ int handler::ha_close(void) if (table->in_use) status_var_add(table->in_use->status_var.rows_tmp_read, rows_tmp_read); #ifdef HAVE_PSI_TABLE_INTERFACE - PSI_CALL(close_table)(m_psi); + PSI_TABLE_CALL(close_table)(m_psi); m_psi= NULL; /* instrumentation handle, invalid after close_table() */ #endif @@ -3190,7 +3190,7 @@ void handler::print_error(int error, myf errflag) uint key_nr=get_dup_key(error); if ((int) key_nr >= 0) { - print_keydup_error(key_nr, ER(ER_DUP_ENTRY_WITH_KEY_NAME), errflag); + print_keydup_error(table, &table->key_info[key_nr], errflag); DBUG_VOID_RETURN; } } @@ -3434,7 +3434,7 @@ int handler::check_collation_compatibility() for (; key < key_end; key++) { KEY_PART_INFO *key_part= key->key_part; - KEY_PART_INFO *key_part_end= key_part + key->key_parts; + KEY_PART_INFO *key_part_end= key_part + key->user_defined_key_parts; for (; key_part < key_part_end; key_part++) { if (!key_part->fieldnr) @@ -3475,7 +3475,7 @@ int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt) for (; keyinfo < keyend; keyinfo++) { keypart= keyinfo->key_part; - keypartend= keypart + keyinfo->key_parts; + keypartend= keypart + keyinfo->user_defined_key_parts; for (; keypart < keypartend; keypart++) { if (!keypart->fieldnr) @@ -4100,7 +4100,7 @@ int handler::index_next_same(uchar *buf, const uchar *key, uint keylen) table->record[0]= buf; key_info= table->key_info + active_index; key_part= key_info->key_part; - key_part_end= key_part + key_info->key_parts; + key_part_end= key_part + key_info->user_defined_key_parts; for (; key_part < key_part_end; key_part++) { DBUG_ASSERT(key_part->field); @@ -4298,7 +4298,7 @@ int ha_create_table(THD *thd, const char *path, goto err; #ifdef HAVE_PSI_TABLE_INTERFACE - share.m_psi= PSI_CALL(get_table_share)(temp_table, &share); + share.m_psi= PSI_TABLE_CALL(get_table_share)(temp_table, &share); #endif if (open_table_from_share(thd, &share, "", 0, (uint) READ_ALL, 0, &table, TRUE)) @@ -4316,8 +4316,8 @@ int ha_create_table(THD *thd, const char *path, strxmov(name_buff, db, ".", table_name, NullS); my_error(ER_CANT_CREATE_TABLE, MYF(ME_BELL+ME_WAITTANG), name_buff, error); #ifdef HAVE_PSI_TABLE_INTERFACE - PSI_CALL(drop_table_share)(temp_table, db, strlen(db), table_name, - strlen(table_name)); + PSI_TABLE_CALL(drop_table_share)(temp_table, db, strlen(db), table_name, + strlen(table_name)); #endif } err: diff --git a/sql/item_func.cc b/sql/item_func.cc index 1692f2b3d89..a8631093f3e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -6171,7 +6171,7 @@ bool Item_func_match::fix_index() for (keynr=0 ; keynr < fts ; keynr++) { KEY *ft_key=&table->key_info[ft_to_key[keynr]]; - uint key_parts=ft_key->key_parts; + uint key_parts=ft_key->user_defined_key_parts; for (uint part=0 ; part < key_parts ; part++) { @@ -6203,7 +6203,7 @@ bool Item_func_match::fix_index() { // partial keys doesn't work if (max_cnt < arg_count-1 || - max_cnt < table->key_info[ft_to_key[keynr]].key_parts) + max_cnt < table->key_info[ft_to_key[keynr]].user_defined_key_parts) continue; key=ft_to_key[keynr]; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 0aafe2c3a74..e853faae88f 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -102,23 +102,6 @@ String *Item_str_func::val_str_from_val_str_ascii(String *str, String *str2) } - -/* - Convert an array of bytes to a hexadecimal representation. - - Used to generate a hexadecimal representation of a message digest. -*/ -static void array_to_hex(char *to, const unsigned char *str, uint len) -{ - const unsigned char *str_end= str + len; - for (; str != str_end; ++str) - { - *to++= _dig_vec_lower[((uchar) *str) >> 4]; - *to++= _dig_vec_lower[((uchar) *str) & 0x0F]; - } -} - - bool Item_str_func::fix_fields(THD *thd, Item **ref) { bool res= Item_func::fix_fields(thd, ref); @@ -217,17 +200,11 @@ String *Item_func_sha::val_str_ascii(String *str) String * sptr= args[0]->val_str(str); if (sptr) /* If we got value different from NULL */ { - SHA1_CONTEXT context; /* Context used to generate SHA1 hash */ /* Temporary buffer to store 160bit digest */ uint8 digest[SHA1_HASH_SIZE]; - mysql_sha1_reset(&context); /* We do not have to check for error here */ - /* No need to check error as the only case would be too long message */ - mysql_sha1_input(&context, - (const uchar *) sptr->ptr(), sptr->length()); - + compute_sha1_hash(digest, (const char *) sptr->ptr(), sptr->length()); /* Ensure that memory is free and we got result */ - if (!( str->alloc(SHA1_HASH_SIZE*2) || - (mysql_sha1_result(&context,digest)))) + if (!str->alloc(SHA1_HASH_SIZE*2)) { array_to_hex((char *) str->ptr(), digest, SHA1_HASH_SIZE); str->set_charset(&my_charset_numeric); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 87e96da8f62..5652c921d27 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -3753,7 +3753,7 @@ void subselect_uniquesubquery_engine::print(String *str) { KEY *key_info= tab->table->key_info + tab->ref.key; str->append(STRING_WITH_LEN("<primary_index_lookup>(")); - for (uint i= 0; i < key_info->key_parts; i++) + for (uint i= 0; i < key_info->user_defined_key_parts; i++) tab->ref.items[i]->print(str); str->append(STRING_WITH_LEN(" in ")); str->append(tab->table->s->table_name.str, tab->table->s->table_name.length); @@ -4310,7 +4310,8 @@ bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id) DBUG_ASSERT( tmp_table->s->uniques || tmp_table->key_info->key_length >= tmp_table->file->max_key_length() || - tmp_table->key_info->key_parts > tmp_table->file->max_key_parts()); + tmp_table->key_info->user_defined_key_parts > + tmp_table->file->max_key_parts()); free_tmp_table(thd, tmp_table); tmp_table= NULL; delete result; @@ -4324,7 +4325,7 @@ bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id) */ DBUG_ASSERT(tmp_table->s->keys == 1 && ((Item_in_subselect *) item)->left_expr->cols() == - tmp_table->key_info->key_parts); + tmp_table->key_info->user_defined_key_parts); if (make_semi_join_conds() || /* A unique_engine is used both for complete and partial matching. */ diff --git a/sql/key.cc b/sql/key.cc index ebf9259d469..c1def96797c 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -78,7 +78,7 @@ int find_ref_key(KEY *key, uint key_count, uchar *record, Field *field, KEY_PART_INFO *key_part; *key_length=0; for (j=0, key_part=key_info->key_part ; - j < key_info->key_parts ; + j < key_info->user_defined_key_parts ; j++, key_part++) { if (key_part->offset == fieldpos) @@ -349,7 +349,7 @@ bool key_cmp_if_same(TABLE *table,const uchar *key,uint idx,uint key_length) idx Key number */ -void key_unpack(String *to,TABLE *table,uint idx) +void key_unpack(String *to,TABLE *table, KEY *key) { KEY_PART_INFO *key_part,*key_part_end; Field *field; @@ -358,8 +358,8 @@ void key_unpack(String *to,TABLE *table,uint idx) DBUG_ENTER("key_unpack"); to->length(0); - for (key_part=table->key_info[idx].key_part,key_part_end=key_part+ - table->key_info[idx].key_parts ; + for (key_part=key->key_part,key_part_end=key_part+ + key->user_defined_key_parts ; key_part < key_part_end; key_part++) { @@ -546,7 +546,7 @@ int key_rec_cmp(void *key_p, uchar *first_rec, uchar *second_rec) /* loop over all given keys */ do { - key_parts= key_info->key_parts; + key_parts= key_info->user_defined_key_parts; key_part= key_info->key_part; key_part_num= 0; diff --git a/sql/key.h b/sql/key.h index 8bf6f88fa04..42e29a0937d 100644 --- a/sql/key.h +++ b/sql/key.h @@ -32,7 +32,7 @@ void key_copy(uchar *to_key, uchar *from_record, KEY *key_info, uint key_length, void key_restore(uchar *to_record, uchar *from_key, KEY *key_info, uint key_length); bool key_cmp_if_same(TABLE *form,const uchar *key,uint index,uint key_length); -void key_unpack(String *to,TABLE *form,uint index); +void key_unpack(String *to, TABLE *form, KEY *key); bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields); int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length); ulong key_hashnr(KEY *key_info, uint used_key_parts, const uchar *key); diff --git a/sql/log_event.cc b/sql/log_event.cc index 2dafd754293..9481261d3ef 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -10440,7 +10440,7 @@ int Rows_log_event::find_key() We can only use a non-unique key if it allows range scans (ie. skip FULLTEXT indexes and such). */ - last_part= key->key_parts - 1; + last_part= key->user_defined_key_parts - 1; DBUG_PRINT("info", ("Index %s rec_per_key[%u]= %lu", key->name, last_part, key->rec_per_key[last_part])); if (!(m_table->file->index_flags(i, last_part, 1) & HA_READ_NEXT)) @@ -10718,7 +10718,7 @@ int Rows_log_event::find_row(const Relay_log_info *rli) field in the BI image that is null and part of UNNI. */ bool null_found= FALSE; - for (uint i=0; i < keyinfo->key_parts && !null_found; i++) + for (uint i=0; i < keyinfo->user_defined_key_parts && !null_found; i++) { uint fieldnr= keyinfo->key_part[i].fieldnr - 1; Field **f= table->field+fieldnr; diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 566a367430c..3511c44c3b9 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -2366,7 +2366,7 @@ int Old_rows_log_event::find_row(const Relay_log_info *rli) field in the BI image that is null and part of UNNI. */ bool null_found= FALSE; - for (uint i=0; i < keyinfo->key_parts && !null_found; i++) + for (uint i=0; i < keyinfo->user_defined_key_parts && !null_found; i++) { uint fieldnr= keyinfo->key_part[i].fieldnr - 1; Field **f= table->field+fieldnr; diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 04557a636d5..f1823ed69fa 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -550,7 +550,7 @@ int Mrr_ordered_index_reader::init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, KEY *key_info= &file->get_table()->key_info[file->active_index]; keypar.index_ranges_unique= test(key_info->flags & HA_NOSAME && - key_info->key_parts == + key_info->user_defined_key_parts == my_count_bits(keypar.key_tuple_map)); mrr_iter= seq_funcs->init(seq_init_param, n_ranges, mode); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8e8414a7acc..a5202cb8888 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2634,7 +2634,7 @@ static bool cache_thread() Delete the instrumentation for the job that just completed, before parking this pthread in the cache (blocked on COND_thread_cache). */ - PSI_CALL(delete_current_thread)(); + PSI_THREAD_CALL(delete_current_thread)(); #endif while (!abort_loop && ! wake_thread && ! kill_cached_threads) @@ -2655,9 +2655,9 @@ static bool cache_thread() Create new instrumentation for the new THD job, and attach it to this running pthread. */ - PSI_thread *psi= PSI_CALL(new_thread)(key_thread_one_connection, - thd, thd->thread_id); - PSI_CALL(set_thread)(psi); + PSI_thread *psi= PSI_THREAD_CALL(new_thread)(key_thread_one_connection, + thd, thd->thread_id); + PSI_THREAD_CALL(set_thread)(psi); #endif /* @@ -3176,7 +3176,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) abort_loop=1; // mark abort for threads #ifdef HAVE_PSI_THREAD_INTERFACE /* Delete the instrumentation for the signal thread */ - PSI_CALL(delete_current_thread)(); + PSI_THREAD_CALL(delete_current_thread)(); #endif #ifdef USE_ONE_SIGNAL_HAND pthread_t tmp; @@ -5000,8 +5000,8 @@ int mysqld_main(int argc, char **argv) */ init_server_psi_keys(); /* Instrument the main thread */ - PSI_thread *psi= PSI_CALL(new_thread)(key_thread_main, NULL, 0); - PSI_CALL(set_thread)(psi); + PSI_thread *psi= PSI_THREAD_CALL(new_thread)(key_thread_main, NULL, 0); + PSI_THREAD_CALL(set_thread)(psi); /* Now that some instrumentation is in place, @@ -5282,7 +5282,7 @@ int mysqld_main(int argc, char **argv) Disable the main thread instrumentation, to avoid recording events during the shutdown. */ - PSI_CALL(delete_current_thread)(); + PSI_THREAD_CALL(delete_current_thread)(); #endif /* Wait until cleanup is done */ diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc index df9dae8e442..fb55aea1968 100644 --- a/sql/opt_index_cond_pushdown.cc +++ b/sql/opt_index_cond_pushdown.cc @@ -117,7 +117,7 @@ bool uses_index_fields_only(Item *item, TABLE *tbl, uint keyno, return FALSE; KEY *key_info= tbl->key_info + keyno; KEY_PART_INFO *key_part= key_info->key_part; - KEY_PART_INFO *key_part_end= key_part + key_info->key_parts; + KEY_PART_INFO *key_part_end= key_part + key_info->user_defined_key_parts; for ( ; key_part < key_part_end; key_part++) { if (field->eq(key_part->field)) @@ -129,7 +129,7 @@ bool uses_index_fields_only(Item *item, TABLE *tbl, uint keyno, { key_info= tbl->key_info + tbl->s->primary_key; key_part= key_info->key_part; - key_part_end= key_part + key_info->key_parts; + key_part_end= key_part + key_info->user_defined_key_parts; for ( ; key_part < key_part_end; key_part++) { /* diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e3bca89d6df..8629ea57fb9 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2849,7 +2849,7 @@ static int fill_used_fields_bitmap(PARAM *param) /* The table uses clustered PK and it is not internally generated */ KEY_PART_INFO *key_part= param->table->key_info[pk].key_part; KEY_PART_INFO *key_part_end= key_part + - param->table->key_info[pk].key_parts; + param->table->key_info[pk].user_defined_key_parts; for (;key_part != key_part_end; ++key_part) bitmap_clear_bit(¶m->needed_fields, key_part->fieldnr-1); } @@ -5900,7 +5900,7 @@ ROR_SCAN_INFO *make_ror_scan(const PARAM *param, int idx, SEL_ARG *sel_arg) KEY_PART_INFO *key_part= param->table->key_info[keynr].key_part; KEY_PART_INFO *key_part_end= key_part + - param->table->key_info[keynr].key_parts; + param->table->key_info[keynr].user_defined_key_parts; for (;key_part != key_part_end; ++key_part) { if (bitmap_is_set(¶m->needed_fields, key_part->fieldnr-1)) @@ -6573,7 +6573,7 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, for (ROR_SCAN_INFO **scan= tree->ror_scans; scan != ror_scans_end; ++scan) (*scan)->key_components= - param->table->key_info[(*scan)->keynr].key_parts; + param->table->key_info[(*scan)->keynr].user_defined_key_parts; /* Run covering-ROR-search algorithm. @@ -10119,7 +10119,7 @@ static bool is_key_scan_ror(PARAM *param, uint keynr, uint8 nparts) KEY *table_key= param->table->key_info + keynr; KEY_PART_INFO *key_part= table_key->key_part + nparts; KEY_PART_INFO *key_part_end= (table_key->key_part + - table_key->key_parts); + table_key->user_defined_key_parts); uint pk_number; for (KEY_PART_INFO *kp= table_key->key_part; kp < key_part; kp++) @@ -10140,7 +10140,7 @@ static bool is_key_scan_ror(PARAM *param, uint keynr, uint8 nparts) KEY_PART_INFO *pk_part= param->table->key_info[pk_number].key_part; KEY_PART_INFO *pk_part_end= pk_part + - param->table->key_info[pk_number].key_parts; + param->table->key_info[pk_number].user_defined_key_parts; for (;(key_part!=key_part_end) && (pk_part != pk_part_end); ++key_part, ++pk_part) { @@ -10301,7 +10301,7 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key, { KEY *table_key=quick->head->key_info+quick->index; flag=EQ_RANGE; - if ((table_key->flags & HA_NOSAME) && key->part == table_key->key_parts-1) + if ((table_key->flags & HA_NOSAME) && key->part == table_key->user_defined_key_parts-1) { if (!(table_key->flags & HA_NULL_PART_KEY) || !null_part_in_key(key, @@ -11328,7 +11328,7 @@ int QUICK_SELECT_DESC::get_next() if (last_range) { // Already read through key result = ((last_range->flag & EQ_RANGE && - used_key_parts <= head->key_info[index].key_parts) ? + used_key_parts <= head->key_info[index].user_defined_key_parts) ? file->ha_index_next_same(record, last_range->min_key, last_range->min_length) : file->ha_index_prev(record)); @@ -11356,7 +11356,7 @@ int QUICK_SELECT_DESC::get_next() } if (last_range->flag & EQ_RANGE && - used_key_parts <= head->key_info[index].key_parts) + used_key_parts <= head->key_info[index].user_defined_key_parts) { result= file->ha_index_read_map(record, last_range->max_key, @@ -11367,7 +11367,7 @@ int QUICK_SELECT_DESC::get_next() { DBUG_ASSERT(last_range->flag & NEAR_MAX || (last_range->flag & EQ_RANGE && - used_key_parts > head->key_info[index].key_parts) || + used_key_parts > head->key_info[index].user_defined_key_parts) || range_reads_after_key(last_range)); result= file->ha_index_read_map(record, last_range->max_key, last_range->max_keypart_map, @@ -11981,7 +11981,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) does not qualify as covering in our case. If this is the case, below we check that all query fields are indeed covered by 'cur_index'. */ - if (cur_index_info->key_parts == table->actual_n_key_parts(cur_index_info) + if (cur_index_info->user_defined_key_parts == table->actual_n_key_parts(cur_index_info) && pk < MAX_KEY && cur_index != pk && (table->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX)) { diff --git a/sql/opt_range_mrr.cc b/sql/opt_range_mrr.cc index e03a1e2e644..72c1fa0a8c9 100644 --- a/sql/opt_range_mrr.cc +++ b/sql/opt_range_mrr.cc @@ -268,7 +268,7 @@ walk_up_n_right: range->end_key.keypart_map= make_prev_keypart_map(cur->max_key_parts); if (!(cur->min_key_flag & ~NULL_RANGE) && !cur->max_key_flag && - (uint)key_tree->part+1 == seq->param->table->key_info[seq->real_keyno].key_parts && + (uint)key_tree->part+1 == seq->param->table->key_info[seq->real_keyno].user_defined_key_parts && (seq->param->table->key_info[seq->real_keyno].flags & HA_NOSAME) && range->start_key.length == range->end_key.length && !memcmp(seq->param->min_key,seq->param->max_key,range->start_key.length)) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index b8aa4c7e944..f5f72fcdd9c 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -739,7 +739,7 @@ end: static void clear_indicator_in_key_fields(KEY *key_info) { KEY_PART_INFO *key_part; - uint key_parts= key_info->key_parts, i; + uint key_parts= key_info->user_defined_key_parts, i; for (i= 0, key_part=key_info->key_part; i < key_parts; i++, key_part++) key_part->field->flags&= (~GET_FIXED_FIELDS_FLAG); } @@ -759,7 +759,7 @@ static void clear_indicator_in_key_fields(KEY *key_info) static void set_indicator_in_key_fields(KEY *key_info) { KEY_PART_INFO *key_part; - uint key_parts= key_info->key_parts, i; + uint key_parts= key_info->user_defined_key_parts, i; for (i= 0, key_part=key_info->key_part; i < key_parts; i++, key_part++) key_part->field->flags|= GET_FIXED_FIELDS_FLAG; } @@ -6941,7 +6941,7 @@ void set_key_field_ptr(KEY *key_info, const uchar *new_buf, const uchar *old_buf) { KEY_PART_INFO *key_part= key_info->key_part; - uint key_parts= key_info->key_parts; + uint key_parts= key_info->user_defined_key_parts; uint i= 0; my_ptrdiff_t diff= (new_buf - old_buf); DBUG_ENTER("set_key_field_ptr"); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e1b2beabd32..ab0fc173ca9 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12105,7 +12105,7 @@ static int compare_fields_by_table_order(Item *field1, if (!cmp) { KEY *key_info= tab->table->key_info + keyno; - for (uint i= 0; i < key_info->key_parts; i++) + for (uint i= 0; i < key_info->user_defined_key_parts; i++) { Field *fld= key_info->key_part[i].field; if (fld->eq(f2->field)) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 74a554d8c6c..9a6717ff318 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1738,7 +1738,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, packet->append(STRING_WITH_LEN(" (")); - for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) + for (uint j=0 ; j < key_info->user_defined_key_parts ; j++,key_part++) { if (j) packet->append(','); @@ -5973,7 +5973,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, { KEY_PART_INFO *key_part= key_info->key_part; const char *str; - for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) + for (uint j=0 ; j < key_info->user_defined_key_parts ; j++,key_part++) { restore_record(table, s->default_values); table->field[0]->store(STRING_WITH_LEN("def"), cs); @@ -6414,7 +6414,7 @@ static int get_schema_key_column_usage_record(THD *thd, continue; uint f_idx= 0; KEY_PART_INFO *key_part= key_info->key_part; - for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) + for (uint j=0 ; j < key_info->user_defined_key_parts ; j++,key_part++) { if (key_part->field) { diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index e34b4b21819..553146b1f7f 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2455,12 +2455,12 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables) } key_part_map ext_key_part_map= key_info->ext_key_part_map; - if (key_info->key_parts != key_info->ext_key_parts && - key_info->read_stats->get_avg_frequency(key_info->key_parts) == 0) + if (key_info->user_defined_key_parts != key_info->ext_key_parts && + key_info->read_stats->get_avg_frequency(key_info->user_defined_key_parts) == 0) { KEY *pk_key_info= table_share->key_info + table_share->primary_key; - uint k= key_info->key_parts; - uint pk_parts= pk_key_info->key_parts; + uint k= key_info->user_defined_key_parts; + uint pk_parts= pk_key_info->user_defined_key_parts; ha_rows n_rows= read_stats->cardinality; double k_dist= n_rows / key_info->read_stats->get_avg_frequency(k-1); uint m= 0; @@ -2842,7 +2842,7 @@ int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info, } else { - for (uint i= key_info->key_parts; i < key_info->ext_key_parts; i++) + for (uint i= key_info->user_defined_key_parts; i < key_info->ext_key_parts; i++) { index_stat.set_key_fields(key_info, i+1); if (index_stat.find_next_stat_for_prefix(4)) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f9dea58bb32..1c064d612ba 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3265,8 +3265,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, if (key->type == Key::FOREIGN_KEY) { fk_key_count++; - if (((Foreign_key *)key)->validate(alter_info->create_list)) - DBUG_RETURN(TRUE); Foreign_key *fk_key= (Foreign_key*) key; if (fk_key->ref_columns.elements && fk_key->ref_columns.elements != fk_key->columns.elements) @@ -3392,7 +3390,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, if (key->generated) key_info->flags|= HA_GENERATED_KEY; - key_info->key_parts=(uint8) key->columns.elements; + key_info->user_defined_key_parts=(uint8) key->columns.elements; key_info->key_part=key_part_info; key_info->usable_key_parts= key_number; key_info->algorithm= key->key_create_info.algorithm; @@ -3429,7 +3427,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, MYF(0)); DBUG_RETURN(TRUE); } - if (key_info->key_parts != 1) + if (key_info->user_defined_key_parts != 1) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "SPATIAL INDEX"); DBUG_RETURN(TRUE); @@ -3438,7 +3436,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, else if (key_info->algorithm == HA_KEY_ALG_RTREE) { #ifdef HAVE_RTREE_KEYS - if ((key_info->key_parts & 1) == 1) + if ((key_info->user_defined_key_parts & 1) == 1) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "RTREE INDEX"); DBUG_RETURN(TRUE); @@ -4739,8 +4737,8 @@ mysql_rename_table(handlerton *base, const char *old_db, if (likely(error == 0)) { my_bool temp_table= (my_bool)is_prefix(old_name, tmp_file_prefix); - PSI_CALL(drop_table_share)(temp_table, old_db, strlen(old_db), - old_name, strlen(old_name)); + PSI_TABLE_CALL(drop_table_share)(temp_table, old_db, strlen(old_db), + old_name, strlen(old_name)); } #endif @@ -5287,7 +5285,7 @@ mysql_compare_tables(TABLE *table, if (key_info->key_part[j].fieldnr-1 == field->field_index) { (void) delete_statistics_for_index(thd, table, key_info, - j >= key_info->key_parts); + j >= key_info->user_defined_key_parts); break; } } @@ -5321,7 +5319,8 @@ mysql_compare_tables(TABLE *table, for (table_key= table->key_info; table_key < table_key_end; table_key++) { KEY_PART_INFO *table_part; - KEY_PART_INFO *table_part_end= table_key->key_part + table_key->key_parts; + KEY_PART_INFO *table_part_end= (table_key->key_part + + table_key->user_defined_key_parts); KEY_PART_INFO *new_part; /* @@ -5358,7 +5357,7 @@ mysql_compare_tables(TABLE *table, if ((table_key->algorithm != new_key->algorithm) || ((table_key->flags & HA_KEYFLAG_MASK) != (new_key->flags & HA_KEYFLAG_MASK)) || - (table_key->key_parts != new_key->key_parts)) + (table_key->user_defined_key_parts != new_key->user_defined_key_parts)) goto index_changed; /* @@ -5385,7 +5384,7 @@ mysql_compare_tables(TABLE *table, (*index_drop_buffer)[(*index_drop_count)++]= table_key - table->key_info; (*index_add_buffer)[(*index_add_count)++]= new_key - *key_info_buffer; key_part= new_key->key_part; - end= key_part + new_key->key_parts; + end= key_part + new_key->user_defined_key_parts; for(; key_part != end; key_part++) { // Mark field to be part of new key @@ -5400,7 +5399,7 @@ mysql_compare_tables(TABLE *table, KEY *tab_key_info= table->key_info; for (uint j=0; j < table->s->keys; j++, tab_key_info++) { - if (tab_key_info->key_parts != tab_key_info->ext_key_parts) + if (tab_key_info->user_defined_key_parts != tab_key_info->ext_key_parts) (void) delete_statistics_for_index(thd, table, tab_key_info, TRUE); } @@ -5429,7 +5428,7 @@ mysql_compare_tables(TABLE *table, /* Key not found. Add the offset of the key to the add buffer. */ (*index_add_buffer)[(*index_add_count)++]= new_key - *key_info_buffer; key_part= new_key->key_part; - end= key_part + new_key->key_parts; + end= key_part + new_key->user_defined_key_parts; for(; key_part != end; key_part++) { // Mark field to be part of new key @@ -5827,7 +5826,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, KEY *tab_key_info= table->key_info; for (uint j=0; j < table->s->keys; j++, tab_key_info++) { - if (tab_key_info->key_parts != tab_key_info->ext_key_parts) + if (tab_key_info->user_defined_key_parts != tab_key_info->ext_key_parts) (void) delete_statistics_for_index(thd, table, tab_key_info, TRUE); } @@ -5840,7 +5839,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, KEY_PART_INFO *key_part= key_info->key_part; key_parts.empty(); bool delete_index_stat= FALSE; - for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) + for (uint j=0 ; j < key_info->user_defined_key_parts ; j++,key_part++) { if (!key_part->field) continue; // Wrong field (from UNIREG) @@ -5914,7 +5913,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (delete_index_stat) (void) delete_statistics_for_index(thd, table, key_info, FALSE); else if (modified_primary_key && - key_info->key_parts != key_info->ext_key_parts) + key_info->user_defined_key_parts != key_info->ext_key_parts) (void) delete_statistics_for_index(thd, table, key_info, TRUE); } @@ -6584,7 +6583,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, } else { - KEY_PART_INFO *part_end= key->key_part + key->key_parts; + KEY_PART_INFO *part_end= key->key_part + key->user_defined_key_parts; bool is_candidate_key= true; /* Non-primary unique key. */ @@ -6627,7 +6626,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, { /* Unique key */ - KEY_PART_INFO *part_end= key->key_part + key->key_parts; + KEY_PART_INFO *part_end= key->key_part + key->user_defined_key_parts; bool is_candidate_key= true; /* @@ -6950,7 +6949,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, /* Copy the KEY struct. */ *key= key_info_buffer[*idx_p]; /* Fix the key parts. */ - part_end= key->key_part + key->key_parts; + part_end= key->key_part + key->user_defined_key_parts; for (key_part= key->key_part; key_part < part_end; key_part++) key_part->field= table->field[key_part->fieldnr]; } @@ -7657,7 +7656,8 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to, (to->key_info[0].key_part[0].field->flags & AUTO_INCREMENT_FLAG)) err_msg= ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE); - to->file->print_keydup_error(key_nr, err_msg, MYF(0)); + to->file->print_keydup_error(table, &table->key_info[key_nr], + err_msg, MYF(0)); break; } } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 02f70c12ad2..c1953ba20f5 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1816,7 +1816,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view) if ((key_info->flags & (HA_NOSAME | HA_NULL_PART_KEY)) == HA_NOSAME) { KEY_PART_INFO *key_part= key_info->key_part; - KEY_PART_INFO *key_part_end= key_part + key_info->key_parts; + KEY_PART_INFO *key_part_end= key_part + key_info->user_defined_key_parts; /* check that all key parts are used */ for (;;) diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index f5cb284c7c4..9a6fcb2c8f2 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -1237,12 +1237,12 @@ bool ha_federatedx::create_where_from_key(String *to, tmp.append(STRING_WITH_LEN(" (")); } - for (key_part= key_info->key_part, - remainder= key_info->key_parts, - length= ranges[i]->length, - ptr= ranges[i]->key; ; + for (key_part= key_info->key_part, + remainder= key_info->user_defined_key_parts, + length= ranges[i]->length, + ptr= ranges[i]->key; ; remainder--, - key_part++) + key_part++) { Field *field= key_part->field; uint store_length= key_part->store_length; diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 092e1a8a79e..fb44307fa44 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -511,7 +511,7 @@ static int table2maria(TABLE *table_arg, data_file_type row_type, pos->algorithm; keydef[i].block_length= pos->block_size; keydef[i].seg= keyseg; - keydef[i].keysegs= pos->key_parts; + keydef[i].keysegs= pos->user_defined_key_parts; for (j= 0; j < pos->user_defined_key_parts; j++) { Field *field= pos->key_part[j].field; @@ -1642,8 +1642,8 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) } if (error && file->create_unique_index_by_sort && share->state.dupp_key != MAX_KEY) - print_keydup_error(share->state.dupp_key, - ER(ER_DUP_ENTRY_WITH_KEY_NAME), MYF(0)); + print_keydup_error(table, &table->key_info[share->state.dupp_key], + MYF(0)); } else { @@ -2471,11 +2471,11 @@ int ha_maria::info(uint flag) share->keys_in_use.intersect_extended(maria_info.key_map); share->keys_for_keyread.intersect(share->keys_in_use); share->db_record_offset= maria_info.record_offset; - if (share->user_defined_key_parts) + if (share->key_parts) { ulong *to= table->key_info[0].rec_per_key, *end; double *from= maria_info.rec_per_key; - for (end= to+ share->user_defined_key_parts ; to < end ; to++, from++) + for (end= to+ share->key_parts ; to < end ; to++, from++) *to= (ulong) (*from + 0.5); } diff --git a/storage/maria/ma_ft_nlq_search.c b/storage/maria/ma_ft_nlq_search.c index c6d9c2411c6..613f13e64a9 100644 --- a/storage/maria/ma_ft_nlq_search.c +++ b/storage/maria/ma_ft_nlq_search.c @@ -71,10 +71,11 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) TREE_ELEMENT *selem; double gweight=1; MARIA_HA *info= aio->info; + MARIA_SHARE *share= info->s; uchar *keybuff= aio->keybuff; - MARIA_KEYDEF *keyinfo= info->s->keyinfo+aio->keynr; - my_off_t key_root=info->s->state.key_root[aio->keynr]; - uint extra=HA_FT_WLEN+info->s->rec_reflength; + MARIA_KEYDEF *keyinfo= share->keyinfo+aio->keynr; + my_off_t key_root; + uint extra=HA_FT_WLEN+share->rec_reflength; MARIA_KEY key; #if HA_FT_WTYPE == HA_KEYTYPE_FLOAT float tmp_weight; @@ -92,6 +93,11 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) key.data_length-= HA_FT_WLEN; doc_cnt=0; + if (share->lock_key_trees) + mysql_rwlock_rdlock(&share->keyinfo[aio->keynr].root_lock); + + key_root= share->state.key_root[aio->keynr]; + /* Skip rows inserted by current inserted */ for (r= _ma_search(info, &key, SEARCH_FIND, key_root) ; !r && @@ -102,12 +108,14 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) r= _ma_search_next(info, &info->last_key, SEARCH_BIGGER, key_root)) ; + if (share->lock_key_trees) + mysql_rwlock_unlock(&share->keyinfo[aio->keynr].root_lock); + info->update|= HA_STATE_AKTIV; /* for _ma_test_if_changed() */ /* The following should be safe, even if we compare doubles */ while (!r && gweight) { - if (key.data_length && ha_compare_text(aio->charset, info->last_key.data+1, @@ -125,9 +133,11 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) be skipped (based on subkeys) ? */ keybuff+= key.data_length; - keyinfo= &info->s->ft2_keyinfo; + keyinfo= &share->ft2_keyinfo; key_root= info->cur_row.lastpos; key.data_length= 0; + if (share->lock_key_trees) + mysql_rwlock_rdlock(&share->keyinfo[aio->keynr].root_lock); r= _ma_search_first(info, keyinfo, key_root); goto do_skip; } @@ -163,6 +173,9 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) if (gweight < 0 || doc_cnt > 2000000) gweight=0; + if (share->lock_key_trees) + mysql_rwlock_rdlock(&share->keyinfo[aio->keynr].root_lock); + if (_ma_test_if_changed(info) == 0) r= _ma_search_next(info, &info->last_key, SEARCH_BIGGER, key_root); else @@ -174,6 +187,8 @@ do_skip: !r && info->cur_row.lastpos >= info->state->data_file_length) r= _ma_search_next(info, &info->last_key, SEARCH_BIGGER, key_root); + if (share->lock_key_trees) + mysql_rwlock_unlock(&share->keyinfo[aio->keynr].root_lock); } word->weight=gweight; diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index ffbe00a1caf..cb57b4711d4 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -265,7 +265,7 @@ static int oqgraph_check_table_structure (TABLE *table_arg) if (!(field[0] == key->key_part[0].field && HA_KEY_ALG_HASH == key->algorithm)) DBUG_RETURN(-1); - if (key->key_parts == 3) + if (key->user_defined_key_parts == 3) { /* KEY (latch, origid, destid) USING HASH */ /* KEY (latch, destid, origid) USING HASH */ @@ -363,7 +363,7 @@ void ha_oqgraph::update_key_stats() if (key->algorithm != HA_KEY_ALG_BTREE) { if (key->flags & HA_NOSAME) - key->rec_per_key[key->key_parts-1]= 1; + key->rec_per_key[key->user_defined_key_parts-1]= 1; else { unsigned vertices= graph->vertices_count(); @@ -371,7 +371,7 @@ void ha_oqgraph::update_key_stats() uint no_records= vertices ? 2 * (edges + vertices) / vertices : 2; if (no_records < 2) no_records= 2; - key->rec_per_key[key->key_parts-1]= no_records; + key->rec_per_key[key->user_defined_key_parts-1]= no_records; } } } @@ -888,7 +888,7 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, /* Assert that info() did run. We need current statistics here. */ DBUG_ASSERT(key_stat_version == share->key_stat_version); - ha_rows result= key->rec_per_key[key->key_parts-1]; + ha_rows result= key->rec_per_key[key->user_defined_key_parts-1]; return result; } diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc index 3305875c124..7c991b7e518 100644 --- a/storage/sphinx/ha_sphinx.cc +++ b/storage/sphinx/ha_sphinx.cc @@ -3375,7 +3375,7 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * ) // check index if ( table->s->keys!=1 || - table->key_info[0].key_parts!=1 || + table->key_info[0].user_defined_key_parts != 1 || strcasecmp ( table->key_info[0].key_part[0].field->field_name, table->field[2]->field_name ) ) { my_snprintf ( sError, sizeof(sError), "%s: there must be an index on '%s' column", @@ -3409,7 +3409,7 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * ) // check index if ( table->s->keys!=1 || - table->key_info[0].key_parts!=1 || + table->key_info[0].user_defined_key_parts!=1 || strcasecmp ( table->key_info[0].key_part[0].field->field_name, "id" ) ) { my_snprintf ( sError, sizeof(sError), "%s: 'id' column must be indexed", name ); |