sedna 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/{CHANGES → CHANGES.rdoc} +9 -0
  2. data/{README → README.rdoc} +23 -25
  3. data/Rakefile +32 -9
  4. data/ext/{extconf.rb → sedna/extconf.rb} +33 -21
  5. data/ext/{sedna.c → sedna/sedna.c} +48 -40
  6. data/test/sedna_test.rb +9 -9
  7. data/vendor/sedna/AUTHORS +18 -0
  8. data/vendor/sedna/COPYRIGHT +90 -0
  9. data/vendor/sedna/LICENSE +202 -0
  10. data/vendor/sedna/Makefile.include +423 -0
  11. data/vendor/sedna/Makefile.platform +31 -0
  12. data/vendor/sedna/depend.sed +48 -0
  13. data/vendor/sedna/driver/c/Makefile +98 -0
  14. data/vendor/sedna/driver/c/libsedna.c +1998 -0
  15. data/vendor/sedna/driver/c/libsedna.h +199 -0
  16. data/vendor/sedna/driver/c/sednamt.def +21 -0
  17. data/vendor/sedna/driver/c/sp_defs.h +186 -0
  18. data/vendor/sedna/kernel/common/FastXptrHash.cpp +101 -0
  19. data/vendor/sedna/kernel/common/IntHash.h +314 -0
  20. data/vendor/sedna/kernel/common/IntList.h +224 -0
  21. data/vendor/sedna/kernel/common/Makefile +30 -0
  22. data/vendor/sedna/kernel/common/SSMMsg.cpp +459 -0
  23. data/vendor/sedna/kernel/common/SSMMsg.h +142 -0
  24. data/vendor/sedna/kernel/common/XptrHash.h +435 -0
  25. data/vendor/sedna/kernel/common/argtable.c +972 -0
  26. data/vendor/sedna/kernel/common/argtable.h +896 -0
  27. data/vendor/sedna/kernel/common/base.cpp +339 -0
  28. data/vendor/sedna/kernel/common/base.h +226 -0
  29. data/vendor/sedna/kernel/common/bit_set.cpp +157 -0
  30. data/vendor/sedna/kernel/common/bit_set.h +55 -0
  31. data/vendor/sedna/kernel/common/commutil.h +67 -0
  32. data/vendor/sedna/kernel/common/config.h +62 -0
  33. data/vendor/sedna/kernel/common/counted_ptr.h +74 -0
  34. data/vendor/sedna/kernel/common/errdbg/ErrorCodes.java +1056 -0
  35. data/vendor/sedna/kernel/common/errdbg/Makefile +34 -0
  36. data/vendor/sedna/kernel/common/errdbg/assert.c +133 -0
  37. data/vendor/sedna/kernel/common/errdbg/d_printf.c +150 -0
  38. data/vendor/sedna/kernel/common/errdbg/d_printf.h +91 -0
  39. data/vendor/sedna/kernel/common/errdbg/error.codes +1743 -0
  40. data/vendor/sedna/kernel/common/errdbg/error_codes.c +531 -0
  41. data/vendor/sedna/kernel/common/errdbg/error_codes.h +549 -0
  42. data/vendor/sedna/kernel/common/errdbg/error_codes_scm.scm +527 -0
  43. data/vendor/sedna/kernel/common/errdbg/event_log.c +956 -0
  44. data/vendor/sedna/kernel/common/errdbg/event_log.h +226 -0
  45. data/vendor/sedna/kernel/common/errdbg/exceptions.cpp +155 -0
  46. data/vendor/sedna/kernel/common/errdbg/exceptions.h +559 -0
  47. data/vendor/sedna/kernel/common/errdbg/gen_error_codes +0 -0
  48. data/vendor/sedna/kernel/common/errdbg/gen_error_codes.c +345 -0
  49. data/vendor/sedna/kernel/common/gmm.cpp +192 -0
  50. data/vendor/sedna/kernel/common/gmm.h +29 -0
  51. data/vendor/sedna/kernel/common/ipc_ops.cpp +435 -0
  52. data/vendor/sedna/kernel/common/ipc_ops.h +51 -0
  53. data/vendor/sedna/kernel/common/lfsGlobals.h +12 -0
  54. data/vendor/sedna/kernel/common/lm_base.h +90 -0
  55. data/vendor/sedna/kernel/common/mmgr/Makefile +11 -0
  56. data/vendor/sedna/kernel/common/mmgr/aset.c +1185 -0
  57. data/vendor/sedna/kernel/common/mmgr/mcxt.c +741 -0
  58. data/vendor/sedna/kernel/common/mmgr/memnodes.h +70 -0
  59. data/vendor/sedna/kernel/common/mmgr/memutils.h +145 -0
  60. data/vendor/sedna/kernel/common/mmgr/se_alloc.h +321 -0
  61. data/vendor/sedna/kernel/common/mmgr/track.c +214 -0
  62. data/vendor/sedna/kernel/common/pping.cpp +672 -0
  63. data/vendor/sedna/kernel/common/pping.h +119 -0
  64. data/vendor/sedna/kernel/common/rcv_test.cpp +273 -0
  65. data/vendor/sedna/kernel/common/rcv_test.h +19 -0
  66. data/vendor/sedna/kernel/common/sedna.c +128 -0
  67. data/vendor/sedna/kernel/common/sedna.h +49 -0
  68. data/vendor/sedna/kernel/common/sedna_ef.h +52 -0
  69. data/vendor/sedna/kernel/common/sm_vmm_data.h +144 -0
  70. data/vendor/sedna/kernel/common/sp.c +93 -0
  71. data/vendor/sedna/kernel/common/sp.h +36 -0
  72. data/vendor/sedna/kernel/common/st/Makefile +20 -0
  73. data/vendor/sedna/kernel/common/st/os_linux/stacktrace.c +213 -0
  74. data/vendor/sedna/kernel/common/st/os_nt/stacktrace.c +338 -0
  75. data/vendor/sedna/kernel/common/st/os_other/stacktrace.c +39 -0
  76. data/vendor/sedna/kernel/common/st/stacktrace.h +72 -0
  77. data/vendor/sedna/kernel/common/st/stacktrfmt.c +64 -0
  78. data/vendor/sedna/kernel/common/tr_debug.cpp +112 -0
  79. data/vendor/sedna/kernel/common/tr_debug.h +22 -0
  80. data/vendor/sedna/kernel/common/u/Makefile +14 -0
  81. data/vendor/sedna/kernel/common/u/u.c +268 -0
  82. data/vendor/sedna/kernel/common/u/u.h +715 -0
  83. data/vendor/sedna/kernel/common/u/uatomic.h +12 -0
  84. data/vendor/sedna/kernel/common/u/udl.h +31 -0
  85. data/vendor/sedna/kernel/common/u/uevent.c +406 -0
  86. data/vendor/sedna/kernel/common/u/uevent.h +71 -0
  87. data/vendor/sedna/kernel/common/u/ugnames.cpp +330 -0
  88. data/vendor/sedna/kernel/common/u/ugnames.h +134 -0
  89. data/vendor/sedna/kernel/common/u/uhash_map.h +77 -0
  90. data/vendor/sedna/kernel/common/u/uhdd.c +1018 -0
  91. data/vendor/sedna/kernel/common/u/uhdd.h +206 -0
  92. data/vendor/sedna/kernel/common/u/ummap.cpp +268 -0
  93. data/vendor/sedna/kernel/common/u/ummap.h +60 -0
  94. data/vendor/sedna/kernel/common/u/umutex.c +145 -0
  95. data/vendor/sedna/kernel/common/u/umutex.h +65 -0
  96. data/vendor/sedna/kernel/common/u/upipe.cpp +244 -0
  97. data/vendor/sedna/kernel/common/u/upipe.h +74 -0
  98. data/vendor/sedna/kernel/common/u/uprocess.c +767 -0
  99. data/vendor/sedna/kernel/common/u/uprocess.h +91 -0
  100. data/vendor/sedna/kernel/common/u/usafesync.h +41 -0
  101. data/vendor/sedna/kernel/common/u/usecurity.c +150 -0
  102. data/vendor/sedna/kernel/common/u/usecurity.h +55 -0
  103. data/vendor/sedna/kernel/common/u/usem.c +891 -0
  104. data/vendor/sedna/kernel/common/u/usem.h +83 -0
  105. data/vendor/sedna/kernel/common/u/ushm.c +222 -0
  106. data/vendor/sedna/kernel/common/u/ushm.h +46 -0
  107. data/vendor/sedna/kernel/common/u/usocket.c +541 -0
  108. data/vendor/sedna/kernel/common/u/usocket.h +118 -0
  109. data/vendor/sedna/kernel/common/u/usystem.c +57 -0
  110. data/vendor/sedna/kernel/common/u/usystem.h +46 -0
  111. data/vendor/sedna/kernel/common/u/uthread.c +259 -0
  112. data/vendor/sedna/kernel/common/u/uthread.h +95 -0
  113. data/vendor/sedna/kernel/common/u/utime.c +65 -0
  114. data/vendor/sedna/kernel/common/u/utime.h +40 -0
  115. data/vendor/sedna/kernel/common/u/uutils.c +142 -0
  116. data/vendor/sedna/kernel/common/u/uutils.h +65 -0
  117. data/vendor/sedna/kernel/common/ugc.cpp +156 -0
  118. data/vendor/sedna/kernel/common/ugc.h +15 -0
  119. data/vendor/sedna/kernel/common/utils.cpp +156 -0
  120. data/vendor/sedna/kernel/common/utils.h +133 -0
  121. data/vendor/sedna/kernel/common/version.c +16 -0
  122. data/vendor/sedna/kernel/common/version.h +21 -0
  123. data/vendor/sedna/kernel/common/wustructures.h +18 -0
  124. data/vendor/sedna/kernel/common/wutypes.h +34 -0
  125. data/vendor/sedna/kernel/common/xptr.cpp +17 -0
  126. data/vendor/sedna/kernel/common/xptr.h +211 -0
  127. data/vendor/sedna/ver +1 -0
  128. metadata +142 -14
