Changeset: 816ebf350015 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=816ebf350015 Modified Files: clients/odbc/driver/ODBCConvert.c clients/odbc/driver/ODBCUtil.c clients/odbc/driver/ODBCUtil.h clients/odbc/driver/SQLBindCol.c clients/odbc/driver/SQLBindParameter.c clients/odbc/driver/SQLColAttribute.c clients/odbc/driver/SQLColAttributes.c clients/odbc/driver/SQLDescribeCol.c clients/odbc/driver/SQLDescribeParam.c clients/odbc/driver/SQLExtendedFetch.c clients/odbc/driver/SQLFetch.c clients/odbc/driver/SQLGetConnectAttr.c clients/odbc/driver/SQLGetConnectOption.c clients/odbc/driver/SQLGetCursorName.c clients/odbc/driver/SQLGetData.c clients/odbc/driver/SQLGetDescField.c clients/odbc/driver/SQLGetDescRec.c clients/odbc/driver/SQLGetDiagField.c clients/odbc/driver/SQLGetEnvAttr.c clients/odbc/driver/SQLGetInfo.c clients/odbc/driver/SQLGetStmtAttr.c clients/odbc/driver/SQLGetStmtOption.c clients/odbc/driver/SQLSetConnectAttr.c clients/odbc/driver/SQLSetDescField.c clients/odbc/driver/SQLSetDescRec.c clients/odbc/driver/SQLSetEnvAttr.c clients/odbc/driver/SQLSetParam.c clients/odbc/driver/SQLSetStmtAttr.c clients/odbc/driver/SQLSetStmtOption.c Branch: Oct2014 Log Message:
ODBC: More debug information. diffs (truncated from 1505 to 300 lines): diff --git a/clients/odbc/driver/ODBCConvert.c b/clients/odbc/driver/ODBCConvert.c --- a/clients/odbc/driver/ODBCConvert.c +++ b/clients/odbc/driver/ODBCConvert.c @@ -253,6 +253,7 @@ parsedate(const char *data, DATE_STRUCT { int n; + memset(dval, 0, sizeof(*dval)); while (space(*data)) data++; if (sscanf(data, "{d '%hd-%hu-%hu'}%n", @@ -278,6 +279,7 @@ parsetime(const char *data, TIME_STRUCT int n; int braces; + memset(tval, 0, sizeof(*tval)); while (space(*data)) data++; if (sscanf(data, "{t '%hu:%hu:%hu%n", @@ -323,6 +325,7 @@ parsetimestamp(const char *data, TIMESTA int n; int braces; + memset(tsval, 0, sizeof(*tsval)); while (space(*data)) data++; if (sscanf(data, "{TS '%hd-%hu-%hu %hu:%hu:%hu%n", @@ -542,6 +545,7 @@ parsemonthintervalstring(char **svalp, long val1 = -1, val2 = -1; SQLLEN leadingprecision; + memset(ival, 0, sizeof(*ival)); if (slen < 8 || strncasecmp(sval, "interval", 8) != 0) return SQL_ERROR; sval += 8; @@ -699,6 +703,7 @@ parsesecondintervalstring(char **svalp, unsigned v1, v2, v3, v4; int n; + memset(ival, 0, sizeof(*ival)); if (slen < 8 || strncasecmp(sval, "interval", 8) != 0) return SQL_ERROR; sval += 8; @@ -1010,6 +1015,10 @@ ODBCFetch(ODBCStmt *stmt, TIMESTAMP_STRUCT tsval; double fval = 0; + /* staging variables for output data */ + SQL_NUMERIC_STRUCT nmval; + SQL_INTERVAL_STRUCT ivval; + assert(ptr != NULL); ird = stmt->ImplRowDescr; @@ -1848,11 +1857,21 @@ ODBCFetch(ODBCStmt *stmt, SQLSMALLINT n; ODBCutf82wchar((SQLCHAR *) ptr, SQL_NTS, (SQLWCHAR *) origptr, origbuflen, &n); +#ifdef ODBCDEBUG + ODBCLOG("Writing %d bytes to " PTRFMT "\n", + (int) (n * sizeof(SQLWCHAR)), + PTRFMTCAST origptr); +#endif if (origlenp) *origlenp = n * sizeof(SQLWCHAR); /* # of bytes, not chars */ free(ptr); } +#ifdef ODBCDEBUG + else + ODBCLOG("Writing %d bytes to " PTRFMT "\n", + (int) strlen(ptr), PTRFMTCAST ptr); +#endif break; } case SQL_C_BINARY: @@ -1924,7 +1943,7 @@ ODBCFetch(ODBCStmt *stmt, addStmtError(stmt, "22003", NULL, 0); return SQL_ERROR; } - *(unsigned char *) ptr = fval >= 1; + WriteData(ptr, fval >= 1, unsigned char); if (fval != 0 && fval != 1) { /* Fractional truncation */ @@ -1949,7 +1968,7 @@ ODBCFetch(ODBCStmt *stmt, addStmtError(stmt, "22003", NULL, 0); return SQL_ERROR; } - *(unsigned char *) ptr = (unsigned char) nval.val; + WriteData(ptr, (unsigned char) nval.val, unsigned char); if (truncated) { /* Fractional truncation */ @@ -2047,18 +2066,18 @@ ODBCFetch(ODBCStmt *stmt, switch (type) { case SQL_C_STINYINT: case SQL_C_TINYINT: - *(signed char *) ptr = nval.sign ? (signed char) nval.val : -(signed char) nval.val; + WriteData(ptr, nval.sign ? (signed char) nval.val : -(signed char) nval.val, signed char); break; case SQL_C_SSHORT: case SQL_C_SHORT: - *(short *) ptr = nval.sign ? (short) nval.val : -(short) nval.val; + WriteData(ptr, nval.sign ? (short) nval.val : -(short) nval.val, short); break; case SQL_C_SLONG: case SQL_C_LONG: - *(int *) ptr = nval.sign ? (int) nval.val : -(int) nval.val; + WriteData(ptr, nval.sign ? (int) nval.val : -(int) nval.val, int); break; case SQL_C_SBIGINT: - *(SQLBIGINT *) ptr = nval.sign ? (SQLBIGINT) nval.val : -(SQLBIGINT) nval.val; + WriteData(ptr, nval.sign ? (SQLBIGINT) nval.val : -(SQLBIGINT) nval.val, SQLBIGINT); break; } break; @@ -2147,16 +2166,16 @@ ODBCFetch(ODBCStmt *stmt, switch (type) { case SQL_C_UTINYINT: - *(unsigned char *) ptr = (unsigned char) nval.val; + WriteData(ptr, (unsigned char) nval.val, unsigned char); break; case SQL_C_USHORT: - *(unsigned short *) ptr = (unsigned short) nval.val; + WriteData(ptr, (unsigned short) nval.val, unsigned short); break; case SQL_C_ULONG: - *(unsigned int *) ptr = (unsigned int) nval.val; + WriteData(ptr, (unsigned int) nval.val, unsigned int); break; case SQL_C_UBIGINT: - *(SQLUBIGINT *) ptr = (SQLUBIGINT) nval.val; + WriteData(ptr, (SQLUBIGINT) nval.val, SQLUBIGINT); break; } break; @@ -2212,21 +2231,23 @@ ODBCFetch(ODBCStmt *stmt, nval.scale--; nval.precision--; } - ((SQL_NUMERIC_STRUCT *) ptr)->precision = nval.precision; - ((SQL_NUMERIC_STRUCT *) ptr)->scale = nval.scale; - ((SQL_NUMERIC_STRUCT *) ptr)->sign = nval.sign; + memset(&nmval, 0, sizeof(nmval)); + nmval.precision = nval.precision; + nmval.scale = nval.scale; + nmval.sign = nval.sign; for (i = 0; i < SQL_MAX_NUMERIC_LEN; i++) { - ((SQL_NUMERIC_STRUCT *) ptr)->val[i] = (SQLCHAR) (nval.val & 0xFF); + nmval.val[i] = (SQLCHAR) (nval.val & 0xFF); nval.val >>= 8; } + WriteData(ptr, nmval, SQL_NUMERIC_STRUCT); + if (lenp) + *lenp = sizeof(SQL_NUMERIC_STRUCT); break; default: /* Restricted data type attribute violation */ addStmtError(stmt, "07006", NULL, 0); return SQL_ERROR; } - if (lenp) - *lenp = sizeof(SQL_NUMERIC_STRUCT); break; case SQL_C_FLOAT: case SQL_C_DOUBLE: @@ -2280,13 +2301,13 @@ ODBCFetch(ODBCStmt *stmt, addStmtError(stmt, "22003", NULL, 0); return SQL_ERROR; } - *(float *) ptr = (float) fval; + WriteData(ptr, (float) fval, float); if (lenp) *lenp = sizeof(float); } else { if (ardrec && row > 0) ptr = (SQLPOINTER) ((char *) ptr + row * (bind_type == SQL_BIND_BY_COLUMN ? (SQLINTEGER) sizeof(double) : bind_type)); - *(double *) ptr = fval; + WriteData(ptr, fval, double); if (lenp) *lenp = sizeof(double); @@ -2321,7 +2342,7 @@ ODBCFetch(ODBCStmt *stmt, } /* fall through */ case SQL_TYPE_DATE: - *(DATE_STRUCT *) ptr = dval; + WriteData(ptr, dval, DATE_STRUCT); break; default: /* Restricted data type attribute violation */ @@ -2360,7 +2381,7 @@ ODBCFetch(ODBCStmt *stmt, } /* fall through */ case SQL_TYPE_TIME: - *(TIME_STRUCT *) ptr = tval; + WriteData(ptr, tval, TIME_STRUCT); break; default: /* Restricted data type attribute violation */ @@ -2423,7 +2444,7 @@ ODBCFetch(ODBCStmt *stmt, } /* fall through */ case SQL_TYPE_TIMESTAMP: /* note i==1 unless we fell through */ - *(TIMESTAMP_STRUCT *) ptr = tsval; + WriteData(ptr, tsval, TIMESTAMP_STRUCT); break; default: /* Restricted data type attribute violation */ @@ -2467,14 +2488,14 @@ ODBCFetch(ODBCStmt *stmt, addStmtError(stmt, "07006", NULL, 0); return SQL_ERROR; } -#define p ((SQL_INTERVAL_STRUCT *) ptr) /* abbrev. */ - p->interval_sign = ival.interval_sign; - p->intval.year_month.year = 0; - p->intval.year_month.month = 0; + memset(&ivval, 0, sizeof(ivval)); + ivval.interval_sign = ival.interval_sign; + ivval.intval.year_month.year = 0; + ivval.intval.year_month.month = 0; switch (type) { case SQL_C_INTERVAL_YEAR: - p->interval_type = SQL_IS_YEAR; - if ((p->intval.year_month.year = ival.intval.year_month.year) >= maxdatetimeval) { + ivval.interval_type = SQL_IS_YEAR; + if ((ivval.intval.year_month.year = ival.intval.year_month.year) >= maxdatetimeval) { /* Interval field overflow */ addStmtError(stmt, "22015", NULL, 0); return SQL_ERROR; @@ -2485,24 +2506,24 @@ ODBCFetch(ODBCStmt *stmt, } break; case SQL_C_INTERVAL_MONTH: - p->interval_type = SQL_IS_MONTH; - if ((p->intval.year_month.month = ival.intval.year_month.month + 12 * ival.intval.year_month.year) >= maxdatetimeval) { + ivval.interval_type = SQL_IS_MONTH; + if ((ivval.intval.year_month.month = ival.intval.year_month.month + 12 * ival.intval.year_month.year) >= maxdatetimeval) { /* Interval field overflow */ addStmtError(stmt, "22015", NULL, 0); return SQL_ERROR; } break; case SQL_C_INTERVAL_YEAR_TO_MONTH: - p->interval_type = SQL_IS_YEAR_TO_MONTH; - if ((p->intval.year_month.year = ival.intval.year_month.year) >= maxdatetimeval) { + ivval.interval_type = SQL_IS_YEAR_TO_MONTH; + if ((ivval.intval.year_month.year = ival.intval.year_month.year) >= maxdatetimeval) { /* Interval field overflow */ addStmtError(stmt, "22015", NULL, 0); return SQL_ERROR; } - p->intval.year_month.month = ival.intval.year_month.month; + ivval.intval.year_month.month = ival.intval.year_month.month; break; } -#undef p + WriteData(ptr, ivval, SQL_INTERVAL_STRUCT); if (lenp) *lenp = sizeof(SQL_INTERVAL_STRUCT); break; @@ -2554,17 +2575,17 @@ ODBCFetch(ODBCStmt *stmt, addStmtError(stmt, "07006", NULL, 0); return SQL_ERROR; } -#define p ((SQL_INTERVAL_STRUCT *) ptr) /* abbrev. */ - p->interval_sign = ival.interval_sign; - p->intval.day_second.day = 0; - p->intval.day_second.hour = 0; - p->intval.day_second.minute = 0; - p->intval.day_second.second = 0; - p->intval.day_second.fraction = 0; + memset(&ivval, 0, sizeof(ivval)); + ivval.interval_sign = ival.interval_sign; + ivval.intval.day_second.day = 0; + ivval.intval.day_second.hour = 0; + ivval.intval.day_second.minute = 0; + ivval.intval.day_second.second = 0; + ivval.intval.day_second.fraction = 0; switch (type) { case SQL_C_INTERVAL_DAY: - p->interval_type = SQL_IS_DAY; - if ((p->intval.day_second.day = ival.intval.day_second.day) >= maxdatetimeval) { + ivval.interval_type = SQL_IS_DAY; + if ((ivval.intval.day_second.day = ival.intval.day_second.day) >= maxdatetimeval) { /* Interval field overflow */ addStmtError(stmt, "22015", NULL, 0); return SQL_ERROR; @@ -2575,8 +2596,8 @@ ODBCFetch(ODBCStmt *stmt, } break; case SQL_C_INTERVAL_HOUR: - p->interval_type = SQL_IS_HOUR; - if ((p->intval.day_second.hour = ival.intval.day_second.hour + 24 * ival.intval.day_second.day) >= maxdatetimeval) { + ivval.interval_type = SQL_IS_HOUR; + if ((ivval.intval.day_second.hour = ival.intval.day_second.hour + 24 * ival.intval.day_second.day) >= maxdatetimeval) { /* Interval field overflow */ addStmtError(stmt, "22015", NULL, 0); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list