Debian Codegraph @

storage/myisam/mi_dynrec.c

raw symbols SCIP
1 /*
2 Copyright (c) 2000, 2011, Oracle and/or its affiliates
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 /*
18 Functions to handle space-packed-records and blobs
19
20 A row may be stored in one or more linked blocks.
21 The block size is between MI_MIN_BLOCK_LENGTH and MI_MAX_BLOCK_LENGTH.
22 Each block is aligned on MI_DYN_ALIGN_SIZE.
23 The reson for the max block size is to not have too many different types
24 of blocks. For the differnet block types, look at _mi_get_block_info()
25 */
26
27 #include "myisamdef.h"cxx . . $ `<file>/storage/myisam/myisamdef.h`/
28
29 /* Enough for comparing if number is zero */
30 static char zero_stringcxx . . $ zero_string.[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
31
32 static int write_dynamic_recordcxx . . $ write_dynamic_record(ed1263bbba4adbe4).(MI_INFOcxx . . $ MI_INFO# *info,const ucharcxx . . $ uchar# *record,
33 ulongcxx . . $ ulong# reclength);
34 static int _mi_find_writeposcxx . . $ _mi_find_writepos(1255bdaa5fb127f8).(MI_INFOcxx . . $ MI_INFO# *info,ulongcxx . . $ ulong# reclength,my_off_tcxx . . $ my_off_t# *filepos,
35 ulongcxx . . $ ulong# *length);
36 static int update_dynamic_recordcxx . . $ update_dynamic_record(4cf11700df929283).(MI_INFOcxx . . $ MI_INFO# *info,my_off_tcxx . . $ my_off_t# filepos,ucharcxx . . $ uchar# *record,
37 ulongcxx . . $ ulong# reclength);
38 static int delete_dynamic_recordcxx . . $ delete_dynamic_record(2fec77617b780741).(MI_INFOcxx . . $ MI_INFO# *info,my_off_tcxx . . $ my_off_t# filepos,
39 uintcxx . . $ uint# second_read);
40 static int _mi_cmp_buffercxx . . $ _mi_cmp_buffer(28f8de9edd2414ae).(Filecxx . . $ File# file, const ucharcxx . . $ uchar# *buff, my_off_tcxx . . $ my_off_t# filepos,
41 uintcxx . . $ uint# length);
42
43 /* Play it safe; We have a small stack when using threads */
44 #undef my_allocacxx . . $ `include/my_sys.h:220:9`!
45 #undef my_afreecxx . . $ `include/my_sys.h:221:9`!
46 #define my_allocacxx . . $ `storage/myisam/mi_dynrec.c:46:9`!(A) my_malloc(PSI_NOT_INSTRUMENTEDcxx . . $ `include/mysql/psi/psi_base.h:51:9`!, (A),MYFcxx . . $ `include/my_global.h:986:9`!(0))
47 #define my_afreecxx . . $ `storage/myisam/mi_dynrec.c:47:9`!(A) my_free((A))
48
49 /* Interface function from MI_INFO */
50
51 #ifdef HAVE_MMAPcxx . . $ `build/include/my_config.h:184:9`!
52
53 /*
54 Create mmaped area for MyISAM handler
55
56 SYNOPSIS
57 mi_dynmap_file()
58 info MyISAM handler
59
60 RETURN
61 0 ok
62 1 error.
63 */
64
65 my_boolcxx . . $ my_bool# mi_dynmap_filecxx . . $ mi_dynmap_file(933341955b3d0d47).(MI_INFOcxx . . $ MI_INFO# *info, my_off_tcxx . . $ my_off_t# size)
66 {
67 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("mi_dynmap_file");
68 if (size == 0 || size > (my_off_tcxx . . $ my_off_t#) (~((size_t) 0)))
69 {
70 if (size)
71 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("warning", ("File is too large for mmap"));
72 else
73 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("warning", ("Do not mmap zero-length"));
74 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
75 }
76 /*
77 I wonder if it is good to use MAP_NORESERVE. From the Linux man page:
78 MAP_NORESERVE
79 Do not reserve swap space for this mapping. When swap space is
80 reserved, one has the guarantee that it is possible to modify the
81 mapping. When swap space is not reserved one might get SIGSEGV
82 upon a write if no physical memory is available.
83 */
84 info->scxx . . $ st_myisam_info#s.->file_mapcxx . . $ st_mi_isam_share#file_map.= (ucharcxx . . $ uchar#*)
85 my_mmapcxx . . $ `include/my_sys.h:1055:9`!(0, (size_t) size,
86 info->s->index_mode == O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`! ? PROT_READcxx . . $ `<external>/17226767460805440860/mman-linux.h:32:9`! :
87 PROT_READcxx . . $ `<external>/17226767460805440860/mman-linux.h:32:9`! | PROT_WRITEcxx . . $ `<external>/17226767460805440860/mman-linux.h:33:9`!,
88 MAP_SHAREDcxx . . $ `<external>/17226767460805440860/mman-linux.h:42:9`! | MAP_NORESERVEcxx . . $ `<external>/17483882539226609504/mman-map-flags-generic.h:32:9`!,
89 info->dfile, 0L);
90 if (info->scxx . . $ st_myisam_info#s.->file_mapcxx . . $ st_mi_isam_share#file_map. == (ucharcxx . . $ uchar#*) MAP_FAILEDcxx . . $ `<external>/6724834311684550606/mman.h:44:9`!)
91 {
92 info->scxx . . $ st_myisam_info#s.->file_mapcxx . . $ st_mi_isam_share#file_map.= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
93 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
94 }
95 #if defined(HAVE_MADVISEcxx . . $ `build/include/my_config.h:173:9`!)
96 madvisecxx . . $ madvise(e72f86de37bb8b46).((char*) info->scxx . . $ st_myisam_info#s.->file_mapcxx . . $ st_mi_isam_share#file_map., size, MADV_RANDOMcxx . . $ `<external>/17226767460805440860/mman-linux.h:89:10`!);
97 #endif
98 info->scxx . . $ st_myisam_info#s.->mmaped_lengthcxx . . $ st_mi_isam_share#mmaped_length.= (size_t) size;
99 info->scxx . . $ st_myisam_info#s.->file_readcxx . . $ st_mi_isam_share#file_read.= mi_mmap_preadcxx . . $ mi_mmap_pread(e2508c0616eb8649).;
100 info->scxx . . $ st_myisam_info#s.->file_writecxx . . $ st_mi_isam_share#file_write.= mi_mmap_pwritecxx . . $ mi_mmap_pwrite(102dae6aeae8472e).;
101 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
102 }
103
104
105 /*
106 Destroy mmaped area for MyISAM handler
107
108 SYNOPSIS
109 mi_munmap_file()
110 info MyISAM handler
111
112 RETURN
113 0 ok
114 !0 error.
115 */
116
117 int mi_munmap_filecxx . . $ mi_munmap_file(5bca52a199e8d1d4).(MI_INFOcxx . . $ MI_INFO# *info)
118 {
119 int ret;
120 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("mi_unmap_file");
121 if ((ret= my_munmapcxx . . $ `include/my_sys.h:1059:9`!((void*) info->s->file_map, info->s->mmaped_length)))
122 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(ret);
123 info->scxx . . $ st_myisam_info#s.->file_readcxx . . $ st_mi_isam_share#file_read.= mi_nommap_preadcxx . . $ mi_nommap_pread(e2508c0616eb8649).;
124 info->scxx . . $ st_myisam_info#s.->file_writecxx . . $ st_mi_isam_share#file_write.= mi_nommap_pwritecxx . . $ mi_nommap_pwrite(102dae6aeae8472e).;
125 info->scxx . . $ st_myisam_info#s.->file_mapcxx . . $ st_mi_isam_share#file_map.= 0;
126 info->scxx . . $ st_myisam_info#s.->mmaped_lengthcxx . . $ st_mi_isam_share#mmaped_length.= 0;
127 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
128 }
129
130
131 /*
132 Resize mmaped area for MyISAM handler
133
134 SYNOPSIS
135 mi_remap_file()
136 info MyISAM handler
137
138 RETURN
139 */
140
141 void mi_remap_filecxx . . $ mi_remap_file(a258e4cc97e55b89).(MI_INFOcxx . . $ MI_INFO# *info, my_off_tcxx . . $ my_off_t# size)
142 {
143 if (info->scxx . . $ st_myisam_info#s.->file_mapcxx . . $ st_mi_isam_share#file_map.)
144 {
145 mi_munmap_filecxx . . $ mi_munmap_file(5bca52a199e8d1d4).(info);
146 mi_dynmap_filecxx . . $ mi_dynmap_file(933341955b3d0d47).(info, size);
147 }
148 }
149 #endif
150
151
152 /*
153 Read bytes from MySAM handler, using mmap or pread
154
155 SYNOPSIS
156 mi_mmap_pread()
157 info MyISAM handler
158 Buffer Input buffer
159 Count Count of bytes for read
160 offset Start position
161 MyFlags
162
163 RETURN
164 0 ok
165 */
166
167 size_t mi_mmap_preadcxx . . $ mi_mmap_pread(e2508c0616eb8649).(MI_INFOcxx . . $ MI_INFO# *info, ucharcxx . . $ uchar# *Buffer,
168 size_t Count, my_off_tcxx . . $ my_off_t# offset, myfcxx . . $ myf# MyFlags)
169 {
170 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info", ("mi_read with mmap %d\n", info->dfile));
171 if (info->scxx . . $ st_myisam_info#s.->concurrent_insertcxx . . $ st_mi_isam_share#concurrent_insert.)
172 mysql_rwlock_rdlockcxx . . $ `include/mysql/psi/mysql_thread.h:452:11`!(&info->s->mmap_lock);
173
174 /*
175 The following test may fail in the following cases:
176 - We failed to remap a memory area (fragmented memory?)
177 - This thread has done some writes, but not yet extended the
178 memory mapped area.
179 */
180
181 if (info->scxx . . $ st_myisam_info#s.->mmaped_lengthcxx . . $ st_mi_isam_share#mmaped_length. >= offset + Count)
182 {
183 memcpycxx . . $ memcpy(cc817cb175f282d).(Buffer, info->scxx . . $ st_myisam_info#s.->file_mapcxx . . $ st_mi_isam_share#file_map. + offset, Count);
184 if (info->scxx . . $ st_myisam_info#s.->concurrent_insertcxx . . $ st_mi_isam_share#concurrent_insert.)
185 mysql_rwlock_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:535:9`!(&info->s->mmap_lock);
186 return 0;
187 }
188 else
189 {
190 if (info->scxx . . $ st_myisam_info#s.->concurrent_insertcxx . . $ st_mi_isam_share#concurrent_insert.)
191 mysql_rwlock_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:535:9`!(&info->s->mmap_lock);
192 return mysql_file_preadcxx . . $ `include/mysql/psi/mysql_file.h:366:11`!(info->dfile, Buffer, Count, offset, MyFlags);
193 }
194 }
195
196
197 /* wrapper for mysql_file_pread in case if mmap isn't used */
198
199 size_t mi_nommap_preadcxx . . $ mi_nommap_pread(e2508c0616eb8649).(MI_INFOcxx . . $ MI_INFO# *info, ucharcxx . . $ uchar# *Buffer,
200 size_t Count, my_off_tcxx . . $ my_off_t# offset, myfcxx . . $ myf# MyFlags)
201 {
202 return mysql_file_preadcxx . . $ `include/mysql/psi/mysql_file.h:366:11`!(info->dfile, Buffer, Count, offset, MyFlags);
203 }
204
205
206 /*
207 Write bytes to MySAM handler, using mmap or pwrite
208
209 SYNOPSIS
210 mi_mmap_pwrite()
211 info MyISAM handler
212 Buffer Output buffer
213 Count Count of bytes for write
214 offset Start position
215 MyFlags
216
217 RETURN
218 0 ok
219 !=0 error. In this case return error from pwrite
220 */
221
222 size_t mi_mmap_pwritecxx . . $ mi_mmap_pwrite(102dae6aeae8472e).(MI_INFOcxx . . $ MI_INFO# *info, const ucharcxx . . $ uchar# *Buffer,
223 size_t Count, my_off_tcxx . . $ my_off_t# offset, myfcxx . . $ myf# MyFlags)
224 {
225 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info", ("mi_write with mmap %d\n", info->dfile));
226 if (info->scxx . . $ st_myisam_info#s.->concurrent_insertcxx . . $ st_mi_isam_share#concurrent_insert.)
227 mysql_rwlock_rdlockcxx . . $ `include/mysql/psi/mysql_thread.h:452:11`!(&info->s->mmap_lock);
228
229 /*
230 The following test may fail in the following cases:
231 - We failed to remap a memory area (fragmented memory?)
232 - This thread has done some writes, but not yet extended the
233 memory mapped area.
234 */
235
236 if (info->scxx . . $ st_myisam_info#s.->mmaped_lengthcxx . . $ st_mi_isam_share#mmaped_length. >= offset + Count)
237 {
238 memcpycxx . . $ memcpy(cc817cb175f282d).(info->scxx . . $ st_myisam_info#s.->file_mapcxx . . $ st_mi_isam_share#file_map. + offset, Buffer, Count);
239 if (info->scxx . . $ st_myisam_info#s.->concurrent_insertcxx . . $ st_mi_isam_share#concurrent_insert.)
240 mysql_rwlock_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:535:9`!(&info->s->mmap_lock);
241 return 0;
242 }
243 else
244 {
245 info->scxx . . $ st_myisam_info#s.->nonmmaped_insertscxx . . $ st_mi_isam_share#nonmmaped_inserts.++;
246 if (info->scxx . . $ st_myisam_info#s.->concurrent_insertcxx . . $ st_mi_isam_share#concurrent_insert.)
247 mysql_rwlock_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:535:9`!(&info->s->mmap_lock);
248 return mysql_file_pwritecxx . . $ `include/mysql/psi/mysql_file.h:379:11`!(info->dfile, Buffer, Count, offset, MyFlags);
249 }
250
251 }
252
253
254 /* wrapper for mysql_file_pwrite in case if mmap isn't used */
255
256 size_t mi_nommap_pwritecxx . . $ mi_nommap_pwrite(102dae6aeae8472e).(MI_INFOcxx . . $ MI_INFO# *info, const ucharcxx . . $ uchar# *Buffer,
257 size_t Count, my_off_tcxx . . $ my_off_t# offset, myfcxx . . $ myf# MyFlags)
258 {
259 return mysql_file_pwritecxx . . $ `include/mysql/psi/mysql_file.h:379:11`!(info->dfile, Buffer, Count, offset, MyFlags);
260 }
261
262
263 int _mi_write_dynamic_recordcxx . . $ _mi_write_dynamic_record(c8f46092f4519684).(MI_INFOcxx . . $ MI_INFO# *info, const ucharcxx . . $ uchar# *record)
264 {
265 ulongcxx . . $ ulong# reclength=_mi_rec_packcxx . . $ _mi_rec_pack(92d72fbc6a90c214).(info,info->rec_buffcxx . . $ st_myisam_info#rec_buff.,record);
266 return (write_dynamic_recordcxx . . $ write_dynamic_record(ed1263bbba4adbe4).(info,info->rec_buffcxx . . $ st_myisam_info#rec_buff.,reclength));
267 }
268
269 int _mi_update_dynamic_recordcxx . . $ _mi_update_dynamic_record(fedf98377116f0fc).(MI_INFOcxx . . $ MI_INFO# *info, my_off_tcxx . . $ my_off_t# pos, const ucharcxx . . $ uchar# *record)
270 {
271 uintcxx . . $ uint# length=_mi_rec_packcxx . . $ _mi_rec_pack(92d72fbc6a90c214).(info,info->rec_buffcxx . . $ st_myisam_info#rec_buff.,record);
272 return (update_dynamic_recordcxx . . $ update_dynamic_record(4cf11700df929283).(info,pos,info->rec_buffcxx . . $ st_myisam_info#rec_buff.,length));
273 }
274
275 int _mi_write_blob_recordcxx . . $ _mi_write_blob_record(c8f46092f4519684).(MI_INFOcxx . . $ MI_INFO# *info, const ucharcxx . . $ uchar# *record)
276 {
277 ucharcxx . . $ uchar# *rec_buff;
278 int error;
279 ulongcxx . . $ ulong# reclength,reclength2,extra;
280
281 extra= (ALIGN_SIZEcxx . . $ `include/my_global.h:823:9`!(MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`!)+MI_SPLIT_LENGTHcxx . . $ `storage/myisam/myisamdef.h:391:9`!+
282 MI_DYN_DELETE_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:394:9`!+1);
283 reclength= (info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..pack_reclengthcxx . . $ st_mi_base_info#pack_reclength. +
284 _mi_calc_total_blob_lengthcxx . . $ _mi_calc_total_blob_length(3352b8d657b3d682).(info,record)+ extra);
285 if (!(rec_buff=(ucharcxx . . $ uchar#*) my_allocacxx . . $ `storage/myisam/mi_dynrec.c:46:9`!(reclength)))
286 {
287 my_errnocxx . . $ `include/my_pthread.h:720:9`!= HA_ERR_OUT_OF_MEMcxx . . $ `include/my_base.h:473:9`!; /* purecov: inspected */
288 return(-1);
289 }
290 reclength2= _mi_rec_packcxx . . $ _mi_rec_pack(92d72fbc6a90c214).(info,rec_buff+ALIGN_SIZEcxx . . $ `include/my_global.h:823:9`!(MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`!),
291 record);
292 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info",("reclength: %lu reclength2: %lu",
293 reclength, reclength2));
294 DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(reclength2 <= reclength);
295 error=write_dynamic_recordcxx . . $ write_dynamic_record(ed1263bbba4adbe4).(info,rec_buff+ALIGN_SIZEcxx . . $ `include/my_global.h:823:9`!(MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`!),
296 reclength2);
297 my_afreecxx . . $ `storage/myisam/mi_dynrec.c:47:9`!(rec_buff);
298 return(error);
299 }
300
301
302 int _mi_update_blob_recordcxx . . $ _mi_update_blob_record(fedf98377116f0fc).(MI_INFOcxx . . $ MI_INFO# *info, my_off_tcxx . . $ my_off_t# pos, const ucharcxx . . $ uchar# *record)
303 {
304 ucharcxx . . $ uchar# *rec_buff;
305 int error;
306 ulongcxx . . $ ulong# reclength,extra;
307
308 extra= (ALIGN_SIZEcxx . . $ `include/my_global.h:823:9`!(MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`!)+MI_SPLIT_LENGTHcxx . . $ `storage/myisam/myisamdef.h:391:9`!+
309 MI_DYN_DELETE_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:394:9`!);
310 reclength= (info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..pack_reclengthcxx . . $ st_mi_base_info#pack_reclength.+
311 _mi_calc_total_blob_lengthcxx . . $ _mi_calc_total_blob_length(3352b8d657b3d682).(info,record)+ extra);
312 if (!(rec_buff=(ucharcxx . . $ uchar#*) my_allocacxx . . $ `storage/myisam/mi_dynrec.c:46:9`!(reclength)))
313 {
314 my_errnocxx . . $ `include/my_pthread.h:720:9`!= HA_ERR_OUT_OF_MEMcxx . . $ `include/my_base.h:473:9`!; /* purecov: inspected */
315 return(-1);
316 }
317 reclength=_mi_rec_packcxx . . $ _mi_rec_pack(92d72fbc6a90c214).(info,rec_buff+ALIGN_SIZEcxx . . $ `include/my_global.h:823:9`!(MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`!),
318 record);
319 error=update_dynamic_recordcxx . . $ update_dynamic_record(4cf11700df929283).(info,pos,
320 rec_buff+ALIGN_SIZEcxx . . $ `include/my_global.h:823:9`!(MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`!),
321 reclength);
322 my_afreecxx . . $ `storage/myisam/mi_dynrec.c:47:9`!(rec_buff);
323 return(error);
324 }
325
326
327 int _mi_delete_dynamic_recordcxx . . $ _mi_delete_dynamic_record(5bca52a199e8d1d4).(MI_INFOcxx . . $ MI_INFO# *info)
328 {
329 return delete_dynamic_recordcxx . . $ delete_dynamic_record(2fec77617b780741).(info,info->lastposcxx . . $ st_myisam_info#lastpos.,0);
330 }
331
332
333 /* Write record to data-file */
334
335 static int write_dynamic_recordcxx . . $ write_dynamic_record(ed1263bbba4adbe4).(MI_INFOcxx . . $ MI_INFO# *info, const ucharcxx . . $ uchar# *record,
336 ulongcxx . . $ ulong# reclength)
337 {
338 int flag;
339 ulongcxx . . $ ulong# length;
340 my_off_tcxx . . $ my_off_t# filepos;
341 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("write_dynamic_record");
342
343 flag=0;
344
345 /*
346 Check if we have enough room for the new record.
347 First we do simplified check to make usual case faster.
348 Then we do more precise check for the space left.
349 Though it still is not absolutely precise, as
350 we always use MI_MAX_DYN_BLOCK_HEADER while it can be
351 less in the most of the cases.
352 */
353
354 if (unlikelycxx . . $ `include/my_global.h:361:9`!(info->s->base.max_data_file_length -
355 info->state->data_file_length <
356 reclength + MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`!))
357 {
358 if (info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..max_data_file_lengthcxx . . $ st_mi_base_info#max_data_file_length. - info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length. +
359 info->statecxx . . $ st_myisam_info#state.->emptycxx . . $ st_mi_status_info#empty. - info->statecxx . . $ st_myisam_info#state.->delcxx . . $ st_mi_status_info#del. * MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`! <
360 reclength + MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`!)
361 {
362 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_RECORD_FILE_FULLcxx . . $ `include/my_base.h:480:9`!;
363 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
364 }
365 }
366
367 do
368 {
369 if (_mi_find_writeposcxx . . $ _mi_find_writepos(1255bdaa5fb127f8).(info,reclength,&filepos,&length))
370 goto err;
371 if (_mi_write_part_recordcxx . . $ _mi_write_part_record(34e55845d0b95b9).(info,filepos,length,
372 (info->append_insert_at_endcxx . . $ st_myisam_info#append_insert_at_end. ?
373 HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`! : info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.),
374 (ucharcxx . . $ uchar#**) &record,&reclength,&flag))
375 goto err;
376 } while (reclength);
377
378 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
379 err:
380 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
381 }
382
383
384 /* Get a block for data ; The given data-area must be used !! */
385
386 static int _mi_find_writeposcxx . . $ _mi_find_writepos(1255bdaa5fb127f8).(MI_INFOcxx . . $ MI_INFO# *info,
387 ulongcxx . . $ ulong# reclength, /* record length */
388 my_off_tcxx . . $ my_off_t# *filepos, /* Return file pos */
389 ulongcxx . . $ ulong# *length) /* length of block at filepos */
390 {
391 MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# block_info;
392 ulongcxx . . $ ulong# tmp;
393 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_mi_find_writepos");
394
395 if (info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink. != HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`! &&
396 !info->append_insert_at_endcxx . . $ st_myisam_info#append_insert_at_end.)
397 {
398 /* Deleted blocks exists; Get last used block */
399 *filepos=info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.;
400 block_info.second_readcxx . . $ st_mi_block_info#second_read.=0;
401 info->rec_cachecxx . . $ st_myisam_info#rec_cache..seek_not_donecxx . . $ st_io_cache#seek_not_done.=1;
402 if (!(_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&block_info,info->dfilecxx . . $ st_myisam_info#dfile.,info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.) &
403 BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`!))
404 {
405 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error",("Delete link crashed"));
406 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!;
407 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(-1);
408 }
409 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.=block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos.;
410 info->statecxx . . $ st_myisam_info#state.->delcxx . . $ st_mi_status_info#del.--;
411 info->statecxx . . $ st_myisam_info#state.->emptycxx . . $ st_mi_status_info#empty.-= block_info.block_lencxx . . $ st_mi_block_info#block_len.;
412 *length= block_info.block_lencxx . . $ st_mi_block_info#block_len.;
413 }
414 else
415 {
416 /* No deleted blocks; Allocate a new block */
417 *filepos=info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length.;
418 if ((tmp= reclength + 3 + MY_TESTcxx . . $ `include/my_global.h:467:9`!(reclength >= (65520 - 3))) <
419 info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..min_block_lengthcxx . . $ st_mi_base_info#min_block_length.)
420 tmp= info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..min_block_lengthcxx . . $ st_mi_base_info#min_block_length.;
421 else
422 tmp= ((tmp+MI_DYN_ALIGN_SIZEcxx . . $ `storage/myisam/myisamdef.h:397:9`!-1) &
423 (~ (ulongcxx . . $ ulong#) (MI_DYN_ALIGN_SIZEcxx . . $ `storage/myisam/myisamdef.h:397:9`!-1)));
424 if (info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length. >
425 (info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..max_data_file_lengthcxx . . $ st_mi_base_info#max_data_file_length. - tmp))
426 {
427 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_RECORD_FILE_FULLcxx . . $ `include/my_base.h:480:9`!;
428 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(-1);
429 }
430 if (tmp > MI_MAX_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:399:9`!)
431 tmp=MI_MAX_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:399:9`!;
432 *length= tmp;
433 info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length.+= tmp;
434 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..splitcxx . . $ st_mi_state_info#split.++;
435 info->updatecxx . . $ st_myisam_info#update.|=HA_STATE_WRITE_AT_ENDcxx . . $ `include/my_base.h:625:9`!;
436 }
437 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
438 } /* _mi_find_writepos */
439
440
441
442 /*
443 Unlink a deleted block from the deleted list.
444 This block will be combined with the preceding or next block to form
445 a big block.
446 */
447
448 static my_boolcxx . . $ my_bool# unlink_deleted_blockcxx . . $ unlink_deleted_block(44c85a7ef039a80c).(MI_INFOcxx . . $ MI_INFO# *info, MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# *block_info)
449 {
450 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("unlink_deleted_block");
451 if (block_info->fileposcxx . . $ st_mi_block_info#filepos. == info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.)
452 {
453 /* First deleted block; We can just use this ! */
454 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.=block_info->next_fileposcxx . . $ st_mi_block_info#next_filepos.;
455 }
456 else
457 {
458 MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# tmp;
459 tmp.second_readcxx . . $ st_mi_block_info#second_read.=0;
460 /* Unlink block from the previous block */
461 if (!(_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&tmp,info->dfilecxx . . $ st_myisam_info#dfile.,block_info->prev_fileposcxx . . $ st_mi_block_info#prev_filepos.)
462 & BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`!))
463 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1); /* Something is wrong */
464 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!(tmp.header+4,block_info->next_filepos);
465 if (info->scxx . . $ st_myisam_info#s.->file_writecxx . . $ st_mi_isam_share#file_write.(info, tmp.headercxx . . $ st_mi_block_info#header.+4,8,
466 block_info->prev_fileposcxx . . $ st_mi_block_info#prev_filepos.+4, MYFcxx . . $ `include/my_global.h:986:9`!(MY_NABPcxx . . $ `include/my_sys.h:55:9`!)))
467 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
468 /* Unlink block from next block */
469 if (block_info->next_fileposcxx . . $ st_mi_block_info#next_filepos. != HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!)
470 {
471 if (!(_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&tmp,info->dfilecxx . . $ st_myisam_info#dfile.,block_info->next_fileposcxx . . $ st_mi_block_info#next_filepos.)
472 & BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`!))
473 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1); /* Something is wrong */
474 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!(tmp.header+12,block_info->prev_filepos);
475 if (info->scxx . . $ st_myisam_info#s.->file_writecxx . . $ st_mi_isam_share#file_write.(info, tmp.headercxx . . $ st_mi_block_info#header.+12,8,
476 block_info->next_fileposcxx . . $ st_mi_block_info#next_filepos.+12,
477 MYFcxx . . $ `include/my_global.h:986:9`!(MY_NABPcxx . . $ `include/my_sys.h:55:9`!)))
478 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
479 }
480 }
481 /* We now have one less deleted block */
482 info->statecxx . . $ st_myisam_info#state.->delcxx . . $ st_mi_status_info#del.--;
483 info->statecxx . . $ st_myisam_info#state.->emptycxx . . $ st_mi_status_info#empty.-= block_info->block_lencxx . . $ st_mi_block_info#block_len.;
484 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..splitcxx . . $ st_mi_state_info#split.--;
485
486 /*
487 If this was a block that we where accessing through table scan
488 (mi_rrnd() or mi_scan(), then ensure that we skip over this block
489 when doing next mi_rrnd() or mi_scan().
490 */
491 if (info->nextposcxx . . $ st_myisam_info#nextpos. == block_info->fileposcxx . . $ st_mi_block_info#filepos.)
492 info->nextposcxx . . $ st_myisam_info#nextpos.+=block_info->block_lencxx . . $ st_mi_block_info#block_len.;
493 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
494 }
495
496
497 /*
498 Add a backward link to delete block
499
500 SYNOPSIS
501 update_backward_delete_link()
502 info MyISAM handler
503 delete_block Position to delete block to update.
504 If this is 'HA_OFFSET_ERROR', nothing will be done
505 filepos Position to block that 'delete_block' should point to
506
507 RETURN
508 0 ok
509 1 error. In this case my_error is set.
510 */
511
512 static int update_backward_delete_linkcxx . . $ update_backward_delete_link(81381df052d4d2d5).(MI_INFOcxx . . $ MI_INFO# *info, my_off_tcxx . . $ my_off_t# delete_block,
513 my_off_tcxx . . $ my_off_t# filepos)
514 {
515 MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# block_info;
516 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("update_backward_delete_link");
517
518 if (delete_block != HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!)
519 {
520 block_info.second_readcxx . . $ st_mi_block_info#second_read.=0;
521 if (_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&block_info,info->dfilecxx . . $ st_myisam_info#dfile.,delete_block)
522 & BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`!)
523 {
524 ucharcxx . . $ uchar# buff[8];
525 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!(buff,filepos);
526 if (info->scxx . . $ st_myisam_info#s.->file_writecxx . . $ st_mi_isam_share#file_write.(info,buff, 8, delete_block+12, MYFcxx . . $ `include/my_global.h:986:9`!(MY_NABPcxx . . $ `include/my_sys.h:55:9`!)))
527 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1); /* Error on write */
528 }
529 else
530 {
531 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!;
532 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1); /* Wrong delete link */
533 }
534 }
535 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
536 }
537
538 /* Delete datarecord from database */
539 /* info->rec_cache.seek_not_done is updated in cmp_record */
540
541 static int delete_dynamic_recordcxx . . $ delete_dynamic_record(2fec77617b780741).(MI_INFOcxx . . $ MI_INFO# *info, my_off_tcxx . . $ my_off_t# filepos,
542 uintcxx . . $ uint# second_read)
543 {
544 uintcxx . . $ uint# length,b_type;
545 MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# block_info,del_block;
546 int error;
547 my_boolcxx . . $ my_bool# remove_next_block;
548 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("delete_dynamic_record");
549
550 /* First add a link from the last block to the new one */
551 error= update_backward_delete_linkcxx . . $ update_backward_delete_link(81381df052d4d2d5).(info, info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink., filepos);
552
553 block_info.second_readcxx . . $ st_mi_block_info#second_read.=second_read;
554 do
555 {
556 /* Remove block at 'filepos' */
557 if ((b_type=_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&block_info,info->dfilecxx . . $ st_myisam_info#dfile.,filepos))
558 & (BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`! | BLOCK_ERRORcxx . . $ `storage/myisam/myisamdef.h:639:9`! | BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`! |
559 BLOCK_FATAL_ERRORcxx . . $ `storage/myisam/myisamdef.h:641:9`!) ||
560 (length=(uintcxx . . $ uint#) (block_info.fileposcxx . . $ st_mi_block_info#filepos.-filepos) +block_info.block_lencxx . . $ st_mi_block_info#block_len.) <
561 MI_MIN_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:389:9`!)
562 {
563 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!;
564 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
565 }
566 /* Check if next block is a delete block */
567 del_block.second_readcxx . . $ st_mi_block_info#second_read.=0;
568 remove_next_block=0;
569 if (_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&del_block,info->dfilecxx . . $ st_myisam_info#dfile.,filepos+length) &
570 BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`! && del_block.block_lencxx . . $ st_mi_block_info#block_len.+length < MI_DYN_MAX_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:395:9`!)
571 {
572 /* We can't remove this yet as this block may be the head block */
573 remove_next_block=1;
574 length+=del_block.block_lencxx . . $ st_mi_block_info#block_len.;
575 }
576
577 block_info.headercxx . . $ st_mi_block_info#header.[0]=0;
578 mi_int3storecxx . . $ `include/myisampack.h:104:9`!(block_info.header+1,length);
579 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!(block_info.header+4,info->s->state.dellink);
580 if (b_type & BLOCK_LASTcxx . . $ `storage/myisam/myisamdef.h:637:9`!)
581 bfillcxx . . $ `include/m_string.h:53:10`!(block_info.header+12,8,255);
582 else
583 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!(block_info.header+12,block_info.next_filepos);
584 if (info->scxx . . $ st_myisam_info#s.->file_writecxx . . $ st_mi_isam_share#file_write.(info,(ucharcxx . . $ uchar#*) block_info.headercxx . . $ st_mi_block_info#header.,20,filepos,
585 MYFcxx . . $ `include/my_global.h:986:9`!(MY_NABPcxx . . $ `include/my_sys.h:55:9`!)))
586 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
587 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink. = filepos;
588 info->statecxx . . $ st_myisam_info#state.->delcxx . . $ st_mi_status_info#del.++;
589 info->statecxx . . $ st_myisam_info#state.->emptycxx . . $ st_mi_status_info#empty.+=length;
590 filepos=block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos.;
591
592 /* Now it's safe to unlink the deleted block directly after this one */
593 if (remove_next_block && unlink_deleted_blockcxx . . $ unlink_deleted_block(44c85a7ef039a80c).(info,&del_block))
594 error=1;
595 } while (!(b_type & BLOCK_LASTcxx . . $ `storage/myisam/myisamdef.h:637:9`!));
596
597 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(error);
598 }
599
600
601 /* Write a block to datafile */
602
603 int _mi_write_part_recordcxx . . $ _mi_write_part_record(34e55845d0b95b9).(MI_INFOcxx . . $ MI_INFO# *info,
604 my_off_tcxx . . $ my_off_t# filepos, /* points at empty block */
605 ulongcxx . . $ ulong# length, /* length of block */
606 my_off_tcxx . . $ my_off_t# next_filepos,/* Next empty block */
607 ucharcxx . . $ uchar# **record, /* pointer to record ptr */
608 ulongcxx . . $ ulong# *reclength, /* length of *record */
609 int *flag) /* *flag == 0 if header */
610 {
611 ulongcxx . . $ ulong# head_length,res_length,extra_length,long_block,del_length;
612 ucharcxx . . $ uchar# *pos,*record_end;
613 my_off_tcxx . . $ my_off_t# next_delete_block;
614 ucharcxx . . $ uchar# temp[MI_SPLIT_LENGTHcxx . . $ `storage/myisam/myisamdef.h:391:9`!+MI_DYN_DELETE_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:394:9`!];
615 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_mi_write_part_record");
616
617 next_delete_block=HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!;
618
619 res_length=extra_length=0;
620 if (length > *reclength + MI_SPLIT_LENGTHcxx . . $ `storage/myisam/myisamdef.h:391:9`!)
621 { /* Splitt big block */
622 res_length=MY_ALIGNcxx . . $ `include/my_global.h:821:9`!(length- *reclength - MI_EXTEND_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:390:9`!,
623 MI_DYN_ALIGN_SIZEcxx . . $ `storage/myisam/myisamdef.h:397:9`!);
624 length-= res_length; /* Use this for first part */
625 }
626 long_block= (length < 65520L && *reclength < 65520L) ? 0 : 1;
627 if (length == *reclength+ 3 + long_block)
628 {
629 /* Block is exactly of the right length */
630 temp[0]=(ucharcxx . . $ uchar#) (1+ *flag)+(ucharcxx . . $ uchar#) long_block; /* Flag is 0 or 6 */
631 if (long_block)
632 {
633 mi_int3storecxx . . $ `include/myisampack.h:104:9`!(temp+1,*reclength);
634 head_length=4;
635 }
636 else
637 {
638 mi_int2storecxx . . $ `include/myisampack.h:101:9`!(temp+1,*reclength);
639 head_length=3;
640 }
641 }
642 else if (length-long_block < *reclength+4)
643 { /* To short block */
644 if (next_filepos == HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!)
645 next_filepos= (info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink. != HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`! &&
646 !info->append_insert_at_endcxx . . $ st_myisam_info#append_insert_at_end. ?
647 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink. : info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length.);
648 if (*flag == 0) /* First block */
649 {
650 if (*reclength > MI_MAX_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:399:9`!)
651 {
652 head_length= 16;
653 temp[0]=13;
654 mi_int4storecxx . . $ `include/myisampack.h:110:9`!(temp+1,*reclength);
655 mi_int3storecxx . . $ `include/myisampack.h:104:9`!(temp+5,length-head_length);
656 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!((uchar*) temp+8,next_filepos);
657 }
658 else
659 {
660 head_length=5+8+long_block*2;
661 temp[0]=5+(ucharcxx . . $ uchar#) long_block;
662 if (long_block)
663 {
664 mi_int3storecxx . . $ `include/myisampack.h:104:9`!(temp+1,*reclength);
665 mi_int3storecxx . . $ `include/myisampack.h:104:9`!(temp+4,length-head_length);
666 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!((uchar*) temp+7,next_filepos);
667 }
668 else
669 {
670 mi_int2storecxx . . $ `include/myisampack.h:101:9`!(temp+1,*reclength);
671 mi_int2storecxx . . $ `include/myisampack.h:101:9`!(temp+3,length-head_length);
672 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!((uchar*) temp+5,next_filepos);
673 }
674 }
675 }
676 else
677 {
678 head_length=3+8+long_block;
679 temp[0]=11+(ucharcxx . . $ uchar#) long_block;
680 if (long_block)
681 {
682 mi_int3storecxx . . $ `include/myisampack.h:104:9`!(temp+1,length-head_length);
683 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!((uchar*) temp+4,next_filepos);
684 }
685 else
686 {
687 mi_int2storecxx . . $ `include/myisampack.h:101:9`!(temp+1,length-head_length);
688 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!((uchar*) temp+3,next_filepos);
689 }
690 }
691 }
692 else
693 { /* Block with empty info last */
694 head_length=4+long_block;
695 extra_length= length- *reclength-head_length;
696 temp[0]= (ucharcxx . . $ uchar#) (3+ *flag)+(ucharcxx . . $ uchar#) long_block; /* 3,4 or 9,10 */
697 if (long_block)
698 {
699 mi_int3storecxx . . $ `include/myisampack.h:104:9`!(temp+1,*reclength);
700 temp[4]= (ucharcxx . . $ uchar#) (extra_length);
701 }
702 else
703 {
704 mi_int2storecxx . . $ `include/myisampack.h:101:9`!(temp+1,*reclength);
705 temp[3]= (ucharcxx . . $ uchar#) (extra_length);
706 }
707 length= *reclength+head_length; /* Write only what is needed */
708 }
709 DBUG_DUMPcxx . . $ `include/my_dbug.h:182:9`!("header",(uchar*) temp,head_length);
710
711 /* Make a long block for one write */
712 record_end= *record+length-head_length;
713 del_length=(res_length ? MI_DYN_DELETE_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:394:9`! : 0);
714 bmovecxx . . $ `include/m_string.h:48:10`!((uchar*) (*record-head_length),(uchar*) temp,head_length);
715 memcpycxx . . $ memcpy(cc817cb175f282d).(temp,record_end,(size_t) (extra_length+del_length));
716 bzerocxx . . $ `include/m_string.h:61:10`!((uchar*) record_end,extra_length);
717
718 if (res_length)
719 {
720 /* Check first if we can join this block with the next one */
721 MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# del_block;
722 my_off_tcxx . . $ my_off_t# next_block=filepos+length+extra_length+res_length;
723
724 del_block.second_readcxx . . $ st_mi_block_info#second_read.=0;
725 if (next_block < info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length. &&
726 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink. != HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!)
727 {
728 if ((_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&del_block,info->dfilecxx . . $ st_myisam_info#dfile.,next_block)
729 & BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`!) &&
730 res_length + del_block.block_lencxx . . $ st_mi_block_info#block_len. < MI_DYN_MAX_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:395:9`!)
731 {
732 if (unlink_deleted_blockcxx . . $ unlink_deleted_block(44c85a7ef039a80c).(info,&del_block))
733 goto err;
734 res_length+=del_block.block_lencxx . . $ st_mi_block_info#block_len.;
735 }
736 }
737
738 /* Create a delete link of the last part of the block */
739 pos=record_end+extra_length;
740 pos[0]= '\0';
741 mi_int3storecxx . . $ `include/myisampack.h:104:9`!(pos+1,res_length);
742 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!(pos+4,info->s->state.dellink);
743 bfillcxx . . $ `include/m_string.h:53:10`!(pos+12,8,255); /* End link */
744 next_delete_block=info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.;
745 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.= filepos+length+extra_length;
746 info->statecxx . . $ st_myisam_info#state.->delcxx . . $ st_mi_status_info#del.++;
747 info->statecxx . . $ st_myisam_info#state.->emptycxx . . $ st_mi_status_info#empty.+=res_length;
748 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..splitcxx . . $ st_mi_state_info#split.++;
749 }
750 if (info->opt_flagcxx . . $ st_myisam_info#opt_flag. & WRITE_CACHE_USEDcxx . . $ `include/my_base.h:613:9`! &&
751 info->updatecxx . . $ st_myisam_info#update. & HA_STATE_WRITE_AT_ENDcxx . . $ `include/my_base.h:625:9`!)
752 {
753 if (info->updatecxx . . $ st_myisam_info#update. & HA_STATE_EXTEND_BLOCKcxx . . $ `include/my_base.h:628:9`!)
754 {
755 info->updatecxx . . $ st_myisam_info#update.&= ~HA_STATE_EXTEND_BLOCKcxx . . $ `include/my_base.h:628:9`!;
756 if (my_block_writecxx . . $ my_block_write(a747af7d2e024992).(&info->rec_cachecxx . . $ st_myisam_info#rec_cache.,(ucharcxx . . $ uchar#*) *record-head_length,
757 length+extra_length+del_length,filepos))
758 goto err;
759 }
760 else if (my_b_writecxx . . $ my_b_write(3ec748bd5b0960c7).(&info->rec_cachecxx . . $ st_myisam_info#rec_cache.,(ucharcxx . . $ uchar#*) *record-head_length,
761 length+extra_length+del_length))
762 goto err;
763 }
764 else
765 {
766 info->rec_cachecxx . . $ st_myisam_info#rec_cache..seek_not_donecxx . . $ st_io_cache#seek_not_done.=1;
767 if (info->scxx . . $ st_myisam_info#s.->file_writecxx . . $ st_mi_isam_share#file_write.(info,(ucharcxx . . $ uchar#*) *record-head_length,length+extra_length+
768 del_length,filepos,info->scxx . . $ st_myisam_info#s.->write_flagcxx . . $ st_mi_isam_share#write_flag.))
769 goto err;
770 }
771 memcpycxx . . $ memcpy(cc817cb175f282d).(record_end,temp,(size_t) (extra_length+del_length));
772 *record=record_end;
773 *reclength-=(length-head_length);
774 *flag=6;
775
776 if (del_length)
777 {
778 /* link the next delete block to this */
779 if (update_backward_delete_linkcxx . . $ update_backward_delete_link(81381df052d4d2d5).(info, next_delete_block,
780 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.))
781 goto err;
782 }
783
784 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
785 err:
786 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("exit",("errno: %d",my_errno));
787 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
788 } /*_mi_write_part_record */
789
790
791 /* update record from datafile */
792
793 static int update_dynamic_recordcxx . . $ update_dynamic_record(4cf11700df929283).(MI_INFOcxx . . $ MI_INFO# *info, my_off_tcxx . . $ my_off_t# filepos, ucharcxx . . $ uchar# *record,
794 ulongcxx . . $ ulong# reclength)
795 {
796 int flag;
797 uintcxx . . $ uint# error;
798 ulongcxx . . $ ulong# length;
799 MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# block_info;
800 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("update_dynamic_record");
801
802 flag=block_info.second_readcxx . . $ st_mi_block_info#second_read.=0;
803 /*
804 Check if we have enough room for the record.
805 First we do simplified check to make usual case faster.
806 Then we do more precise check for the space left.
807 Though it still is not absolutely precise, as
808 we always use MI_MAX_DYN_BLOCK_HEADER while it can be
809 less in the most of the cases.
810 */
811
812 /*
813 compare with just the reclength as we're going
814 to get some space from the old replaced record
815 */
816 if (unlikelycxx . . $ `include/my_global.h:361:9`!(info->s->base.max_data_file_length -
817 info->state->data_file_length < reclength))
818 {
819 /*
820 let's read the old record's block to find out the length of the
821 old record
822 */
823 if ((error=_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&block_info,info->dfilecxx . . $ st_myisam_info#dfile.,filepos))
824 & (BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`! | BLOCK_ERRORcxx . . $ `storage/myisam/myisamdef.h:639:9`! | BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`! | BLOCK_FATAL_ERRORcxx . . $ `storage/myisam/myisamdef.h:641:9`!))
825 {
826 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error",("Got wrong block info"));
827 if (!(error & BLOCK_FATAL_ERRORcxx . . $ `storage/myisam/myisamdef.h:641:9`!))
828 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!;
829 goto err;
830 }
831
832 /*
833 if new record isn't longer, we can go on safely
834 */
835 if (block_info.rec_lencxx . . $ st_mi_block_info#rec_len. < reclength)
836 {
837 if (info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..max_data_file_lengthcxx . . $ st_mi_base_info#max_data_file_length. - info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length. +
838 info->statecxx . . $ st_myisam_info#state.->emptycxx . . $ st_mi_status_info#empty. - info->statecxx . . $ st_myisam_info#state.->delcxx . . $ st_mi_status_info#del. * MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`! <
839 reclength - block_info.rec_lencxx . . $ st_mi_block_info#rec_len. + MI_MAX_DYN_BLOCK_HEADERcxx . . $ `storage/myisam/myisamdef.h:392:9`!)
840 {
841 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_RECORD_FILE_FULLcxx . . $ `include/my_base.h:480:9`!;
842 goto err;
843 }
844 }
845 block_info.second_readcxx . . $ st_mi_block_info#second_read.=0;
846 }
847
848 while (reclength > 0)
849 {
850 if (filepos != info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.)
851 {
852 block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos.= HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!;
853 if ((error=_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&block_info,info->dfilecxx . . $ st_myisam_info#dfile.,filepos))
854 & (BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`! | BLOCK_ERRORcxx . . $ `storage/myisam/myisamdef.h:639:9`! | BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`! |
855 BLOCK_FATAL_ERRORcxx . . $ `storage/myisam/myisamdef.h:641:9`!))
856 {
857 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error",("Got wrong block info"));
858 if (!(error & BLOCK_FATAL_ERRORcxx . . $ `storage/myisam/myisamdef.h:641:9`!))
859 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!;
860 goto err;
861 }
862 length=(ulongcxx . . $ ulong#) (block_info.fileposcxx . . $ st_mi_block_info#filepos.-filepos) + block_info.block_lencxx . . $ st_mi_block_info#block_len.;
863 if (length < reclength)
864 {
865 uintcxx . . $ uint# tmp=MY_ALIGNcxx . . $ `include/my_global.h:821:9`!(reclength - length + 3 +
866 MY_TESTcxx . . $ `include/my_global.h:467:9`!(reclength >= 65520L), MI_DYN_ALIGN_SIZEcxx . . $ `storage/myisam/myisamdef.h:397:9`!);
867 /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
868 tmp= MY_MINcxx . . $ `include/my_global.h:1108:9`!(length+tmp, MI_MAX_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:399:9`!)-length;
869 /* Check if we can extend this block */
870 if (block_info.fileposcxx . . $ st_mi_block_info#filepos. + block_info.block_lencxx . . $ st_mi_block_info#block_len. ==
871 info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length. &&
872 info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length. <
873 info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..max_data_file_lengthcxx . . $ st_mi_base_info#max_data_file_length.-tmp)
874 {
875 /* extend file */
876 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info",("Extending file with %d bytes",tmp));
877 if (info->nextposcxx . . $ st_myisam_info#nextpos. == info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length.)
878 info->nextposcxx . . $ st_myisam_info#nextpos.+= tmp;
879 info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length.+= tmp;
880 info->updatecxx . . $ st_myisam_info#update.|= HA_STATE_WRITE_AT_ENDcxx . . $ `include/my_base.h:625:9`! | HA_STATE_EXTEND_BLOCKcxx . . $ `include/my_base.h:628:9`!;
881 length+=tmp;
882 }
883 else if (length < MI_MAX_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:399:9`! - MI_MIN_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:389:9`!)
884 {
885 /*
886 Check if next block is a deleted block
887 Above we have MI_MIN_BLOCK_LENGTH to avoid the problem where
888 the next block is so small it can't be split which could
889 cause problems
890 */
891
892 MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# del_block;
893 del_block.second_readcxx . . $ st_mi_block_info#second_read.=0;
894 if (_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&del_block,info->dfilecxx . . $ st_myisam_info#dfile.,
895 block_info.fileposcxx . . $ st_mi_block_info#filepos. + block_info.block_lencxx . . $ st_mi_block_info#block_len.) &
896 BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`!)
897 {
898 /* Use; Unlink it and extend the current block */
899 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info",("Extending current block"));
900 if (unlink_deleted_blockcxx . . $ unlink_deleted_block(44c85a7ef039a80c).(info,&del_block))
901 goto err;
902 if ((length+=del_block.block_lencxx . . $ st_mi_block_info#block_len.) > MI_MAX_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:399:9`!)
903 {
904 /*
905 New block was too big, link overflow part back to
906 delete list
907 */
908 my_off_tcxx . . $ my_off_t# next_pos;
909 ulongcxx . . $ ulong# rest_length= length-MI_MAX_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:399:9`!;
910 set_if_biggercxx . . $ `include/my_global.h:468:9`!(rest_length, MI_MIN_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:389:9`!);
911 next_pos= del_block.fileposcxx . . $ st_mi_block_info#filepos.+ del_block.block_lencxx . . $ st_mi_block_info#block_len. - rest_length;
912
913 if (update_backward_delete_linkcxx . . $ update_backward_delete_link(81381df052d4d2d5).(info, info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.,
914 next_pos))
915 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
916
917 /* create delete link for data that didn't fit into the page */
918 del_block.headercxx . . $ st_mi_block_info#header.[0]=0;
919 mi_int3storecxx . . $ `include/myisampack.h:104:9`!(del_block.header+1, rest_length);
920 mi_sizestorecxx . . $ `include/myisampack.h:241:9`!(del_block.header+4,info->s->state.dellink);
921 bfillcxx . . $ `include/m_string.h:53:10`!(del_block.header+12,8,255);
922 if (info->scxx . . $ st_myisam_info#s.->file_writecxx . . $ st_mi_isam_share#file_write.(info,(ucharcxx . . $ uchar#*) del_block.headercxx . . $ st_mi_block_info#header.,20, next_pos,
923 MYFcxx . . $ `include/my_global.h:986:9`!(MY_NABPcxx . . $ `include/my_sys.h:55:9`!)))
924 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
925 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.= next_pos;
926 info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..splitcxx . . $ st_mi_state_info#split.++;
927 info->statecxx . . $ st_myisam_info#state.->delcxx . . $ st_mi_status_info#del.++;
928 info->statecxx . . $ st_myisam_info#state.->emptycxx . . $ st_mi_status_info#empty.+= rest_length;
929 length-= rest_length;
930 }
931 }
932 }
933 }
934 }
935 else
936 {
937 if (_mi_find_writeposcxx . . $ _mi_find_writepos(1255bdaa5fb127f8).(info,reclength,&filepos,&length))
938 goto err;
939 }
940 if (_mi_write_part_recordcxx . . $ _mi_write_part_record(34e55845d0b95b9).(info,filepos,length,block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos.,
941 &record,&reclength,&flag))
942 goto err;
943 if ((filepos=block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos.) == HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!)
944 {
945 /* Start writing data on deleted blocks */
946 filepos=info->scxx . . $ st_myisam_info#s.->statecxx . . $ st_mi_isam_share#state..dellinkcxx . . $ st_mi_state_info#dellink.;
947 }
948 }
949
950 if (block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos. != HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!)
951 {
952 /*
953 delete_dynamic_record() may change data file position.
954 IO cache must be notified as it may still have cached
955 data, which has to be flushed later.
956 */
957 info->rec_cachecxx . . $ st_myisam_info#rec_cache..seek_not_donecxx . . $ st_io_cache#seek_not_done.= 1;
958 if (delete_dynamic_recordcxx . . $ delete_dynamic_record(2fec77617b780741).(info,block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos.,1))
959 goto err;
960 }
961 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
962 err:
963 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
964 }
965
966
967 /* Pack a record. Return new reclength */
968
969 uintcxx . . $ uint# _mi_rec_packcxx . . $ _mi_rec_pack(92d72fbc6a90c214).(MI_INFOcxx . . $ MI_INFO# *info, register ucharcxx . . $ uchar# *to,
970 register const ucharcxx . . $ uchar# *from)
971 {
972 uintcxx . . $ uint# length,new_length,flag,bit,i;
973 ucharcxx . . $ uchar# *pos,*end,*startpos,*packpos;
974 enum en_fieldtypecxx . . $ en_fieldtype# type;
975 reg3cxx . . $ `include/my_global.h:995:9`! MI_COLUMNDEFcxx . . $ MI_COLUMNDEF# *rec;
976 MI_BLOBcxx . . $ MI_BLOB# *blob;
977 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_mi_rec_pack");
978
979 flag=0 ; bit=1;
980 startpos=packpos=to; to+= info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..pack_bitscxx . . $ st_mi_base_info#pack_bits.; blob=info->blobscxx . . $ st_myisam_info#blobs.;
981 rec=info->scxx . . $ st_myisam_info#s.->reccxx . . $ st_mi_isam_share#rec.;
982
983 for (i=info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..fieldscxx . . $ st_mi_base_info#fields. ; i-- > 0; from+= length,rec++)
984 {
985 length=(uintcxx . . $ uint#) rec->lengthcxx . . $ st_columndef#length.;
986 if ((type = (enum en_fieldtypecxx . . $ en_fieldtype#) rec->typecxx . . $ st_columndef#type.) != FIELD_NORMALcxx . . $ FIELD_NORMAL.)
987 {
988 if (type == FIELD_BLOBcxx . . $ FIELD_BLOB.)
989 {
990 if (!blob->lengthcxx . . $ st_mi_blob#length.)
991 flag|=bit;
992 else
993 {
994 char *temp_pos;
995 size_t tmp_length=length-portable_sizeof_char_ptrcxx . . $ `include/my_compare.h:252:9`!;
996 memcpycxx . . $ memcpy(cc817cb175f282d).((ucharcxx . . $ uchar#*) to,from,tmp_length);
997 memcpycxx . . $ memcpy(cc817cb175f282d).(&temp_pos,from+tmp_length,sizeof(char*));
998 memcpycxx . . $ memcpy(cc817cb175f282d).(to+tmp_length,temp_pos,(size_t) blob->lengthcxx . . $ st_mi_blob#length.);
999 to+=tmp_length+blob->lengthcxx . . $ st_mi_blob#length.;
1000 }
1001 blob++;
1002 }
1003 else if (type == FIELD_SKIP_ZEROcxx . . $ FIELD_SKIP_ZERO.)
1004 {
1005 if (memcmpcxx . . $ memcmp(36f949851efa3055).((ucharcxx . . $ uchar#*) from,zero_stringcxx . . $ zero_string.,length) == 0)
1006 flag|=bit;
1007 else
1008 {
1009 memcpycxx . . $ memcpy(cc817cb175f282d).((ucharcxx . . $ uchar#*) to,from,(size_t) length); to+=length;
1010 }
1011 }
1012 else if (type == FIELD_SKIP_ENDSPACEcxx . . $ FIELD_SKIP_ENDSPACE. ||
1013 type == FIELD_SKIP_PRESPACEcxx . . $ FIELD_SKIP_PRESPACE.)
1014 {
1015 pos= (ucharcxx . . $ uchar#*) from; end= (ucharcxx . . $ uchar#*) from + length;
1016 if (type == FIELD_SKIP_ENDSPACEcxx . . $ FIELD_SKIP_ENDSPACE.)
1017 { /* Pack trailing spaces */
1018 while (end > from && *(end-1) == ' ')
1019 end--;
1020 }
1021 else
1022 { /* Pack pref-spaces */
1023 while (pos < end && *pos == ' ')
1024 pos++;
1025 }
1026 new_length=(uintcxx . . $ uint#) (end-pos);
1027 if (new_length + 1 + MY_TESTcxx . . $ `include/my_global.h:467:9`!(rec->length > 255 && new_length > 127)
1028 < length)
1029 {
1030 if (rec->lengthcxx . . $ st_columndef#length. > 255 && new_length > 127)
1031 {
1032 to[0]= (ucharcxx . . $ uchar#) ((new_length & 127) + 128);
1033 to[1]= (ucharcxx . . $ uchar#) (new_length >> 7);
1034 to+=2;
1035 }
1036 else
1037 *to++= (ucharcxx . . $ uchar#) new_length;
1038 memcpycxx . . $ memcpy(cc817cb175f282d).((ucharcxx . . $ uchar#*) to,pos,(size_t) new_length); to+=new_length;
1039 flag|=bit;
1040 }
1041 else
1042 {
1043 memcpycxx . . $ memcpy(cc817cb175f282d).(to,from,(size_t) length); to+=length;
1044 }
1045 }
1046 else if (type == FIELD_VARCHARcxx . . $ FIELD_VARCHAR.)
1047 {
1048 uintcxx . . $ uint# pack_length= HA_VARCHAR_PACKLENGTHcxx . . $ `include/my_base.h:704:9`!(rec->length -1);
1049 uintcxx . . $ uint# tmp_length;
1050 if (pack_length == 1)
1051 {
1052 tmp_length= (uintcxx . . $ uint#) *(ucharcxx . . $ uchar#*) from;
1053 *to++= *from;
1054 }
1055 else
1056 {
1057 tmp_length= uint2korrcxx . . $ uint2korr(533a9de78501ce46).(from);
1058 store_key_length_inccxx . . $ `include/my_compare.h:85:9`!(to,tmp_length);
1059 }
1060 memcpycxx . . $ memcpy(cc817cb175f282d).(to, from+pack_length,tmp_length);
1061 to+= tmp_length;
1062 continue;
1063 }
1064 else
1065 {
1066 memcpycxx . . $ memcpy(cc817cb175f282d).(to,from,(size_t) length); to+=length;
1067 continue; /* Normal field */
1068 }
1069 if ((bit= bit << 1) >= 256)
1070 {
1071 *packpos++= (ucharcxx . . $ uchar#) flag;
1072 bit=1; flag=0;
1073 }
1074 }
1075 else
1076 {
1077 memcpycxx . . $ memcpy(cc817cb175f282d).(to,from,(size_t) length); to+=length;
1078 }
1079 }
1080 if (bit != 1)
1081 *packpos= (ucharcxx . . $ uchar#) flag;
1082 if (info->scxx . . $ st_myisam_info#s.->calc_checksumcxx . . $ st_mi_isam_share#calc_checksum.)
1083 *to++= (ucharcxx . . $ uchar#) info->checksumcxx . . $ st_myisam_info#checksum.;
1084 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("exit",("packed length: %d",(int) (to-startpos)));
1085 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!((uint) (to-startpos));
1086 } /* _mi_rec_pack */
1087
1088
1089
1090 /*
1091 Check if a record was correctly packed. Used only by myisamchk
1092 Returns 0 if record is ok.
1093 */
1094
1095 my_boolcxx . . $ my_bool# _mi_rec_checkcxx . . $ _mi_rec_check(8bac5ad3620c2e47).(MI_INFOcxx . . $ MI_INFO# *info,const ucharcxx . . $ uchar# *record, ucharcxx . . $ uchar# *rec_buff,
1096 ulongcxx . . $ ulong# packed_length, my_boolcxx . . $ my_bool# with_checksum)
1097 {
1098 uintcxx . . $ uint# length,new_length,flag,bit,i;
1099 ucharcxx . . $ uchar# *pos,*end,*packpos,*to;
1100 enum en_fieldtypecxx . . $ en_fieldtype# type;
1101 reg3cxx . . $ `include/my_global.h:995:9`! MI_COLUMNDEFcxx . . $ MI_COLUMNDEF# *rec;
1102 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_mi_rec_check");
1103
1104 packpos=rec_buff; to= rec_buff+info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..pack_bitscxx . . $ st_mi_base_info#pack_bits.;
1105 rec=info->scxx . . $ st_myisam_info#s.->reccxx . . $ st_mi_isam_share#rec.;
1106 flag= *packpos; bit=1;
1107
1108 for (i=info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..fieldscxx . . $ st_mi_base_info#fields. ; i-- > 0; record+= length, rec++)
1109 {
1110 length=(uintcxx . . $ uint#) rec->lengthcxx . . $ st_columndef#length.;
1111 if ((type = (enum en_fieldtypecxx . . $ en_fieldtype#) rec->typecxx . . $ st_columndef#type.) != FIELD_NORMALcxx . . $ FIELD_NORMAL.)
1112 {
1113 if (type == FIELD_BLOBcxx . . $ FIELD_BLOB.)
1114 {
1115 uintcxx . . $ uint# blob_length=
1116 _mi_calc_blob_lengthcxx . . $ _mi_calc_blob_length(3cbac61846b0ebe9).(length-portable_sizeof_char_ptrcxx . . $ `include/my_compare.h:252:9`!,record);
1117 if (!blob_length && !(flag & bit))
1118 goto err;
1119 if (blob_length)
1120 to+=length - portable_sizeof_char_ptrcxx . . $ `include/my_compare.h:252:9`!+ blob_length;
1121 }
1122 else if (type == FIELD_SKIP_ZEROcxx . . $ FIELD_SKIP_ZERO.)
1123 {
1124 if (memcmpcxx . . $ memcmp(36f949851efa3055).((ucharcxx . . $ uchar#*) record,zero_stringcxx . . $ zero_string.,length) == 0)
1125 {
1126 if (!(flag & bit))
1127 goto err;
1128 }
1129 else
1130 to+=length;
1131 }
1132 else if (type == FIELD_SKIP_ENDSPACEcxx . . $ FIELD_SKIP_ENDSPACE. ||
1133 type == FIELD_SKIP_PRESPACEcxx . . $ FIELD_SKIP_PRESPACE.)
1134 {
1135 pos= (ucharcxx . . $ uchar#*) record; end= (ucharcxx . . $ uchar#*) record + length;
1136 if (type == FIELD_SKIP_ENDSPACEcxx . . $ FIELD_SKIP_ENDSPACE.)
1137 { /* Pack trailing spaces */
1138 while (end > record && *(end-1) == ' ')
1139 end--;
1140 }
1141 else
1142 { /* Pack pre-spaces */
1143 while (pos < end && *pos == ' ')
1144 pos++;
1145 }
1146 new_length=(uintcxx . . $ uint#) (end-pos);
1147 if (new_length + 1 + MY_TESTcxx . . $ `include/my_global.h:467:9`!(rec->length > 255 && new_length > 127)
1148 < length)
1149 {
1150 if (!(flag & bit))
1151 goto err;
1152 if (rec->lengthcxx . . $ st_columndef#length. > 255 && new_length > 127)
1153 {
1154 /* purecov: begin inspected */
1155 if (to[0] != (ucharcxx . . $ uchar#) ((new_length & 127) + 128) ||
1156 to[1] != (ucharcxx . . $ uchar#) (new_length >> 7))
1157 goto err;
1158 to+=2;
1159 /* purecov: end */
1160 }
1161 else if (*to++ != (ucharcxx . . $ uchar#) new_length)
1162 goto err;
1163 to+=new_length;
1164 }
1165 else
1166 to+=length;
1167 }
1168 else if (type == FIELD_VARCHARcxx . . $ FIELD_VARCHAR.)
1169 {
1170 uintcxx . . $ uint# pack_length= HA_VARCHAR_PACKLENGTHcxx . . $ `include/my_base.h:704:9`!(rec->length -1);
1171 uintcxx . . $ uint# tmp_length;
1172 if (pack_length == 1)
1173 {
1174 tmp_length= (uintcxx . . $ uint#) *(ucharcxx . . $ uchar#*) record;
1175 to+= 1+ tmp_length;
1176 continue;
1177 }
1178 else
1179 {
1180 tmp_length= uint2korrcxx . . $ uint2korr(533a9de78501ce46).(record);
1181 to+= get_pack_lengthcxx . . $ `storage/myisam/myisamdef.h:387:9`!(tmp_length)+tmp_length;
1182 }
1183 continue;
1184 }
1185 else
1186 {
1187 to+=length;
1188 continue; /* Normal field */
1189 }
1190 if ((bit= bit << 1) >= 256)
1191 {
1192 flag= *++packpos;
1193 bit=1;
1194 }
1195 }
1196 else
1197 to+= length;
1198 }
1199 if (packed_length != (uintcxx . . $ uint#) (to - rec_buff) + MY_TESTcxx . . $ `include/my_global.h:467:9`!(info->s->calc_checksum) ||
1200 (bit != 1 && (flag & ~(bit - 1))))
1201 goto err;
1202 if (with_checksum && ((ucharcxx . . $ uchar#) info->checksumcxx . . $ st_myisam_info#checksum. != (ucharcxx . . $ uchar#) *to))
1203 {
1204 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error",("wrong checksum for row"));
1205 goto err;
1206 }
1207 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
1208
1209 err:
1210 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
1211 }
1212
1213
1214
1215 /* Unpacks a record */
1216 /* Returns -1 and my_errno =HA_ERR_RECORD_DELETED if reclength isn't */
1217 /* right. Returns reclength (>0) if ok */
1218
1219 size_t _mi_rec_unpackcxx . . $ _mi_rec_unpack(f9f31885b079ea9b).(register MI_INFOcxx . . $ MI_INFO# *info, register ucharcxx . . $ uchar# *to, ucharcxx . . $ uchar# *from,
1220 ulongcxx . . $ ulong# found_length)
1221 {
1222 uintcxx . . $ uint# flag,bit,length,rec_length,min_pack_length;
1223 enum en_fieldtypecxx . . $ en_fieldtype# type;
1224 ucharcxx . . $ uchar# *from_end,*to_end,*packpos;
1225 reg3cxx . . $ `include/my_global.h:995:9`! MI_COLUMNDEFcxx . . $ MI_COLUMNDEF# *rec,*end_field;
1226 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_mi_rec_unpack");
1227
1228 to_end=to + info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..reclengthcxx . . $ st_mi_base_info#reclength.;
1229 from_end=from+found_length;
1230 flag= (ucharcxx . . $ uchar#) *from; bit=1; packpos=from;
1231 if (found_length < info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..min_pack_lengthcxx . . $ st_mi_base_info#min_pack_length.)
1232 goto err;
1233 from+= info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..pack_bitscxx . . $ st_mi_base_info#pack_bits.;
1234 min_pack_length=info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..min_pack_lengthcxx . . $ st_mi_base_info#min_pack_length. - info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..pack_bitscxx . . $ st_mi_base_info#pack_bits.;
1235
1236 for (rec=info->scxx . . $ st_myisam_info#s.->reccxx . . $ st_mi_isam_share#rec. , end_field=rec+info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..fieldscxx . . $ st_mi_base_info#fields. ;
1237 rec < end_field ; to+= rec_length, rec++)
1238 {
1239 rec_length=rec->lengthcxx . . $ st_columndef#length.;
1240 if ((type = (enum en_fieldtypecxx . . $ en_fieldtype#) rec->typecxx . . $ st_columndef#type.) != FIELD_NORMALcxx . . $ FIELD_NORMAL. &&
1241 (type != FIELD_CHECKcxx . . $ FIELD_CHECK.))
1242 {
1243 if (type == FIELD_VARCHARcxx . . $ FIELD_VARCHAR.)
1244 {
1245 uintcxx . . $ uint# pack_length= HA_VARCHAR_PACKLENGTHcxx . . $ `include/my_base.h:704:9`!(rec_length-1);
1246 if (pack_length == 1)
1247 {
1248 length= (uintcxx . . $ uint#) *(ucharcxx . . $ uchar#*) from;
1249 if (length > rec_length-1)
1250 goto err;
1251 *to= *from++;
1252 }
1253 else
1254 {
1255 get_key_lengthcxx . . $ `include/my_compare.h:64:9`!(length, from);
1256 if (length > rec_length-2)
1257 goto err;
1258 int2storecxx . . $ int2store(5c09680d73aae78e).(to,length);
1259 }
1260 if (from+length > from_end)
1261 goto err;
1262 memcpycxx . . $ memcpy(cc817cb175f282d).(to+pack_length, from, length);
1263 from+= length;
1264 min_pack_length--;
1265 continue;
1266 }
1267 if (flag & bit)
1268 {
1269 if (type == FIELD_BLOBcxx . . $ FIELD_BLOB. || type == FIELD_SKIP_ZEROcxx . . $ FIELD_SKIP_ZERO.)
1270 bzerocxx . . $ `include/m_string.h:61:10`!((uchar*) to,rec_length);
1271 else if (type == FIELD_SKIP_ENDSPACEcxx . . $ FIELD_SKIP_ENDSPACE. ||
1272 type == FIELD_SKIP_PRESPACEcxx . . $ FIELD_SKIP_PRESPACE.)
1273 {
1274 if (rec->lengthcxx . . $ st_columndef#length. > 255 && *from & 128)
1275 {
1276 if (from + 1 >= from_end)
1277 goto err;
1278 length= (*from & 127)+ ((uintcxx . . $ uint#) (ucharcxx . . $ uchar#) *(from+1) << 7); from+=2;
1279 }
1280 else
1281 {
1282 if (from == from_end)
1283 goto err;
1284 length= (ucharcxx . . $ uchar#) *from++;
1285 }
1286 min_pack_length--;
1287 if (length >= rec_length ||
1288 min_pack_length + length > (uintcxx . . $ uint#) (from_end - from))
1289 goto err;
1290 if (type == FIELD_SKIP_ENDSPACEcxx . . $ FIELD_SKIP_ENDSPACE.)
1291 {
1292 memcpycxx . . $ memcpy(cc817cb175f282d).(to,(ucharcxx . . $ uchar#*) from,(size_t) length);
1293 bfillcxx . . $ `include/m_string.h:53:10`!((uchar*) to+length,rec_length-length,' ');
1294 }
1295 else
1296 {
1297 bfillcxx . . $ `include/m_string.h:53:10`!((uchar*) to,rec_length-length,' ');
1298 memcpycxx . . $ memcpy(cc817cb175f282d).(to+rec_length-length,(ucharcxx . . $ uchar#*) from,(size_t) length);
1299 }
1300 from+=length;
1301 }
1302 }
1303 else if (type == FIELD_BLOBcxx . . $ FIELD_BLOB.)
1304 {
1305 uintcxx . . $ uint# size_length=rec_length- portable_sizeof_char_ptrcxx . . $ `include/my_compare.h:252:9`!;
1306 ulongcxx . . $ ulong# blob_length=_mi_calc_blob_lengthcxx . . $ _mi_calc_blob_length(3cbac61846b0ebe9).(size_length,from);
1307 ulongcxx . . $ ulong# from_left= (ulongcxx . . $ ulong#) (from_end - from);
1308 if (from_left < size_length ||
1309 from_left - size_length < blob_length ||
1310 from_left - size_length - blob_length < min_pack_length)
1311 goto err;
1312 memcpycxx . . $ memcpy(cc817cb175f282d).(to, from, (size_t) size_length);
1313 from+=size_length;
1314 memcpycxx . . $ memcpy(cc817cb175f282d).(to+size_length, &from, sizeof(char*));
1315 from+=blob_length;
1316 }
1317 else
1318 {
1319 if (type == FIELD_SKIP_ENDSPACEcxx . . $ FIELD_SKIP_ENDSPACE. || type == FIELD_SKIP_PRESPACEcxx . . $ FIELD_SKIP_PRESPACE.)
1320 min_pack_length--;
1321 if (min_pack_length + rec_length > (uintcxx . . $ uint#) (from_end - from))
1322 goto err;
1323 memcpycxx . . $ memcpy(cc817cb175f282d).(to,(ucharcxx . . $ uchar#*) from,(size_t) rec_length); from+=rec_length;
1324 }
1325 if ((bit= bit << 1) >= 256)
1326 {
1327 flag= (ucharcxx . . $ uchar#) *++packpos; bit=1;
1328 }
1329 }
1330 else
1331 {
1332 if (min_pack_length > (uintcxx . . $ uint#) (from_end - from))
1333 goto err;
1334 min_pack_length-=rec_length;
1335 memcpycxx . . $ memcpy(cc817cb175f282d).(to, (ucharcxx . . $ uchar#*) from, (size_t) rec_length);
1336 from+=rec_length;
1337 }
1338 }
1339 if (info->scxx . . $ st_myisam_info#s.->calc_checksumcxx . . $ st_mi_isam_share#calc_checksum.)
1340 from++;
1341 if (to == to_end && from == from_end && (bit == 1 || !(flag & ~(bit-1))))
1342 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(found_length);
1343
1344 err:
1345 my_errnocxx . . $ `include/my_pthread.h:720:9`!= HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!;
1346 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error",("to_end: %p -> %p from_end: %p -> %p",
1347 to, to_end, from, from_end));
1348 DBUG_DUMPcxx . . $ `include/my_dbug.h:182:9`!("from",(uchar*) info->rec_buff,info->s->base.min_pack_length);
1349 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(MY_FILE_ERRORcxx . . $ `include/my_sys.h:50:9`!);
1350 } /* _mi_rec_unpack */
1351
1352
1353 /* Calc length of blob. Update info in blobs->length */
1354
1355 ulongcxx . . $ ulong# _mi_calc_total_blob_lengthcxx . . $ _mi_calc_total_blob_length(3352b8d657b3d682).(MI_INFOcxx . . $ MI_INFO# *info, const ucharcxx . . $ uchar# *record)
1356 {
1357 ulongcxx . . $ ulong# length;
1358 MI_BLOBcxx . . $ MI_BLOB# *blob,*end;
1359
1360 for (length=0, blob= info->blobscxx . . $ st_myisam_info#blobs., end=blob+info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..blobscxx . . $ st_mi_base_info#blobs. ;
1361 blob != end;
1362 blob++)
1363 {
1364 blob->lengthcxx . . $ st_mi_blob#length.=_mi_calc_blob_lengthcxx . . $ _mi_calc_blob_length(3cbac61846b0ebe9).(blob->pack_lengthcxx . . $ st_mi_blob#pack_length.,record + blob->offsetcxx . . $ st_mi_blob#offset.);
1365 length+=blob->lengthcxx . . $ st_mi_blob#length.;
1366 }
1367 return length;
1368 }
1369
1370
1371 ulongcxx . . $ ulong# _mi_calc_blob_lengthcxx . . $ _mi_calc_blob_length(3cbac61846b0ebe9).(uintcxx . . $ uint# length, const ucharcxx . . $ uchar# *pos)
1372 {
1373 switch (length) {
1374 case 1:
1375 return (uintcxx . . $ uint#) (ucharcxx . . $ uchar#) *pos;
1376 case 2:
1377 return (uintcxx . . $ uint#) uint2korrcxx . . $ uint2korr(533a9de78501ce46).(pos);
1378 case 3:
1379 return uint3korrcxx . . $ uint3korr(b11f534102b1ad6).(pos);
1380 case 4:
1381 return uint4korrcxx . . $ uint4korr(b11f534102b1ad6).(pos);
1382 default:
1383 break;
1384 }
1385 return 0; /* Impossible */
1386 }
1387
1388
1389 void _mi_store_blob_lengthcxx . . $ _mi_store_blob_length(f63137c5d602553b).(ucharcxx . . $ uchar# *pos,uintcxx . . $ uint# pack_length,uintcxx . . $ uint# length)
1390 {
1391 switch (pack_length) {
1392 case 1:
1393 *pos= (ucharcxx . . $ uchar#) length;
1394 break;
1395 case 2:
1396 int2storecxx . . $ int2store(5c09680d73aae78e).(pos,length);
1397 break;
1398 case 3:
1399 int3storecxx . . $ int3store(5c09680d73aae78e).(pos,length);
1400 break;
1401 case 4:
1402 int4storecxx . . $ int4store(5c09680d73aae78e).(pos,length);
1403 default:
1404 break;
1405 }
1406 return;
1407 }
1408
1409
1410 /*
1411 Read record from datafile.
1412
1413 SYNOPSIS
1414 _mi_read_dynamic_record()
1415 info MI_INFO pointer to table.
1416 filepos From where to read the record.
1417 buf Destination for record.
1418
1419 NOTE
1420
1421 If a write buffer is active, it needs to be flushed if its contents
1422 intersects with the record to read. We always check if the position
1423 of the first byte of the write buffer is lower than the position
1424 past the last byte to read. In theory this is also true if the write
1425 buffer is completely below the read segment. That is, if there is no
1426 intersection. But this case is unusual. We flush anyway. Only if the
1427 first byte in the write buffer is above the last byte to read, we do
1428 not flush.
1429
1430 A dynamic record may need several reads. So this check must be done
1431 before every read. Reading a dynamic record starts with reading the
1432 block header. If the record does not fit into the free space of the
1433 header, the block may be longer than the header. In this case a
1434 second read is necessary. These one or two reads repeat for every
1435 part of the record.
1436
1437 RETURN
1438 0 OK
1439 -1 Error
1440 */
1441
1442 int _mi_read_dynamic_recordcxx . . $ _mi_read_dynamic_record(b7c1c5f7482b1f1b).(MI_INFOcxx . . $ MI_INFO# *info, my_off_tcxx . . $ my_off_t# filepos, ucharcxx . . $ uchar# *buf)
1443 {
1444 int block_of_record;
1445 uintcxx . . $ uint# b_type,UNINIT_VARcxx . . $ `include/my_global.h:456:9`!(left_length);
1446 ucharcxx . . $ uchar# *UNINIT_VARcxx . . $ `include/my_global.h:456:9`!(to);
1447 MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# block_info;
1448 Filecxx . . $ File# file;
1449 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("mi_read_dynamic_record");
1450
1451 if (filepos != HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!)
1452 {
1453 file=info->dfilecxx . . $ st_myisam_info#dfile.;
1454 block_of_record= 0; /* First block of record is numbered as zero. */
1455 block_info.second_readcxx . . $ st_mi_block_info#second_read.= 0;
1456 do
1457 {
1458 /* A corrupted table can have wrong pointers. (Bug# 19835) */
1459 if (filepos == HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!)
1460 goto panic;
1461 if (info->opt_flagcxx . . $ st_myisam_info#opt_flag. & WRITE_CACHE_USEDcxx . . $ `include/my_base.h:613:9`! &&
1462 info->rec_cachecxx . . $ st_myisam_info#rec_cache..pos_in_filecxx . . $ st_io_cache#pos_in_file. < filepos + MI_BLOCK_INFO_HEADER_LENGTHcxx . . $ `storage/myisam/myisamdef.h:393:9`! &&
1463 flush_io_cachecxx . . $ `include/my_sys.h:850:9`!(&info->rec_cache))
1464 goto err;
1465 info->rec_cachecxx . . $ st_myisam_info#rec_cache..seek_not_donecxx . . $ st_io_cache#seek_not_done.=1;
1466 if ((b_type= _mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&block_info, file, filepos))
1467 & (BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`! | BLOCK_ERRORcxx . . $ `storage/myisam/myisamdef.h:639:9`! | BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`! |
1468 BLOCK_FATAL_ERRORcxx . . $ `storage/myisam/myisamdef.h:641:9`!))
1469 {
1470 if (b_type & (BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`! | BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`!))
1471 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_RECORD_DELETEDcxx . . $ `include/my_base.h:479:9`!;
1472 goto err;
1473 }
1474 if (block_of_record++ == 0) /* First block */
1475 {
1476 if (block_info.rec_lencxx . . $ st_mi_block_info#rec_len. > (uintcxx . . $ uint#) info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..max_pack_lengthcxx . . $ st_mi_base_info#max_pack_length.)
1477 goto panic;
1478 if (info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..blobscxx . . $ st_mi_base_info#blobs.)
1479 {
1480 if (!(to=mi_alloc_rec_buffcxx . . $ mi_alloc_rec_buff(ce2bb3388a676b50).(info, block_info.rec_lencxx . . $ st_mi_block_info#rec_len.,
1481 &info->rec_buffcxx . . $ st_myisam_info#rec_buff.)))
1482 goto err;
1483 }
1484 else
1485 to= info->rec_buffcxx . . $ st_myisam_info#rec_buff.;
1486 left_length=block_info.rec_lencxx . . $ st_mi_block_info#rec_len.;
1487 }
1488 if (left_length < block_info.data_lencxx . . $ st_mi_block_info#data_len. || ! block_info.data_lencxx . . $ st_mi_block_info#data_len.)
1489 goto panic; /* Wrong linked record */
1490 /* copy information that is already read */
1491 {
1492 uintcxx . . $ uint# offset= (uintcxx . . $ uint#) (block_info.fileposcxx . . $ st_mi_block_info#filepos. - filepos);
1493 uintcxx . . $ uint# prefetch_len= (sizeof(block_info.headercxx . . $ st_mi_block_info#header.) - offset);
1494 filepos+= sizeof(block_info.headercxx . . $ st_mi_block_info#header.);
1495
1496 if (prefetch_len > block_info.data_lencxx . . $ st_mi_block_info#data_len.)
1497 prefetch_len= block_info.data_lencxx . . $ st_mi_block_info#data_len.;
1498 if (prefetch_len)
1499 {
1500 memcpycxx . . $ memcpy(cc817cb175f282d).((ucharcxx . . $ uchar#*) to, block_info.headercxx . . $ st_mi_block_info#header. + offset, prefetch_len);
1501 block_info.data_lencxx . . $ st_mi_block_info#data_len.-= prefetch_len;
1502 left_length-= prefetch_len;
1503 to+= prefetch_len;
1504 }
1505 }
1506 /* read rest of record from file */
1507 if (block_info.data_lencxx . . $ st_mi_block_info#data_len.)
1508 {
1509 if (info->opt_flagcxx . . $ st_myisam_info#opt_flag. & WRITE_CACHE_USEDcxx . . $ `include/my_base.h:613:9`! &&
1510 info->rec_cachecxx . . $ st_myisam_info#rec_cache..pos_in_filecxx . . $ st_io_cache#pos_in_file. < filepos + block_info.data_lencxx . . $ st_mi_block_info#data_len. &&
1511 flush_io_cachecxx . . $ `include/my_sys.h:850:9`!(&info->rec_cache))
1512 goto err;
1513 /*
1514 What a pity that this method is not called 'file_pread' and that
1515 there is no equivalent without seeking. We are at the right
1516 position already. :(
1517 */
1518 if (info->scxx . . $ st_myisam_info#s.->file_readcxx . . $ st_mi_isam_share#file_read.(info, (ucharcxx . . $ uchar#*) to, block_info.data_lencxx . . $ st_mi_block_info#data_len.,
1519 filepos, MYFcxx . . $ `include/my_global.h:986:9`!(MY_NABPcxx . . $ `include/my_sys.h:55:9`!)))
1520 goto panic;
1521 left_length-=block_info.data_lencxx . . $ st_mi_block_info#data_len.;
1522 to+=block_info.data_lencxx . . $ st_mi_block_info#data_len.;
1523 }
1524 filepos= block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos.;
1525 } while (left_length);
1526
1527 info->updatecxx . . $ st_myisam_info#update.|= HA_STATE_AKTIVcxx . . $ `include/my_base.h:618:9`!; /* We have a aktive record */
1528 fast_mi_writeinfocxx . . $ `storage/myisam/myisamdef.h:672:9`!(info);
1529 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(_mi_rec_unpack(info,buf,info->rec_buff,block_info.rec_len) !=
1530 MY_FILE_ERRORcxx . . $ `include/my_sys.h:50:9`! ? 0 : -1);
1531 }
1532 fast_mi_writeinfocxx . . $ `storage/myisam/myisamdef.h:672:9`!(info);
1533 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(-1); /* Wrong data to read */
1534
1535 panic:
1536 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!;
1537 err:
1538 (void) _mi_writeinfocxx . . $ _mi_writeinfo(83f767d3a6dbcc54).(info,0);
1539 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(-1);
1540 }
1541
1542 /* compare unique constraint between stored rows */
1543
1544 int _mi_cmp_dynamic_uniquecxx . . $ _mi_cmp_dynamic_unique(da8c61c5d794970a).(MI_INFOcxx . . $ MI_INFO# *info, MI_UNIQUEDEFcxx . . $ MI_UNIQUEDEF# *def,
1545 const ucharcxx . . $ uchar# *record, my_off_tcxx . . $ my_off_t# pos)
1546 {
1547 ucharcxx . . $ uchar# *rec_buff,*old_record;
1548 int error;
1549 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_mi_cmp_dynamic_unique");
1550
1551 if (!(old_record=my_allocacxx . . $ `storage/myisam/mi_dynrec.c:46:9`!(info->s->base.reclength)))
1552 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
1553
1554 /* Don't let the compare destroy blobs that may be in use */
1555 rec_buff=info->rec_buffcxx . . $ st_myisam_info#rec_buff.;
1556 if (info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..blobscxx . . $ st_mi_base_info#blobs.)
1557 info->rec_buffcxx . . $ st_myisam_info#rec_buff.=0;
1558 error=_mi_read_dynamic_recordcxx . . $ _mi_read_dynamic_record(b7c1c5f7482b1f1b).(info,pos,old_record);
1559 if (!error)
1560 error=mi_unique_compcxx . . $ mi_unique_comp(2c507bec3d1830c7).(def, record, old_record, def->null_are_equalcxx . . $ st_unique_def#null_are_equal.);
1561 if (info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..blobscxx . . $ st_mi_base_info#blobs.)
1562 {
1563 my_freecxx . . $ my_free(5d22bdacc48458e8).(mi_get_rec_buff_ptrcxx . . $ `storage/myisam/myisamdef.h:573:9`!(info, info->rec_buff));
1564 info->rec_buffcxx . . $ st_myisam_info#rec_buff.=rec_buff;
1565 }
1566 my_afreecxx . . $ `storage/myisam/mi_dynrec.c:47:9`!(old_record);
1567 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(error);
1568 }
1569
1570
1571 /* Compare of record one disk with packed record in memory */
1572
1573 int _mi_cmp_dynamic_recordcxx . . $ _mi_cmp_dynamic_record(c8f46092f4519684).(register MI_INFOcxx . . $ MI_INFO# *info, register const ucharcxx . . $ uchar# *record)
1574 {
1575 uintcxx . . $ uint# flag,reclength,b_type;
1576 my_off_tcxx . . $ my_off_t# filepos;
1577 ucharcxx . . $ uchar# *buffer;
1578 MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# block_info;
1579 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_mi_cmp_dynamic_record");
1580
1581 if (info->opt_flagcxx . . $ st_myisam_info#opt_flag. & WRITE_CACHE_USEDcxx . . $ `include/my_base.h:613:9`!)
1582 {
1583 info->updatecxx . . $ st_myisam_info#update.&= ~(HA_STATE_WRITE_AT_ENDcxx . . $ `include/my_base.h:625:9`! | HA_STATE_EXTEND_BLOCKcxx . . $ `include/my_base.h:628:9`!);
1584 if (flush_io_cachecxx . . $ `include/my_sys.h:850:9`!(&info->rec_cache))
1585 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(-1);
1586 }
1587 info->rec_cachecxx . . $ st_myisam_info#rec_cache..seek_not_donecxx . . $ st_io_cache#seek_not_done.=1;
1588
1589 /* If nobody have touched the database we don't have to test rec */
1590
1591 buffer=info->rec_buffcxx . . $ st_myisam_info#rec_buff.;
1592 if ((info->opt_flagcxx . . $ st_myisam_info#opt_flag. & READ_CHECK_USEDcxx . . $ `include/my_base.h:611:9`!))
1593 { /* If check isn't disabled */
1594 if (info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..blobscxx . . $ st_mi_base_info#blobs.)
1595 {
1596 if (!(buffer=(ucharcxx . . $ uchar#*) my_allocacxx . . $ `storage/myisam/mi_dynrec.c:46:9`!(info->s->base.pack_reclength+
1597 _mi_calc_total_blob_length(info,record))))
1598 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(-1);
1599 }
1600 reclength=_mi_rec_packcxx . . $ _mi_rec_pack(92d72fbc6a90c214).(info,buffer,record);
1601 record= buffer;
1602
1603 filepos=info->lastposcxx . . $ st_myisam_info#lastpos.;
1604 flag=block_info.second_readcxx . . $ st_mi_block_info#second_read.=0;
1605 block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos.=filepos;
1606 while (reclength > 0)
1607 {
1608 if ((b_type=_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&block_info,info->dfilecxx . . $ st_myisam_info#dfile.,
1609 block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos.))
1610 & (BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`! | BLOCK_ERRORcxx . . $ `storage/myisam/myisamdef.h:639:9`! | BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`! |
1611 BLOCK_FATAL_ERRORcxx . . $ `storage/myisam/myisamdef.h:641:9`!))
1612 {
1613 if (b_type & (BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`! | BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`!))
1614 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_RECORD_CHANGEDcxx . . $ `include/my_base.h:469:9`!;
1615 goto err;
1616 }
1617 if (flag == 0) /* First block */
1618 {
1619 flag=1;
1620 if (reclength != block_info.rec_lencxx . . $ st_mi_block_info#rec_len.)
1621 {
1622 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_RECORD_CHANGEDcxx . . $ `include/my_base.h:469:9`!;
1623 goto err;
1624 }
1625 } else if (reclength < block_info.data_lencxx . . $ st_mi_block_info#data_len.)
1626 {
1627 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!;
1628 goto err;
1629 }
1630 reclength-=block_info.data_lencxx . . $ st_mi_block_info#data_len.;
1631 if (_mi_cmp_buffercxx . . $ _mi_cmp_buffer(28f8de9edd2414ae).(info->dfilecxx . . $ st_myisam_info#dfile.,record,block_info.fileposcxx . . $ st_mi_block_info#filepos.,
1632 block_info.data_lencxx . . $ st_mi_block_info#data_len.))
1633 {
1634 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_RECORD_CHANGEDcxx . . $ `include/my_base.h:469:9`!;
1635 goto err;
1636 }
1637 flag=1;
1638 record+=block_info.data_lencxx . . $ st_mi_block_info#data_len.;
1639 }
1640 }
1641 my_errnocxx . . $ `include/my_pthread.h:720:9`!=0;
1642 err:
1643 if (buffer != info->rec_buffcxx . . $ st_myisam_info#rec_buff.)
1644 my_afreecxx . . $ `storage/myisam/mi_dynrec.c:47:9`!((uchar*) buffer);
1645 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(my_errnocxx . . $ `include/my_pthread.h:720:9`!);
1646 }
1647
1648
1649 /* Compare file to buffert */
1650
1651 static int _mi_cmp_buffercxx . . $ _mi_cmp_buffer(28f8de9edd2414ae).(Filecxx . . $ File# file, const ucharcxx . . $ uchar# *buff, my_off_tcxx . . $ my_off_t# filepos,
1652 uintcxx . . $ uint# length)
1653 {
1654 uintcxx . . $ uint# next_length;
1655 ucharcxx . . $ uchar# temp_buff[IO_SIZEcxx . . $ `include/my_global.h:672:9`!*2];
1656 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_mi_cmp_buffer");
1657
1658 next_length= IO_SIZEcxx . . $ `include/my_global.h:672:9`!*2 - (uintcxx . . $ uint#) (filepos & (IO_SIZEcxx . . $ `include/my_global.h:672:9`!-1));
1659
1660 while (length > IO_SIZEcxx . . $ `include/my_global.h:672:9`!*2)
1661 {
1662 if (mysql_file_preadcxx . . $ `include/mysql/psi/mysql_file.h:366:11`!(file, temp_buff, next_length, filepos, MYFcxx . . $ `include/my_global.h:986:9`!(MY_NABPcxx . . $ `include/my_sys.h:55:9`!)) ||
1663 memcmpcxx . . $ memcmp(36f949851efa3055).(buff, temp_buff, next_length))
1664 goto err;
1665 filepos+=next_length;
1666 buff+=next_length;
1667 length-= next_length;
1668 next_length=IO_SIZEcxx . . $ `include/my_global.h:672:9`!*2;
1669 }
1670 if (mysql_file_preadcxx . . $ `include/mysql/psi/mysql_file.h:366:11`!(file, temp_buff, length, filepos, MYFcxx . . $ `include/my_global.h:986:9`!(MY_NABPcxx . . $ `include/my_sys.h:55:9`!)))
1671 goto err;
1672 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(memcmp(buff,temp_buff,length));
1673 err:
1674 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1);
1675 }
1676
1677
1678 /*
1679 Read record from datafile.
1680
1681 SYNOPSIS
1682 _mi_read_rnd_dynamic_record()
1683 info MI_INFO pointer to table.
1684 buf Destination for record.
1685 filepos From where to read the record.
1686 skip_deleted_blocks If to repeat reading until a non-deleted
1687 record is found.
1688
1689 NOTE
1690
1691 If a write buffer is active, it needs to be flushed if its contents
1692 intersects with the record to read. We always check if the position
1693 of the first byte of the write buffer is lower than the position
1694 past the last byte to read. In theory this is also true if the write
1695 buffer is completely below the read segment. That is, if there is no
1696 intersection. But this case is unusual. We flush anyway. Only if the
1697 first byte in the write buffer is above the last byte to read, we do
1698 not flush.
1699
1700 A dynamic record may need several reads. So this check must be done
1701 before every read. Reading a dynamic record starts with reading the
1702 block header. If the record does not fit into the free space of the
1703 header, the block may be longer than the header. In this case a
1704 second read is necessary. These one or two reads repeat for every
1705 part of the record.
1706
1707 RETURN
1708 0 OK
1709 != 0 Error
1710 */
1711
1712 int _mi_read_rnd_dynamic_recordcxx . . $ _mi_read_rnd_dynamic_record(d44cfcf591c80129).(MI_INFOcxx . . $ MI_INFO# *info, ucharcxx . . $ uchar# *buf,
1713 register my_off_tcxx . . $ my_off_t# filepos,
1714 my_boolcxx . . $ my_bool# skip_deleted_blocks)
1715 {
1716 int block_of_record, info_read, save_errno;
1717 uintcxx . . $ uint# left_len,b_type;
1718 ucharcxx . . $ uchar# *UNINIT_VARcxx . . $ `include/my_global.h:456:9`!(to);
1719 MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# block_info;
1720 MYISAM_SHAREcxx . . $ MYISAM_SHARE# *share=info->scxx . . $ st_myisam_info#s.;
1721 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_mi_read_rnd_dynamic_record");
1722
1723 info_read=0;
1724
1725 if (info->lock_typecxx . . $ st_myisam_info#lock_type. == F_UNLCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:225:10`!)
1726 {
1727 #ifndef UNSAFE_LOCKING
1728 if (share->tot_lockscxx . . $ st_mi_isam_share#tot_locks. == 0)
1729 {
1730 if (my_lockcxx . . $ my_lock(dbd27b0f34827610).(share->kfilecxx . . $ st_mi_isam_share#kfile.,F_RDLCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:223:10`!,0L,F_TO_EOFcxx . . $ `include/my_global.h:560:9`!,
1731 MYFcxx . . $ `include/my_global.h:986:9`!(MY_SEEK_NOT_DONEcxx . . $ `include/my_sys.h:72:9`!) | info->lock_waitcxx . . $ st_myisam_info#lock_wait.))
1732 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(my_errnocxx . . $ `include/my_pthread.h:720:9`!);
1733 }
1734 #else
1735 info->tmp_lock_type=F_RDLCK;
1736 #endif
1737 }
1738 else
1739 info_read=1; /* memory-keyinfoblock is ok */
1740
1741 block_of_record= 0; /* First block of record is numbered as zero. */
1742 block_info.second_readcxx . . $ st_mi_block_info#second_read.= 0;
1743 left_len=1;
1744 do
1745 {
1746 if (filepos >= info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length.)
1747 {
1748 if (!info_read)
1749 { /* Check if changed */
1750 info_read=1;
1751 info->rec_cachecxx . . $ st_myisam_info#rec_cache..seek_not_donecxx . . $ st_io_cache#seek_not_done.=1;
1752 if (mi_state_info_read_dskcxx . . $ mi_state_info_read_dsk(b9b09994d5b2e9f).(share->kfilecxx . . $ st_mi_isam_share#kfile.,&share->statecxx . . $ st_mi_isam_share#state.,1))
1753 goto panic;
1754 }
1755 if (filepos >= info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length.)
1756 {
1757 my_errnocxx . . $ `include/my_pthread.h:720:9`!= HA_ERR_END_OF_FILEcxx . . $ `include/my_base.h:482:9`!;
1758 goto err;
1759 }
1760 }
1761 if (info->opt_flagcxx . . $ st_myisam_info#opt_flag. & READ_CACHE_USEDcxx . . $ `include/my_base.h:610:9`!)
1762 {
1763 if (_mi_read_cachecxx . . $ _mi_read_cache(63fe62baf4b2799f).(&info->rec_cachecxx . . $ st_myisam_info#rec_cache.,(ucharcxx . . $ uchar#*) block_info.headercxx . . $ st_mi_block_info#header.,filepos,
1764 sizeof(block_info.headercxx . . $ st_mi_block_info#header.),
1765 (!block_of_record && skip_deleted_blocks ?
1766 READING_NEXTcxx . . $ `storage/myisam/myisamdef.h:341:9`! : 0) | READING_HEADERcxx . . $ `storage/myisam/myisamdef.h:342:9`!))
1767 goto panic;
1768 b_type=_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&block_info,-1,filepos);
1769 }
1770 else
1771 {
1772 if (info->opt_flagcxx . . $ st_myisam_info#opt_flag. & WRITE_CACHE_USEDcxx . . $ `include/my_base.h:613:9`! &&
1773 info->rec_cachecxx . . $ st_myisam_info#rec_cache..pos_in_filecxx . . $ st_io_cache#pos_in_file. < filepos + MI_BLOCK_INFO_HEADER_LENGTHcxx . . $ `storage/myisam/myisamdef.h:393:9`! &&
1774 flush_io_cachecxx . . $ `include/my_sys.h:850:9`!(&info->rec_cache))
1775 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(my_errnocxx . . $ `include/my_pthread.h:720:9`!);
1776 info->rec_cachecxx . . $ st_myisam_info#rec_cache..seek_not_donecxx . . $ st_io_cache#seek_not_done.=1;
1777 b_type=_mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(&block_info,info->dfilecxx . . $ st_myisam_info#dfile.,filepos);
1778 }
1779
1780 if (b_type & (BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`! | BLOCK_ERRORcxx . . $ `storage/myisam/myisamdef.h:639:9`! | BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`! |
1781 BLOCK_FATAL_ERRORcxx . . $ `storage/myisam/myisamdef.h:641:9`!))
1782 {
1783 if ((b_type & (BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`! | BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`!)))
1784 {
1785 if (skip_deleted_blocks)
1786 {
1787 filepos=block_info.fileposcxx . . $ st_mi_block_info#filepos.+block_info.block_lencxx . . $ st_mi_block_info#block_len.;
1788 block_info.second_readcxx . . $ st_mi_block_info#second_read.=0;
1789 continue; /* Search after next_record */
1790 }
1791 /*
1792 If we're not on the first block of a record and
1793 the block is marked as deleted or out of sync,
1794 something's gone wrong: the record is damaged.
1795 */
1796 if (block_of_record != 0)
1797 goto panic;
1798 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_RECORD_DELETEDcxx . . $ `include/my_base.h:479:9`!;
1799 info->lastposcxx . . $ st_myisam_info#lastpos.=block_info.fileposcxx . . $ st_mi_block_info#filepos.;
1800 info->nextposcxx . . $ st_myisam_info#nextpos.=block_info.fileposcxx . . $ st_mi_block_info#filepos.+block_info.block_lencxx . . $ st_mi_block_info#block_len.;
1801 }
1802 goto err;
1803 }
1804 if (block_of_record == 0) /* First block */
1805 {
1806 if (block_info.rec_lencxx . . $ st_mi_block_info#rec_len. > (uintcxx . . $ uint#) share->basecxx . . $ st_mi_isam_share#base..max_pack_lengthcxx . . $ st_mi_base_info#max_pack_length.)
1807 goto panic;
1808 info->lastposcxx . . $ st_myisam_info#lastpos.=filepos;
1809 if (share->basecxx . . $ st_mi_isam_share#base..blobscxx . . $ st_mi_base_info#blobs.)
1810 {
1811 if (!(to= mi_alloc_rec_buffcxx . . $ mi_alloc_rec_buff(ce2bb3388a676b50).(info, block_info.rec_lencxx . . $ st_mi_block_info#rec_len.,
1812 &info->rec_buffcxx . . $ st_myisam_info#rec_buff.)))
1813 goto err;
1814 }
1815 else
1816 to= info->rec_buffcxx . . $ st_myisam_info#rec_buff.;
1817 left_len=block_info.rec_lencxx . . $ st_mi_block_info#rec_len.;
1818 }
1819 if (left_len < block_info.data_lencxx . . $ st_mi_block_info#data_len.)
1820 goto panic; /* Wrong linked record */
1821
1822 /* copy information that is already read */
1823 {
1824 uintcxx . . $ uint# offset=(uintcxx . . $ uint#) (block_info.fileposcxx . . $ st_mi_block_info#filepos. - filepos);
1825 uintcxx . . $ uint# tmp_length= (sizeof(block_info.headercxx . . $ st_mi_block_info#header.) - offset);
1826 filepos=block_info.fileposcxx . . $ st_mi_block_info#filepos.;
1827
1828 if (tmp_length > block_info.data_lencxx . . $ st_mi_block_info#data_len.)
1829 tmp_length= block_info.data_lencxx . . $ st_mi_block_info#data_len.;
1830 if (tmp_length)
1831 {
1832 memcpycxx . . $ memcpy(cc817cb175f282d).((ucharcxx . . $ uchar#*) to, block_info.headercxx . . $ st_mi_block_info#header.+offset,tmp_length);
1833 block_info.data_lencxx . . $ st_mi_block_info#data_len.-=tmp_length;
1834 left_len-=tmp_length;
1835 to+=tmp_length;
1836 filepos+=tmp_length;
1837 }
1838 }
1839 /* read rest of record from file */
1840 if (block_info.data_lencxx . . $ st_mi_block_info#data_len.)
1841 {
1842 if (info->opt_flagcxx . . $ st_myisam_info#opt_flag. & READ_CACHE_USEDcxx . . $ `include/my_base.h:610:9`!)
1843 {
1844 if (_mi_read_cachecxx . . $ _mi_read_cache(63fe62baf4b2799f).(&info->rec_cachecxx . . $ st_myisam_info#rec_cache.,(ucharcxx . . $ uchar#*) to,filepos,
1845 block_info.data_lencxx . . $ st_mi_block_info#data_len.,
1846 (!block_of_record && skip_deleted_blocks) ?
1847 READING_NEXTcxx . . $ `storage/myisam/myisamdef.h:341:9`! : 0))
1848 goto panic;
1849 }
1850 else
1851 {
1852 if (info->opt_flagcxx . . $ st_myisam_info#opt_flag. & WRITE_CACHE_USEDcxx . . $ `include/my_base.h:613:9`! &&
1853 info->rec_cachecxx . . $ st_myisam_info#rec_cache..pos_in_filecxx . . $ st_io_cache#pos_in_file. <
1854 block_info.fileposcxx . . $ st_mi_block_info#filepos. + block_info.data_lencxx . . $ st_mi_block_info#data_len. &&
1855 flush_io_cachecxx . . $ `include/my_sys.h:850:9`!(&info->rec_cache))
1856 goto err;
1857 /* mysql_file_seek(info->dfile, filepos, MY_SEEK_SET, MYF(0)); */
1858 if (mysql_file_readcxx . . $ `include/mysql/psi/mysql_file.h:340:11`!(info->dfile, (uchar*) to, block_info.data_len,
1859 MYFcxx . . $ `include/my_global.h:986:9`!(MY_NABPcxx . . $ `include/my_sys.h:55:9`!)))
1860 {
1861 if (my_errnocxx . . $ `include/my_pthread.h:720:9`! == HA_ERR_FILE_TOO_SHORTcxx . . $ `include/my_base.h:532:9`!)
1862 my_errnocxx . . $ `include/my_pthread.h:720:9`!= HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!; /* Unexpected end of file */
1863 goto err;
1864 }
1865 }
1866 }
1867 /*
1868 Increment block-of-record counter. If it was the first block,
1869 remember the position behind the block for the next call.
1870 */
1871 if (block_of_record++ == 0)
1872 {
1873 info->nextposcxx . . $ st_myisam_info#nextpos.= block_info.fileposcxx . . $ st_mi_block_info#filepos. + block_info.block_lencxx . . $ st_mi_block_info#block_len.;
1874 skip_deleted_blocks= 0;
1875 }
1876 left_len-=block_info.data_lencxx . . $ st_mi_block_info#data_len.;
1877 to+=block_info.data_lencxx . . $ st_mi_block_info#data_len.;
1878 filepos=block_info.next_fileposcxx . . $ st_mi_block_info#next_filepos.;
1879 } while (left_len);
1880
1881 info->updatecxx . . $ st_myisam_info#update.|= HA_STATE_AKTIVcxx . . $ `include/my_base.h:618:9`! | HA_STATE_KEY_CHANGEDcxx . . $ `include/my_base.h:624:9`!;
1882 fast_mi_writeinfocxx . . $ `storage/myisam/myisamdef.h:672:9`!(info);
1883 if (_mi_rec_unpackcxx . . $ _mi_rec_unpack(f9f31885b079ea9b).(info,buf,info->rec_buffcxx . . $ st_myisam_info#rec_buff.,block_info.rec_lencxx . . $ st_mi_block_info#rec_len.) !=
1884 MY_FILE_ERRORcxx . . $ `include/my_sys.h:50:9`!)
1885 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
1886 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(my_errnocxx . . $ `include/my_pthread.h:720:9`!); /* Wrong record */
1887
1888 panic:
1889 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!; /* Something is fatal wrong */
1890 err:
1891 save_errno=my_errnocxx . . $ `include/my_pthread.h:720:9`!;
1892 (void) _mi_writeinfocxx . . $ _mi_writeinfo(83f767d3a6dbcc54).(info,0);
1893 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(my_errnocxx . . $ `include/my_pthread.h:720:9`!=save_errno);
1894 }
1895
1896
1897 /* Read and process header from a dynamic-record-file */
1898
1899 uintcxx . . $ uint# _mi_get_block_infocxx . . $ _mi_get_block_info(f82b234ea2afc1c6).(MI_BLOCK_INFOcxx . . $ MI_BLOCK_INFO# *info, Filecxx . . $ File# file, my_off_tcxx . . $ my_off_t# filepos)
1900 {
1901 uintcxx . . $ uint# return_val=0;
1902 ucharcxx . . $ uchar# *header=info->headercxx . . $ st_mi_block_info#header.;
1903
1904 if (file >= 0)
1905 {
1906 /*
1907 We do not use mysql_file_pread() here because we want to have the file
1908 pointer set to the end of the header after this function.
1909 mysql_file_pread() may leave the file pointer untouched.
1910 */
1911 mysql_file_seekcxx . . $ `include/mysql/psi/mysql_file.h:392:11`!(file, filepos, MY_SEEK_SETcxx . . $ `include/my_sys.h:125:9`!, MYFcxx . . $ `include/my_global.h:986:9`!(0));
1912 if (mysql_file_readcxx . . $ `include/mysql/psi/mysql_file.h:340:11`!(file, header, sizeof(info->header), MYFcxx . . $ `include/my_global.h:986:9`!(0)) !=
1913 sizeof(info->headercxx . . $ st_mi_block_info#header.))
1914 goto err;
1915 }
1916 DBUG_DUMPcxx . . $ `include/my_dbug.h:182:9`!("header",header,MI_BLOCK_INFO_HEADER_LENGTH);
1917 if (info->second_readcxx . . $ st_mi_block_info#second_read.)
1918 {
1919 if (info->headercxx . . $ st_mi_block_info#header.[0] <= 6 || info->headercxx . . $ st_mi_block_info#header.[0] == 13)
1920 return_val=BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`!;
1921 }
1922 else
1923 {
1924 if (info->headercxx . . $ st_mi_block_info#header.[0] > 6 && info->headercxx . . $ st_mi_block_info#header.[0] != 13)
1925 return_val=BLOCK_SYNC_ERRORcxx . . $ `storage/myisam/myisamdef.h:640:9`!;
1926 }
1927 info->next_fileposcxx . . $ st_mi_block_info#next_filepos.= HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!; /* Dummy if no next block */
1928
1929 switch (info->headercxx . . $ st_mi_block_info#header.[0]) {
1930 case 0:
1931 if ((info->block_lencxx . . $ st_mi_block_info#block_len.=(uintcxx . . $ uint#) mi_uint3korrcxx . . $ `include/myisampack.h:49:9`!(header+1)) <
1932 MI_MIN_BLOCK_LENGTHcxx . . $ `storage/myisam/myisamdef.h:389:9`! ||
1933 (info->block_lencxx . . $ st_mi_block_info#block_len. & (MI_DYN_ALIGN_SIZEcxx . . $ `storage/myisam/myisamdef.h:397:9`! -1)))
1934 goto err;
1935 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos;
1936 info->next_fileposcxx . . $ st_mi_block_info#next_filepos.=mi_sizekorrcxx . . $ `include/myisampack.h:242:9`!(header+4);
1937 info->prev_fileposcxx . . $ st_mi_block_info#prev_filepos.=mi_sizekorrcxx . . $ `include/myisampack.h:242:9`!(header+12);
1938 #if SIZEOF_OFF_Tcxx . . $ `build/include/my_config.h:294:9`! == 4
1939 if ((mi_uint4korr(header+4) != 0 &&
1940 (mi_uint4korr(header+4) != (ulong) ~0 ||
1941 info->next_filepos != (ulong) ~0)) ||
1942 (mi_uint4korr(header+12) != 0 &&
1943 (mi_uint4korr(header+12) != (ulong) ~0 ||
1944 info->prev_filepos != (ulong) ~0)))
1945 goto err;
1946 #endif
1947 return return_val | BLOCK_DELETEDcxx . . $ `storage/myisam/myisamdef.h:638:9`!; /* Deleted block */
1948
1949 case 1:
1950 info->rec_lencxx . . $ st_mi_block_info#rec_len.=info->data_lencxx . . $ st_mi_block_info#data_len.=info->block_lencxx . . $ st_mi_block_info#block_len.=mi_uint2korrcxx . . $ `include/myisampack.h:47:9`!(header+1);
1951 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+3;
1952 return return_val | BLOCK_FIRSTcxx . . $ `storage/myisam/myisamdef.h:636:9`! | BLOCK_LASTcxx . . $ `storage/myisam/myisamdef.h:637:9`!;
1953 case 2:
1954 info->rec_lencxx . . $ st_mi_block_info#rec_len.=info->data_lencxx . . $ st_mi_block_info#data_len.=info->block_lencxx . . $ st_mi_block_info#block_len.=mi_uint3korrcxx . . $ `include/myisampack.h:49:9`!(header+1);
1955 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+4;
1956 return return_val | BLOCK_FIRSTcxx . . $ `storage/myisam/myisamdef.h:636:9`! | BLOCK_LASTcxx . . $ `storage/myisam/myisamdef.h:637:9`!;
1957
1958 case 13:
1959 info->rec_lencxx . . $ st_mi_block_info#rec_len.=mi_uint4korrcxx . . $ `include/myisampack.h:52:9`!(header+1);
1960 info->block_lencxx . . $ st_mi_block_info#block_len.=info->data_lencxx . . $ st_mi_block_info#data_len.=mi_uint3korrcxx . . $ `include/myisampack.h:49:9`!(header+5);
1961 info->next_fileposcxx . . $ st_mi_block_info#next_filepos.=mi_sizekorrcxx . . $ `include/myisampack.h:242:9`!(header+8);
1962 info->second_readcxx . . $ st_mi_block_info#second_read.=1;
1963 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+16;
1964 return return_val | BLOCK_FIRSTcxx . . $ `storage/myisam/myisamdef.h:636:9`!;
1965
1966 case 3:
1967 info->rec_lencxx . . $ st_mi_block_info#rec_len.=info->data_lencxx . . $ st_mi_block_info#data_len.=mi_uint2korrcxx . . $ `include/myisampack.h:47:9`!(header+1);
1968 info->block_lencxx . . $ st_mi_block_info#block_len.=info->rec_lencxx . . $ st_mi_block_info#rec_len.+ (uintcxx . . $ uint#) header[3];
1969 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+4;
1970 return return_val | BLOCK_FIRSTcxx . . $ `storage/myisam/myisamdef.h:636:9`! | BLOCK_LASTcxx . . $ `storage/myisam/myisamdef.h:637:9`!;
1971 case 4:
1972 info->rec_lencxx . . $ st_mi_block_info#rec_len.=info->data_lencxx . . $ st_mi_block_info#data_len.=mi_uint3korrcxx . . $ `include/myisampack.h:49:9`!(header+1);
1973 info->block_lencxx . . $ st_mi_block_info#block_len.=info->rec_lencxx . . $ st_mi_block_info#rec_len.+ (uintcxx . . $ uint#) header[4];
1974 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+5;
1975 return return_val | BLOCK_FIRSTcxx . . $ `storage/myisam/myisamdef.h:636:9`! | BLOCK_LASTcxx . . $ `storage/myisam/myisamdef.h:637:9`!;
1976
1977 case 5:
1978 info->rec_lencxx . . $ st_mi_block_info#rec_len.=mi_uint2korrcxx . . $ `include/myisampack.h:47:9`!(header+1);
1979 info->block_lencxx . . $ st_mi_block_info#block_len.=info->data_lencxx . . $ st_mi_block_info#data_len.=mi_uint2korrcxx . . $ `include/myisampack.h:47:9`!(header+3);
1980 info->next_fileposcxx . . $ st_mi_block_info#next_filepos.=mi_sizekorrcxx . . $ `include/myisampack.h:242:9`!(header+5);
1981 info->second_readcxx . . $ st_mi_block_info#second_read.=1;
1982 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+13;
1983 return return_val | BLOCK_FIRSTcxx . . $ `storage/myisam/myisamdef.h:636:9`!;
1984 case 6:
1985 info->rec_lencxx . . $ st_mi_block_info#rec_len.=mi_uint3korrcxx . . $ `include/myisampack.h:49:9`!(header+1);
1986 info->block_lencxx . . $ st_mi_block_info#block_len.=info->data_lencxx . . $ st_mi_block_info#data_len.=mi_uint3korrcxx . . $ `include/myisampack.h:49:9`!(header+4);
1987 info->next_fileposcxx . . $ st_mi_block_info#next_filepos.=mi_sizekorrcxx . . $ `include/myisampack.h:242:9`!(header+7);
1988 info->second_readcxx . . $ st_mi_block_info#second_read.=1;
1989 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+15;
1990 return return_val | BLOCK_FIRSTcxx . . $ `storage/myisam/myisamdef.h:636:9`!;
1991
1992 /* The following blocks are identical to 1-6 without rec_len */
1993 case 7:
1994 info->data_lencxx . . $ st_mi_block_info#data_len.=info->block_lencxx . . $ st_mi_block_info#block_len.=mi_uint2korrcxx . . $ `include/myisampack.h:47:9`!(header+1);
1995 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+3;
1996 return return_val | BLOCK_LASTcxx . . $ `storage/myisam/myisamdef.h:637:9`!;
1997 case 8:
1998 info->data_lencxx . . $ st_mi_block_info#data_len.=info->block_lencxx . . $ st_mi_block_info#block_len.=mi_uint3korrcxx . . $ `include/myisampack.h:49:9`!(header+1);
1999 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+4;
2000 return return_val | BLOCK_LASTcxx . . $ `storage/myisam/myisamdef.h:637:9`!;
2001
2002 case 9:
2003 info->data_lencxx . . $ st_mi_block_info#data_len.=mi_uint2korrcxx . . $ `include/myisampack.h:47:9`!(header+1);
2004 info->block_lencxx . . $ st_mi_block_info#block_len.=info->data_lencxx . . $ st_mi_block_info#data_len.+ (uintcxx . . $ uint#) header[3];
2005 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+4;
2006 return return_val | BLOCK_LASTcxx . . $ `storage/myisam/myisamdef.h:637:9`!;
2007 case 10:
2008 info->data_lencxx . . $ st_mi_block_info#data_len.=mi_uint3korrcxx . . $ `include/myisampack.h:49:9`!(header+1);
2009 info->block_lencxx . . $ st_mi_block_info#block_len.=info->data_lencxx . . $ st_mi_block_info#data_len.+ (uintcxx . . $ uint#) header[4];
2010 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+5;
2011 return return_val | BLOCK_LASTcxx . . $ `storage/myisam/myisamdef.h:637:9`!;
2012
2013 case 11:
2014 info->data_lencxx . . $ st_mi_block_info#data_len.=info->block_lencxx . . $ st_mi_block_info#block_len.=mi_uint2korrcxx . . $ `include/myisampack.h:47:9`!(header+1);
2015 info->next_fileposcxx . . $ st_mi_block_info#next_filepos.=mi_sizekorrcxx . . $ `include/myisampack.h:242:9`!(header+3);
2016 info->second_readcxx . . $ st_mi_block_info#second_read.=1;
2017 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+11;
2018 return return_val;
2019 case 12:
2020 info->data_lencxx . . $ st_mi_block_info#data_len.=info->block_lencxx . . $ st_mi_block_info#block_len.=mi_uint3korrcxx . . $ `include/myisampack.h:49:9`!(header+1);
2021 info->next_fileposcxx . . $ st_mi_block_info#next_filepos.=mi_sizekorrcxx . . $ `include/myisampack.h:242:9`!(header+4);
2022 info->second_readcxx . . $ st_mi_block_info#second_read.=1;
2023 info->fileposcxx . . $ st_mi_block_info#filepos.=filepos+12;
2024 return return_val;
2025 }
2026
2027 err:
2028 my_errnocxx . . $ `include/my_pthread.h:720:9`!=HA_ERR_WRONG_IN_RECORDcxx . . $ `include/my_base.h:472:9`!; /* Garbage */
2029 return BLOCK_ERRORcxx . . $ `storage/myisam/myisamdef.h:639:9`!;
2030 }