List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:November 17 2005 9:52pm
Subject:bk commit into 5.0 tree (serg:1.1972) BUG#13406
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of serg. When serg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1972 05/11/17 22:52:31 serg@stripped +4 -0
  BUG#13406 - incorrect amount of "records deleted" in CSV.
  Fallback to row-wise delete if number or rows in the table is unknown

  sql/examples/ha_tina.h
    1.6 05/11/17 22:52:19 serg@stripped +1 -0
    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.cc
    1.22 05/11/17 22:52:19 serg@stripped +12 -3
    BUG#13406 - incorrect amount of "records deleted".
    Fallback to row-wise delete if number or rows in the table is unknown

  mysql-test/t/csv.test
    1.5 05/11/17 22:52:19 serg@stripped +32 -0
    BUG#13406 - incorrect amount of "records deleted"

  mysql-test/r/csv.result
    1.4 05/11/17 22:52:19 serg@stripped +24 -0
    BUG#13406 - incorrect amount of "records deleted"

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	serg
# Host:	serg.mylan
# Root:	/usr/home/serg/Abk/mysql-5.0

--- 1.3/mysql-test/r/csv.result	Sun Nov  6 00:11:00 2005
+++ 1.4/mysql-test/r/csv.result	Thu Nov 17 22:52:19 2005
@@ -4976,3 +4976,27 @@ c1
 4
 5
 DROP TABLE bug14672;
+create table t1 (a int) engine=csv;
+insert t1 values (1);
+delete from t1;
+affected rows: 1
+delete from t1;
+affected rows: 0
+insert t1 values (1),(2);
+delete from t1;
+affected rows: 2
+insert t1 values (1),(2),(3);
+flush tables;
+delete from t1;
+affected rows: 3
+insert t1 values (1),(2),(3),(4);
+flush tables;
+select count(*) from t1;
+count(*)
+4
+delete from t1;
+affected rows: 4
+insert t1 values (1),(2),(3),(4),(5);
+truncate table t1;
+affected rows: 0
+drop table t1;

--- 1.4/mysql-test/t/csv.test	Sun Nov  6 00:11:00 2005
+++ 1.5/mysql-test/t/csv.test	Thu Nov 17 22:52:19 2005
@@ -1352,3 +1352,35 @@ SELECT * FROM bug14672;  
 DROP TABLE bug14672;
 
 # End of 4.1 tests
+
+#
+# BUG#13406 - incorrect amount of "records deleted"
+#
+
+create table t1 (a int) engine=csv;
+insert t1 values (1);
+--enable_info
+delete from t1;                 -- delete_row
+delete from t1;                 -- delete_all_rows
+--disable_info
+insert t1 values (1),(2);
+--enable_info
+delete from t1;                 -- delete_all_rows
+--disable_info
+insert t1 values (1),(2),(3);
+flush tables;
+--enable_info
+delete from t1;                 -- delete_row
+--disable_info
+insert t1 values (1),(2),(3),(4);
+flush tables;
+select count(*) from t1;
+--enable_info
+delete from t1;                 -- delete_all_rows
+--disable_info
+insert t1 values (1),(2),(3),(4),(5);
+--enable_info
+truncate table t1;              -- truncate
+--disable_info
+drop table t1;
+

--- 1.21/sql/examples/ha_tina.cc	Mon Nov  7 23:12:32 2005
+++ 1.22/sql/examples/ha_tina.cc	Thu Nov 17 22:52:19 2005
@@ -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);
 }
 

--- 1.5/sql/examples/ha_tina.h	Tue Oct  4 03:41:51 2005
+++ 1.6/sql/examples/ha_tina.h	Thu Nov 17 22:52:19 2005
@@ -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);
Thread
bk commit into 5.0 tree (serg:1.1972) BUG#13406Sergei Golubchik17 Nov