summaryrefslogtreecommitdiff
path: root/sql/examples
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-11-24 04:08:07 +0200
committerunknown <monty@mysql.com>2005-11-24 04:08:07 +0200
commitc5349d884557ba7706a35e38c8cb35da1d332e00 (patch)
tree439a23033b6cb0f1815201ada8b600383b2c6aef /sql/examples
parent039168c2fa724b9ed87ce2f19a7ea20acbd8a1de (diff)
parent81b2bbac056f21b0783f21a5830c07aba4850d85 (diff)
downloadmariadb-git-c5349d884557ba7706a35e38c8cb35da1d332e00.tar.gz
Merge mysql.com:/home/my/mysql-5.1
into mysql.com:/home/my/mysql-5.1-TDC sql/ha_federated.cc: Auto merged sql/mysql_priv.h: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_parse.cc: Auto merged sql/examples/ha_tina.cc: Auto merged sql/examples/ha_tina.h: Auto merged sql/unireg.h: Auto merged
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 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);