diff options
author | monty@tik.mysql.fi <> | 2002-01-12 15:42:54 +0200 |
---|---|---|
committer | monty@tik.mysql.fi <> | 2002-01-12 15:42:54 +0200 |
commit | 7dd4eb71fe7576e428fe1ecaaad214d3a39ff4dc (patch) | |
tree | 5c9b603230485a57877f3b066d095b6668bd1d2e /sql/ha_berkeley.cc | |
parent | 47408baac6f53cd32ff45c83b09fb56a9084bd5b (diff) | |
download | mariadb-git-7dd4eb71fe7576e428fe1ecaaad214d3a39ff4dc.tar.gz |
Added support of null keys in HEAP tables
Added ORDER BY optimization
Diffstat (limited to 'sql/ha_berkeley.cc')
-rw-r--r-- | sql/ha_berkeley.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index e0a802b499a..6a9187a7cb2 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -1454,6 +1454,37 @@ int ha_berkeley::index_read(byte * buf, const byte * key, DBUG_RETURN(error); } +/* + Read last key is solved by reading the next key and then reading + the previous key +*/ + +int ha_berkeley::index_read_last(byte * buf, const byte * key, uint key_len) +{ + DBT row; + int error; + KEY *key_info= &table->key_info[active_index]; + DBUG_ENTER("ha_berkeley::index_read"); + + statistic_increment(ha_read_key_count,&LOCK_status); + bzero((char*) &row,sizeof(row)); + + /* read of partial key */ + pack_key(&last_key, active_index, key_buff, key, key_len); + /* Store for compare */ + memcpy(key_buff2, key_buff, (key_len=last_key.size)); + key_info->handler.bdb_return_if_eq= 1; + error=read_row(cursor->c_get(cursor, &last_key, &row, DB_SET_RANGE), + (char*) buf, active_index, &row, (DBT*) 0, 0); + key_info->handler.bdb_return_if_eq= 0; + bzero((char*) &row,sizeof(row)); + if (read_row(cursor->c_get(cursor, &last_key, &row, DB_PREV), + (char*) buf, active_index, &row, &last_key, 1) || + berkeley_key_cmp(table, key_info, key_buff2, key_len)) + error=HA_ERR_KEY_NOT_FOUND; + DBUG_RETURN(error); +} + int ha_berkeley::index_next(byte * buf) { |