diff options
author | monty@mysql.com <> | 2005-11-24 04:08:07 +0200 |
---|---|---|
committer | monty@mysql.com <> | 2005-11-24 04:08:07 +0200 |
commit | a3436bd7de3bf1376a4cff23503a41d70ca84e73 (patch) | |
tree | 439a23033b6cb0f1815201ada8b600383b2c6aef /sql/examples | |
parent | 4575a662cb99b63ec4c790ed00ac6ec09deb7cc3 (diff) | |
parent | aa37b75768eaea30a35b0e6e60185bbd95b7bada (diff) | |
download | mariadb-git-a3436bd7de3bf1376a4cff23503a41d70ca84e73.tar.gz |
Merge mysql.com:/home/my/mysql-5.1
into mysql.com:/home/my/mysql-5.1-TDC
Diffstat (limited to 'sql/examples')
-rw-r--r-- | sql/examples/ha_tina.cc | 18 | ||||
-rw-r--r-- | sql/examples/ha_tina.h | 1 |
2 files changed, 15 insertions, 4 deletions
diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 1312577e126..4f2dc0b5cac 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -298,7 +298,7 @@ ha_tina::ha_tina(TABLE_SHARE *table_arg) They are not probably completely right. */ current_position(0), next_position(0), chain_alloced(0), - chain_size(DEFAULT_CHAIN_LENGTH) + chain_size(DEFAULT_CHAIN_LENGTH), records_is_known(0) { /* Set our original buffers from pre-allocated memory */ buffer.set(byte_buffer, IO_SIZE, system_charset_info); @@ -535,6 +535,7 @@ int ha_tina::write_row(byte * buf) */ if (get_mmap(share, 0) > 0) DBUG_RETURN(-1); + records++; DBUG_RETURN(0); } @@ -701,6 +702,7 @@ int ha_tina::rnd_init(bool scan) current_position= next_position= 0; records= 0; + records_is_known= 0; chain_ptr= chain; #ifdef HAVE_MADVISE if (scan) @@ -782,7 +784,7 @@ void ha_tina::info(uint flag) { DBUG_ENTER("ha_tina::info"); /* This is a lie, but you don't want the optimizer to see zero or 1 */ - if (records < 2) + if (!records_is_known && records < 2) records= 2; DBUG_VOID_RETURN; } @@ -819,6 +821,8 @@ int ha_tina::rnd_end() { DBUG_ENTER("ha_tina::rnd_end"); + records_is_known= 1; + /* First position will be truncate position, second will be increment */ if ((chain_ptr - chain) > 0) { @@ -863,18 +867,24 @@ int ha_tina::rnd_end() DBUG_RETURN(0); } -/* - Truncate table and others of its ilk call this. + +/* + DELETE without WHERE calls this */ + int ha_tina::delete_all_rows() { DBUG_ENTER("ha_tina::delete_all_rows"); + if (!records_is_known) + return (my_errno=HA_ERR_WRONG_COMMAND); + int rc= my_chsize(share->data_file, 0, 0, MYF(MY_WME)); if (get_mmap(share, 0) > 0) DBUG_RETURN(-1); + records=0; DBUG_RETURN(rc); } diff --git a/sql/examples/ha_tina.h b/sql/examples/ha_tina.h index eecdeeb5826..c46750fb703 100644 --- a/sql/examples/ha_tina.h +++ b/sql/examples/ha_tina.h @@ -53,6 +53,7 @@ class ha_tina: public handler tina_set *chain_ptr; byte chain_alloced; uint32 chain_size; + bool records_is_known; public: ha_tina(TABLE_SHARE *table_arg); |