From ae4f164c70abe96ec0575a3b0ce8b07575e04ad5 Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Tue, 17 Oct 2006 16:18:56 +0000 Subject: [PATCH] The version is now 8.2.0104. Take 64bit mode into account for the format parameter of (s(n))printf, sscanf etc. --- bind.c | 36 ++++++++++++++--------------- connection.c | 47 ++++++++++++++++++++++---------------- connection.h | 4 ---- convert.c | 8 +++---- descriptor.c | 12 +++++----- dlg_specific.c | 1 + drvconn.c | 10 ++++---- environ.c | 16 ++++++------- execute.c | 20 +++++++++------- info.c | 38 +++++++++++++++---------------- inouealc.c | 30 ++++++++++++------------ loadlib.c | 6 ++--- misc.c | 3 ++- odbcapi.c | 2 +- odbcapi30.c | 10 ++++---- odbcapi30w.c | 2 +- odbcapiw.c | 2 +- options.c | 6 ++--- parse.c | 8 +++---- pgapi30.c | 16 ++++++------- psqlodbc.h | 51 ++++++++++++++++++++++++++++++++++++----- qresult.c | 22 +++++++++--------- results.c | 50 ++++++++++++++++++++-------------------- statement.c | 62 +++++++++++++++++++++++++------------------------- statement.h | 2 +- version.h | 6 ++--- win_unicode.c | 6 ++--- 27 files changed, 262 insertions(+), 214 deletions(-) diff --git a/bind.c b/bind.c index 17619e1..80f4c9d 100644 --- a/bind.c +++ b/bind.c @@ -132,9 +132,9 @@ PGAPI_BindParameter( SC_recycle_statement(stmt); mylog("%s: ipar=%d, paramType=%d, fCType=%d, fSqlType=%d, cbColDef=%d, ibScale=%d,", func, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale); - /*** mylog("rgbValue=%x, pcbValue = %x(%d), data_at_exec = %d\n", rgbValue, pcbValue, pcbValue ? *pcbValue : -777, apdopts->parameters[ipar].data_at_exec); ***/ + /*** mylog("rgbValue=%p, pcbValue = %p(%d), data_at_exec = %d\n", rgbValue, pcbValue, pcbValue ? *pcbValue : -777, apdopts->parameters[ipar].data_at_exec); ***/ - mylog("rgbValue=%x, pcbValue = %x, data_at_exec = %d\n", rgbValue, pcbValue, apdopts->parameters[ipar].data_at_exec); + mylog("rgbValue=%p, pcbValue = %p, data_at_exec = %d\n", rgbValue, pcbValue, apdopts->parameters[ipar].data_at_exec); return SQL_SUCCESS; } @@ -159,8 +159,8 @@ PGAPI_BindCol( mylog("%s: entering...\n", func); - mylog("**** PGAPI_BindCol: stmt = %x, icol = %d\n", stmt, icol); - mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueMax, pcbValue); + mylog("**** PGAPI_BindCol: stmt = %p, icol = %d\n", stmt, icol); + mylog("**** : fCType=%d rgb=%p valusMax=%d pcb=%p\n", fCType, rgbValue, cbValueMax, pcbValue); if (!stmt) { @@ -270,7 +270,7 @@ inolog("Bind column 0 is type %d not of type SQL_C_BOOKMARK", fCType); opts->bindings[icol].precision = 0; opts->bindings[icol].scale = 0; - mylog(" bound buffer[%d] = %x\n", icol, opts->bindings[icol].buffer); + mylog(" bound buffer[%d] = %p\n", icol, opts->bindings[icol].buffer); } cleanup: @@ -406,7 +406,7 @@ PGAPI_ParamOptions( APDFields *apdopts; IPDFields *ipdopts; - mylog("%s: entering... %d %x\n", func, crow, pirow); + mylog("%s: entering... %d %p\n", func, crow, pirow); apdopts = SC_get_APDF(stmt); apdopts->paramset_size = crow; @@ -591,7 +591,7 @@ extend_parameter_bindings(APDFields *self, int num_params) CSTR func = "extend_parameter_bindings"; ParameterInfoClass *new_bindings; - mylog("%s: entering ... self=%x, parameters_allocated=%d, num_params=%d\n", func, self, self->allocated, num_params); + mylog("%s: entering ... self=%p, parameters_allocated=%d, num_params=%d\n", func, self, self->allocated, num_params); /* * if we have too few, allocate room for more, and copy the old @@ -624,7 +624,7 @@ extend_iparameter_bindings(IPDFields *self, int num_params) CSTR func = "extend_iparameter_bindings"; ParameterImplClass *new_bindings; - mylog("%s: entering ... self=%x, parameters_allocated=%d, num_params=%d\n", func, self, self->allocated, num_params); + mylog("%s: entering ... self=%p, parameters_allocated=%d, num_params=%d\n", func, self, self->allocated, num_params); /* * if we have too few, allocate room for more, and copy the old @@ -656,7 +656,7 @@ reset_a_parameter_binding(APDFields *self, int ipar) { CSTR func = "reset_a_parameter_binding"; - mylog("%s: entering ... self=%x, parameters_allocated=%d, ipar=%d\n", func, self, self->allocated, ipar); + mylog("%s: entering ... self=%p, parameters_allocated=%d, ipar=%d\n", func, self, self->allocated, ipar); if (ipar < 1 || ipar > self->allocated) return; @@ -676,7 +676,7 @@ reset_a_iparameter_binding(IPDFields *self, int ipar) { CSTR func = "reset_a_iparameter_binding"; - mylog("%s: entering ... self=%x, parameters_allocated=%d, ipar=%d\n", func, self, self->allocated, ipar); + mylog("%s: entering ... self=%p, parameters_allocated=%d, ipar=%d\n", func, self, self->allocated, ipar); if (ipar < 1 || ipar > self->allocated) return; @@ -762,7 +762,7 @@ PDATA_free_params(PutDataInfo *pdata, char option) { int i; - mylog("PDATA_free_params: ENTER, self=%x\n", pdata); + mylog("PDATA_free_params: ENTER, self=%p\n", pdata); if (!pdata->pdata) return; @@ -797,7 +797,7 @@ PDATA_free_params(PutDataInfo *pdata, char option) void IPD_free_params(IPDFields *ipdopts, char option) { - mylog("IPD_free_params: ENTER, self=%x\n", ipdopts); + mylog("IPD_free_params: ENTER, self=%p\n", ipdopts); if (!ipdopts->parameters) return; @@ -818,7 +818,7 @@ extend_column_bindings(ARDFields *self, int num_columns) BindInfoClass *new_bindings; int i; - mylog("%s: entering ... self=%x, bindings_allocated=%d, num_columns=%d\n", func, self, self->allocated, num_columns); + mylog("%s: entering ... self=%p, bindings_allocated=%d, num_columns=%d\n", func, self, self->allocated, num_columns); /* * if we have too few, allocate room for more, and copy the old @@ -871,7 +871,7 @@ reset_a_column_binding(ARDFields *self, int icol) CSTR func = "reset_a_column_binding"; BindInfoClass *bookmark; - mylog("%s: entering ... self=%x, bindings_allocated=%d, icol=%d\n", func, self, self->allocated, icol); + mylog("%s: entering ... self=%p, bindings_allocated=%d, icol=%d\n", func, self, self->allocated, icol); if (icol > self->allocated) return; @@ -901,7 +901,7 @@ void ARD_unbind_cols(ARDFields *self, BOOL freeall) { Int2 lf; -inolog("ARD_unbind_cols freeall=%d allocated=%d bindings=%x", freeall, self->allocated, self->bindings); +inolog("ARD_unbind_cols freeall=%d allocated=%d bindings=%p", freeall, self->allocated, self->bindings); for (lf = 1; lf <= self->allocated; lf++) reset_a_column_binding(self, lf); if (freeall) @@ -916,7 +916,7 @@ void GDATA_unbind_cols(GetDataInfo *self, BOOL freeall) { Int2 lf; -inolog("GDATA_unbind_cols freeall=%d allocated=%d gdata=%x", freeall, self->allocated, self->gdata); +inolog("GDATA_unbind_cols freeall=%d allocated=%d gdata=%p", freeall, self->allocated, self->gdata); if (self->fdata.ttlbuf) { free(self->fdata.ttlbuf); @@ -969,7 +969,7 @@ extend_getdata_info(GetDataInfo *self, int num_columns, BOOL shrink) CSTR func = "extend_getdata_info"; GetDataClass *new_gdata; - mylog("%s: entering ... self=%x, gdata_allocated=%d, num_columns=%d\n", func, self, self->allocated, num_columns); + mylog("%s: entering ... self=%p, gdata_allocated=%d, num_columns=%d\n", func, self, self->allocated, num_columns); /* * if we have too few, allocate room for more, and copy the old @@ -1049,7 +1049,7 @@ extend_putdata_info(PutDataInfo *self, int num_params, BOOL shrink) CSTR func = "extend_putdata_info"; PutDataClass *new_pdata; - mylog("%s: entering ... self=%x, parameters_allocated=%d, num_params=%d\n", func, self, self->allocated, num_params); + mylog("%s: entering ... self=%p, parameters_allocated=%d, num_params=%d\n", func, self, self->allocated, num_params); /* * if we have too few, allocate room for more, and copy the old diff --git a/connection.c b/connection.c index 5b9eae9..c023d21 100644 --- a/connection.c +++ b/connection.c @@ -61,7 +61,7 @@ PGAPI_AllocConnect( mylog("%s: entering...\n", func); conn = CC_Constructor(); - mylog("**** %s: henv = %x, conn = %x\n", func, henv, conn); + mylog("**** %s: henv = %p, conn = %p\n", func, henv, conn); if (!conn) { @@ -103,6 +103,7 @@ PGAPI_Connect( ConnInfo *ci; CSTR func = "PGAPI_Connect"; RETCODE ret = SQL_SUCCESS; + char fchar; mylog("%s: entering...\n", func); @@ -127,13 +128,19 @@ PGAPI_Connect( * override values from DSN info with UID and authStr(pwd) This only * occurs if the values are actually there. */ + fchar = ci->username[0]; /* save the first byte */ make_string(szUID, cbUID, ci->username, sizeof(ci->username)); + if ('\0' == ci->username[0]) /* an empty string is specified */ + ci->username[0] = fchar; /* restore the original username */ + fchar = ci->password[0]; make_string(szAuthStr, cbAuthStr, ci->password, sizeof(ci->password)); + if ('\0' == ci->password[0]) /* an empty string is specified */ + ci->password[0] = fchar; /* restore the original password */ /* fill in any defaults */ getDSNdefaults(ci); - qlog("conn = %x, %s(DSN='%s', UID='%s', PWD='%s')\n", conn, func, ci->dsn, ci->username, ci->password ? "xxxxx" : ""); + qlog("conn = %p, %s(DSN='%s', UID='%s', PWD='%s')\n", conn, func, ci->dsn, ci->username, ci->password ? "xxxxx" : ""); if (CC_connect(conn, AUTH_REQ_OK, NULL) <= 0) { @@ -184,7 +191,7 @@ PGAPI_Disconnect( return SQL_INVALID_HANDLE; } - qlog("conn=%x, %s\n", conn, func); + qlog("conn=%p, %s\n", conn, func); if (conn->status == CONN_EXECUTING) { @@ -213,7 +220,7 @@ PGAPI_FreeConnect( CSTR func = "PGAPI_FreeConnect"; mylog("%s: entering...\n", func); - mylog("**** in %s: hdbc=%x\n", func, hdbc); + mylog("**** in %s: hdbc=%p\n", func, hdbc); if (!conn) { @@ -391,7 +398,7 @@ cleanup: char CC_Destructor(ConnectionClass *self) { - mylog("enter CC_Destructor, self=%x\n", self); + mylog("enter CC_Destructor, self=%p\n", self); if (self->status == CONN_EXECUTING) return 0; @@ -438,7 +445,7 @@ CC_cursor_count(ConnectionClass *self) count = 0; QResultClass *res; - mylog("CC_cursor_count: self=%x, num_stmts=%d\n", self, self->num_stmts); + mylog("CC_cursor_count: self=%p, num_stmts=%d\n", self, self->num_stmts); CONNLOCK_ACQUIRE(self); for (i = 0; i < self->num_stmts; i++) @@ -541,7 +548,7 @@ CC_cleanup(ConnectionClass *self) if (self->status == CONN_EXECUTING) return FALSE; - mylog("in CC_Cleanup, self=%x\n", self); + mylog("in CC_Cleanup, self=%p\n", self); /* Cancel an ongoing transaction */ /* We are always in the middle of a transaction, */ @@ -1145,7 +1152,7 @@ static char *protocol3_opts_build(ConnectionClass *self) char tmout[16]; slen += (strlen(l_login_timeout) + 2 + 2); - snprintf(tmout, sizeof(tmout), "%lu", self->login_timeout); + snprintf(tmout, sizeof(tmout), FORMAT_UINTEGER, self->login_timeout); slen += strlen(tmout); } slen++; @@ -1182,7 +1189,7 @@ static char *protocol3_opts_build(ConnectionClass *self) { sprintf(ppacket, " %s=", l_login_timeout); ppacket += (strlen(l_login_timeout) + 2); - sprintf(ppacket, "%lu", self->login_timeout); + sprintf(ppacket, FORMAT_UINTEGER, self->login_timeout); ppacket = strchr(ppacket, '\0'); } *ppacket = '\0'; @@ -1745,7 +1752,7 @@ CC_add_statement(ConnectionClass *self, StatementClass *stmt) int i; char ret = TRUE; - mylog("CC_add_statement: self=%x, stmt=%x\n", self, stmt); + mylog("CC_add_statement: self=%p, stmt=%p\n", self, stmt); CONNLOCK_ACQUIRE(self); for (i = 0; i < self->num_stmts; i++) @@ -1783,7 +1790,7 @@ CC_set_error_statements(ConnectionClass *self) { int i; - mylog("CC_error_statements: self=%x\n", self); + mylog("CC_error_statements: self=%p\n", self); for (i = 0; i < self->num_stmts; i++) { @@ -2090,8 +2097,8 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag, St /* QR_set_command() dups this string so doesn't need static */ char cmdbuffer[ERROR_MSG_LENGTH + 1]; - mylog("send_query(): conn=%x, query='%s'\n", self, query); - qlog("conn=%x, query='%s'\n", self, query); + mylog("send_query(): conn=%p, query='%s'\n", self, query); + qlog("conn=%p, query='%s'\n", self, query); if (!self->sock) { @@ -2304,7 +2311,7 @@ inolog("Discarded the first SAVEPOINT\n"); QR_set_rstatus(res, PORES_COMMAND_OK); QR_set_command(res, cmdbuffer); query_completed = TRUE; - mylog("send_query: returning res = %x\n", res); + mylog("send_query: returning res = %p\n", res); if (!before_64) break; @@ -2395,7 +2402,7 @@ inolog("Discarded the first SAVEPOINT\n"); if (stmt) res->num_key_fields = stmt->num_key_fields; } - mylog("send_query: 'T' no result_in: res = %x\n", res->next); + mylog("send_query: 'T' no result_in: res = %p\n", res->next); res = res->next; if (qi) @@ -2599,7 +2606,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_ ConnInfo *ci; int func_cs_count = 0; - mylog("send_function(): conn=%x, fnid=%d, result_is_int=%d, nargs=%d\n", self, fnid, result_is_int, nargs); + mylog("send_function(): conn=%p, fnid=%d, result_is_int=%d, nargs=%d\n", self, fnid, result_is_int, nargs); if (!self->sock) { @@ -2662,7 +2669,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_ for (i = 0; i < nargs; ++i) { - mylog(" arg[%d]: len = %d, isint = %d, integer = %d, ptr = %x\n", i, args[i].len, args[i].isint, args[i].u.integer, args[i].u.ptr); + mylog(" arg[%d]: len = %d, isint = %d, integer = %d, ptr = %p\n", i, args[i].len, args[i].isint, args[i].u.integer, args[i].u.ptr); SOCK_put_int(sock, args[i].len, 4); if (args[i].isint) @@ -3087,8 +3094,8 @@ CC_log_error(const char *func, const char *desc, const ConnectionClass *self) qlog("CONN ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->__error_number, nullcheck(self->__error_message)); mylog("CONN ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->__error_number, nullcheck(self->__error_message)); qlog(" ------------------------------------------------------------\n"); - qlog(" henv=%x, conn=%x, status=%u, num_stmts=%d\n", self->henv, self, self->status, self->num_stmts); - qlog(" sock=%x, stmts=%x, lobj_type=%d\n", self->sock, self->stmts, self->lobj_type); + qlog(" henv=%p, conn=%p, status=%u, num_stmts=%d\n", self->henv, self, self->status, self->num_stmts); + qlog(" sock=%p, stmts=%p, lobj_type=%d\n", self->sock, self->stmts, self->lobj_type); qlog(" ---------------- Socket Info -------------------------------\n"); if (self->sock) @@ -3270,7 +3277,7 @@ LIBPQ_connect(ConnectionClass *self) mylog("connecting to the database using %s as the server\n",self->connInfo.server); sock = self->sock; -inolog("sock=%x\n", sock); +inolog("sock=%p\n", sock); if (!sock) { sock = SOCK_Constructor(self); diff --git a/connection.h b/connection.h index 8b6a6be..d260425 100644 --- a/connection.h +++ b/connection.h @@ -162,11 +162,7 @@ do { \ { \ if (pthread_mutex_lock(&((x)->cs)) == 0) \ entered++; \ - else \ - -1; \ } \ - else \ - 0; \ } while (0) #define LEAVE_CONN_CS(x) pthread_mutex_unlock(&((x)->cs)) #define CONNLOCK_RELEASE(x) pthread_mutex_unlock(&((x)->slock)) diff --git a/convert.c b/convert.c index ef3074b..1c8773d 100644 --- a/convert.c +++ b/convert.c @@ -3125,7 +3125,7 @@ inolog("resolveOneParam %d(%d,%d)\n", param_number, ipdopts->allocated, apdopts- } } -inolog("ipara=%x paramType=%d %d proc_return=%d\n", ipara, ipara ? ipara->paramType : -1, PG_VERSION_LT(conn, 8.1), qb->proc_return); +inolog("ipara=%p paramType=%d %d proc_return=%d\n", ipara, ipara ? ipara->paramType : -1, PG_VERSION_LT(conn, 8.1), qb->proc_return); if (param_number < qb->proc_return) { if (ipara && SQL_PARAM_OUTPUT != ipara->paramType) @@ -3353,7 +3353,7 @@ mylog("C_WCHAR=%s(%d)\n", buffer, used); case SQL_C_SLONG: case SQL_C_LONG: - sprintf(param_string, "%ld", + sprintf(param_string, FORMAT_INTEGER, *((SQLINTEGER *) buffer)); break; @@ -3383,7 +3383,7 @@ mylog("C_WCHAR=%s(%d)\n", buffer, used); break; case SQL_C_ULONG: - sprintf(param_string, "%lu", + sprintf(param_string, FORMAT_UINTEGER, *((SQLUINTEGER *) buffer)); break; @@ -3472,7 +3472,7 @@ mylog("C_WCHAR=%s(%d)\n", buffer, used); */ /* Special handling NULL string For FOXPRO */ -mylog("cvt_null_date_string=%d pgtype=%d buf=%x\n", conn->connInfo.cvt_null_date_string, param_pgtype, buf); +mylog("cvt_null_date_string=%d pgtype=%d buf=%p\n", conn->connInfo.cvt_null_date_string, param_pgtype, buf); if (conn->connInfo.cvt_null_date_string > 0 && PG_TYPE_DATE == param_pgtype && SQL_C_CHAR == param_ctype && diff --git a/descriptor.c b/descriptor.c index 4741df3..e41740f 100644 --- a/descriptor.c +++ b/descriptor.c @@ -102,7 +102,7 @@ void DC_Constructor(DescriptorClass *self, BOOL embedded, StatementClass *stmt) static void ARDFields_free(ARDFields * self) { -inolog("ARDFields_free %x bookmark=%x", self, self->bookmark); +inolog("ARDFields_free %p bookmark=%p", self, self->bookmark); if (self->bookmark) { free(self->bookmark); @@ -249,7 +249,7 @@ char CC_add_descriptor(ConnectionClass *self, DescriptorClass *desc) { int i; - mylog("CC_add_descriptor: self=%x, desc=%x\n", self, desc); + mylog("CC_add_descriptor: self=%p, desc=%p\n", self, desc); for (i = 0; i < self->num_descs; i++) { @@ -451,19 +451,19 @@ inolog("source type=%d -> target type=%d\n", src->desc_type, target->desc_type); switch (src->desc_type) { case SQL_ATTR_APP_ROW_DESC: -inolog("src=%x target=%x type=%d", src, target, src->desc_type); +inolog("src=%p target=%p type=%d", src, target, src->desc_type); if (!target->type_defined) { target->desc_type = src->desc_type; } ard_src = (ARDFields *) (src + 1); -inolog(" rowset_size=%d bind_size=%d ope_ptr=%x off_ptr=%x\n", +inolog(" rowset_size=%d bind_size=%d ope_ptr=%p off_ptr=%p\n", ard_src->size_of_rowset, ard_src->bind_size, ard_src->row_operation_ptr, ard_src->row_offset_ptr); ard_tgt = (ARDFields *) (target + 1); -inolog(" target=%x", ard_tgt); +inolog(" target=%p", ard_tgt); ARDFields_copy(ard_src, ard_tgt); -inolog(" offset_ptr=%x\n", ard_tgt->row_offset_ptr); +inolog(" offset_ptr=%p\n", ard_tgt->row_offset_ptr); break; case SQL_ATTR_APP_PARAM_DESC: if (!target->type_defined) diff --git a/dlg_specific.c b/dlg_specific.c index d813d83..2824003 100644 --- a/dlg_specific.c +++ b/dlg_specific.c @@ -17,6 +17,7 @@ */ /* Multibyte support Eiji Tokuya 2001-03-15 */ +#include #include "dlg_specific.h" #include "convert.h" diff --git a/drvconn.c b/drvconn.c index 76afa94..01889e0 100644 --- a/drvconn.c +++ b/drvconn.c @@ -110,14 +110,14 @@ PGAPI_DriverConnect( #ifdef FORCE_PASSWORD_DISPLAY mylog("**** PGAPI_DriverConnect: fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, connStrIn); - qlog("conn=%x, PGAPI_DriverConnect( in)='%s', fDriverCompletion=%d\n", conn, connStrIn, fDriverCompletion); + qlog("conn=%p, PGAPI_DriverConnect( in)='%s', fDriverCompletion=%d\n", conn, connStrIn, fDriverCompletion); #else if (get_qlog() || get_mylog()) { char *hide_str = hide_password(connStrIn); mylog("**** PGAPI_DriverConnect: fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, NULL_IF_NULL(hide_str)); - qlog("conn=%x, PGAPI_DriverConnect( in)='%s', fDriverCompletion=%d\n", conn, NULL_IF_NULL(hide_str), fDriverCompletion); + qlog("conn=%p, PGAPI_DriverConnect( in)='%s', fDriverCompletion=%d\n", conn, NULL_IF_NULL(hide_str), fDriverCompletion); if (hide_str) free(hide_str); } @@ -291,7 +291,7 @@ inolog("before CC_connect\n"); if (cbConnStrOutMax > 0) { mylog("szConnStrOut = '%s' len=%d,%d\n", NULL_IF_NULL(szConnStrOut), len, cbConnStrOutMax); - qlog("conn=%x, PGAPI_DriverConnect(out)='%s'\n", conn, NULL_IF_NULL(szConnStrOut)); + qlog("conn=%p, PGAPI_DriverConnect(out)='%s'\n", conn, NULL_IF_NULL(szConnStrOut)); } #else if (get_qlog() || get_mylog()) @@ -301,7 +301,7 @@ inolog("before CC_connect\n"); if (cbConnStrOutMax > 0) hide_str = hide_password(szConnStrOut); mylog("szConnStrOut = '%s' len=%d,%d\n", NULL_IF_NULL(hide_str), len, cbConnStrOutMax); - qlog("conn=%x, PGAPI_DriverConnect(out)='%s'\n", conn, NULL_IF_NULL(hide_str)); + qlog("conn=%p, PGAPI_DriverConnect(out)='%s'\n", conn, NULL_IF_NULL(hide_str)); if (hide_str) free(hide_str); } @@ -320,7 +320,7 @@ dconn_DoDialog(HWND hwnd, ConnInfo *ci) { LRESULT dialog_result; - mylog("dconn_DoDialog: ci = %x\n", ci); + mylog("dconn_DoDialog: ci = %p\n", ci); if (hwnd) { diff --git a/environ.c b/environ.c index 43931b7..fb22846 100644 --- a/environ.c +++ b/environ.c @@ -63,7 +63,7 @@ PGAPI_AllocEnv(HENV FAR * phenv) return SQL_ERROR; } - mylog("** exit PGAPI_AllocEnv: phenv = %x **\n", *phenv); + mylog("** exit PGAPI_AllocEnv: phenv = %p **\n", *phenv); return SQL_SUCCESS; } @@ -74,7 +74,7 @@ PGAPI_FreeEnv(HENV henv) CSTR func = "PGAPI_FreeEnv"; EnvironmentClass *env = (EnvironmentClass *) henv; - mylog("**** in PGAPI_FreeEnv: env = %x ** \n", env); + mylog("**** in PGAPI_FreeEnv: env = %p ** \n", env); if (env && EN_Destructor(env)) { @@ -263,7 +263,7 @@ PGAPI_ConnectError( HDBC hdbc, BOOL once_again = FALSE; ssize_t msglen; - mylog("**** PGAPI_ConnectError: hdbc=%x <%d>\n", hdbc, cbErrorMsgMax); + mylog("**** PGAPI_ConnectError: hdbc=%p <%d>\n", hdbc, cbErrorMsgMax); if (RecNumber != 1 && RecNumber != -1) return SQL_NO_DATA_FOUND; if (cbErrorMsgMax < 0) @@ -393,7 +393,7 @@ PGAPI_EnvError( HENV henv, char *msg; int status; - mylog("**** PGAPI_EnvError: henv=%x <%d>\n", henv, cbErrorMsgMax); + mylog("**** PGAPI_EnvError: henv=%p <%d>\n", henv, cbErrorMsgMax); if (RecNumber != 1 && RecNumber != -1) return SQL_NO_DATA_FOUND; if (cbErrorMsgMax < 0) @@ -454,7 +454,7 @@ PGAPI_Error( RETCODE ret; UWORD flag = PODBC_ALLOW_PARTIAL_EXTRACT | PODBC_ERROR_CLEAR; - mylog("**** PGAPI_Error: henv=%x, hdbc=%x hstmt=%d\n", henv, hdbc, hstmt); + mylog("**** PGAPI_Error: henv=%p, hdbc=%p hstmt=%d\n", henv, hdbc, hstmt); if (cbErrorMsgMax < 0) return SQL_ERROR; @@ -509,7 +509,7 @@ EN_Destructor(EnvironmentClass *self) int lf; char rv = 1; - mylog("in EN_Destructor, self=%x\n", self); + mylog("in EN_Destructor, self=%p\n", self); /* * the error messages are static strings distributed throughout the @@ -559,7 +559,7 @@ EN_add_connection(EnvironmentClass *self, ConnectionClass *conn) { int i; - mylog("EN_add_connection: self = %x, conn = %x\n", self, conn); + mylog("EN_add_connection: self = %p, conn = %p\n", self, conn); ENTER_CONNS_CS; for (i = 0; i < MAX_CONNECTIONS; i++) @@ -570,7 +570,7 @@ EN_add_connection(EnvironmentClass *self, ConnectionClass *conn) conns[i] = conn; LEAVE_CONNS_CS; - mylog(" added at i =%d, conn->henv = %x, conns[i]->henv = %x\n", i, conn->henv, conns[i]->henv); + mylog(" added at i =%d, conn->henv = %p, conns[i]->henv = %p\n", i, conn->henv, conns[i]->henv); return TRUE; } diff --git a/execute.c b/execute.c index 4a6a621..2560867 100644 --- a/execute.c +++ b/execute.c @@ -18,6 +18,10 @@ #include #include +#ifndef WIN32 +#include +#endif /* WIN32 */ + #include "environ.h" #include "connection.h" #include "statement.h" @@ -165,7 +169,7 @@ inolog("a2\n"); return SQL_ERROR; } - mylog("**** %s: hstmt=%x, statement='%s'\n", func, hstmt, stmt->statement); + mylog("**** %s: hstmt=%p, statement='%s'\n", func, hstmt, stmt->statement); if (0 != (flag & PODBC_WITH_HOLD)) SC_set_with_hold(stmt); @@ -413,7 +417,7 @@ mylog("about to begin SC_execute\n"); QResultClass *kres; kres = res->next; -inolog("res->next=%x\n", kres); +inolog("res->next=%p\n", kres); res->next = NULL; SC_set_Result(stmt, kres); res = kres; @@ -502,7 +506,7 @@ StartRollbackState(StatementClass *stmt) ConnectionClass *conn; ConnInfo *ci = NULL; -inolog("%s:%x->internal=%d\n", func, stmt, stmt->internal); +inolog("%s:%p->internal=%d\n", func, stmt, stmt->internal); conn = SC_get_conn(stmt); if (conn) ci = &conn->connInfo; @@ -598,7 +602,7 @@ SetStatementSvp(StatementClass *stmt) else SC_set_accessed_db(stmt); } -inolog("%s:%x->accessed=%d\n", func, stmt, SC_accessed_db(stmt)); +inolog("%s:%p->accessed=%d\n", func, stmt, SC_accessed_db(stmt)); return ret; } @@ -611,7 +615,7 @@ DiscardStatementSvp(StatementClass *stmt, RETCODE ret, BOOL errorOnly) QResultClass *res; BOOL cmd_success, start_stmt = FALSE; -inolog("%s:%x->accessed=%d is_in=%d is_rb=%d is_tc=%d\n", func, stmt, SC_accessed_db(stmt), +inolog("%s:%p->accessed=%d is_in=%d is_rb=%d is_tc=%d\n", func, stmt, SC_accessed_db(stmt), CC_is_in_trans(conn), SC_is_rb_stmt(stmt), SC_is_tc_stmt(stmt)); switch (ret) { @@ -1072,7 +1076,7 @@ PGAPI_Transact( *stmt_string; int lf; - mylog("entering %s: hdbc=%x, henv=%x\n", func, hdbc, henv); + mylog("entering %s: hdbc=%p, henv=%p\n", func, hdbc, henv); if (hdbc == SQL_NULL_HDBC && henv == SQL_NULL_HENV) { @@ -1365,7 +1369,7 @@ PGAPI_ParamData( /* Done, now copy the params and then execute the statement */ ipdopts = SC_get_IPDF(estmt); -inolog("ipdopts=%x\n", ipdopts); +inolog("ipdopts=%p\n", ipdopts); if (estmt->data_at_exec == 0) { BOOL exec_end; @@ -1401,7 +1405,7 @@ inolog("i=%d allocated=%d num_p=%d\n", i, apdopts->allocated, num_p); inolog("i=%d", i); if (apdopts->parameters[i].data_at_exec) { -inolog(" at exec buffer=%x", apdopts->parameters[i].buffer); +inolog(" at exec buffer=%p", apdopts->parameters[i].buffer); estmt->data_at_exec--; estmt->current_exec_param = i; estmt->put_data = FALSE; diff --git a/info.c b/info.c index d0cd6f1..96e2dcd 100644 --- a/info.c +++ b/info.c @@ -147,7 +147,7 @@ PGAPI_GetInfo( case SQL_CONVERT_VARCHAR: /* ODBC 1.0 */ len = sizeof(SQLUINTEGER); value = SQL_CVT_BIT | SQL_CVT_INTEGER; -mylog("SQL_CONVERT_ mask=%x\n", value); +mylog("SQL_CONVERT_ mask=" FORMAT_ULEN "\n", value); break; case SQL_CONVERT_BIGINT: case SQL_CONVERT_DECIMAL: @@ -175,7 +175,7 @@ mylog("SQL_CONVERT_ mask=%x\n", value); case SQL_CONVERT_FUNCTIONS: /* ODBC 1.0 */ len = sizeof(SQLUINTEGER); value = SQL_FN_CVT_CONVERT; -mylog("CONVERT_FUNCTIONS=%x\n", value); +mylog("CONVERT_FUNCTIONS=" FORMAT_ULEN "\n", value); break; case SQL_CORRELATION_NAME: /* ODBC 1.0 */ @@ -1508,7 +1508,7 @@ PGAPI_Tables( BOOL search_pattern, list_schemas = FALSE; SQLLEN cbRelname, cbRelkind; - mylog("%s: entering...stmt=%x scnm=%x len=%d\n", func, stmt, NULL_IF_NULL(szTableOwner), cbTableOwner); + mylog("%s: entering...stmt=%p scnm=%p len=%d\n", func, stmt, NULL_IF_NULL(szTableOwner), cbTableOwner); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; @@ -1896,7 +1896,7 @@ cleanup: if (stmt->internal) ret = DiscardStatementSvp(stmt, ret, FALSE); - mylog("%s: EXIT, stmt=%x, ret=%d\n", func, stmt, ret); + mylog("%s: EXIT, stmt=%p, ret=%d\n", func, stmt, ret); return ret; } @@ -1948,7 +1948,7 @@ PGAPI_Columns( const char *like_or_eq = likeop; const char *szSchemaName; - mylog("%s: entering...stmt=%x scnm=%x len=%d\n", func, stmt, NULL_IF_NULL(szTableOwner), cbTableOwner); + mylog("%s: entering...stmt=%p scnm=%p len=%d\n", func, stmt, NULL_IF_NULL(szTableOwner), cbTableOwner); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; @@ -2064,7 +2064,7 @@ retry_public_schema: } col_stmt = (StatementClass *) hcol_stmt; - mylog("%s: hcol_stmt = %x, col_stmt = %x\n", func, hcol_stmt, col_stmt); + mylog("%s: hcol_stmt = %p, col_stmt = %p\n", func, hcol_stmt, col_stmt); result = PGAPI_ExecDirect(hcol_stmt, columns_query, SQL_NTS, 0); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) @@ -2560,7 +2560,7 @@ cleanup: PGAPI_FreeStmt(hcol_stmt, SQL_DROP); if (stmt->internal) result = DiscardStatementSvp(stmt, result, FALSE); - mylog("%s: EXIT, stmt=%x\n", func, stmt); + mylog("%s: EXIT, stmt=%p\n", func, stmt); return result; } @@ -2594,7 +2594,7 @@ PGAPI_SpecialColumns( SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName; const char *szSchemaName; - mylog("%s: entering...stmt=%x scnm=%x len=%d colType=%d\n", func, stmt, NULL_IF_NULL(szTableOwner), cbTableOwner, fColType); + mylog("%s: entering...stmt=%p scnm=%p len=%d colType=%d\n", func, stmt, NULL_IF_NULL(szTableOwner), cbTableOwner, fColType); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; @@ -2654,7 +2654,7 @@ retry_public_schema: } col_stmt = (StatementClass *) hcol_stmt; - mylog("%s: hcol_stmt = %x, col_stmt = %x\n", func, hcol_stmt, col_stmt); + mylog("%s: hcol_stmt = %p, col_stmt = %p\n", func, hcol_stmt, col_stmt); result = PGAPI_ExecDirect(hcol_stmt, columns_query, SQL_NTS, 0); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) @@ -2823,7 +2823,7 @@ cleanup: PGAPI_FreeStmt(hcol_stmt, SQL_DROP); if (stmt->internal) result = DiscardStatementSvp(stmt, result, FALSE); - mylog("%s: EXIT, stmt=%x\n", func, stmt); + mylog("%s: EXIT, stmt=%p\n", func, stmt); return result; } @@ -2874,7 +2874,7 @@ PGAPI_Statistics( const char *szSchemaName; BOOL unknownf; - mylog("%s: entering...stmt=%x scnm=%x len=%d\n", func, stmt, NULL_IF_NULL(szTableOwner), cbTableOwner); + mylog("%s: entering...stmt=%p scnm=%p len=%d\n", func, stmt, NULL_IF_NULL(szTableOwner), cbTableOwner); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; @@ -3290,7 +3290,7 @@ cleanup: if (stmt->internal) ret = DiscardStatementSvp(stmt, ret, FALSE); - mylog("%s: EXIT, stmt=%x, ret=%d\n", func, stmt, ret); + mylog("%s: EXIT, stmt=%p, ret=%d\n", func, stmt, ret); return ret; } @@ -3438,7 +3438,7 @@ PGAPI_PrimaryKeys( const char *szSchemaName; char *escSchemaName = NULL, *escTableName = NULL; - mylog("%s: entering...stmt=%x scnm=%x len=%d\n", func, stmt, NULL_IF_NULL(szTableOwner), cbTableOwner); + mylog("%s: entering...stmt=%p scnm=%p len=%d\n", func, stmt, NULL_IF_NULL(szTableOwner), cbTableOwner); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; @@ -3691,7 +3691,7 @@ cleanup: if (stmt->internal) ret = DiscardStatementSvp(stmt, ret, FALSE); - mylog("%s: EXIT, stmt=%x, ret=%d\n", func, stmt, ret); + mylog("%s: EXIT, stmt=%p, ret=%d\n", func, stmt, ret); return ret; } @@ -3837,7 +3837,7 @@ PGAPI_ForeignKeys( Int2 result_cols; UInt4 relid1, relid2; - mylog("%s: entering...stmt=%x\n", func, stmt); + mylog("%s: entering...stmt=%p\n", func, stmt); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; @@ -4654,7 +4654,7 @@ cleanup: if (stmt->internal) ret = DiscardStatementSvp(stmt, ret, FALSE); - mylog("%s(): EXIT, stmt=%x, ret=%d\n", func, stmt, ret); + mylog("%s(): EXIT, stmt=%p, ret=%d\n", func, stmt, ret); return ret; } @@ -4921,7 +4921,7 @@ mylog("atttypid=%s\n", atttypid ? atttypid : "(null)"); params = NULL; else { - sscanf(params, "%d", &pgtype); + sscanf(params, "%u", &pgtype); while (isdigit(*params)) params++; } @@ -5086,7 +5086,7 @@ PGAPI_Procedures( const char *like_or_eq; BOOL search_pattern; - mylog("%s: entering... scnm=%x len=%d\n", func, szProcOwner, cbProcOwner); + mylog("%s: entering... scnm=%p len=%d\n", func, szProcOwner, cbProcOwner); if (PG_VERSION_LT(conn, 6.5)) { @@ -5237,7 +5237,7 @@ PGAPI_TablePrivileges( char *escSchemaName = NULL, *escTableName = NULL; BOOL search_pattern; - mylog("%s: entering... scnm=%x len-%d\n", func, NULL_IF_NULL(szTableOwner), cbTableOwner); + mylog("%s: entering... scnm=%p len-%d\n", func, NULL_IF_NULL(szTableOwner), cbTableOwner); if (result = SC_initialize_and_recycle(stmt), SQL_SUCCESS != result) return result; diff --git a/inouealc.c b/inouealc.c index 899e9c6..9f03211 100644 --- a/inouealc.c +++ b/inouealc.c @@ -39,7 +39,7 @@ void * debug_alloc(size_t size) { void * alloced; alloced = malloc(size); -inolog(" alloced=%x(%d)\n", alloced, size); +inolog(" alloced=%p(%d)\n", alloced, size); if (alloced) { if (!alsize) @@ -82,7 +82,7 @@ void * debug_calloc(size_t n, size_t size) } else mylog("%s:calloc %dbyte\n", ALCERR, size); -inolog("calloced = %x\n", alloced); +inolog("calloced = %p\n", alloced); return alloced; } void * debug_realloc(void * ptr, size_t size) @@ -90,7 +90,7 @@ void * debug_realloc(void * ptr, size_t size) void * alloced = realloc(ptr, size); if (!alloced) { - mylog("%s:debug_realloc %x error\n", ALCERR, ptr); + mylog("%s:debug_realloc %p error\n", ALCERR, ptr); } else if (!ptr) { @@ -112,7 +112,7 @@ void * debug_realloc(void * ptr, size_t size) } } - inolog("debug_realloc %x->%x\n", ptr, alloced); + inolog("debug_realloc %p->%p\n", ptr, alloced); return alloced; } char * debug_strdup(const char * ptr) @@ -120,7 +120,7 @@ char * debug_strdup(const char * ptr) char * alloced = strdup(ptr); if (!alloced) { - mylog("%s:debug_strdup %x error\n", ALCERR, ptr); + mylog("%s:debug_strdup %p error\n", ALCERR, ptr); } else { @@ -138,7 +138,7 @@ char * debug_strdup(const char * ptr) altbl[tbsize].len = strlen(ptr) + 1; tbsize++; } - inolog("debug_strdup %x->%x(%s)\n", ptr, alloced, alloced); + inolog("debug_strdup %p->%p(%s)\n", ptr, alloced, alloced); return alloced; } @@ -167,9 +167,9 @@ void debug_free(void * ptr) } } if (! freed) - mylog("%s:debug_freeing not found ptr %x\n", ALCERR, ptr); + mylog("%s:debug_freeing not found ptr %p\n", ALCERR, ptr); else - inolog("debug_freeing ptr=%x\n", ptr); + inolog("debug_freeing ptr=%p\n", ptr); free(ptr); } @@ -187,7 +187,7 @@ static BOOL out_check(void *out, size_t len, const char *name) if ((UInt4)out + len > (UInt4)(altbl[i].aladr) + altbl[i].len) { ret = FALSE; - mylog("%s:%s:out_check found memory buffer overrun %x(%d)>=%x(%d)\n", ALCERR, name, out, len, altbl[i].aladr, altbl[i].len); + mylog("%s:%s:out_check found memory buffer overrun %p(%d)>=%p(%d)\n", ALCERR, name, out, len, altbl[i].aladr, altbl[i].len); } break; } @@ -198,7 +198,7 @@ char *debug_strcpy(char *out, const char *in) { if (!out || !in) { - mylog("%s:debug_strcpy null pointer out=%x,in=%x\n", ALCERR, out, in); + mylog("%s:debug_strcpy null pointer out=%p,in=%p\n", ALCERR, out, in); return NULL; } out_check(out, strlen(in) + 1, "debug_strcpy"); @@ -210,7 +210,7 @@ char *debug_strncpy(char *out, const char *in, size_t len) if (!out || !in) { - mylog("%s:%s null pointer out=%x,in=%x\n", ALCERR, func, out, in); + mylog("%s:%s null pointer out=%p,in=%p\n", ALCERR, func, out, in); return NULL; } out_check(out, len, func); @@ -222,7 +222,7 @@ char *debug_strncpy_null(char *out, const char *in, size_t len) if (!out || !in) { - mylog("%s:%s null pointer out=%x,in=%x\n", ALCERR, func, out, in); + mylog("%s:%s null pointer out=%p,in=%p\n", ALCERR, func, out, in); return NULL; } out_check(out, len, func); @@ -233,7 +233,7 @@ void *debug_memcpy(void *out, const void *in, size_t len) { if (!out || !in) { - mylog("%s:debug_memcpy null pointer out=%x,in=%x\n", ALCERR, out, in); + mylog("%s:debug_memcpy null pointer out=%p,in=%p\n", ALCERR, out, in); return NULL; } out_check(out, len, "debug_memcpy"); @@ -244,7 +244,7 @@ void *debug_memset(void *out, int c, size_t len) { if (!out) { - mylog("%s:debug_memcpy null pointer out=%xx\n", ALCERR, out); + mylog("%s:debug_memcpy null pointer out=%p\n", ALCERR, out); return NULL; } out_check(out, len, "debug_memset"); @@ -266,7 +266,7 @@ void debug_memory_check(void) mylog("%s:memory leak found check count=%d alloc=%d\n", ALCERR, tbsize, alsize); for (i = 0; i < tbsize; i++) { - mylog("%s:leak = %x(%d)\n", ALCERR, altbl[i].aladr, altbl[i].len); + mylog("%s:leak = %p(%d)\n", ALCERR, altbl[i].aladr, altbl[i].len); } } } diff --git a/loadlib.c b/loadlib.c index 4c1dd90..a8d27ad 100644 --- a/loadlib.c +++ b/loadlib.c @@ -60,7 +60,7 @@ static HMODULE LIBPQ_load_from_psqlodbc_path() if (strnicmp(szFileName, sysdir, strlen(sysdir)) != 0) { hmodule = LoadLibraryEx(szFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - mylog("psqlodbc path based libpq loaded module=%x\n", hmodule); + mylog("psqlodbc path based libpq loaded module=%p\n", hmodule); } } return hmodule; @@ -85,7 +85,7 @@ DliErrorHook(unsigned dliNotify, int i; static const char * const libarray[] = {"libssl32", "ssleay32"}; - mylog("DliErrorHook Notify=%d %x\n", dliNotify, pdli); + mylog("DliErrorHook Notify=%d %p\n", dliNotify, pdli); switch (dliNotify) { case dliFailLoadLib: @@ -188,7 +188,7 @@ BOOL LIBPQ_check() if (!(hmodule = LoadLibrary(libpq))) /* Second try the driver's directory */ hmodule = LIBPQ_load_from_psqlodbc_path(); - mylog("hmodule=%x\n", hmodule); + mylog("hmodule=%p\n", hmodule); if (hmodule) FreeLibrary(hmodule); return (NULL != hmodule); diff --git a/misc.c b/misc.c index 7d8a064..8cc5404 100644 --- a/misc.c +++ b/misc.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #ifndef WIN32 @@ -133,7 +134,7 @@ make_string(const char *s, ssize_t len, char *buf, size_t bufsize) inolog("malloc size=%d\n", length); str = malloc(length + 1); -inolog("str=%x\n", str); +inolog("str=%p\n", str); if (!str) return NULL; diff --git a/odbcapi.c b/odbcapi.c index 7226077..b58984a 100644 --- a/odbcapi.c +++ b/odbcapi.c @@ -293,7 +293,7 @@ SQLDisconnect(HDBC ConnectionHandle) RETCODE ret; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; - mylog("[%s for %x]", func, ConnectionHandle); + mylog("[%s for %p]", func, ConnectionHandle); #ifdef _HANDLE_ENLIST_IN_DTC_ DtcOnDisconnect(conn); /* must be called without holding the connection lock */ #endif /* _HANDLE_ENLIST_IN_DTC_ */ diff --git a/odbcapi30.c b/odbcapi30.c index 6e092a6..c0992ac 100644 --- a/odbcapi30.c +++ b/odbcapi30.c @@ -59,7 +59,7 @@ SQLAllocHandle(SQLSMALLINT HandleType, ENTER_CONN_CS(conn); ret = PGAPI_AllocDesc(InputHandle, OutputHandle); LEAVE_CONN_CS(conn); -inolog("OutputHandle=%x\n", *OutputHandle); +inolog("OutputHandle=%p\n", *OutputHandle); break; default: ret = SQL_ERROR; @@ -296,7 +296,7 @@ SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, CSTR func = "SQLGetDiagField"; RETCODE ret; - mylog("[[%s]] Handle=(%u,%x) Rec=%d Id=%d info=(%x,%d)\n", func, HandleType, Handle, RecNumber, DiagIdentifier, DiagInfo, BufferLength); + mylog("[[%s]] Handle=(%u,%p) Rec=%d Id=%d info=(%p,%d)\n", func, HandleType, Handle, RecNumber, DiagIdentifier, DiagInfo, BufferLength); ret = PGAPI_GetDiagField(HandleType, Handle, RecNumber, DiagIdentifier, DiagInfo, BufferLength, StringLength); return ret; @@ -415,7 +415,7 @@ SQLSetDescField(SQLHDESC DescriptorHandle, { RETCODE ret; - mylog("[[SQLSetDescField]] h=%x rec=%d field=%d val=%x\n", DescriptorHandle, RecNumber, FieldIdentifier, Value); + mylog("[[SQLSetDescField]] h=%p rec=%d field=%d val=%p\n", DescriptorHandle, RecNumber, FieldIdentifier, Value); ret = PGAPI_SetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength); return ret; @@ -508,7 +508,7 @@ SQLSetStmtAttr(HSTMT StatementHandle, StatementClass *stmt = (StatementClass *) StatementHandle; RETCODE ret; - mylog("[[%s]] Handle=%x %d,%u\n", func, StatementHandle, Attribute, Value); + mylog("[[%s]] Handle=%p %d,%u\n", func, StatementHandle, Attribute, Value); ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); @@ -649,7 +649,7 @@ SQLBulkOperations(HSTMT hstmt, SQLSMALLINT operation) StatementClass *stmt = (StatementClass *) hstmt; ENTER_STMT_CS(stmt); - mylog("[[%s]] Handle=%x %d\n", func, hstmt, operation); + mylog("[[%s]] Handle=%p %d\n", func, hstmt, operation); SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_BulkOperations(hstmt, operation); diff --git a/odbcapi30w.c b/odbcapi30w.c index 8b36af6..4b6c8ae 100644 --- a/odbcapi30w.c +++ b/odbcapi30w.c @@ -338,7 +338,7 @@ RETCODE SQL_API SQLGetDiagFieldW( SQLSMALLINT *rgbL, blen = 0, bMax; char *rgbD = NULL; - mylog("[[%s]] Handle=(%u,%x) Rec=%d Id=%d info=(%x,%d)\n", func, fHandleType, + mylog("[[%s]] Handle=(%u,%p) Rec=%d Id=%d info=(%p,%d)\n", func, fHandleType, handle, iRecord, fDiagField, rgbDiagInfo, cbDiagInfoMax); switch (fDiagField) { diff --git a/odbcapiw.c b/odbcapiw.c index 52b8ab7..4110de3 100644 --- a/odbcapiw.c +++ b/odbcapiw.c @@ -149,7 +149,7 @@ RETCODE SQL_API SQLDriverConnectW(HDBC hdbc, utf8_to_ucs2(szOut, maxlen, szConnStrOut, cbConnStrOutMax); if (outlen >= cbConnStrOutMax) { -inolog("cbConnstrOutMax=%d pcb=%x\n", cbConnStrOutMax, pcbConnStrOut); +inolog("cbConnstrOutMax=%d pcb=%p\n", cbConnStrOutMax, pcbConnStrOut); if (SQL_SUCCESS == ret) { CC_set_error(conn, CONN_TRUNCATED, "the ConnStrOut is too small", func); diff --git a/options.c b/options.c index f9e8f64..d87138d 100644 --- a/options.c +++ b/options.c @@ -248,13 +248,13 @@ set_statement_option(ConnectionClass *conn, if (stmt) { SC_set_error(stmt, STMT_NOT_IMPLEMENTED_ERROR, "Unknown statement option (Set)", NULL); - sprintf(option, "fOption=%d, vParam=%ld", fOption, vParam); + sprintf(option, "fOption=%d, vParam=" FORMAT_LEN, fOption, vParam); SC_log_error(func, option, stmt); } if (conn) { CC_set_error(conn, CONN_NOT_IMPLEMENTED_ERROR, "Unknown statement option (Set)", func); - sprintf(option, "fOption=%d, vParam=%ld", fOption, vParam); + sprintf(option, "fOption=%d, vParam=" FORMAT_LEN, fOption, vParam); CC_log_error(func, option, conn); } @@ -454,7 +454,7 @@ PGAPI_SetConnectOption( char option[64]; CC_set_error(conn, CONN_UNSUPPORTED_OPTION, "Unknown connect option (Set)", func); - sprintf(option, "fOption=%d, vParam=%ld", fOption, vParam); + sprintf(option, "fOption=%d, vParam=" FORMAT_LEN, fOption, vParam); if (fOption == 30002 && vParam) { int cmp; diff --git a/parse.c b/parse.c index 39923b2..75603e3 100644 --- a/parse.c +++ b/parse.c @@ -679,7 +679,7 @@ BOOL getCOLIfromTI(const char *func, ConnectionClass *conn, StatementClass *stmt HSTMT hcol_stmt = NULL; QResultClass *res; -inolog("getCOLIfromTI reloid=%u ti=%x\n", reloid, wti); +inolog("getCOLIfromTI reloid=%u ti=%p\n", reloid, wti); if (!conn) conn = SC_get_conn(stmt); if (!wti) /* SQLColAttribute case */ @@ -706,7 +706,7 @@ inolog("before increaseNtab\n"); } *pti = wti; } -inolog("fi=%x greloid=%d col_info=%x\n", wti, greloid, wti->col_info); +inolog("fi=%p greloid=%d col_info=%p\n", wti, greloid, wti->col_info); if (0 == greloid) greloid = wti->table_oid; if (NULL != wti->col_info) @@ -826,7 +826,7 @@ inolog("fi=%x greloid=%d col_info=%x\n", wti, greloid, wti->col_info); STR_TO_NAME(wti->table_name, QR_get_value_backend_row(res, 0, COLUMNS_TABLE_NAME)); } -inolog("#2 %x->table_name=%s(%u)\n", wti, PRINT_NAME(wti->table_name), wti->table_oid); +inolog("#2 %p->table_name=%s(%u)\n", wti, PRINT_NAME(wti->table_name), wti->table_oid); /* * Store the table name and the SQLColumns result * structure @@ -877,7 +877,7 @@ cleanup: STR_TO_NAME(wti->table_name, QR_get_value_backend_row(res, 0, COLUMNS_TABLE_NAME)); } -inolog("#1 %x->table_name=%s(%u)\n", wti, PRINT_NAME(wti->table_name), wti->table_oid); +inolog("#1 %p->table_name=%s(%u)\n", wti, PRINT_NAME(wti->table_name), wti->table_oid); if (colatt /* SQLColAttribute case */ && 0 == (wti->flags & TI_COLATTRIBUTE)) { diff --git a/pgapi30.c b/pgapi30.c index 74c7b28..962a8f0 100644 --- a/pgapi30.c +++ b/pgapi30.c @@ -1521,7 +1521,7 @@ PGAPI_GetStmtAttr(HSTMT StatementHandle, RETCODE ret = SQL_SUCCESS; SQLINTEGER len = 0; - mylog("%s Handle=%x %d\n", func, StatementHandle, Attribute); + mylog("%s Handle=%p %d\n", func, StatementHandle, Attribute); switch (Attribute) { case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ @@ -1623,7 +1623,7 @@ PGAPI_SetConnectAttr(HDBC ConnectionHandle, RETCODE ret = SQL_SUCCESS; BOOL unsupported = FALSE; - mylog("%s for %x: %d %x\n", func, ConnectionHandle, Attribute, Value); + mylog("%s for %p: %d %p\n", func, ConnectionHandle, Attribute, Value); switch (Attribute) { case SQL_ATTR_METADATA_ID: @@ -1647,7 +1647,7 @@ PGAPI_SetConnectAttr(HDBC ConnectionHandle, case SQL_ATTR_ENLIST_IN_DTC: #ifdef WIN32 #ifdef _HANDLE_ENLIST_IN_DTC_ - mylog("SQL_ATTR_ENLIST_IN_DTC %x request received\n", Value); + mylog("SQL_ATTR_ENLIST_IN_DTC %p request received\n", Value); if (conn->connInfo.xa_opt != 0) return EnlistInDtc(conn, Value, conn->connInfo.xa_opt); #endif /* _HANDLE_ENLIST_IN_DTC_ */ @@ -1669,7 +1669,7 @@ PGAPI_SetConnectAttr(HDBC ConnectionHandle, if (unsupported) { char msg[64]; - snprintf(msg, sizeof(msg), "Couldn't set unsupported connect attribute %ld", (LONG_PTR) Value); + snprintf(msg, sizeof(msg), "Couldn't set unsupported connect attribute " FORMAT_LPTR, (LONG_PTR) Value); CC_set_error(conn, CONN_OPTION_NOT_FOR_THE_DRIVER, msg, func); return SQL_ERROR; } @@ -1687,7 +1687,7 @@ PGAPI_GetDescField(SQLHDESC DescriptorHandle, RETCODE ret = SQL_SUCCESS; DescriptorClass *desc = (DescriptorClass *) DescriptorHandle; - mylog("%s h=%x rec=%d field=%d blen=%d\n", func, DescriptorHandle, RecNumber, FieldIdentifier, BufferLength); + mylog("%s h=%p rec=%d field=%d blen=%d\n", func, DescriptorHandle, RecNumber, FieldIdentifier, BufferLength); switch (desc->desc_type) { case SQL_ATTR_APP_ROW_DESC: @@ -1737,7 +1737,7 @@ PGAPI_SetDescField(SQLHDESC DescriptorHandle, RETCODE ret = SQL_SUCCESS; DescriptorClass *desc = (DescriptorClass *) DescriptorHandle; - mylog("%s h=%x rec=%d field=%d val=%x,%d\n", func, DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength); + mylog("%s h=%p rec=%d field=%d val=%p,%d\n", func, DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength); switch (desc->desc_type) { case SQL_ATTR_APP_ROW_DESC: @@ -1787,7 +1787,7 @@ PGAPI_SetStmtAttr(HSTMT StatementHandle, CSTR func = "PGAPI_SetStmtAttr"; StatementClass *stmt = (StatementClass *) StatementHandle; - mylog("%s Handle=%x %d,%u\n", func, StatementHandle, Attribute, Value); + mylog("%s Handle=%p %d,%u\n", func, StatementHandle, Attribute, Value); switch (Attribute) { case SQL_ATTR_ENABLE_AUTO_IPD: /* 15 */ @@ -1820,7 +1820,7 @@ PGAPI_SetStmtAttr(HSTMT StatementHandle, else { stmt->ard = (ARDClass *) Value; -inolog("set ard=%x\n", stmt->ard); +inolog("set ard=%p\n", stmt->ard); } break; case SQL_ATTR_APP_PARAM_DESC: /* 10011 */ diff --git a/psqlodbc.h b/psqlodbc.h index 8ec6f3d..7ad5675 100644 --- a/psqlodbc.h +++ b/psqlodbc.h @@ -5,7 +5,7 @@ * * Comments: See "notice.txt" for copyright and license information. * - * $Id: psqlodbc.h,v 1.111 2006/10/12 01:55:33 h-saito Exp $ + * $Id: psqlodbc.h,v 1.112 2006/10/17 16:18:56 hinoue Exp $ * */ @@ -98,17 +98,56 @@ typedef UInt4 OID; #ifdef WIN32 #define ssize_t SSIZE_T +#define FORMAT_SIZE_T "%Iu" /* size_t */ +#define FORMAT_SSIZE_T "%Id" /* ssize_t */ +#define FORMAT_INTEGER "%ld" /* SQLINTEGER */ +#define FORMAT_UINTEGER "%lu" /* SQLUINTEGER */ +#ifdef _WIN64 +#define FORMAT_LEN "%I64d" /* SQLLEN */ +#define FORMAT_ULEN "%I64u" /* SQLULEN */ +#define FORMAT_LPTR "%I64d" /* LONG_PTR */ +#define FORMAT_ULPTR "%I64u" /* ULONG_PTR */ #else +#define FORMAT_LEN "%ld" /* SQLLEN */ +#define FORMAT_ULEN "%lu" /* SQLULEN */ +#define FORMAT_LPTR "%ld" /* LONG_PTR */ +#define FORMAT_ULPTR "%lu" /* ULONG_PTR */ +#endif /* _WIN64 */ +#else +#define FORMAT_SIZE_T "%xu" /* size_t */ +#define FORMAT_SSIZE_T "%xd" /* ssize_t */ +#ifndef HAVE_SSIZE_T +typedef long ssize_t +#endif /* HAVE_SSIZE_T */ #if (SIZE_OF_VOID_P == SIZE_OF_LONG) typedef long LONG_PTR; typedef unsigned long ULONG_PTR; +#define FORMAT_LPTR "%ld" /* LONG_PTR */ +#define FORMAT_ULPTR "%lu" /* ULONG_PTR */ +#elif defined (HAVE_LONG_LONG) +typedef long long LONG_PTR; +typedef unsigned long long ULONG_PTR; +#define FORMAT_LPTR "%lld" /* LONG_PTR */ +#define FORMAT_ULPTR "%llu" /* ULONG_PTR */ #else -typedef SQLLEN LONG_PTR; -typedef unsigned SQLLEN ULONG_PTR; +#error neither long nor long long is defined +#endif /* SIZE_OF_VOID_P */ +#if (SIZE_OF_VOID_P == 8) +#define FORMAT_INTEGER "%d" /* SQLINTEGER */ +#define FORMAT_UINTEGER "%u" /* SQLUINTEGER */ +#if defined(WITH_UNIXODBC) && !defined(BUILD_REAL_64_BIT_MODE) +#define FORMAT_LEN "%d" /* SQLLEN */ +#define FORMAT_ULEN "%u" /* SQLULEN */ +#else +#define FORMAT_LEN "%ld" /* SQLLEN */ +#define FORMAT_ULEN "%lu" /* SQLULEN */ +#endif /* WITH_UNIXODBC */ +#else +#define FORMAT_LEN "%ld" /* SQLLEN */ +#define FORMAT_ULEN "%lu" /* SQLULEN */ +#define FORMAT_INTEGER "%ld" /* SQLINTEGER */ +#define FORMAT_UINTEGER "%lu" /* SQLUINTEGER */ #endif /* SIZE_OF_VOID_P */ -#ifndef HAVE_SSIZE_T -typedef long ssize_t -#endif /* HAVE_SSIZE_T */ #endif /* WIN32 */ #define CAST_PTR(type, ptr) (type)((LONG_PTR)(ptr)) #define CAST_UPTR(type, ptr) (type)((ULONG_PTR)(ptr)) diff --git a/qresult.c b/qresult.c index 7b13371..d11b8e7 100644 --- a/qresult.c +++ b/qresult.c @@ -521,7 +521,7 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, const char *cursor) QR_set_conn(self, conn); - mylog("%s: cursor = '%s', self->cursor=%x\n", func, (cursor == NULL) ? "" : cursor, QR_get_cursor(self)); + mylog("%s: cursor = '%s', self->cursor=%p\n", func, (cursor == NULL) ? "" : cursor, QR_get_cursor(self)); if (cursor && !cursor[0]) cursor = NULL; @@ -653,7 +653,7 @@ QR_close(QResultClass *self) /* End the transaction if there are no cursors left on this conn */ if (CC_is_in_autocommit(conn) && CC_cursor_count(conn) == 0) { - mylog("QResult: END transaction on conn=%x\n", conn); + mylog("QResult: END transaction on conn=%p\n", conn); if (!CC_commit(conn)) { @@ -711,7 +711,7 @@ inolog("QR_get_tupledata num_fields=%d\n", self->num_fields); QR_set_message(self, "Error reading the tuple"); return FALSE; } -inolog("!!%x->cursTup=%d total_read=%d\n", self, self->cursTuple, self->num_total_read); +inolog("!!%p->cursTup=%d total_read=%d\n", self, self->cursTuple, self->num_total_read); if (!QR_once_reached_eof(self) && self->cursTuple >= (Int4) self->num_total_read) self->num_total_read = self->cursTuple + 1; inolog("!!cursTup=%d total_read=%d\n", self->cursTuple, self->num_total_read); @@ -808,7 +808,7 @@ QR_next_tuple(QResultClass *self, StatementClass *stmt) BOOL reached_eof_now = FALSE, curr_eof; /* detecting EOF is pretty important */ Int4 response_length; -inolog("Oh %x->fetch_number=%d\n", self, self->fetch_number); +inolog("Oh %p->fetch_number=%d\n", self, self->fetch_number); inolog("in total_read=%d cursT=%d currT=%d ad=%d total=%d rowsetSize=%d\n", self->num_total_read, self->cursTuple, stmt ? stmt->currTuple : -1, self->ad_count, QR_get_num_total_tuples(self), self->rowset_size_include_ommitted); num_total_rows = QR_get_num_total_tuples(self); @@ -836,11 +836,11 @@ inolog("in total_read=%d cursT=%d currT=%d ad=%d total=%d rowsetSize=%d\n", self } else self->cache_size = req_size; -inolog("cache=%d rowset=%d movement=%d\n", self->cache_size, req_size, movement); - sprintf(movecmd, "move backward %lu in \"%s\"", movement, QR_get_cursor(self)); +inolog("cache=%d rowset=%d movement=" FORMAT_ULEN "\n", self->cache_size, req_size, movement); + sprintf(movecmd, "move backward " FORMAT_ULEN " in \"%s\"", movement, QR_get_cursor(self)); } else if (QR_is_moving_forward(self)) - sprintf(movecmd, "move %lu in \"%s\"", movement, QR_get_cursor(self)); + sprintf(movecmd, "move " FORMAT_ULEN " in \"%s\"", movement, QR_get_cursor(self)); else { sprintf(movecmd, "move all in \"%s\"", QR_get_cursor(self)); @@ -857,7 +857,7 @@ inolog("cache=%d rowset=%d movement=%d\n", self->cache_size, req_size, movement) moved = movement; if (sscanf(mres->command, "MOVE %lu", &moved) > 0) { -inolog("moved=%d ? %d\n", moved, movement); +inolog("moved=%d ? " FORMAT_ULEN "\n", moved, movement); if (moved < movement) { if (0 < moved) @@ -895,7 +895,7 @@ inolog("back_offset=%d and move_offset=%d\n", back_offset, self->move_offset); if (back_offset + 1 > (Int4) self->ad_count) { bmovement = back_offset + 1 - self->ad_count; - sprintf(movecmd, "move backward %lu in \"%s\"", bmovement, QR_get_cursor(self)); + sprintf(movecmd, "move backward " FORMAT_ULEN " in \"%s\"", bmovement, QR_get_cursor(self)); QR_Destructor(mres); mres = CC_send_query(conn, movecmd, NULL, 0, stmt); if (!QR_command_maybe_successful(mres)) @@ -965,7 +965,7 @@ inolog("back_offset=%d and move_offset=%d\n", back_offset, self->move_offset); /* return a row from cache */ mylog("%s: fetch_number < fcount: returning tuple %d, fcount = %d\n", func, fetch_number, num_backend_rows); self->tupleField = the_tuples + (fetch_number * num_fields); -inolog("tupleField=%x\n", self->tupleField); +inolog("tupleField=%p\n", self->tupleField); /* move to next row */ QR_inc_next_in_cache(self); return TRUE; @@ -1175,7 +1175,7 @@ inolog("id='%c' response_length=%d\n", id, response_length); SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH); QR_set_command(self, cmdbuffer); - mylog("end of tuple list -- setting inUse to false: this = %x %s\n", self, cmdbuffer); + mylog("end of tuple list -- setting inUse to false: this = %p %s\n", self, cmdbuffer); qlog(" [ fetched %d rows ]\n", self->num_total_read); mylog("_%s: 'C' fetch_total = %d & this_fetch = %d\n", func, self->num_total_read, self->num_cached_rows); diff --git a/results.c b/results.c index 7d1a53c..ab92f6f 100644 --- a/results.c +++ b/results.c @@ -95,7 +95,7 @@ static BOOL SC_pre_execute_ok(StatementClass *stmt, BOOL build_fi, int col_idx, QResultClass *result = SC_get_Curres(stmt); BOOL exec_ok = TRUE; - mylog("%s: result = %x, status = %d, numcols = %d\n", func, result, stmt->status, result != NULL ? QR_NumResultCols(result) : -1); + mylog("%s: result = %p, status = %d, numcols = %d\n", func, result, stmt->status, result != NULL ? QR_NumResultCols(result) : -1); /****if ((!result) || ((stmt->status != STMT_FINISHED) && (stmt->status != STMT_PREMATURE))) ****/ if (!QR_command_maybe_successful(result) || num_fields < 0) { @@ -174,7 +174,7 @@ PGAPI_NumResultCols( { if (SC_parsed_status(stmt) == STMT_PARSE_NONE) { - mylog("PGAPI_NumResultCols: calling parse_statement on stmt=%x\n", stmt); + mylog("PGAPI_NumResultCols: calling parse_statement on stmt=%p\n", stmt); parse_statement(stmt, FALSE); } @@ -290,11 +290,11 @@ inolog("answering bookmark info\n"); { if (SC_parsed_status(stmt) == STMT_PARSE_NONE) { - mylog("%s: calling parse_statement on stmt=%x\n", func, stmt); + mylog("%s: calling parse_statement on stmt=%p\n", func, stmt); parse_statement(stmt, FALSE); } - mylog("PARSE: DescribeCol: icol=%d, stmt=%x, stmt->nfld=%d, stmt->fi=%x\n", icol, stmt, irdflds->nfields, irdflds->fi); + mylog("PARSE: DescribeCol: icol=%d, stmt=%p, stmt->nfld=%d, stmt->fi=%p\n", icol, stmt, irdflds->nfields, irdflds->fi); if (SC_parsed_status(stmt) != STMT_PARSE_FATAL && irdflds->fi) { @@ -617,7 +617,7 @@ inolog("answering bookmark info\n"); field_type = (conn->lobj_type == fi->columntype) ? fi->columntype : FI_type(fi); } - mylog("colAttr: col %d field_type=%d fi,ti=%x,%x\n", col_idx, field_type, fi, ti); + mylog("colAttr: col %d field_type=%d fi,ti=%p,%p\n", col_idx, field_type, fi, ti); switch (fDescType) { @@ -663,7 +663,7 @@ inolog("answering bookmark info\n"); #else case SQL_COLUMN_NAME: #endif /* ODBCVER */ -inolog("fi=%x", fi); +inolog("fi=%p", fi); if (fi) inolog(" (%s,%s)", PRINT_NAME(fi->column_alias), PRINT_NAME(fi->column_name)); p = fi ? (NAME_IS_NULL(fi->column_alias) ? SAFE_NAME(fi->column_name) : GET_NAME(fi->column_alias)) : QR_get_fieldname(res, col_idx); @@ -883,7 +883,7 @@ PGAPI_GetData( ConnInfo *ci; SQLSMALLINT target_type; - mylog("%s: enter, stmt=%x\n", func, stmt); + mylog("%s: enter, stmt=%p\n", func, stmt); if (!stmt) { @@ -1101,7 +1101,7 @@ PGAPI_Fetch( BindInfoClass *bookmark; RETCODE retval = SQL_SUCCESS; - mylog("%s: stmt = %x, stmt->result= %x\n", func, stmt, stmt ? SC_get_Curres(stmt) : NULL); + mylog("%s: stmt = %p, stmt->result= %p\n", func, stmt, stmt ? SC_get_Curres(stmt) : NULL); if (!stmt) { @@ -1376,7 +1376,7 @@ PGAPI_ExtendedFetch( UWORD pstatus; BOOL currp_is_valid, reached_eof; - mylog("%s: stmt=%x rowsetSize=%d\n", func, stmt, rowsetSize); + mylog("%s: stmt=%p rowsetSize=%d\n", func, stmt, rowsetSize); if (!stmt) { @@ -1973,7 +1973,7 @@ SQLLEN ClearCachedRows(TupleField *tuple, int num_fields, SQLLEN num_rows) { if (tuple->value) { -inolog("freeing tuple[%d][%d].value=%x\n", i / num_fields, i % num_fields, tuple->value); +inolog("freeing tuple[%d][%d].value=%p\n", i / num_fields, i % num_fields, tuple->value); free(tuple->value); tuple->value = NULL; } @@ -1985,7 +1985,7 @@ SQLLEN ReplaceCachedRows(TupleField *otuple, const TupleField *ituple, int num_f { SQLLEN i; -inolog("ReplaceCachedRows %x num_fields=%d num_rows=%d\n", otuple, num_fields, num_rows); +inolog("ReplaceCachedRows %p num_fields=%d num_rows=%d\n", otuple, num_fields, num_rows); for (i = 0; i < num_fields * num_rows; i++, ituple++, otuple++) { if (otuple->value) @@ -2008,7 +2008,7 @@ int MoveCachedRows(TupleField *otuple, TupleField *ituple, Int2 num_fields, SQLL { int i; -inolog("MoveCachedRows %x num_fields=%d num_rows=%d\n", otuple, num_fields, num_rows); +inolog("MoveCachedRows %p num_fields=%d num_rows=%d\n", otuple, num_fields, num_rows); for (i = 0; i < num_fields * num_rows; i++, ituple++, otuple++) { if (otuple->value) @@ -2167,7 +2167,7 @@ static void AddAdded(StatementClass *stmt, QResultClass *res, SQLLEN index, cons if (!res) return; num_fields = res->num_fields; -inolog("AddAdded index=%d, tuple=%x, num_fields=%d\n", index, tuple_added, num_fields); +inolog("AddAdded index=%d, tuple=%p, num_fields=%d\n", index, tuple_added, num_fields); ad_count = res->ad_count; res->ad_count++; if (QR_get_cursor(res)) @@ -2240,7 +2240,7 @@ static void CommitAdded(QResultClass *res) int i; UWORD status; - mylog("CommitAdded res=%x\n", res); + mylog("CommitAdded res=%p\n", res); if (!res || !res->added_keyset) return; added_keyset = res->added_keyset; for (i = res->ad_count - 1; i >= 0; i--) @@ -2639,7 +2639,7 @@ static void CommitUpdated(QResultClass *res) int i; UWORD status; - mylog("CommitUpdated res=%x\n", res); + mylog("CommitUpdated res=%p\n", res); if (!res) return; if (!QR_get_cursor(res)) return; @@ -2899,7 +2899,7 @@ inolog("UndoRollback %d(%d)\n", i, rollback[i].option); status = wkey->status; } } -inolog(" index=%d status=%x", index, status); +inolog(" index=%d status=%hx", index, status); if (kres_is_valid) { QResultClass *qres; @@ -3063,7 +3063,7 @@ SC_pos_reload(StatementClass *stmt, SQLULEN global_ridx, UInt2 *count, Int4 logK char tidval[32]; BOOL use_ctid = TRUE, data_in_cache = TRUE, key_in_cache = TRUE; - mylog("positioned load fi=%x ti=%x\n", irdflds->fi, stmt->ti); + mylog("positioned load fi=%p ti=%p\n", irdflds->fi, stmt->ti); rcnt = 0; if (count) *count = 0; @@ -3449,7 +3449,7 @@ SC_pos_newload(StatementClass *stmt, const UInt4 *oidint, BOOL tidRef) QResultClass *res, *qres; RETCODE ret = SQL_ERROR; - mylog("positioned new ti=%x\n", stmt->ti); + mylog("positioned new ti=%p\n", stmt->ti); if (!(res = SC_get_Curres(stmt))) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in SC_pos_newload.", func); @@ -3702,7 +3702,7 @@ SC_pos_update(StatementClass *stmt, SC_set_error(s.stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in SC_pos_update.", func); return SQL_ERROR; } - mylog("POS UPDATE %d+%d fi=%x ti=%x\n", s.irow, QR_get_rowstart_in_cache(s.res), fi, s.stmt->ti); + mylog("POS UPDATE %d+%d fi=%p ti=%p\n", s.irow, QR_get_rowstart_in_cache(s.res), fi, s.stmt->ti); if (SC_update_not_ready(stmt)) parse_statement(s.stmt, TRUE); /* not preferable */ if (!s.stmt->updatable) @@ -3743,7 +3743,7 @@ SC_pos_update(StatementClass *stmt, used = LENADDR_SHIFT(used, bind_size * s.irow); else used = LENADDR_SHIFT(used, s.irow * sizeof(SQLLEN)); - mylog("%d used=%d,%x\n", i, *used, used); + mylog("%d used=%d,%p\n", i, *used, used); if (*used != SQL_IGNORE && fi[i]->updatable) { if (upd_cols) @@ -3853,7 +3853,7 @@ SC_pos_delete(StatementClass *stmt, const char *bestitem; const char *bestqual; - mylog("POS DELETE ti=%x\n", stmt->ti); + mylog("POS DELETE ti=%p\n", stmt->ti); if (!(res = SC_get_Curres(stmt))) { SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Null statement result in SC_pos_delete.", func); @@ -4012,7 +4012,7 @@ irow_insert(RETCODE ret, StatementClass *stmt, StatementClass *istmt, SQLLEN add char buf[32]; SQLULEN offset = opts->row_offset_ptr ? *opts->row_offset_ptr : 0; - snprintf(buf, sizeof(buf), "%ld", SC_make_bookmark(addpos)); + snprintf(buf, sizeof(buf), FORMAT_LEN, SC_make_bookmark(addpos)); SC_set_current_col(stmt, -1); copy_and_convert_field(stmt, PG_TYPE_INT4, @@ -4126,7 +4126,7 @@ SC_pos_add(StatementClass *stmt, OID fieldtype; int func_cs_count = 0; - mylog("POS ADD fi=%x ti=%x\n", fi, stmt->ti); + mylog("POS ADD fi=%p ti=%p\n", fi, stmt->ti); s.stmt = stmt; s.irow = irow; if (!(s.res = SC_get_Curres(s.stmt))) @@ -4627,7 +4627,7 @@ PGAPI_SetCursorName( CSTR func = "PGAPI_SetCursorName"; StatementClass *stmt = (StatementClass *) hstmt; - mylog("PGAPI_SetCursorName: hstmt=%x, szCursor=%x, cbCursorMax=%d\n", hstmt, szCursor, cbCursor); + mylog("PGAPI_SetCursorName: hstmt=%p, szCursor=%p, cbCursorMax=%d\n", hstmt, szCursor, cbCursor); if (!stmt) { @@ -4653,7 +4653,7 @@ PGAPI_GetCursorName( size_t len = 0; RETCODE result; - mylog("PGAPI_GetCursorName: hstmt=%x, szCursor=%x, cbCursorMax=%d, pcbCursor=%x\n", hstmt, szCursor, cbCursorMax, pcbCursor); + mylog("PGAPI_GetCursorName: hstmt=%p, szCursor=%p, cbCursorMax=%d, pcbCursor=%p\n", hstmt, szCursor, cbCursorMax, pcbCursor); if (!stmt) { diff --git a/statement.c b/statement.c index 1f6e649..4805cd7 100644 --- a/statement.c +++ b/statement.c @@ -175,7 +175,7 @@ PGAPI_AllocStmt(HDBC hdbc, stmt = SC_Constructor(conn); - mylog("**** PGAPI_AllocStmt: hdbc = %x, stmt = %x\n", hdbc, stmt); + mylog("**** PGAPI_AllocStmt: hdbc = %p, stmt = %p\n", hdbc, stmt); if (!stmt) { @@ -215,7 +215,7 @@ PGAPI_FreeStmt(HSTMT hstmt, CSTR func = "PGAPI_FreeStmt"; StatementClass *stmt = (StatementClass *) hstmt; - mylog("%s: entering...hstmt=%x, fOption=%d\n", func, hstmt, fOption); + mylog("%s: entering...hstmt=%p, fOption=%hi\n", func, hstmt, fOption); if (!stmt) { @@ -423,7 +423,7 @@ SC_Destructor(StatementClass *self) QResultClass *res = SC_get_Result(self); if (!self) return FALSE; - mylog("SC_Destructor: self=%x, self->result=%x, self->hdbc=%x\n", self, res, self->hdbc); + mylog("SC_Destructor: self=%p, self->result=%p, self->hdbc=%p\n", self, res, self->hdbc); SC_clear_error(self); if (STMT_EXECUTING == self->status) { @@ -534,7 +534,7 @@ SC_set_rowset_start(StatementClass *stmt, SQLLEN start, BOOL valid_base) QResultClass *res = SC_get_Curres(stmt); SQLLEN incr = start - stmt->rowset_start; -inolog("%x->SC_set_rowstart %d->%d(%s) ", stmt, stmt->rowset_start, start, valid_base ? "valid" : "unknown"); +inolog("%p->SC_set_rowstart " FORMAT_LEN "->" FORMAT_LEN "(%s) ", stmt, stmt->rowset_start, start, valid_base ? "valid" : "unknown"); if (res != NULL) { BOOL valid = QR_has_valid_base(res); @@ -557,10 +557,10 @@ inolog(":QR is %s", QR_has_valid_base(res) ? "valid" : "unknown"); } if (!QR_get_cursor(res)) res->key_base = start; -inolog(":QR result=%d(%s)", QR_get_rowstart_in_cache(res), QR_has_valid_base(res) ? "valid" : "unknown"); +inolog(":QR result=" FORMAT_LEN "(%s)", QR_get_rowstart_in_cache(res), QR_has_valid_base(res) ? "valid" : "unknown"); } stmt->rowset_start = start; -inolog(":stmt result=%d\n", stmt->rowset_start); +inolog(":stmt result=" FORMAT_LEN "\n", stmt->rowset_start); } void SC_inc_rowset_start(StatementClass *stmt, SQLLEN inc) @@ -717,7 +717,7 @@ SC_recycle_statement(StatementClass *self) ConnectionClass *conn; QResultClass *res; - mylog("%s: self= %x\n", func, self); + mylog("%s: self= %p\n", func, self); SC_clear_error(self); /* This would not happen */ @@ -805,7 +805,7 @@ inolog("SC_clear_parse_status\n"); SC_set_rowset_start(self, -1, FALSE); SC_set_current_col(self, -1); self->bind_row = 0; -inolog("%s statement=%x ommitted=0\n", func, self); +inolog("%s statement=%p ommitted=0\n", func, self); self->last_fetch_count = self->last_fetch_count_include_ommitted = 0; self->__error_message = NULL; @@ -1118,10 +1118,10 @@ StatementClass *SC_get_ancestor(StatementClass *stmt) { StatementClass *child = stmt, *parent; -inolog("SC_get_ancestor in stmt=%x\n", stmt); +inolog("SC_get_ancestor in stmt=%p\n", stmt); for (child = stmt, parent = child->execute_parent; parent; child = parent, parent = child->execute_parent) { - inolog("parent=%x\n", parent); + inolog("parent=%p\n", parent); } return child; } @@ -1161,7 +1161,7 @@ SC_replace_error_with_res(StatementClass *self, int number, const char *message, QResultClass *self_res; BOOL repstate; -inolog("SC_set_error_from_res %x->%x check=%d\n", from_res ,self, check); +inolog("SC_set_error_from_res %p->%p check=%i\n", from_res ,self, check); if (check) { if (0 == number) return; @@ -1206,7 +1206,7 @@ SC_error_copy(StatementClass *self, const StatementClass *from, BOOL check) QResultClass *self_res, *from_res; BOOL repstate; -inolog("SC_error_copy %x->%x check=%d\n", from ,self, check); +inolog("SC_error_copy %p->%p check=%i\n", from ,self, check); if (self == from) return; if (check) { @@ -1254,7 +1254,7 @@ SC_full_error_copy(StatementClass *self, const StatementClass *from, BOOL allres { PG_ErrorInfo *pgerror; -inolog("SC_full_error_copy %x->%x\n", from ,self); +inolog("SC_full_error_copy %p->%p\n", from ,self); if (self->__error_message) { free(self->__error_message); @@ -1343,11 +1343,11 @@ SC_fetch(StatementClass *self) /* TupleField *tupleField; */ -inolog("%s statement=%x ommitted=0\n", func, self); +inolog("%s statement=%p ommitted=0\n", func, self); self->last_fetch_count = self->last_fetch_count_include_ommitted = 0; coli = QR_get_fields(res); /* the column info */ - mylog("fetch_cursor=%d, %x->total_read=%d\n", SC_is_fetchcursor(self), res, res->num_total_read); + mylog("fetch_cursor=%d, %p->total_read=%d\n", SC_is_fetchcursor(self), res, res->num_total_read); if (!SC_is_fetchcursor(self)) { @@ -1395,7 +1395,7 @@ inolog("%s statement=%x ommitted=0\n", func, self); if (kres_ridx >= 0 && kres_ridx < res->num_cached_keys) { UWORD pstatus = res->keyset[kres_ridx].status; -inolog("SC_ pstatus[%d]=%x fetch_count=%d\n", kres_ridx, pstatus, self->last_fetch_count); +inolog("SC_ pstatus[%d]=%hx fetch_count=" FORMAT_LEN "\n", kres_ridx, pstatus, self->last_fetch_count); if (0 != (pstatus & (CURS_SELF_DELETING | CURS_SELF_DELETED))) return SQL_SUCCESS_WITH_INFO; if (SQL_ROW_DELETED != (pstatus & KEYSET_INFO_PUBLIC) && @@ -1417,7 +1417,7 @@ inolog("SC_ pstatus[%d]=%x fetch_count=%d\n", kres_ridx, pstatus, self->last_fet result = SQL_SUCCESS; self->last_fetch_count++; -inolog("%s: stmt=%x ommitted++\n", func, self); +inolog("%s: stmt=%p ommitted++\n", func, self); self->last_fetch_count_include_ommitted++; opts = SC_get_ARDF(self); @@ -1432,7 +1432,7 @@ inolog("%s: stmt=%x ommitted++\n", func, self); char buf[32]; SQLLEN offset = opts->row_offset_ptr ? *opts->row_offset_ptr : 0; - sprintf(buf, "%ld", SC_get_bookmark(self)); + sprintf(buf, FORMAT_ULEN, SC_get_bookmark(self)); SC_set_current_col(self, -1); result = copy_and_convert_field(self, 0, buf, SQL_C_ULONG, bookmark->buffer + offset, 0, @@ -1446,7 +1446,7 @@ inolog("%s: stmt=%x ommitted++\n", func, self); extend_getdata_info(gdata, opts->allocated, TRUE); for (lf = 0; lf < num_cols; lf++) { - mylog("fetch: cols=%d, lf=%d, opts = %x, opts->bindings = %x, buffer[] = %x\n", num_cols, lf, opts, opts->bindings, opts->bindings[lf].buffer); + mylog("fetch: cols=%d, lf=%d, opts = %p, opts->bindings = %p, buffer[] = %p\n", num_cols, lf, opts, opts->bindings, opts->bindings[lf].buffer); /* reset for SQLGetData */ gdata->gdata[lf].data_left = -1; @@ -1581,7 +1581,7 @@ SC_execute(StatementClass *self) } if (issue_begin) { - mylog(" about to begin a transaction on statement = %x\n", self); + mylog(" about to begin a transaction on statement = %p\n", self); if (PG_VERSION_GE(conn, 7.1)) qflag |= GO_INTO_TRANSACTION; else if (!CC_begin(conn)) @@ -1633,7 +1633,7 @@ SC_execute(StatementClass *self) if (issue_begin) CC_begin(conn); res = SC_get_Result(self); -inolog("get_Result=%x\n", res); +inolog("get_Result=%p\n", res); if (!plan_name) plan_name = ""; if (!SendBindRequest(self, plan_name)) @@ -1661,7 +1661,7 @@ inolog("get_Result=%x\n", res); char fetch[128]; qflag |= (SQL_CONCUR_READ_ONLY != self->options.scroll_concurrency ? CREATE_KEYSET : 0); - mylog(" Sending SELECT statement on stmt=%x, cursor_name='%s' qflag=%d,%d\n", self, SC_cursor_name(self), qflag, self->options.scroll_concurrency); + mylog(" Sending SELECT statement on stmt=%p, cursor_name='%s' qflag=%d,%d\n", self, SC_cursor_name(self), qflag, self->options.scroll_concurrency); /* send the declare/select */ res = CC_send_query(conn, self->stmt_with_params, NULL, qflag, SC_get_ancestor(self)); @@ -1686,7 +1686,7 @@ inolog("get_Result=%x\n", res); * will correct for any discrepancies in sizes and adjust the * cache accordingly. */ - sprintf(fetch, "fetch %ld in \"%s\"", qi.row_size, SC_cursor_name(self)); + sprintf(fetch, "fetch " FORMAT_LEN " in \"%s\"", qi.row_size, SC_cursor_name(self)); res = CC_send_query(conn, fetch, &qi, qflag, SC_get_ancestor(self)); if (SC_is_with_hold(self)) @@ -1697,7 +1697,7 @@ inolog("get_Result=%x\n", res); else { /* not a SELECT statement so don't use a cursor */ - mylog(" it's NOT a select statement: stmt=%x\n", self); + mylog(" it's NOT a select statement: stmt=%p\n", self); res = CC_send_query(conn, self->stmt_with_params, NULL, qflag, SC_get_ancestor(self)); /* @@ -1770,7 +1770,7 @@ inolog("get_Result=%x\n", res); } } -inolog("!!%x->SC_is_concat_pre=%x res=%x\n", self, self->miscinfo, res); +inolog("!!%p->SC_is_concat_pre=%x res=%p\n", self, self->miscinfo, res); /* * special handling of result for keyset driven cursors. * Use the columns info of the 1st query and * user the keyset info of the 2nd query. @@ -1797,7 +1797,7 @@ inolog("!!%x->SC_is_concat_pre=%x res=%x\n", self, self->miscinfo, res); else if (SC_is_concat_prepare_exec(self)) { tres = res->next; -inolog("res->next=%x\n", tres); +inolog("res->next=%p\n", tres); res->next = NULL; if (res != SC_get_Result(self)) QR_Destructor(res); @@ -1935,7 +1935,7 @@ int enqueueNeedDataCallback(StatementClass *stmt, NeedDataCallfunc func, void *d stmt->callbacks[stmt->num_callbacks].data = data; stmt->num_callbacks++; -inolog("enqueueNeedDataCallack stmt=%x, func=%x, count=%d\n", stmt, func, stmt->num_callbacks); +inolog("enqueueNeedDataCallack stmt=%p, func=%p, count=%d\n", stmt, func, stmt->num_callbacks); return stmt->num_callbacks; } @@ -2006,10 +2006,10 @@ SC_log_error(const char *func, const char *desc, const StatementClass *self) if (SC_get_errornumber(self) > 0) { qlog(" ------------------------------------------------------------\n"); - qlog(" hdbc=%x, stmt=%x, result=%x\n", self->hdbc, self, res); + qlog(" hdbc=%p, stmt=%p, result=%p\n", self->hdbc, self, res); qlog(" prepare=%d, internal=%d\n", self->prepare, self->internal); - qlog(" bindings=%x, bindings_allocated=%d\n", opts->bindings, opts->allocated); - qlog(" parameters=%x, parameters_allocated=%d\n", apdopts->parameters, apdopts->allocated); + qlog(" bindings=%p, bindings_allocated=%d\n", opts->bindings, opts->allocated); + qlog(" parameters=%p, parameters_allocated=%d\n", apdopts->parameters, apdopts->allocated); qlog(" statement_type=%d, statement='%s'\n", self->statement_type, nullcheck(self->statement)); qlog(" stmt_with_params='%s'\n", nullcheck(self->stmt_with_params)); qlog(" data_at_exec=%d, current_exec_param=%d, put_data=%d\n", self->data_at_exec, self->current_exec_param, self->put_data); @@ -2021,7 +2021,7 @@ SC_log_error(const char *func, const char *desc, const StatementClass *self) if (res) { - qlog(" fields=%x, backend_tuples=%x, tupleField=%d, conn=%x\n", res->fields, res->backend_tuples, res->tupleField, res->conn); + qlog(" fields=%p, backend_tuples=%p, tupleField=%d, conn=%p\n", res->fields, res->backend_tuples, res->tupleField, res->conn); qlog(" fetch_count=%d, num_total_rows=%d, num_fields=%d, cursor='%s'\n", res->fetch_number, QR_get_num_total_tuples(res), res->num_fields, nullcheck(QR_get_cursor(res))); qlog(" message='%s', command='%s', notice='%s'\n", nullcheck(res->message), nullcheck(res->command), nullcheck(res->notice)); qlog(" status=%d, inTuples=%d\n", QR_get_rstatus(res), QR_is_fetching_tuples(res)); diff --git a/statement.h b/statement.h index 2856627..0e0f599 100644 --- a/statement.h +++ b/statement.h @@ -245,7 +245,7 @@ struct StatementClass_ char pre_executing; /* This statement is prematurely executing */ char inaccurate_result; /* Current status is PREMATURE but * result is inaccurate */ - char miscinfo; + unsigned char miscinfo; char updatable; SQLLEN diag_row_count; char *load_statement; /* to (re)load updatable individual rows */ diff --git a/version.h b/version.h index 43e13d1..e2c4218 100644 --- a/version.h +++ b/version.h @@ -9,8 +9,8 @@ #ifndef __VERSION_H__ #define __VERSION_H__ -#define POSTGRESDRIVERVERSION "08.02.0103" -#define POSTGRES_RESOURCE_VERSION "08.02.0103\0" -#define PG_DRVFILE_VERSION 8,2,01,03 +#define POSTGRESDRIVERVERSION "08.02.0104" +#define POSTGRES_RESOURCE_VERSION "08.02.0104\0" +#define PG_DRVFILE_VERSION 8,2,01,04 #endif diff --git a/win_unicode.c b/win_unicode.c index 0094da2..4d8b153 100644 --- a/win_unicode.c +++ b/win_unicode.c @@ -8,11 +8,11 @@ */ #include "psqlodbc.h" +#include #ifdef WIN32 #ifdef _DEBUG #ifndef _MEMORY_DEBUG_ #include -#include #define _CRTDBG_MAP_ALLOC #include #endif /* _MEMORY_DEBUG_ */ @@ -29,12 +29,12 @@ #define byte3_mask2 0x0fc0 #define byte3_mask3 0x003f +#include #ifndef WIN32 #ifdef HAVE_ISWASCII #include #else #include -#include int iswascii(wchar_t c) { return isascii(wctob(c)); @@ -52,7 +52,7 @@ SQLULEN ucs2strlen(const SQLWCHAR *ucs2str) char *ucs2_to_utf8(const SQLWCHAR *ucs2str, SQLLEN ilen, SQLLEN *olen, BOOL lower_identifier) { char * utf8str; -/*mylog("ucs2_to_utf8 %x ilen=%d ", ucs2str, ilen);*/ +/*mylog("ucs2_to_utf8 %p ilen=%d ", ucs2str, ilen);*/ if (!ucs2str) { -- 2.39.5