mirror of
https://github.com/MariaDB/server.git
synced 2025-01-28 17:54:16 +01:00
cleanup: spaces, casts, comments
This commit is contained in:
parent
9f2adffcca
commit
9fa31c1bd9
22 changed files with 162 additions and 254 deletions
|
@ -99,16 +99,16 @@ enum ha_rkey_function {
|
|||
HA_READ_MBR_EQUAL
|
||||
};
|
||||
|
||||
/* Key algorithm types */
|
||||
/* Key algorithm types (stored in .frm) */
|
||||
|
||||
enum ha_key_alg {
|
||||
HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */
|
||||
HA_KEY_ALG_BTREE= 1, /* B-tree, default one */
|
||||
HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */
|
||||
HA_KEY_ALG_HASH= 3, /* HASH keys (HEAP tables) */
|
||||
HA_KEY_ALG_FULLTEXT= 4, /* FULLTEXT (MyISAM tables) */
|
||||
HA_KEY_ALG_LONG_HASH= 5, /* long BLOB keys */
|
||||
HA_KEY_ALG_UNIQUE_HASH= 6 /* Internal UNIQUE hash (Aria) */
|
||||
HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */
|
||||
HA_KEY_ALG_BTREE= 1, /* B-tree, default one */
|
||||
HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */
|
||||
HA_KEY_ALG_HASH= 3, /* HASH keys (HEAP tables) */
|
||||
HA_KEY_ALG_FULLTEXT= 4, /* FULLTEXT */
|
||||
HA_KEY_ALG_LONG_HASH= 5, /* long BLOB keys */
|
||||
HA_KEY_ALG_UNIQUE_HASH= 6 /* Internal UNIQUE hash (Aria) */
|
||||
};
|
||||
|
||||
/* Storage media types */
|
||||
|
|
|
@ -37,7 +37,7 @@ extern const uchar _my_bits_reverse_table[256];
|
|||
- returns 0 for (1<<0)
|
||||
- returns 1 for (1<<1)
|
||||
- returns 2 for (1<<2)
|
||||
- returns 2 for 3, which has (1<<2) as the highest bit set.
|
||||
- returns 1 for 3, which has (1<<1) as the highest bit set.
|
||||
|
||||
Note, the behaviour of log2(0) is not defined.
|
||||
Let's return 0 for the input 0, for the code simplicity.
|
||||
|
|
|
@ -595,7 +595,7 @@ struct st_maria_plugin
|
|||
API for Storage Engine plugin. (MYSQL_DAEMON_PLUGIN)
|
||||
*/
|
||||
|
||||
/* handlertons of different MySQL releases are incompatible */
|
||||
/* daemon plugins of different MySQL releases are incompatible */
|
||||
#define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
|
||||
|
||||
/*
|
||||
|
@ -613,7 +613,7 @@ struct st_mysql_daemon
|
|||
API for I_S plugin. (MYSQL_INFORMATION_SCHEMA_PLUGIN)
|
||||
*/
|
||||
|
||||
/* handlertons of different MySQL releases are incompatible */
|
||||
/* information schema plugins different MySQL releases are incompatible */
|
||||
#define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
|
||||
|
||||
/*
|
||||
|
@ -631,7 +631,7 @@ struct st_mysql_information_schema
|
|||
API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN)
|
||||
*/
|
||||
|
||||
/* handlertons of different MySQL releases are incompatible */
|
||||
/* storage engines of different MySQL releases are incompatible */
|
||||
#define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
|
||||
|
||||
/*
|
||||
|
|
|
@ -454,9 +454,6 @@ select * from t1 where a='807780' and b='477' and c='165';
|
|||
a b c
|
||||
807780 477 165
|
||||
drop table t1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 'test.t1'
|
||||
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a));
|
||||
INSERT t1 VALUES ("can \tcan");
|
||||
INSERT t1 VALUES ("can can");
|
||||
|
|
|
@ -437,7 +437,6 @@ drop table t1;
|
|||
#
|
||||
# space-stripping in _mi_prefix_search: BUG#5284
|
||||
#
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a));
|
||||
INSERT t1 VALUES ("can \tcan");
|
||||
INSERT t1 VALUES ("can can");
|
||||
|
@ -1128,7 +1127,7 @@ drop table t1;
|
|||
create table t1 (c1 int) engine=myisam pack_keys=0;
|
||||
create table t2 (c1 int) engine=myisam pack_keys=1;
|
||||
create table t3 (c1 int) engine=myisam pack_keys=default;
|
||||
--error 1064
|
||||
--error ER_PARSE_ERROR
|
||||
create table t4 (c1 int) engine=myisam pack_keys=2;
|
||||
drop table t1, t2, t3;
|
||||
|
||||
|
@ -1315,9 +1314,9 @@ create table t1 (a int not null, key `a` (a) key_block_size=1025);
|
|||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--error 1064
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int not null, key key_block_size=1024 (a));
|
||||
--error 1064
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int not null, key `a` key_block_size=1024 (a));
|
||||
|
||||
#
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
--plugin-maturity=unknown
|
|
@ -7,8 +7,6 @@ set global default_storage_engine=aria;
|
|||
set session default_storage_engine=aria;
|
||||
set global aria_page_checksum=0;
|
||||
set global aria_log_file_size=4294959104;
|
||||
drop table if exists t1,t2;
|
||||
drop view if exists v1;
|
||||
SET SQL_WARNINGS=1;
|
||||
CREATE TABLE t1 (
|
||||
STRING_DATA char(255) default NULL,
|
||||
|
|
|
@ -21,10 +21,6 @@ let $default_log_file_size=`select @@global.aria_log_file_size`;
|
|||
set global aria_log_file_size=4294959104;
|
||||
|
||||
# Initialise
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2;
|
||||
drop view if exists v1;
|
||||
--enable_warnings
|
||||
SET SQL_WARNINGS=1;
|
||||
|
||||
#
|
||||
|
@ -1062,7 +1058,7 @@ drop table t1;
|
|||
create table t1 (c1 int) pack_keys=0;
|
||||
create table t2 (c1 int) pack_keys=1;
|
||||
create table t3 (c1 int) pack_keys=default;
|
||||
--error 1064
|
||||
--error ER_PARSE_ERROR
|
||||
create table t4 (c1 int) pack_keys=2;
|
||||
drop table t1, t2, t3;
|
||||
|
||||
|
@ -1209,9 +1205,9 @@ create table t1 (a int not null, key `a` (a) key_block_size=1025);
|
|||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--error 1064
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int not null, key key_block_size=1024 (a));
|
||||
--error 1064
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int not null, key `a` key_block_size=1024 (a));
|
||||
|
||||
#
|
||||
|
|
|
@ -48,7 +48,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
|
|||
ha_rows *found_rows);
|
||||
static bool write_keys(Sort_param *param, SORT_INFO *fs_info,
|
||||
uint count, IO_CACHE *buffer_file, IO_CACHE *tempfile);
|
||||
static uint make_sortkey(Sort_param *param, uchar *to, uchar *ref_pos,
|
||||
static uint make_sortkey(Sort_param *, uchar *, uchar *,
|
||||
bool using_packed_sortkeys= false);
|
||||
static uint make_sortkey(Sort_param *param, uchar *to);
|
||||
static uint make_packed_sortkey(Sort_param *param, uchar *to);
|
||||
|
@ -1516,8 +1516,7 @@ static void register_used_fields(Sort_param *param)
|
|||
}
|
||||
|
||||
|
||||
static bool save_index(Sort_param *param, uint count,
|
||||
SORT_INFO *table_sort)
|
||||
static bool save_index(Sort_param *param, uint count, SORT_INFO *table_sort)
|
||||
{
|
||||
uint offset,res_length, length;
|
||||
uchar *to;
|
||||
|
@ -2958,16 +2957,14 @@ static uint make_sortkey(Sort_param *param, uchar *to)
|
|||
{
|
||||
bool maybe_null=0;
|
||||
if ((field=sort_field->field))
|
||||
{
|
||||
// Field
|
||||
{ // Field
|
||||
field->make_sort_key_part(to, sort_field->length);
|
||||
if ((maybe_null= field->maybe_null()))
|
||||
to++;
|
||||
}
|
||||
else
|
||||
{ // Item
|
||||
sort_field->item->type_handler()->make_sort_key_part(to,
|
||||
sort_field->item,
|
||||
{ // Item
|
||||
sort_field->item->type_handler()->make_sort_key_part(to, sort_field->item,
|
||||
sort_field,
|
||||
¶m->tmp_buffer);
|
||||
if ((maybe_null= sort_field->item->maybe_null()))
|
||||
|
|
|
@ -141,9 +141,8 @@ int ha_partition::notify_tabledef_changed(LEX_CSTRING *db,
|
|||
{
|
||||
LEX_CSTRING table_name;
|
||||
const char *table_name_ptr;
|
||||
if (create_partition_name(from_buff, sizeof(from_buff),
|
||||
from_path, name_buffer_ptr,
|
||||
NORMAL_PART_NAME, FALSE))
|
||||
if (create_partition_name(from_buff, sizeof(from_buff), from_path,
|
||||
name_buffer_ptr, NORMAL_PART_NAME, FALSE))
|
||||
res=1;
|
||||
table_name_ptr= from_buff + dirname_length(from_buff);
|
||||
|
||||
|
@ -159,12 +158,9 @@ int ha_partition::notify_tabledef_changed(LEX_CSTRING *db,
|
|||
|
||||
|
||||
static int
|
||||
partition_notify_tabledef_changed(handlerton *,
|
||||
LEX_CSTRING *db,
|
||||
LEX_CSTRING *table,
|
||||
LEX_CUSTRING *frm,
|
||||
LEX_CUSTRING *version,
|
||||
handler *file)
|
||||
partition_notify_tabledef_changed(handlerton *, LEX_CSTRING *db,
|
||||
LEX_CSTRING *table, LEX_CUSTRING *frm,
|
||||
LEX_CUSTRING *version, handler *file)
|
||||
{
|
||||
DBUG_ENTER("partition_notify_tabledef_changed");
|
||||
DBUG_RETURN(static_cast<ha_partition*>
|
||||
|
|
|
@ -871,8 +871,8 @@ int ha_end()
|
|||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
static my_bool dropdb_handlerton(THD *unused1, plugin_ref plugin,
|
||||
void *path)
|
||||
|
||||
static my_bool dropdb_handlerton(THD *, plugin_ref plugin, void *path)
|
||||
{
|
||||
handlerton *hton= plugin_hton(plugin);
|
||||
if (hton->drop_database)
|
||||
|
@ -888,8 +888,7 @@ void ha_drop_database(const char* path)
|
|||
}
|
||||
|
||||
|
||||
static my_bool checkpoint_state_handlerton(THD *unused1, plugin_ref plugin,
|
||||
void *disable)
|
||||
static my_bool checkpoint_state_handlerton(THD *, plugin_ref plugin, void *disable)
|
||||
{
|
||||
handlerton *hton= plugin_hton(plugin);
|
||||
if (hton->checkpoint_state)
|
||||
|
@ -909,8 +908,8 @@ struct st_commit_checkpoint_request {
|
|||
void (*pre_hook)(void *);
|
||||
};
|
||||
|
||||
static my_bool commit_checkpoint_request_handlerton(THD *unused1, plugin_ref plugin,
|
||||
void *data)
|
||||
static my_bool commit_checkpoint_request_handlerton(THD *, plugin_ref plugin,
|
||||
void *data)
|
||||
{
|
||||
st_commit_checkpoint_request *st= (st_commit_checkpoint_request *)data;
|
||||
handlerton *hton= plugin_hton(plugin);
|
||||
|
@ -1024,8 +1023,7 @@ void ha_signal_ddl_recovery_done()
|
|||
Backup functions
|
||||
******************************************************************************/
|
||||
|
||||
static my_bool plugin_prepare_for_backup(THD *unused1, plugin_ref plugin,
|
||||
void *not_used)
|
||||
static my_bool plugin_prepare_for_backup(THD *, plugin_ref plugin, void *)
|
||||
{
|
||||
handlerton *hton= plugin_hton(plugin);
|
||||
if (hton->prepare_for_backup)
|
||||
|
@ -1040,8 +1038,7 @@ void ha_prepare_for_backup()
|
|||
PLUGIN_IS_DELETED|PLUGIN_IS_READY, 0);
|
||||
}
|
||||
|
||||
static my_bool plugin_end_backup(THD *unused1, plugin_ref plugin,
|
||||
void *not_used)
|
||||
static my_bool plugin_end_backup(THD *, plugin_ref plugin, void *)
|
||||
{
|
||||
handlerton *hton= plugin_hton(plugin);
|
||||
if (hton->end_backup)
|
||||
|
@ -2419,8 +2416,7 @@ struct xahton_st {
|
|||
int result;
|
||||
};
|
||||
|
||||
static my_bool xacommit_handlerton(THD *unused1, plugin_ref plugin,
|
||||
void *arg)
|
||||
static my_bool xacommit_handlerton(THD *, plugin_ref plugin, void *arg)
|
||||
{
|
||||
handlerton *hton= plugin_hton(plugin);
|
||||
if (hton->recover)
|
||||
|
@ -2431,8 +2427,7 @@ static my_bool xacommit_handlerton(THD *unused1, plugin_ref plugin,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static my_bool xarollback_handlerton(THD *unused1, plugin_ref plugin,
|
||||
void *arg)
|
||||
static my_bool xarollback_handlerton(THD *, plugin_ref plugin, void *arg)
|
||||
{
|
||||
handlerton *hton= plugin_hton(plugin);
|
||||
if (hton->recover)
|
||||
|
@ -2713,7 +2708,7 @@ static void xarecover_do_commit_or_rollback(handlerton *hton,
|
|||
/*
|
||||
Per hton recovery decider function.
|
||||
*/
|
||||
static my_bool xarecover_do_commit_or_rollback_handlerton(THD *unused,
|
||||
static my_bool xarecover_do_commit_or_rollback_handlerton(THD *,
|
||||
plugin_ref plugin,
|
||||
void *arg)
|
||||
{
|
||||
|
@ -2783,8 +2778,7 @@ uint ha_recover_complete(HASH *commit_list, Binlog_offset *coord)
|
|||
return complete.count;
|
||||
}
|
||||
|
||||
static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin,
|
||||
void *arg)
|
||||
static my_bool xarecover_handlerton(THD *, plugin_ref plugin, void *arg)
|
||||
{
|
||||
handlerton *hton= plugin_hton(plugin);
|
||||
struct xarecover_st *info= (struct xarecover_st *) arg;
|
||||
|
@ -3159,9 +3153,7 @@ int ha_release_savepoint(THD *thd, SAVEPOINT *sv)
|
|||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
||||
static my_bool snapshot_handlerton(THD *thd, plugin_ref plugin,
|
||||
void *arg)
|
||||
static my_bool snapshot_handlerton(THD *thd, plugin_ref plugin, void *arg)
|
||||
{
|
||||
handlerton *hton= plugin_hton(plugin);
|
||||
if (hton->start_consistent_snapshot)
|
||||
|
@ -3281,6 +3273,13 @@ Lex_cstring handler::get_canonical_filename(const Lex_cstring &path,
|
|||
/**
|
||||
Delete a table in the engine
|
||||
|
||||
@param thd
|
||||
@param hton
|
||||
@param path no extension, e.g. "./test/t1"
|
||||
@param db for the error message only
|
||||
@param alias table name, for the error message only
|
||||
@param generate_warning generate "table not found" warnings as needed
|
||||
|
||||
@return 0 Table was deleted
|
||||
@return -1 Table didn't exists, no error given
|
||||
@return # Error from table handler
|
||||
|
@ -6310,6 +6309,14 @@ int handler::calculate_checksum()
|
|||
/**
|
||||
Initiates table-file and calls appropriate database-creator.
|
||||
|
||||
@param thd
|
||||
@param path no extension, e.g. "./test/t1"
|
||||
@param db
|
||||
@param table_name
|
||||
@param create_info
|
||||
@param frm an frm image or NULL (meaning, read it from the file)
|
||||
@param skip_frm_file do not write the frm image to the .frm file
|
||||
|
||||
@retval
|
||||
0 ok
|
||||
@retval
|
||||
|
@ -6400,8 +6407,7 @@ void st_ha_check_opt::init()
|
|||
/**
|
||||
Init a key cache if it has not been initied before.
|
||||
*/
|
||||
int ha_init_key_cache(const char *name, KEY_CACHE *key_cache, void *unused
|
||||
__attribute__((unused)))
|
||||
int ha_init_key_cache(const char *name, KEY_CACHE *key_cache, void *)
|
||||
{
|
||||
DBUG_ENTER("ha_init_key_cache");
|
||||
|
||||
|
@ -7285,8 +7291,7 @@ int handler::index_read_idx_map(uchar * buf, uint index, const uchar * key,
|
|||
@retval
|
||||
pointer pointer to TYPELIB structure
|
||||
*/
|
||||
static my_bool exts_handlerton(THD *unused, plugin_ref plugin,
|
||||
void *arg)
|
||||
static my_bool exts_handlerton(THD *, plugin_ref plugin, void *arg)
|
||||
{
|
||||
List<char> *found_exts= (List<char> *) arg;
|
||||
handlerton *hton= plugin_hton(plugin);
|
||||
|
|
|
@ -150,7 +150,7 @@ enum chf_create_flags {
|
|||
*/
|
||||
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1ULL << 6)
|
||||
#define HA_NULL_IN_KEY (1ULL << 7) /* One can have keys with NULL */
|
||||
#define HA_DUPLICATE_POS (1ULL << 8) /* ha_position() gives dup row */
|
||||
#define HA_DUPLICATE_POS (1ULL << 8) /* position() gives dup row */
|
||||
#define HA_NO_BLOBS (1ULL << 9) /* Doesn't support blobs */
|
||||
#define HA_CAN_INDEX_BLOBS (1ULL << 10)
|
||||
#define HA_AUTO_PART_KEY (1ULL << 11) /* auto-increment in multi-part key */
|
||||
|
|
|
@ -2821,7 +2821,7 @@ inline Item* get_item_copy (THD *thd, const T* item)
|
|||
if (likely(copy))
|
||||
copy->register_in(thd);
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
|
|
|
@ -4373,12 +4373,8 @@ bool select_insert::prepare_eof()
|
|||
DBUG_PRINT("enter", ("trans_table: %d, table_type: '%s'",
|
||||
trans_table, table->file->table_type()));
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
error= (thd->wsrep_cs().current_error()) ? -1 :
|
||||
error= IF_WSREP(thd->wsrep_cs().current_error(), 0) ? -1 :
|
||||
(thd->locked_tables_mode <= LTM_LOCK_TABLES) ?
|
||||
#else
|
||||
error= (thd->locked_tables_mode <= LTM_LOCK_TABLES) ?
|
||||
#endif /* WITH_WSREP */
|
||||
table->file->ha_end_bulk_insert() : 0;
|
||||
|
||||
if (likely(!error) && unlikely(thd->is_error()))
|
||||
|
|
|
@ -245,7 +245,6 @@ static int join_init_quick_read_record(JOIN_TAB *tab);
|
|||
static quick_select_return test_if_quick_select(JOIN_TAB *tab);
|
||||
static int test_if_use_dynamic_range_scan(JOIN_TAB *join_tab);
|
||||
static int join_read_first(JOIN_TAB *tab);
|
||||
static int join_read_next(READ_RECORD *info);
|
||||
static int join_read_next_same(READ_RECORD *info);
|
||||
static int join_read_last(JOIN_TAB *tab);
|
||||
static int join_read_prev_same(READ_RECORD *info);
|
||||
|
@ -374,13 +373,7 @@ static
|
|||
bool join_limit_shortcut_is_applicable(const JOIN *join);
|
||||
POSITION *join_limit_shortcut_finalize_plan(JOIN *join, double *cost);
|
||||
|
||||
static
|
||||
bool find_indexes_matching_order(JOIN *join, TABLE *table, ORDER *order,
|
||||
key_map *usable_keys);
|
||||
static
|
||||
void compute_part_of_sort_key_for_equals(JOIN *join, TABLE *table,
|
||||
Item_field *item_field,
|
||||
key_map *col_keys);
|
||||
static bool find_indexes_matching_order(JOIN *, TABLE *, ORDER *, key_map *);
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
|
||||
|
@ -7246,8 +7239,7 @@ add_keyuse(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field,
|
|||
|
||||
static LEX_CSTRING equal_str= { STRING_WITH_LEN("=") };
|
||||
|
||||
static bool
|
||||
add_key_part(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field)
|
||||
static bool add_key_part(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field)
|
||||
{
|
||||
Field *field=key_field->field;
|
||||
TABLE *form= field->table;
|
||||
|
@ -7260,7 +7252,7 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field)
|
|||
if (!(form->keys_in_use_for_query.is_set(key)))
|
||||
continue;
|
||||
if (form->key_info[key].flags & (HA_FULLTEXT | HA_SPATIAL))
|
||||
continue; // ToDo: ft-keys in non-ft queries. SerG
|
||||
continue;
|
||||
|
||||
KEY *keyinfo= form->key_info+key;
|
||||
uint key_parts= form->actual_n_key_parts(keyinfo);
|
||||
|
@ -11555,9 +11547,7 @@ bool test_if_skip_sort_order_early(JOIN *join,
|
|||
|
||||
// Step #1: Find indexes that produce the required ordering.
|
||||
if (find_indexes_matching_order(join, table, join->order, &usable_keys))
|
||||
{
|
||||
return false; // Cannot skip sorting
|
||||
}
|
||||
|
||||
// Step #2: Check if the index we're using produces the needed ordering
|
||||
uint ref_key;
|
||||
|
@ -26441,7 +26431,6 @@ part_of_refkey(TABLE *table,Field *field)
|
|||
@param used_key_parts [out] NULL by default, otherwise return value for
|
||||
used key parts.
|
||||
|
||||
|
||||
@note
|
||||
used_key_parts is set to correct key parts used if return value != 0
|
||||
(On other cases, used_key_part may be changed)
|
||||
|
@ -26457,9 +26446,8 @@ part_of_refkey(TABLE *table,Field *field)
|
|||
-1 Reverse key can be used
|
||||
*/
|
||||
|
||||
static int test_if_order_by_key(JOIN *join,
|
||||
ORDER *order, TABLE *table, uint idx,
|
||||
uint *used_key_parts)
|
||||
static int test_if_order_by_key(JOIN *join, ORDER *order, TABLE *table,
|
||||
uint idx, uint *used_key_parts)
|
||||
{
|
||||
KEY_PART_INFO *key_part,*key_part_end;
|
||||
key_part=table->key_info[idx].key_part;
|
||||
|
@ -26474,8 +26462,7 @@ static int test_if_order_by_key(JOIN *join,
|
|||
DBUG_ENTER("test_if_order_by_key");
|
||||
|
||||
if ((table->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) &&
|
||||
table->key_info[idx].ext_key_part_map &&
|
||||
pk != MAX_KEY && pk != idx)
|
||||
table->key_info[idx].ext_key_part_map && pk != MAX_KEY && pk != idx)
|
||||
{
|
||||
have_pk_suffix= true;
|
||||
}
|
||||
|
@ -27078,9 +27065,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
|||
|
||||
// Step #1: Find indexes that produce the required ordering.
|
||||
if (find_indexes_matching_order(tab->join, table, order, &usable_keys))
|
||||
{
|
||||
DBUG_RETURN(false); // Cannot skip sorting
|
||||
}
|
||||
|
||||
/*
|
||||
Step #2: Analyze the current access method. Note the used index as ref_key
|
||||
|
@ -32729,8 +32714,7 @@ test_if_cheaper_ordering(bool in_join_optimizer,
|
|||
temporary table + filesort could be cheaper for grouping
|
||||
queries too.
|
||||
*/
|
||||
if (is_covering ||
|
||||
has_limit ||
|
||||
if (is_covering || has_limit ||
|
||||
(ref_key < 0 && (group || table->force_index)))
|
||||
{
|
||||
double rec_per_key;
|
||||
|
@ -32995,8 +32979,7 @@ uint get_index_for_order(ORDER *order, TABLE *table, SQL_SELECT *select,
|
|||
int key, direction;
|
||||
double new_cost;
|
||||
if (test_if_cheaper_ordering(FALSE, NULL, order, table,
|
||||
table->keys_in_use_for_order_by, -1,
|
||||
limit,
|
||||
table->keys_in_use_for_order_by, -1, limit,
|
||||
&key, &direction, &limit, &new_cost) &&
|
||||
!is_key_used(table, key, table->write_set))
|
||||
{
|
||||
|
|
|
@ -2611,7 +2611,6 @@ static void store_key_options(THD *thd, String *packet, TABLE *table,
|
|||
MODE_DB2 |
|
||||
MODE_MAXDB |
|
||||
MODE_ANSI)) != 0;
|
||||
char *end, buff[32];
|
||||
|
||||
if (!(thd->variables.sql_mode & MODE_NO_KEY_OPTIONS) &&
|
||||
!limited_mysql_mode && !foreign_db_mode)
|
||||
|
@ -2633,8 +2632,7 @@ static void store_key_options(THD *thd, String *packet, TABLE *table,
|
|||
table->s->key_block_size != key_info->block_size)
|
||||
{
|
||||
packet->append(STRING_WITH_LEN(" KEY_BLOCK_SIZE="));
|
||||
end= longlong10_to_str(key_info->block_size, buff, 10);
|
||||
packet->append(buff, (uint) (end - buff));
|
||||
packet->append_ulonglong(key_info->block_size);
|
||||
}
|
||||
DBUG_ASSERT(MY_TEST(key_info->flags & HA_USES_COMMENT) ==
|
||||
(key_info->comment.length > 0));
|
||||
|
@ -7299,9 +7297,8 @@ err:
|
|||
}
|
||||
|
||||
|
||||
static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
|
||||
TABLE *table, bool res,
|
||||
const LEX_CSTRING *db_name,
|
||||
static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, TABLE *table,
|
||||
bool res, const LEX_CSTRING *db_name,
|
||||
const LEX_CSTRING *table_name)
|
||||
{
|
||||
CHARSET_INFO *cs= system_charset_info;
|
||||
|
@ -7309,7 +7306,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
|
|||
if (!tables->view)
|
||||
{
|
||||
TABLE *show_table= tables->table;
|
||||
KEY *key_info=show_table->s->key_info;
|
||||
KEY *key_info= show_table->s->key_info;
|
||||
if (show_table->file)
|
||||
{
|
||||
(void) read_statistics_for_tables(thd, tables, false);
|
||||
|
@ -7363,21 +7360,18 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
|
|||
table->field[0]->store(STRING_WITH_LEN("def"), cs);
|
||||
table->field[1]->store(db_name->str, db_name->length, cs);
|
||||
table->field[2]->store(table_name->str, table_name->length, cs);
|
||||
table->field[3]->store((longlong) ((key_info->flags &
|
||||
HA_NOSAME) ? 0 : 1), TRUE);
|
||||
table->field[3]->store(key_info->flags & HA_NOSAME ? 0 : 1, TRUE);
|
||||
table->field[4]->store(db_name->str, db_name->length, cs);
|
||||
table->field[5]->store(key_info->name.str, key_info->name.length, cs);
|
||||
table->field[6]->store((longlong) (j+1), TRUE);
|
||||
str= (key_part->field ? &key_part->field->field_name :
|
||||
&unknown);
|
||||
str= key_part->field ? &key_part->field->field_name : &unknown;
|
||||
table->field[7]->store(str->str, str->length, cs);
|
||||
if (show_table->file)
|
||||
{
|
||||
if (show_table->file->index_flags(i, j, 0) & HA_READ_ORDER)
|
||||
{
|
||||
table->field[8]->store(((key_part->key_part_flag &
|
||||
HA_REVERSE_SORT) ?
|
||||
"D" : "A"), 1, cs);
|
||||
table->field[8]->store(key_part->key_part_flag & HA_REVERSE_SORT
|
||||
? "D" : "A", 1, cs);
|
||||
table->field[8]->set_notnull();
|
||||
}
|
||||
if (key_info->algorithm == HA_KEY_ALG_LONG_HASH)
|
||||
|
@ -7389,11 +7383,11 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
|
|||
from table as key_info points to TABLE_SHARE which has no
|
||||
statistics.
|
||||
*/
|
||||
KEY *key_info= show_table->key_info + i;
|
||||
if (key_info->rec_per_key[j])
|
||||
KEY *keyinfo= show_table->key_info + i;
|
||||
if (keyinfo->rec_per_key[j])
|
||||
{
|
||||
ha_rows records= (ha_rows) ((double) show_table->stat_records() /
|
||||
key_info->actual_rec_per_key(j));
|
||||
keyinfo->actual_rec_per_key(j));
|
||||
table->field[9]->store((longlong) records, TRUE);
|
||||
table->field[9]->set_notnull();
|
||||
}
|
||||
|
@ -7411,7 +7405,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
|
|||
table->field[10]->set_notnull();
|
||||
}
|
||||
uint flags= key_part->field ? key_part->field->flags : 0;
|
||||
const char *pos=(char*) ((flags & NOT_NULL_FLAG) ? "" : "YES");
|
||||
const char *pos= flags & NOT_NULL_FLAG ? "" : "YES";
|
||||
table->field[12]->store(pos, strlen(pos), cs);
|
||||
if (!show_table->s->keys_in_use.is_set(i))
|
||||
table->field[14]->store(STRING_WITH_LEN("disabled"), cs);
|
||||
|
|
164
sql/sql_table.cc
164
sql/sql_table.cc
|
@ -1208,8 +1208,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, bool if_exists,
|
|||
/* mark for close and remove all cached entries */
|
||||
thd->push_internal_handler(&err_handler);
|
||||
error= mysql_rm_table_no_locks(thd, tables, &thd->db, (DDL_LOG_STATE*) 0,
|
||||
if_exists,
|
||||
drop_temporary,
|
||||
if_exists, drop_temporary,
|
||||
false, drop_sequence, dont_log_query,
|
||||
false);
|
||||
thd->pop_internal_handler();
|
||||
|
@ -1306,32 +1305,28 @@ static uint32 get_comment(THD *thd, uint32 comment_pos,
|
|||
|
||||
int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables,
|
||||
const LEX_CSTRING *current_db,
|
||||
DDL_LOG_STATE *ddl_log_state,
|
||||
bool if_exists,
|
||||
DDL_LOG_STATE *ddl_log_state, bool if_exists,
|
||||
bool drop_temporary, bool drop_view,
|
||||
bool drop_sequence,
|
||||
bool dont_log_query,
|
||||
bool drop_sequence, bool dont_log_query,
|
||||
bool dont_free_locks)
|
||||
{
|
||||
TABLE_LIST *table;
|
||||
char path[FN_REFLEN + 1];
|
||||
LEX_CSTRING alias= null_clex_str;
|
||||
LEX_CUSTRING version;
|
||||
LEX_CSTRING partition_engine_name= {NULL, 0};
|
||||
LEX_CSTRING partition_engine_name= null_clex_str;
|
||||
StringBuffer<160> unknown_tables(system_charset_info);
|
||||
DDL_LOG_STATE local_ddl_log_state;
|
||||
const char *comment_start;
|
||||
uint table_count= 0, non_temp_tables_count= 0;
|
||||
int error= 0;
|
||||
uint32 comment_len;
|
||||
size_t comment_len;
|
||||
bool trans_tmp_table_deleted= 0, non_trans_tmp_table_deleted= 0;
|
||||
bool is_drop_tmp_if_exists_added= 0, non_tmp_table_deleted= 0;
|
||||
bool log_if_exists= if_exists;
|
||||
const LEX_CSTRING *object_to_drop= ((drop_sequence) ?
|
||||
&SEQUENCE_clex_str :
|
||||
&TABLE_clex_str);
|
||||
String normal_tables;
|
||||
String built_trans_tmp_query, built_non_trans_tmp_query;
|
||||
const LEX_CSTRING *object_to_drop= drop_sequence ? &SEQUENCE_clex_str
|
||||
: &TABLE_clex_str;
|
||||
String normal_tables, built_trans_tmp_query, built_non_trans_tmp_query;
|
||||
DBUG_ENTER("mysql_rm_table_no_locks");
|
||||
|
||||
if (!ddl_log_state)
|
||||
|
@ -1456,7 +1451,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables,
|
|||
}
|
||||
|
||||
/* First try to delete temporary tables and temporary sequences */
|
||||
if ((table->open_type != OT_BASE_ONLY && is_temporary_table(table)))
|
||||
if (table->open_type != OT_BASE_ONLY && is_temporary_table(table))
|
||||
{
|
||||
table_creation_was_logged= table->table->s->table_creation_was_logged;
|
||||
if (thd->drop_temporary_table(table->table, &is_trans, true))
|
||||
|
@ -1538,7 +1533,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables,
|
|||
continue;
|
||||
}
|
||||
|
||||
lex_string_set3(&cpath, path, (size_t) (path_end - path));
|
||||
cpath = { path, (size_t)(path_end - path) };
|
||||
|
||||
{
|
||||
char engine_buf[NAME_CHAR_LEN + 1];
|
||||
|
@ -1560,7 +1555,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables,
|
|||
|
||||
if (!table_count++)
|
||||
{
|
||||
LEX_CSTRING comment= {comment_start, (size_t) comment_len};
|
||||
LEX_CSTRING comment= {comment_start, comment_len};
|
||||
if (ddl_log_drop_table_init(ddl_log_state, current_db, &comment))
|
||||
{
|
||||
error= 1;
|
||||
|
@ -1621,11 +1616,9 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables,
|
|||
bool enoent_warning= !dont_log_query && !(hton && hton->discover_table);
|
||||
|
||||
if (was_view)
|
||||
res= ddl_log_drop_view(ddl_log_state, &cpath, &db,
|
||||
&table_name);
|
||||
res= ddl_log_drop_view(ddl_log_state, &cpath, &db, &table_name);
|
||||
else
|
||||
res= ddl_log_drop_table(ddl_log_state, hton, &cpath, &db,
|
||||
&table_name);
|
||||
res= ddl_log_drop_table(ddl_log_state, hton, &cpath, &db, &table_name);
|
||||
if (res)
|
||||
{
|
||||
error= -1;
|
||||
|
@ -1633,8 +1626,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables,
|
|||
}
|
||||
|
||||
debug_crash_here("ddl_log_drop_before_delete_table");
|
||||
error= ha_delete_table(thd, hton, path, &db, &table_name,
|
||||
enoent_warning);
|
||||
error= ha_delete_table(thd, hton, path, &db, &table_name, enoent_warning);
|
||||
debug_crash_here("ddl_log_drop_after_delete_table");
|
||||
|
||||
if (!error)
|
||||
|
@ -1702,8 +1694,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables,
|
|||
int ferror= 0;
|
||||
DBUG_ASSERT(!was_view);
|
||||
|
||||
if (ddl_log_drop_table(ddl_log_state, 0, &cpath, &db,
|
||||
&table_name))
|
||||
if (ddl_log_drop_table(ddl_log_state, 0, &cpath, &db, &table_name))
|
||||
{
|
||||
error= -1;
|
||||
goto err;
|
||||
|
@ -1762,7 +1753,6 @@ report_error:
|
|||
uint is_note= (if_exists && (was_view || wrong_drop_sequence) ?
|
||||
ME_NOTE : 0);
|
||||
|
||||
tbl_name.length(0);
|
||||
tbl_name.append(&db);
|
||||
tbl_name.append('.');
|
||||
tbl_name.append(&table_name);
|
||||
|
@ -1890,9 +1880,8 @@ err:
|
|||
built_non_trans_tmp_query.append(generated_by_server);
|
||||
error |= (thd->binlog_query(THD::STMT_QUERY_TYPE,
|
||||
built_non_trans_tmp_query.ptr(),
|
||||
built_non_trans_tmp_query.length(),
|
||||
FALSE, FALSE,
|
||||
is_drop_tmp_if_exists_added,
|
||||
built_non_trans_tmp_query.length(), FALSE,
|
||||
FALSE, is_drop_tmp_if_exists_added,
|
||||
0) > 0);
|
||||
}
|
||||
if (trans_tmp_table_deleted)
|
||||
|
@ -1902,9 +1891,8 @@ err:
|
|||
built_trans_tmp_query.append(generated_by_server);
|
||||
error |= (thd->binlog_query(THD::STMT_QUERY_TYPE,
|
||||
built_trans_tmp_query.ptr(),
|
||||
built_trans_tmp_query.length(),
|
||||
TRUE, FALSE,
|
||||
is_drop_tmp_if_exists_added,
|
||||
built_trans_tmp_query.length(), TRUE,
|
||||
FALSE, is_drop_tmp_if_exists_added,
|
||||
0) > 0);
|
||||
}
|
||||
if (non_tmp_table_deleted)
|
||||
|
@ -1932,8 +1920,7 @@ err:
|
|||
thd->binlog_xid= thd->query_id;
|
||||
ddl_log_update_xid(ddl_log_state, thd->binlog_xid);
|
||||
error |= (thd->binlog_query(THD::STMT_QUERY_TYPE,
|
||||
built_query.ptr(),
|
||||
built_query.length(),
|
||||
built_query.ptr(), built_query.length(),
|
||||
TRUE, FALSE, FALSE, 0) > 0);
|
||||
thd->binlog_xid= 0;
|
||||
}
|
||||
|
@ -2101,6 +2088,7 @@ bool quick_rm_table(THD *thd, handlerton *base, const LEX_CSTRING *db,
|
|||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
#define return_if_nonzero(X) do { if (int r=(X)) return r; } while(0)
|
||||
|
||||
/*
|
||||
Sort keys in the following order:
|
||||
|
@ -2119,48 +2107,37 @@ bool quick_rm_table(THD *thd, handlerton *base, const LEX_CSTRING *db,
|
|||
static int sort_keys(KEY *a, KEY *b)
|
||||
{
|
||||
ulong a_flags= a->flags, b_flags= b->flags;
|
||||
|
||||
|
||||
/*
|
||||
Do not reorder LONG_HASH indexes, because they must match the order
|
||||
of their LONG_UNIQUE_HASH_FIELD's.
|
||||
Do not reorder HA_KEY_ALG_LONG_HASH indexes, because they must match the
|
||||
order of their LONG_UNIQUE_HASH_FIELD's.
|
||||
*/
|
||||
if (a->algorithm == HA_KEY_ALG_LONG_HASH &&
|
||||
b->algorithm == HA_KEY_ALG_LONG_HASH)
|
||||
return a->usable_key_parts - b->usable_key_parts;
|
||||
|
||||
return_if_nonzero((b_flags & HA_NOSAME) - (a_flags & HA_NOSAME));
|
||||
|
||||
/* historically, rules below apply only to UNIQUE keys */
|
||||
if (a_flags & HA_NOSAME)
|
||||
{
|
||||
if (!(b_flags & HA_NOSAME))
|
||||
return -1;
|
||||
/*
|
||||
Long Unique keys should always be last unique key.
|
||||
Before this patch they used to change order wrt to partial keys
|
||||
(MDEV-19049)
|
||||
*/
|
||||
if (a->algorithm == HA_KEY_ALG_LONG_HASH)
|
||||
return 1;
|
||||
if (b->algorithm == HA_KEY_ALG_LONG_HASH)
|
||||
return -1;
|
||||
if ((a_flags ^ b_flags) & HA_NULL_PART_KEY)
|
||||
{
|
||||
/* Sort NOT NULL keys before other keys */
|
||||
return (a_flags & HA_NULL_PART_KEY) ? 1 : -1;
|
||||
}
|
||||
if (a->name.str == primary_key_name.str)
|
||||
return -1;
|
||||
if (b->name.str == primary_key_name.str)
|
||||
return 1;
|
||||
/* Sort keys don't containing partial segments before others */
|
||||
if ((a_flags ^ b_flags) & HA_KEY_HAS_PART_KEY_SEG)
|
||||
return (a_flags & HA_KEY_HAS_PART_KEY_SEG) ? 1 : -1;
|
||||
}
|
||||
else if (b_flags & HA_NOSAME)
|
||||
return 1; // Prefer b
|
||||
/* Long Unique keys should always be last unique key. */
|
||||
return_if_nonzero((a->algorithm == HA_KEY_ALG_LONG_HASH) -
|
||||
(b->algorithm == HA_KEY_ALG_LONG_HASH));
|
||||
|
||||
if ((a_flags ^ b_flags) & HA_FULLTEXT)
|
||||
{
|
||||
return (a_flags & HA_FULLTEXT) ? 1 : -1;
|
||||
/* Sort NOT NULL keys before other keys */
|
||||
return_if_nonzero((a_flags & HA_NULL_PART_KEY) -
|
||||
(b_flags & HA_NULL_PART_KEY));
|
||||
return_if_nonzero((b->name.str == primary_key_name.str) -
|
||||
(a->name.str == primary_key_name.str));
|
||||
/* Sort keys don't containing partial segments before others */
|
||||
return_if_nonzero((a_flags & HA_KEY_HAS_PART_KEY_SEG) -
|
||||
(b_flags & HA_KEY_HAS_PART_KEY_SEG));
|
||||
}
|
||||
|
||||
return_if_nonzero((a_flags & HA_FULLTEXT) -
|
||||
(b_flags & HA_FULLTEXT));
|
||||
|
||||
/*
|
||||
Prefer original key order. usable_key_parts contains here
|
||||
the original key position.
|
||||
|
@ -2619,8 +2596,8 @@ static inline void make_long_hash_field_name(LEX_CSTRING *buf, uint num)
|
|||
@param create_list List of table fields.
|
||||
@param key_info current long unique key info
|
||||
*/
|
||||
static Create_field * add_hash_field(THD * thd, List<Create_field> *create_list,
|
||||
KEY *key_info)
|
||||
static Create_field *add_hash_field(THD *thd, List<Create_field> *create_list,
|
||||
KEY *key_info)
|
||||
{
|
||||
List_iterator<Create_field> it(*create_list);
|
||||
Create_field *dup_field, *cf= new (thd->mem_root) Create_field();
|
||||
|
@ -2632,7 +2609,7 @@ static Create_field * add_hash_field(THD * thd, List<Create_field> *create_list,
|
|||
cf->vcol_info= new (thd->mem_root) Virtual_column_info();
|
||||
cf->vcol_info->set_vcol_type(VCOL_GENERATED_VIRTUAL);
|
||||
uint num= 1;
|
||||
LEX_CSTRING field_name;
|
||||
Lex_ident_column field_name;
|
||||
field_name.str= (char *)thd->alloc(LONG_HASH_FIELD_NAME_LENGTH);
|
||||
make_long_hash_field_name(&field_name, num);
|
||||
/*
|
||||
|
@ -3340,11 +3317,11 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
|
|||
}
|
||||
|
||||
cols2.rewind();
|
||||
const Type_handler *field_type= sql_field->type_handler();
|
||||
switch(key->type) {
|
||||
|
||||
case Key::FULLTEXT:
|
||||
if (sql_field->type_handler()->Key_part_spec_init_ft(column,
|
||||
*sql_field) ||
|
||||
if (field_type->Key_part_spec_init_ft(column, *sql_field) ||
|
||||
(ft_key_charset && sql_field->charset != ft_key_charset))
|
||||
{
|
||||
my_error(ER_BAD_FT_COLUMN, MYF(0), column->field_name.str);
|
||||
|
@ -3354,8 +3331,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
|
|||
break;
|
||||
|
||||
case Key::SPATIAL:
|
||||
if (sql_field->type_handler()->Key_part_spec_init_spatial(column,
|
||||
*sql_field) ||
|
||||
if (field_type->Key_part_spec_init_spatial(column, *sql_field) ||
|
||||
sql_field->check_vcol_for_key(thd))
|
||||
DBUG_RETURN(TRUE);
|
||||
if (!(sql_field->flags & NOT_NULL_FLAG))
|
||||
|
@ -3372,9 +3348,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
|
|||
my_error(ER_PRIMARY_KEY_BASED_ON_GENERATED_COLUMN, MYF(0));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (sql_field->type_handler()->Key_part_spec_init_primary(column,
|
||||
*sql_field,
|
||||
file))
|
||||
if (field_type->Key_part_spec_init_primary(column, *sql_field, file))
|
||||
DBUG_RETURN(TRUE);
|
||||
if (!(sql_field->flags & NOT_NULL_FLAG))
|
||||
{
|
||||
|
@ -3386,27 +3360,22 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
|
|||
break;
|
||||
|
||||
case Key::MULTIPLE:
|
||||
if (sql_field->type_handler()->Key_part_spec_init_multiple(column,
|
||||
*sql_field,
|
||||
file) ||
|
||||
if (field_type->Key_part_spec_init_multiple(column, *sql_field, file) ||
|
||||
sql_field->check_vcol_for_key(thd) ||
|
||||
key_add_part_check_null(file, key_info, sql_field, column))
|
||||
DBUG_RETURN(TRUE);
|
||||
break;
|
||||
|
||||
case Key::FOREIGN_KEY:
|
||||
if (sql_field->type_handler()->Key_part_spec_init_foreign(column,
|
||||
*sql_field,
|
||||
file) ||
|
||||
if (field_type->Key_part_spec_init_foreign(column, *sql_field, file) ||
|
||||
sql_field->check_vcol_for_key(thd) ||
|
||||
key_add_part_check_null(file, key_info, sql_field, column))
|
||||
DBUG_RETURN(TRUE);
|
||||
break;
|
||||
|
||||
case Key::UNIQUE:
|
||||
if (sql_field->type_handler()->Key_part_spec_init_unique(column,
|
||||
*sql_field, file,
|
||||
&is_hash_field_needed) ||
|
||||
if (field_type->Key_part_spec_init_unique(column, *sql_field, file,
|
||||
&is_hash_field_needed) ||
|
||||
sql_field->check_vcol_for_key(thd) ||
|
||||
key_add_part_check_null(file, key_info, sql_field, column))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
@ -3428,8 +3397,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
|
|||
key_part_info->offset= (uint16) sql_field->offset;
|
||||
key_part_info->key_type=sql_field->pack_flag;
|
||||
key_part_info->key_part_flag= column->asc ? 0 : HA_REVERSE_SORT;
|
||||
uint key_part_length= sql_field->type_handler()->
|
||||
calc_key_length(*sql_field);
|
||||
uint key_part_length= field_type->calc_key_length(*sql_field);
|
||||
|
||||
if (column->length)
|
||||
{
|
||||
|
@ -3460,7 +3428,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
|
|||
// is prefix length bigger than field length?
|
||||
(column->length > key_part_length ||
|
||||
// can the field have a partial key?
|
||||
!sql_field->type_handler()->type_can_have_key_part() ||
|
||||
!field_type->type_can_have_key_part() ||
|
||||
// a packed field can't be used in a partial key
|
||||
f_is_packed(sql_field->pack_flag) ||
|
||||
// does the storage engine allow prefixed search?
|
||||
|
@ -3524,12 +3492,11 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
|
|||
(key_part_length >= KEY_DEFAULT_PACK_LENGTH) &&
|
||||
!is_hash_field_needed)
|
||||
{
|
||||
key_info->flags|= sql_field->type_handler()->KEY_pack_flags(column_nr);
|
||||
key_info->flags|= field_type->KEY_pack_flags(column_nr);
|
||||
}
|
||||
/* Check if the key segment is partial, set the key flag accordingly */
|
||||
if (key_part_length != sql_field->type_handler()->
|
||||
calc_key_length(*sql_field) &&
|
||||
key_part_length != sql_field->type_handler()->max_octet_length())
|
||||
if (key_part_length != field_type->calc_key_length(*sql_field) &&
|
||||
key_part_length != field_type->max_octet_length())
|
||||
key_info->flags|= HA_KEY_HAS_PART_KEY_SEG;
|
||||
|
||||
key_length+= key_part_length;
|
||||
|
@ -3558,12 +3525,11 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
|
|||
if (auto_increment_key)
|
||||
{
|
||||
my_error(ER_NO_AUTOINCREMENT_WITH_UNIQUE, MYF(0),
|
||||
sql_field->field_name.str,
|
||||
key_info->name.str);
|
||||
sql_field->field_name.str, key_info->name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (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);
|
||||
DBUG_RETURN(TRUE);
|
||||
|
@ -3571,8 +3537,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
|
|||
}
|
||||
if (is_hash_field_needed ||
|
||||
(key_info->algorithm == HA_KEY_ALG_HASH &&
|
||||
key->type != Key::PRIMARY &&
|
||||
key_info->flags & HA_NOSAME &&
|
||||
key->type != Key::PRIMARY && key_info->flags & HA_NOSAME &&
|
||||
!(file->ha_table_flags() & HA_CAN_HASH_KEYS ) &&
|
||||
file->ha_table_flags() & HA_CAN_VIRTUAL_COLUMNS))
|
||||
{
|
||||
|
@ -4783,10 +4748,9 @@ int mysql_create_table_no_lock(THD *thd,
|
|||
}
|
||||
lex_string_set3(&cpath, path, path_length);
|
||||
|
||||
res= create_table_impl(thd, ddl_log_state_create, ddl_log_state_rm,
|
||||
*db, *table_name, *db, *table_name, cpath,
|
||||
*create_info, create_info,
|
||||
alter_info, create_table_mode,
|
||||
res= create_table_impl(thd, ddl_log_state_create, ddl_log_state_rm, *db,
|
||||
*table_name, *db, *table_name, cpath, *create_info,
|
||||
create_info, alter_info, create_table_mode,
|
||||
is_trans, ¬_used_1, ¬_used_2, &frm);
|
||||
my_free(const_cast<uchar*>(frm.str));
|
||||
|
||||
|
|
|
@ -1385,8 +1385,7 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables,
|
|||
/* This code is executed in case of DROP TRIGGER */
|
||||
lex_string_set3(&query, thd->query(), thd->query_length());
|
||||
}
|
||||
if (ddl_log_drop_trigger(ddl_log_state,
|
||||
&tables->db, &tables->table_name,
|
||||
if (ddl_log_drop_trigger(ddl_log_state, &tables->db, &tables->table_name,
|
||||
sp_name, &query))
|
||||
goto err;
|
||||
}
|
||||
|
|
|
@ -7452,12 +7452,6 @@ static Sys_var_ulonglong Sys_binlog_large_commit_threshold(
|
|||
"binlogging",
|
||||
GLOBAL_VAR(opt_binlog_commit_by_rotate_threshold),
|
||||
CMD_LINE(REQUIRED_ARG),
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
// Allow a smaller minimum value for debug builds to help with testing
|
||||
VALID_RANGE(100 * 1024, ULLONG_MAX),
|
||||
#else
|
||||
VALID_RANGE(10 * 1024 * 1024, ULLONG_MAX),
|
||||
#endif
|
||||
|
||||
VALID_RANGE(IF_DBUG(100, 10240) * 1024, ULLONG_MAX),
|
||||
DEFAULT(128 * 1024 * 1024), BLOCK_SIZE(1));
|
||||
|
|
28
sql/table.cc
28
sql/table.cc
|
@ -789,11 +789,9 @@ err_not_open:
|
|||
}
|
||||
|
||||
static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
|
||||
uint keys, KEY *keyinfo,
|
||||
uint new_frm_ver, uint *ext_key_parts,
|
||||
TABLE_SHARE *share, uint len,
|
||||
KEY *first_keyinfo,
|
||||
LEX_STRING *keynames)
|
||||
uint keys, KEY *keyinfo, uint new_frm_ver,
|
||||
uint *ext_key_parts, TABLE_SHARE *share, uint len,
|
||||
KEY *first_keyinfo, LEX_STRING *keynames)
|
||||
{
|
||||
uint i, j, n_length;
|
||||
uint primary_key_parts= 0;
|
||||
|
@ -882,26 +880,25 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
|
|||
{
|
||||
if (strpos + (new_frm_ver >= 1 ? 9 : 7) >= frm_image_end)
|
||||
return 1;
|
||||
if (!(keyinfo->algorithm == HA_KEY_ALG_LONG_HASH))
|
||||
if (keyinfo->algorithm != HA_KEY_ALG_LONG_HASH)
|
||||
rec_per_key++;
|
||||
key_part->fieldnr= (uint16) (uint2korr(strpos) & FIELD_NR_MASK);
|
||||
key_part->offset= (uint) uint2korr(strpos+2)-1;
|
||||
key_part->key_type= (uint) uint2korr(strpos+5);
|
||||
// key_part->field= (Field*) 0; // Will be fixed later
|
||||
key_part->fieldnr= (uint16) (uint2korr(strpos) & FIELD_NR_MASK);
|
||||
key_part->offset= (uint) uint2korr(strpos+2)-1;
|
||||
key_part->key_type= (uint) uint2korr(strpos+5);
|
||||
if (new_frm_ver >= 1)
|
||||
{
|
||||
key_part->key_part_flag= *(strpos+4);
|
||||
key_part->length= (uint) uint2korr(strpos+7);
|
||||
key_part->length= (uint) uint2korr(strpos+7);
|
||||
strpos+=9;
|
||||
}
|
||||
else
|
||||
{
|
||||
key_part->length= *(strpos+4);
|
||||
key_part->length= *(strpos+4);
|
||||
key_part->key_part_flag=0;
|
||||
if (key_part->length > 128)
|
||||
{
|
||||
key_part->length&=127; /* purecov: inspected */
|
||||
key_part->key_part_flag=HA_REVERSE_SORT; /* purecov: inspected */
|
||||
key_part->length&= 127;
|
||||
key_part->key_part_flag=HA_REVERSE_SORT;
|
||||
}
|
||||
strpos+=7;
|
||||
}
|
||||
|
@ -4164,8 +4161,7 @@ bool copy_keys_from_share(TABLE *outparam, MEM_ROOT *root)
|
|||
KEY_PART_INFO *key_part;
|
||||
|
||||
if (!multi_alloc_root(root, &key_info, share->keys*sizeof(KEY),
|
||||
&key_part,
|
||||
share->ext_key_parts*sizeof(KEY_PART_INFO),
|
||||
&key_part, share->ext_key_parts*sizeof(KEY_PART_INFO),
|
||||
NullS))
|
||||
return 1;
|
||||
|
||||
|
|
|
@ -733,9 +733,8 @@ static int chk_index_down(HA_CHECK *param, MARIA_HA *info,
|
|||
if (page + keyinfo->block_length > max_length)
|
||||
goto err;
|
||||
/* Fix the remembered key file length. */
|
||||
share->state.state.key_file_length= (max_length &
|
||||
~ (my_off_t) (keyinfo->block_length -
|
||||
1));
|
||||
share->state.state.key_file_length=
|
||||
max_length & ~ (my_off_t) (keyinfo->block_length - 1);
|
||||
/* purecov: end */
|
||||
}
|
||||
|
||||
|
|
|
@ -1367,13 +1367,9 @@ int mi_indexes_are_disabled(MI_INFO *info)
|
|||
{
|
||||
MYISAM_SHARE *share= info->s;
|
||||
|
||||
/*
|
||||
No keys or all are enabled. keys is the number of keys. Left shifted
|
||||
gives us only one bit set. When decreased by one, gives us all all bits
|
||||
up to this one set and it gets unset.
|
||||
*/
|
||||
/* No keys or all are enabled */
|
||||
if (!share->base.keys ||
|
||||
(mi_is_all_keys_active(share->state.key_map, share->base.keys)))
|
||||
mi_is_all_keys_active(share->state.key_map, share->base.keys))
|
||||
return 0;
|
||||
|
||||
/* All are disabled */
|
||||
|
|
Loading…
Add table
Reference in a new issue