7#if __DCL_HAVE_ALLOC_DEBUG
8#undef __DCL_ALLOC_LEVEL
9#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
21#define __DCL_TRACE0_N __DCL_TRACE0
22#define __DCL_TRACE1_N __DCL_TRACE1
23#define __DCL_TRACE2_N __DCL_TRACE2
24#define __DCL_TRACE3_N __DCL_TRACE3
25#define __DCL_TRACE4_N __DCL_TRACE4
27#define __DCL_TRACE0_N(fmt)
28#define __DCL_TRACE1_N(fmt, arg)
29#define __DCL_TRACE2_N(fmt, arg1, arg2)
30#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
31#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
34#if __DCL_HAVE_THIS_FILE__
44 : Connection(_serverTitle)
46 Connection::__canTransact =
true;
48 __storeResult =
false;
84 if ((__mysql = mysql_init(
NULL)) ==
NULL) {
89 ListedByteStringToByteStringMap map;
90 Connection::splitConnectionString(_pszConnString, _n, map);
92 ByteString strAppName = map[
"APPLICATION"];
94 if (!strAppName.isEmpty()) {
95 mysql_options(
connHandle(), MYSQL_READ_DEFAULT_GROUP, strAppName.data());
98 ByteString strUser = map[
"USER"];
99 ByteString strPassword = map[
"PASSWORD"];
100 ByteString strHost = map[
"SERVER"];
101 ByteString strDb = map[
"DATABASE"];
102 ByteString strPort = map[
"PORT"];
103 ByteString strUnixSocket = map[
"UNIX_SOCKET"];
104 __storeResult = map.find(
"STORE_RESULT") != map.end();
106 unsigned int port = 0;
107 if (!strPort.isEmpty()) {
109 unsigned long n = strtoul(strPort.data(), &endptr, 10);
110 if (
n == ULONG_MAX) {
114 port = (
unsigned int)
n;
117 if (mysql_real_connect(
119 strHost.isEmpty()?
NULL : strHost.data(),
120 strUser.isEmpty()?
NULL : strUser.data(),
121 strPassword.isEmpty()?
NULL : strPassword.data(),
122 strDb.isEmpty() ?
NULL : strDb.data(),
124 strUnixSocket.isEmpty() ?
NULL : strUnixSocket.data(),
131 if (mysql_set_character_set(
connHandle(),
"utf8")) {
155 mysql_close(__mysql);
178static StmtType __GetStmtType(
const char* _sql)
180 for (
size_t i = 0; sp[i].type !=
StmtOther; i++) {
194 if (mysql_real_query(
connHandle(), _sql, (
unsigned long) _n)) {
200 switch (__GetStmtType(_sql)) {
217 return __execute(
"START TRANSACTION", 17);
252 *_ppQuery = pNewQuery;
258 if (__lastErrorMessage.length() < *_size)
259 *_size = __lastErrorMessage.length();
261 strncpy(_buffer, __lastErrorMessage.data(), *_size);
268 const char* psz = mysql_get_server_info(
connHandle());
272 size_t nLength = strlen(psz);
274 if (nLength < *_size)
277 strncpy(_buffer, psz, *_size);
#define __DCL_TRACE0_N(fmt)
#define __SET_ERROR(_error)
#define __SET_ERROR_MSG(_msg)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
#define __UNSET_STATE(state)
#define __SET_STATE(state)
void CharsetConvertException *size_t n
virtual bool __startTrans()
virtual bool __rollbackTrans()
MyConnection(const wchar_t *_serverTitle)
virtual bool __commitTrans()
virtual bool __createQueryInstance(SQL::Query **_ppQuery)
virtual bool __execute(const char *pszSQL, size_t _n)
virtual bool __getServerInfo(char *_buffer, size_t *_size)
MYSQL * connHandle() const
virtual bool __open(const char *_pszConnString, size_t _n)
virtual bool __getErrorMessage(char *_buffer, size_t *_size)
static bool test(const wchar_t *_regex, const wchar_t *_string, bool _icase=false) __DCL_THROWS1(RegexException *)