summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorserg@janus.mylan <>2007-03-17 00:13:25 +0100
committerserg@janus.mylan <>2007-03-17 00:13:25 +0100
commit68fd66e853cd94fcb76aba6b95a592bb39e2b8f7 (patch)
tree37481f305868166d3013f273d8fccadb4776d51c /sql
parent55a548cf4d923fc6a3ab38a4b447f639257e358f (diff)
downloadmariadb-git-68fd66e853cd94fcb76aba6b95a592bb39e2b8f7.tar.gz
wl#3700 - post-review fixes:
s/ulonglong/key_part_map/, comments
Diffstat (limited to 'sql')
-rw-r--r--sql/event_db_repository.cc4
-rw-r--r--sql/ha_partition.cc6
-rw-r--r--sql/ha_partition.h9
-rw-r--r--sql/handler.cc4
-rw-r--r--sql/handler.h29
-rw-r--r--sql/item_subselect.cc4
-rw-r--r--sql/log_event.cc6
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/opt_range.cc70
-rw-r--r--sql/opt_range.h29
-rw-r--r--sql/sp.cc4
-rw-r--r--sql/sql_acl.cc20
-rw-r--r--sql/sql_handler.cc2
-rw-r--r--sql/sql_help.cc4
-rw-r--r--sql/sql_insert.cc2
-rw-r--r--sql/sql_plugin.cc2
-rw-r--r--sql/sql_select.cc13
-rw-r--r--sql/sql_select.h7
-rw-r--r--sql/sql_servers.cc6
-rw-r--r--sql/sql_udf.cc4
-rw-r--r--sql/table.cc2
-rw-r--r--sql/table.h6
-rw-r--r--sql/tztime.cc8
23 files changed, 122 insertions, 120 deletions
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index 860cb54e27f..c5d015cdea7 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -288,7 +288,7 @@ Event_db_repository::index_read_for_db_for_i_s(THD *thd, TABLE *schema_table,
{
key_copy(key_buf, event_table->record[0], key_info, key_len);
if (!(ret= event_table->file->index_read(event_table->record[0], key_buf,
- (ulonglong)1, HA_READ_PREFIX)))
+ (key_part_map)1, HA_READ_PREFIX)))
{
DBUG_PRINT("info",("Found rows. Let's retrieve them. ret=%d", ret));
do
@@ -843,7 +843,7 @@ Event_db_repository::find_named_event(THD *thd, LEX_STRING db, LEX_STRING name,
key_copy(key, table->record[0], table->key_info, table->key_info->key_length);
- if (table->file->index_read_idx(table->record[0], 0, key, ~ULL(0),
+ if (table->file->index_read_idx(table->record[0], 0, key, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{
DBUG_PRINT("info", ("Row not found"));
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 4ed602be54d..d3979fa0718 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -3336,7 +3336,7 @@ int ha_partition::index_end()
*/
int ha_partition::index_read(byte * buf, const byte * key,
- ulonglong keypart_map,
+ key_part_map keypart_map,
enum ha_rkey_function find_flag)
{
DBUG_ENTER("ha_partition::index_read");
@@ -3357,7 +3357,7 @@ int ha_partition::index_read(byte * buf, const byte * key,
*/
int ha_partition::common_index_read(byte *buf, const byte *key,
- ulonglong keypart_map,
+ key_part_map keypart_map,
enum ha_rkey_function find_flag)
{
int error;
@@ -3513,7 +3513,7 @@ int ha_partition::common_first_last(byte *buf)
*/
int ha_partition::index_read_last(byte *buf, const byte *key,
- ulonglong keypart_map)
+ key_part_map keypart_map)
{
DBUG_ENTER("ha_partition::index_read_last");
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index 2d43e2b0df2..a081e4bb472 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -384,8 +384,8 @@ public:
any end processing needed.
*/
virtual int index_read(byte * buf, const byte * key,
- ulonglong keypart_map,
- enum ha_rkey_function find_flag);
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag);
virtual int index_init(uint idx, bool sorted);
virtual int index_end();
@@ -399,7 +399,7 @@ public:
virtual int index_last(byte * buf);
virtual int index_next_same(byte * buf, const byte * key, uint keylen);
virtual int index_read_last(byte * buf, const byte * key,
- ulonglong keypart_map);
+ key_part_map keypart_map);
/*
read_first_row is virtual method but is only implemented by
@@ -425,7 +425,8 @@ public:
private:
int common_index_read(byte * buf, const byte * key,
- ulonglong keypart_map, enum ha_rkey_function find_flag);
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag);
int common_first_last(byte * buf);
int partition_scan_set_up(byte * buf, bool idx_read_flag);
int handle_unordered_next(byte * buf, bool next_same);
diff --git a/sql/handler.cc b/sql/handler.cc
index 7d3edf36162..6df8a4a5021 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3282,8 +3282,8 @@ int handler::compare_key(key_range *range)
int handler::index_read_idx(byte * buf, uint index, const byte * key,
- ulonglong keypart_map,
- enum ha_rkey_function find_flag)
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag)
{
int error, error1;
error= index_init(index, 0);
diff --git a/sql/handler.h b/sql/handler.h
index 1d02d6a7ee3..0158cbad515 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -867,17 +867,17 @@ public:
{}
};
-uint calculate_key_len(TABLE *, uint, const byte *, ulonglong);
+uint calculate_key_len(TABLE *, uint, const byte *, key_part_map);
/*
bitmap with first N+1 bits set
(keypart_map for a key prefix of [0..N] keyparts)
*/
-#define make_keypart_map(N) (((ulonglong)2 << (N)) - 1)
+#define make_keypart_map(N) (((key_part_map)2 << (N)) - 1)
/*
bitmap with first N bits set
(keypart_map for a key prefix of [0..N-1] keyparts)
*/
-#define make_prev_keypart_map(N) (((ulonglong)1 << (N)) - 1)
+#define make_prev_keypart_map(N) (((key_part_map)1 << (N)) - 1)
/*
The handler class is the interface for dynamically loadable
@@ -1219,14 +1219,26 @@ public:
enum ha_rkey_function find_flag)
{ return HA_ERR_WRONG_COMMAND; }
public:
- virtual int index_read(byte * buf, const byte * key, ulonglong keypart_map,
+/**
+ @brief
+ Positions an index cursor to the index specified in the handle. Fetches the
+ row if available. If the key value is null, begin at the first key of the
+ index.
+*/
+ virtual int index_read(byte * buf, const byte * key, key_part_map keypart_map,
enum ha_rkey_function find_flag)
{
uint key_len= calculate_key_len(table, active_index, key, keypart_map);
return index_read(buf, key, key_len, find_flag);
}
+/**
+ @brief
+ Positions an index cursor to the index specified in the handle. Fetches the
+ row if available. If the key value is null, begin at the first key of the
+ index.
+*/
virtual int index_read_idx(byte * buf, uint index, const byte * key,
- ulonglong keypart_map,
+ key_part_map keypart_map,
enum ha_rkey_function find_flag);
virtual int index_next(byte * buf)
{ return HA_ERR_WRONG_COMMAND; }
@@ -1241,8 +1253,13 @@ public:
virtual int index_read_last(byte * buf, const byte * key, uint key_len)
{ return (my_errno=HA_ERR_WRONG_COMMAND); }
public:
+/**
+ @brief
+ The following functions works like index_read, but it find the last
+ row with the current key value or prefix.
+*/
virtual int index_read_last(byte * buf, const byte * key,
- ulonglong keypart_map)
+ key_part_map keypart_map)
{
uint key_len= calculate_key_len(table, active_index, key, keypart_map);
return index_read_last(buf, key, key_len);
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index d9141cc0740..e1abda2f612 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -2045,7 +2045,7 @@ int subselect_uniquesubquery_engine::exec()
table->file->ha_index_init(tab->ref.key, 0);
error= table->file->index_read(table->record[0],
tab->ref.key_buff,
- tab_to_keypart_map(tab),
+ make_prev_keypart_map(tab->ref.key_parts),
HA_READ_KEY_EXACT);
if (error &&
error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
@@ -2155,7 +2155,7 @@ int subselect_indexsubquery_engine::exec()
table->file->ha_index_init(tab->ref.key, 1);
error= table->file->index_read(table->record[0],
tab->ref.key_buff,
- tab_to_keypart_map(tab),
+ make_prev_keypart_map(tab->ref.key_parts),
HA_READ_KEY_EXACT);
if (error &&
error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 5ff23a49252..0448aacd4f3 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -6855,7 +6855,7 @@ replace_record(THD *thd, TABLE *table,
key_copy((byte*)key.get(), table->record[0], table->key_info + keynum, 0);
error= table->file->index_read_idx(table->record[1], keynum,
- (const byte*)key.get(), ~ULL(0),
+ (const byte*)key.get(), HA_WHOLE_KEY,
HA_READ_KEY_EXACT);
if (error)
DBUG_RETURN(error);
@@ -7039,8 +7039,8 @@ static int find_and_fetch_row(TABLE *table, byte *key)
my_ptrdiff_t const pos=
table->s->null_bytes > 0 ? table->s->null_bytes - 1 : 0;
table->record[1][pos]= 0xFF;
- if ((error= table->file->index_read(table->record[1], key,
- ~(ulonglong)0, HA_READ_KEY_EXACT)))
+ if ((error= table->file->index_read(table->record[1], key, HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT)))
{
table->file->print_error(error, MYF(0));
table->file->ha_index_end();
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 1852e74a333..099c9b98c1f 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -47,7 +47,6 @@ typedef Bitmap<64> key_map; /* Used for finding keys */
#else
typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
#endif
-typedef ulong key_part_map; /* Used for finding key parts */
typedef ulong nesting_map; /* Used for flags of nesting constructs */
/*
Used to identify NESTED_JOIN structures within a join (applicable only to
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index d95eb1c3553..52faaf25b42 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -312,6 +312,7 @@ public:
min_value=arg->max_value;
min_flag=arg->max_flag & NEAR_MAX ? 0 : NEAR_MIN;
}
+ /* returns a number of keypart values (0 or 1) appended to the key buffer */
int store_min(uint length,char **min_key,uint min_key_flag)
{
if ((min_flag & GEOM_FLAG) ||
@@ -330,6 +331,7 @@ public:
}
return 0;
}
+ /* returns a number of keypart values (0 or 1) appended to the key buffer */
int store_max(uint length,char **max_key, uint max_key_flag)
{
if (!(max_flag & NO_MAX_RANGE) &&
@@ -347,13 +349,8 @@ public:
}
return 0;
}
- /*void store(uint length,char **min_key,uint min_key_flag,
- char **max_key, uint max_key_flag)
- {
- store_min(length, min_key, min_key_flag);
- store_max(length, max_key, max_key_flag);
- }*/
+ /* returns a number of keypart values appended to the key buffer */
int store_min_key(KEY_PART *key,char **range_key, uint *range_key_flag)
{
SEL_ARG *key_tree= first();
@@ -369,6 +366,7 @@ public:
return res;
}
+ /* returns a number of keypart values appended to the key buffer */
int store_max_key(KEY_PART *key,char **range_key, uint *range_key_flag)
{
SEL_ARG *key_tree= last();
@@ -595,7 +593,7 @@ static SEL_ARG *get_mm_leaf(RANGE_OPT_PARAM *param,COND *cond_func,Field *field,
static SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param,COND *cond);
static bool is_key_scan_ror(PARAM *param, uint keynr, uint8 nparts);
-static ha_rows check_quick_select(PARAM *param,uint index,SEL_ARG *key_tree,
+static ha_rows check_quick_select(PARAM *param,uint index,SEL_ARG *key_tree,
bool update_tbl_stats);
static ha_rows check_quick_keys(PARAM *param,uint index,SEL_ARG *key_tree,
char *min_key, uint min_key_flag, int,
@@ -4075,7 +4073,7 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info,
byte key_val[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; /* key values tuple */
char *key_ptr= (char*) key_val;
SEL_ARG *sel_arg, *tuple_arg= NULL;
- ulonglong keypart_map= 0;
+ key_part_map keypart_map= 0;
bool cur_covered;
bool prev_covered= test(bitmap_is_set(&info->covered_fields,
key_part->fieldnr-1));
@@ -7457,7 +7455,8 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
{
QUICK_RANGE *range;
uint flag;
- int min_part= key_tree->part-1, max_part=key_tree->part-1;
+ int min_part= key_tree->part-1, // # of keypart values in min_key buffer
+ max_part= key_tree->part-1; // # of keypart values in max_key buffer
if (key_tree->left != &null_element)
{
@@ -7488,15 +7487,11 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
{
uint tmp_min_flag=key_tree->min_flag,tmp_max_flag=key_tree->max_flag;
if (!tmp_min_flag)
- {
min_part+= key_tree->next_key_part->store_min_key(key, &tmp_min_key,
&tmp_min_flag);
- }
if (!tmp_max_flag)
- {
max_part+= key_tree->next_key_part->store_max_key(key, &tmp_max_key,
&tmp_max_flag);
- }
flag=tmp_min_flag | tmp_max_flag;
}
}
@@ -7652,13 +7647,13 @@ bool QUICK_ROR_UNION_SELECT::is_keys_used(const MY_BITMAP *fields)
thd Thread handle
table Table to access
ref ref[_or_null] scan parameters
- records Estimate of number of records (needed only to construct
+ records Estimate of number of records (needed only to construct
quick select)
NOTES
This allocates things in a new memory root, as this may be called many
times during a query.
-
- RETURN
+
+ RETURN
Quick select that retrieves the same rows as passed ref scan
NULL on error.
*/
@@ -7694,9 +7689,10 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
!(range= new(alloc) QUICK_RANGE()))
goto err; // out of memory
- range->min_key=range->max_key=(char*) ref->key_buff;
- range->min_length=range->max_length=ref->key_length;
- range->min_keypart_map= range->max_keypart_map= (1 << ref->key_parts) - 1;
+ range->min_key= range->max_key= (char*) ref->key_buff;
+ range->min_length= range->max_length= ref->key_length;
+ range->min_keypart_map= range->max_keypart_map=
+ make_prev_keypart_map(ref->key_parts);
range->flag= ((ref->key_length == key_info->key_length &&
(key_info->flags & (HA_NOSAME | HA_END_SPACE_KEY)) ==
HA_NOSAME) ? EQ_RANGE : 0);
@@ -7709,7 +7705,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
{
key_part->part=part;
key_part->field= key_info->key_part[part].field;
- key_part->length= key_info->key_part[part].length;
+ key_part->length= key_info->key_part[part].length;
key_part->store_length= key_info->key_part[part].store_length;
key_part->null_bit= key_info->key_part[part].null_bit;
key_part->flag= (uint8) key_info->key_part[part].key_part_flag;
@@ -7728,13 +7724,11 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
QUICK_RANGE *null_range;
*ref->null_ref_key= 1; // Set null byte then create a range
- if (!(null_range= new (alloc) QUICK_RANGE((char*)ref->key_buff,
- ref->key_length,
- (1 << ref->key_parts) - 1,
- (char*)ref->key_buff,
- ref->key_length,
- (1 << ref->key_parts) - 1,
- EQ_RANGE)))
+ if (!(null_range= new (alloc)
+ QUICK_RANGE((char*)ref->key_buff, ref->key_length,
+ make_prev_keypart_map(ref->key_parts),
+ (char*)ref->key_buff, ref->key_length,
+ make_prev_keypart_map(ref->key_parts), EQ_RANGE)))
goto err;
*ref->null_ref_key= 0; // Clear null byte
if (insert_dynamic(&quick->ranges,(gptr)&null_range))
@@ -8246,7 +8240,7 @@ end:
*/
int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length,
- ulonglong keypart_map,
+ key_part_map keypart_map,
byte *cur_prefix)
{
DBUG_ENTER("QUICK_RANGE_SELECT::get_next_prefix");
@@ -10502,7 +10496,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_prefix()
{
byte *cur_prefix= seen_first_key ? group_prefix : NULL;
if ((result= quick_prefix_select->get_next_prefix(group_prefix_len,
- (ULL(1) << group_key_parts) - 1, cur_prefix)))
+ make_prev_keypart_map(group_key_parts), cur_prefix)))
DBUG_RETURN(result);
seen_first_key= TRUE;
}
@@ -10561,8 +10555,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_prefix()
int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range()
{
ha_rkey_function find_flag;
- uint search_prefix_len;
- ulonglong keypart_map;
+ key_part_map keypart_map;
QUICK_RANGE *cur_range;
bool found_null= FALSE;
int result= HA_ERR_KEY_NOT_FOUND;
@@ -10584,8 +10577,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range()
if (cur_range->flag & NO_MIN_RANGE)
{
- search_prefix_len= real_prefix_len;
- keypart_map= (ULL(1) << real_key_parts) - 1;
+ keypart_map= make_prev_keypart_map(real_key_parts);
find_flag= HA_READ_KEY_EXACT;
}
else
@@ -10593,8 +10585,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range()
/* Extend the search key with the lower boundary for this range. */
memcpy(group_prefix + real_prefix_len, cur_range->min_key,
cur_range->min_length);
- search_prefix_len= real_prefix_len + min_max_arg_len;
- keypart_map= (ULL(2) << real_key_parts) - 1;
+ keypart_map= make_keypart_map(real_key_parts);
find_flag= (cur_range->flag & (EQ_RANGE | NULL_RANGE)) ?
HA_READ_KEY_EXACT : (cur_range->flag & NEAR_MIN) ?
HA_READ_AFTER_KEY : HA_READ_KEY_OR_NEXT;
@@ -10697,8 +10688,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range()
int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range()
{
ha_rkey_function find_flag;
- uint search_prefix_len;
- ulonglong keypart_map;
+ key_part_map keypart_map;
QUICK_RANGE *cur_range;
int result;
@@ -10720,8 +10710,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range()
if (cur_range->flag & NO_MAX_RANGE)
{
- search_prefix_len= real_prefix_len;
- keypart_map= (ULL(1) << real_key_parts) - 1;
+ keypart_map= make_prev_keypart_map(real_key_parts);
find_flag= HA_READ_PREFIX_LAST;
}
else
@@ -10729,8 +10718,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range()
/* Extend the search key with the upper boundary for this range. */
memcpy(group_prefix + real_prefix_len, cur_range->max_key,
cur_range->max_length);
- search_prefix_len= real_prefix_len + min_max_arg_len;
- keypart_map= (ULL(2) << real_key_parts) - 1;
+ keypart_map= make_keypart_map(real_key_parts);
find_flag= (cur_range->flag & EQ_RANGE) ?
HA_READ_KEY_EXACT : (cur_range->flag & NEAR_MAX) ?
HA_READ_BEFORE_KEY : HA_READ_PREFIX_LAST_OR_PREV;
diff --git a/sql/opt_range.h b/sql/opt_range.h
index ce98b4609d1..1ad9567cddd 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -37,15 +37,16 @@ class QUICK_RANGE :public Sql_alloc {
public:
char *min_key,*max_key;
uint16 min_length,max_length,flag;
- ulonglong min_keypart_map, max_keypart_map;
+ key_part_map min_keypart_map, // bitmap of used keyparts in min_key
+ max_keypart_map; // bitmap of used keyparts in max_key
#ifdef HAVE_purify
uint16 dummy; /* Avoid warnings on 'flag' */
#endif
QUICK_RANGE(); /* Full range */
QUICK_RANGE(const char *min_key_arg, uint min_length_arg,
- ulonglong min_keypart_map_arg,
+ key_part_map min_keypart_map_arg,
const char *max_key_arg, uint max_length_arg,
- ulonglong max_keypart_map_arg,
+ key_part_map max_keypart_map_arg,
uint flag_arg)
: min_key((char*) sql_memdup(min_key_arg,min_length_arg+1)),
max_key((char*) sql_memdup(max_key_arg,max_length_arg+1)),
@@ -65,11 +66,11 @@ class QUICK_RANGE :public Sql_alloc {
/*
Quick select interface.
This class is a parent for all QUICK_*_SELECT and FT_SELECT classes.
-
+
The usage scenario is as follows:
1. Create quick select
quick= new QUICK_XXX_SELECT(...);
-
+
2. Perform lightweight initialization. This can be done in 2 ways:
2.a: Regular initialization
if (quick->init())
@@ -80,29 +81,29 @@ class QUICK_RANGE :public Sql_alloc {
2.b: Special initialization for quick selects merged by QUICK_ROR_*_SELECT
if (quick->init_ror_merged_scan())
delete quick;
-
+
3. Perform zero, one, or more scans.
while (...)
{
// initialize quick select for scan. This may allocate
- // buffers and/or prefetch rows.
+ // buffers and/or prefetch rows.
if (quick->reset())
{
//the only valid action after failed reset() call is delete
delete quick;
//abort query
}
-
+
// perform the scan
do
{
res= quick->get_next();
} while (res && ...)
}
-
+
4. Delete the select:
delete quick;
-
+
*/
class QUICK_SELECT_I
@@ -128,6 +129,8 @@ public:
Max. number of (first) key parts this quick select uses for retrieval.
eg. for "(key1p1=c1 AND key1p2=c2) OR key1p1=c2" used_key_parts == 2.
Applicable if index!= MAX_KEY.
+
+ For QUICK_GROUP_MIN_MAX_SELECT it includes MIN/MAX argument keyparts.
*/
uint used_key_parts;
@@ -323,7 +326,7 @@ public:
int reset(void);
int get_next();
void range_end();
- int get_next_prefix(uint prefix_length, ulonglong keypart_map,
+ int get_next_prefix(uint prefix_length, key_part_map keypart_map,
byte *cur_prefix);
bool reverse_sorted() { return 0; }
bool unique_key_range();
@@ -611,7 +614,7 @@ private:
byte *tmp_record; /* Temporary storage for next_min(), next_max(). */
byte *group_prefix; /* Key prefix consisting of the GROUP fields. */
uint group_prefix_len; /* Length of the group prefix. */
- uint group_key_parts;
+ uint group_key_parts; /* A number of keyparts in the group prefix */
byte *last_prefix; /* Prefix of the last group for detecting EOF. */
bool have_min; /* Specify whether we are computing */
bool have_max; /* a MIN, a MAX, or both. */
@@ -623,7 +626,7 @@ private:
uint key_infix_len;
DYNAMIC_ARRAY min_max_ranges; /* Array of range ptrs for the MIN/MAX field. */
uint real_prefix_len; /* Length of key prefix extended with key_infix. */
- uint real_key_parts;
+ uint real_key_parts; /* A number of keyparts in the above value. */
List<Item_sum> *min_functions;
List<Item_sum> *max_functions;
List_iterator<Item_sum> *min_functions_it;
diff --git a/sql/sp.cc b/sql/sp.cc
index 27b3b2532c3..eef5dc01912 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -218,7 +218,7 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, TABLE *table)
key_copy(key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read_idx(table->record[0], 0, key, ~ULL(0),
+ if (table->file->index_read_idx(table->record[0], 0, key, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
DBUG_RETURN(SP_KEY_NOT_FOUND);
@@ -924,7 +924,7 @@ sp_drop_db_routines(THD *thd, char *db)
table->file->ha_index_init(0, 1);
if (! table->file->index_read(table->record[0],
(byte *)table->field[MYSQL_PROC_FIELD_DB]->ptr,
- (ulonglong)1, HA_READ_KEY_EXACT))
+ (key_part_map)1, HA_READ_KEY_EXACT))
{
int nxtres;
bool deleted= FALSE;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 2b642689281..aaa88071173 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1813,7 +1813,7 @@ static bool update_user_table(THD *thd, TABLE *table,
table->key_info->key_length);
if (table->file->index_read_idx(table->record[0], 0,
- (byte *) user_key, ~ULL(0),
+ (byte *) user_key, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{
my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH),
@@ -1904,7 +1904,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
key_copy(user_key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read_idx(table->record[0], 0, user_key, ~ULL(0),
+ if (table->file->index_read_idx(table->record[0], 0, user_key, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{
/* what == 'N' means revoke */
@@ -2121,7 +2121,7 @@ static int replace_db_table(TABLE *table, const char *db,
key_copy(user_key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read_idx(table->record[0],0, user_key, ~ULL(0),
+ if (table->file->index_read_idx(table->record[0],0, user_key, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{
if (what == 'N')
@@ -2339,7 +2339,7 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
col_privs->file->ha_index_init(0, 1);
if (col_privs->file->index_read(col_privs->record[0], (byte*) key,
- (ulonglong)15, HA_READ_KEY_EXACT))
+ (key_part_map)15, HA_READ_KEY_EXACT))
{
cols = 0; /* purecov: deadcode */
col_privs->file->ha_index_end();
@@ -2501,7 +2501,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
key_copy(user_key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read(table->record[0], user_key, ~(ulonglong)0,
+ if (table->file->index_read(table->record[0], user_key, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{
if (revoke_grant)
@@ -2577,7 +2577,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
key_copy(user_key, table->record[0], table->key_info,
key_prefix_length);
- if (table->file->index_read(table->record[0], user_key, (ulonglong)15,
+ if (table->file->index_read(table->record[0], user_key, (key_part_map)15,
HA_READ_KEY_EXACT))
goto end;
@@ -2678,7 +2678,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
key_copy(user_key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read_idx(table->record[0], 0, user_key, ~ULL(0),
+ if (table->file->index_read_idx(table->record[0], 0, user_key, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{
/*
@@ -2796,13 +2796,13 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name,
table->field[2]->store(combo.user.str,combo.user.length, &my_charset_latin1);
table->field[3]->store(routine_name,(uint) strlen(routine_name),
&my_charset_latin1);
- table->field[4]->store((longlong)(is_proc ?
+ table->field[4]->store((longlong)(is_proc ?
TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION),
TRUE);
store_record(table,record[1]); // store at pos 1
if (table->file->index_read_idx(table->record[0], 0,
- (byte*) table->field[0]->ptr, ~ULL(0),
+ (byte*) table->field[0]->ptr, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{
/*
@@ -5001,7 +5001,7 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop,
key_copy(user_key, table->record[0], table->key_info, key_prefix_length);
if ((error= table->file->index_read_idx(table->record[0], 0,
- user_key, ULL(3),
+ user_key, (key_part_map)3,
HA_READ_KEY_EXACT)))
{
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 9c6c98cb151..cd87330cedb 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -515,7 +515,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
}
List_iterator<Item> it_ke(*key_expr);
Item *item;
- ulonglong keypart_map;
+ key_part_map keypart_map;
for (keypart_map= key_len=0 ; (item=it_ke++) ; key_part++)
{
my_bitmap_map *old_map;
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index aacfd8f8245..b677111c019 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -295,7 +295,7 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations,
rkey_id->store((longlong) key_id, TRUE);
rkey_id->get_key_image(buff, rkey_id->pack_length(), Field::itRAW);
int key_res= relations->file->index_read(relations->record[0],
- (byte *) buff, (ulonglong)1,
+ (byte *) buff, (key_part_map)1,
HA_READ_KEY_EXACT);
for ( ;
@@ -309,7 +309,7 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations,
field->get_key_image(topic_id_buff, field->pack_length(), Field::itRAW);
if (!topics->file->index_read(topics->record[0], (byte *)topic_id_buff,
- (ulonglong)1, HA_READ_KEY_EXACT))
+ (key_part_map)1, HA_READ_KEY_EXACT))
{
memorize_variant_topic(thd,topics,count,find_fields,
names,name,description,example);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 62c4e32409b..e973180eef7 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1214,7 +1214,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
}
key_copy((byte*) key,table->record[0],table->key_info+key_nr,0);
if ((error=(table->file->index_read_idx(table->record[1],key_nr,
- (byte*) key, ~ULL(0),
+ (byte*) key, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))))
goto err;
}
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index d7ced748394..70bc9ef23d5 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -943,7 +943,7 @@ my_bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name)
table->use_all_columns();
table->field[0]->store(name->str, name->length, system_charset_info);
if (! table->file->index_read_idx(table->record[0], 0,
- (byte *)table->field[0]->ptr, ~ULL(0),
+ (byte *)table->field[0]->ptr, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{
int error;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 8661503df8e..8184b2a732e 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -10980,7 +10980,7 @@ int safe_index_read(JOIN_TAB *tab)
TABLE *table= tab->table;
if ((error=table->file->index_read(table->record[0],
tab->ref.key_buff,
- tab_to_keypart_map(tab),
+ make_prev_keypart_map(tab->ref.key_parts),
HA_READ_KEY_EXACT)))
return report_error(table, error);
return 0;
@@ -11119,7 +11119,7 @@ join_read_const(JOIN_TAB *tab)
{
error=table->file->index_read_idx(table->record[0],tab->ref.key,
(byte*) tab->ref.key_buff,
- tab_to_keypart_map(tab),
+ make_prev_keypart_map(tab->ref.key_parts),
HA_READ_KEY_EXACT);
}
if (error)
@@ -11163,7 +11163,7 @@ join_read_key(JOIN_TAB *tab)
}
error=table->file->index_read(table->record[0],
tab->ref.key_buff,
- tab_to_keypart_map(tab),
+ make_prev_keypart_map(tab->ref.key_parts),
HA_READ_KEY_EXACT);
if (error && error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
return report_error(table, error);
@@ -11192,7 +11192,7 @@ join_read_always_key(JOIN_TAB *tab)
return -1;
if ((error=table->file->index_read(table->record[0],
tab->ref.key_buff,
- tab_to_keypart_map(tab),
+ make_prev_keypart_map(tab->ref.key_parts),
HA_READ_KEY_EXACT)))
{
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
@@ -11219,8 +11219,7 @@ join_read_last_key(JOIN_TAB *tab)
if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref))
return -1;
if ((error=table->file->index_read_last(table->record[0],
- tab->ref.key_buff,
- tab_to_keypart_map(tab))))
+ tab->ref.key_buff, make_prev_keypart_map(tab->ref.key_parts))))
{
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
return report_error(table, error);
@@ -11761,7 +11760,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
group->buff[-1]= (char) group->field->is_null();
}
if (!table->file->index_read(table->record[1],
- join->tmp_table_param.group_buff, ~(ulonglong)0,
+ join->tmp_table_param.group_buff, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{ /* Update old record */
restore_record(table,record[1]);
diff --git a/sql/sql_select.h b/sql/sql_select.h
index e31fe143573..ca93179f9d9 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -192,7 +192,7 @@ typedef struct st_join_table {
JOIN *join;
/* Bitmap of nested joins this table is part of */
nested_join_map embedding_map;
-
+
void cleanup();
inline bool is_using_loose_index_scan()
{
@@ -202,11 +202,6 @@ typedef struct st_join_table {
}
} JOIN_TAB;
-static inline ulonglong tab_to_keypart_map(JOIN_TAB *tab)
-{
- return (ULL(1) << tab->ref.key_parts) - 1;
-}
-
enum_nested_loop_state sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool
end_of_records);
enum_nested_loop_state sub_select(JOIN *join,JOIN_TAB *join_tab, bool
diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc
index 1d7c8d5272d..7b3b71cdd9a 100644
--- a/sql/sql_servers.cc
+++ b/sql/sql_servers.cc
@@ -354,7 +354,7 @@ my_bool server_exists_in_table(THD *thd, LEX_SERVER_OPTIONS *server_options)
system_charset_info);
if ((error= table->file->index_read_idx(table->record[0], 0,
- (byte *)table->field[0]->ptr, ~(ulonglong)0,
+ (byte *)table->field[0]->ptr, HA_WHOLE_KEY,
HA_READ_KEY_EXACT)))
{
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
@@ -554,7 +554,7 @@ int insert_server_record(TABLE *table, FOREIGN_SERVER *server)
/* read index until record is that specified in server_name */
if ((error= table->file->index_read_idx(table->record[0], 0,
- (byte *)table->field[0]->ptr, ~(longlong)0,
+ (byte *)table->field[0]->ptr, HA_WHOLE_KEY,
HA_READ_KEY_EXACT)))
{
/* if not found, err */
@@ -926,7 +926,7 @@ int delete_server_record(TABLE *table,
table->field[0]->store(server_name, server_name_length, system_charset_info);
if ((error= table->file->index_read_idx(table->record[0], 0,
- (byte *)table->field[0]->ptr, ~(ulonglong)0,
+ (byte *)table->field[0]->ptr, HA_WHOLE_KEY,
HA_READ_KEY_EXACT)))
{
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index b0e7831465a..4c584bff72a 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -514,7 +514,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
table->use_all_columns();
table->field[0]->store(exact_name_str, exact_name_len, &my_charset_bin);
if (!table->file->index_read_idx(table->record[0], 0,
- (byte*) table->field[0]->ptr, ~ULL(0),
+ (byte*) table->field[0]->ptr, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{
int error;
@@ -523,7 +523,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
}
close_thread_tables(thd);
- rw_unlock(&THR_LOCK_udf);
+ rw_unlock(&THR_LOCK_udf);
DBUG_RETURN(0);
err:
rw_unlock(&THR_LOCK_udf);
diff --git a/sql/table.cc b/sql/table.cc
index e4b3be5dbe0..f2bf25e6a75 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2250,7 +2250,7 @@ char *get_field(MEM_ROOT *mem, Field *field)
that are present in this value, returns the length of the value
*/
uint calculate_key_len(TABLE *table, uint key, const byte *buf,
- ulonglong keypart_map)
+ key_part_map keypart_map)
{
/* works only with key prefixes */
DBUG_ASSERT(((keypart_map + 1) & keypart_map) == 0);
diff --git a/sql/table.h b/sql/table.h
index d15929e8cba..aa053f207b3 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -197,9 +197,9 @@ typedef struct st_table_share
uint rowid_field_offset; /* Field_nr +1 to rowid field */
/* Index of auto-updated TIMESTAMP field in field array */
uint primary_key;
- uint next_number_index;
- uint next_number_key_offset;
- uint next_number_keypart;
+ uint next_number_index; /* autoincrement key number */
+ uint next_number_key_offset; /* autoinc keypart offset in a key */
+ uint next_number_keypart; /* autoinc keypart number in a key */
uint error, open_errno, errarg; /* error from open_table_def() */
uint column_bitmap_size;
uchar frm_version;
diff --git a/sql/tztime.cc b/sql/tztime.cc
index b9f757faeb8..18161022dc3 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -1917,7 +1917,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
(void)table->file->ha_index_init(0, 1);
if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr,
- ~(ulonglong)0, HA_READ_KEY_EXACT))
+ HA_WHOLE_KEY, HA_READ_KEY_EXACT))
{
#ifdef EXTRA_DEBUG
/*
@@ -1945,7 +1945,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
(void)table->file->ha_index_init(0, 1);
if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr,
- ~(ulonglong)0, HA_READ_KEY_EXACT))
+ HA_WHOLE_KEY, HA_READ_KEY_EXACT))
{
sql_print_error("Can't find description of time zone '%u'", tzid);
goto end;
@@ -1973,7 +1973,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
(void)table->file->ha_index_init(0, 1);
res= table->file->index_read(table->record[0], (byte*)table->field[0]->ptr,
- (ulonglong)1, HA_READ_KEY_EXACT);
+ (key_part_map)1, HA_READ_KEY_EXACT);
while (!res)
{
ttid= (uint)table->field[1]->val_int();
@@ -2045,7 +2045,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
(void)table->file->ha_index_init(0, 1);
res= table->file->index_read(table->record[0], (byte*)table->field[0]->ptr,
- (ulonglong)1, HA_READ_KEY_EXACT);
+ (key_part_map)1, HA_READ_KEY_EXACT);
while (!res)
{
ttime= (my_time_t)table->field[1]->val_int();