~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/test/ndbapi/bench/ndb_error.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL 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
#ifndef NDB_ERROR_H
 
17
#define NDB_ERROR_H
 
18
 
 
19
#include <ndb_global.h>
 
20
#include <NdbOut.hpp>
 
21
#include "userInterface.h"
 
22
#include <NdbError.hpp>
 
23
#include <NdbApi.hpp>
 
24
 
 
25
#define error_handler(x,y, z) { \
 
26
   ndbout << x << " " << y << endl; \
 
27
   exit(-1); }
 
28
 
 
29
#define CHECK_MINUS_ONE(x, y, z) if(x == -1) \
 
30
   error_handler(y,(z->getNdbError()), 0)
 
31
  
 
32
inline
 
33
void
 
34
CHECK_ALLOWED_ERROR(const char * str, 
 
35
                    const ThreadData * td, 
 
36
                    const struct NdbError & error){
 
37
  
 
38
  char buf[100];
 
39
  snprintf(buf, sizeof(buf), "subscriber = %.*s ", 
 
40
          SUBSCRIBER_NUMBER_LENGTH, 
 
41
          td->transactionData.number);
 
42
  ndbout << str << " " << error << endl
 
43
         << buf;
 
44
  showTime();
 
45
  
 
46
  switch(error.classification) { 
 
47
  case NdbError::TimeoutExpired:  
 
48
  case NdbError::OverloadError: 
 
49
  case NdbError::TemporaryResourceError: 
 
50
  case NdbError::NodeRecoveryError:
 
51
    break;    
 
52
  default:    
 
53
    if(error.status != NdbError::TemporaryError)
 
54
      exit(-1);
 
55
  }
 
56
}
 
57
 
 
58
inline
 
59
void
 
60
CHECK_NULL(void * null, 
 
61
           const char * str, 
 
62
           const ThreadData * td,
 
63
           const struct NdbError & err){
 
64
  if(null == 0){
 
65
    CHECK_ALLOWED_ERROR(str, td, err);
 
66
    exit(-1);
 
67
  }
 
68
}
 
69
 
 
70
inline
 
71
void
 
72
CHECK_NULL(void * null, const char* msg, NdbConnection* obj)
 
73
{
 
74
  if(null == 0)
 
75
  {
 
76
    error_handler(msg, obj->getNdbError(), 0);
 
77
  }
 
78
}
 
79
 
 
80
#endif