@@ -0,0 +1,226 @@
1
+ /*
2
+ * File: event_log.h
3
+ * Copyright (C) 2006 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+ /*
7
+ * Architecture of the event log:
8
+ * Event logger is represented as a daemon thread in a main process (in the
9
+ * governor). Other processes should call init function before writing to log
10
+ * (otherwise the message would be written to stderr).
11
+ * Event log writing macros are thread safe.
12
+ */
13
+
14
+ #ifndef _EVENT_LOG_H
15
+ #define _EVENT_LOG_H
16
+
17
+ #include "common/sedna.h"
18
+ #include "common/u/uhdd.h"
19
+
20
+ /* Error level codes */
21
+ #define EL_DBG 8 /* debugging messages */
22
+ #define EL_LOG 7 /* server operational messages */
23
+ #define EL_COMM 6 /* client communication problems */
24
+ #define EL_INFO 5 /* informative messages (like current values of some parameters) */
25
+ #define EL_WARN 4 /* warning - inform that something is going not as well as it could be */
26
+ #define EL_ERROR 3 /* user error (corresponds to SednaUserException) */
27
+ #define EL_SYS 2 /* system call error */
28
+ #define EL_FATAL 1 /* fatal error - perform soft fault (corresponds to SednaSystemException) */
29
+
30
+
31
+ #define SE_EVENT_LOG_FILENAME_LEN 128
32
+ #define SE_EVENT_LOG_FUNCNAME_LEN 128
33
+ #define SE_EVENT_LOG_CONTENT_LEN 1024
34
+
35
+ #define SE_SOFT_FAULT_LOG_DIR "fault-"
36
+ #define SE_LAST_SOFT_FAULT_DIR "fault-last"
37
+ #define SE_ASSERT_FAILED_FILE_NAME "assert_failed"
38
+ #define SE_SOFT_FAULT_LOG_CONTENT_LEN 1024
39
+
40
+ /* Component codes */
41
+ #define EL_UNK 0
42
+ #define EL_CDB 1
43
+ #define EL_DDB 2
44
+ #define EL_GOV 3
45
+ #define EL_RC 4
46
+ #define EL_SM 5
47
+ #define EL_SMSD 6
48
+ #define EL_STOP 7
49
+ #define EL_TRN 8
50
+ #define EL_RCV 9
51
+
52
+
53
+ typedef struct event_log_msg
54
+ {
55
+ int processed;
56
+ int global_elevel;
57
+
58
+ int type;
59
+ int elevel;
60
+ int component;
61
+ char component_detail[SE_MAX_DB_NAME_LENGTH + 1];
62
+ int sid;
63
+ int trid;
64
+ int pid;
65
+ int lineno;
66
+ char filename[SE_EVENT_LOG_FILENAME_LEN];
67
+ char funcname[SE_EVENT_LOG_FUNCNAME_LEN];
68
+ char content[SE_EVENT_LOG_CONTENT_LEN];
69
+ } event_log_msg;
70
+
71
+
72
+
73
+
74
+
75
+ /*----------
76
+ * Error reporting API for short messages (less than SE_EVENT_LOG_CONTENT_LEN)
77
+ * to be used in this way:
78
+ * elog(EL_ERROR,
79
+ * ("Not enough resources to complete the query (mem_free = %d, mem_used = %d)", mem_free, mem_used));
80
+ *----------
81
+ */
82
+ #define elog(elevel, rest) \
83
+ ((elevel) <= event_log_elevel \
84
+ ? ((event_log_initialized) ? (event_log_short_msg_macro((elevel), \
85
+ __FILE__, \
86
+ __LINE__, \
87
+ __SE_FUNCTION__, \
88
+ (event_log_short_msg_param rest))) \
89
+ : (event_log_short_write_to_stderr rest)) \
90
+ : 0)
91
+
92
+ /*----------
93
+ * Error reporting API for long messages to be used in this way:
94
+ * elog_long(EL_LOG, "User query: ", query);
95
+ *----------
96
+ */
97
+ #define elog_long(elevel, short_str, long_str) \
98
+ ((elevel) <= event_log_elevel \
99
+ ? ((event_log_initialized) ? (event_log_long_msg((elevel), \
100
+ __FILE__, \
101
+ __LINE__, \
102
+ __SE_FUNCTION__, \
103
+ (short_str), \
104
+ (long_str))) \
105
+ : (event_log_long_write_to_stderr((short_str), (long_str)))) \
106
+ : 0)
107
+
108
+
109
+
110
+ #ifdef __cplusplus
111
+ extern "C" {
112
+ #endif
113
+
114
+ /*
115
+ * Event log set up parameters
116
+ */
117
+ extern int event_log_elevel; /* current event log error level */
118
+ extern int event_log_location; /* output the originator of record (GOV, SM, etc.)*/
119
+ extern int event_log_detailed_location; /* output filename, function, line */
120
+ extern int event_log_recommended_size; /* after exceeding this size the log file rotate is done */
121
+ extern int event_log_truncate; /* delete file after log rotation? */
122
+
123
+ extern int event_log_initialized;
124
+
125
+ /* ============================================================================
126
+ * Client functions for logging short messages
127
+ * ============================================================================
128
+ */
129
+ int event_log_short_msg_macro(int elevel,
130
+ const char *filename,
131
+ int lineno,
132
+ const char *funcname,
133
+ int content_len);
134
+
135
+ int event_log_short_msg_param(const char *s,
136
+ ...);
137
+
138
+ int event_log_short_msg(int elevel,
139
+ const char *filename,
140
+ int lineno,
141
+ const char *funcname,
142
+ const char *s,
143
+ ...);
144
+
145
+ int event_log_short_write_to_stderr(const char *s, ...);
146
+
147
+
148
+ /* ============================================================================
149
+ * Client functions for logging long messages
150
+ * ============================================================================
151
+ */
152
+ int event_log_long_msg(int elevel,
153
+ const char *filename,
154
+ int lineno,
155
+ const char *funcname,
156
+ const char *short_str,
157
+ const char *long_str);
158
+
159
+ int event_log_long_write_to_stderr(const char *short_str, const char *long_str);
160
+
161
+
162
+ /* ============================================================================
163
+ * Init/release functions
164
+ * ============================================================================
165
+ */
166
+
167
+ /*
168
+ * Start/shutdown event logging daemon
169
+ * (call these functions in the 'main' process)
170
+ *
171
+ */
172
+ int event_logger_start_daemon(int elevel, global_name shm_name, global_name sems_name);
173
+ int event_logger_shutdown_daemon();
174
+
175
+ /*
176
+ * Init/release event log
177
+ * (call these functions in the 'client' processes)
178
+ */
179
+ int event_logger_init(int component, const char* component_detail, global_name shm_name, global_name sems_name);
180
+ int event_logger_release();
181
+
182
+
183
+ /* ============================================================================
184
+ * Set/get functions
185
+ * ============================================================================
186
+ */
187
+
188
+ /*
189
+ * Set session id for trn process
190
+ */
191
+ int event_logger_set_sid(int sid);
192
+
193
+ /*
194
+ * Set transaction id for trn process
195
+ */
196
+ int event_logger_set_trid(int trid);
197
+
198
+ /*
199
+ * Converts level provided from the command line/configuration file to
200
+ * the one of the known by event log (EL_LOG, EL_ERRORS, etc).
201
+ */
202
+ int el_convert_log_level(int level);
203
+
204
+ /*
205
+ * Creates a file for soft fault log
206
+ */
207
+ UFile sedna_soft_fault_log_fh(int component, const char *suffix);
208
+
209
+ /*
210
+ * Creates a separate file with soft fault log (log_message) for the component (component).
211
+ */
212
+ void sedna_soft_fault_log(const char* log_message, int component);
213
+
214
+ /*
215
+ * Sedna soft fault function.
216
+ * !! two sedna_soft_fault functions are defined in exceptions.h
217
+ */
218
+
219
+ void sedna_soft_fault(int component);
220
+
221
+ #ifdef __cplusplus
222
+ }
223
+ #endif
224
+
225
+
226
+ #endif /*_EVENT_LOG_H*/
@@ -0,0 +1,155 @@
1
+ /*
2
+ * File: exceptions.cpp
3
+ * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+ #include "common/sedna.h"
7
+ #include "common/errdbg/exceptions.h"
8
+ #include "common/u/uprocess.h"
9
+ #include "common/errdbg/event_log.h"
10
+
11
+ /* SednaException is derived from std::exception, hence
12
+ it must implement the following method:
13
+
14
+ const char *what() const throw();
15
+
16
+ SednaException defines virtual function to obtain
17
+ error description as std::string, namely getMsg2().
18
+ The string must not vanish when what() function
19
+ returns. We have descriptCache member for this purpose.
20
+ */
21
+ const std::string &SednaException::getMsg() const
22
+ {
23
+ if (descriptCache.empty())
24
+ {
25
+ std::string descript = getMsg2();
26
+ descriptCache.swap(descript);
27
+ }
28
+ return descriptCache;
29
+ }
30
+
31
+ std::string SednaSystemException::getMsg2() const
32
+ {
33
+ std::string res;
34
+ res.reserve(1024);
35
+ res += "SEDNA Message: FATAL ERROR\n";
36
+ res += "System error. This error means system malfunction.\n";
37
+ res += "Details: " + err_msg + "\n";
38
+ #if (EL_DEBUG == 1)
39
+ res += "Position: [" + file + ":" + function + ":" + int2string(line) + "]\n";
40
+ #endif
41
+ return res;
42
+ }
43
+
44
+ std::string SednaSystemEnvException::getMsg2() const
45
+ {
46
+ std::string res;
47
+ res.reserve(1024);
48
+ res += "SEDNA Message: FATAL ERROR\n";
49
+ res += "Environment error. This error is caused by environment (operating system) and ";
50
+ res += "it means that the system cannot continue execution anymore.\n";
51
+ res += "Details: " + err_msg + "\n";
52
+ #if (EL_DEBUG == 1)
53
+ res += "Position: [" + file + ":" + function + ":" + int2string(line) + "]\n";
54
+ #endif
55
+ return res;
56
+ }
57
+
58
+ std::string SednaUserException::getMsg2() const
59
+ {
60
+ std::string res;
61
+ res.reserve(1024);
62
+ res += "SEDNA Message: ERROR ";
63
+ res += std::string(user_error_code_entries[internal_code].code) + "\n";
64
+ res += std::string(user_error_code_entries[internal_code].descr) + "\n";
65
+ if (err_msg.length() != 0)
66
+ {
67
+ res += "Details: " + err_msg + "\n";
68
+ }
69
+ #if (EL_DEBUG == 1)
70
+ res += "Position: [" + file + ":" + function + ":" + int2string(line) + "]\n";
71
+ #endif
72
+ return res;
73
+ }
74
+
75
+ std::string SednaUserExceptionFnError::getMsg2() const
76
+ {
77
+ U_ASSERT(error_name.size() != 0);
78
+
79
+ std::string res;
80
+ res.reserve(1024);
81
+ res += "SEDNA Message: ERROR ";
82
+ res += error_name + "\n";
83
+ res += " " + (error_descr.size() == 0 ? std::string("User defined error") : error_descr) + "\n";
84
+ #if (EL_DEBUG == 1)
85
+ res += "Position: [" + file + ":" + function + ":" + int2string(line) + "]\n";
86
+ #endif
87
+ return res;
88
+ }
89
+
90
+ std::string SednaUserEnvException::getDescription() const
91
+ {
92
+ return err_msg +
93
+ (explanation.length() != 0 ? " (" + explanation + ")"
94
+ : "");
95
+ }
96
+
97
+ std::string SednaUserEnvException::getMsg2() const
98
+ {
99
+ std::string res;
100
+ res.reserve(1024);
101
+ res += "SEDNA Message: ERROR ";
102
+ res += std::string(user_error_code_entries[internal_code].code) + "\n";
103
+ res += std::string(user_error_code_entries[internal_code].descr) + "\n";
104
+ res += "Details: " + err_msg;
105
+ if (explanation.length() != 0)
106
+ {
107
+ res += " (" + explanation + ")";
108
+ }
109
+ res += "\n";
110
+ #if (EL_DEBUG == 1)
111
+ res += "Position: [" + file + ":" + function + ":" + int2string(line) + "]\n";
112
+ #endif
113
+ return res;
114
+ }
115
+
116
+
117
+ void sedna_soft_fault(const SednaException &e, int component)
118
+ {
119
+ SEDNA_SOFT_FAULT_BASE_MSG;
120
+
121
+ char log_message[SE_SOFT_FAULT_LOG_CONTENT_LEN];
122
+ int log_message_len = e.getDescription().length();
123
+
124
+ if (log_message_len != 0)
125
+ fprintf(stderr, "Details: %s\n", e.getDescription().c_str());
126
+ if(log_message_len < SE_SOFT_FAULT_LOG_CONTENT_LEN)
127
+ strcpy(log_message, e.getDescription().c_str());
128
+ else
129
+ strcpy(log_message, "Failed to record exception description into the log\n");
130
+ #if (EL_DEBUG == 1)
131
+ fprintf(stderr, "Position: [%s:%s:%d]\n", e.getFile().c_str(), e.getFunction().c_str(), e.getLine());
132
+ sprintf(log_message+(log_message_len),"\nPosition: [%s:%s:%d]\n", e.getFile().c_str(), e.getFunction().c_str(), e.getLine());
133
+ #endif
134
+
135
+ sedna_soft_fault_log(log_message, component);
136
+ #ifdef SE_MEMORY_TRACK
137
+ DumpUnfreed(component);
138
+ #endif
139
+
140
+ SEDNA_SOFT_FAULT_FINALIZER;
141
+ }
142
+
143
+ void sedna_soft_fault(const char* s, int component)
144
+ {
145
+ SEDNA_SOFT_FAULT_BASE_MSG;
146
+ fprintf(stderr, "Details: %s\n", s);
147
+ sedna_soft_fault_log(s, component);
148
+
149
+ #ifdef SE_MEMORY_TRACK
150
+ DumpUnfreed(component);
151
+ #endif
152
+
153
+ SEDNA_SOFT_FAULT_FINALIZER;
154
+ }
155
+
@@ -0,0 +1,559 @@
1
+ /*
2
+ * File: exceptions.h
3
+ * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+
7
+
8
+ /**
9
+ The following primary exceptions are defined for Sedna (later referred as
10
+ "the system").
11
+
12
+ SednaException
13
+ // \\______________________
14
+ // \\_____________________\\
15
+ // \\
16
+ SednaSystemException SednaUserException ______________________________
17
+ || ________// || \\____________ _______________\\
18
+ || / ________/ || \____________\\ \\
19
+ || // || \\ \\
20
+ SednaSystemEnvException SednaUserExceptionFnError SednaUserEnvException SednaUserSoftException SednaXQueryException
21
+
22
+
23
+ SednaException -- abstract base exception class. You cannot use it for raising
24
+ exceptions
25
+
26
+ SednaSystemException -- use it when some system error happens. This error means
27
+ that the system is completely malfunction. The reaction on this error is hard
28
+ stopping of all components currently running.
29
+
30
+ SednaSystemEnvException -- the same as SednaSystemException except one point.
31
+ The output to a user produced as the reaction to this error says that it was
32
+ environment (operating system) fault and the system can not be longer running.
33
+ For the previous exception responsibility is on the developers.
34
+
35
+ SednaUserException -- use it when some kind of error happens but this error
36
+ is not fatal for the system but rather a recoverable error. Most errors of
37
+ this type are errors caused by users (wrong queries they sends). But they can
38
+ be other errors such as "can not connect to sm because sm is not running"
39
+ caused by trn. The reaction on this error is to produce correct message to the
40
+ user with an explanation of the problem. Error codes and descriptions of errors
41
+ are defined in error.codes file, which is in the same directory as the file you
42
+ are reading now.
43
+
44
+ SednaXQueryException -- use it within physical plan operations (PP*). It has
45
+ semantic as SednaUserException with better diagnostic. Line of the XQuery query
46
+ must be provided with which error is connected. 0 means 'I can't say exact line'.
47
+
48
+ SednaUserExceptionFnError -- use it for errors raised by users (fn:error function).
49
+
50
+ SednaUserEnvException -- the same as SednaUserException with a bit different
51
+ semantics. Use this exception to notify the user that the system cannot do
52
+ something because of the environment (operating system). You need not define
53
+ error code for this kind of error (it is already defined), but you
54
+ rather need to provide a correct description. This exception is needed to
55
+ simplify the life of the developers, because it allow them not to define
56
+ enormous number of error codes for routine operations such as semaphore
57
+ creation.
58
+ The example of using this exception is the following:
59
+
60
+ if (<cannot create semaphore during startup>)
61
+ throw USER_ENV_EXCEPTION("Cannot create semaphore <the name of the semaphore>",
62
+ false);
63
+
64
+ SednaUserSoftException -- this exception class rather differs from other
65
+ exceptions. It is used for correct program termination instead of signaling
66
+ some error condition. Its purpose can be clarified by the following example.
67
+ Suppose you have to parse command line arguments for already started (and
68
+ initialized) process. If you find some error in command line parameters its your
69
+ obligatory to finish the process and bring the error message to the user. If you
70
+ just simply write error message to console and exit from the process, it may
71
+ crash the system because in this case you avoid process deinitialization, which
72
+ is performed by the program code somewhere else in the program. From the other
73
+ hand, if you raise SednaUserException then you have to supply error code and,
74
+ what is more important, the error message that is identified by this error
75
+ code will be enlarged with additional information such as error code and a
76
+ comment. The solution to this problem is to use SednaUserSoftException for raising
77
+ the error. In this case process deinitialization will be completed as a part
78
+ of the standard error handling mechanism and the user will see exactly the same
79
+ error message that you have supplied.
80
+
81
+
82
+
83
+
84
+ For raising exception it is better to use these macroses:
85
+
86
+ #define SYSTEM_EXCEPTION(msg) SednaSystemException(__FILE__, __FUNCTION__, __LINE__, msg)
87
+ #define SYSTEM_ENV_EXCEPTION(msg) SednaSystemEnvException(__FILE__, __FUNCTION__, __LINE__, msg)
88
+ #define USER_EXCEPTION(code) SednaUserException(__FILE__, __FUNCTION__, __LINE__, code)
89
+ #define USER_EXCEPTION2(code, details) SednaUserException(__FILE__, __FUNCTION__, __LINE__, details, code)
90
+ #define XQUERY_EXCEPTION(code) SednaUserException(__FILE__, __FUNCTION__, __LINE__, code, __current_physop)
91
+ #define XQUERY_EXCEPTION2(code, details) SednaUserException(__FILE__, __FUNCTION__, __LINE__, details, code, __current_physop)
92
+ #define USER_EXCEPTION_FNERROR(err_name, err_descr) SednaUserException(__FILE__, __SE_FUNCTION__, __LINE__, err_name, err_descr))
93
+ #define USER_ENV_EXCEPTION(msg, rollback) SednaUserEnvException(__FILE__, __FUNCTION__, __LINE__, msg, rollback)
94
+ #define USER_ENV_EXCEPTION2(msg, expl, rollback) SednaUserEnvException(__FILE__, __FUNCTION__, __LINE__, msg, expl, rollback)
95
+ #define USER_SOFT_EXCEPTION(msg) SednaUserSoftException(__FILE__, __FUNCTION__, __LINE__, msg)
96
+
97
+ Their names are straightfoward. Parameters are:
98
+ msg -- a textual message (some kind of error description)
99
+ code -- the code for user defined error (use constants defined in
100
+ error_codes.h; example is SE1001)
101
+ details -- details for user error
102
+ expl -- explanation of error
103
+ rollback -- does the error leads to rollback?
104
+ __current_physop -- defines current physical operation
105
+
106
+
107
+
108
+ Errors could be outputted to the user in the format of <sedna-message>:
109
+
110
+ <sedna-message. ::=
111
+ "SEDNA Message: " <problem> <line-break>
112
+ <description> <line-break>
113
+ [ "Details: " <details> <line-break> ]
114
+ [ "Position: [" <file> ":" <function> ":" <line> "]" <line-break> ]
115
+
116
+ <problem> ::= "ERROR " <code>
117
+ | "FATAL ERROR"
118
+
119
+ <description> ::= <string-without-without-line-break>
120
+
121
+ <file> ::= <string-without-without-line-break>
122
+
123
+ <function> ::= <string-without-without-line-break>
124
+
125
+ <line> ::= <integer>
126
+
127
+ <code> ::= <code-from-(error.codes)>
128
+
129
+ */
130
+
131
+
132
+
133
+ #ifndef __EXCEPTIONS_H
134
+ #define __EXCEPTIONS_H
135
+
136
+ #include <stdexcept>
137
+ #include <string>
138
+ #include "common/utils.h"
139
+ #include "common/errdbg/error_codes.h"
140
+
141
+ /* Never use catch(...), use catch(ANY_SE_EXCEPTION) instead. Catch(...)
142
+ statement is missinterpreted by cl version 13 and earlier ones. It catches
143
+ not just any C++ object coming from 'throw' statement (as per C++ standard)
144
+ but also access violations and other exceptional conditions reported by OS.
145
+ For catch(ANY_SE_EXCEPTION) to work properly ensure that all exceptions
146
+ in the project are descendants of std::exception class. */
147
+ #define ANY_SE_EXCEPTION std::exception &
148
+
149
+ #define SYSTEM_EXCEPTION(msg) \
150
+ ((U_ASSERT_MACRO(false)), \
151
+ elog(EL_FATAL, (msg)), \
152
+ SednaSystemException(__FILE__, __SE_FUNCTION__, __LINE__, msg))
153
+
154
+ #define SYSTEM_ENV_EXCEPTION(msg) \
155
+ (elog(EL_FATAL, (msg)), \
156
+ SednaSystemEnvException(__FILE__, __SE_FUNCTION__, __LINE__, msg))
157
+
158
+ #define USER_EXCEPTION(internal_code) \
159
+ (elog(EL_ERROR, ("(%s) %s", \
160
+ user_error_code_entries[internal_code].code, \
161
+ user_error_code_entries[internal_code].descr)), \
162
+ SednaUserException(__FILE__, __SE_FUNCTION__, __LINE__, internal_code))
163
+
164
+ #define USER_EXCEPTION2(internal_code, details) \
165
+ (elog(EL_ERROR, ("(%s) %s Details: %s", \
166
+ user_error_code_entries[internal_code].code, \
167
+ user_error_code_entries[internal_code].descr, \
168
+ details)), \
169
+ SednaUserException(__FILE__, __SE_FUNCTION__, __LINE__, details, internal_code))
170
+
171
+ #define XQUERY_EXCEPTION(internal_code) \
172
+ (elog(EL_ERROR, ("(%s) %s", \
173
+ user_error_code_entries[internal_code].code, \
174
+ user_error_code_entries[internal_code].descr)), \
175
+ SednaXQueryException(__FILE__, __SE_FUNCTION__, __LINE__, internal_code, executor_globals::__current_physop))
176
+
177
+ #define XQUERY_EXCEPTION2(internal_code, details) \
178
+ (elog(EL_ERROR, ("(%s) %s Details: %s", \
179
+ user_error_code_entries[internal_code].code, \
180
+ user_error_code_entries[internal_code].descr, \
181
+ details)), \
182
+ SednaXQueryException(__FILE__, __SE_FUNCTION__, __LINE__, details, internal_code, executor_globals::__current_physop))
183
+
184
+ #define USER_EXCEPTION_FNERROR(err_name, err_descr) \
185
+ (elog(EL_ERROR, ("(%s) %s", \
186
+ err_name, \
187
+ err_descr)), \
188
+ SednaUserExceptionFnError(__FILE__, __SE_FUNCTION__, __LINE__, err_name, err_descr))
189
+
190
+ #define USER_ENV_EXCEPTION(msg, rollback) \
191
+ (elog(EL_ERROR, ("(%s) %s Details: %s", \
192
+ user_error_code_entries[0].code, \
193
+ user_error_code_entries[0].descr, \
194
+ msg)), \
195
+ SednaUserEnvException(__FILE__, __SE_FUNCTION__, __LINE__, msg, rollback))
196
+
197
+
198
+ #define USER_ENV_EXCEPTION2(msg, expl, rollback) \
199
+ (elog(EL_ERROR, ("(%s) %s Details: %s (%s)", \
200
+ user_error_code_entries[0].code, \
201
+ user_error_code_entries[0].descr, \
202
+ msg, \
203
+ expl)), \
204
+ SednaUserEnvException(__FILE__, __SE_FUNCTION__, __LINE__, msg, expl, rollback))
205
+
206
+ #define USER_SOFT_EXCEPTION(msg) \
207
+ SednaUserSoftException(__FILE__, __SE_FUNCTION__, __LINE__, msg)
208
+
209
+
210
+ //////////////////////////////////////////////////////////////////////////////
211
+ /// SednaException
212
+ //////////////////////////////////////////////////////////////////////////////
213
+
214
+ class SednaException : public std::exception
215
+ {
216
+ private:
217
+ /* see SednaException::getMsg() for explanation (in cpp file) */
218
+ mutable std::string descriptCache;
219
+
220
+ protected:
221
+ std::string file;
222
+ std::string function;
223
+ int line;
224
+ std::string err_msg;
225
+
226
+ virtual std::string getMsg2() const = 0;
227
+
228
+ public:
229
+ /* Since SednaException is derived from std::exception, throw() specification
230
+ established in base class must be met. The compiler-generated destructor
231
+ has wrong throw() specification since std::string destructor doesn't
232
+ manifest anything about exceptions.
233
+
234
+ GCC is the jerk! */
235
+ ~SednaException() throw() { ; }
236
+
237
+ SednaException(const char* _file_,
238
+ const char* _function_,
239
+ int _line_,
240
+ const char* _err_msg_) : file(_file_),
241
+ function(_function_),
242
+ line(_line_),
243
+ err_msg(_err_msg_) {}
244
+
245
+ const std::string &getMsg() const;
246
+ virtual std::string getDescription() const { return err_msg; }
247
+ virtual std::string getFile() const { return file; }
248
+ virtual std::string getFunction() const { return function; }
249
+ virtual int getLine() const { return line; }
250
+
251
+ /* Throw self. Used somewhere to determine the preciese type
252
+ of the exception object given a reference to SednaException.
253
+ The code is similar to this snippet:
254
+
255
+ void DispatchSednaException(SednaException *e)
256
+ {
257
+ try
258
+ {
259
+ e.rase();
260
+ }
261
+ catch(const SednaSystemEnvException &sysEnvE)
262
+ {
263
+ -- the exception is SednaSystemEnvException, act accordingly --
264
+ }
265
+ catch(const SednaSystemException &sysE)
266
+ {
267
+ -- the exception is SednaSystemException, act accordingly --
268
+ }
269
+ -- etc --
270
+ }*/
271
+ virtual void raise() const = 0;
272
+
273
+ /* The standard method to obtain exception info defined by
274
+ all std::exception descendants. */
275
+ const char *what() const throw() { return getMsg().c_str(); }
276
+ };
277
+
278
+ //////////////////////////////////////////////////////////////////////////////
279
+ /// SednaSystemException
280
+ //////////////////////////////////////////////////////////////////////////////
281
+
282
+ class SednaSystemException : public SednaException
283
+ {
284
+ protected:
285
+ virtual std::string getMsg2() const;
286
+
287
+ public:
288
+ SednaSystemException(const char* _file_,
289
+ const char* _function_,
290
+ int _line_,
291
+ const char* _err_msg_) : SednaException(_file_,
292
+ _function_,
293
+ _line_,
294
+ _err_msg_) {}
295
+ virtual void raise() const { throw *this; }
296
+ };
297
+
298
+ //////////////////////////////////////////////////////////////////////////////
299
+ /// SednaSystemEnvException
300
+ //////////////////////////////////////////////////////////////////////////////
301
+
302
+ class SednaSystemEnvException : public SednaSystemException
303
+ {
304
+ protected:
305
+ virtual std::string getMsg2() const;
306
+
307
+ public:
308
+ SednaSystemEnvException(const char* _file_,
309
+ const char* _function_,
310
+ int _line_,
311
+ const char* _err_msg_) : SednaSystemException(_file_,
312
+ _function_,
313
+ _line_,
314
+ _err_msg_) {}
315
+ virtual void raise() const { throw *this; }
316
+ };
317
+
318
+ //////////////////////////////////////////////////////////////////////////////
319
+ /// SednaUserException
320
+ //////////////////////////////////////////////////////////////////////////////
321
+
322
+ class SednaUserException : public SednaException
323
+ {
324
+ protected:
325
+ int internal_code;
326
+ virtual std::string getMsg2() const;
327
+
328
+ public:
329
+ SednaUserException(const char* _file_,
330
+ const char* _function_,
331
+ int _line_,
332
+ int _internal_code_) : SednaException(_file_,
333
+ _function_,
334
+ _line_,
335
+ ""),
336
+ internal_code(_internal_code_) {}
337
+ SednaUserException(const char* _file_,
338
+ const char* _function_,
339
+ int _line_,
340
+ const char* _err_msg_,
341
+ int _internal_code_) : SednaException(_file_,
342
+ _function_,
343
+ _line_,
344
+ _err_msg_),
345
+ internal_code(_internal_code_) {}
346
+ virtual int get_code() const { return internal_code; }
347
+ virtual bool need_rollback()
348
+ {
349
+ return user_error_code_entries[internal_code].act == ueca_ROLLBACK_TRN;
350
+ }
351
+ virtual void raise() const { throw *this; }
352
+ };
353
+
354
+ //////////////////////////////////////////////////////////////////////////////
355
+ /// SednaUserExceptionFnError
356
+ //////////////////////////////////////////////////////////////////////////////
357
+
358
+ class SednaUserExceptionFnError : public SednaUserException
359
+ {
360
+ protected:
361
+ std::string error_name;
362
+ std::string error_descr;
363
+ virtual std::string getMsg2() const;
364
+
365
+ public:
366
+ /* see ~SednaException() for explanation */
367
+ ~SednaUserExceptionFnError() throw() { ; }
368
+
369
+ SednaUserExceptionFnError(const char* _file_,
370
+ const char* _function_,
371
+ int _line_,
372
+ const char* _error_name_,
373
+ const char* _error_descr_) :
374
+ SednaUserException(_file_,
375
+ _function_,
376
+ _line_,
377
+ SE9000),
378
+ error_name(_error_name_),
379
+ error_descr(_error_descr_ ? _error_descr_ : "") {}
380
+
381
+ virtual int get_code() const { return internal_code; }
382
+ virtual bool need_rollback() { return true; }
383
+ virtual void raise() const { throw *this; }
384
+ };
385
+
386
+ //////////////////////////////////////////////////////////////////////////////
387
+ /// SednaUserEnvException
388
+ //////////////////////////////////////////////////////////////////////////////
389
+
390
+ class SednaUserEnvException : public SednaUserException
391
+ {
392
+ protected:
393
+ bool rollback;
394
+ std::string explanation;
395
+ virtual std::string getMsg2() const;
396
+
397
+ public:
398
+ /* see ~SednaException() for explanation */
399
+ ~SednaUserEnvException() throw() { ; }
400
+
401
+ SednaUserEnvException(const char* _file_,
402
+ const char* _function_,
403
+ int _line_,
404
+ const char* _err_msg_,
405
+ bool _rollback_) : SednaUserException(_file_,
406
+ _function_,
407
+ _line_,
408
+ _err_msg_,
409
+ 0),
410
+ rollback(_rollback_) {}
411
+ SednaUserEnvException(const char* _file_,
412
+ const char* _function_,
413
+ int _line_,
414
+ const char* _err_msg_,
415
+ const char* _explanation_,
416
+ bool _rollback_) : SednaUserException(_file_,
417
+ _function_,
418
+ _line_,
419
+ _err_msg_,
420
+ 0),
421
+ rollback(_rollback_),
422
+ explanation(_explanation_){}
423
+
424
+ virtual std::string getDescription() const;
425
+ virtual bool need_rollback() { return rollback; }
426
+ virtual void raise() const { throw *this; }
427
+ };
428
+
429
+ //////////////////////////////////////////////////////////////////////////////
430
+ /// SednaUserSoftException
431
+ //////////////////////////////////////////////////////////////////////////////
432
+
433
+ class SednaUserSoftException : public SednaUserException
434
+ {
435
+ protected:
436
+ virtual std::string getMsg2() const { return err_msg; }
437
+
438
+ public:
439
+ SednaUserSoftException(const char* _file_,
440
+ const char* _function_,
441
+ int _line_,
442
+ const char* _err_msg_) : SednaUserException(_file_,
443
+ _function_,
444
+ _line_,
445
+ _err_msg_,
446
+ -1) {}
447
+ virtual bool need_rollback() { return false; }
448
+ virtual void raise() const { throw *this; }
449
+ };
450
+
451
+ //////////////////////////////////////////////////////////////////////////////
452
+ /// SednaXQueryException - in PPBase.h
453
+ //////////////////////////////////////////////////////////////////////////////
454
+
455
+ class SednaXQueryException;
456
+
457
+ //////////////////////////////////////////////////////////////////////////////
458
+ /// Sedna soft fault fuctions.
459
+ /// 'sedna_soft_fault' fuction with no message parameter is defined in event_loc.h
460
+ //////////////////////////////////////////////////////////////////////////////
461
+
462
+ void sedna_soft_fault(const SednaException &e, int component);
463
+ void sedna_soft_fault(const char* s, int component);
464
+
465
+
466
+ //////////////////////////////////////////////////////////////////////////////
467
+ /// Under Darwin we need this hack to compile Sedna with gcc 4.0.1
468
+ //////////////////////////////////////////////////////////////////////////////
469
+
470
+ #if defined(DARWIN)
471
+
472
+ #ifdef SYSTEM_EXCEPTION
473
+ #undef SYSTEM_EXCEPTION
474
+ #define SYSTEM_EXCEPTION(msg) __system_exception(__FILE__, __SE_FUNCTION__, __LINE__, msg)
475
+ #endif /* SYSTEM_EXCEPTION */
476
+
477
+ #ifdef SYSTEM_ENV_EXCEPTION
478
+ #undef SYSTEM_ENV_EXCEPTION
479
+ #define SYSTEM_ENV_EXCEPTION(msg) __system_env_exception(__FILE__, __SE_FUNCTION__, __LINE__, msg)
480
+ #endif /* SYSTEM_ENV_EXCEPTION */
481
+
482
+ #ifdef USER_EXCEPTION2
483
+ #undef USER_EXCEPTION2
484
+ #define USER_EXCEPTION2(internal_code, details) __user_exception2(__FILE__, __SE_FUNCTION__, __LINE__, internal_code, details)
485
+ #endif /* USER_EXCEPTION2 */
486
+
487
+ #ifdef XQUERY_EXCEPTION2
488
+ #undef XQUERY_EXCEPTION2
489
+ #define XQUERY_EXCEPTION2(internal_code, details) __xquery_exception2(__FILE__, __SE_FUNCTION__, __LINE__, internal_code, details)
490
+ #endif /* XQUERY_EXCEPTION2 */
491
+
492
+ #ifdef USER_EXCEPTION_FNERROR
493
+ #undef USER_EXCEPTION_FNERROR
494
+ #define USER_EXCEPTION_FNERROR(err_name, err_descr) __user_exception_fnerror(__FILE__, __SE_FUNCTION__, __LINE__, err_name, err_descr)
495
+ #endif /* USER_EXCEPTION_FNERROR */
496
+
497
+ #ifdef USER_ENV_EXCEPTION
498
+ #undef USER_ENV_EXCEPTION
499
+ #define USER_ENV_EXCEPTION(msg, rollback) __user_env_exception(__FILE__, __SE_FUNCTION__, __LINE__, msg, rollback)
500
+ #endif /* USER_ENV_EXCEPTION */
501
+
502
+ #ifdef USER_ENV_EXCEPTION2
503
+ #undef USER_ENV_EXCEPTION2
504
+ #define USER_ENV_EXCEPTION2(msg, expl, rollback) __user_env_exception2(__FILE__, __SE_FUNCTION__, __LINE__, msg, expl, rollback)
505
+ #endif /* USER_ENV_EXCEPTION2 */
506
+
507
+ #ifdef USER_SOFT_EXCEPTION
508
+ #undef USER_SOFT_EXCEPTION
509
+ #define USER_SOFT_EXCEPTION(msg) __user_soft_exception(__FILE__, __SE_FUNCTION__, __LINE__, msg)
510
+ #endif /* USER_SOFT_EXCEPTION */
511
+
512
+
513
+ inline SednaSystemException __system_exception(const char *file, const char *func, int line, const char *msg) {
514
+ return ((U_ASSERT_MACRO(false)),
515
+ elog(EL_FATAL, (msg)),
516
+ SednaSystemException(file, func, line, msg)); }
517
+
518
+ inline SednaSystemEnvException __system_env_exception(const char *file, const char *func, int line, const char *msg) {
519
+ return (elog(EL_FATAL, (msg)),
520
+ SednaSystemEnvException(file, func, line, msg)); }
521
+
522
+ inline SednaUserException __user_exception2(const char *file, const char *func, int line, int code, const char * details) {
523
+ return (elog(EL_ERROR, ("(%s) %s Details: %s",
524
+ user_error_code_entries[code].code,
525
+ user_error_code_entries[code].descr,
526
+ details)),
527
+ SednaUserException(file, func, line, details, code)); }
528
+
529
+ inline SednaUserExceptionFnError __user_exception_fnerror(const char *file, const char *func, int line, const char *err_name, const char* err_descr) {
530
+ return (elog(EL_ERROR, ("(%s) %s",
531
+ err_name,
532
+ err_descr)),
533
+ SednaUserExceptionFnError(file, func, line, err_name, err_descr)); }
534
+
535
+ inline SednaUserEnvException __user_env_exception(const char *file, const char *func, int line, const char *msg, bool rollback) {
536
+ return (elog(EL_ERROR, ("(%s) %s Details: %s",
537
+ user_error_code_entries[0].code,
538
+ user_error_code_entries[0].descr,
539
+ msg)),
540
+ SednaUserEnvException(file, func, line, msg, rollback)); }
541
+
542
+ inline SednaUserEnvException __user_env_exception2(const char *file, const char *func, int line, const char *msg, const char* expl, bool rollback) {
543
+ return (elog(EL_ERROR, ("(%s) %s Details: %s (%s)",
544
+ user_error_code_entries[0].code,
545
+ user_error_code_entries[0].descr,
546
+ msg,
547
+ expl)),
548
+ SednaUserEnvException(file, func, line, msg, expl, rollback)); }
549
+
550
+ inline SednaUserSoftException __user_soft_exception(const char *file, const char *func, int line, const char *msg) {
551
+ return SednaUserSoftException(file, func, line, msg); }
552
+
553
+
554
+ #endif /* DARWIN */
555
+
556
+ //////////////////////////////////////////////////////////////////////////////
557
+
558
+
559
+ #endif