1
/* Copyright (C) 2000-2001, 2003-2004 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
/* Return useful base information for an open table */
18
#include "myisamdef.h"
23
/* Get position to last record */
25
my_off_t mi_position(MI_INFO *info)
31
/* Get information about the table */
32
/* if flag == 2 one get current info (no sync from database */
34
int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag)
37
MYISAM_SHARE *share=info->s;
38
DBUG_ENTER("mi_status");
40
x->recpos = info->lastpos;
41
if (flag == HA_STATUS_POS)
42
DBUG_RETURN(0); /* Compatible with ISAM */
43
if (!(flag & HA_STATUS_NO_LOCK))
45
pthread_mutex_lock(&share->intern_lock);
46
VOID(_mi_readinfo(info,F_RDLCK,0));
47
fast_mi_writeinfo(info);
48
pthread_mutex_unlock(&share->intern_lock);
50
if (flag & HA_STATUS_VARIABLE)
52
x->records = info->state->records;
53
x->deleted = info->state->del;
54
x->delete_length = info->state->empty;
55
x->data_file_length =info->state->data_file_length;
56
x->index_file_length=info->state->key_file_length;
58
x->keys = share->state.header.keys;
59
x->check_time = share->state.check_time;
60
x->mean_reclength= x->records ?
61
(ulong) ((x->data_file_length - x->delete_length) / x->records) :
62
(ulong) share->min_pack_length;
64
if (flag & HA_STATUS_ERRKEY)
66
x->errkey = info->errkey;
67
x->dupp_key_pos= info->dupp_key_pos;
69
if (flag & HA_STATUS_CONST)
71
x->reclength = share->base.reclength;
72
x->max_data_file_length=share->base.max_data_file_length;
73
x->max_index_file_length=info->s->base.max_key_file_length;
74
x->filenr = info->dfile;
75
x->options = share->options;
76
x->create_time=share->state.create_time;
77
x->reflength= mi_get_pointer_length(share->base.max_data_file_length,
78
myisam_data_pointer_size);
79
x->record_offset= ((share->options &
80
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ?
81
0L : share->base.pack_reclength);
82
x->sortkey= -1; /* No clustering */
83
x->rec_per_key = share->state.rec_per_key_part;
84
x->key_map = share->state.key_map;
85
x->data_file_name = share->data_file_name;
86
x->index_file_name = share->index_file_name;
88
if ((flag & HA_STATUS_TIME) && !my_fstat(info->dfile,&state,MYF(0)))
89
x->update_time=state.st_mtime;
92
if (flag & HA_STATUS_AUTO)
94
x->auto_increment= share->state.auto_increment+1;
95
if (!x->auto_increment) /* This shouldn't happen */
96
x->auto_increment= ~(ulonglong) 0;
103
Write a message to the error log.
107
file_name Name of table file (e.g. index_file_name).
108
errcode Error number.
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).
121
void mi_report_error(int errcode, const char *file_name)
124
DBUG_ENTER("mi_report_error");
125
DBUG_PRINT("enter",("errcode %d, table '%s'", errcode, file_name));
127
if ((lgt= strlen(file_name)) > 64)
128
file_name+= lgt - 64;
129
my_error(errcode, MYF(ME_NOREFRESH), file_name);