summaryrefslogtreecommitdiff
path: root/sql/examples
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2005-11-17 22:52:31 +0100
committerunknown <serg@serg.mylan>2005-11-17 22:52:31 +0100
commitf2af624e4514078a7cb8aac973777f1dc9b10b9b (patch)
treed8d084fac2edf719bb5f0ed8d2db29cfa7df4f66 /sql/examples
parent57ad6b20ed8b22b010af1c354b23591570f12b09 (diff)
downloadmariadb-git-f2af624e4514078a7cb8aac973777f1dc9b10b9b.tar.gz
BUG#13406 - incorrect amount of "records deleted" in CSV.
Fallback to row-wise delete if number or rows in the table is unknown mysql-test/r/csv.result: BUG#13406 - incorrect amount of "records deleted" mysql-test/t/csv.test: BUG#13406 - incorrect amount of "records deleted" sql/examples/ha_tina.cc: BUG#13406 - incorrect amount of "records deleted". Fallback to row-wise delete if number or rows in the table is unknown sql/examples/ha_tina.h: BUG#13406 - incorrect amount of "records deleted". Fallback to row-wise delete if number or rows in the table is unknown
Diffstat (limited to 'sql/examples')
-rw-r--r--sql/examples/ha_tina.cc15
-rw-r--r--sql/examples/ha_tina.h1
2 files changed, 13 insertions, 3 deletions
diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc
index e00657c66ba..8ae82f97d0b 100644
--- a/sql/examples/ha_tina.cc
+++ b/sql/examples/ha_tina.cc
@@ -274,7 +274,8 @@ ha_tina::ha_tina(TABLE *table_arg)
These definitions are found in hanler.h
These are not probably completely right.
*/
- current_position(0), next_position(0), chain_alloced(0), chain_size(DEFAULT_CHAIN_LENGTH)
+ current_position(0), next_position(0), chain_alloced(0),
+ 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);
@@ -504,6 +505,7 @@ int ha_tina::write_row(byte * buf)
*/
if (get_mmap(share, 0) > 0)
DBUG_RETURN(-1);
+ records++;
DBUG_RETURN(0);
}
@@ -668,6 +670,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)
@@ -745,7 +748,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;
}
@@ -780,6 +783,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)
{
@@ -824,17 +829,21 @@ int ha_tina::rnd_end()
}
/*
- Truncate table and others of its ilk call this.
+ DELETE without WHERE calls it
*/
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 84854e868fa..97659f99dd9 100644
--- a/sql/examples/ha_tina.h
+++ b/sql/examples/ha_tina.h
@@ -48,6 +48,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);