From 81b70f979804cc91f2d11750a694ca414806b947 Mon Sep 17 00:00:00 2001 From: "svoj@may.pils.ru" <> Date: Wed, 9 Aug 2006 14:28:39 +0500 Subject: [PATCH] BUG#20060 - mysqld option "--flush " doesn't work for update statement Problem described in this bug report affects MyISAM tables only. Running mysqld --flush instructs mysqld to sync all changes to disk after each SQL statement. It worked well for INSERT and DELETE statements, but it did sync for UPDATE only in case if there was index change (change of colum that has an index). If no updated column has an index, data wasn't synced to disk. This fix makes UPDATE statement to sync data to disk even if there is no index change (that is only data change) and mysqld is run with --flush option. --- myisam/mi_update.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/myisam/mi_update.c b/myisam/mi_update.c index 672c8407353..00eee18bfab 100644 --- a/myisam/mi_update.c +++ b/myisam/mi_update.c @@ -168,7 +168,17 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec) info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED | HA_STATE_AKTIV | key_changed); myisam_log_record(MI_LOG_UPDATE,info,newrec,info->lastpos,0); - VOID(_mi_writeinfo(info,key_changed ? WRITEINFO_UPDATE_KEYFILE : 0)); + /* + Every myisam function that updates myisam table must end with + call to _mi_writeinfo(). If operation (second param of + _mi_writeinfo()) is not 0 it sets share->changed to 1, that is + flags that data has changed. If operation is 0, this function + equals to no-op in this case. + + mi_update() must always pass !0 value as operation, since even if + there is no index change there could be data change. + */ + VOID(_mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE)); allow_break(); /* Allow SIGHUP & SIGINT */ if (info->invalidator != 0) {