summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-04-05 16:28:16 +0300
committerunknown <monty@mysql.com>2004-04-05 16:28:16 +0300
commit9d0166363eaaccdf79961c4320590c2d5040e7bb (patch)
tree2c8ec348c331cb6321acc9ec80f6b07df0a8d51e /myisam
parent73d0a99142e8459d3e9207a5bc57b9eb5c921970 (diff)
parent7873b89fc50d420a5f538a5b60faf79131f86c4f (diff)
downloadmariadb-git-9d0166363eaaccdf79961c4320590c2d5040e7bb.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/my/mysql-4.1 sql/field.cc: Auto merged sql/field.h: Auto merged sql/ha_innodb.cc: Auto merged sql/item.cc: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged
Diffstat (limited to 'myisam')
-rw-r--r--myisam/mi_locking.c15
-rw-r--r--myisam/mi_rnext.c64
-rw-r--r--myisam/mi_rprev.c23
3 files changed, 58 insertions, 44 deletions
diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c
index 816748d459a..b13ebfb4cad 100644
--- a/myisam/mi_locking.c
+++ b/myisam/mi_locking.c
@@ -286,6 +286,21 @@ void mi_copy_status(void* to,void *from)
((MI_INFO*) to)->state= &((MI_INFO*) from)->save_state;
}
+
+/*
+ Check if should allow concurrent inserts
+
+ IMPLEMENTATION
+ Don't allow concurrent inserts if we have a hole in the table.
+
+ NOTES
+ Rtree indexes are disabled in mi_open()
+
+ RETURN
+ 0 ok to use concurrent inserts
+ 1 not ok
+*/
+
my_bool mi_check_status(void* param)
{
MI_INFO *info=(MI_INFO*) param;
diff --git a/myisam/mi_rnext.c b/myisam/mi_rnext.c
index e1cf916d6d9..6e6056f98d9 100644
--- a/myisam/mi_rnext.c
+++ b/myisam/mi_rnext.c
@@ -57,47 +57,45 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx)
}
else
{
- switch(info->s->keyinfo[inx].key_alg)
- {
- case HA_KEY_ALG_RTREE:
+ switch (info->s->keyinfo[inx].key_alg) {
+ case HA_KEY_ALG_RTREE:
/*
- Note that rtree doesn't support that the table
- may be changed since last call, so we do need
- to skip rows inserted by other threads like in btree
+ Note that rtree doesn't support that the table
+ may be changed since last call, so we do need
+ to skip rows inserted by other threads like in btree
*/
- error=rtree_get_next(info,inx,info->lastkey_length);
- break;
+ error= rtree_get_next(info,inx,info->lastkey_length);
+ break;
- case HA_KEY_ALG_BTREE:
- default:
- if (!changed)
- {
- error=_mi_search_next(info,info->s->keyinfo+inx,info->lastkey,
- info->lastkey_length,flag,
- info->s->state.key_root[inx]);
- }
- else
- {
- error=_mi_search(info,info->s->keyinfo+inx,info->lastkey,
- USE_WHOLE_KEY,flag, info->s->state.key_root[inx]);
- }
- if (!error && info->s->concurrent_insert)
- {
- while (info->lastpos >= info->state->data_file_length)
- {
- /* Skip rows that are inserted by other threads since we got a lock */
- if ((error=_mi_search_next(info,info->s->keyinfo+inx,info->lastkey,
- info->lastkey_length,
- SEARCH_BIGGER,
- info->s->state.key_root[inx])))
- break;
- }
- }
+ case HA_KEY_ALG_BTREE:
+ default:
+ if (!changed)
+ error= _mi_search_next(info,info->s->keyinfo+inx,info->lastkey,
+ info->lastkey_length,flag,
+ info->s->state.key_root[inx]);
+ else
+ error= _mi_search(info,info->s->keyinfo+inx,info->lastkey,
+ USE_WHOLE_KEY,flag, info->s->state.key_root[inx]);
}
}
if (info->s->concurrent_insert)
+ {
+ if (!error)
+ {
+ while (info->lastpos >= info->state->data_file_length)
+ {
+ /* Skip rows inserted by other threads since we got a lock */
+ if ((error=_mi_search_next(info,info->s->keyinfo+inx,
+ info->lastkey,
+ info->lastkey_length,
+ SEARCH_BIGGER,
+ info->s->state.key_root[inx])))
+ break;
+ }
+ }
rw_unlock(&info->s->key_root_lock[inx]);
+ }
/* Don't clear if database-changed */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_NEXT_FOUND;
diff --git a/myisam/mi_rprev.c b/myisam/mi_rprev.c
index 4807e636252..b787210e037 100644
--- a/myisam/mi_rprev.c
+++ b/myisam/mi_rprev.c
@@ -52,21 +52,22 @@ int mi_rprev(MI_INFO *info, byte *buf, int inx)
error=_mi_search(info,share->keyinfo+inx,info->lastkey,
USE_WHOLE_KEY, flag, share->state.key_root[inx]);
- if (!error)
+ if (share->concurrent_insert)
{
- while (info->lastpos >= info->state->data_file_length)
+ if (!error)
{
- /* Skip rows that are inserted by other threads since we got a lock */
- if ((error=_mi_search_next(info,share->keyinfo+inx,info->lastkey,
- info->lastkey_length,
- SEARCH_SMALLER,
- share->state.key_root[inx])))
- break;
+ while (info->lastpos >= info->state->data_file_length)
+ {
+ /* Skip rows that are inserted by other threads since we got a lock */
+ if ((error=_mi_search_next(info,share->keyinfo+inx,info->lastkey,
+ info->lastkey_length,
+ SEARCH_SMALLER,
+ share->state.key_root[inx])))
+ break;
+ }
}
- }
-
- if (share->concurrent_insert)
rw_unlock(&share->key_root_lock[inx]);
+ }
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_PREV_FOUND;
if (error)