~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/btr/btr0pcur.c

  • Committer: Monty Taylor
  • Date: 2009-08-12 06:25:19 UTC
  • mto: (1114.1.1 innodb-plugin-merge)
  • mto: This revision was merged to the branch mainline in revision 1183.
  • Revision ID: mordred@inaugust.com-20090812062519-cij02mrrunvnxblt
Tags: innodb-plugin-1.0.4
InnoDB Plugin 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/******************************************************
 
19
/**************************************************//**
 
20
@file btr/btr0pcur.c
20
21
The index tree persistent cursor
21
22
 
22
23
Created 2/23/1996 Heikki Tuuri
32
33
#include "rem0cmp.h"
33
34
#include "trx0trx.h"
34
35
 
35
 
/******************************************************************
36
 
Allocates memory for a persistent cursor object and initializes the cursor. */
 
36
/**************************************************************//**
 
37
Allocates memory for a persistent cursor object and initializes the cursor.
 
38
@return own: persistent cursor */
37
39
UNIV_INTERN
38
40
btr_pcur_t*
39
41
btr_pcur_create_for_mysql(void)
40
42
/*============================*/
41
 
                                /* out, own: persistent cursor */
42
43
{
43
44
        btr_pcur_t*     pcur;
44
45
 
50
51
        return(pcur);
51
52
}
52
53
 
53
 
/******************************************************************
 
54
/**************************************************************//**
54
55
Frees the memory for a persistent cursor object. */
55
56
UNIV_INTERN
56
57
void
57
58
btr_pcur_free_for_mysql(
58
59
/*====================*/
59
 
        btr_pcur_t*     cursor) /* in, own: persistent cursor */
 
60
        btr_pcur_t*     cursor) /*!< in, own: persistent cursor */
60
61
{
61
62
        if (cursor->old_rec_buf != NULL) {
62
63
 
76
77
        mem_free(cursor);
77
78
}
78
79
 
79
 
/******************************************************************
 
80
/**************************************************************//**
80
81
The position of the cursor is stored by taking an initial segment of the
81
82
record the cursor is positioned on, before, or after, and copying it to the
82
83
cursor data structure, or just setting a flag if the cursor id before the
87
88
void
88
89
btr_pcur_store_position(
89
90
/*====================*/
90
 
        btr_pcur_t*     cursor, /* in: persistent cursor */
91
 
        mtr_t*          mtr)    /* in: mtr */
 
91
        btr_pcur_t*     cursor, /*!< in: persistent cursor */
 
92
        mtr_t*          mtr)    /*!< in: mtr */
92
93
{
93
94
        page_cur_t*     page_cursor;
94
95
        buf_block_t*    block;
157
158
        cursor->modify_clock = buf_block_get_modify_clock(block);
158
159
}
159
160
 
160
 
/******************************************************************
 
161
/**************************************************************//**
161
162
Copies the stored position of a pcur to another pcur. */
162
163
UNIV_INTERN
163
164
void
164
165
btr_pcur_copy_stored_position(
165
166
/*==========================*/
166
 
        btr_pcur_t*     pcur_receive,   /* in: pcur which will receive the
 
167
        btr_pcur_t*     pcur_receive,   /*!< in: pcur which will receive the
167
168
                                        position info */
168
 
        btr_pcur_t*     pcur_donate)    /* in: pcur from which the info is
 
169
        btr_pcur_t*     pcur_donate)    /*!< in: pcur from which the info is
169
170
                                        copied */
170
171
{
171
172
        if (pcur_receive->old_rec_buf) {
187
188
        pcur_receive->old_n_fields = pcur_donate->old_n_fields;
188
189
}
189
190
 
190
 
/******************************************************************
 
191
/**************************************************************//**
191
192
Restores the stored position of a persistent cursor bufferfixing the page and
192
193
obtaining the specified latches. If the cursor position was saved when the
193
194
(1) cursor was positioned on a user record: this function restores the position
198
199
(3) cursor was positioned on the page supremum: restores to the first record
199
200
GREATER than the user record which was the predecessor of the supremum.
200
201
(4) cursor was positioned before the first or after the last in an empty tree:
201
 
restores to before first or after the last in the tree. */
 
202
restores to before first or after the last in the tree.
 
203
@return TRUE if the cursor position was stored when it was on a user
 
204
record and it can be restored on a user record whose ordering fields
 
205
are identical to the ones of the original user record */
202
206
UNIV_INTERN
203
207
ibool
204
208
btr_pcur_restore_position(
205
209
/*======================*/
206
 
                                        /* out: TRUE if the cursor position
207
 
                                        was stored when it was on a user record
208
 
                                        and it can be restored on a user record
209
 
                                        whose ordering fields are identical to
210
 
                                        the ones of the original user record */
211
 
        ulint           latch_mode,     /* in: BTR_SEARCH_LEAF, ... */
212
 
        btr_pcur_t*     cursor,         /* in: detached persistent cursor */
213
 
        mtr_t*          mtr)            /* in: mtr */
 
210
        ulint           latch_mode,     /*!< in: BTR_SEARCH_LEAF, ... */
 
211
        btr_pcur_t*     cursor,         /*!< in: detached persistent cursor */
 
212
        mtr_t*          mtr)            /*!< in: mtr */
