MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ndb_error.hpp
1 /*
2  Copyright (C) 2005, 2006, 2008 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef NDB_ERROR_H
20 #define NDB_ERROR_H
21 
22 #include <ndb_global.h>
23 #include <NdbOut.hpp>
24 #include "userInterface.h"
25 #include <NdbError.hpp>
26 #include <NdbApi.hpp>
27 
28 #define error_handler(x,y, z) { \
29  ndbout << x << " " << y << endl; \
30  exit(-1); }
31 
32 #define CHECK_MINUS_ONE(x, y, z) if(x == -1) \
33  error_handler(y,(z->getNdbError()), 0)
34 
35 inline
36 void
37 CHECK_ALLOWED_ERROR(const char * str,
38  const ThreadData * td,
39  const struct NdbError & error){
40 
41  char buf[100];
42  BaseString::snprintf(buf, sizeof(buf), "subscriber = %.*s ",
43  SUBSCRIBER_NUMBER_LENGTH,
44  td->transactionData.number);
45  ndbout << str << " " << error << endl
46  << buf;
47  showTime();
48 
49  switch(error.classification) {
54  break;
55  default:
56  if(error.status != NdbError::TemporaryError)
57  exit(-1);
58  }
59 }
60 
61 inline
62 void
63 CHECK_NULL(void * null,
64  const char * str,
65  const ThreadData * td,
66  const struct NdbError & err){
67  if(null == 0){
68  CHECK_ALLOWED_ERROR(str, td, err);
69  exit(-1);
70  }
71 }
72 
73 inline
74 void
75 CHECK_NULL(void * null, const char* msg, NdbConnection* obj)
76 {
77  if(null == 0)
78  {
79  error_handler(msg, obj->getNdbError(), 0);
80  }
81 }
82 
83 #endif