1#line 1 "ifxconnection.ec"
13#if __DCL_HAVE_ALLOC_DEBUG
14#undef __DCL_ALLOC_LEVEL
15#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
28#define __DCL_TRACE0_N __DCL_TRACE0
29#define __DCL_TRACE1_N __DCL_TRACE1
30#define __DCL_TRACE2_N __DCL_TRACE2
31#define __DCL_TRACE3_N __DCL_TRACE3
32#define __DCL_TRACE4_N __DCL_TRACE4
34#define __DCL_TRACE0_N(fmt)
35#define __DCL_TRACE1_N(fmt, arg)
36#define __DCL_TRACE2_N(fmt, arg1, arg2)
37#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
38#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
46#define __SET_ERROR(_error) \
47 setErrorHandle(_error, 0L, __THIS_FILE__, __LINE__)
48#define __SET_ERROR_HANDLE(_SQLCODE) \
49 setErrorHandle(SQL::eServerError, _SQLCODE, __THIS_FILE__, __LINE__)
50#define __SET_ERROR_MSG(_message) \
51 setErrorMessage(_message, __THIS_FILE__, __LINE__)
56 : Connection(_serverTitle)
62 if (!__connectionID.isEmpty()) {
81void IFXConnection::reset()
86#line 79 "ifxconnection.ec"
87#line 80 "ifxconnection.ec"
88 char *connID = (
_CONST char*) __connectionID.data();
92#line 81 "ifxconnection.ec"
98#line 83 "ifxconnection.ec"
100#line 83 "ifxconnection.ec"
101 sqli_connect_set(0, connID, 0);
102#line 83 "ifxconnection.ec"
108#line 85 "ifxconnection.ec"
110#line 85 "ifxconnection.ec"
111 sqli_trans_begin2((
mint)1);
112#line 85 "ifxconnection.ec"
115 Connection::__canTransact =
true;
119#line 88 "ifxconnection.ec"
121#line 88 "ifxconnection.ec"
122 sqli_trans_rollback();
123#line 88 "ifxconnection.ec"
127 Connection::__canTransact =
false;
135 ListedByteStringToByteStringMap map;
136 Connection::splitConnStr(_conns, _connlen, map);
138 ByteString _SERVER = map[
"SERVER"];
139 ByteString _USER = map[
"USER"];
140 ByteString _PASSWORD = map[
"PASSWORD"];
141 ByteString _DATABASE = map[
"DATABASE"];
145 ByteStringBuilder sb = _DATABASE;
146 if (!_SERVER.isEmpty()) {
147 sb.append(
"@").append(_SERVER);
149 _TARGET = sb.toByteString();
153 ByteString
connectionID = ByteString::format(
"conn_%zx", (
size_t)
this);
158#line 119 "ifxconnection.ec"
159#line 120 "ifxconnection.ec"
160 char *user = (
_CONST char*) _USER.data();
161 char *pass = (
_CONST char*) _PASSWORD.data();
162 char *target = (
_CONST char*) _TARGET.data();
167#line 124 "ifxconnection.ec"
175#line 126 "ifxconnection.ec"
177#line 128 "ifxconnection.ec"
178 ifx_conn_t *_sqiconn;
179 _sqiconn = (ifx_conn_t *)ifx_alloc_conn_user(user, pass);
180 sqli_connect_open(ESQLINTVERSION, 0, target, connID, _sqiconn, 1);
181 ifx_free_conn_user(&_sqiconn);
182#line 128 "ifxconnection.ec"
191 if (!_DATABASE.isEmpty()) {
199 if (__connectionID.isEmpty()) {
207#line 149 "ifxconnection.ec"
208#line 150 "ifxconnection.ec"
209 char *connID = (
_CONST char*) __connectionID.data();
213#line 151 "ifxconnection.ec"
219#line 153 "ifxconnection.ec"
221#line 153 "ifxconnection.ec"
222 sqli_connect_close(0, connID, 0, 0);
223#line 153 "ifxconnection.ec"
230 __connectionID.clear();
253static StmtType __GetStmtType(
const char* _sql)
255 for(
size_t i = 0; sp[i].type !=
StmtOther; i++) {
272#line 198 "ifxconnection.ec"
273#line 199 "ifxconnection.ec"
274 char *connID = (
_CONST char*) __connectionID.data();
275 char *pszSqlStatement = (
_CONST char*) _sql;
279#line 201 "ifxconnection.ec"
285#line 203 "ifxconnection.ec"
287#line 203 "ifxconnection.ec"
288 sqli_connect_set(0, connID, 0);
289#line 203 "ifxconnection.ec"
299#line 209 "ifxconnection.ec"
301#line 209 "ifxconnection.ec"
302 sqli_exec_immed(pszSqlStatement);
303#line 209 "ifxconnection.ec"
310 switch(__GetStmtType(_sql)) {
333#line 235 "ifxconnection.ec"
334#line 236 "ifxconnection.ec"
335 char *connID = (
_CONST char*) __connectionID.data();
339#line 237 "ifxconnection.ec"
345#line 239 "ifxconnection.ec"
347#line 239 "ifxconnection.ec"
348 sqli_connect_set(0, connID, 0);
349#line 239 "ifxconnection.ec"
359#line 245 "ifxconnection.ec"
361#line 245 "ifxconnection.ec"
362 sqli_trans_begin2((
mint)1);
363#line 245 "ifxconnection.ec"
379#line 257 "ifxconnection.ec"
380#line 258 "ifxconnection.ec"
381 char *connID = (
_CONST char*) __connectionID.data();
385#line 259 "ifxconnection.ec"
391#line 261 "ifxconnection.ec"
393#line 261 "ifxconnection.ec"
394 sqli_connect_set(0, connID, 0);
395#line 261 "ifxconnection.ec"
405#line 267 "ifxconnection.ec"
407#line 267 "ifxconnection.ec"
409#line 267 "ifxconnection.ec"
425#line 279 "ifxconnection.ec"
426#line 280 "ifxconnection.ec"
427 char *connID = (
_CONST char*) __connectionID.data();
431#line 281 "ifxconnection.ec"
437#line 283 "ifxconnection.ec"
439#line 283 "ifxconnection.ec"
440 sqli_connect_set(0, connID, 0);
441#line 283 "ifxconnection.ec"
451#line 289 "ifxconnection.ec"
453#line 289 "ifxconnection.ec"
454 sqli_trans_rollback();
455#line 289 "ifxconnection.ec"
476 *_queryHandleOut = pNewQuery;
487 __lastErrorMessage.clear();
493 ByteStringBuilder sb;
494 sb.format(
"SQLCODE(%d) ", _SQLCODE);
498 mint r = rgetlmsg(_SQLCODE, buf,
sizeof(buf), &actual);
501 if (!isspace(buf[actual - 1]))
506 sb.format(buf, sqlca.sqlerrm);
509 sb.format(
"(%d)",
r);
512 sb.append(
"Message file not found");
515 sb.append(
"Message number not found in message file");
518 sb.append(
"Cannot seek within messge file");
521 sb.append(
"Message buffer too small");
524 sb.append(
"Unkndown");
527 __lastErrorMessage = sb.toByteString();
533 if (__lastErrorMessage.length() < *_buflen) {
534 *_buflen = __lastErrorMessage.length();
535 *(_buf + *_buflen) =
'\0';
537 strncpy(_buf, __lastErrorMessage.data(), *_buflen);
549 bool localTrans =
false;
556 "SELECT DBINFO('version', 'full')"
557 "\n FROM systables WHERE tabid = 1";
559 if (!query->prepare(_sql, ByteString::length(_sql), 0))
562 if (!query->execute())
577 size_t size = (size_t)-1;
578 if (!field->
__getDataSize(&size,
false) || size == (
size_t)-1) {
587 *_buflen = ByteString::length(_buf, *_buflen);
610#line 441 "ifxconnection.ec"
#define __DCL_TRACE1_N(fmt, arg)
#define __DCL_TRACE0_N(fmt)
#define __SET_ERROR_HANDLE(_SQLCODE)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
#define __SET_ERROR(_errorCode)
#define __UNSET_STATE(state)
#define __SET_STATE(state)
_CONST char * connectionID() const
virtual bool __startTrans()
virtual bool __open(const char *_conns, size_t _connlen)
virtual bool __commitTrans()
virtual bool __rollbackTrans()
void setErrorHandle(SQL::Error _error, long _SQLCODE, const wchar_t *_filename, int _line)
virtual bool __createQueryInstance(SQL::Query **_queryHandleOut)
virtual bool __execute(const char *_sql, size_t _sqllen)
virtual bool __getServerInfo(char *_buf, size_t *_buflen)
IFXConnection(const wchar_t *_serverTitle)
virtual bool __getErrorMessage(char *_buf, size_t *_buflen)
virtual bool __getDataSize(size_t *_size, bool _maxsize)
virtual bool __getData(void *_buf, size_t *_size, SQL::DataType _bufType)
virtual bool __getField(size_t _index, SQL::Field **_fieldHandleOut)
static bool test(const wchar_t *_regex, const wchar_t *_string, bool _icase=false) __DCL_THROWS1(RegexException *)
_PROTECTED const wchar_t * _filename
_PROTECTED const wchar_t int _line
bool inState(unsigned int _state) const