summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMagne Mahre <magne.mahre@sun.com>2009-11-25 20:19:59 +0100
committerMagne Mahre <magne.mahre@sun.com>2009-11-25 20:19:59 +0100
commit6002c1adeb6a2cd8edb0fa0045aa74a393712dd4 (patch)
tree3838701c91d89f6d3942217ed3106be6ac3563c1 /storage
parent412c6c4bd7b6b21fc1ccdf25b0d69daa2ebbfcc5 (diff)
downloadmariadb-git-6002c1adeb6a2cd8edb0fa0045aa74a393712dd4.tar.gz
Fix for Bug#36573 myisampack --join does not create destination
table .frm file Problem: ======== Myisampack --join did not create the destination table .frm file. The user had to copy one of the source table .frm file as destination .frm file for mysql server to recognize. This is just 'user-friendliness' issue. How it was solved ================= After successful join and compression we copy the frm file from the first source table. Functionality added =================== myisampack --join=/path/t3 /path/t1 /path/t2 creates /path/t3.frm (which is bascially copied from first table's frm /path/t1) Tests ===== Modified myisampack.test to test two scenario's 1. Positive myisampack --join test In this case after the join operation is done,we test if the destination table is accessible from the server 2. Positive myisampack --join test with an existing .frm file. We test the above case with an existing .frm file for the destination table. It should return success even in this case. 3. Positive myisampack --join test with no .frm file for source tables We test the join operation with no .frm files for source tables. It should complete the join operation without any warnings and error messages 4. Negative myisampack --join test We test myisampack --join with existing .MYI,.MDI,.frm files for the destination table. It should fail with exit status 2 in this case.
Diffstat (limited to 'storage')
-rw-r--r--storage/myisam/myisampack.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c
index 8adfcfd6fb2..7cd84b642e4 100644
--- a/storage/myisam/myisampack.c
+++ b/storage/myisam/myisampack.c
@@ -44,6 +44,7 @@
#define DATA_TMP_EXT ".TMD"
#define OLD_EXT ".OLD"
+#define FRM_EXT ".frm"
#define WRITE_COUNT MY_HOW_OFTEN_TO_WRITE
struct st_file_buffer {
@@ -125,6 +126,7 @@ static void get_options(int *argc,char ***argv);
static MI_INFO *open_isam_file(char *name,int mode);
static my_bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count);
static int compress(PACK_MRG_INFO *file,char *join_name);
+static int create_dest_frm(char *source_table, char *dest_table);
static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records);
static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees,
uint trees,
@@ -214,9 +216,13 @@ int main(int argc, char **argv)
error=ok=isamchk_neaded=0;
if (join_table)
- { /* Join files into one */
+ {
+ /*
+ Join files into one and create FRM file for the compressed table only if
+ the compression succeeds
+ */
if (open_isam_files(&merge,argv,(uint) argc) ||
- compress(&merge,join_table))
+ compress(&merge, join_table) || create_dest_frm(argv[0], join_table))
error=1;
}
else while (argc--)
@@ -757,6 +763,45 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
DBUG_RETURN(-1);
}
+
+/**
+ Create FRM for the destination table for --join operation
+ Copy the first table FRM as the destination table FRM file. Doing so
+ will help the mysql server to recognize the newly created table.
+ See Bug#36573.
+
+ @param source_table Name of the source table
+ @param dest_table Name of the destination table
+ @retval 0 Successful copy operation
+
+ @note We always return 0 because we don't want myisampack to report error
+ even if the copy operation fails.
+*/
+
+static int create_dest_frm(char *source_table, char *dest_table)
+{
+ char source_name[FN_REFLEN], dest_name[FN_REFLEN];
+ int error;
+
+ DBUG_ENTER("create_dest_frm");
+
+ (void) fn_format(source_name, source_table,
+ "", FRM_EXT, MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS);
+ (void) fn_format(dest_name, dest_table,
+ "", FRM_EXT, MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS);
+ /*
+ Error messages produced by my_copy() are suppressed as this
+ is not vital for --join operation. User shouldn't see any error messages
+ like "source file frm not found" and "unable to create destination frm
+ file. So we don't pass the flag MY_WME -Write Message on Error to
+ my_copy()
+ */
+ (void) my_copy(source_name, dest_name, MYF(MY_DONT_OVERWRITE_FILE));
+
+ return 0;
+}
+
+
/* Init a huff_count-struct for each field and init it */
static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records)