1 /* Copyright (c) 2000-2003, 2005-2007 MySQL AB
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.
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.
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
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
18 static int queue_key_cmp(void *keyseg
, uchar
*a
, uchar
*b
)
20 MYRG_TABLE
*ma
= (MYRG_TABLE
*)a
;
21 MYRG_TABLE
*mb
= (MYRG_TABLE
*)b
;
22 MI_INFO
*aa
= ma
->table
;
23 MI_INFO
*bb
= mb
->table
;
25 int ret
= ha_key_cmp((HA_KEYSEG
*)keyseg
, aa
->lastkey
, bb
->lastkey
,
26 USE_WHOLE_KEY
, SEARCH_FIND
, not_used
);
33 If index tuples have the same values, let the record with least rowid
34 value be "smaller", so index scans return records ordered by (keytuple,
35 rowid). This is used by index_merge access method, grep for ROR in
36 sql/opt_range.cc for details.
38 return (ma
->file_offset
< mb
->file_offset
)? -1 : (ma
->file_offset
>
39 mb
->file_offset
) ? 1 : 0;
43 int _myrg_init_queue(MYRG_INFO
*info
,int inx
,enum ha_rkey_function search_flag
)
46 QUEUE
*q
= &(info
->by_key
);
48 if (inx
< (int) info
->keys
)
50 if (!is_queue_inited(q
))
52 if (init_queue(q
,info
->tables
, 0,
53 (myisam_readnext_vec
[search_flag
] == SEARCH_SMALLER
),
55 info
->open_tables
->table
->s
->keyinfo
[inx
].seg
))
60 if (reinit_queue(q
,info
->tables
, 0,
61 (myisam_readnext_vec
[search_flag
] == SEARCH_SMALLER
),
63 info
->open_tables
->table
->s
->keyinfo
[inx
].seg
))
68 my_errno
= error
= HA_ERR_WRONG_INDEX
;
72 int _myrg_mi_read_record(MI_INFO
*info
, uchar
*buf
)
74 if (!(*info
->read_record
)(info
,info
->lastpos
,buf
))
76 info
->update
|= HA_STATE_AKTIV
; /* Record is read */