aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi Inoue <inoue@tpf.co.jp>2001-09-13 00:27:11 +0000
committerHiroshi Inoue <inoue@tpf.co.jp>2001-09-13 00:27:11 +0000
commit9f990a73c13a17faf87417eee9e17faabfa00179 (patch)
treeafb8432ca5ef439a28f137224f185358c4e2bded
parentf93449eb34eb40d8063174e9dcb40c7736d90fd1 (diff)
downloadpostgresql-9f990a73c13a17faf87417eee9e17faabfa00179.tar.gz
postgresql-9f990a73c13a17faf87417eee9e17faabfa00179.zip
1) Not export ODBC 3.0 functions.
2) (Maybe) fix a bug reported by Mika Muntila.
-rw-r--r--src/interfaces/odbc/convert.c13
-rw-r--r--src/interfaces/odbc/drvconn.c3
-rw-r--r--src/interfaces/odbc/environ.c21
-rw-r--r--src/interfaces/odbc/info.c20
-rw-r--r--src/interfaces/odbc/pgtypes.c8
-rw-r--r--src/interfaces/odbc/psqlodbc_win32.def22
6 files changed, 58 insertions, 29 deletions
diff --git a/src/interfaces/odbc/convert.c b/src/interfaces/odbc/convert.c
index 8052709fdac..84f99b40e3e 100644
--- a/src/interfaces/odbc/convert.c
+++ b/src/interfaces/odbc/convert.c
@@ -1674,12 +1674,19 @@ copy_statement_with_parameters(StatementClass *stmt)
if (buf)
{
- CVT_APPEND_DATA(buf, used);
+ switch (used)
+ {
+ case SQL_NULL_DATA:
+ break;
+ case SQL_NTS:
+ CVT_APPEND_STR(buf);
+ break;
+ default:
+ CVT_APPEND_DATA(buf, used);
+ }
}
else
- {
CVT_APPEND_STR(param_string);
- }
if (param_sqltype == SQL_BIT)
CVT_APPEND_CHAR('\''); /* Close Quote */
diff --git a/src/interfaces/odbc/drvconn.c b/src/interfaces/odbc/drvconn.c
index e1eee25de55..80f1d69b7d6 100644
--- a/src/interfaces/odbc/drvconn.c
+++ b/src/interfaces/odbc/drvconn.c
@@ -230,6 +230,9 @@ dialog:
if (len >= cbConnStrOutMax)
{
+ int clen;
+ for (clen = strlen(szConnStrOut) - 1; clen >= 0 && szConnStrOut[clen] != ';'; clen--)
+ szConnStrOut[clen] = '\0';
result = SQL_SUCCESS_WITH_INFO;
conn->errornumber = CONN_TRUNCATED;
conn->errormsg = "The buffer was too small for the ConnStrOut.";
diff --git a/src/interfaces/odbc/environ.c b/src/interfaces/odbc/environ.c
index 8e9156d2d0c..0471e1f4284 100644
--- a/src/interfaces/odbc/environ.c
+++ b/src/interfaces/odbc/environ.c
@@ -92,6 +92,8 @@ PGAPI_Error(
{
char *msg;
int status;
+ BOOL once_again = FALSE;
+ SWORD msglen;
mylog("**** PGAPI_Error: henv=%u, hdbc=%u, hstmt=%u <%d>\n", henv, hdbc, hstmt, cbErrorMsgMax);
@@ -101,8 +103,6 @@ PGAPI_Error(
{
/* CC: return an error of a hstmt */
StatementClass *stmt = (StatementClass *) hstmt;
- SWORD msglen;
- BOOL once_again = FALSE;
if (SC_get_error(stmt, &status, &msg))
{
@@ -306,8 +306,15 @@ PGAPI_Error(
return SQL_NO_DATA_FOUND;
}
+ msglen = strlen(msg);
if (NULL != pcbErrorMsg)
- *pcbErrorMsg = (SWORD) strlen(msg);
+ {
+ *pcbErrorMsg = msglen;
+ if (cbErrorMsgMax == 0)
+ once_again = TRUE;
+ else if (msglen >= cbErrorMsgMax)
+ *pcbErrorMsg = cbErrorMsgMax - 1;
+ }
if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0))
strncpy_null(szErrorMsg, msg, cbErrorMsgMax);
if (NULL != pfNativeError)
@@ -391,7 +398,13 @@ PGAPI_Error(
return SQL_NO_DATA_FOUND;
}
- return SQL_SUCCESS;
+ if (once_again)
+ {
+ conn->errornumber = status;
+ return SQL_SUCCESS_WITH_INFO;
+ }
+ else
+ return SQL_SUCCESS;
}
else if (SQL_NULL_HENV != henv)
{
diff --git a/src/interfaces/odbc/info.c b/src/interfaces/odbc/info.c
index 1f458ba043e..54d97304bc3 100644
--- a/src/interfaces/odbc/info.c
+++ b/src/interfaces/odbc/info.c
@@ -3614,9 +3614,29 @@ PGAPI_Procedures(
SWORD cbProcName)
{
static char *func = "PGAPI_Procedures";
+ StatementClass *stmt = (StatementClass *) hstmt;
+ Int2 result_cols;
mylog("%s: entering...\n", func);
+ /*
+ * a statement is actually executed, so we'll have to do this
+ * ourselves.
+ */
+ result_cols = 8;
+ extend_bindings(stmt, result_cols);
+
+ /* set the field names */
+ QR_set_num_fields(stmt->result, result_cols);
+ QR_set_field_info(stmt->result, 0, "PROCEDURE_CAT", PG_TYPE_TEXT, MAX_INFO_STRING);
+ QR_set_field_info(stmt->result, 1, "PROCEDURE_SCHEM", PG_TYPE_TEXT, MAX_INFO_STRING);
+ QR_set_field_info(stmt->result, 2, "PROCEDURE_NAME", PG_TYPE_TEXT, MAX_INFO_STRING);
+ QR_set_field_info(stmt->result, 3, "NUM_INPUT_PARAMS", PG_TYPE_TEXT, MAX_INFO_STRING);
+ QR_set_field_info(stmt->result, 4, "NUM_OUTPUT_PARAMS", PG_TYPE_TEXT, MAX_INFO_STRING);
+ QR_set_field_info(stmt->result, 5, "NUM_RESULT_SET", PG_TYPE_TEXT, MAX_INFO_STRING);
+ QR_set_field_info(stmt->result, 6, "REMARKS", PG_TYPE_TEXT, MAX_INFO_STRING);
+ QR_set_field_info(stmt->result, 7, "PROCEDURE_TYPE", PG_TYPE_INT2, 2);
+
SC_log_error(func, "Function not implemented", (StatementClass *) hstmt);
return SQL_ERROR;
}
diff --git a/src/interfaces/odbc/pgtypes.c b/src/interfaces/odbc/pgtypes.c
index f2b18535901..97a6ff82016 100644
--- a/src/interfaces/odbc/pgtypes.c
+++ b/src/interfaces/odbc/pgtypes.c
@@ -698,7 +698,15 @@ pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_
/* Character types (and NUMERIC) use the default precision */
case PG_TYPE_VARCHAR:
case PG_TYPE_BPCHAR:
+#ifdef MULTIBYTE
+ /* after 7.2 */
+ if (PG_VERSION_GE(SC_get_conn(stmt), 7.2)
+ return 3 * pgtype_precision(stmt, type, col, handle_unknown_size_as);
+ else
+#else
+ /* CR -> CR/LF */
return 2 * pgtype_precision(stmt, type, col, handle_unknown_size_as);
+#endif /* MULTIBYTE */
default:
return pgtype_precision(stmt, type, col, handle_unknown_size_as);
}
diff --git a/src/interfaces/odbc/psqlodbc_win32.def b/src/interfaces/odbc/psqlodbc_win32.def
index 25cd5547451..23a5a82b39c 100644
--- a/src/interfaces/odbc/psqlodbc_win32.def
+++ b/src/interfaces/odbc/psqlodbc_win32.def
@@ -53,28 +53,6 @@ SQLSetPos @68
SQLSetScrollOptions @69
SQLTablePrivileges @70
SQLBindParameter @72
-
-SQLAllocHandle @80
-SQLBindParam @81
-SQLCloseCursor @82
-SQLColAttribute @83
-SQLCopyDesc @84
-SQLEndTran @85
-SQLFetchScroll @86
-SQLFreeHandle @87
-SQLGetDescField @88
-SQLGetDescRec @89
-SQLGetDiagField @90
-SQLGetDiagRec @91
-SQLGetEnvAttr @92
-SQLGetConnectAttr @93
-SQLGetStmtAttr @94
-SQLSetConnectAttr @95
-SQLSetDescField @96
-SQLSetDescRec @97
-SQLSetEnvAttr @98
-SQLSetStmtAttr @99
-
SQLDummyOrdinal @199
dconn_FDriverConnectProc @200
DllMain @201