LTP GCOV extension - code coverage report
Current view: directory - storage/maria - ma_init.c
Test: maria-unit-test.html
Date: 2009-03-04 Instrumented lines: 31
Code covered: 83.9 % Executed lines: 26

       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                 : /* Initialize an maria-database */
      17                 : 
      18                 : #include "maria_def.h"
      19                 : #include <ft_global.h>
      20                 : #include "ma_blockrec.h"
      21                 : #include "trnman_public.h"
      22                 : #include "ma_checkpoint.h"
      23                 : #include <hash.h>
      24                 : 
      25                 : void history_state_free(MARIA_STATE_HISTORY_CLOSED *closed_history)
      26               0 : {
      27                 :   MARIA_STATE_HISTORY *history, *next;
      28                 : 
      29                 :   /*
      30                 :     Free all active history
      31                 :     In case of maria_open() this list should be empty as the history is moved
      32                 :     to handler->share.
      33                 :  */
      34               0 :   for (history= closed_history->state_history; history ; history= next)
      35                 :   {
      36               0 :     next= history->next;
      37               0 :     my_free(history, MYF(0));
      38                 :   }
      39               0 :   my_free(closed_history, MYF(0));
      40                 : }
      41                 : 
      42                 : 
      43                 : /*
      44                 :   Initialize maria
      45                 : 
      46                 :   SYNOPSIS
      47                 :     maria_init()
      48                 : 
      49                 :   TODO
      50                 :     Open log files and do recovery if need
      51                 : 
      52                 :   RETURN
      53                 :   0  ok
      54                 :   #  error number
      55                 : */
      56                 : 
      57                 : int maria_init(void)
      58            2553 : {
      59            2553 :   DBUG_ASSERT(maria_block_size &&
      60                 :               maria_block_size % MARIA_MIN_KEY_BLOCK_LENGTH == 0);
      61            2553 :   if (!maria_inited)
      62                 :   {
      63            2553 :     maria_inited= TRUE;
      64            2553 :     pthread_mutex_init(&THR_LOCK_maria,MY_MUTEX_INIT_SLOW);
      65            2553 :     _ma_init_block_record_data();
      66            2553 :     trnman_end_trans_hook= _ma_trnman_end_trans_hook;
      67            2553 :     my_handler_error_register();
      68                 :   }
      69            2553 :   hash_init(&maria_stored_state, &my_charset_bin, 32,
      70                 :             0, sizeof(LSN), 0, (hash_free_key) history_state_free, 0);
      71            2553 :   DBUG_PRINT("info",("dummy_transaction_object: %p",
      72                 :                      &dummy_transaction_object));
      73            2553 :   return 0;
      74                 : }
      75                 : 
      76                 : 
      77                 : void maria_end(void)
      78            2571 : {
      79            2571 :   if (maria_inited)
      80                 :   {
      81                 :     TrID trid;
      82            2454 :     maria_inited= maria_multi_threaded= FALSE;
      83            2454 :     ft_free_stopwords();
      84            2454 :     ma_checkpoint_end();
      85            2454 :     if ((trid= trnman_get_max_trid()) > max_trid_in_control_file)
      86                 :     {
      87                 :       /*
      88                 :         Store max transaction id into control file, in case logs are removed
      89                 :         by user, or maria_chk wants to check tables (it cannot access max trid
      90                 :         from the log, as it cannot process REDOs).
      91                 :       */
      92             297 :       (void)ma_control_file_write_and_force(last_checkpoint_lsn, last_logno,
      93                 :                                             trid, recovery_failures);
      94                 :     }
      95            2454 :     trnman_destroy();
      96            2454 :     if (translog_status == TRANSLOG_OK)
      97             686 :       translog_destroy();
      98            2454 :     end_pagecache(maria_log_pagecache, TRUE);
      99            2454 :     end_pagecache(maria_pagecache, TRUE);
     100            2454 :     ma_control_file_end();
     101            2454 :     pthread_mutex_destroy(&THR_LOCK_maria);
     102            2454 :     hash_free(&maria_stored_state);
     103                 :   }
     104                 : }

Generated by: LTP GCOV extension version 1.4