Index: src/interfaces/odbc/bind.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/odbc/bind.c,v retrieving revision 1.37 diff -c -r1.37 bind.c *** src/interfaces/odbc/bind.c 11 Mar 2002 10:25:55 -0000 1.37 --- src/interfaces/odbc/bind.c 25 Mar 2002 01:39:29 -0000 *************** *** 340,346 **** mylog("%s: entering... %d %x\n", func, crow, pirow); stmt->options.paramset_size = crow; ! stmt->options.param_processed_ptr = pirow; return SQL_SUCCESS; } --- 340,346 ---- mylog("%s: entering... %d %x\n", func, crow, pirow); stmt->options.paramset_size = crow; ! stmt->options.param_processed_ptr = (SQLUINTEGER *)pirow; return SQL_SUCCESS; } Index: src/interfaces/odbc/connection.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/odbc/connection.c,v retrieving revision 1.57 diff -c -r1.57 connection.c *** src/interfaces/odbc/connection.c 14 Mar 2002 05:41:59 -0000 1.57 --- src/interfaces/odbc/connection.c 25 Mar 2002 01:39:30 -0000 *************** *** 1130,1137 **** QResultClass * CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag) { ! QResultClass *result_in = NULL, ! *cmdres = NULL, *retres = NULL, *res = NULL; BOOL clear_result_on_abort = ((flag & CLEAR_RESULT_ON_ABORT) != 0), --- 1130,1136 ---- QResultClass * CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag) { ! QResultClass *cmdres = NULL, *retres = NULL, *res = NULL; BOOL clear_result_on_abort = ((flag & CLEAR_RESULT_ON_ABORT) != 0), Index: src/interfaces/odbc/convert.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/odbc/convert.c,v retrieving revision 1.75 diff -c -r1.75 convert.c *** src/interfaces/odbc/convert.c 14 Mar 2002 05:42:00 -0000 1.75 --- src/interfaces/odbc/convert.c 25 Mar 2002 01:39:32 -0000 *************** *** 107,113 **** {"DAYNAME", "to_char($1, 'Day')" }, {"DAYOFMONTH", "cast(extract(day from $1) as integer)" }, {"DAYOFWEEK", "(cast(extract(dow from $1) as integer) + 1)" }, ! {"DAYOFYEAR", "cast(extract(doy from $1) as integer)" }, {"HOUR", "cast(extract(hour from $1) as integer)" }, {"MINUTE", "cast(extract(minute from $1) as integer)" }, {"MONTH", "cast(extract(month from $1) as integer)" }, --- 107,113 ---- {"DAYNAME", "to_char($1, 'Day')" }, {"DAYOFMONTH", "cast(extract(day from $1) as integer)" }, {"DAYOFWEEK", "(cast(extract(dow from $1) as integer) + 1)" }, ! {"DAYOFYEAR", "cast(extract(doy from $1) as integer)" }, {"HOUR", "cast(extract(hour from $1) as integer)" }, {"MINUTE", "cast(extract(minute from $1) as integer)" }, {"MONTH", "cast(extract(month from $1) as integer)" }, *************** *** 161,167 **** --- 161,169 ---- *ptr; int scnt, i; + #if defined(WIN32) || defined(HAVE_INT_TIMEZONE) long timediff; + #endif BOOL withZone = *bZone; *bZone = FALSE; *************** *** 402,408 **** else { stmt->errornumber = STMT_RETURN_NULL_WITHOUT_INDICATOR; ! stmt->errormsg = "StrLen_or_IndPtr was a null pointer and NULL data was retrieved"; SC_log_error(func, "", stmt); return SQL_ERROR; } --- 404,410 ---- else { stmt->errornumber = STMT_RETURN_NULL_WITHOUT_INDICATOR; ! stmt->errormsg = "StrLen_or_IndPtr was a null pointer and NULL data was retrieved"; SC_log_error(func, "", stmt); return SQL_ERROR; } *************** *** 757,763 **** if (cbValueMax < 2 * (SDWORD) ucount) result = COPY_RESULT_TRUNCATED; len = ucount * 2; ! free(str); } else { --- 759,765 ---- if (cbValueMax < 2 * (SDWORD) ucount) result = COPY_RESULT_TRUNCATED; len = ucount * 2; ! free(str); } else { *************** *** 1431,1437 **** */ else if (oldchar == '{') { ! char *begin = &old_statement[opos], *end; /* procedure calls */ if (stmt->statement_type == STMT_TYPE_PROCCALL) --- 1433,1440 ---- */ else if (oldchar == '{') { ! char *begin = &old_statement[opos]; ! const char *end; /* procedure calls */ if (stmt->statement_type == STMT_TYPE_PROCCALL) *************** *** 1463,1470 **** proc_no_param = FALSE; continue; } ! if (convert_escape(begin, stmt, &npos, &new_stsize, &end ! ) != CONVERT_ESCAPE_OK) { stmt->errormsg = "ODBC escape convert error"; stmt->errornumber = STMT_EXEC_ERROR; --- 1466,1473 ---- proc_no_param = FALSE; continue; } ! if (convert_escape(begin, stmt, &npos, &new_stsize, &end) != ! CONVERT_ESCAPE_OK) { stmt->errormsg = "ODBC escape convert error"; stmt->errornumber = STMT_EXEC_ERROR; *************** *** 1604,1610 **** buffer += (bind_size * current_row); else if (ctypelen = ctype_length(stmt->parameters[param_number].CType), ctypelen > 0) buffer += current_row * ctypelen; ! else buffer += current_row * stmt->parameters[param_number].buflen; } if (stmt->parameters[param_number].used) --- 1607,1613 ---- buffer += (bind_size * current_row); else if (ctypelen = ctype_length(stmt->parameters[param_number].CType), ctypelen > 0) buffer += current_row * ctypelen; ! else buffer += current_row * stmt->parameters[param_number].buflen; } if (stmt->parameters[param_number].used) *************** *** 2080,2086 **** if (mapFuncs[i][0][0] == '%') { if (mapFuncs[i][0][1] - '0' == param_count && ! !stricmp(mapFuncs[i][0] + 2, func)) return mapFuncs[i][1]; } else if (!stricmp(mapFuncs[i][0], func)) --- 2083,2089 ---- if (mapFuncs[i][0][0] == '%') { if (mapFuncs[i][0][1] - '0' == param_count && ! !stricmp(mapFuncs[i][0] + 2, func)) return mapFuncs[i][1]; } else if (!stricmp(mapFuncs[i][0], func)) *************** *** 2098,2104 **** * inner_convert_escape() * work with embedded escapes sequences */ ! static int inner_convert_escape(const ConnectionClass *conn, const char *value, char *result, UInt4 maxLen, const char **input_resume, --- 2101,2107 ---- * inner_convert_escape() * work with embedded escapes sequences */ ! static int inner_convert_escape(const ConnectionClass *conn, const char *value, char *result, UInt4 maxLen, const char **input_resume, *************** *** 2111,2117 **** const char *valptr; UInt4 vlen, prtlen, input_consumed, param_consumed, extra_len; Int4 param_pos[16][2]; ! valptr = value; if (*valptr == '{') /* skip the first { */ valptr++; --- 2114,2120 ---- const char *valptr; UInt4 vlen, prtlen, input_consumed, param_consumed, extra_len; Int4 param_pos[16][2]; ! valptr = value; if (*valptr == '{') /* skip the first { */ valptr++; *************** *** 2123,2129 **** valptr++; while ((*valptr != '\0') && isspace((unsigned char) *valptr)) valptr++; ! if (end = my_strchr(conn, valptr, '}'), NULL == end) { mylog("%s couldn't find the ending }\n",func); --- 2126,2132 ---- valptr++; while ((*valptr != '\0') && isspace((unsigned char) *valptr)) valptr++; ! if (end = my_strchr(conn, valptr, '}'), NULL == end) { mylog("%s couldn't find the ending }\n",func); *************** *** 2135,2141 **** valnts[vlen] = '\0'; *input_resume = valptr + vlen; /* resume from the last } */ mylog("%s: key='%s', val='%s'\n", func, key, valnts); ! extra_len = 0; if (isalnum(result[-1])) /* Avoid the concatenation of the function name with the previous word. Aceto */ { --- 2138,2144 ---- valnts[vlen] = '\0'; *input_resume = valptr + vlen; /* resume from the last } */ mylog("%s: key='%s', val='%s'\n", func, key, valnts); ! extra_len = 0; if (isalnum(result[-1])) /* Avoid the concatenation of the function name with the previous word. Aceto */ { *************** *** 2172,2178 **** { /* Literal; return the escape part as-is */ strncpy(result, valnts, maxLen); ! prtlen = vlen; } else if (strcmp(key, "fn") == 0) { --- 2175,2181 ---- { /* Literal; return the escape part as-is */ strncpy(result, valnts, maxLen); ! prtlen = vlen; } else if (strcmp(key, "fn") == 0) { *************** *** 2183,2189 **** char *funcEnd = valnts; char svchar; const char *mapExpr; ! params[sizeof(params)-1] = '\0'; while ((*funcEnd != '\0') && (*funcEnd != '(') && --- 2186,2192 ---- char *funcEnd = valnts; char svchar; const char *mapExpr; ! params[sizeof(params)-1] = '\0'; while ((*funcEnd != '\0') && (*funcEnd != '(') && *************** *** 2197,2203 **** funcEnd++; /* ! * We expect left parenthesis here, else return fn body as-is * since it is one of those "function constants". */ if (*funcEnd != '(') --- 2200,2206 ---- funcEnd++; /* ! * We expect left parenthesis here, else return fn body as-is * since it is one of those "function constants". */ if (*funcEnd != '(') *************** *** 2213,2219 **** */ valptr += (UInt4)(funcEnd - valnts); ! if (subret = processParameters(conn, valptr, params, sizeof(params) - 1, &input_consumed, ¶m_consumed, param_pos), CONVERT_ESCAPE_OK != subret) return CONVERT_ESCAPE_ERROR; for (param_count = 0;; param_count++) --- 2216,2222 ---- */ valptr += (UInt4)(funcEnd - valnts); ! if (subret = processParameters(conn, valptr, params, sizeof(params) - 1, &input_consumed, ¶m_consumed, param_pos), CONVERT_ESCAPE_OK != subret) return CONVERT_ESCAPE_ERROR; for (param_count = 0;; param_count++) *************** *** 2222,2230 **** break; } if (param_count == 1 && ! param_pos[0][1] < param_pos[0][0]) param_count = 0; ! mapExpr = mapFunction(key, param_count); if (mapExpr == NULL) prtlen = snprintf(result, maxLen, "%s%s", key, params); --- 2225,2233 ---- break; } if (param_count == 1 && ! param_pos[0][1] < param_pos[0][0]) param_count = 0; ! mapExpr = mapFunction(key, param_count); if (mapExpr == NULL) prtlen = snprintf(result, maxLen, "%s%s", key, params); *************** *** 2256,2262 **** { pidx = *mapptr - '0' - 1; if (pidx < 0 || ! param_pos[pidx][0] <0) { qlog("%s %dth param not found for the expression %s\n", pidx + 1, mapExpr); return CONVERT_ESCAPE_ERROR; --- 2259,2265 ---- { pidx = *mapptr - '0' - 1; if (pidx < 0 || ! param_pos[pidx][0] <0) { qlog("%s %dth param not found for the expression %s\n", pidx + 1, mapExpr); return CONVERT_ESCAPE_ERROR; *************** *** 2291,2297 **** /* Bogus key, leave untranslated */ return CONVERT_ESCAPE_ERROR; } ! if (count) *count = prtlen + extra_len; if (prtlen < 0 || prtlen >= maxLen) /* buffer overflow */ --- 2294,2300 ---- /* Bogus key, leave untranslated */ return CONVERT_ESCAPE_ERROR; } ! if (count) *count = prtlen + extra_len; if (prtlen < 0 || prtlen >= maxLen) /* buffer overflow */ *************** *** 2301,2312 **** } return CONVERT_ESCAPE_OK; } ! /* * processParameters() * Process function parameters and work with embedded escapes sequences. */ ! static int processParameters(const ConnectionClass *conn, const char *value, char *result, UInt4 maxLen, UInt4 *input_consumed, --- 2304,2315 ---- } return CONVERT_ESCAPE_OK; } ! /* * processParameters() * Process function parameters and work with embedded escapes sequences. */ ! static int processParameters(const ConnectionClass *conn, const char *value, char *result, UInt4 maxLen, UInt4 *input_consumed, *************** *** 2321,2327 **** #ifdef MULTIBYTE encoded_str encstr; #endif /* MULTIBYTE */ ! buf[sizeof(buf)-1] = '\0'; innerParenthesis = 0; in_quote = in_dquote = in_escape = leadingSpace = FALSE; --- 2324,2330 ---- #ifdef MULTIBYTE encoded_str encstr; #endif /* MULTIBYTE */ ! buf[sizeof(buf)-1] = '\0'; innerParenthesis = 0; in_quote = in_dquote = in_escape = leadingSpace = FALSE; *************** *** 2400,2406 **** } innerParenthesis++; break; ! case ')': innerParenthesis--; if (0 == innerParenthesis) --- 2403,2409 ---- } innerParenthesis++; break; ! case ')': innerParenthesis--; if (0 == innerParenthesis) *************** *** 2411,2428 **** param_pos[param_count][1] = -1; } break; ! case '}': stop = TRUE; break; ! case '{': if (subret = inner_convert_escape(conn, valptr, buf, sizeof(buf) - 1, &valptr, &inner_count), CONVERT_ESCAPE_OK != subret) return CONVERT_ESCAPE_ERROR; ! if (inner_count + count >= maxLen) return CONVERT_ESCAPE_OVERFLOW; ! memcpy(&result[count], buf, inner_count); count += inner_count; ipos = (UInt4) (valptr - value); continue; --- 2414,2431 ---- param_pos[param_count][1] = -1; } break; ! case '}': stop = TRUE; break; ! case '{': if (subret = inner_convert_escape(conn, valptr, buf, sizeof(buf) - 1, &valptr, &inner_count), CONVERT_ESCAPE_OK != subret) return CONVERT_ESCAPE_ERROR; ! if (inner_count + count >= maxLen) return CONVERT_ESCAPE_OVERFLOW; ! memcpy(&result[count], buf, inner_count); count += inner_count; ipos = (UInt4) (valptr - value); continue; *************** *** 2442,2455 **** *output_count = count; return CONVERT_ESCAPE_OK; } ! /* * convert_escape() * This function returns a pointer to static memory! */ ! int ! convert_escape(const char *value, StatementClass *stmt, int *npos, int *stsize, const char **val_resume) { int ret, pos = *npos; UInt4 count; --- 2445,2459 ---- *output_count = count; return CONVERT_ESCAPE_OK; } ! /* * convert_escape() * This function returns a pointer to static memory! */ ! int ! convert_escape(const char *value, StatementClass *stmt, int *npos, int *stsize, ! const char **val_resume) { int ret, pos = *npos; UInt4 count; Index: src/interfaces/odbc/dlg_specific.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/odbc/dlg_specific.c,v retrieving revision 1.45 diff -c -r1.45 dlg_specific.c *** src/interfaces/odbc/dlg_specific.c 11 Mar 2002 10:25:56 -0000 1.45 --- src/interfaces/odbc/dlg_specific.c 25 Mar 2002 01:39:32 -0000 *************** *** 641,647 **** flag |= BIT_TRUEISMINUS1; sprintf(&connect_string[hlen], ! ";A6=%s;A7=%d;A8=%d;B0=%d;B1=%d;C2=%s;CX=%02x%x", encoded_conn_settings, ci->drivers.fetch_max, ci->drivers.socket_buffersize, --- 641,647 ---- flag |= BIT_TRUEISMINUS1; sprintf(&connect_string[hlen], ! ";A6=%s;A7=%d;A8=%d;B0=%d;B1=%d;C2=%s;CX=%02x%lx", encoded_conn_settings, ci->drivers.fetch_max, ci->drivers.socket_buffersize, *************** *** 662,668 **** if (strlen(value) < 2) { count = 3; ! sscanf(value, "%x", &flag); } else { --- 662,668 ---- if (strlen(value) < 2) { count = 3; ! sscanf(value, "%lx", &flag); } else { *************** *** 670,676 **** memcpy(cnt, value, 2); cnt[2] = '\0'; sscanf(cnt, "%x", &count); ! sscanf(value + 2, "%x", &flag); } ci->disallow_premature = (char)((flag & BIT_DISALLOWPREMATURE) != 0); ci->updatable_cursors = (char)((flag & BIT_UPDATABLECURSORS) != 0); --- 670,676 ---- memcpy(cnt, value, 2); cnt[2] = '\0'; sscanf(cnt, "%x", &count); ! sscanf(value + 2, "%lx", &flag); } ci->disallow_premature = (char)((flag & BIT_DISALLOWPREMATURE) != 0); ci->updatable_cursors = (char)((flag & BIT_UPDATABLECURSORS) != 0); Index: src/interfaces/odbc/environ.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/odbc/environ.c,v retrieving revision 1.38 diff -c -r1.38 environ.c *** src/interfaces/odbc/environ.c 14 Mar 2002 05:42:01 -0000 1.38 --- src/interfaces/odbc/environ.c 25 Mar 2002 01:39:33 -0000 *************** *** 94,102 **** StatementClass *stmt = (StatementClass *) hstmt; char *msg; int status; ! BOOL once_again = FALSE, ! partial_ok = (flag & PODBC_ALLOW_PARTIAL_EXTRACT != 0), ! clear_str = (flag & PODBC_ERROR_CLEAR != 0); SWORD msglen, stapos, wrtlen, pcblen; mylog("**** PGAPI_StmtError: hstmt=%u <%d>\n", hstmt, cbErrorMsgMax); --- 94,101 ---- StatementClass *stmt = (StatementClass *) hstmt; char *msg; int status; ! BOOL partial_ok = ((flag & PODBC_ALLOW_PARTIAL_EXTRACT) != 0), ! clear_str = ((flag & PODBC_ERROR_CLEAR) != 0); SWORD msglen, stapos, wrtlen, pcblen; mylog("**** PGAPI_StmtError: hstmt=%u <%d>\n", hstmt, cbErrorMsgMax); Index: src/interfaces/odbc/info.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/odbc/info.c,v retrieving revision 1.73 diff -c -r1.73 info.c *** src/interfaces/odbc/info.c 14 Mar 2002 05:42:01 -0000 1.73 --- src/interfaces/odbc/info.c 25 Mar 2002 01:39:37 -0000 *************** *** 3983,3989 **** char *grolist, *uid, *delm; snprintf(proc_query, sizeof(proc_query) - 1, "select grolist from pg_group where groname = '%s'", user); ! if (gres = CC_send_query(conn, proc_query, NULL, CLEAR_RESULT_ON_ABORT)) { grolist = QR_get_value_backend_row(gres, 0, 0); if (grolist && grolist[0] == '{') --- 3983,3989 ---- char *grolist, *uid, *delm; snprintf(proc_query, sizeof(proc_query) - 1, "select grolist from pg_group where groname = '%s'", user); ! if ((gres = CC_send_query(conn, proc_query, NULL, CLEAR_RESULT_ON_ABORT))) { grolist = QR_get_value_backend_row(gres, 0, 0); if (grolist && grolist[0] == '{') Index: src/interfaces/odbc/multibyte.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/odbc/multibyte.c,v retrieving revision 1.17 diff -c -r1.17 multibyte.c *** src/interfaces/odbc/multibyte.c 14 Mar 2002 05:42:03 -0000 1.17 --- src/interfaces/odbc/multibyte.c 25 Mar 2002 01:39:37 -0000 *************** *** 228,235 **** character > 0xa0) stat = 3; else if (stat == 3 || ! stat < 2 && ! character > 0xa0) stat = 2; else if (stat == 2) stat = 1; --- 228,235 ---- character > 0xa0) stat = 3; else if (stat == 3 || ! (stat < 2 && ! character > 0xa0)) stat = 2; else if (stat == 2) stat = 1; Index: src/interfaces/odbc/multibyte.h =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/odbc/multibyte.h,v retrieving revision 1.8 diff -c -r1.8 multibyte.h *** src/interfaces/odbc/multibyte.h 8 Mar 2002 08:52:51 -0000 1.8 --- src/interfaces/odbc/multibyte.h 25 Mar 2002 01:39:37 -0000 *************** *** 86,89 **** --- 86,92 ---- #define make_encoded_str(encstr, conn, str) encoded_str_constr(encstr, conn->ccsc, str) extern int encoded_nextchar(encoded_str *encstr); extern int encoded_byte_check(encoded_str *encstr, int abspos); + + /* This doesn't seem to be called by anyone, bjm 2002-03-24 */ + extern int pg_ismb(int characterset_code); #define check_client_encoding(X) pg_CS_name(pg_CS_code(X)) Index: src/interfaces/odbc/pgtypes.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/odbc/pgtypes.c,v retrieving revision 1.43 diff -c -r1.43 pgtypes.c *** src/interfaces/odbc/pgtypes.c 8 Mar 2002 09:50:39 -0000 1.43 --- src/interfaces/odbc/pgtypes.c 25 Mar 2002 01:39:38 -0000 *************** *** 234,240 **** --- 234,242 ---- { ConnectionClass *conn = SC_get_conn(stmt); ConnInfo *ci = &(conn->connInfo); + #if (ODBCVER >= 0x0300) EnvironmentClass *env = (EnvironmentClass *) (conn->henv); + #endif switch (type) { *************** *** 342,348 **** --- 344,352 ---- { ConnectionClass *conn = SC_get_conn(stmt); ConnInfo *ci = &(conn->connInfo); + #if (ODBCVER >= 0x0300) EnvironmentClass *env = (EnvironmentClass *) (conn->henv); + #endif switch (type) { Index: src/interfaces/odbc/qresult.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/odbc/qresult.c,v retrieving revision 1.35 diff -c -r1.35 qresult.c *** src/interfaces/odbc/qresult.c 14 Mar 2002 05:42:03 -0000 1.35 --- src/interfaces/odbc/qresult.c 25 Mar 2002 01:39:38 -0000 *************** *** 731,740 **** if (this_keyset) { if (this_tuplefield[num_fields - 2].value) ! sscanf(this_tuplefield[num_fields - 2].value, "(%u,%hu)", &this_keyset->blocknum, &this_keyset->offset); if (this_tuplefield[num_fields - 1].value) ! sscanf(this_tuplefield[num_fields - 1].value, "%u", &this_keyset->oid); } self->currTuple++; --- 731,740 ---- if (this_keyset) { if (this_tuplefield[num_fields - 2].value) ! sscanf(this_tuplefield[num_fields - 2].value, "(%lu,%hu)", &this_keyset->blocknum, &this_keyset->offset); if (this_tuplefield[num_fields - 1].value) ! sscanf(this_tuplefield[num_fields - 1].value, "%lu", &this_keyset->oid); } self->currTuple++;