Debian Codegraph @

storage/myisam/mi_info.c

raw symbols SCIP
1 /* Copyright (c) 2000, 2001, 2003-2007 MySQL AB, 2009 Sun Microsystems, Inc.
2 Use is subject to license terms.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
16
17 /* Return useful base information for an open table */
18
19 #include "myisamdef.h"cxx . . $ `<file>/storage/myisam/myisamdef.h`/
20 #ifdef _WIN32
21 #include <sys/stat.h>
22 #endif
23
24 /* Get position to last record */
25
26 my_off_tcxx . . $ my_off_t# mi_positioncxx . . $ mi_position(f47fce3d6c3fdedf).(MI_INFOcxx . . $ MI_INFO# *info)
27 {
28 return info->lastposcxx . . $ st_myisam_info#lastpos.;
29 }
30
31
32 /* Get information about the table */
33 /* if flag == 2 one get current info (no sync from database */
34
35 int mi_statuscxx . . $ mi_status(f2de6e8a9578a3ea).(MI_INFOcxx . . $ MI_INFO# *info, register MI_ISAMINFOcxx . . $ MI_ISAMINFO# *x, uintcxx . . $ uint# flag)
36 {
37 MY_STATcxx . . $ `include/my_dir.h:82:9`! state;
38 MYISAM_SHAREcxx . . $ MYISAM_SHARE# *share=info->scxx . . $ st_myisam_info#s.;
39 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("mi_status");
40
41 x->recposcxx . . $ st_mi_isaminfo#recpos. = info->lastposcxx . . $ st_myisam_info#lastpos.;
42 if (flag == HA_STATUS_POScxx . . $ `include/my_base.h:414:9`!)
43 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); /* Compatible with ISAM */
44 if (!(flag & HA_STATUS_NO_LOCKcxx . . $ `include/my_base.h:421:9`!))
45 {
46 mysql_mutex_lockcxx . . $ `include/mysql/psi/mysql_thread.h:360:11`!(&share->intern_lock);
47 (void) _mi_readinfocxx . . $ _mi_readinfo(fd66c073ad9c9ca7).(info,F_RDLCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:223:10`!,0);
48 fast_mi_writeinfocxx . . $ `storage/myisam/myisamdef.h:672:9`!(info);
49 mysql_mutex_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:391:11`!(&share->intern_lock);
50 }
51 if (flag & HA_STATUS_VARIABLEcxx . . $ `include/my_base.h:436:9`!)
52 {
53 x->recordscxx . . $ st_mi_isaminfo#records. = info->statecxx . . $ st_myisam_info#state.->recordscxx . . $ st_mi_status_info#records.;
54 x->deletedcxx . . $ st_mi_isaminfo#deleted. = info->statecxx . . $ st_myisam_info#state.->delcxx . . $ st_mi_status_info#del.;
55 x->delete_lengthcxx . . $ st_mi_isaminfo#delete_length. = info->statecxx . . $ st_myisam_info#state.->emptycxx . . $ st_mi_status_info#empty.;
56 x->data_file_lengthcxx . . $ st_mi_isaminfo#data_file_length. =info->statecxx . . $ st_myisam_info#state.->data_file_lengthcxx . . $ st_mi_status_info#data_file_length.;
57 x->index_file_lengthcxx . . $ st_mi_isaminfo#index_file_length.=info->statecxx . . $ st_myisam_info#state.->key_file_lengthcxx . . $ st_mi_status_info#key_file_length.;
58
59 x->keyscxx . . $ st_mi_isaminfo#keys. = share->statecxx . . $ st_mi_isam_share#state..headercxx . . $ st_mi_state_info#header..keyscxx . . $ st_mi_state_info#$anonymous_type_0#keys.;
60 x->check_timecxx . . $ st_mi_isaminfo#check_time. = share->statecxx . . $ st_mi_isam_share#state..check_timecxx . . $ st_mi_state_info#check_time.;
61 x->mean_reclengthcxx . . $ st_mi_isaminfo#mean_reclength.= x->recordscxx . . $ st_mi_isaminfo#records. ?
62 (ulongcxx . . $ ulong#) ((x->data_file_lengthcxx . . $ st_mi_isaminfo#data_file_length. - x->delete_lengthcxx . . $ st_mi_isaminfo#delete_length.) / x->recordscxx . . $ st_mi_isaminfo#records.) :
63 (ulongcxx . . $ ulong#) share->min_pack_lengthcxx . . $ st_mi_isam_share#min_pack_length.;
64 }
65 if (flag & HA_STATUS_ERRKEYcxx . . $ `include/my_base.h:442:9`!)
66 {
67 x->errkeycxx . . $ st_mi_isaminfo#errkey. = info->errkeycxx . . $ st_myisam_info#errkey.;
68 x->dupp_key_poscxx . . $ st_mi_isaminfo#dupp_key_pos.= info->dupp_key_poscxx . . $ st_myisam_info#dupp_key_pos.;
69 }
70 if (flag & HA_STATUS_CONSTcxx . . $ `include/my_base.h:430:9`!)
71 {
72 x->reclengthcxx . . $ st_mi_isaminfo#reclength. = share->basecxx . . $ st_mi_isam_share#base..reclengthcxx . . $ st_mi_base_info#reclength.;
73 x->max_data_file_lengthcxx . . $ st_mi_isaminfo#max_data_file_length.=share->basecxx . . $ st_mi_isam_share#base..max_data_file_lengthcxx . . $ st_mi_base_info#max_data_file_length.;
74 x->max_index_file_lengthcxx . . $ st_mi_isaminfo#max_index_file_length.=info->scxx . . $ st_myisam_info#s.->basecxx . . $ st_mi_isam_share#base..max_key_file_lengthcxx . . $ st_mi_base_info#max_key_file_length.;
75 x->filenrcxx . . $ st_mi_isaminfo#filenr. = info->dfilecxx . . $ st_myisam_info#dfile.;
76 x->optionscxx . . $ st_mi_isaminfo#options. = share->optionscxx . . $ st_mi_isam_share#options.;
77 x->create_timecxx . . $ st_mi_isaminfo#create_time.=share->statecxx . . $ st_mi_isam_share#state..create_timecxx . . $ st_mi_state_info#create_time.;
78 x->reflengthcxx . . $ st_mi_isaminfo#reflength.= share->basecxx . . $ st_mi_isam_share#base..rec_reflengthcxx . . $ st_mi_base_info#rec_reflength.;
79 x->record_offsetcxx . . $ st_mi_isaminfo#record_offset.= ((share->optionscxx . . $ st_mi_isam_share#options. &
80 (HA_OPTION_PACK_RECORDcxx . . $ `include/my_base.h:344:9`! | HA_OPTION_COMPRESS_RECORDcxx . . $ `include/my_base.h:346:9`!)) ?
81 0L : share->basecxx . . $ st_mi_isam_share#base..pack_reclengthcxx . . $ st_mi_base_info#pack_reclength.);
82 x->sortkeycxx . . $ st_mi_isaminfo#sortkey.= -1; /* No clustering */
83 x->rec_per_keycxx . . $ st_mi_isaminfo#rec_per_key. = share->statecxx . . $ st_mi_isam_share#state..rec_per_key_partcxx . . $ st_mi_state_info#rec_per_key_part.;
84 x->key_mapcxx . . $ st_mi_isaminfo#key_map. = share->statecxx . . $ st_mi_isam_share#state..key_mapcxx . . $ st_mi_state_info#key_map.;
85 x->data_file_namecxx . . $ st_mi_isaminfo#data_file_name. = share->data_file_namecxx . . $ st_mi_isam_share#data_file_name.;
86 x->index_file_namecxx . . $ st_mi_isaminfo#index_file_name. = share->index_file_namecxx . . $ st_mi_isam_share#index_file_name.;
87 }
88 if ((flag & HA_STATUS_TIMEcxx . . $ `include/my_base.h:423:9`!) && !mysql_file_fstatcxx . . $ `include/mysql/psi/mysql_file.h:164:11`!(info->dfile, &state, MYFcxx . . $ `include/my_global.h:986:9`!(0)))
89 x->update_timecxx . . $ st_mi_isaminfo#update_time.=state.st_mtimecxx . . $ `<external>/16045971866008360577/struct_stat.h:78:11`!;
90 else
91 x->update_timecxx . . $ st_mi_isaminfo#update_time.=0;
92 if (flag & HA_STATUS_AUTOcxx . . $ `include/my_base.h:446:9`!)
93 {
94 x->auto_incrementcxx . . $ st_mi_isaminfo#auto_increment.= share->statecxx . . $ st_mi_isam_share#state..auto_incrementcxx . . $ st_mi_state_info#auto_increment.+1;
95 if (!x->auto_incrementcxx . . $ st_mi_isaminfo#auto_increment.) /* This shouldn't happen */
96 x->auto_incrementcxx . . $ st_mi_isaminfo#auto_increment.= ~(ulonglongcxx . . $ ulonglong#) 0;
97 }
98 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0);
99 }
100
101
102 /*
103 Write a message to the error log.
104
105 SYNOPSIS
106 mi_report_error()
107 file_name Name of table file (e.g. index_file_name).
108 errcode Error number.
109
110 DESCRIPTION
111 This function supplies my_error() with a table name. Most error
112 messages need one. Since string arguments in error messages are limited
113 to 64 characters by convention, we ensure that in case of truncation,
114 that the end of the index file path is in the message. This contains
115 the most valuable information (the table name and the database name).
116
117 RETURN
118 void
119 */
120
121 void mi_report_errorcxx . . $ mi_report_error(66835f578de1bcb3).(int errcode, const char *file_name)
122 {
123 size_t lgt;
124 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("mi_report_error");
125 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("enter",("errcode %d, table '%s'", errcode, file_name));
126
127 if ((lgt= strlencxx . . $ strlen(751346f8406fd082).(file_name)) > 64)
128 file_name+= lgt - 64;
129 my_errorcxx . . $ my_error(21e90ace5e448e7a).(errcode, MYFcxx . . $ `include/my_global.h:986:9`!(ME_ERROR_LOGcxx . . $ `include/my_sys.h:106:9`!), file_name);
130 DBUG_VOID_RETURNcxx . . $ `include/my_dbug.h:169:9`!;
131 }
132