CUBRID Engine  latest
connection_error.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * connection_error.h -
22  */
23 
24 #ifndef _CONNECTION_ERROR_H_
25 #define _CONNECTION_ERROR_H_
26 
27 #ident "$Id$"
28 
29 #if defined (SERVER_MODE)
30 #include "connection_defs.h"
31 #include "error_manager.h"
32 #endif /* SERVER_MODE */
33 
34 #if defined (SERVER_MODE)
35 #include <errno.h>
36 #endif // SERVER_MODE
37 #if defined (SERVER_MODE) && !defined(WINDOWS)
38 #include <pthread.h>
39 #endif // SERVER_MODE and not WINDOWS
40 #include <stdio.h>
41 
42 /* TODO: ER_CSS_NOERROR -> NO_ERROR */
43 #define ER_CSS_NOERROR 0
44 
45 #if defined(SERVER_MODE)
46 #define CSS_CHECK(r, e) \
47  do \
48  { \
49  if ((r) != 0) \
50  { \
51  er_set_with_oserror (ER_ERROR_SEVERITY, ARG_FILE_LINE, (e), 0); \
52  } \
53  } \
54  while (0)
55 
56 #define CSS_CHECK_RETURN(r, e) \
57  do \
58  { \
59  if ((r) != 0) \
60  { \
61  er_set_with_oserror (ER_ERROR_SEVERITY, ARG_FILE_LINE, (e), 0); \
62  return; \
63  } \
64  } \
65  while (0)
66 
67 #define CSS_CHECK_RETURN_ERROR(r, e) \
68  do { \
69  if ((r) != 0) { \
70  er_set_with_oserror(ER_ERROR_SEVERITY, ARG_FILE_LINE, (e), 0); \
71  return (e); \
72  } \
73  } while(0)
74 
75 #define CSS_CHECK_CONTINUE(r, e) \
76  do \
77  { \
78  if ((r) != 0) \
79  { \
80  er_set_with_oserror (ER_ERROR_SEVERITY, ARG_FILE_LINE, (e), 0); \
81  continue; \
82  } \
83  } \
84  while (0)
85 
86 #if defined(TRACE_LIST)
87 #define PRINT_INIT_LIST(p) \
88  fprintf (stderr, "TID(%2d):%10s(%4d): Initialize LIST (%p)\n", \
89  THREAD_ID(), __FILE__, __LINE__, (p))
90 
91 #define PRINT_FINALIZE_LIST(p) \
92  fprintf (stderr, "TID(%2d):%10s(%4d): Finalize LIST (%p)\n", \
93  THREAD_ID(), __FILE__, __LINE__, (p))
94 
95 #define PRINT_TRY_LOCK(p) \
96  fprintf (stderr, "TID(%2d):%10s(%4d): Before LOCK on (%p)\n", \
97  THREAD_ID(), __FILE__, __LINE__, (p))
98 
99 #define PRINT_DONE_LOCK(p) \
100  fprintf (stderr, "TID(%2d):%10s(%4d): After LOCK on (%p)\n", \
101  THREAD_ID(), __FILE__, __LINE__, (p))
102 
103 #define PRINT_TRY_UNLOCK(p) \
104  fprintf (stderr, "TID(%2d):%10s(%4d): Before UNLOCK on (%p)\n", \
105  THREAD_ID(), __FILE__, __LINE__, (p))
106 
107 #define PRINT_DONE_UNLOCK(p) \
108  fprintf (stderr, "TID(%2d):%10s(%4d): After UNLOCK on (%p)\n", \
109  THREAD_ID(), __FILE__, __LINE__, (p))
110 #else /* TRACE_LIST */
111 #define PRINT_INIT_LIST(p)
112 #define PRINT_FINALIZE_LIST(p)
113 #define PRINT_TRY_LOCK(p)
114 #define PRINT_DONE_LOCK(p)
115 #define PRINT_TRY_UNLOCK(p)
116 #define PRINT_DONE_UNLOCK(p)
117 #endif /* TRACE_LIST */
118 
119 #if defined(PRINTING)
120 #define CSS_TRACE1(a) \
121  do \
122  { \
123  fprintf (stderr, "TID(%2d):%10s(%4d): " a, \
124  THREAD_ID (), __FILE__, __LINE__); \
125  } \
126  while (0)
127 
128 #define CSS_TRACE2(a,b) \
129  do \
130  { \
131  fprintf (stderr, "TID(%2d):%10s(%4d): " a, \
132  THREAD_ID (), __FILE__, __LINE__, (b)); \
133  } \
134  while (0)
135 
136 #define CSS_TRACE3(a,b,c) \
137  do \
138  { \
139  fprintf (stderr, "TID(%2d):%10s(%4d): " a, \
140  THREAD_ID (), __FILE__, __LINE__, (b), (c)); \
141  } \
142  while (0)
143 
144 #define CSS_TRACE4(a,b,c,d) \
145  do \
146  { \
147  fprintf (stderr, "TID(%2d):%10s(%4d): " a, \
148  THREAD_ID (), __FILE__, __LINE__, (b), (c), (d)); \
149  } \
150  while (0)
151 
152 #define CSS_TRACE5(a,b,c,d,e) \
153  do \
154  { \
155  fprintf (stderr, "TID(%2d):%10s(%4d): " a, \
156  THREAD_ID (), __FILE__, __LINE__, (b), (c), (d), (e)); \
157  } \
158  while (0)
159 
160 #define CSS_TRACE6(a,b,c,d,e,f) \
161  do \
162  { \
163  fprintf (stderr, "TID(%2d):%10s(%4d): " a, \
164  THREAD_ID (), __FILE__, __LINE__, (b), (c), (d), (e), (f)); \
165  } \
166  while (0)
167 #else /* PRINTING */
168 #define CSS_TRACE1(a)
169 #define CSS_TRACE2(a,b)
170 #define CSS_TRACE3(a,b,c)
171 #define CSS_TRACE4(a,b,c,d)
172 #define CSS_TRACE5(a,b,c,d,e)
173 #define CSS_TRACE6(a,b,c,d,e,f)
174 #endif /* PRINTING */
175 #endif /* SERVER_MODE */
176 
177 #endif /* _CONNECTION_ERROR_H_ */