Below is the list of changes that have just been committed into a local
5.1 repository of brian. When brian 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.2361 06/04/16 21:55:02 brian@zim.(none) +4 -0
Fixed a few pieces around support for data directory.
sql/ha_archive.h
1.43 06/04/16 21:54:57 brian@zim.(none) +4 -1
Added real_path to share (will come in handy in later code)
sql/ha_archive.cc
1.86 06/04/16 21:54:57 brian@zim.(none) +70 -19
Updated comments, added printable bits for support of "data directory"
mysql-test/t/archive.test
1.20 06/04/16 21:54:56 brian@zim.(none) +3 -0
Added test for "data directory" support in archive.
mysql-test/r/archive.result
1.20 06/04/16 21:54:56 brian@zim.(none) +7 -0
Adding test case for data directory support in create table.
# 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: brian
# Host: zim.(none)
# Root: /home/brian/mysql/archive-files
--- 1.19/mysql-test/r/archive.result 2006-02-22 01:09:46 -08:00
+++ 1.20/mysql-test/r/archive.result 2006-04-16 21:54:56 -07:00
@@ -13809,4 +13809,11 @@
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
i v
4 3r4f
+alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
+select * from t1;
+i v
+1 def
+2 abc
+4 3r4f
+5 lmn
drop table t1, t2, t4, t5;
--- 1.19/mysql-test/t/archive.test 2006-02-15 00:59:20 -08:00
+++ 1.20/mysql-test/t/archive.test 2006-04-16 21:54:56 -07:00
@@ -1486,6 +1486,9 @@
alter table t1 add unique key (i, v);
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
+alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
+select * from t1;
+
#
# Cleanup, test is over
#
--- 1.85/sql/ha_archive.cc 2006-03-29 03:27:30 -08:00
+++ 1.86/sql/ha_archive.cc 2006-04-16 21:54:57 -07:00
@@ -63,8 +63,7 @@
pool. For MyISAM its a question of how much the file system caches the
MyISAM file. With enough free memory MyISAM is faster. Its only when the OS
doesn't have enough memory to cache entire table that archive turns out
- to be any faster. For writes it is always a bit slower then MyISAM. It has no
- internal limits though for row length.
+ to be any faster.
Examples between MyISAM (packed) and Archive.
@@ -81,11 +80,8 @@
TODO:
Add bzip optional support.
Allow users to set compression level.
- Add truncate table command.
Implement versioning, should be easy.
Allow for errors, find a way to mark bad rows.
- Talk to the azip guys, come up with a writable format so that updates are doable
- without switching to a block method.
Add optional feature so that rows can be flushed at interval (which will cause less
compression but may speed up ordered searches).
Checkpoint the meta file to allow for faster rebuilds.
@@ -126,10 +122,12 @@
#define ARN ".ARN" // Files used during an optimize call
#define ARM ".ARM" // Meta file
/*
- uchar + uchar + ulonglong + ulonglong + ulonglong + ulonglong + uchar
+ uchar + uchar + ulonglong + ulonglong + ulonglong + ulonglong + FN_REFLEN
+ + uchar
*/
#define META_BUFFER_SIZE sizeof(uchar) + sizeof(uchar) + sizeof(ulonglong) \
- + sizeof(ulonglong) + sizeof(ulonglong) + sizeof(ulonglong) + sizeof(uchar)
+ + sizeof(ulonglong) + sizeof(ulonglong) + sizeof(ulonglong) + FN_REFLEN \
+ + sizeof(uchar)
/*
uchar + uchar
@@ -317,7 +315,8 @@
*/
int ha_archive::read_meta_file(File meta_file, ha_rows *rows,
ulonglong *auto_increment,
- ulonglong *forced_flushes)
+ ulonglong *forced_flushes,
+ char *real_path)
{
uchar meta_buffer[META_BUFFER_SIZE];
uchar *ptr= meta_buffer;
@@ -342,6 +341,8 @@
ptr+= sizeof(ulonglong); // Move past auto_increment
*forced_flushes= uint8korr(ptr);
ptr+= sizeof(ulonglong); // Move past forced_flush
+ memmove(real_path, ptr, FN_REFLEN);
+ ptr+= FN_REFLEN; // Move past the possible location of the file
DBUG_PRINT("ha_archive::read_meta_file", ("Check %d", (uint)meta_buffer[0]));
DBUG_PRINT("ha_archive::read_meta_file", ("Version %d", (uint)meta_buffer[1]));
@@ -349,6 +350,7 @@
DBUG_PRINT("ha_archive::read_meta_file", ("Checkpoint %llu", check_point));
DBUG_PRINT("ha_archive::read_meta_file", ("Auto-Increment %llu", *auto_increment));
DBUG_PRINT("ha_archive::read_meta_file", ("Forced Flushes %llu", *forced_flushes));
+ DBUG_PRINT("ha_archive::read_meta_file", ("Real Path %s", real_path));
DBUG_PRINT("ha_archive::read_meta_file", ("Dirty %d", (int)(*ptr)));
if ((meta_buffer[0] != (uchar)ARCHIVE_CHECK_HEADER) ||
@@ -368,6 +370,7 @@
int ha_archive::write_meta_file(File meta_file, ha_rows rows,
ulonglong auto_increment,
ulonglong forced_flushes,
+ char *real_path,
bool dirty)
{
uchar meta_buffer[META_BUFFER_SIZE];
@@ -388,6 +391,12 @@
ptr += sizeof(ulonglong);
int8store(ptr, forced_flushes);
ptr += sizeof(ulonglong);
+ // No matter what, we pad with nulls
+ if (real_path)
+ strncpy((char *)ptr, real_path, FN_REFLEN);
+ else
+ bzero(ptr, FN_REFLEN);
+ ptr += FN_REFLEN;
*ptr= (uchar)dirty;
DBUG_PRINT("ha_archive::write_meta_file", ("Check %d",
(uint)ARCHIVE_CHECK_HEADER));
@@ -399,6 +408,8 @@
auto_increment));
DBUG_PRINT("ha_archive::write_meta_file", ("Forced Flushes %llu",
forced_flushes));
+ DBUG_PRINT("ha_archive::write_meta_file", ("Real path %s",
+ real_path));
DBUG_PRINT("ha_archive::write_meta_file", ("Dirty %d", (uint)dirty));
VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0)));
@@ -448,8 +459,12 @@
share->table_name_length= length;
share->table_name= tmp_name;
share->crashed= FALSE;
- fn_format(share->data_file_name,table_name,"",ARZ,MY_REPLACE_EXT|MY_UNPACK_FILENAME);
- fn_format(meta_file_name,table_name,"",ARM,MY_REPLACE_EXT|MY_UNPACK_FILENAME);
+ fn_format(share->data_file_name, table_name, "",
+ ARZ,MY_REPLACE_EXT|MY_UNPACK_FILENAME);
+ fn_format(meta_file_name, table_name, "", ARM,
+ MY_REPLACE_EXT|MY_UNPACK_FILENAME);
+ DBUG_PRINT("info", ("archive opening (1) up write at %s",
+ share->data_file_name));
strmov(share->table_name,table_name);
/*
We will use this lock for rows.
@@ -457,6 +472,8 @@
VOID(pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST));
if ((share->meta_file= my_open(meta_file_name, O_RDWR, MYF(0))) == -1)
share->crashed= TRUE;
+ DBUG_PRINT("info", ("archive opening (1) up write at %s",
+ share->data_file_name));
/*
After we read, we set the file to dirty. When we close, we will do the
@@ -465,13 +482,21 @@
*/
if (read_meta_file(share->meta_file, &share->rows_recorded,
&share->auto_increment_value,
- &share->forced_flushes))
+ &share->forced_flushes,
+ share->real_path))
share->crashed= TRUE;
else
(void)write_meta_file(share->meta_file, share->rows_recorded,
share->auto_increment_value,
share->forced_flushes,
+ share->real_path,
TRUE);
+ /*
+ Since we now possibly no real_path, we will use it instead if it exists.
+ */
+ if (*share->real_path)
+ fn_format(share->data_file_name, share->real_path, "", ARZ,
+ MY_REPLACE_EXT|MY_UNPACK_FILENAME);
/*
It is expensive to open and close the data files and since you can't have
a gzip file that can be both read and written we keep a writer open
@@ -527,6 +552,7 @@
(void)write_meta_file(share->meta_file, share->rows_recorded,
share->auto_increment_value,
share->forced_flushes,
+ share->real_path,
share->crashed ? TRUE :FALSE);
if (azclose(&(share->archive_write)))
rc= 1;
@@ -566,7 +592,7 @@
int rc= 0;
DBUG_ENTER("ha_archive::open");
- DBUG_PRINT("info", ("archive table was opened for crash %s",
+ DBUG_PRINT("info", ("archive table was opened for crash: %s",
(open_options & HA_OPEN_FOR_REPAIR) ? "yes" : "no"));
share= get_share(name, table, &rc);
@@ -582,6 +608,7 @@
thr_lock_data_init(&share->lock,&lock,NULL);
+ DBUG_PRINT("info", ("archive data_file_name %s", share->data_file_name));
if (!(azopen(&archive, share->data_file_name, O_RDONLY|O_BINARY)))
{
if (errno == EROFS || errno == EACCES)
@@ -679,18 +706,40 @@
}
}
- write_meta_file(create_file, 0, auto_increment_value, 0, FALSE);
+ write_meta_file(create_file, 0, auto_increment_value, 0,
+ (char *)create_info->data_file_name,
+ FALSE);
my_close(create_file,MYF(0));
/*
We reuse name_buff since it is available.
*/
- if ((create_file= my_create(fn_format(name_buff,name,"",ARZ,
- MY_REPLACE_EXT|MY_UNPACK_FILENAME),0,
- O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
+ if (create_info->data_file_name)
{
- error= my_errno;
- goto error;
+ char linkname[FN_REFLEN];
+ DBUG_PRINT("info", ("archive will create stream file %s",
+ create_info->data_file_name));
+
+ fn_format(name_buff, create_info->data_file_name, "", ARZ,
+ MY_REPLACE_EXT|MY_UNPACK_FILENAME);
+ fn_format(linkname, name, "", ARZ,
+ MY_UNPACK_FILENAME | MY_APPEND_EXT);
+ if ((create_file= my_create_with_symlink(linkname, name_buff, 0,
+ O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
+ {
+ error= my_errno;
+ goto error;
+ }
+ }
+ else
+ {
+ if ((create_file= my_create(fn_format(name_buff, name,"", ARZ,
+ MY_REPLACE_EXT|MY_UNPACK_FILENAME),0,
+ O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
+ {
+ error= my_errno;
+ goto error;
+ }
}
if (!azdopen(&archive, create_file, O_WRONLY|O_BINARY))
{
@@ -1348,8 +1397,10 @@
ha_archive::info(HA_STATUS_AUTO | HA_STATUS_CONST);
if (!(create_info->used_fields & HA_CREATE_USED_AUTO))
{
- create_info->auto_increment_value=auto_increment_value;
+ create_info->auto_increment_value= auto_increment_value;
}
+ if (*share->real_path)
+ create_info->data_file_name= share->real_path;
}
--- 1.42/sql/ha_archive.h 2006-02-15 00:59:20 -08:00
+++ 1.43/sql/ha_archive.h 2006-04-16 21:54:57 -07:00
@@ -41,6 +41,7 @@
ulonglong auto_increment_value;
ulonglong forced_flushes;
ulonglong mean_rec_length;
+ char real_path[FN_REFLEN];
} ARCHIVE_SHARE;
/*
@@ -102,10 +103,12 @@
int get_row(azio_stream *file_to_read, byte *buf);
int read_meta_file(File meta_file, ha_rows *rows,
ulonglong *auto_increment,
- ulonglong *forced_flushes);
+ ulonglong *forced_flushes,
+ char *real_path);
int write_meta_file(File meta_file, ha_rows rows,
ulonglong auto_increment,
ulonglong forced_flushes,
+ char *real_path,
bool dirty);
ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table, int *rc);
int free_share(ARCHIVE_SHARE *share);
| Thread |
|---|
| • bk commit into 5.1 tree (brian:1.2361) | Brian Aker | 17 Apr |