214
213
{
215
214
        dict_index_t*   index;
216
215
        dtuple_t*       tuple;
351
350
        return(FALSE);
352
351
}
353
352
 
354
 
/******************************************************************
 
353
/**************************************************************//**
355
354
If the latch mode of the cursor is BTR_LEAF_SEARCH or BTR_LEAF_MODIFY,
356
355
releases the page latch and bufferfix reserved by the cursor.
357
356
NOTE! In the case of BTR_LEAF_MODIFY, there should not exist changes
361
360
void
362
361
btr_pcur_release_leaf(
363
362
/*==================*/
364
 
        btr_pcur_t*     cursor, /* in: persistent cursor */
365
 
        mtr_t*          mtr)    /* in: mtr */
 
363
        btr_pcur_t*     cursor, /*!< in: persistent cursor */
 
364
        mtr_t*          mtr)    /*!< in: mtr */
366
365
{
367
366
        buf_block_t*    block;
368
367
 
378
377
        cursor->pos_state = BTR_PCUR_WAS_POSITIONED;
379
378
}
380
379
 
381
 
/*************************************************************
 
380
/*********************************************************//**
382
381
Moves the persistent cursor to the first record on the next page. Releases the
383
382
latch on the current page, and bufferunfixes it. Note that there must not be
384
383
modifications on the current page, as then the x-latch can be released only in
387
386
void
388
387
btr_pcur_move_to_next_page(
389
388
/*=======================*/
390
 
        btr_pcur_t*     cursor, /* in: persistent cursor; must be on the
 
389
        btr_pcur_t*     cursor, /*!< in: persistent cursor; must be on the
391
390
                                last record of the current page */
392
 
        mtr_t*          mtr)    /* in: mtr */
 
391
        mtr_t*          mtr)    /*!< in: mtr */
393
392
{
394
393
        ulint           next_page_no;
395
394
        ulint           space;
429
428
        page_check_dir(next_page);
430
429
}
431
430
 
432
 
/*************************************************************
 
431
/*********************************************************//**
433
432
Moves the persistent cursor backward if it is on the first record of the page.
434
433
Commits mtr. Note that to prevent a possible deadlock, the operation
435
434
first stores the position of the cursor, commits mtr, acquires the necessary
442
441
void
443
442
btr_pcur_move_backward_from_page(
444
443
/*=============================*/
445
 
        btr_pcur_t*     cursor, /* in: persistent cursor, must be on the first
 
444
        btr_pcur_t*     cursor, /*!< in: persistent cursor, must be on the first
446
445
                                record of the current page */
447
 
        mtr_t*          mtr)    /* in: mtr */
 
446
        mtr_t*          mtr)    /*!< in: mtr */
448
447
{
449
448
        ulint           prev_page_no;
450
449
        ulint           space;
511
510
        cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
512
511
}
513
512
 
514
 
/*************************************************************
 
513
/*********************************************************//**
515
514
Moves the persistent cursor to the previous record in the tree. If no records
516
 
are left, the cursor stays 'before first in tree'. */
 
515
are left, the cursor stays 'before first in tree'.
 
516
@return TRUE if the cursor was not before first in tree */
517
517
UNIV_INTERN
518
518
ibool
519
519
btr_pcur_move_to_prev(
520
520
/*==================*/
521
 
                                /* out: TRUE if the cursor was not before first
522
 
                                in tree */
523
 
        btr_pcur_t*     cursor, /* in: persistent cursor; NOTE that the
 
521
        btr_pcur_t*     cursor, /*!< in: persistent cursor; NOTE that the
524
522
                                function may release the page latch */
525
 
        mtr_t*          mtr)    /* in: mtr */
 
523
        mtr_t*          mtr)    /*!< in: mtr */
526
524
{
527
525
        ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
528
526
        ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
546
544
        return(TRUE);
547
545
}
548
546
 
549
 
/******************************************************************
 
547
/**************************************************************//**
550
548
If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first
551
549
user record satisfying the search condition, in the case PAGE_CUR_L or
552
550
PAGE_CUR_LE, on the last user record. If no such user record exists, then
557
555
void
558
556
btr_pcur_open_on_user_rec(
559
557
/*======================*/
560
 
        dict_index_t*   index,          /* in: index */
561
 
        const dtuple_t* tuple,          /* in: tuple on which search done */
562
 
        ulint           mode,           /* in: PAGE_CUR_L, ... */
563
 
        ulint           latch_mode,     /* in: BTR_SEARCH_LEAF or
 
558
        dict_index_t*   index,          /*!< in: index */
 
559
        const dtuple_t* tuple,          /*!< in: tuple on which search done */
 
560
        ulint           mode,           /*!< in: PAGE_CUR_L, ... */
 
561
        ulint           latch_mode,     /*!< in: BTR_SEARCH_LEAF or
564
562
                                        BTR_MODIFY_LEAF */
565
 
        btr_pcur_t*     cursor,         /* in: memory buffer for persistent
 
563
        btr_pcur_t*     cursor,         /*!< in: memory buffer for persistent
566
564
                                        cursor */
567
 
        mtr_t*          mtr)            /* in: mtr */
 
565
        mtr_t*          mtr)            /*!< in: mtr */
568
566
{
569
567
        btr_pcur_open(index, tuple, mode, latch_mode, cursor, mtr);
570
568