summaryrefslogtreecommitdiff
path: root/sql/examples
diff options
context:
space:
mode:
authormonty@mysql.com <>2005-11-24 02:56:12 +0200
committermonty@mysql.com <>2005-11-24 02:56:12 +0200
commitaa37b75768eaea30a35b0e6e60185bbd95b7bada (patch)
tree586e1c8d17361d92a7ddb4190893e1d6527e6fc9 /sql/examples
parent30b360bfccdf9471efb444df0514693f0fb94444 (diff)
parentf5804869e376e7214817a5ccd23737ec9f46f0d0 (diff)
downloadmariadb-git-aa37b75768eaea30a35b0e6e60185bbd95b7bada.tar.gz
Merge mysql.com:/home/my/mysql-5.0
into mysql.com:/home/my/mysql-5.1
Diffstat (limited to 'sql/examples')
-rw-r--r--sql/examples/ha_tina.cc18
-rw-r--r--sql/examples/ha_tina.h1
2 files changed, 15 insertions, 4 deletions
diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc
index 6bb883f91e0..16815a9705b 100644
--- a/sql/examples/ha_tina.cc
+++ b/sql/examples/ha_tina.cc
@@ -298,7 +298,7 @@ ha_tina::ha_tina(TABLE *table_arg)
These 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);
@@ -534,6 +534,7 @@ int ha_tina::write_row(byte * buf)
*/
if (get_mmap(share, 0) > 0)
DBUG_RETURN(-1);
+ records++;
DBUG_RETURN(0);
}
@@ -700,6 +701,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)
@@ -781,7 +783,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;
}
@@ -818,6 +820,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)
{
@@ -862,18 +866,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 2de6d8c8257..eab8c01c9ec 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 *table_arg);