LTP GCOV extension - code coverage report
Current view: directory - storage/maria - ma_dbug.c
Test: maria-unit-test.html
Date: 2009-03-04 Instrumented lines: 89
Code covered: 0.0 % Executed lines: 0

       1                 : /* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
       2                 : 
       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.
       6                 : 
       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.
      11                 : 
      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 */
      15                 : 
      16                 : /* Support rutiner with are using with dbug */
      17                 : 
      18                 : #include "maria_def.h"
      19                 : 
      20                 : void _ma_print_key(FILE *stream, MARIA_KEY *key)
      21               0 : {
      22               0 :   _ma_print_keydata(stream, key->keyinfo->seg, key->data, key->data_length);
      23                 : }
      24                 : 
      25                 : 
      26                 : /* Print a key in a user understandable format */
      27                 : 
      28                 : void _ma_print_keydata(FILE *stream, register HA_KEYSEG *keyseg,
      29                 :                        const uchar *key, uint length)
      30               0 : {
      31                 :   int flag;
      32                 :   short int s_1;
      33                 :   long  int l_1;
      34                 :   float f_1;
      35                 :   double d_1;
      36                 :   const uchar *end;
      37               0 :   const uchar *key_end= key + length;
      38                 : 
      39               0 :   VOID(fputs("Key: \"",stream));
      40               0 :   flag=0;
      41               0 :   for (; keyseg->type && key < key_end ;keyseg++)
      42                 :   {
      43               0 :     if (flag++)
      44               0 :       VOID(putc('-',stream));
      45               0 :     end= key+ keyseg->length;
      46               0 :     if (keyseg->flag & HA_NULL_PART)
      47                 :     {
      48                 :       /* A NULL value is encoded by a 1-byte flag. Zero means NULL. */
      49               0 :       if (! *(key++))
      50                 :       {
      51               0 :         fprintf(stream,"NULL");
      52               0 :         continue;
      53                 :       }
      54               0 :       end++;
      55                 :     }
      56                 : 
      57               0 :     switch (keyseg->type) {
      58                 :     case HA_KEYTYPE_BINARY:
      59               0 :       if (!(keyseg->flag & HA_SPACE_PACK) && keyseg->length == 1)
      60                 :       {                                         /* packed binary digit */
      61               0 :         VOID(fprintf(stream,"%d",(uint) *key++));
      62               0 :         break;
      63                 :       }
      64                 :       /* fall through */
      65                 :     case HA_KEYTYPE_TEXT:
      66                 :     case HA_KEYTYPE_NUM:
      67               0 :       if (keyseg->flag & HA_SPACE_PACK)
      68                 :       {
      69               0 :         VOID(fprintf(stream,"%.*s",(int) *key,key+1));
      70               0 :         key+= (int) *key+1;
      71                 :       }
      72                 :       else
      73                 :       {
      74               0 :         VOID(fprintf(stream,"%.*s",(int) keyseg->length,key));
      75               0 :         key=end;
      76                 :       }
      77                 :       break;
      78                 :     case HA_KEYTYPE_INT8:
      79               0 :       VOID(fprintf(stream,"%d",(int) *((const signed char*) key)));
      80               0 :       key=end;
      81               0 :       break;
      82                 :     case HA_KEYTYPE_SHORT_INT:
      83               0 :       s_1= mi_sint2korr(key);
      84               0 :       VOID(fprintf(stream,"%d",(int) s_1));
      85               0 :       key=end;
      86               0 :       break;
      87                 :     case HA_KEYTYPE_USHORT_INT:
      88                 :       {
      89                 :         ushort u_1;
      90               0 :         u_1= mi_uint2korr(key);
      91               0 :         VOID(fprintf(stream,"%u",(uint) u_1));
      92               0 :         key=end;
      93               0 :         break;
      94                 :       }
      95                 :     case HA_KEYTYPE_LONG_INT:
      96               0 :       l_1=mi_sint4korr(key);
      97               0 :       VOID(fprintf(stream,"%ld",l_1));
      98               0 :       key=end;
      99               0 :       break;
     100                 :     case HA_KEYTYPE_ULONG_INT:
     101               0 :       l_1=mi_uint4korr(key);
     102               0 :       VOID(fprintf(stream,"%lu",(ulong) l_1));
     103               0 :       key=end;
     104               0 :       break;
     105                 :     case HA_KEYTYPE_INT24:
     106               0 :       VOID(fprintf(stream,"%ld",(long) mi_sint3korr(key)));
     107               0 :       key=end;
     108               0 :       break;
     109                 :     case HA_KEYTYPE_UINT24:
     110               0 :       VOID(fprintf(stream,"%lu",(ulong) mi_uint3korr(key)));
     111               0 :       key=end;
     112               0 :       break;
     113                 :     case HA_KEYTYPE_FLOAT:
     114               0 :       mi_float4get(f_1,key);
     115               0 :       VOID(fprintf(stream,"%g",(double) f_1));
     116               0 :       key=end;
     117               0 :       break;
     118                 :     case HA_KEYTYPE_DOUBLE:
     119               0 :       mi_float8get(d_1,key);
     120               0 :       VOID(fprintf(stream,"%g",d_1));
     121               0 :       key=end;
     122               0 :       break;
     123                 : #ifdef HAVE_LONG_LONG
     124                 :     case HA_KEYTYPE_LONGLONG:
     125                 :     {
     126                 :       char buff[21];
     127               0 :       longlong2str(mi_sint8korr(key),buff,-10);
     128               0 :       VOID(fprintf(stream,"%s",buff));
     129               0 :       key=end;
     130               0 :       break;
     131                 :     }
     132                 :     case HA_KEYTYPE_ULONGLONG:
     133                 :     {
     134                 :       char buff[21];
     135               0 :       longlong2str(mi_sint8korr(key),buff,10);
     136               0 :       VOID(fprintf(stream,"%s",buff));
     137               0 :       key=end;
     138               0 :       break;
     139                 :     }
     140                 :     case HA_KEYTYPE_BIT:
     141                 :     {
     142                 :       uint i;
     143               0 :       fputs("0x",stream);
     144               0 :       for (i=0 ; i < keyseg->length ; i++)
     145               0 :         fprintf(stream, "%02x", (uint) *key++);
     146               0 :       key= end;
     147               0 :       break;
     148                 :     }
     149                 : 
     150                 : #endif
     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 */
     155                 :     {
     156                 :       uint tmp_length;
     157               0 :       get_key_length(tmp_length,key);
     158                 :       /*
     159                 :         The following command sometimes gives a warning from valgrind.
     160                 :         Not yet sure if the bug is in valgrind, glibc or mysqld
     161                 :       */
     162               0 :       VOID(fprintf(stream,"%.*s",(int) tmp_length,key));
     163               0 :       key+=tmp_length;
     164                 :       break;
     165                 :     }
     166                 :     default: break;                     /* This never happens */
     167                 :     }
     168                 :   }
     169               0 :   VOID(fputs("\"\n",stream));
     170                 :   return;
     171                 : } /* print_key */
     172                 : 
     173                 : 
     174                 : #ifdef EXTRA_DEBUG
     175                 : 
     176                 : my_bool _ma_check_table_is_closed(const char *name, const char *where)
     177               0 : {
     178                 :   char filename[FN_REFLEN];
     179                 :   LIST *pos;
     180               0 :   DBUG_ENTER("_ma_check_table_is_closed");
     181                 : 
     182               0 :   (void) fn_format(filename,name,"",MARIA_NAME_IEXT,4+16+32);
     183               0 :   pthread_mutex_lock(&THR_LOCK_maria);
     184               0 :   for (pos=maria_open_list ; pos ; pos=pos->next)
     185                 :   {
     186               0 :     MARIA_HA *info=(MARIA_HA*) pos->data;
     187               0 :     MARIA_SHARE *share= info->s;
     188               0 :     if (!strcmp(share->unique_file_name.str, filename))
     189                 :     {
     190               0 :       if (share->last_version)
     191                 :       {
     192               0 :         fprintf(stderr,"Warning:  Table: %s is open on %s\n", name,where);
     193               0 :         DBUG_PRINT("warning",("Table: %s is open on %s", name,where));
     194               0 :         pthread_mutex_unlock(&THR_LOCK_maria);
     195               0 :         DBUG_RETURN(1);
     196                 :       }
     197                 :     }
     198                 :   }
     199               0 :   pthread_mutex_unlock(&THR_LOCK_maria);
     200               0 :   DBUG_RETURN(0);
     201                 : }
     202                 : #endif /* EXTRA_DEBUG */

Generated by: LTP GCOV extension version 1.4