Debian Codegraph @

storage/myisam/mi_rprev.c

raw symbols SCIP
1 /* Copyright (c) 2000, 2001, 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc.
2 Use is subject to license terms.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
16
17 #include "myisamdef.h"cxx . . $ `<file>/storage/myisam/myisamdef.h`/
18
19 /*
20 Read previous row with the same key as previous read
21 One may have done a write, update or delete of the previous row.
22 NOTE! Even if one changes the previous row, the next read is done
23 based on the position of the last used key!
24 */
25
26 int mi_rprevcxx . . $ mi_rprev(b13a3588bf66f733).(MI_INFOcxx . . $ MI_INFO# *info, ucharcxx . . $ uchar# *buf, int inx)
27 {
28 int error,changed;
29 register uintcxx . . $ uint# flag;
30 MYISAM_SHAREcxx . . $ MYISAM_SHARE# *share=info->scxx . . $ st_myisam_info#s.;
31 check_result_tcxx . . $ check_result_t# check= CHECK_POScxx . . $ CHECK_POS.;
32 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("mi_rprev");
33
34 if ((inx = _mi_check_indexcxx . . $ _mi_check_index(a395578934ddaf1c).(info,inx)) < 0)
35 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(my_errnocxx . . $ `include/my_pthread.h:720:9`!);
36 flag=SEARCH_SMALLERcxx . . $ `include/my_base.h:586:9`!; /* Read previous */
37 if (info->lastposcxx . . $ st_myisam_info#lastpos. == HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`! && info->updatecxx . . $ st_myisam_info#update. & HA_STATE_NEXT_FOUNDcxx . . $ `include/my_base.h:621:9`!)
38 flag=0; /* Read last */
39
40 if (fast_mi_readinfocxx . . $ `storage/myisam/myisamdef.h:673:9`!(info))
41 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(my_errnocxx . . $ `include/my_pthread.h:720:9`!);
42 changed=_mi_test_if_changedcxx . . $ _mi_test_if_changed(5bca52a199e8d1d4).(info);
43 if (share->concurrent_insertcxx . . $ st_mi_isam_share#concurrent_insert.)
44 mysql_rwlock_rdlockcxx . . $ `include/mysql/psi/mysql_thread.h:452:11`!(&share->key_root_lock[inx]);
45 if (!flag)
46 error=_mi_search_lastcxx . . $ _mi_search_last(31890286b5e8653e).(info, share->keyinfocxx . . $ st_mi_isam_share#keyinfo.+inx,
47 share->statecxx . . $ st_mi_isam_share#state..key_rootcxx . . $ st_mi_state_info#key_root.[inx]);
48 else if (!changed)
49 error=_mi_search_nextcxx . . $ _mi_search_next(11619ded83ef7296).(info,share->keyinfocxx . . $ st_mi_isam_share#keyinfo.+inx,info->lastkeycxx . . $ st_myisam_info#lastkey.,
50 info->lastkey_lengthcxx . . $ st_myisam_info#lastkey_length.,flag,
51 share->statecxx . . $ st_mi_isam_share#state..key_rootcxx . . $ st_mi_state_info#key_root.[inx]);
52 else
53 error=_mi_searchcxx . . $ _mi_search(11619ded83ef7296).(info,share->keyinfocxx . . $ st_mi_isam_share#keyinfo.+inx,info->lastkeycxx . . $ st_myisam_info#lastkey.,
54 USE_WHOLE_KEYcxx . . $ `storage/myisam/myisamdef.h:319:9`!, flag, share->statecxx . . $ st_mi_isam_share#state..key_rootcxx . . $ st_mi_state_info#key_root.[inx]);
55
56 if (!error)
57 {
58 my_off_tcxx . . $ my_off_t# cur_keypage= info->last_keypagecxx . . $ st_myisam_info#last_keypage.;
59 while ((share->concurrent_insertcxx . . $ st_mi_isam_share#concurrent_insert. &&
60 info->lastposcxx . . $ st_myisam_info#lastpos. >= info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length.) ||
61 (check= mi_check_index_tuplecxx . . $ mi_check_index_tuple(8d6ff5a0859961cd).(info, inx, buf)) == CHECK_NEGcxx . . $ CHECK_NEG.)
62 {
63 /*
64 If we are at the last (i.e. first?) key on the key page,
65 allow writers to access the index.
66 */
67 if (info->last_keypagecxx . . $ st_myisam_info#last_keypage. != cur_keypage)
68 {
69 cur_keypage= info->last_keypagecxx . . $ st_myisam_info#last_keypage.;
70 if (mi_yield_and_check_if_killedcxx . . $ mi_yield_and_check_if_killed(34a1a3a12ffdfe3).(info, inx))
71 {
72 error= 1;
73 break;
74 }
75 }
76
77 /*
78 Skip rows that are either inserted by other threads since
79 we got a lock or do not match pushed index conditions
80 */
81 if ((error=_mi_search_nextcxx . . $ _mi_search_next(11619ded83ef7296).(info,share->keyinfocxx . . $ st_mi_isam_share#keyinfo.+inx,info->lastkeycxx . . $ st_myisam_info#lastkey.,
82 info->lastkey_lengthcxx . . $ st_myisam_info#lastkey_length.,
83 SEARCH_SMALLERcxx . . $ `include/my_base.h:586:9`!,
84 share->statecxx . . $ st_mi_isam_share#state..key_rootcxx . . $ st_mi_state_info#key_root.[inx])))
85 break;
86 }
87 }
88
89 if (share->concurrent_insertcxx . . $ st_mi_isam_share#concurrent_insert.)
90 mysql_rwlock_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:535:9`!(&share->key_root_lock[inx]);
91
92 info->updatecxx . . $ st_myisam_info#update.&= (HA_STATE_CHANGEDcxx . . $ `include/my_base.h:617:9`! | HA_STATE_ROW_CHANGEDcxx . . $ `include/my_base.h:627:9`!);
93 info->updatecxx . . $ st_myisam_info#update.|= HA_STATE_PREV_FOUNDcxx . . $ `include/my_base.h:622:9`!;
94
95 if (error || check != CHECK_POScxx . . $ CHECK_POS.)
96 {
97 fast_mi_writeinfocxx . . $ `storage/myisam/myisamdef.h:672:9`!(info);
98 if (my_errnocxx . . $ `include/my_pthread.h:720:9`! == HA_ERR_KEY_NOT_FOUNDcxx . . $ `include/my_base.h:466:9`!)
99 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_END_OF_FILEcxx . . $ `include/my_base.h:482:9`!;
100 }
101 else if (!buf)
102 {
103 fast_mi_writeinfocxx . . $ `storage/myisam/myisamdef.h:672:9`!(info);
104 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(info->lastpos==HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`! ? my_errnocxx . . $ `include/my_pthread.h:720:9`! : 0);
105 }
106 else if (!(*info->read_recordcxx . . $ st_myisam_info#read_record.)(info,info->lastposcxx . . $ st_myisam_info#lastpos.,buf))
107 {
108 info->updatecxx . . $ st_myisam_info#update.|= HA_STATE_AKTIVcxx . . $ `include/my_base.h:618:9`!; /* Record is read */
109 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
110 }
111 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(my_errnocxx . . $ `include/my_pthread.h:720:9`!);
112 } /* mi_rprev */