Commit 14e6526a authored by unknown's avatar unknown

support for HA_READ_PREFIX_LAST_OR_PREV in headres

full support for HA_READ_PREFIX_LAST_OR_PREV in MyISAM
protected by #if NOT_IMPLEMENTED_YET in opt_range.cc as not all table handlers support it


BitKeeper/etc/ignore:
  Added configure.lineno innobase/configure.lineno innobase/stamp-h1 myisam/rt_test.MYD myisam/rt_test.MYI stamp-h1 to the ignore list
include/my_base.h:
  support for HA_READ_PREFIX_LAST_OR_PREV
myisam/mi_search.c:
  full support of HA_READ_PREFIX_LAST_OR_PREV in MyISAM
myisam/mi_static.c:
  full support of HA_READ_PREFIX_LAST_OR_PREV in MyISAM
sql/opt_range.cc:
  support for HA_READ_PREFIX_LAST_OR_PREV
  protected by #if NOT_IMPLEMENTED_YET, not all table handlers support it
sql/sql_handler.cc:
  support for HA_READ_PREFIX_LAST_OR_PREV
parent 372b26e7
...@@ -505,3 +505,11 @@ vio/test-sslserver ...@@ -505,3 +505,11 @@ vio/test-sslserver
vio/viotest-ssl vio/viotest-ssl
sql_error.cc sql_error.cc
sql_prepare.cc sql_prepare.cc
autom4te.cache/*
innobase/autom4te.cache/*
configure.lineno
innobase/configure.lineno
innobase/stamp-h1
myisam/rt_test.MYD
myisam/rt_test.MYI
stamp-h1
...@@ -50,13 +50,14 @@ ...@@ -50,13 +50,14 @@
/* The following is parameter to ha_rkey() how to use key */ /* The following is parameter to ha_rkey() how to use key */
enum ha_rkey_function { enum ha_rkey_function {
HA_READ_KEY_EXACT, /* Find first record else error */ HA_READ_KEY_EXACT, /* Find first record else error */
HA_READ_KEY_OR_NEXT, /* Record or next record */ HA_READ_KEY_OR_NEXT, /* Record or next record */
HA_READ_KEY_OR_PREV, /* Record or previous */ HA_READ_KEY_OR_PREV, /* Record or previous */
HA_READ_AFTER_KEY, /* Find next rec. after key-record */ HA_READ_AFTER_KEY, /* Find next rec. after key-record */
HA_READ_BEFORE_KEY, /* Find next rec. before key-record */ HA_READ_BEFORE_KEY, /* Find next rec. before key-record */
HA_READ_PREFIX, /* Key which as same prefix */ HA_READ_PREFIX, /* Key which as same prefix */
HA_READ_PREFIX_LAST, /* Last key with the same prefix */ HA_READ_PREFIX_LAST, /* Last key with the same prefix */
HA_READ_PREFIX_LAST_OR_PREV, /* Last or prev key with the same prefix */
HA_READ_MBR_CONTAIN, HA_READ_MBR_CONTAIN,
HA_READ_MBR_INTERSECT, HA_READ_MBR_INTERSECT,
HA_READ_MBR_WITHIN, HA_READ_MBR_WITHIN,
...@@ -66,7 +67,7 @@ enum ha_rkey_function { ...@@ -66,7 +67,7 @@ enum ha_rkey_function {
/* Key algorithm types */ /* Key algorithm types */
enum ha_key_alg { enum ha_key_alg {
HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */ HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */
HA_KEY_ALG_BTREE= 1, /* B-tree, default one */ HA_KEY_ALG_BTREE= 1, /* B-tree, default one */
HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */ HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */
...@@ -202,7 +203,7 @@ enum ha_base_keytype { ...@@ -202,7 +203,7 @@ enum ha_base_keytype {
/* Bits in flag to _status */ /* Bits in flag to _status */
#define HA_STATUS_POS 1 /* Return position */ #define HA_STATUS_POS 1 /* Return position */
#define HA_STATUS_NO_LOCK 2 /* Don't use external lock */ #define HA_STATUS_NO_LOCK 2 /* Don't use external lock */
#define HA_STATUS_TIME 4 /* Return update time */ #define HA_STATUS_TIME 4 /* Return update time */
#define HA_STATUS_CONST 8 /* Return constants values */ #define HA_STATUS_CONST 8 /* Return constants values */
#define HA_STATUS_VARIABLE 16 #define HA_STATUS_VARIABLE 16
...@@ -233,7 +234,7 @@ enum ha_base_keytype { ...@@ -233,7 +234,7 @@ enum ha_base_keytype {
#define HA_ERR_WRONG_TABLE_DEF 143 #define HA_ERR_WRONG_TABLE_DEF 143
#define HA_ERR_CRASHED_ON_REPAIR 144 /* Last (automatic?) repair failed */ #define HA_ERR_CRASHED_ON_REPAIR 144 /* Last (automatic?) repair failed */
#define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */ #define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */
#define HA_ERR_LOCK_WAIT_TIMEOUT 146 #define HA_ERR_LOCK_WAIT_TIMEOUT 146
#define HA_ERR_LOCK_TABLE_FULL 147 #define HA_ERR_LOCK_TABLE_FULL 147
#define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */ #define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */
#define HA_ERR_LOCK_DEADLOCK 149 #define HA_ERR_LOCK_DEADLOCK 149
...@@ -272,7 +273,7 @@ enum ha_base_keytype { ...@@ -272,7 +273,7 @@ enum ha_base_keytype {
#define READ_CHECK_USED 4 #define READ_CHECK_USED 4
#define KEY_READ_USED 8 #define KEY_READ_USED 8
#define WRITE_CACHE_USED 16 #define WRITE_CACHE_USED 16
#define OPT_NO_ROWS 32 #define OPT_NO_ROWS 32
/* bits in update */ /* bits in update */
#define HA_STATE_CHANGED 1 /* Database has changed */ #define HA_STATE_CHANGED 1 /* Database has changed */
...@@ -302,7 +303,7 @@ enum data_file_type { ...@@ -302,7 +303,7 @@ enum data_file_type {
#ifdef BIG_TABLES #ifdef BIG_TABLES
typedef my_off_t ha_rows; typedef my_off_t ha_rows;
#else #else
typedef ulong ha_rows; typedef ulong ha_rows;
#endif #endif
#define HA_POS_ERROR (~ (ha_rows) 0) #define HA_POS_ERROR (~ (ha_rows) 0)
......
...@@ -132,7 +132,7 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, ...@@ -132,7 +132,7 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
if (_mi_get_prev_key(info,keyinfo, buff, info->lastkey, keypos, if (_mi_get_prev_key(info,keyinfo, buff, info->lastkey, keypos,
&info->lastkey_length)) &info->lastkey_length))
goto err; goto err;
if ((nextflag & SEARCH_LAST) && if (!(nextflag & SEARCH_SMALLER) &&
ha_key_cmp(keyinfo->seg, info->lastkey, key, key_len, SEARCH_FIND, ha_key_cmp(keyinfo->seg, info->lastkey, key, key_len, SEARCH_FIND,
&not_used)) &not_used))
{ {
......
...@@ -51,12 +51,12 @@ uint NEAR myisam_read_vec[]= ...@@ -51,12 +51,12 @@ uint NEAR myisam_read_vec[]=
{ {
SEARCH_FIND, SEARCH_FIND | SEARCH_BIGGER, SEARCH_FIND | SEARCH_SMALLER, SEARCH_FIND, SEARCH_FIND | SEARCH_BIGGER, SEARCH_FIND | SEARCH_SMALLER,
SEARCH_NO_FIND | SEARCH_BIGGER, SEARCH_NO_FIND | SEARCH_SMALLER, SEARCH_NO_FIND | SEARCH_BIGGER, SEARCH_NO_FIND | SEARCH_SMALLER,
SEARCH_FIND | SEARCH_PREFIX, SEARCH_LAST, SEARCH_FIND | SEARCH_PREFIX, SEARCH_LAST, SEARCH_LAST | SEARCH_SMALLER,
MBR_CONTAIN, MBR_INTERSECT, MBR_WITHIN, MBR_DISJOINT, MBR_EQUAL MBR_CONTAIN, MBR_INTERSECT, MBR_WITHIN, MBR_DISJOINT, MBR_EQUAL
}; };
uint NEAR myisam_readnext_vec[]= uint NEAR myisam_readnext_vec[]=
{ {
SEARCH_BIGGER, SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_BIGGER, SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_BIGGER, SEARCH_SMALLER,
SEARCH_BIGGER, SEARCH_SMALLER SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_SMALLER
}; };
...@@ -2238,7 +2238,7 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree, ...@@ -2238,7 +2238,7 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree,
{ {
tmp=param->table->file-> tmp=param->table->file->
records_in_range((int) keynr,(byte*)(param->min_key + 1), records_in_range((int) keynr,(byte*)(param->min_key + 1),
min_key_length, (ha_rkey_function)(tmp_min_flag ^ GEOM_FLAG), min_key_length, (ha_rkey_function)(tmp_min_flag ^ GEOM_FLAG),
(byte *)NullS,0,HA_READ_KEY_EXACT); (byte *)NullS,0,HA_READ_KEY_EXACT);
} }
else else
...@@ -2705,20 +2705,28 @@ int QUICK_SELECT_DESC::get_next() ...@@ -2705,20 +2705,28 @@ int QUICK_SELECT_DESC::get_next()
} }
else else
{ {
DBUG_ASSERT(range->flag & NEAR_MAX || range_reads_after_key(range));
#if NOT_IMPLEMENTED_YET
result=file->index_read(record, (byte*) range->max_key,
range->max_length,
((range->flag & NEAR_MAX) ?
HA_READ_BEFORE_KEY : HA_READ_PREFIX_LAST_OR_PREV));
#else
/* Heikki changed Sept 11, 2002: since InnoDB does not store the cursor /* Heikki changed Sept 11, 2002: since InnoDB does not store the cursor
position if READ_KEY_EXACT is used to a primary key with all position if READ_KEY_EXACT is used to a primary key with all
key columns specified, we must use below HA_READ_KEY_OR_NEXT, key columns specified, we must use below HA_READ_KEY_OR_NEXT,
so that InnoDB stores the cursor position and is able to move so that InnoDB stores the cursor position and is able to move
the cursor one step backward after the search. */ the cursor one step backward after the search. */
DBUG_ASSERT(range->flag & NEAR_MAX || range_reads_after_key(range));
/* Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will /* Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will
* do the right thing - go past all keys which match the prefix */ * do the right thing - go past all keys which match the prefix */
result=file->index_read(record, (byte*) range->max_key, result=file->index_read(record, (byte*) range->max_key,
range->max_length, range->max_length,
((range->flag & NEAR_MAX) ? ((range->flag & NEAR_MAX) ?
HA_READ_KEY_OR_NEXT : HA_READ_AFTER_KEY)); HA_READ_KEY_OR_NEXT : HA_READ_AFTER_KEY));
result = file->index_prev(record); result = file->index_prev(record);
#endif
} }
if (result) if (result)
{ {
......
...@@ -88,7 +88,7 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok) ...@@ -88,7 +88,7 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok)
} }
static enum enum_ha_read_modes rkey_to_rnext[]= static enum enum_ha_read_modes rkey_to_rnext[]=
{ RNEXT, RNEXT, RPREV, RNEXT, RPREV, RNEXT, RPREV }; { RNEXT, RNEXT, RPREV, RNEXT, RPREV, RNEXT, RPREV, RPREV };
int mysql_ha_read(THD *thd, TABLE_LIST *tables, int mysql_ha_read(THD *thd, TABLE_LIST *tables,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment