summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatya B <satya.bn@sun.com>2009-09-03 16:02:03 +0530
committerSatya B <satya.bn@sun.com>2009-09-03 16:02:03 +0530
commit4a9e7e8e25192fda25a71bbb4d7f9b5b6088e0c6 (patch)
treebc7f9709d4619c3b3db77c9ad3c177844a34ce4b
parentdb8471aa857e911bd7f20b5c67161cd3274f6974 (diff)
downloadmariadb-git-4a9e7e8e25192fda25a71bbb4d7f9b5b6088e0c6.tar.gz
Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled for
CREATE TABLE...LIKE... The mysql server option 'sync_frm' is ignored when table is created with syntax CREATE TABLE .. LIKE.. Fixed by adding the MY_SYNC flag and calling my_sync() from my_copy() when the flag is set. In mysql_create_table(), when the 'sync_frm' is set, MY_SYNC flag is passed to my_copy(). Note: TestCase is not attached and can be tested manually using debugger.
-rw-r--r--client/Makefile.am1
-rw-r--r--include/my_sys.h1
-rw-r--r--mysys/my_copy.c7
-rw-r--r--sql/sql_table.cc7
4 files changed, 15 insertions, 1 deletions
diff --git a/client/Makefile.am b/client/Makefile.am
index e77d294b0ac..192b89f8a2c 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -35,6 +35,7 @@ mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) $(CXXLDFLAGS)
mysqltest_SOURCES= mysqltest.c \
$(top_srcdir)/mysys/my_getsystime.c \
$(top_srcdir)/mysys/my_copy.c \
+ $(top_srcdir)/mysys/my_sync.c \
$(top_srcdir)/mysys/my_mkdir.c
mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD)
diff --git a/include/my_sys.h b/include/my_sys.h
index 4254ec3dbcb..4ec4846f528 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -68,6 +68,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */
#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */
#define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */
+#define MY_SYNC 4096 /* my_copy(): sync dst file */
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
#define MY_GIVE_INFO 2 /* Give time info about process*/
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index b6bb925e898..f44a497fbc8 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -87,6 +87,13 @@ int my_copy(const char *from, const char *to, myf MyFlags)
my_write(to_file,buff,Count,MYF(MyFlags | MY_NABP)))
goto err;
+ /* sync the destination file */
+ if (MyFlags & MY_SYNC)
+ {
+ if (my_sync(to_file, MyFlags))
+ goto err;
+ }
+
if (my_close(from_file,MyFlags) | my_close(to_file,MyFlags))
DBUG_RETURN(-1); /* Error on close */
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 84370873054..5a3100685e0 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2773,6 +2773,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST *src_table,
int err;
bool res= TRUE;
db_type not_used;
+ myf flags= MY_DONT_OVERWRITE_FILE;
DBUG_ENTER("mysql_create_like_table");
/*
@@ -2859,10 +2860,14 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST *src_table,
DBUG_EXECUTE_IF("sleep_create_like_before_copy", my_sleep(6000000););
+ if (opt_sync_frm && !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
+ flags|= MY_SYNC;
+
/*
Create a new table by copying from source table
+ and sync the new table if the flag MY_SYNC is set
*/
- if (my_copy(src_path, dst_path, MYF(MY_DONT_OVERWRITE_FILE)))
+ if (my_copy(src_path, dst_path, flags))
{
if (my_errno == ENOENT)
my_error(ER_BAD_DB_ERROR,MYF(0),db);