summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2007-07-10 13:09:07 +0500
committerunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2007-07-10 13:09:07 +0500
commit29ca25a675aafb46ad0decd19e7ab82ead72402b (patch)
tree630e37500148b29a4c01be4eeb192c14747fc117
parenteb40ffbc66172c01b97b239b4c9c6acc55a43df5 (diff)
downloadmariadb-git-29ca25a675aafb46ad0decd19e7ab82ead72402b.tar.gz
Fix for bug #29652: csv.test failure: two changes conflict after merge
Problem: we don't take into account the length of the data written to the temporary data file during update on a CSV table. Fix: properly calculate the data file length during update. mysql-test/r/csv.result: Fix for bug #29652: csv.test failure: two changes conflict after merge - test result adjusted. storage/csv/ha_tina.cc: Fix for bug #29652: csv.test failure: two changes conflict after merge - adjust local_saved_data_file_length in case of update as well. storage/csv/ha_tina.h: Fix for bug #29652: csv.test failure: two changes conflict after merge - adjust local_saved_data_file_length in case of update as well.
-rw-r--r--mysql-test/r/csv.result2
-rw-r--r--storage/csv/ha_tina.cc15
-rw-r--r--storage/csv/ha_tina.h1
3 files changed, 16 insertions, 2 deletions
diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result
index 65677e75ceb..86ba5002af8 100644
--- a/mysql-test/r/csv.result
+++ b/mysql-test/r/csv.result
@@ -4945,6 +4945,8 @@ SELECT * FROM bug13894;
val
6
6
+5
+11
DROP TABLE bug13894;
DROP TABLE IF EXISTS bug14672;
CREATE TABLE bug14672 (c1 integer) engine = CSV;
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index 8b0359fdc21..07bd28f8e65 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -904,6 +904,7 @@ int ha_tina::open_update_temp_file_if_needed()
0, O_RDWR | O_TRUNC, MYF(MY_WME))) < 0)
return 1;
share->update_file_opened= TRUE;
+ temp_file_length= 0;
}
return 0;
}
@@ -928,6 +929,13 @@ int ha_tina::update_row(const uchar * old_data, uchar * new_data)
size= encode_quote(new_data);
+ /*
+ During update we mark each updating record as deleted
+ (see the chain_append()) then write new one to the temporary data file.
+ At the end of the sequence in the rnd_end() we append all non-marked
+ records from the data file to the temporary data file then rename it.
+ The temp_file_length is used to calculate new data file length.
+ */
if (chain_append())
DBUG_RETURN(-1);
@@ -937,6 +945,7 @@ int ha_tina::update_row(const uchar * old_data, uchar * new_data)
if (my_write(update_temp_file, (uchar*)buffer.ptr(), size,
MYF(MY_WME | MY_NABP)))
DBUG_RETURN(-1);
+ temp_file_length+= size;
/* UPDATE should never happen on the log tables */
DBUG_ASSERT(!share->is_log_table);
@@ -1154,7 +1163,6 @@ int ha_tina::rnd_end()
if ((chain_ptr - chain) > 0)
{
- off_t temp_file_length= 0;
tina_set *ptr= chain;
/*
@@ -1244,7 +1252,10 @@ int ha_tina::rnd_end()
Here we record this fact to the meta-file.
*/
(void)write_meta_file(share->meta_file, share->rows_recorded, FALSE);
-
+ /*
+ Update local_saved_data_file_length with the real length of the
+ data file.
+ */
local_saved_data_file_length= temp_file_length;
}
diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h
index 8d2c6855b84..2e43f1a2307 100644
--- a/storage/csv/ha_tina.h
+++ b/storage/csv/ha_tina.h
@@ -63,6 +63,7 @@ class ha_tina: public handler
off_t current_position; /* Current position in the file during a file scan */
off_t next_position; /* Next position in the file scan */
off_t local_saved_data_file_length; /* save position for reads */
+ off_t temp_file_length;
uchar byte_buffer[IO_SIZE];
Transparent_file *file_buff;
File data_file; /* File handler for readers */