12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
17
locking of isam-tables.
82
84
if ((info->s->mmaped_length != info->s->state.state.data_file_length) &&
83
85
(info->s->nonmmaped_inserts > MAX_NONMAPPED_INSERTS))
87
if (info->s->concurrent_insert)
88
pthread_rwlock_wrlock(&info->s->mmap_lock);
85
89
mi_remap_file(info, info->s->state.state.data_file_length);
86
90
info->s->nonmmaped_inserts= 0;
91
if (info->s->concurrent_insert)
92
pthread_rwlock_unlock(&info->s->mmap_lock);
88
94
share->state.process= share->last_process=share->this_process;
89
95
share->state.unique= info->last_unique= info->this_unique;
219
226
/****************************************************************************
227
The following functions are called by thr_lock() in threaded applications
228
****************************************************************************/
231
Create a copy of the current status for the table
235
param Pointer to Myisam handler
236
concurrent_insert Set to 1 if we are going to do concurrent inserts
237
(THR_WRITE_CONCURRENT_INSERT was used)
240
void mi_get_status(void* param, int concurrent_insert)
242
MI_INFO *info=(MI_INFO*) param;
244
info->save_state=info->s->state.state;
245
info->state= &info->save_state;
246
info->append_insert_at_end= concurrent_insert;
251
void mi_update_status(void* param)
253
MI_INFO *info=(MI_INFO*) param;
255
Because someone may have closed the table we point at, we only
256
update the state if its our own state. This isn't a problem as
257
we are always pointing at our own lock or at a read lock.
258
(This is enforced by thr_multi_lock.c)
260
if (info->state == &info->save_state)
262
info->s->state.state= *info->state;
263
info->state= &info->s->state.state;
265
info->append_insert_at_end= 0;
268
We have to flush the write cache here as other threads may start
269
reading the table before mi_lock_database() is called
271
if (info->opt_flag & WRITE_CACHE_USED)
273
if (end_io_cache(&info->rec_cache))
275
mi_print_error(info->s, HA_ERR_CRASHED);
276
mi_mark_crashed(info);
278
info->opt_flag&= ~WRITE_CACHE_USED;
283
void mi_restore_status(void *param)
285
MI_INFO *info= (MI_INFO*) param;
286
info->state= &info->s->state.state;
287
info->append_insert_at_end= 0;
291
void mi_copy_status(void* to,void *from)
293
((MI_INFO*) to)->state= &((MI_INFO*) from)->save_state;
298
Check if should allow concurrent inserts
301
Allow concurrent inserts if we don't have a hole in the table or
302
if there is no active write lock and there is active read locks and
303
myisam_concurrent_insert == 2. In this last case the new
304
row('s) are inserted at end of file instead of filling up the hole.
306
The last case is to allow one to inserts into a heavily read-used table
307
even if there is holes.
310
If there is a an rtree indexes in the table, concurrent inserts are
311
disabled in mi_open()
314
0 ok to use concurrent inserts
318
bool mi_check_status(void *param)
320
MI_INFO *info=(MI_INFO*) param;
322
The test for w_locks == 1 is here because this thread has already done an
323
external lock (in other words: w_locks == 1 means no other threads has
326
return (bool) !(info->s->state.dellink == HA_OFFSET_ERROR ||
327
(myisam_concurrent_insert == 2 && info->s->r_locks &&
328
info->s->w_locks == 1));
332
/****************************************************************************
220
333
** functions to read / write the state
221
334
****************************************************************************/
287
400
share->state.update_count != info->last_loop)
288
401
{ /* Keyfile has changed */
289
402
if (share->state.process != share->this_process)
290
flush_key_blocks(share->getKeyCache(), share->kfile, FLUSH_RELEASE);
403
flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE);
291
404
share->last_process=share->state.process;
292
405
info->last_unique= share->state.unique;
293
406
info->last_loop= share->state.update_count;