diff options
author | unknown <brian@zim.(none)> | 2006-01-10 22:54:34 -0800 |
---|---|---|
committer | unknown <brian@zim.(none)> | 2006-01-10 22:54:34 -0800 |
commit | a9d9054a10b5f7cb6ed288871fd4922ba8387380 (patch) | |
tree | aad87c148f4c6253ee2360c95716cb028bb23652 /sql/ha_archive.cc | |
parent | 2c0f53d69ceba4f3db98afba47bfb73b3b83525d (diff) | |
download | mariadb-git-a9d9054a10b5f7cb6ed288871fd4922ba8387380.tar.gz |
Added support for CREATE TABLE AUTO_INCREMENT and added more tests. Also non-unique index scans of autoincrement not function.
mysql-test/r/archive.result:
New Result file.
mysql-test/t/archive.test:
New tests. Modifies old style 0 to NULL.
sql/ha_archive.cc:
Added support for scanning non unique indexes. Added support for the AUTO_INCREMENT bit for CREATE TABLE
sql/ha_archive.h:
Added variables for continueing scans of index_next
Diffstat (limited to 'sql/ha_archive.cc')
-rw-r--r-- | sql/ha_archive.cc | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index 74e7fa68499..81b3a4e2339 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -581,6 +581,10 @@ int ha_archive::create(const char *name, TABLE *table_arg, int error; DBUG_ENTER("ha_archive::create"); + auto_increment_value= (create_info->auto_increment_value ? + create_info->auto_increment_value -1 : + (ulonglong) 0); + if ((create_file= my_create(fn_format(name_buff,name,"",ARM, MY_REPLACE_EXT|MY_UNPACK_FILENAME),0, O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) @@ -607,7 +611,7 @@ int ha_archive::create(const char *name, TABLE *table_arg, } } - write_meta_file(create_file, 0, 0, FALSE); + write_meta_file(create_file, 0, auto_increment_value, FALSE); my_close(create_file,MYF(0)); /* @@ -834,7 +838,9 @@ int ha_archive::index_read_idx(byte *buf, uint index, const byte *key, int rc= 0; bool found= 0; KEY *mkey= &table->s->key_info[index]; - uint k_offset= mkey->key_part->offset; + current_k_offset= mkey->key_part->offset; + current_key= key; + current_key_len= key_len; DBUG_ENTER("ha_archive::index_read_idx"); @@ -858,7 +864,7 @@ int ha_archive::index_read_idx(byte *buf, uint index, const byte *key, while (!(get_row(&archive, buf))) { - if (!memcmp(key, buf+k_offset, key_len)) + if (!memcmp(current_key, buf + current_k_offset, current_key_len)) { found= 1; break; @@ -872,6 +878,25 @@ error: DBUG_RETURN(rc ? rc : HA_ERR_END_OF_FILE); } + +int ha_archive::index_next(byte * buf) +{ + bool found= 0; + + DBUG_ENTER("ha_archive::index_next"); + + while (!(get_row(&archive, buf))) + { + if (!memcmp(current_key, buf+current_k_offset, current_key_len)) + { + found= 1; + break; + } + } + + DBUG_RETURN(found ? 0 : HA_ERR_END_OF_FILE); +} + /* All calls that need to scan the table start with this method. If we are told that it is a table scan we rewind the file to the beginning, otherwise @@ -1210,6 +1235,15 @@ THR_LOCK_DATA **ha_archive::store_lock(THD *thd, return to; } +void ha_archive::update_create_info(HA_CREATE_INFO *create_info) +{ + ha_archive::info(HA_STATUS_AUTO | HA_STATUS_CONST); + if (!(create_info->used_fields & HA_CREATE_USED_AUTO)) + { + create_info->auto_increment_value=auto_increment_value; + } +} + /* Hints for optimizer, see ha_tina for more information |