18
18
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
20
You should have received a copy of the GNU General Public License along with
21
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22
Place, Suite 330, Boston, MA 02111-1307 USA
21
this program; if not, write to the Free Software Foundation, Inc.,
22
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
24
*****************************************************************************/
3094
3095
mtr_t* mtr) /*!< in: mtr; CAUTION: may commit
3095
3096
mtr temporarily! */
3098
ulint relative_position;
3100
relative_position = pcur->rel_pos;
3102
3100
success = btr_pcur_restore_position(latch_mode, pcur, mtr);
3104
3102
*same_user_rec = success;
3106
if (relative_position == BTR_PCUR_ON) {
3104
ut_ad(!success || pcur->rel_pos == BTR_PCUR_ON);
3106
if (pcur->pos_state == BTR_PCUR_IS_POSITIONED_OPTIMISTIC) {
3107
ut_ad(pcur->rel_pos == BTR_PCUR_BEFORE
3108
|| pcur->rel_pos == BTR_PCUR_AFTER);
3110
ut_ad(pcur->pos_state == BTR_PCUR_IS_POSITIONED);
3111
ut_ad((pcur->rel_pos == BTR_PCUR_ON)
3112
== btr_pcur_is_on_user_rec(pcur));
3116
/* The position may need be adjusted for rel_pos and moves_up. */
3118
switch (pcur->rel_pos) {
3120
if (!success && moves_up) {
3112
3122
btr_pcur_move_to_next(pcur, mtr);
3126
case BTR_PCUR_AFTER_LAST_IN_TREE:
3127
case BTR_PCUR_BEFORE_FIRST_IN_TREE:
3118
if (relative_position == BTR_PCUR_AFTER
3119
|| relative_position == BTR_PCUR_AFTER_LAST_IN_TREE) {
3125
if (btr_pcur_is_on_user_rec(pcur)) {
3129
case BTR_PCUR_AFTER:
3130
/* positioned to record after pcur->old_rec. */
3131
pcur->pos_state = BTR_PCUR_IS_POSITIONED;
3133
if (btr_pcur_is_on_user_rec(pcur) && !moves_up) {
3126
3134
btr_pcur_move_to_prev(pcur, mtr);
3132
ut_ad(relative_position == BTR_PCUR_BEFORE
3133
|| relative_position == BTR_PCUR_BEFORE_FIRST_IN_TREE);
3135
if (moves_up && btr_pcur_is_on_user_rec(pcur)) {
3136
btr_pcur_move_to_next(pcur, mtr);
3137
case BTR_PCUR_BEFORE:
3138
/* For non optimistic restoration:
3139
The position is now set to the record before pcur->old_rec.
3141
For optimistic restoration:
3142
The position also needs to take the previous search_mode into
3145
switch (pcur->pos_state) {
3146
case BTR_PCUR_IS_POSITIONED_OPTIMISTIC:
3147
pcur->pos_state = BTR_PCUR_IS_POSITIONED;
3148
if (pcur->search_mode == PAGE_CUR_GE) {
3149
/* Positioned during Greater or Equal search
3150
with BTR_PCUR_BEFORE. Optimistic restore to
3151
the same record. If scanning for lower then
3152
we must move to previous record.
3153
This can happen with:
3154
HANDLER READ idx a = (const);
3155
HANDLER READ idx PREV; */
3159
case BTR_PCUR_IS_POSITIONED:
3160
if (moves_up && btr_pcur_is_on_user_rec(pcur)) {
3164
case BTR_PCUR_WAS_POSITIONED:
3165
case BTR_PCUR_NOT_POSITIONED:
4120
4151
btr_pcur_store_position(pcur, &mtr);
4153
/* The found record was not a match, but may be used
4154
as NEXT record (index_next). Set the relative position
4155
to BTR_PCUR_BEFORE, to reflect that the position of
4156
the persistent cursor is before the found/stored row
4158
ut_ad(pcur->rel_pos == BTR_PCUR_ON);
4159
pcur->rel_pos = BTR_PCUR_BEFORE;
4122
4161
err = DB_RECORD_NOT_FOUND;
4123
4162
/* ut_print_name(stderr, index->name);
4124
4163
fputs(" record not found 3\n", stderr); */
4159
4198
btr_pcur_store_position(pcur, &mtr);
4200
/* The found record was not a match, but may be used
4201
as NEXT record (index_next). Set the relative position
4202
to BTR_PCUR_BEFORE, to reflect that the position of
4203
the persistent cursor is before the found/stored row
4205
ut_ad(pcur->rel_pos == BTR_PCUR_ON);
4206
pcur->rel_pos = BTR_PCUR_BEFORE;
4161
4208
err = DB_RECORD_NOT_FOUND;
4162
4209
/* ut_print_name(stderr, index->name);
4163
4210
fputs(" record not found 4\n", stderr); */