1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2006 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
1
by brian
clean slate |
15 |
|
1130.3.28
by Monty Taylor
Moved heapdef.h and myisamdef.h to *_priv.h for easier filtering for include guard check. |
16 |
#include "myisam_priv.h" |
1
by brian
clean slate |
17 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
18 |
using namespace drizzled; |
19 |
||
1
by brian
clean slate |
20 |
/*
|
21 |
Read next row with the same key as previous read, but abort if
|
|
22 |
the key changes.
|
|
23 |
One may have done a write, update or delete of the previous row.
|
|
24 |
NOTE! Even if one changes the previous row, the next read is done
|
|
25 |
based on the position of the last used key!
|
|
26 |
*/
|
|
27 |
||
481
by Brian Aker
Remove all of uchar. |
28 |
int mi_rnext_same(MI_INFO *info, unsigned char *buf) |
1
by brian
clean slate |
29 |
{
|
30 |
int error; |
|
482
by Brian Aker
Remove uint. |
31 |
uint32_t inx,not_used[2]; |
1
by brian
clean slate |
32 |
MI_KEYDEF *keyinfo; |
33 |
||
34 |
if ((int) (inx=info->lastinx) < 0 || info->lastpos == HA_OFFSET_ERROR) |
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
35 |
return(errno=HA_ERR_WRONG_INDEX); |
1
by brian
clean slate |
36 |
keyinfo=info->s->keyinfo+inx; |
37 |
if (fast_mi_readinfo(info)) |
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
38 |
return(errno); |
1
by brian
clean slate |
39 |
|
40 |
switch (keyinfo->key_alg) |
|
41 |
{
|
|
42 |
case HA_KEY_ALG_BTREE: |
|
43 |
default: |
|
44 |
if (!(info->update & HA_STATE_RNEXT_SAME)) |
|
45 |
{
|
|
46 |
/* First rnext_same; Store old key */
|
|
47 |
memcpy(info->lastkey2,info->lastkey,info->last_rkey_length); |
|
48 |
}
|
|
49 |
for (;;) |
|
50 |
{
|
|
51 |
if ((error=_mi_search_next(info,keyinfo,info->lastkey, |
|
52 |
info->lastkey_length,SEARCH_BIGGER, |
|
53 |
info->s->state.key_root[inx]))) |
|
54 |
break; |
|
55 |
if (ha_key_cmp(keyinfo->seg, info->lastkey, info->lastkey2, |
|
56 |
info->last_rkey_length, SEARCH_FIND, not_used)) |
|
57 |
{
|
|
58 |
error=1; |
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
59 |
errno=HA_ERR_END_OF_FILE; |
1
by brian
clean slate |
60 |
info->lastpos= HA_OFFSET_ERROR; |
61 |
break; |
|
62 |
}
|
|
63 |
/* Skip rows that are inserted by other threads since we got a lock */
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
64 |
if (info->lastpos < info->state->data_file_length && |
1
by brian
clean slate |
65 |
(!info->index_cond_func || mi_check_index_cond(info, inx, buf))) |
66 |
break; |
|
67 |
}
|
|
68 |
}
|
|
1689.2.27
by Brian Aker
More lock removal from myisam. |
69 |
/* Don't clear if database-changed */
|
1
by brian
clean slate |
70 |
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); |
71 |
info->update|= HA_STATE_NEXT_FOUND | HA_STATE_RNEXT_SAME; |
|
72 |
||
73 |
if (error) |
|
74 |
{
|
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
75 |
if (errno == HA_ERR_KEY_NOT_FOUND) |
76 |
errno=HA_ERR_END_OF_FILE; |
|
1
by brian
clean slate |
77 |
}
|
78 |
else if (!buf) |
|
79 |
{
|
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
80 |
return(info->lastpos==HA_OFFSET_ERROR ? errno : 0); |
1
by brian
clean slate |
81 |
}
|
82 |
else if (!(*info->read_record)(info,info->lastpos,buf)) |
|
83 |
{
|
|
84 |
info->update|= HA_STATE_AKTIV; /* Record is read */ |
|
51.1.109
by Jay Pipes
Removed/replaced DBUG |
85 |
return(0); |
1
by brian
clean slate |
86 |
}
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
87 |
return(errno); |
1
by brian
clean slate |
88 |
} /* mi_rnext_same */ |