1
/* Copyright (C) 2000-2005 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
/* Support rutiner with are using with dbug */
18
#include "myisamdef.h"
20
/* Print a key in user understandable format */
22
void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg,
23
const uchar *key, uint length)
31
const uchar *key_end=key+length;
33
VOID(fputs("Key: \"",stream));
35
for (; keyseg->type && key < key_end ;keyseg++)
38
VOID(putc('-',stream));
39
end= key+ keyseg->length;
40
if (keyseg->flag & HA_NULL_PART)
42
/* A NULL value is encoded by a 1-byte flag. Zero means NULL. */
45
fprintf(stream,"NULL");
50
switch (keyseg->type) {
51
case HA_KEYTYPE_BINARY:
52
if (!(keyseg->flag & HA_SPACE_PACK) && keyseg->length == 1)
53
{ /* packed binary digit */
54
VOID(fprintf(stream,"%d",(uint) *key++));
60
if (keyseg->flag & HA_SPACE_PACK)
62
VOID(fprintf(stream,"%.*s",(int) *key,key+1));
67
VOID(fprintf(stream,"%.*s",(int) keyseg->length,key));
72
VOID(fprintf(stream,"%d",(int) *((signed char*) key)));
75
case HA_KEYTYPE_SHORT_INT:
76
s_1= mi_sint2korr(key);
77
VOID(fprintf(stream,"%d",(int) s_1));
80
case HA_KEYTYPE_USHORT_INT:
83
u_1= mi_uint2korr(key);
84
VOID(fprintf(stream,"%u",(uint) u_1));
88
case HA_KEYTYPE_LONG_INT:
89
l_1=mi_sint4korr(key);
90
VOID(fprintf(stream,"%ld",l_1));
93
case HA_KEYTYPE_ULONG_INT:
94
l_1=mi_sint4korr(key);
95
VOID(fprintf(stream,"%lu",(ulong) l_1));
98
case HA_KEYTYPE_INT24:
99
VOID(fprintf(stream,"%ld",(long) mi_sint3korr(key)));
102
case HA_KEYTYPE_UINT24:
103
VOID(fprintf(stream,"%lu",(ulong) mi_uint3korr(key)));
106
case HA_KEYTYPE_FLOAT:
107
mi_float4get(f_1,key);
108
VOID(fprintf(stream,"%g",(double) f_1));
111
case HA_KEYTYPE_DOUBLE:
112
mi_float8get(d_1,key);
113
VOID(fprintf(stream,"%g",d_1));
116
#ifdef HAVE_LONG_LONG
117
case HA_KEYTYPE_LONGLONG:
120
longlong2str(mi_sint8korr(key),buff,-10);
121
VOID(fprintf(stream,"%s",buff));
125
case HA_KEYTYPE_ULONGLONG:
128
longlong2str(mi_sint8korr(key),buff,10);
129
VOID(fprintf(stream,"%s",buff));
137
for (i=0 ; i < keyseg->length ; i++)
138
fprintf(stream, "%02x", (uint) *key++);
144
case HA_KEYTYPE_VARTEXT1: /* VARCHAR and TEXT */
145
case HA_KEYTYPE_VARTEXT2: /* VARCHAR and TEXT */
146
case HA_KEYTYPE_VARBINARY1: /* VARBINARY and BLOB */
147
case HA_KEYTYPE_VARBINARY2: /* VARBINARY and BLOB */
150
get_key_length(tmp_length,key);
152
The following command sometimes gives a warning from valgrind.
153
Not yet sure if the bug is in valgrind, glibc or mysqld
155
VOID(fprintf(stream,"%.*s",(int) tmp_length,key));
159
default: break; /* This never happens */
162
VOID(fputs("\"\n",stream));
169
my_bool check_table_is_closed(const char *name, const char *where)
171
char filename[FN_REFLEN];
173
DBUG_ENTER("check_table_is_closed");
175
pthread_mutex_lock(&THR_LOCK_myisam);
177
(void) fn_format(filename,name,"",MI_NAME_IEXT,4+16+32);
178
for (pos=myisam_open_list ; pos ; pos=pos->next)
180
MI_INFO *info=(MI_INFO*) pos->data;
181
MYISAM_SHARE *share=info->s;
182
if (!strcmp(share->unique_file_name,filename))
184
if (share->last_version)
186
fprintf(stderr,"Warning: Table: %s is open on %s\n", name,where);
187
DBUG_PRINT("warning",("Table: %s is open on %s", name,where));
188
pthread_mutex_unlock(&THR_LOCK_myisam);
193
pthread_mutex_unlock(&THR_LOCK_myisam);
196
#endif /* EXTRA_DEBUG */