mirror of
https://github.com/MariaDB/server.git
synced 2025-10-12 12:25:37 +03:00
cleanup: cosmetic fixes
This commit is contained in:
@@ -4288,8 +4288,7 @@ err:
|
|||||||
*/
|
*/
|
||||||
uint handler::get_dup_key(int error)
|
uint handler::get_dup_key(int error)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
|
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK);
|
||||||
m_lock_type != F_UNLCK);
|
|
||||||
DBUG_ENTER("handler::get_dup_key");
|
DBUG_ENTER("handler::get_dup_key");
|
||||||
if (table->s->long_unique_table && table->file->errkey < table->s->keys)
|
if (table->s->long_unique_table && table->file->errkey < table->s->keys)
|
||||||
DBUG_RETURN(table->file->errkey);
|
DBUG_RETURN(table->file->errkey);
|
||||||
@@ -6488,17 +6487,18 @@ static int wsrep_after_row(THD *thd)
|
|||||||
}
|
}
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
|
|
||||||
static int check_duplicate_long_entry_key(TABLE *table, handler *h, uchar *new_rec,
|
static int check_duplicate_long_entry_key(TABLE *table, handler *h,
|
||||||
uint key_no)
|
uchar *new_rec, uint key_no)
|
||||||
{
|
{
|
||||||
Field *hash_field;
|
Field *hash_field;
|
||||||
int result, error= 0;
|
int result, error= 0;
|
||||||
KEY *key_info= table->key_info + key_no;
|
KEY *key_info= table->key_info + key_no;
|
||||||
hash_field= key_info->key_part->field;
|
hash_field= key_info->key_part->field;
|
||||||
|
uchar ptr[HA_HASH_KEY_LENGTH_WITH_NULL];
|
||||||
|
|
||||||
DBUG_ASSERT((key_info->flags & HA_NULL_PART_KEY &&
|
DBUG_ASSERT((key_info->flags & HA_NULL_PART_KEY &&
|
||||||
key_info->key_length == HA_HASH_KEY_LENGTH_WITH_NULL)
|
key_info->key_length == HA_HASH_KEY_LENGTH_WITH_NULL)
|
||||||
|| key_info->key_length == HA_HASH_KEY_LENGTH_WITHOUT_NULL);
|
|| key_info->key_length == HA_HASH_KEY_LENGTH_WITHOUT_NULL);
|
||||||
uchar ptr[HA_HASH_KEY_LENGTH_WITH_NULL];
|
|
||||||
|
|
||||||
if (hash_field->is_real_null())
|
if (hash_field->is_real_null())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -6551,20 +6551,14 @@ static int check_duplicate_long_entry_key(TABLE *table, handler *h, uchar *new_r
|
|||||||
while (!is_same && !(result= table->file->ha_index_next_same(table->check_unique_buf,
|
while (!is_same && !(result= table->file->ha_index_next_same(table->check_unique_buf,
|
||||||
ptr, key_info->key_length)));
|
ptr, key_info->key_length)));
|
||||||
if (is_same)
|
if (is_same)
|
||||||
{
|
|
||||||
table->file->errkey= key_no;
|
|
||||||
error= HA_ERR_FOUND_DUPP_KEY;
|
error= HA_ERR_FOUND_DUPP_KEY;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
if (result == HA_ERR_LOCK_WAIT_TIMEOUT)
|
if (result == HA_ERR_LOCK_WAIT_TIMEOUT)
|
||||||
{
|
|
||||||
table->file->errkey= key_no;
|
|
||||||
error= HA_ERR_LOCK_WAIT_TIMEOUT;
|
error= HA_ERR_LOCK_WAIT_TIMEOUT;
|
||||||
}
|
|
||||||
exit:
|
exit:
|
||||||
|
if (error)
|
||||||
|
table->file->errkey= key_no;
|
||||||
h->ha_index_end();
|
h->ha_index_end();
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@@ -1744,10 +1744,8 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
|
|||||||
was used. This ensures that we don't get a problem when the
|
was used. This ensures that we don't get a problem when the
|
||||||
whole range of the key has been used.
|
whole range of the key has been used.
|
||||||
*/
|
*/
|
||||||
if (info->handle_duplicates == DUP_REPLACE &&
|
if (info->handle_duplicates == DUP_REPLACE && table->next_number_field &&
|
||||||
table->next_number_field &&
|
key_nr == table->s->next_number_index && insert_id_for_cur_row > 0)
|
||||||
key_nr == table->s->next_number_index &&
|
|
||||||
(insert_id_for_cur_row > 0))
|
|
||||||
goto err;
|
goto err;
|
||||||
if (table->file->ha_table_flags() & HA_DUPLICATE_POS)
|
if (table->file->ha_table_flags() & HA_DUPLICATE_POS)
|
||||||
{
|
{
|
||||||
|
@@ -4167,8 +4167,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
|||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_hash_field_needed &&
|
if (is_hash_field_needed && key_info->algorithm != HA_KEY_ALG_UNDEF &&
|
||||||
key_info->algorithm != HA_KEY_ALG_UNDEF &&
|
|
||||||
key_info->algorithm != HA_KEY_ALG_HASH )
|
key_info->algorithm != HA_KEY_ALG_HASH )
|
||||||
{
|
{
|
||||||
my_error(ER_TOO_LONG_KEY, MYF(0), max_key_length);
|
my_error(ER_TOO_LONG_KEY, MYF(0), max_key_length);
|
||||||
|
36
sql/table.cc
36
sql/table.cc
@@ -712,9 +712,9 @@ err_not_open:
|
|||||||
|
|
||||||
static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
|
static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
|
||||||
uint keys, KEY *keyinfo,
|
uint keys, KEY *keyinfo,
|
||||||
uint new_frm_ver, uint &ext_key_parts,
|
uint new_frm_ver, uint *ext_key_parts,
|
||||||
TABLE_SHARE *share, uint len,
|
TABLE_SHARE *share, uint len,
|
||||||
KEY *first_keyinfo, char* &keynames)
|
KEY *first_keyinfo, char** keynames)
|
||||||
{
|
{
|
||||||
uint i, j, n_length;
|
uint i, j, n_length;
|
||||||
KEY_PART_INFO *key_part= NULL;
|
KEY_PART_INFO *key_part= NULL;
|
||||||
@@ -770,8 +770,8 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
|
|||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
ext_key_parts+= (share->use_ext_keys ? first_keyinfo->user_defined_key_parts*(keys-1) : 0);
|
(*ext_key_parts)+= (share->use_ext_keys ? first_keyinfo->user_defined_key_parts*(keys-1) : 0);
|
||||||
n_length=keys * sizeof(KEY) + ext_key_parts * sizeof(KEY_PART_INFO);
|
n_length=keys * sizeof(KEY) + *ext_key_parts * sizeof(KEY_PART_INFO);
|
||||||
if (!(keyinfo= (KEY*) alloc_root(&share->mem_root,
|
if (!(keyinfo= (KEY*) alloc_root(&share->mem_root,
|
||||||
n_length + len)))
|
n_length + len)))
|
||||||
return 1;
|
return 1;
|
||||||
@@ -780,7 +780,7 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
|
|||||||
key_part= reinterpret_cast<KEY_PART_INFO*> (keyinfo + keys);
|
key_part= reinterpret_cast<KEY_PART_INFO*> (keyinfo + keys);
|
||||||
|
|
||||||
if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root,
|
if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root,
|
||||||
sizeof(ulong) * ext_key_parts)))
|
sizeof(ulong) * *ext_key_parts)))
|
||||||
return 1;
|
return 1;
|
||||||
first_key_part= key_part;
|
first_key_part= key_part;
|
||||||
first_key_parts= first_keyinfo->user_defined_key_parts;
|
first_key_parts= first_keyinfo->user_defined_key_parts;
|
||||||
@@ -825,8 +825,7 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
|
|||||||
if (keyinfo->algorithm == HA_KEY_ALG_LONG_HASH)
|
if (keyinfo->algorithm == HA_KEY_ALG_LONG_HASH)
|
||||||
{
|
{
|
||||||
keyinfo->key_length= HA_HASH_KEY_LENGTH_WITHOUT_NULL;
|
keyinfo->key_length= HA_HASH_KEY_LENGTH_WITHOUT_NULL;
|
||||||
//Storing key hash
|
key_part++; // reserved for the hash value
|
||||||
key_part++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -865,8 +864,8 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
|
|||||||
share->ext_key_parts++;
|
share->ext_key_parts++;
|
||||||
share->ext_key_parts+= keyinfo->ext_key_parts;
|
share->ext_key_parts+= keyinfo->ext_key_parts;
|
||||||
}
|
}
|
||||||
keynames=(char*) key_part;
|
*keynames=(char*) key_part;
|
||||||
strpos+= strnmov(keynames, (char *) strpos, frm_image_end - strpos) - keynames;
|
strpos+= strnmov(*keynames, (char *) strpos, frm_image_end - strpos) - *keynames;
|
||||||
if (*strpos++) // key names are \0-terminated
|
if (*strpos++) // key names are \0-terminated
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -1189,10 +1188,11 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
|
|||||||
{
|
{
|
||||||
key=table->key_info + key_index;
|
key=table->key_info + key_index;
|
||||||
parts= key->user_defined_key_parts;
|
parts= key->user_defined_key_parts;
|
||||||
if (key->algorithm == HA_KEY_ALG_LONG_HASH &&
|
if (key->key_part[parts].fieldnr == field->field_index + 1)
|
||||||
key->key_part[key->user_defined_key_parts].fieldnr == field->field_index+ 1)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (key->algorithm != HA_KEY_ALG_LONG_HASH)
|
||||||
|
goto end;
|
||||||
KEY_PART_INFO *keypart;
|
KEY_PART_INFO *keypart;
|
||||||
for (uint i=0; i < parts; i++)
|
for (uint i=0; i < parts; i++)
|
||||||
{
|
{
|
||||||
@@ -1581,7 +1581,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
|
|||||||
DBUG_ENTER("TABLE_SHARE::init_from_binary_frm_image");
|
DBUG_ENTER("TABLE_SHARE::init_from_binary_frm_image");
|
||||||
|
|
||||||
keyinfo= &first_keyinfo;
|
keyinfo= &first_keyinfo;
|
||||||
share->ext_key_parts= 0;
|
|
||||||
thd->mem_root= &share->mem_root;
|
thd->mem_root= &share->mem_root;
|
||||||
|
|
||||||
if (write && write_frm_image(frm_image, frm_length))
|
if (write && write_frm_image(frm_image, frm_length))
|
||||||
@@ -1821,8 +1820,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
|
|||||||
share->set_use_ext_keys_flag(plugin_hton(se_plugin)->flags & HTON_SUPPORTS_EXTENDED_KEYS);
|
share->set_use_ext_keys_flag(plugin_hton(se_plugin)->flags & HTON_SUPPORTS_EXTENDED_KEYS);
|
||||||
|
|
||||||
if (create_key_infos(disk_buff + 6, frm_image_end, keys, keyinfo,
|
if (create_key_infos(disk_buff + 6, frm_image_end, keys, keyinfo,
|
||||||
new_frm_ver, ext_key_parts,
|
new_frm_ver, &ext_key_parts,
|
||||||
share, len, &first_keyinfo, keynames))
|
share, len, &first_keyinfo, &keynames))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (next_chunk + 5 < buff_end)
|
if (next_chunk + 5 < buff_end)
|
||||||
@@ -1914,8 +1913,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (create_key_infos(disk_buff + 6, frm_image_end, keys, keyinfo,
|
if (create_key_infos(disk_buff + 6, frm_image_end, keys, keyinfo,
|
||||||
new_frm_ver, ext_key_parts,
|
new_frm_ver, &ext_key_parts,
|
||||||
share, len, &first_keyinfo, keynames))
|
share, len, &first_keyinfo, &keynames))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
share->key_block_size= uint2korr(frm_image+62);
|
share->key_block_size= uint2korr(frm_image+62);
|
||||||
@@ -2436,10 +2435,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
|
|||||||
uint offset= share->reclength - HA_HASH_FIELD_LENGTH * hash_fields;
|
uint offset= share->reclength - HA_HASH_FIELD_LENGTH * hash_fields;
|
||||||
for (uint i= 0; i < share->keys; i++, keyinfo++)
|
for (uint i= 0; i < share->keys; i++, keyinfo++)
|
||||||
{
|
{
|
||||||
/*
|
/* We need set value in hash key_part */
|
||||||
We need set value in hash key_part
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (keyinfo->algorithm == HA_KEY_ALG_LONG_HASH)
|
if (keyinfo->algorithm == HA_KEY_ALG_LONG_HASH)
|
||||||
{
|
{
|
||||||
share->long_unique_table= 1;
|
share->long_unique_table= 1;
|
||||||
|
Reference in New Issue
Block a user