summaryrefslogtreecommitdiff
path: root/src/interfaces/odbc/odbcapi30w.c
diff options
context:
space:
mode:
authorHiroshi Inoue <inoue@tpf.co.jp>2002-03-08 08:52:55 +0000
committerHiroshi Inoue <inoue@tpf.co.jp>2002-03-08 08:52:55 +0000
commit4b47467a6b0d86162dd8814b8ab923aba982fb34 (patch)
tree85fea3bf0475716f35d440468eda620769081bac /src/interfaces/odbc/odbcapi30w.c
parent21f8aa396fa833ac95cff4e85c5281fd24fd1632 (diff)
1) Implement SQLParamOptions().
2) Handle Multiple results and implement SQLMoreResult(). 3) Improve multibyte handling thanks to Eiji Tokuya. 4) Add new options. LF <-> CR/LF converion. TRUE is -1 (for VB). 5) Introduce unicode(UCS-2) support. 6) Reduce the length of connection strings. 7) Improve SQLError, SQLGetDiagRec(ODBC 3.0). 8) Implement SQLTablePrivileges(). 9) Miscellaneous changes for ODBC 3.0 support.
Diffstat (limited to 'src/interfaces/odbc/odbcapi30w.c')
-rw-r--r--src/interfaces/odbc/odbcapi30w.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/src/interfaces/odbc/odbcapi30w.c b/src/interfaces/odbc/odbcapi30w.c
index d2a2005c1b9..35237202faa 100644
--- a/src/interfaces/odbc/odbcapi30w.c
+++ b/src/interfaces/odbc/odbcapi30w.c
@@ -85,22 +85,37 @@ RETCODE SQL_API SQLGetDiagRecW(SWORD fHandleType,
SQLSMALLINT *pcbErrorMsg)
{
RETCODE ret;
- SWORD tlen;
- char *qst = NULL, *mtxt = NULL;
+ SWORD buflen, tlen;
+ char *qstr = NULL, *mtxt = NULL;
mylog("[SQLGetDiagRecW]");
if (szSqlState)
- qst = malloc(8);
- if (szErrorMsg)
- mtxt = malloc(cbErrorMsgMax);
- ret = PGAPI_GetDiagRec(fHandleType, handle, iRecord, qst,
- pfNativeError, mtxt, cbErrorMsgMax, &tlen);
- if (qst)
- utf8_to_ucs2(qst, strlen(qst), szSqlState, 5);
- if (pcbErrorMsg)
- *pcbErrorMsg = utf8_to_ucs2(mtxt, tlen, szErrorMsg, cbErrorMsgMax);
- free(qst);
- free(mtxt);
+ qstr = malloc(8);
+ buflen = 0;
+ if (szErrorMsg && cbErrorMsgMax > 0)
+ {
+ buflen = cbErrorMsgMax;
+ mtxt = malloc(buflen);
+ }
+ ret = PGAPI_GetDiagRec(fHandleType, handle, iRecord, qstr,
+ pfNativeError, mtxt, buflen, &tlen);
+ if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
+ {
+ if (qstr)
+ utf8_to_ucs2(qstr, strlen(qstr), szSqlState, 6);
+ if (mtxt && tlen <= cbErrorMsgMax)
+ {
+ tlen = utf8_to_ucs2(mtxt, tlen, szErrorMsg, cbErrorMsgMax);
+ if (tlen >= cbErrorMsgMax)
+ ret = SQL_SUCCESS_WITH_INFO;
+ }
+ if (pcbErrorMsg)
+ *pcbErrorMsg = tlen;
+ }
+ if (qstr);
+ free(qstr);
+ if (mtxt)
+ free(mtxt);
return ret;
}