Skip to content

Commit e171647

Browse files
author
Hiroshi Inoue
committed
Add files for Unicode support.
1 parent 8f0a9e8 commit e171647

File tree

6 files changed

+1392
-0
lines changed

6 files changed

+1392
-0
lines changed

src/interfaces/odbc/connection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ struct ConnectionClass_
266266
Int2 pg_version_major;
267267
Int2 pg_version_minor;
268268
char ms_jet;
269+
char unicode;
269270
#ifdef MULTIBYTE
270271
char *client_encoding;
271272
char *server_encoding;

src/interfaces/odbc/odbcapi25w.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*-------
2+
* Module: odbcapi25w.c
3+
*
4+
* Description: This module contains UNICODE routines
5+
*
6+
* Classes: n/a
7+
*
8+
* API functions: SQLColAttributesW, SQLErrorW, SQLGetConnectOptionW,
9+
SQLSetConnectOptionW
10+
*-------
11+
*/
12+
13+
#include "psqlodbc.h"
14+
#include <stdio.h>
15+
#include <string.h>
16+
17+
#include "pgapifunc.h"
18+
#include "connection.h"
19+
#include "statement.h"
20+
21+
RETCODE SQL_API SQLErrorW(HENV EnvironmentHandle,
22+
HDBC ConnectionHandle, HSTMT StatementHandle,
23+
SQLWCHAR *Sqlstate, SQLINTEGER *NativeError,
24+
SQLWCHAR *MessageText, SQLSMALLINT BufferLength,
25+
SQLSMALLINT *TextLength)
26+
{
27+
RETCODE ret;
28+
SWORD tlen;
29+
char *qst = NULL, *mtxt = NULL;
30+
31+
mylog("[SQLErrorW]");
32+
if (Sqlstate)
33+
qst = malloc(8);
34+
if (MessageText)
35+
mtxt = malloc(BufferLength);
36+
ret = PGAPI_Error(EnvironmentHandle, ConnectionHandle, StatementHandle,
37+
qst, NativeError, mtxt, BufferLength, &tlen);
38+
if (qst)
39+
utf8_to_ucs2(qst, strlen(qst), Sqlstate, 5);
40+
if (TextLength)
41+
*TextLength = utf8_to_ucs2(mtxt, tlen, MessageText, BufferLength);
42+
free(qst);
43+
free(mtxt);
44+
return ret;
45+
}
46+
47+
RETCODE SQL_API SQLGetConnectOptionW(HDBC ConnectionHandle,
48+
SQLUSMALLINT Option, PTR Value)
49+
{
50+
mylog("[SQLGetConnectOptionW]");
51+
((ConnectionClass *) ConnectionHandle)->unicode = 1;
52+
return PGAPI_GetConnectOption(ConnectionHandle, Option, Value);
53+
}
54+
55+
RETCODE SQL_API SQLSetConnectOptionW(HDBC ConnectionHandle,
56+
SQLUSMALLINT Option, SQLUINTEGER Value)
57+
{
58+
mylog("[SQLSetConnectionOptionW]");
59+
((ConnectionClass *) ConnectionHandle)->unicode = 1;
60+
return PGAPI_SetConnectOption(ConnectionHandle, Option, Value);
61+
}
62+
63+
RETCODE SQL_API SQLColAttributesW(
64+
HSTMT hstmt,
65+
SQLUSMALLINT icol,
66+
SQLUSMALLINT fDescType,
67+
PTR rgbDesc,
68+
SQLSMALLINT cbDescMax,
69+
SQLSMALLINT *pcbDesc,
70+
SQLINTEGER *pfDesc)
71+
{
72+
mylog("[SQLColAttributesW]");
73+
return PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc,
74+
cbDescMax, pcbDesc, pfDesc);
75+
}

src/interfaces/odbc/odbcapi30w.c

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*-------
2+
* Module: odbcapi30w.c
3+
*
4+
* Description: This module contains UNICODE routines
5+
*
6+
* Classes: n/a
7+
*
8+
* API functions: SQLColAttributeW, SQLGetStmtW, SQLSetStmtW,
9+
SQLSetConnectAttrW, SQLGetConnectAttrW,
10+
SQLGetDescFieldW, SQLGetDescRecW, SQLGetDiagFieldW,
11+
SQLGetDiagRecW,
12+
*-------
13+
*/
14+
15+
#include "psqlodbc.h"
16+
#include <stdio.h>
17+
#include <string.h>
18+
19+
#include "pgapifunc.h"
20+
#include "connection.h"
21+
#include "statement.h"
22+
23+
24+
RETCODE SQL_API SQLGetStmtAttrW(SQLHSTMT hstmt,
25+
SQLINTEGER fAttribute,
26+
PTR rgbValue,
27+
SQLINTEGER cbValueMax,
28+
SQLINTEGER *pcbValue)
29+
{
30+
RETCODE ret;
31+
32+
mylog("[SQLGetStmtAttrW]");
33+
ret = PGAPI_GetStmtAttr(hstmt, fAttribute, rgbValue,
34+
cbValueMax, pcbValue);
35+
return ret;
36+
}
37+
38+
RETCODE SQL_API SQLSetStmtAttrW(SQLHSTMT hstmt,
39+
SQLINTEGER fAttribute,
40+
PTR rgbValue,
41+
SQLINTEGER cbValueMax)
42+
{
43+
RETCODE ret;
44+
45+
mylog("[SQLSetStmtAttrW]");
46+
ret = PGAPI_SetStmtAttr(hstmt, fAttribute, rgbValue,
47+
cbValueMax);
48+
return ret;
49+
}
50+
51+
RETCODE SQL_API SQLGetConnectAttrW(HDBC hdbc,
52+
SQLINTEGER fAttribute,
53+
PTR rgbValue,
54+
SQLINTEGER cbValueMax,
55+
SQLINTEGER *pcbValue)
56+
{
57+
RETCODE ret;
58+
59+
mylog("[SQLGetConnectAttrW]");
60+
ret = PGAPI_GetConnectAttr(hdbc, fAttribute, rgbValue,
61+
cbValueMax, pcbValue);
62+
return ret;
63+
}
64+
65+
RETCODE SQL_API SQLSetConnectAttrW(HDBC hdbc,
66+
SQLINTEGER fAttribute,
67+
PTR rgbValue,
68+
SQLINTEGER cbValue)
69+
{
70+
RETCODE ret;
71+
72+
mylog("[SQLSetConnectAttrW]");
73+
ret = PGAPI_SetConnectAttr(hdbc, fAttribute, rgbValue,
74+
cbValue);
75+
return ret;
76+
}
77+
78+
RETCODE SQL_API SQLGetDiagRecW(SWORD fHandleType,
79+
SQLHANDLE handle,
80+
SQLSMALLINT iRecord,
81+
SQLWCHAR *szSqlState,
82+
SQLINTEGER *pfNativeError,
83+
SQLWCHAR *szErrorMsg,
84+
SQLSMALLINT cbErrorMsgMax,
85+
SQLSMALLINT *pcbErrorMsg)
86+
{
87+
RETCODE ret;
88+
SWORD tlen;
89+
char *qst = NULL, *mtxt = NULL;
90+
91+
mylog("[SQLGetDiagRecW]");
92+
if (szSqlState)
93+
qst = malloc(8);
94+
if (szErrorMsg)
95+
mtxt = malloc(cbErrorMsgMax);
96+
ret = PGAPI_GetDiagRec(fHandleType, handle, iRecord, qst,
97+
pfNativeError, mtxt, cbErrorMsgMax, &tlen);
98+
if (qst)
99+
utf8_to_ucs2(qst, strlen(qst), szSqlState, 5);
100+
if (pcbErrorMsg)
101+
*pcbErrorMsg = utf8_to_ucs2(mtxt, tlen, szErrorMsg, cbErrorMsgMax);
102+
free(qst);
103+
free(mtxt);
104+
return ret;
105+
}
106+
107+
RETCODE SQL_API SQLColAttributeW(
108+
HSTMT hstmt,
109+
SQLUSMALLINT icol,
110+
SQLUSMALLINT fDescType,
111+
PTR rgbDesc,
112+
SQLSMALLINT cbDescMax,
113+
SQLSMALLINT *pcbDesc,
114+
SQLINTEGER *pfDesc)
115+
{
116+
RETCODE ret;
117+
118+
mylog("[SQLColAttributeW]");
119+
ret = PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc,
120+
cbDescMax, pcbDesc, pfDesc);
121+
return ret;
122+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy