1
/* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 "maria_def.h"
20
void _ma_print_key(FILE *stream, MARIA_KEY *key)
22
_ma_print_keydata(stream, key->keyinfo->seg, key->data, key->data_length);
26
/* Print a key in a user understandable format */
28
void _ma_print_keydata(FILE *stream, register HA_KEYSEG *keyseg,
29
const uchar *key, uint length)
37
const uchar *key_end= key + length;
39
(void)(fputs("Key: \"",stream));
41
for (; keyseg->type && key < key_end ;keyseg++)
44
(void)(putc('-',stream));
45
end= key+ keyseg->length;
46
if (keyseg->flag & HA_NULL_PART)
48
/* A NULL value is encoded by a 1-byte flag. Zero means NULL. */
51
fprintf(stream,"NULL");
57
switch (keyseg->type) {
58
case HA_KEYTYPE_BINARY:
59
if (!(keyseg->flag & HA_SPACE_PACK) && keyseg->length == 1)
60
{ /* packed binary digit */
61
(void)(fprintf(stream,"%d",(uint) *key++));
67
if (keyseg->flag & HA_SPACE_PACK)
69
(void)(fprintf(stream,"%.*s",(int) *key,key+1));
74
(void)(fprintf(stream,"%.*s",(int) keyseg->length,key));
79
(void)(fprintf(stream,"%d",(int) *((const signed char*) key)));
82
case HA_KEYTYPE_SHORT_INT:
83
s_1= mi_sint2korr(key);
84
(void)(fprintf(stream,"%d",(int) s_1));
87
case HA_KEYTYPE_USHORT_INT:
90
u_1= mi_uint2korr(key);
91
(void)(fprintf(stream,"%u",(uint) u_1));
95
case HA_KEYTYPE_LONG_INT:
96
l_1=mi_sint4korr(key);
97
(void)(fprintf(stream,"%ld",l_1));
100
case HA_KEYTYPE_ULONG_INT:
101
l_1=mi_uint4korr(key);
102
(void)(fprintf(stream,"%lu",(ulong) l_1));
105
case HA_KEYTYPE_INT24:
106
(void)(fprintf(stream,"%ld",(long) mi_sint3korr(key)));
109
case HA_KEYTYPE_UINT24:
110
(void)(fprintf(stream,"%lu",(ulong) mi_uint3korr(key)));
113
case HA_KEYTYPE_FLOAT:
114
mi_float4get(f_1,key);
115
(void)(fprintf(stream,"%g",(double) f_1));
118
case HA_KEYTYPE_DOUBLE:
119
mi_float8get(d_1,key);
120
(void)(fprintf(stream,"%g",d_1));
123
#ifdef HAVE_LONG_LONG
124
case HA_KEYTYPE_LONGLONG:
127
longlong2str(mi_sint8korr(key),buff,-10);
128
(void)(fprintf(stream,"%s",buff));
132
case HA_KEYTYPE_ULONGLONG:
135
longlong2str(mi_sint8korr(key),buff,10);
136
(void)(fprintf(stream,"%s",buff));
144
for (i=0 ; i < keyseg->length ; i++)
145
fprintf(stream, "%02x", (uint) *key++);
151
case HA_KEYTYPE_VARTEXT1: /* VARCHAR and TEXT */
152
case HA_KEYTYPE_VARTEXT2: /* VARCHAR and TEXT */
153
case HA_KEYTYPE_VARBINARY1: /* VARBINARY and BLOB */
154
case HA_KEYTYPE_VARBINARY2: /* VARBINARY and BLOB */
157
get_key_length(tmp_length,key);
159
The following command sometimes gives a warning from valgrind.
160
Not yet sure if the bug is in valgrind, glibc or mysqld
162
(void)(fprintf(stream,"%.*s",(int) tmp_length,key));
166
default: break; /* This never happens */
169
(void)(fputs("\"\n",stream));
176
my_bool _ma_check_table_is_closed(const char *name, const char *where)
178
char filename[FN_REFLEN];
180
DBUG_ENTER("_ma_check_table_is_closed");
182
(void) fn_format(filename,name,"",MARIA_NAME_IEXT,4+16+32);
183
for (pos=maria_open_list ; pos ; pos=pos->next)
185
MARIA_HA *info=(MARIA_HA*) pos->data;
186
MARIA_SHARE *share= info->s;
187
if (!strcmp(share->unique_file_name,filename))
189
if (share->last_version)
191
fprintf(stderr,"Warning: Table: %s is open on %s\n", name,where);
192
DBUG_PRINT("warning",("Table: %s is open on %s", name,where));
199
#endif /* EXTRA_DEBUG */