Commit 2b521320 authored by Michael Widenius's avatar Michael Widenius

Added ha_maria::is_changed() (needed for Query cache)


storage/maria/ha_maria.cc:
  Added ha_maria::is_changed()
storage/maria/ha_maria.h:
  Added ha_maria::is_changed()
storage/maria/ma_delete.c:
  Mark that table changed
storage/maria/ma_open.c:
  Ensure that info->state->changed is always reset from thr_lock()
storage/maria/ma_state.c:
  Reset handler->state->changed at first usage of transactional table
  Reset handler->state->changed when taking lock for not transactional table
storage/maria/ma_state.h:
  Added variable and function to track changes of table
storage/maria/ma_update.c:
  Mark that table changed
storage/maria/ma_write.c:
  Mark that table changed
parent ca4d512a
...@@ -3074,6 +3074,16 @@ static int mark_recovery_success(void) ...@@ -3074,6 +3074,16 @@ static int mark_recovery_success(void)
} }
/*
Return 1 if table has changed during the current transaction
*/
bool ha_maria::is_changed() const
{
return file->state->changed;
}
static int ha_maria_init(void *p) static int ha_maria_init(void *p)
{ {
int res; int res;
......
...@@ -139,6 +139,7 @@ public: ...@@ -139,6 +139,7 @@ public:
int repair(THD * thd, HA_CHECK_OPT * check_opt); int repair(THD * thd, HA_CHECK_OPT * check_opt);
bool check_and_repair(THD * thd); bool check_and_repair(THD * thd);
bool is_crashed() const; bool is_crashed() const;
bool is_changed() const;
bool auto_repair() const { return 1; } bool auto_repair() const { return 1; }
int optimize(THD * thd, HA_CHECK_OPT * check_opt); int optimize(THD * thd, HA_CHECK_OPT * check_opt);
int restore(THD * thd, HA_CHECK_OPT * check_opt); int restore(THD * thd, HA_CHECK_OPT * check_opt);
......
...@@ -116,6 +116,7 @@ int maria_delete(MARIA_HA *info,const uchar *record) ...@@ -116,6 +116,7 @@ int maria_delete(MARIA_HA *info,const uchar *record)
info->update= HA_STATE_CHANGED+HA_STATE_DELETED+HA_STATE_ROW_CHANGED; info->update= HA_STATE_CHANGED+HA_STATE_DELETED+HA_STATE_ROW_CHANGED;
share->state.changed|= (STATE_NOT_OPTIMIZED_ROWS | STATE_NOT_MOVABLE | share->state.changed|= (STATE_NOT_OPTIMIZED_ROWS | STATE_NOT_MOVABLE |
STATE_NOT_ZEROFILLED); STATE_NOT_ZEROFILLED);
info->state->changed=1;
mi_sizestore(lastpos, info->cur_row.lastpos); mi_sizestore(lastpos, info->cur_row.lastpos);
VOID(_ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE)); VOID(_ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
......
...@@ -824,6 +824,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -824,6 +824,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
VOID(my_rwlock_init(&share->mmap_lock, NULL)); VOID(my_rwlock_init(&share->mmap_lock, NULL));
share->row_is_visible= _ma_row_visible_always; share->row_is_visible= _ma_row_visible_always;
share->lock.get_status= _ma_reset_update_flag;
if (!thr_lock_inited) if (!thr_lock_inited)
{ {
/* Probably a single threaded program; Don't use concurrent inserts */ /* Probably a single threaded program; Don't use concurrent inserts */
......
...@@ -96,6 +96,8 @@ my_bool _ma_setup_live_state(MARIA_HA *info) ...@@ -96,6 +96,8 @@ my_bool _ma_setup_live_state(MARIA_HA *info)
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
/* The current item can't be deleted as it's the first one visible for us */ /* The current item can't be deleted as it's the first one visible for us */
tables->state_start= tables->state_current= history->state; tables->state_start= tables->state_current= history->state;
tables->state_current.changed= 0;
DBUG_PRINT("info", ("records: %ld", (ulong) tables->state_start.records)); DBUG_PRINT("info", ("records: %ld", (ulong) tables->state_start.records));
end: end:
...@@ -262,6 +264,7 @@ void _ma_get_status(void* param, my_bool concurrent_insert) ...@@ -262,6 +264,7 @@ void _ma_get_status(void* param, my_bool concurrent_insert)
#endif #endif
info->state_save= info->s->state.state; info->state_save= info->s->state.state;
info->state= &info->state_save; info->state= &info->state_save;
info->state->changed= 0;
info->append_insert_at_end= concurrent_insert; info->append_insert_at_end= concurrent_insert;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -315,6 +318,13 @@ void _ma_copy_status(void* to, void *from) ...@@ -315,6 +318,13 @@ void _ma_copy_status(void* to, void *from)
} }
void _ma_reset_update_flag(void *param)
{
MARIA_HA *info=(MARIA_HA*) param;
info->state->changed= 0;
}
/** /**
@brief Check if should allow concurrent inserts @brief Check if should allow concurrent inserts
......
...@@ -24,6 +24,7 @@ typedef struct st_maria_status_info ...@@ -24,6 +24,7 @@ typedef struct st_maria_status_info
my_off_t key_file_length; my_off_t key_file_length;
my_off_t data_file_length; my_off_t data_file_length;
ha_checksum checksum; ha_checksum checksum;
my_bool changed;
} MARIA_STATUS_INFO; } MARIA_STATUS_INFO;
...@@ -62,6 +63,7 @@ void _ma_get_status(void* param, my_bool concurrent_insert); ...@@ -62,6 +63,7 @@ void _ma_get_status(void* param, my_bool concurrent_insert);
void _ma_update_status(void* param); void _ma_update_status(void* param);
void _ma_restore_status(void *param); void _ma_restore_status(void *param);
void _ma_copy_status(void* to, void *from); void _ma_copy_status(void* to, void *from);
void _ma_reset_update_flag(void *param);
my_bool _ma_check_status(void *param); my_bool _ma_check_status(void *param);
void _ma_block_get_status(void* param, my_bool concurrent_insert); void _ma_block_get_status(void* param, my_bool concurrent_insert);
void _ma_block_update_status(void *param); void _ma_block_update_status(void *param);
......
...@@ -173,6 +173,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec) ...@@ -173,6 +173,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
*/ */
info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED | key_changed); info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED | key_changed);
share->state.changed|= STATE_NOT_MOVABLE | STATE_NOT_ZEROFILLED; share->state.changed|= STATE_NOT_MOVABLE | STATE_NOT_ZEROFILLED;
info->state->changed= 1;
/* /*
Every Maria function that updates Maria table must end with Every Maria function that updates Maria table must end with
......
...@@ -289,6 +289,7 @@ int maria_write(MARIA_HA *info, uchar *record) ...@@ -289,6 +289,7 @@ int maria_write(MARIA_HA *info, uchar *record)
info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN | info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN |
HA_STATE_ROW_CHANGED); HA_STATE_ROW_CHANGED);
share->state.changed|= STATE_NOT_MOVABLE | STATE_NOT_ZEROFILLED; share->state.changed|= STATE_NOT_MOVABLE | STATE_NOT_ZEROFILLED;
info->state->changed= 1;
info->cur_row.lastpos= filepos; info->cur_row.lastpos= filepos;
VOID(_ma_writeinfo(info, WRITEINFO_UPDATE_KEYFILE)); VOID(_ma_writeinfo(info, WRITEINFO_UPDATE_KEYFILE));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment