summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorunknown <msvensson@shellback.(none)>2006-04-04 10:00:27 +0200
committerunknown <msvensson@shellback.(none)>2006-04-04 10:00:27 +0200
commit3e2cf7664060a7dd1ef9157e26370b44f81b7bd6 (patch)
treeb6db1bd1fe52a371605e9680a273a9183ed927ba /storage
parent90c926d99af7b82e4e32eca26f7733d3a5233006 (diff)
parent89c8b298f0ae707a186b988dd079488f812adae0 (diff)
downloadmariadb-git-3e2cf7664060a7dd1ef9157e26370b44f81b7bd6.tar.gz
Merge shellback.(none):/home/msvensson/mysql/mysql-5.1
into shellback.(none):/home/msvensson/mysql/bug17368/my51-bug17368
Diffstat (limited to 'storage')
-rw-r--r--storage/csv/ha_tina.cc31
-rw-r--r--storage/csv/ha_tina.h6
2 files changed, 23 insertions, 14 deletions
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index 066a3011381..fed9394e91e 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -49,7 +49,6 @@ TODO:
#include "mysql_priv.h"
#include "ha_tina.h"
-#include <sys/mman.h>
#include <mysql/plugin.h>
@@ -143,7 +142,7 @@ int get_mmap(TINA_SHARE *share, int write)
share->mapped_file= (byte *)my_mmap(NULL, share->file_stat.st_size,
PROT_READ, MAP_PRIVATE,
share->data_file, 0);
- if ((share->mapped_file ==(caddr_t)-1))
+ if ((share->mapped_file == MAP_FAILED))
{
/*
Bad idea you think? See the problem is that nothing actually checks
@@ -331,7 +330,7 @@ ha_tina::ha_tina(TABLE_SHARE *table_arg)
records_is_known(0)
{
/* Set our original buffers from pre-allocated memory */
- buffer.set(byte_buffer, IO_SIZE, system_charset_info);
+ buffer.set((char*)byte_buffer, IO_SIZE, system_charset_info);
chain= chain_buffer;
}
@@ -688,7 +687,8 @@ int ha_tina::write_row(byte * buf)
size= encode_quote(buf);
- if (my_write(share->data_file, buffer.ptr(), size, MYF(MY_WME | MY_NABP)))
+ if (my_write(share->data_file, (byte*)buffer.ptr(), size,
+ MYF(MY_WME | MY_NABP)))
DBUG_RETURN(-1);
/*
@@ -740,7 +740,8 @@ int ha_tina::update_row(const byte * old_data, byte * new_data)
if (chain_append())
DBUG_RETURN(-1);
- if (my_write(share->data_file, buffer.ptr(), size, MYF(MY_WME | MY_NABP)))
+ if (my_write(share->data_file, (byte*)buffer.ptr(), size,
+ MYF(MY_WME | MY_NABP)))
DBUG_RETURN(-1);
/* UPDATE should never happen on the log tables */
@@ -934,7 +935,7 @@ int ha_tina::rnd_end()
if ((chain_ptr - chain) > 0)
{
tina_set *ptr;
- off_t length;
+ size_t length;
/*
Setting up writable map, this will contain all of the data after the
@@ -958,15 +959,16 @@ int ha_tina::rnd_end()
length= length - (size_t)(ptr->end - ptr->begin);
}
- /* Truncate the file to the new size */
- if (my_chsize(share->data_file, length, 0, MYF(MY_WME)))
+ /* Unmap the file before the new size is set */
+ if (my_munmap(share->mapped_file, share->file_stat.st_size))
DBUG_RETURN(-1);
+ /* We set it to null so that get_mmap() won't try to unmap it */
+ share->mapped_file= NULL;
- if (my_munmap(share->mapped_file, length))
+ /* Set the file to the new size */
+ if (my_chsize(share->data_file, length, 0, MYF(MY_WME)))
DBUG_RETURN(-1);
- /* We set it to null so that get_mmap() won't try to unmap it */
- share->mapped_file= NULL;
if (get_mmap(share, 0) > 0)
DBUG_RETURN(-1);
}
@@ -986,6 +988,13 @@ int ha_tina::delete_all_rows()
if (!records_is_known)
return (my_errno=HA_ERR_WRONG_COMMAND);
+ /* Unmap the file before the new size is set */
+ if (share->mapped_file && my_munmap(share->mapped_file,
+ share->file_stat.st_size))
+ DBUG_RETURN(-1);
+ share->mapped_file= NULL;
+
+ /* Truncate the file to zero size */
int rc= my_chsize(share->data_file, 0, 0, MYF(MY_WME));
if (get_mmap(share, 0) > 0)
diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h
index 572d05cb779..dc743cf6514 100644
--- a/storage/csv/ha_tina.h
+++ b/storage/csv/ha_tina.h
@@ -41,9 +41,9 @@ typedef struct st_tina_share {
THR_LOCK lock;
} TINA_SHARE;
-typedef struct tina_set {
- off_t begin;
- off_t end;
+struct tina_set {
+ off_t begin;
+ off_t end;
};
class ha_tina: public handler