e95ca078b6d4a6722bede899e335db512be6cbdf
[reactos.git] / reactos / dll / win32 / odbc32 / proxyodbc.c
1 /*
2 * Win32 ODBC functions
3 *
4 * Copyright 1999 Xiang Li, Corel Corporation
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 *
20 * NOTES:
21 * Proxy ODBC driver manager. This manager delegates all ODBC
22 * calls to a real ODBC driver manager named by the environment
23 * variable LIB_ODBC_DRIVER_MANAGER, or to libodbc.so if the
24 * variable is not set.
25 *
26 */
27
28 #define WIN32_NO_STATUS
29
30 #include <config.h>
31 #include <wine/port.h>
32
33 //#include <stdarg.h>
34 //#include <stdio.h>
35 //#include <stdlib.h>
36 //#include <string.h>
37 #include <assert.h>
38
39 #include <windef.h>
40 //#include "winbase.h"
41 #include <winreg.h>
42
43 //#include "sql.h"
44 //#include "sqltypes.h"
45 #include <sqlext.h>
46
47 #undef TRACE_ON
48
49 #include <wine/debug.h>
50 #include <wine/library.h>
51 #include <wine/unicode.h>
52
53 static BOOL ODBC_LoadDriverManager(void);
54 static BOOL ODBC_LoadDMFunctions(void);
55
56 WINE_DEFAULT_DEBUG_CHANNEL(odbc);
57
58 static SQLRETURN (*pSQLAllocConnect)(SQLHENV,SQLHDBC*);
59 static SQLRETURN (*pSQLAllocEnv)(SQLHENV*);
60 static SQLRETURN (*pSQLAllocHandle)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
61 static SQLRETURN (*pSQLAllocHandleStd)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
62 static SQLRETURN (*pSQLAllocStmt)(SQLHDBC,SQLHSTMT*);
63 static SQLRETURN (*pSQLBindCol)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
64 static SQLRETURN (*pSQLBindParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*);
65 static SQLRETURN (*pSQLBindParameter)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
66 static SQLRETURN (*pSQLBrowseConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
67 static SQLRETURN (*pSQLBrowseConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
68 static SQLRETURN (*pSQLBulkOperations)(SQLHSTMT,SQLSMALLINT);
69 static SQLRETURN (*pSQLCancel)(SQLHSTMT);
70 static SQLRETURN (*pSQLCloseCursor)(SQLHSTMT);
71 static SQLRETURN (*pSQLColAttribute)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
72 static SQLRETURN (*pSQLColAttributeW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
73 static SQLRETURN (*pSQLColAttributes)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLINTEGER*);
74 static SQLRETURN (*pSQLColAttributesW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
75 static SQLRETURN (*pSQLColumnPrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
76 static SQLRETURN (*pSQLColumnPrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
77 static SQLRETURN (*pSQLColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
78 static SQLRETURN (*pSQLColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
79 static SQLRETURN (*pSQLConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
80 static SQLRETURN (*pSQLConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
81 static SQLRETURN (*pSQLCopyDesc)(SQLHDESC,SQLHDESC);
82 static SQLRETURN (*pSQLDataSources)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
83 static SQLRETURN (*pSQLDataSourcesA)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
84 static SQLRETURN (*pSQLDataSourcesW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
85 static SQLRETURN (*pSQLDescribeCol)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*);
86 static SQLRETURN (*pSQLDescribeColW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
87 static SQLRETURN (*pSQLDescribeParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*);
88 static SQLRETURN (*pSQLDisconnect)(SQLHDBC);
89 static SQLRETURN (*pSQLDriverConnect)(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
90 static SQLRETURN (*pSQLDriverConnectW)(SQLHDBC,SQLHWND,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
91 static SQLRETURN (*pSQLDrivers)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
92 static SQLRETURN (*pSQLDriversW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
93 static SQLRETURN (*pSQLEndTran)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT);
94 static SQLRETURN (*pSQLError)(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
95 static SQLRETURN (*pSQLErrorW)(SQLHENV,SQLHDBC,SQLHSTMT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
96 static SQLRETURN (*pSQLExecDirect)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
97 static SQLRETURN (*pSQLExecDirectW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
98 static SQLRETURN (*pSQLExecute)(SQLHSTMT);
99 static SQLRETURN (*pSQLExtendedFetch)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUINTEGER*,SQLUSMALLINT*);
100 static SQLRETURN (*pSQLFetch)(SQLHSTMT);
101 static SQLRETURN (*pSQLFetchScroll)(SQLHSTMT,SQLSMALLINT,SQLINTEGER);
102 static SQLRETURN (*pSQLForeignKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
103 static SQLRETURN (*pSQLForeignKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
104 static SQLRETURN (*pSQLFreeConnect)(SQLHDBC);
105 static SQLRETURN (*pSQLFreeEnv)(SQLHENV);
106 static SQLRETURN (*pSQLFreeHandle)(SQLSMALLINT,SQLHANDLE);
107 static SQLRETURN (*pSQLFreeStmt)(SQLHSTMT,SQLUSMALLINT);
108 static SQLRETURN (*pSQLGetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
109 static SQLRETURN (*pSQLGetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
110 static SQLRETURN (*pSQLGetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
111 static SQLRETURN (*pSQLGetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
112 static SQLRETURN (*pSQLGetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
113 static SQLRETURN (*pSQLGetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
114 static SQLRETURN (*pSQLGetData)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
115 static SQLRETURN (*pSQLGetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
116 static SQLRETURN (*pSQLGetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
117 static SQLRETURN (*pSQLGetDescRec)(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLINTEGER*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
118 static SQLRETURN (*pSQLGetDescRecW)(SQLHDESC,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
119 static SQLRETURN (*pSQLGetDiagField)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
120 static SQLRETURN (*pSQLGetDiagFieldW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
121 static SQLRETURN (*pSQLGetDiagRec)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
122 static SQLRETURN (*pSQLGetDiagRecW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
123 static SQLRETURN (*pSQLGetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
124 static SQLRETURN (*pSQLGetFunctions)(SQLHDBC,SQLUSMALLINT,SQLUSMALLINT*);
125 static SQLRETURN (*pSQLGetInfo)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
126 static SQLRETURN (*pSQLGetInfoW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
127 static SQLRETURN (*pSQLGetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
128 static SQLRETURN (*pSQLGetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
129 static SQLRETURN (*pSQLGetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLPOINTER);
130 static SQLRETURN (*pSQLGetTypeInfo)(SQLHSTMT,SQLSMALLINT);
131 static SQLRETURN (*pSQLGetTypeInfoW)(SQLHSTMT,SQLSMALLINT);
132 static SQLRETURN (*pSQLMoreResults)(SQLHSTMT);
133 static SQLRETURN (*pSQLNativeSql)(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*);
134 static SQLRETURN (*pSQLNativeSqlW)(SQLHDBC,SQLWCHAR*,SQLINTEGER,SQLWCHAR*,SQLINTEGER,SQLINTEGER*);
135 static SQLRETURN (*pSQLNumParams)(SQLHSTMT,SQLSMALLINT*);
136 static SQLRETURN (*pSQLNumResultCols)(SQLHSTMT,SQLSMALLINT*);
137 static SQLRETURN (*pSQLParamData)(SQLHSTMT,SQLPOINTER*);
138 static SQLRETURN (*pSQLParamOptions)(SQLHSTMT,SQLUINTEGER,SQLUINTEGER*);
139 static SQLRETURN (*pSQLPrepare)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
140 static SQLRETURN (*pSQLPrepareW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
141 static SQLRETURN (*pSQLPrimaryKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
142 static SQLRETURN (*pSQLPrimaryKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
143 static SQLRETURN (*pSQLProcedureColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
144 static SQLRETURN (*pSQLProcedureColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
145 static SQLRETURN (*pSQLProcedures)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
146 static SQLRETURN (*pSQLProceduresW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
147 static SQLRETURN (*pSQLPutData)(SQLHSTMT,SQLPOINTER,SQLINTEGER);
148 static SQLRETURN (*pSQLRowCount)(SQLHSTMT,SQLINTEGER*);
149 static SQLRETURN (*pSQLSetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
150 static SQLRETURN (*pSQLSetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
151 static SQLRETURN (*pSQLSetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLUINTEGER);
152 static SQLRETURN (*pSQLSetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLULEN);
153 static SQLRETURN (*pSQLSetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT);
154 static SQLRETURN (*pSQLSetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT);
155 static SQLRETURN (*pSQLSetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
156 static SQLRETURN (*pSQLSetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
157 static SQLRETURN (*pSQLSetDescRec)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLINTEGER,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER*,SQLINTEGER*);
158 static SQLRETURN (*pSQLSetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER);
159 static SQLRETURN (*pSQLSetParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*);
160 static SQLRETURN (*pSQLSetPos)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
161 static SQLRETURN (*pSQLSetScrollOptions)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUSMALLINT);
162 static SQLRETURN (*pSQLSetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
163 static SQLRETURN (*pSQLSetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
164 static SQLRETURN (*pSQLSetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLUINTEGER);
165 static SQLRETURN (*pSQLSpecialColumns)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
166 static SQLRETURN (*pSQLSpecialColumnsW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
167 static SQLRETURN (*pSQLStatistics)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
168 static SQLRETURN (*pSQLStatisticsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
169 static SQLRETURN (*pSQLTablePrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
170 static SQLRETURN (*pSQLTablePrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
171 static SQLRETURN (*pSQLTables)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
172 static SQLRETURN (*pSQLTablesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
173 static SQLRETURN (*pSQLTransact)(SQLHENV,SQLHDBC,SQLUSMALLINT);
174
175 #define ERROR_FREE 0
176 #define ERROR_SQLERROR 1
177 #define ERROR_LIBRARY_NOT_FOUND 2
178
179 static void *dmHandle;
180 static int nErrorType;
181
182 /***********************************************************************
183 * ODBC_ReplicateODBCInstToRegistry
184 *
185 * PARAMS
186 *
187 * RETURNS
188 *
189 * Utility to ODBC_ReplicateToRegistry to replicate the drivers of the
190 * ODBCINST.INI settings
191 *
192 * The driver settings are not replicated to the registry. If we were to
193 * replicate them we would need to decide whether to replicate all settings
194 * or to do some translation; whether to remove any entries present only in
195 * the windows registry, etc.
196 */
197
198 static void ODBC_ReplicateODBCInstToRegistry (SQLHENV hEnv)
199 {
200 HKEY hODBCInst;
201 LONG reg_ret;
202 int success;
203
204 success = 0;
205 TRACE ("Driver settings are not currently replicated to the registry\n");
206 if ((reg_ret = RegCreateKeyExA (HKEY_LOCAL_MACHINE,
207 "Software\\ODBC\\ODBCINST.INI", 0, NULL,
208 REG_OPTION_NON_VOLATILE,
209 KEY_ALL_ACCESS /* a couple more than we need */, NULL,
210 &hODBCInst, NULL)) == ERROR_SUCCESS)
211 {
212 HKEY hDrivers;
213 if ((reg_ret = RegCreateKeyExA (hODBCInst, "ODBC Drivers", 0,
214 NULL, REG_OPTION_NON_VOLATILE,
215 KEY_ALL_ACCESS /* overkill */, NULL, &hDrivers, NULL))
216 == ERROR_SUCCESS)
217 {
218 SQLRETURN sql_ret;
219 SQLUSMALLINT dirn;
220 CHAR desc [256];
221 SQLSMALLINT sizedesc;
222
223 success = 1;
224 dirn = SQL_FETCH_FIRST;
225 while ((sql_ret = SQLDrivers (hEnv, dirn, (SQLCHAR*)desc, sizeof(desc),
226 &sizedesc, NULL, 0, NULL)) == SQL_SUCCESS ||
227 sql_ret == SQL_SUCCESS_WITH_INFO)
228 {
229 /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
230 dirn = SQL_FETCH_NEXT;
231 if (sizedesc == lstrlenA(desc))
232 {
233 HKEY hThis;
234 if ((reg_ret = RegQueryValueExA (hDrivers, desc, NULL,
235 NULL, NULL, NULL)) == ERROR_FILE_NOT_FOUND)
236 {
237 if ((reg_ret = RegSetValueExA (hDrivers, desc, 0,
238 REG_SZ, (const BYTE *)"Installed", 10)) != ERROR_SUCCESS)
239 {
240 TRACE ("Error %d replicating driver %s\n",
241 reg_ret, desc);
242 success = 0;
243 }
244 }
245 else if (reg_ret != ERROR_SUCCESS)
246 {
247 TRACE ("Error %d checking for %s in drivers\n",
248 reg_ret, desc);
249 success = 0;
250 }
251 if ((reg_ret = RegCreateKeyExA (hODBCInst, desc, 0,
252 NULL, REG_OPTION_NON_VOLATILE,
253 KEY_ALL_ACCESS, NULL, &hThis, NULL))
254 == ERROR_SUCCESS)
255 {
256 /* FIXME This is where the settings go.
257 * I suggest that if the disposition says it
258 * exists then we leave it alone. Alternatively
259 * include an extra value to flag that it is
260 * a replication of the unixODBC/iODBC/...
261 */
262 if ((reg_ret = RegCloseKey (hThis)) !=
263 ERROR_SUCCESS)
264 TRACE ("Error %d closing %s key\n", reg_ret,
265 desc);
266 }
267 else
268 {
269 TRACE ("Error %d ensuring driver key %s\n",
270 reg_ret, desc);
271 success = 0;
272 }
273 }
274 else
275 {
276 WARN ("Unusually long driver name %s not replicated\n",
277 desc);
278 success = 0;
279 }
280 }
281 if (sql_ret != SQL_NO_DATA)
282 {
283 TRACE ("Error %d enumerating drivers\n", (int)sql_ret);
284 success = 0;
285 }
286 if ((reg_ret = RegCloseKey (hDrivers)) != ERROR_SUCCESS)
287 {
288 TRACE ("Error %d closing hDrivers\n", reg_ret);
289 }
290 }
291 else
292 {
293 TRACE ("Error %d opening HKLM\\S\\O\\OI\\Drivers\n", reg_ret);
294 }
295 if ((reg_ret = RegCloseKey (hODBCInst)) != ERROR_SUCCESS)
296 {
297 TRACE ("Error %d closing HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
298 }
299 }
300 else
301 {
302 TRACE ("Error %d opening HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
303 }
304 if (!success)
305 {
306 WARN ("May not have replicated all ODBC drivers to the registry\n");
307 }
308 }
309
310 /***********************************************************************
311 * ODBC_ReplicateODBCToRegistry
312 *
313 * PARAMS
314 *
315 * RETURNS
316 *
317 * Utility to ODBC_ReplicateToRegistry to replicate either the USER or
318 * SYSTEM dsns
319 *
320 * For now simply place the "Driver description" (as returned by SQLDataSources)
321 * into the registry as the driver. This is enough to satisfy Crystal's
322 * requirement that there be a driver entry. (It doesn't seem to care what
323 * the setting is).
324 * A slightly more accurate setting would be to access the registry to find
325 * the actual driver library for the given description (which appears to map
326 * to one of the HKLM/Software/ODBC/ODBCINST.INI keys). (If you do this note
327 * that this will add a requirement that this function be called after
328 * ODBC_ReplicateODBCInstToRegistry)
329 */
330 static void ODBC_ReplicateODBCToRegistry (int is_user, SQLHENV hEnv)
331 {
332 HKEY hODBC;
333 LONG reg_ret;
334 SQLRETURN sql_ret;
335 SQLUSMALLINT dirn;
336 CHAR dsn [SQL_MAX_DSN_LENGTH + 1];
337 SQLSMALLINT sizedsn;
338 CHAR desc [256];
339 SQLSMALLINT sizedesc;
340 int success;
341 const char *which = is_user ? "user" : "system";
342
343 success = 0;
344 if ((reg_ret = RegCreateKeyExA (
345 is_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
346 "Software\\ODBC\\ODBC.INI", 0, NULL, REG_OPTION_NON_VOLATILE,
347 KEY_ALL_ACCESS /* a couple more than we need */, NULL, &hODBC,
348 NULL)) == ERROR_SUCCESS)
349 {
350 success = 1;
351 dirn = is_user ? SQL_FETCH_FIRST_USER : SQL_FETCH_FIRST_SYSTEM;
352 while ((sql_ret = SQLDataSources (hEnv, dirn,
353 (SQLCHAR*)dsn, sizeof(dsn), &sizedsn,
354 (SQLCHAR*)desc, sizeof(desc), &sizedesc)) == SQL_SUCCESS
355 || sql_ret == SQL_SUCCESS_WITH_INFO)
356 {
357 /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
358 dirn = SQL_FETCH_NEXT;
359 if (sizedsn == lstrlenA(dsn) && sizedesc == lstrlenA(desc))
360 {
361 HKEY hDSN;
362 if ((reg_ret = RegCreateKeyExA (hODBC, dsn, 0,
363 NULL, REG_OPTION_NON_VOLATILE,
364 KEY_ALL_ACCESS, NULL, &hDSN, NULL))
365 == ERROR_SUCCESS)
366 {
367 static const char DRIVERKEY[] = "Driver";
368 if ((reg_ret = RegQueryValueExA (hDSN, DRIVERKEY,
369 NULL, NULL, NULL, NULL))
370 == ERROR_FILE_NOT_FOUND)
371 {
372 if ((reg_ret = RegSetValueExA (hDSN, DRIVERKEY, 0,
373 REG_SZ, (LPBYTE)desc, sizedesc)) != ERROR_SUCCESS)
374 {
375 TRACE ("Error %d replicating description of "
376 "%s(%s)\n", reg_ret, dsn, desc);
377 success = 0;
378 }
379 }
380 else if (reg_ret != ERROR_SUCCESS)
381 {
382 TRACE ("Error %d checking for description of %s\n",
383 reg_ret, dsn);
384 success = 0;
385 }
386 if ((reg_ret = RegCloseKey (hDSN)) != ERROR_SUCCESS)
387 {
388 TRACE ("Error %d closing %s DSN key %s\n",
389 reg_ret, which, dsn);
390 }
391 }
392 else
393 {
394 TRACE ("Error %d opening %s DSN key %s\n",
395 reg_ret, which, dsn);
396 success = 0;
397 }
398 }
399 else
400 {
401 WARN ("Unusually long %s data source name %s (%s) not "
402 "replicated\n", which, dsn, desc);
403 success = 0;
404 }
405 }
406 if (sql_ret != SQL_NO_DATA)
407 {
408 TRACE ("Error %d enumerating %s datasources\n",
409 (int)sql_ret, which);
410 success = 0;
411 }
412 if ((reg_ret = RegCloseKey (hODBC)) != ERROR_SUCCESS)
413 {
414 TRACE ("Error %d closing %s ODBC.INI registry key\n", reg_ret,
415 which);
416 }
417 }
418 else
419 {
420 TRACE ("Error %d creating/opening %s ODBC.INI registry key\n",
421 reg_ret, which);
422 }
423 if (!success)
424 {
425 WARN ("May not have replicated all %s ODBC DSNs to the registry\n",
426 which);
427 }
428 }
429
430 /***********************************************************************
431 * ODBC_ReplicateToRegistry
432 *
433 * PARAMS
434 *
435 * RETURNS
436 *
437 * Unfortunately some of the functions that Windows documents as being part
438 * of the ODBC API it implements directly during compilation or something
439 * in terms of registry access functions.
440 * e.g. SQLGetInstalledDrivers queries the list at
441 * HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\ODBC Drivers
442 *
443 * This function is called when the driver manager is loaded and is used
444 * to replicate the appropriate details into the Wine registry
445 */
446
447 static void ODBC_ReplicateToRegistry (void)
448 {
449 SQLRETURN sql_ret;
450 SQLHENV hEnv;
451
452 if ((sql_ret = SQLAllocEnv (&hEnv)) == SQL_SUCCESS)
453 {
454 ODBC_ReplicateODBCInstToRegistry (hEnv);
455 ODBC_ReplicateODBCToRegistry (0 /* system dsns */, hEnv);
456 ODBC_ReplicateODBCToRegistry (1 /* user dsns */, hEnv);
457
458 if ((sql_ret = SQLFreeEnv (hEnv)) != SQL_SUCCESS)
459 {
460 TRACE ("Error %d freeing the SQL environment.\n", (int)sql_ret);
461 }
462 }
463 else
464 {
465 TRACE ("Error %d opening an SQL environment.\n", (int)sql_ret);
466 WARN ("The external ODBC settings have not been replicated to the"
467 " Wine registry\n");
468 }
469 }
470
471 /***********************************************************************
472 * DllMain [Internal] Initializes the internal 'ODBC32.DLL'.
473 */
474 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
475 {
476 TRACE("proxy ODBC: %p,%x,%p\n", hinstDLL, reason, reserved);
477
478 switch (reason)
479 {
480 case DLL_PROCESS_ATTACH:
481 DisableThreadLibraryCalls(hinstDLL);
482 if (ODBC_LoadDriverManager())
483 {
484 ODBC_LoadDMFunctions();
485 ODBC_ReplicateToRegistry();
486 }
487 break;
488
489 case DLL_PROCESS_DETACH:
490 if (reserved) break;
491 if (dmHandle) wine_dlclose(dmHandle,NULL,0);
492 }
493
494 return TRUE;
495 }
496
497 /***********************************************************************
498 * ODBC_LoadDriverManager [Internal] Load ODBC library.
499 *
500 * PARAMS
501 *
502 * RETURNS
503 * Success: TRUE
504 * Failure: FALSE
505 */
506
507 static BOOL ODBC_LoadDriverManager(void)
508 {
509 const char *s = getenv("LIB_ODBC_DRIVER_MANAGER");
510 char error[256];
511
512 TRACE("\n");
513
514 #ifdef SONAME_LIBODBC
515 if (!s || !s[0]) s = SONAME_LIBODBC;
516 #endif
517 if (!s || !s[0]) goto failed;
518
519 dmHandle = wine_dlopen(s, RTLD_LAZY | RTLD_GLOBAL, error, sizeof(error));
520
521 if (dmHandle != NULL)
522 {
523 nErrorType = ERROR_FREE;
524 return TRUE;
525 }
526 failed:
527 WARN("failed to open library %s: %s\n", debugstr_a(s), error);
528 nErrorType = ERROR_LIBRARY_NOT_FOUND;
529 return FALSE;
530 }
531
532
533 /***********************************************************************
534 * ODBC_LoadDMFunctions [Internal] Populate function table.
535 *
536 * PARAMS
537 *
538 * RETURNS
539 * Success: TRUE
540 * Failure: FALSE
541 */
542
543 static BOOL ODBC_LoadDMFunctions(void)
544 {
545 char error[256];
546
547 if (dmHandle == NULL)
548 return FALSE;
549
550 #define LOAD_FUNC(name) \
551 if ((p##name = wine_dlsym( dmHandle, #name, error, sizeof(error) ))); \
552 else WARN( "Failed to load %s: %s\n", #name, error )
553
554 LOAD_FUNC(SQLAllocConnect);
555 LOAD_FUNC(SQLAllocEnv);
556 LOAD_FUNC(SQLAllocHandle);
557 LOAD_FUNC(SQLAllocHandleStd);
558 LOAD_FUNC(SQLAllocStmt);
559 LOAD_FUNC(SQLBindCol);
560 LOAD_FUNC(SQLBindParam);
561 LOAD_FUNC(SQLBindParameter);
562 LOAD_FUNC(SQLBrowseConnect);
563 LOAD_FUNC(SQLBrowseConnectW);
564 LOAD_FUNC(SQLBulkOperations);
565 LOAD_FUNC(SQLCancel);
566 LOAD_FUNC(SQLCloseCursor);
567 LOAD_FUNC(SQLColAttribute);
568 LOAD_FUNC(SQLColAttributeW);
569 LOAD_FUNC(SQLColAttributes);
570 LOAD_FUNC(SQLColAttributesW);
571 LOAD_FUNC(SQLColumnPrivileges);
572 LOAD_FUNC(SQLColumnPrivilegesW);
573 LOAD_FUNC(SQLColumns);
574 LOAD_FUNC(SQLColumnsW);
575 LOAD_FUNC(SQLConnect);
576 LOAD_FUNC(SQLConnectW);
577 LOAD_FUNC(SQLCopyDesc);
578 LOAD_FUNC(SQLDataSources);
579 LOAD_FUNC(SQLDataSourcesA);
580 LOAD_FUNC(SQLDataSourcesW);
581 LOAD_FUNC(SQLDescribeCol);
582 LOAD_FUNC(SQLDescribeColW);
583 LOAD_FUNC(SQLDescribeParam);
584 LOAD_FUNC(SQLDisconnect);
585 LOAD_FUNC(SQLDriverConnect);
586 LOAD_FUNC(SQLDriverConnectW);
587 LOAD_FUNC(SQLDrivers);
588 LOAD_FUNC(SQLDriversW);
589 LOAD_FUNC(SQLEndTran);
590 LOAD_FUNC(SQLError);
591 LOAD_FUNC(SQLErrorW);
592 LOAD_FUNC(SQLExecDirect);
593 LOAD_FUNC(SQLExecDirectW);
594 LOAD_FUNC(SQLExecute);
595 LOAD_FUNC(SQLExtendedFetch);
596 LOAD_FUNC(SQLFetch);
597 LOAD_FUNC(SQLFetchScroll);
598 LOAD_FUNC(SQLForeignKeys);
599 LOAD_FUNC(SQLForeignKeysW);
600 LOAD_FUNC(SQLFreeConnect);
601 LOAD_FUNC(SQLFreeEnv);
602 LOAD_FUNC(SQLFreeHandle);
603 LOAD_FUNC(SQLFreeStmt);
604 LOAD_FUNC(SQLGetConnectAttr);
605 LOAD_FUNC(SQLGetConnectAttrW);
606 LOAD_FUNC(SQLGetConnectOption);
607 LOAD_FUNC(SQLGetConnectOptionW);
608 LOAD_FUNC(SQLGetCursorName);
609 LOAD_FUNC(SQLGetCursorNameW);
610 LOAD_FUNC(SQLGetData);
611 LOAD_FUNC(SQLGetDescField);
612 LOAD_FUNC(SQLGetDescFieldW);
613 LOAD_FUNC(SQLGetDescRec);
614 LOAD_FUNC(SQLGetDescRecW);
615 LOAD_FUNC(SQLGetDiagField);
616 LOAD_FUNC(SQLGetDiagFieldW);
617 LOAD_FUNC(SQLGetDiagRec);
618 LOAD_FUNC(SQLGetDiagRecW);
619 LOAD_FUNC(SQLGetEnvAttr);
620 LOAD_FUNC(SQLGetFunctions);
621 LOAD_FUNC(SQLGetInfo);
622 LOAD_FUNC(SQLGetInfoW);
623 LOAD_FUNC(SQLGetStmtAttr);
624 LOAD_FUNC(SQLGetStmtAttrW);
625 LOAD_FUNC(SQLGetStmtOption);
626 LOAD_FUNC(SQLGetTypeInfo);
627 LOAD_FUNC(SQLGetTypeInfoW);
628 LOAD_FUNC(SQLMoreResults);
629 LOAD_FUNC(SQLNativeSql);
630 LOAD_FUNC(SQLNativeSqlW);
631 LOAD_FUNC(SQLNumParams);
632 LOAD_FUNC(SQLNumResultCols);
633 LOAD_FUNC(SQLParamData);
634 LOAD_FUNC(SQLParamOptions);
635 LOAD_FUNC(SQLPrepare);
636 LOAD_FUNC(SQLPrepareW);
637 LOAD_FUNC(SQLPrimaryKeys);
638 LOAD_FUNC(SQLPrimaryKeysW);
639 LOAD_FUNC(SQLProcedureColumns);
640 LOAD_FUNC(SQLProcedureColumnsW);
641 LOAD_FUNC(SQLProcedures);
642 LOAD_FUNC(SQLProceduresW);
643 LOAD_FUNC(SQLPutData);
644 LOAD_FUNC(SQLRowCount);
645 LOAD_FUNC(SQLSetConnectAttr);
646 LOAD_FUNC(SQLSetConnectAttrW);
647 LOAD_FUNC(SQLSetConnectOption);
648 LOAD_FUNC(SQLSetConnectOptionW);
649 LOAD_FUNC(SQLSetCursorName);
650 LOAD_FUNC(SQLSetCursorNameW);
651 LOAD_FUNC(SQLSetDescField);
652 LOAD_FUNC(SQLSetDescFieldW);
653 LOAD_FUNC(SQLSetDescRec);
654 LOAD_FUNC(SQLSetEnvAttr);
655 LOAD_FUNC(SQLSetParam);
656 LOAD_FUNC(SQLSetPos);
657 LOAD_FUNC(SQLSetScrollOptions);
658 LOAD_FUNC(SQLSetStmtAttr);
659 LOAD_FUNC(SQLSetStmtAttrW);
660 LOAD_FUNC(SQLSetStmtOption);
661 LOAD_FUNC(SQLSpecialColumns);
662 LOAD_FUNC(SQLSpecialColumnsW);
663 LOAD_FUNC(SQLStatistics);
664 LOAD_FUNC(SQLStatisticsW);
665 LOAD_FUNC(SQLTablePrivileges);
666 LOAD_FUNC(SQLTablePrivilegesW);
667 LOAD_FUNC(SQLTables);
668 LOAD_FUNC(SQLTablesW);
669 LOAD_FUNC(SQLTransact);
670 #undef LOAD_FUNC
671
672 return TRUE;
673 }
674
675
676 /*************************************************************************
677 * SQLAllocConnect [ODBC32.001]
678 */
679 SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionHandle)
680 {
681 SQLRETURN ret;
682 TRACE("Env=%p\n",EnvironmentHandle);
683
684 if (!pSQLAllocConnect)
685 {
686 *ConnectionHandle = SQL_NULL_HDBC;
687 TRACE("Not ready\n");
688 return SQL_ERROR;
689 }
690
691 ret = pSQLAllocConnect(EnvironmentHandle, ConnectionHandle);
692 TRACE("Returns ret=%d, Handle %p\n",ret, *ConnectionHandle);
693 return ret;
694 }
695
696
697 /*************************************************************************
698 * SQLAllocEnv [ODBC32.002]
699 */
700 SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle)
701 {
702 SQLRETURN ret;
703 TRACE("\n");
704
705 if (!pSQLAllocEnv)
706 {
707 *EnvironmentHandle = SQL_NULL_HENV;
708 TRACE("Not ready\n");
709 return SQL_ERROR;
710 }
711
712 ret = pSQLAllocEnv(EnvironmentHandle);
713 TRACE("Returns ret=%d, Env=%p\n",ret, *EnvironmentHandle);
714 return ret;
715 }
716
717
718 /*************************************************************************
719 * SQLAllocHandle [ODBC32.024]
720 */
721 SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
722 {
723 SQLRETURN ret;
724 TRACE("(Type=%d, Handle=%p)\n",HandleType,InputHandle);
725
726 if (!pSQLAllocHandle)
727 {
728 if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
729 WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
730
731 if (HandleType == SQL_HANDLE_ENV)
732 *OutputHandle = SQL_NULL_HENV;
733 else if (HandleType == SQL_HANDLE_DBC)
734 *OutputHandle = SQL_NULL_HDBC;
735 else if (HandleType == SQL_HANDLE_STMT)
736 *OutputHandle = SQL_NULL_HSTMT;
737 else if (HandleType == SQL_HANDLE_DESC)
738 *OutputHandle = SQL_NULL_HDESC;
739
740 TRACE ("Not ready\n");
741 return SQL_ERROR;
742 }
743
744 ret = pSQLAllocHandle(HandleType, InputHandle, OutputHandle);
745 TRACE("Returns ret=%d, Handle=%p\n",ret, *OutputHandle);
746 return ret;
747 }
748
749
750 /*************************************************************************
751 * SQLAllocStmt [ODBC32.003]
752 */
753 SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandle)
754 {
755 SQLRETURN ret;
756
757 TRACE("(Connection=%p)\n",ConnectionHandle);
758
759 if (!pSQLAllocStmt)
760 {
761 *StatementHandle = SQL_NULL_HSTMT;
762 TRACE ("Not ready\n");
763 return SQL_ERROR;
764 }
765
766 ret = pSQLAllocStmt(ConnectionHandle, StatementHandle);
767 TRACE ("Returns ret=%d, Handle=%p\n", ret, *StatementHandle);
768 return ret;
769 }
770
771
772 /*************************************************************************
773 * SQLAllocHandleStd [ODBC32.077]
774 */
775 SQLRETURN WINAPI SQLAllocHandleStd( SQLSMALLINT HandleType,
776 SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
777 {
778 TRACE("ProxyODBC: SQLAllocHandleStd.\n");
779
780 if (!pSQLAllocHandleStd)
781 {
782 if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
783 WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
784
785 if (HandleType == SQL_HANDLE_ENV)
786 *OutputHandle = SQL_NULL_HENV;
787 else if (HandleType == SQL_HANDLE_DBC)
788 *OutputHandle = SQL_NULL_HDBC;
789 else if (HandleType == SQL_HANDLE_STMT)
790 *OutputHandle = SQL_NULL_HSTMT;
791 else if (HandleType == SQL_HANDLE_DESC)
792 *OutputHandle = SQL_NULL_HDESC;
793
794 return SQL_ERROR;
795 }
796
797 return pSQLAllocHandleStd(HandleType, InputHandle, OutputHandle);
798 }
799
800
801 /*************************************************************************
802 * SQLBindCol [ODBC32.004]
803 */
804 SQLRETURN WINAPI SQLBindCol(SQLHSTMT StatementHandle,
805 SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
806 SQLPOINTER TargetValue, SQLLEN BufferLength,
807 SQLLEN *StrLen_or_Ind)
808 {
809 TRACE("\n");
810
811 if (!pSQLBindCol)
812 {
813 TRACE ("Not ready\n");
814 return SQL_ERROR;
815 }
816
817 return pSQLBindCol(StatementHandle, ColumnNumber, TargetType,
818 TargetValue, BufferLength, StrLen_or_Ind);
819 }
820
821
822 /*************************************************************************
823 * SQLBindParam [ODBC32.025]
824 */
825 SQLRETURN WINAPI SQLBindParam(SQLHSTMT StatementHandle,
826 SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
827 SQLSMALLINT ParameterType, SQLULEN LengthPrecision,
828 SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
829 SQLLEN *StrLen_or_Ind)
830 {
831 TRACE("\n");
832
833 if (!pSQLBindParam) return SQL_ERROR;
834 return pSQLBindParam(StatementHandle, ParameterNumber, ValueType,
835 ParameterType, LengthPrecision, ParameterScale,
836 ParameterValue, StrLen_or_Ind);
837 }
838
839
840 /*************************************************************************
841 * SQLCancel [ODBC32.005]
842 */
843 SQLRETURN WINAPI SQLCancel(SQLHSTMT StatementHandle)
844 {
845 TRACE("\n");
846
847 if (!pSQLCancel) return SQL_ERROR;
848 return pSQLCancel(StatementHandle);
849 }
850
851
852 /*************************************************************************
853 * SQLCloseCursor [ODBC32.026]
854 */
855 SQLRETURN WINAPI SQLCloseCursor(SQLHSTMT StatementHandle)
856 {
857 SQLRETURN ret;
858 TRACE("(Handle=%p)\n",StatementHandle);
859
860 if (!pSQLCloseCursor) return SQL_ERROR;
861
862 ret = pSQLCloseCursor(StatementHandle);
863 TRACE("returns %d\n",ret);
864 return ret;
865 }
866
867
868 /*************************************************************************
869 * SQLColAttribute [ODBC32.027]
870 */
871 SQLRETURN WINAPI SQLColAttribute (SQLHSTMT StatementHandle,
872 SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
873 SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
874 SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute)
875 {
876 TRACE("\n");
877
878 if (!pSQLColAttribute) return SQL_ERROR;
879 return pSQLColAttribute(StatementHandle, ColumnNumber, FieldIdentifier,
880 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
881 }
882
883
884 /*************************************************************************
885 * SQLColumns [ODBC32.040]
886 */
887 SQLRETURN WINAPI SQLColumns(SQLHSTMT StatementHandle,
888 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
889 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
890 SQLCHAR *TableName, SQLSMALLINT NameLength3,
891 SQLCHAR *ColumnName, SQLSMALLINT NameLength4)
892 {
893 TRACE("\n");
894
895 if (!pSQLColumns) return SQL_ERROR;
896 return pSQLColumns(StatementHandle, CatalogName, NameLength1,
897 SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
898 }
899
900
901 /*************************************************************************
902 * SQLConnect [ODBC32.007]
903 */
904 SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle,
905 SQLCHAR *ServerName, SQLSMALLINT NameLength1,
906 SQLCHAR *UserName, SQLSMALLINT NameLength2,
907 SQLCHAR *Authentication, SQLSMALLINT NameLength3)
908 {
909 SQLRETURN ret;
910 TRACE("(Server=%.*s)\n",NameLength1, ServerName);
911
912 if (!pSQLConnect) return SQL_ERROR;
913
914 ret = pSQLConnect(ConnectionHandle, ServerName, NameLength1,
915 UserName, NameLength2, Authentication, NameLength3);
916
917 TRACE("returns %d\n",ret);
918 return ret;
919 }
920
921
922 /*************************************************************************
923 * SQLCopyDesc [ODBC32.028]
924 */
925 SQLRETURN WINAPI SQLCopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandle)
926 {
927 TRACE("\n");
928
929 if (!pSQLCopyDesc) return SQL_ERROR;
930 return pSQLCopyDesc(SourceDescHandle, TargetDescHandle);
931 }
932
933
934 /*************************************************************************
935 * SQLDataSources [ODBC32.057]
936 */
937 SQLRETURN WINAPI SQLDataSources(SQLHENV EnvironmentHandle,
938 SQLUSMALLINT Direction, SQLCHAR *ServerName,
939 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
940 SQLCHAR *Description, SQLSMALLINT BufferLength2,
941 SQLSMALLINT *NameLength2)
942 {
943 SQLRETURN ret;
944
945 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
946
947 if (!pSQLDataSources) return SQL_ERROR;
948
949 ret = pSQLDataSources(EnvironmentHandle, Direction, ServerName,
950 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
951
952 if (TRACE_ON(odbc))
953 {
954 TRACE("returns: %d \t", ret);
955 if (NameLength1 && *NameLength1 > 0)
956 TRACE("DataSource = %s,", ServerName);
957 if (NameLength2 && *NameLength2 > 0)
958 TRACE(" Description = %s", Description);
959 TRACE("\n");
960 }
961
962 return ret;
963 }
964
965 SQLRETURN WINAPI SQLDataSourcesA(SQLHENV EnvironmentHandle,
966 SQLUSMALLINT Direction, SQLCHAR *ServerName,
967 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
968 SQLCHAR *Description, SQLSMALLINT BufferLength2,
969 SQLSMALLINT *NameLength2)
970 {
971 SQLRETURN ret;
972
973 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
974
975 if (!pSQLDataSourcesA) return SQL_ERROR;
976
977 ret = pSQLDataSourcesA(EnvironmentHandle, Direction, ServerName,
978 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
979 if (TRACE_ON(odbc))
980 {
981 TRACE("returns: %d \t", ret);
982 if (NameLength1 && *NameLength1 > 0)
983 TRACE("DataSource = %s,", ServerName);
984 if (NameLength2 && *NameLength2 > 0)
985 TRACE(" Description = %s", Description);
986 TRACE("\n");
987 }
988
989 return ret;
990 }
991
992 /*************************************************************************
993 * SQLDescribeCol [ODBC32.008]
994 */
995 SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle,
996 SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
997 SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
998 SQLSMALLINT *DataType, SQLULEN *ColumnSize,
999 SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
1000 {
1001 TRACE("\n");
1002
1003 if (!pSQLDescribeCol) return SQL_ERROR;
1004 return pSQLDescribeCol(StatementHandle, ColumnNumber, ColumnName,
1005 BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable);
1006 }
1007
1008
1009 /*************************************************************************
1010 * SQLDisconnect [ODBC32.009]
1011 */
1012 SQLRETURN WINAPI SQLDisconnect(SQLHDBC ConnectionHandle)
1013 {
1014 SQLRETURN ret;
1015 TRACE("(Handle=%p)\n", ConnectionHandle);
1016
1017 if (!pSQLDisconnect) return SQL_ERROR;
1018
1019 ret = pSQLDisconnect(ConnectionHandle);
1020 TRACE("returns %d\n",ret);
1021 return ret;
1022 }
1023
1024
1025 /*************************************************************************
1026 * SQLEndTran [ODBC32.029]
1027 */
1028 SQLRETURN WINAPI SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT CompletionType)
1029 {
1030 TRACE("\n");
1031
1032 if (!pSQLEndTran) return SQL_ERROR;
1033 return pSQLEndTran(HandleType, Handle, CompletionType);
1034 }
1035
1036
1037 /*************************************************************************
1038 * SQLError [ODBC32.010]
1039 */
1040 SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle,
1041 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
1042 SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
1043 SQLCHAR *MessageText, SQLSMALLINT BufferLength,
1044 SQLSMALLINT *TextLength)
1045 {
1046 TRACE("\n");
1047
1048 if (!pSQLError) return SQL_ERROR;
1049 return pSQLError(EnvironmentHandle, ConnectionHandle, StatementHandle,
1050 Sqlstate, NativeError, MessageText, BufferLength, TextLength);
1051 }
1052
1053
1054 /*************************************************************************
1055 * SQLExecDirect [ODBC32.011]
1056 */
1057 SQLRETURN WINAPI SQLExecDirect(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
1058 {
1059 TRACE("\n");
1060
1061 if (!pSQLExecDirect) return SQL_ERROR;
1062 return pSQLExecDirect(StatementHandle, StatementText, TextLength);
1063 }
1064
1065
1066 /*************************************************************************
1067 * SQLExecute [ODBC32.012]
1068 */
1069 SQLRETURN WINAPI SQLExecute(SQLHSTMT StatementHandle)
1070 {
1071 TRACE("\n");
1072
1073 if (!pSQLExecute) return SQL_ERROR;
1074 return pSQLExecute(StatementHandle);
1075 }
1076
1077
1078 /*************************************************************************
1079 * SQLFetch [ODBC32.013]
1080 */
1081 SQLRETURN WINAPI SQLFetch(SQLHSTMT StatementHandle)
1082 {
1083 TRACE("\n");
1084
1085 if (!pSQLFetch) return SQL_ERROR;
1086 return pSQLFetch(StatementHandle);
1087 }
1088
1089
1090 /*************************************************************************
1091 * SQLFetchScroll [ODBC32.030]
1092 */
1093 SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrientation, SQLLEN FetchOffset)
1094 {
1095 TRACE("\n");
1096
1097 if (!pSQLFetchScroll) return SQL_ERROR;
1098 return pSQLFetchScroll(StatementHandle, FetchOrientation, FetchOffset);
1099 }
1100
1101
1102 /*************************************************************************
1103 * SQLFreeConnect [ODBC32.014]
1104 */
1105 SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
1106 {
1107 SQLRETURN ret;
1108 TRACE("(Handle=%p)\n",ConnectionHandle);
1109
1110 if (!pSQLFreeConnect) return SQL_ERROR;
1111
1112 ret = pSQLFreeConnect(ConnectionHandle);
1113 TRACE("Returns %d\n",ret);
1114 return ret;
1115 }
1116
1117
1118 /*************************************************************************
1119 * SQLFreeEnv [ODBC32.015]
1120 */
1121 SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle)
1122 {
1123 SQLRETURN ret;
1124 TRACE("(Env=%p)\n",EnvironmentHandle);
1125
1126 if (!pSQLFreeEnv) return SQL_ERROR;
1127
1128 ret = pSQLFreeEnv(EnvironmentHandle);
1129 TRACE("Returns %d\n",ret);
1130 return ret;
1131 }
1132
1133
1134 /*************************************************************************
1135 * SQLFreeHandle [ODBC32.031]
1136 */
1137 SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
1138 {
1139 SQLRETURN ret;
1140 TRACE("(Type=%d, Handle=%p)\n",HandleType,Handle);
1141
1142 if (!pSQLFreeHandle) return SQL_ERROR;
1143
1144 ret = pSQLFreeHandle(HandleType, Handle);
1145 TRACE ("Returns %d\n",ret);
1146 return ret;
1147 }
1148
1149
1150 /*************************************************************************
1151 * SQLFreeStmt [ODBC32.016]
1152 */
1153 SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
1154 {
1155 SQLRETURN ret;
1156 TRACE("(Handle %p, Option=%d)\n",StatementHandle, Option);
1157
1158 if (!pSQLFreeStmt) return SQL_ERROR;
1159
1160 ret = pSQLFreeStmt(StatementHandle, Option);
1161 TRACE("Returns %d\n",ret);
1162 return ret;
1163 }
1164
1165
1166 /*************************************************************************
1167 * SQLGetConnectAttr [ODBC32.032]
1168 */
1169 SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle,
1170 SQLINTEGER Attribute, SQLPOINTER Value,
1171 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1172 {
1173 TRACE("\n");
1174
1175 if (!pSQLGetConnectAttr) return SQL_ERROR;
1176 return pSQLGetConnectAttr(ConnectionHandle, Attribute, Value,
1177 BufferLength, StringLength);
1178 }
1179
1180
1181 /*************************************************************************
1182 * SQLGetConnectOption [ODBC32.042]
1183 */
1184 SQLRETURN WINAPI SQLGetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
1185 {
1186 TRACE("\n");
1187
1188 if (!pSQLGetConnectOption) return SQL_ERROR;
1189 return pSQLGetConnectOption(ConnectionHandle, Option, Value);
1190 }
1191
1192
1193 /*************************************************************************
1194 * SQLGetCursorName [ODBC32.017]
1195 */
1196 SQLRETURN WINAPI SQLGetCursorName(SQLHSTMT StatementHandle,
1197 SQLCHAR *CursorName, SQLSMALLINT BufferLength,
1198 SQLSMALLINT *NameLength)
1199 {
1200 TRACE("\n");
1201
1202 if (!pSQLGetCursorName) return SQL_ERROR;
1203 return pSQLGetCursorName(StatementHandle, CursorName, BufferLength, NameLength);
1204 }
1205
1206
1207 /*************************************************************************
1208 * SQLGetData [ODBC32.043]
1209 */
1210 SQLRETURN WINAPI SQLGetData(SQLHSTMT StatementHandle,
1211 SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
1212 SQLPOINTER TargetValue, SQLLEN BufferLength,
1213 SQLLEN *StrLen_or_Ind)
1214 {
1215 TRACE("\n");
1216
1217 if (!pSQLGetData) return SQL_ERROR;
1218 return pSQLGetData(StatementHandle, ColumnNumber, TargetType,
1219 TargetValue, BufferLength, StrLen_or_Ind);
1220 }
1221
1222
1223 /*************************************************************************
1224 * SQLGetDescField [ODBC32.033]
1225 */
1226 SQLRETURN WINAPI SQLGetDescField(SQLHDESC DescriptorHandle,
1227 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
1228 SQLPOINTER Value, SQLINTEGER BufferLength,
1229 SQLINTEGER *StringLength)
1230 {
1231 TRACE("\n");
1232
1233 if (!pSQLGetDescField) return SQL_ERROR;
1234 return pSQLGetDescField(DescriptorHandle, RecNumber, FieldIdentifier,
1235 Value, BufferLength, StringLength);
1236 }
1237
1238
1239 /*************************************************************************
1240 * SQLGetDescRec [ODBC32.034]
1241 */
1242 SQLRETURN WINAPI SQLGetDescRec(SQLHDESC DescriptorHandle,
1243 SQLSMALLINT RecNumber, SQLCHAR *Name,
1244 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
1245 SQLSMALLINT *Type, SQLSMALLINT *SubType,
1246 SQLLEN *Length, SQLSMALLINT *Precision,
1247 SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
1248 {
1249 TRACE("\n");
1250
1251 if (!pSQLGetDescRec) return SQL_ERROR;
1252 return pSQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength,
1253 StringLength, Type, SubType, Length, Precision, Scale, Nullable);
1254 }
1255
1256
1257 /*************************************************************************
1258 * SQLGetDiagField [ODBC32.035]
1259 */
1260 SQLRETURN WINAPI SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
1261 SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
1262 SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
1263 SQLSMALLINT *StringLength)
1264 {
1265 TRACE("\n");
1266
1267 if (!pSQLGetDiagField) return SQL_ERROR;
1268 return pSQLGetDiagField(HandleType, Handle, RecNumber, DiagIdentifier,
1269 DiagInfo, BufferLength, StringLength);
1270 }
1271
1272
1273 /*************************************************************************
1274 * SQLGetDiagRec [ODBC32.036]
1275 */
1276 SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
1277 SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
1278 SQLINTEGER *NativeError, SQLCHAR *MessageText,
1279 SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
1280 {
1281 TRACE("\n");
1282
1283 if (!pSQLGetDiagRec) return SQL_ERROR;
1284 return pSQLGetDiagRec(HandleType, Handle, RecNumber, Sqlstate, NativeError,
1285 MessageText, BufferLength, TextLength);
1286 }
1287
1288
1289 /*************************************************************************
1290 * SQLGetEnvAttr [ODBC32.037]
1291 */
1292 SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle,
1293 SQLINTEGER Attribute, SQLPOINTER Value,
1294 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1295 {
1296 TRACE("\n");
1297
1298 if (!pSQLGetEnvAttr) return SQL_ERROR;
1299 return pSQLGetEnvAttr(EnvironmentHandle, Attribute, Value, BufferLength, StringLength);
1300 }
1301
1302
1303 /*************************************************************************
1304 * SQLGetFunctions [ODBC32.044]
1305 */
1306 SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
1307 {
1308 TRACE("\n");
1309
1310 if (!pSQLGetFunctions) return SQL_ERROR;
1311 return pSQLGetFunctions(ConnectionHandle, FunctionId, Supported);
1312 }
1313
1314
1315 /*************************************************************************
1316 * SQLGetInfo [ODBC32.045]
1317 */
1318 SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle,
1319 SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
1320 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
1321 {
1322 TRACE("\n");
1323
1324 if (!pSQLGetInfo) return SQL_ERROR;
1325 return pSQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
1326 }
1327
1328
1329 /*************************************************************************
1330 * SQLGetStmtAttr [ODBC32.038]
1331 */
1332 SQLRETURN WINAPI SQLGetStmtAttr(SQLHSTMT StatementHandle,
1333 SQLINTEGER Attribute, SQLPOINTER Value,
1334 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1335 {
1336 TRACE("\n");
1337
1338 if (!pSQLGetStmtAttr) return SQL_ERROR;
1339 return pSQLGetStmtAttr(StatementHandle, Attribute, Value, BufferLength, StringLength);
1340 }
1341
1342
1343 /*************************************************************************
1344 * SQLGetStmtOption [ODBC32.046]
1345 */
1346 SQLRETURN WINAPI SQLGetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLPOINTER Value)
1347 {
1348 TRACE("\n");
1349
1350 if (!pSQLGetStmtOption) return SQL_ERROR;
1351 return pSQLGetStmtOption(StatementHandle, Option, Value);
1352 }
1353
1354
1355 /*************************************************************************
1356 * SQLGetTypeInfo [ODBC32.047]
1357 */
1358 SQLRETURN WINAPI SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
1359 {
1360 TRACE("\n");
1361
1362 if (!pSQLGetTypeInfo) return SQL_ERROR;
1363 return pSQLGetTypeInfo(StatementHandle, DataType);
1364 }
1365
1366
1367 /*************************************************************************
1368 * SQLNumResultCols [ODBC32.018]
1369 */
1370 SQLRETURN WINAPI SQLNumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT *ColumnCount)
1371 {
1372 TRACE("\n");
1373
1374 if (!pSQLNumResultCols) return SQL_ERROR;
1375 return pSQLNumResultCols(StatementHandle, ColumnCount);
1376 }
1377
1378
1379 /*************************************************************************
1380 * SQLParamData [ODBC32.048]
1381 */
1382 SQLRETURN WINAPI SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER *Value)
1383 {
1384 TRACE("\n");
1385
1386 if (!pSQLParamData) return SQL_ERROR;
1387 return pSQLParamData(StatementHandle, Value);
1388 }
1389
1390
1391 /*************************************************************************
1392 * SQLPrepare [ODBC32.019]
1393 */
1394 SQLRETURN WINAPI SQLPrepare(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
1395 {
1396 TRACE("\n");
1397
1398 if (!pSQLPrepare) return SQL_ERROR;
1399 return pSQLPrepare(StatementHandle, StatementText, TextLength);
1400 }
1401
1402
1403 /*************************************************************************
1404 * SQLPutData [ODBC32.049]
1405 */
1406 SQLRETURN WINAPI SQLPutData(SQLHSTMT StatementHandle, SQLPOINTER Data, SQLLEN StrLen_or_Ind)
1407 {
1408 TRACE("\n");
1409
1410 if (!pSQLPutData) return SQL_ERROR;
1411 return pSQLPutData(StatementHandle, Data, StrLen_or_Ind);
1412 }
1413
1414
1415 /*************************************************************************
1416 * SQLRowCount [ODBC32.020]
1417 */
1418 SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLLEN *RowCount)
1419 {
1420 TRACE("\n");
1421
1422 if (!pSQLRowCount) return SQL_ERROR;
1423 return pSQLRowCount(StatementHandle, RowCount);
1424 }
1425
1426
1427 /*************************************************************************
1428 * SQLSetConnectAttr [ODBC32.039]
1429 */
1430 SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
1431 SQLPOINTER Value, SQLINTEGER StringLength)
1432 {
1433 TRACE("\n");
1434
1435 if (!pSQLSetConnectAttr) return SQL_ERROR;
1436 return pSQLSetConnectAttr(ConnectionHandle, Attribute, Value, StringLength);
1437 }
1438
1439
1440 /*************************************************************************
1441 * SQLSetConnectOption [ODBC32.050]
1442 */
1443 SQLRETURN WINAPI SQLSetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLULEN Value)
1444 {
1445 TRACE("\n");
1446
1447 if (!pSQLSetConnectOption) return SQL_ERROR;
1448 return pSQLSetConnectOption(ConnectionHandle, Option, Value);
1449 }
1450
1451
1452 /*************************************************************************
1453 * SQLSetCursorName [ODBC32.021]
1454 */
1455 SQLRETURN WINAPI SQLSetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName, SQLSMALLINT NameLength)
1456 {
1457 TRACE("\n");
1458
1459 if (!pSQLSetCursorName) return SQL_ERROR;
1460 return pSQLSetCursorName(StatementHandle, CursorName, NameLength);
1461 }
1462
1463
1464 /*************************************************************************
1465 * SQLSetDescField [ODBC32.073]
1466 */
1467 SQLRETURN WINAPI SQLSetDescField(SQLHDESC DescriptorHandle,
1468 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
1469 SQLPOINTER Value, SQLINTEGER BufferLength)
1470 {
1471 TRACE("\n");
1472
1473 if (!pSQLSetDescField) return SQL_ERROR;
1474 return pSQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
1475 }
1476
1477
1478 /*************************************************************************
1479 * SQLSetDescRec [ODBC32.074]
1480 */
1481 SQLRETURN WINAPI SQLSetDescRec(SQLHDESC DescriptorHandle,
1482 SQLSMALLINT RecNumber, SQLSMALLINT Type,
1483 SQLSMALLINT SubType, SQLLEN Length,
1484 SQLSMALLINT Precision, SQLSMALLINT Scale,
1485 SQLPOINTER Data, SQLLEN *StringLength,
1486 SQLLEN *Indicator)
1487 {
1488 TRACE("\n");
1489
1490 if (!pSQLSetDescRec) return SQL_ERROR;
1491 return pSQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length,
1492 Precision, Scale, Data, StringLength, Indicator);
1493 }
1494
1495
1496 /*************************************************************************
1497 * SQLSetEnvAttr [ODBC32.075]
1498 */
1499 SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle,
1500 SQLINTEGER Attribute, SQLPOINTER Value,
1501 SQLINTEGER StringLength)
1502 {
1503 TRACE("\n");
1504
1505 if (!pSQLSetEnvAttr) return SQL_ERROR;
1506 return pSQLSetEnvAttr(EnvironmentHandle, Attribute, Value, StringLength);
1507 }
1508
1509
1510 /*************************************************************************
1511 * SQLSetParam [ODBC32.022]
1512 */
1513 SQLRETURN WINAPI SQLSetParam(SQLHSTMT StatementHandle,
1514 SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
1515 SQLSMALLINT ParameterType, SQLULEN LengthPrecision,
1516 SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
1517 SQLLEN *StrLen_or_Ind)
1518 {
1519 TRACE("\n");
1520
1521 if (!pSQLSetParam) return SQL_ERROR;
1522 return pSQLSetParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision,
1523 ParameterScale, ParameterValue, StrLen_or_Ind);
1524 }
1525
1526
1527 /*************************************************************************
1528 * SQLSetStmtAttr [ODBC32.076]
1529 */
1530 SQLRETURN WINAPI SQLSetStmtAttr(SQLHSTMT StatementHandle,
1531 SQLINTEGER Attribute, SQLPOINTER Value,
1532 SQLINTEGER StringLength)
1533 {
1534 TRACE("\n");
1535
1536 if (!pSQLSetStmtAttr) return SQL_ERROR;
1537 return pSQLSetStmtAttr(StatementHandle, Attribute, Value, StringLength);
1538 }
1539
1540
1541 /*************************************************************************
1542 * SQLSetStmtOption [ODBC32.051]
1543 */
1544 SQLRETURN WINAPI SQLSetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLULEN Value)
1545 {
1546 TRACE("\n");
1547
1548 if (!pSQLSetStmtOption) return SQL_ERROR;
1549 return pSQLSetStmtOption(StatementHandle, Option, Value);
1550 }
1551
1552
1553 /*************************************************************************
1554 * SQLSpecialColumns [ODBC32.052]
1555 */
1556 SQLRETURN WINAPI SQLSpecialColumns(SQLHSTMT StatementHandle,
1557 SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
1558 SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
1559 SQLSMALLINT NameLength2, SQLCHAR *TableName,
1560 SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
1561 SQLUSMALLINT Nullable)
1562 {
1563
1564 if (!pSQLSpecialColumns) return SQL_ERROR;
1565 return pSQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
1566 NameLength2, TableName, NameLength3, Scope, Nullable);
1567 }
1568
1569
1570 /*************************************************************************
1571 * SQLStatistics [ODBC32.053]
1572 */
1573 SQLRETURN WINAPI SQLStatistics(SQLHSTMT StatementHandle,
1574 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
1575 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
1576 SQLCHAR *TableName, SQLSMALLINT NameLength3,
1577 SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
1578 {
1579 TRACE("\n");
1580
1581 if (!pSQLStatistics) return SQL_ERROR;
1582 return pSQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
1583 TableName, NameLength3, Unique, Reserved);
1584 }
1585
1586
1587 /*************************************************************************
1588 * SQLTables [ODBC32.054]
1589 */
1590 SQLRETURN WINAPI SQLTables(SQLHSTMT StatementHandle,
1591 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
1592 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
1593 SQLCHAR *TableName, SQLSMALLINT NameLength3,
1594 SQLCHAR *TableType, SQLSMALLINT NameLength4)
1595 {
1596 TRACE("\n");
1597
1598 if (!pSQLTables) return SQL_ERROR;
1599 return pSQLTables(StatementHandle, CatalogName, NameLength1,
1600 SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
1601 }
1602
1603
1604 /*************************************************************************
1605 * SQLTransact [ODBC32.023]
1606 */
1607 SQLRETURN WINAPI SQLTransact(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle,
1608 SQLUSMALLINT CompletionType)
1609 {
1610 TRACE("\n");
1611
1612 if (!pSQLTransact) return SQL_ERROR;
1613 return pSQLTransact(EnvironmentHandle, ConnectionHandle, CompletionType);
1614 }
1615
1616
1617 /*************************************************************************
1618 * SQLBrowseConnect [ODBC32.055]
1619 */
1620 SQLRETURN WINAPI SQLBrowseConnect(
1621 SQLHDBC hdbc,
1622 SQLCHAR *szConnStrIn,
1623 SQLSMALLINT cbConnStrIn,
1624 SQLCHAR *szConnStrOut,
1625 SQLSMALLINT cbConnStrOutMax,
1626 SQLSMALLINT *pcbConnStrOut)
1627 {
1628 TRACE("\n");
1629
1630 if (!pSQLBrowseConnect) return SQL_ERROR;
1631 return pSQLBrowseConnect(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut);
1632 }
1633
1634
1635 /*************************************************************************
1636 * SQLBulkOperations [ODBC32.078]
1637 */
1638 SQLRETURN WINAPI SQLBulkOperations(
1639 SQLHSTMT StatementHandle,
1640 SQLSMALLINT Operation)
1641 {
1642 TRACE("\n");
1643
1644 if (!pSQLBulkOperations) return SQL_ERROR;
1645 return pSQLBulkOperations(StatementHandle, Operation);
1646 }
1647
1648
1649 /*************************************************************************
1650 * SQLColAttributes [ODBC32.006]
1651 */
1652 SQLRETURN WINAPI SQLColAttributes(
1653 SQLHSTMT hstmt,
1654 SQLUSMALLINT icol,
1655 SQLUSMALLINT fDescType,
1656 SQLPOINTER rgbDesc,
1657 SQLSMALLINT cbDescMax,
1658 SQLSMALLINT *pcbDesc,
1659 SQLLEN *pfDesc)
1660 {
1661 TRACE("\n");
1662
1663 if (!pSQLColAttributes) return SQL_ERROR;
1664 return pSQLColAttributes(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
1665 }
1666
1667
1668 /*************************************************************************
1669 * SQLColumnPrivileges [ODBC32.056]
1670 */
1671 SQLRETURN WINAPI SQLColumnPrivileges(
1672 SQLHSTMT hstmt,
1673 SQLCHAR *szCatalogName,
1674 SQLSMALLINT cbCatalogName,
1675 SQLCHAR *szSchemaName,
1676 SQLSMALLINT cbSchemaName,
1677 SQLCHAR *szTableName,
1678 SQLSMALLINT cbTableName,
1679 SQLCHAR *szColumnName,
1680 SQLSMALLINT cbColumnName)
1681 {
1682 TRACE("\n");
1683
1684 if (!pSQLColumnPrivileges) return SQL_ERROR;
1685 return pSQLColumnPrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1686 szTableName, cbTableName, szColumnName, cbColumnName);
1687 }
1688
1689
1690 /*************************************************************************
1691 * SQLDescribeParam [ODBC32.058]
1692 */
1693 SQLRETURN WINAPI SQLDescribeParam(
1694 SQLHSTMT hstmt,
1695 SQLUSMALLINT ipar,
1696 SQLSMALLINT *pfSqlType,
1697 SQLULEN *pcbParamDef,
1698 SQLSMALLINT *pibScale,
1699 SQLSMALLINT *pfNullable)
1700 {
1701 TRACE("\n");
1702
1703 if (!pSQLDescribeParam) return SQL_ERROR;
1704 return pSQLDescribeParam(hstmt, ipar, pfSqlType, pcbParamDef, pibScale, pfNullable);
1705 }
1706
1707
1708 /*************************************************************************
1709 * SQLExtendedFetch [ODBC32.059]
1710 */
1711 SQLRETURN WINAPI SQLExtendedFetch(
1712 SQLHSTMT hstmt,
1713 SQLUSMALLINT fFetchType,
1714 SQLINTEGER irow,
1715 SQLUINTEGER *pcrow,
1716 SQLUSMALLINT *rgfRowStatus)
1717 {
1718 TRACE("\n");
1719
1720 if (!pSQLExtendedFetch) return SQL_ERROR;
1721 return pSQLExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus);
1722 }
1723
1724
1725 /*************************************************************************
1726 * SQLForeignKeys [ODBC32.060]
1727 */
1728 SQLRETURN WINAPI SQLForeignKeys(
1729 SQLHSTMT hstmt,
1730 SQLCHAR *szPkCatalogName,
1731 SQLSMALLINT cbPkCatalogName,
1732 SQLCHAR *szPkSchemaName,
1733 SQLSMALLINT cbPkSchemaName,
1734 SQLCHAR *szPkTableName,
1735 SQLSMALLINT cbPkTableName,
1736 SQLCHAR *szFkCatalogName,
1737 SQLSMALLINT cbFkCatalogName,
1738 SQLCHAR *szFkSchemaName,
1739 SQLSMALLINT cbFkSchemaName,
1740 SQLCHAR *szFkTableName,
1741 SQLSMALLINT cbFkTableName)
1742 {
1743 TRACE("\n");
1744
1745 if (!pSQLForeignKeys) return SQL_ERROR;
1746 return pSQLForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
1747 szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
1748 szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
1749 }
1750
1751
1752 /*************************************************************************
1753 * SQLMoreResults [ODBC32.061]
1754 */
1755 SQLRETURN WINAPI SQLMoreResults(SQLHSTMT hstmt)
1756 {
1757 TRACE("\n");
1758
1759 if (!pSQLMoreResults) return SQL_ERROR;
1760 return pSQLMoreResults(hstmt);
1761 }
1762
1763
1764 /*************************************************************************
1765 * SQLNativeSql [ODBC32.062]
1766 */
1767 SQLRETURN WINAPI SQLNativeSql(
1768 SQLHDBC hdbc,
1769 SQLCHAR *szSqlStrIn,
1770 SQLINTEGER cbSqlStrIn,
1771 SQLCHAR *szSqlStr,
1772 SQLINTEGER cbSqlStrMax,
1773 SQLINTEGER *pcbSqlStr)
1774 {
1775 TRACE("\n");
1776
1777 if (!pSQLNativeSql) return SQL_ERROR;
1778 return pSQLNativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
1779 }
1780
1781
1782 /*************************************************************************
1783 * SQLNumParams [ODBC32.063]
1784 */
1785 SQLRETURN WINAPI SQLNumParams(
1786 SQLHSTMT hstmt,
1787 SQLSMALLINT *pcpar)
1788 {
1789 TRACE("\n");
1790
1791 if (!pSQLNumParams) return SQL_ERROR;
1792 return pSQLNumParams(hstmt, pcpar);
1793 }
1794
1795
1796 /*************************************************************************
1797 * SQLParamOptions [ODBC32.064]
1798 */
1799 SQLRETURN WINAPI SQLParamOptions(
1800 SQLHSTMT hstmt,
1801 SQLUINTEGER crow,
1802 SQLUINTEGER *pirow)
1803 {
1804 TRACE("\n");
1805
1806 if (!pSQLParamOptions) return SQL_ERROR;
1807 return pSQLParamOptions(hstmt, crow, pirow);
1808 }
1809
1810
1811 /*************************************************************************
1812 * SQLPrimaryKeys [ODBC32.065]
1813 */
1814 SQLRETURN WINAPI SQLPrimaryKeys(
1815 SQLHSTMT hstmt,
1816 SQLCHAR *szCatalogName,
1817 SQLSMALLINT cbCatalogName,
1818 SQLCHAR *szSchemaName,
1819 SQLSMALLINT cbSchemaName,
1820 SQLCHAR *szTableName,
1821 SQLSMALLINT cbTableName)
1822 {
1823 TRACE("\n");
1824
1825 if (!pSQLPrimaryKeys) return SQL_ERROR;
1826 return pSQLPrimaryKeys(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1827 szTableName, cbTableName);
1828 }
1829
1830
1831 /*************************************************************************
1832 * SQLProcedureColumns [ODBC32.066]
1833 */
1834 SQLRETURN WINAPI SQLProcedureColumns(
1835 SQLHSTMT hstmt,
1836 SQLCHAR *szCatalogName,
1837 SQLSMALLINT cbCatalogName,
1838 SQLCHAR *szSchemaName,
1839 SQLSMALLINT cbSchemaName,
1840 SQLCHAR *szProcName,
1841 SQLSMALLINT cbProcName,
1842 SQLCHAR *szColumnName,
1843 SQLSMALLINT cbColumnName)
1844 {
1845 TRACE("\n");
1846
1847 if (!pSQLProcedureColumns) return SQL_ERROR;
1848 return pSQLProcedureColumns(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1849 szProcName, cbProcName, szColumnName, cbColumnName);
1850 }
1851
1852
1853 /*************************************************************************
1854 * SQLProcedures [ODBC32.067]
1855 */
1856 SQLRETURN WINAPI SQLProcedures(
1857 SQLHSTMT hstmt,
1858 SQLCHAR *szCatalogName,
1859 SQLSMALLINT cbCatalogName,
1860 SQLCHAR *szSchemaName,
1861 SQLSMALLINT cbSchemaName,
1862 SQLCHAR *szProcName,
1863 SQLSMALLINT cbProcName)
1864 {
1865 TRACE("\n");
1866
1867 if (!pSQLProcedures) return SQL_ERROR;
1868 return pSQLProcedures(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1869 szProcName, cbProcName);
1870 }
1871
1872
1873 /*************************************************************************
1874 * SQLSetPos [ODBC32.068]
1875 */
1876 SQLRETURN WINAPI SQLSetPos(
1877 SQLHSTMT hstmt,
1878 SQLUSMALLINT irow,
1879 SQLUSMALLINT fOption,
1880 SQLUSMALLINT fLock)
1881 {
1882 TRACE("\n");
1883
1884 if (!pSQLSetPos) return SQL_ERROR;
1885 return pSQLSetPos(hstmt, irow, fOption, fLock);
1886 }
1887
1888
1889 /*************************************************************************
1890 * SQLTablePrivileges [ODBC32.070]
1891 */
1892 SQLRETURN WINAPI SQLTablePrivileges(
1893 SQLHSTMT hstmt,
1894 SQLCHAR *szCatalogName,
1895 SQLSMALLINT cbCatalogName,
1896 SQLCHAR *szSchemaName,
1897 SQLSMALLINT cbSchemaName,
1898 SQLCHAR *szTableName,
1899 SQLSMALLINT cbTableName)
1900 {
1901 TRACE("\n");
1902
1903 if (!pSQLTablePrivileges) return SQL_ERROR;
1904 return pSQLTablePrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1905 szTableName, cbTableName);
1906 }
1907
1908
1909 /*************************************************************************
1910 * SQLDrivers [ODBC32.071]
1911 */
1912 SQLRETURN WINAPI SQLDrivers(
1913 SQLHENV henv,
1914 SQLUSMALLINT fDirection,
1915 SQLCHAR *szDriverDesc,
1916 SQLSMALLINT cbDriverDescMax,
1917 SQLSMALLINT *pcbDriverDesc,
1918 SQLCHAR *szDriverAttributes,
1919 SQLSMALLINT cbDriverAttrMax,
1920 SQLSMALLINT *pcbDriverAttr)
1921 {
1922 TRACE("\n");
1923
1924 if (!pSQLDrivers) return SQL_ERROR;
1925 return pSQLDrivers(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
1926 szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
1927 }
1928
1929
1930 /*************************************************************************
1931 * SQLBindParameter [ODBC32.072]
1932 */
1933 SQLRETURN WINAPI SQLBindParameter(
1934 SQLHSTMT hstmt,
1935 SQLUSMALLINT ipar,
1936 SQLSMALLINT fParamType,
1937 SQLSMALLINT fCType,
1938 SQLSMALLINT fSqlType,
1939 SQLULEN cbColDef,
1940 SQLSMALLINT ibScale,
1941 SQLPOINTER rgbValue,
1942 SQLLEN cbValueMax,
1943 SQLLEN *pcbValue)
1944 {
1945 TRACE("\n");
1946
1947 if (!pSQLBindParameter) return SQL_ERROR;
1948 return pSQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale,
1949 rgbValue, cbValueMax, pcbValue);
1950 }
1951
1952
1953 /*************************************************************************
1954 * SQLDriverConnect [ODBC32.041]
1955 */
1956 SQLRETURN WINAPI SQLDriverConnect(
1957 SQLHDBC hdbc,
1958 SQLHWND hwnd,
1959 SQLCHAR *conn_str_in,
1960 SQLSMALLINT len_conn_str_in,
1961 SQLCHAR *conn_str_out,
1962 SQLSMALLINT conn_str_out_max,
1963 SQLSMALLINT *ptr_conn_str_out,
1964 SQLUSMALLINT driver_completion )
1965 {
1966 TRACE("\n");
1967
1968 if (!pSQLDriverConnect) return SQL_ERROR;
1969 return pSQLDriverConnect(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
1970 conn_str_out_max, ptr_conn_str_out, driver_completion);
1971 }
1972
1973
1974 /*************************************************************************
1975 * SQLSetScrollOptions [ODBC32.069]
1976 */
1977 SQLRETURN WINAPI SQLSetScrollOptions(
1978 SQLHSTMT statement_handle,
1979 SQLUSMALLINT f_concurrency,
1980 SQLLEN crow_keyset,
1981 SQLUSMALLINT crow_rowset )
1982 {
1983 TRACE("\n");
1984
1985 if (!pSQLSetScrollOptions) return SQL_ERROR;
1986 return pSQLSetScrollOptions(statement_handle, f_concurrency, crow_keyset, crow_rowset);
1987 }
1988
1989 static int SQLColAttributes_KnownStringAttribute(SQLUSMALLINT fDescType)
1990 {
1991 static const SQLUSMALLINT attrList[] =
1992 {
1993 SQL_COLUMN_OWNER_NAME,
1994 SQL_COLUMN_QUALIFIER_NAME,
1995 SQL_COLUMN_LABEL,
1996 SQL_COLUMN_NAME,
1997 SQL_COLUMN_TABLE_NAME,
1998 SQL_COLUMN_TYPE_NAME,
1999 SQL_DESC_BASE_COLUMN_NAME,
2000 SQL_DESC_BASE_TABLE_NAME,
2001 SQL_DESC_CATALOG_NAME,
2002 SQL_DESC_LABEL,
2003 SQL_DESC_LITERAL_PREFIX,
2004 SQL_DESC_LITERAL_SUFFIX,
2005 SQL_DESC_LOCAL_TYPE_NAME,
2006 SQL_DESC_NAME,
2007 SQL_DESC_SCHEMA_NAME,
2008 SQL_DESC_TABLE_NAME,
2009 SQL_DESC_TYPE_NAME,
2010 };
2011 unsigned int i;
2012
2013 for (i = 0; i < sizeof(attrList) / sizeof(SQLUSMALLINT); i++) {
2014 if (attrList[i] == fDescType) return 1;
2015 }
2016 return 0;
2017 }
2018
2019 /*************************************************************************
2020 * SQLColAttributesW [ODBC32.106]
2021 */
2022 SQLRETURN WINAPI SQLColAttributesW(
2023 SQLHSTMT hstmt,
2024 SQLUSMALLINT icol,
2025 SQLUSMALLINT fDescType,
2026 SQLPOINTER rgbDesc,
2027 SQLSMALLINT cbDescMax,
2028 SQLSMALLINT *pcbDesc,
2029 SQLLEN *pfDesc)
2030 {
2031 SQLRETURN iResult;
2032
2033 TRACE("hstmt=%p icol=%d fDescType=%d rgbDesc=%p cbDescMax=%d pcbDesc=%p pfDesc=%p\n",
2034 hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2035
2036 if (!pSQLColAttributesW) return SQL_ERROR;
2037
2038 iResult = pSQLColAttributesW(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2039 if (iResult == SQL_SUCCESS && rgbDesc != NULL && SQLColAttributes_KnownStringAttribute(fDescType)) {
2040 /*
2041 TRACE("Dumping values fetched via SQLColAttributesW:\n");
2042 TRACE(" Attribute name : %s\n", debugstr_w(rgbDesc));
2043 TRACE(" Declared length: %d\n", *pcbDesc);
2044 */
2045 if (*pcbDesc != lstrlenW(rgbDesc) * 2) {
2046 TRACE("CHEAT: resetting name length for ADO\n");
2047 *pcbDesc = lstrlenW(rgbDesc) * 2;
2048 }
2049 }
2050 return iResult;
2051 }
2052
2053 /*************************************************************************
2054 * SQLConnectW [ODBC32.107]
2055 */
2056 SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle,
2057 WCHAR *ServerName, SQLSMALLINT NameLength1,
2058 WCHAR *UserName, SQLSMALLINT NameLength2,
2059 WCHAR *Authentication, SQLSMALLINT NameLength3)
2060 {
2061 SQLRETURN ret;
2062 TRACE("(Server=%.*s)\n",NameLength1+3, debugstr_w(ServerName));
2063
2064 if (!pSQLConnectW) return SQL_ERROR;
2065
2066 ret = pSQLConnectW(ConnectionHandle, ServerName, NameLength1,
2067 UserName, NameLength2, Authentication, NameLength3);
2068
2069 TRACE("returns %d\n",ret);
2070 return ret;
2071 }
2072
2073 /*************************************************************************
2074 * SQLDescribeColW [ODBC32.108]
2075 */
2076 SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle,
2077 SQLUSMALLINT ColumnNumber, WCHAR *ColumnName,
2078 SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
2079 SQLSMALLINT *DataType, SQLULEN *ColumnSize,
2080 SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
2081 {
2082 SQLRETURN iResult;
2083 TRACE("\n");
2084
2085 if (!pSQLDescribeColW) return SQL_ERROR;
2086
2087 iResult = pSQLDescribeColW(StatementHandle, ColumnNumber, ColumnName,
2088 BufferLength, NameLength, DataType, ColumnSize,
2089 DecimalDigits, Nullable);
2090 if (iResult >= 0) {
2091 TRACE("Successfully recovered the following column information:\n");
2092 TRACE("\tRequested column index: %d\n", ColumnNumber);
2093 TRACE("\tAvailable length for column name: %d\n", BufferLength);
2094 if (NameLength != NULL)
2095 TRACE("\tActual length for column name: %d\n", *NameLength);
2096 else TRACE("\tActual length for column name: (null)\n");
2097 TRACE("\tReturned column name: %s\n", debugstr_w(ColumnName));
2098 }
2099 return iResult;
2100 }
2101
2102 /*************************************************************************
2103 * SQLErrorW [ODBC32.110]
2104 */
2105 SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle,
2106 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
2107 WCHAR *Sqlstate, SQLINTEGER *NativeError,
2108 WCHAR *MessageText, SQLSMALLINT BufferLength,
2109 SQLSMALLINT *TextLength)
2110 {
2111 TRACE("\n");
2112
2113 if (!pSQLErrorW) return SQL_ERROR;
2114 return pSQLErrorW(EnvironmentHandle, ConnectionHandle, StatementHandle,
2115 Sqlstate, NativeError, MessageText, BufferLength, TextLength);
2116 }
2117
2118 /*************************************************************************
2119 * SQLExecDirectW [ODBC32.111]
2120 */
2121 SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle,
2122 WCHAR *StatementText, SQLINTEGER TextLength)
2123 {
2124 TRACE("\n");
2125
2126 if (!pSQLExecDirectW) return SQL_ERROR;
2127 return pSQLExecDirectW(StatementHandle, StatementText, TextLength);
2128 }
2129
2130 /*************************************************************************
2131 * SQLGetCursorNameW [ODBC32.117]
2132 */
2133 SQLRETURN WINAPI SQLGetCursorNameW(SQLHSTMT StatementHandle,
2134 WCHAR *CursorName, SQLSMALLINT BufferLength,
2135 SQLSMALLINT *NameLength)
2136 {
2137 TRACE("\n");
2138
2139 if (!pSQLGetCursorNameW) return SQL_ERROR;
2140 return pSQLGetCursorNameW(StatementHandle, CursorName, BufferLength, NameLength);
2141 }
2142
2143 /*************************************************************************
2144 * SQLPrepareW [ODBC32.119]
2145 */
2146 SQLRETURN WINAPI SQLPrepareW(SQLHSTMT StatementHandle,
2147 WCHAR *StatementText, SQLINTEGER TextLength)
2148 {
2149 TRACE("\n");
2150
2151 if (!pSQLPrepareW) return SQL_ERROR;
2152 return pSQLPrepareW(StatementHandle, StatementText, TextLength);
2153 }
2154
2155 /*************************************************************************
2156 * SQLSetCursorNameW [ODBC32.121]
2157 */
2158 SQLRETURN WINAPI SQLSetCursorNameW(SQLHSTMT StatementHandle, WCHAR *CursorName, SQLSMALLINT NameLength)
2159 {
2160 TRACE("\n");
2161
2162 if (!pSQLSetCursorNameW) return SQL_ERROR;
2163 return pSQLSetCursorNameW(StatementHandle, CursorName, NameLength);
2164 }
2165
2166 /*************************************************************************
2167 * SQLColAttributeW [ODBC32.127]
2168 */
2169 SQLRETURN WINAPI SQLColAttributeW (SQLHSTMT StatementHandle,
2170 SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
2171 SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
2172 SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute)
2173 {
2174 SQLRETURN iResult;
2175
2176 TRACE("StatementHandle=%p ColumnNumber=%d FieldIdentifier=%d CharacterAttribute=%p BufferLength=%d StringLength=%p NumericAttribute=%p\n",
2177 StatementHandle, ColumnNumber, FieldIdentifier,
2178 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2179
2180 if (!pSQLColAttributeW) return SQL_ERROR;
2181
2182 iResult = pSQLColAttributeW(StatementHandle, ColumnNumber, FieldIdentifier,
2183 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2184 if (iResult == SQL_SUCCESS && CharacterAttribute != NULL && SQLColAttributes_KnownStringAttribute(FieldIdentifier)) {
2185 /*
2186 TRACE("Dumping values fetched via SQLColAttributeW:\n");
2187 TRACE(" Attribute name : %s\n", debugstr_w(rgbDesc));
2188 TRACE(" Declared length: %d\n", *pcbDesc);
2189 */
2190 if (*StringLength != lstrlenW(CharacterAttribute) * 2) {
2191 TRACE("CHEAT: resetting name length for ADO\n");
2192 *StringLength = lstrlenW(CharacterAttribute) * 2;
2193 }
2194 }
2195 return iResult;
2196 }
2197
2198 /*************************************************************************
2199 * SQLGetConnectAttrW [ODBC32.132]
2200 */
2201 SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle,
2202 SQLINTEGER Attribute, SQLPOINTER Value,
2203 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
2204 {
2205 TRACE("\n");
2206
2207 if (!pSQLGetConnectAttrW) return SQL_ERROR;
2208 return pSQLGetConnectAttrW(ConnectionHandle, Attribute, Value,
2209 BufferLength, StringLength);
2210 }
2211
2212 /*************************************************************************
2213 * SQLGetDescFieldW [ODBC32.133]
2214 */
2215 SQLRETURN WINAPI SQLGetDescFieldW(SQLHDESC DescriptorHandle,
2216 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
2217 SQLPOINTER Value, SQLINTEGER BufferLength,
2218 SQLINTEGER *StringLength)
2219 {
2220 TRACE("\n");
2221
2222 if (!pSQLGetDescFieldW) return SQL_ERROR;
2223 return pSQLGetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier,
2224 Value, BufferLength, StringLength);
2225 }
2226
2227 /*************************************************************************
2228 * SQLGetDescRecW [ODBC32.134]
2229 */
2230 SQLRETURN WINAPI SQLGetDescRecW(SQLHDESC DescriptorHandle,
2231 SQLSMALLINT RecNumber, WCHAR *Name,
2232 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
2233 SQLSMALLINT *Type, SQLSMALLINT *SubType,
2234 SQLLEN *Length, SQLSMALLINT *Precision,
2235 SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
2236 {
2237 TRACE("\n");
2238
2239 if (!pSQLGetDescRecW) return SQL_ERROR;
2240 return pSQLGetDescRecW(DescriptorHandle, RecNumber, Name, BufferLength,
2241 StringLength, Type, SubType, Length, Precision, Scale, Nullable);
2242 }
2243
2244 /*************************************************************************
2245 * SQLGetDiagFieldW [ODBC32.135]
2246 */
2247 SQLRETURN WINAPI SQLGetDiagFieldW(SQLSMALLINT HandleType, SQLHANDLE Handle,
2248 SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
2249 SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
2250 SQLSMALLINT *StringLength)
2251 {
2252 TRACE("\n");
2253
2254 if (!pSQLGetDiagFieldW) return SQL_ERROR;
2255 return pSQLGetDiagFieldW(HandleType, Handle, RecNumber, DiagIdentifier,
2256 DiagInfo, BufferLength, StringLength);
2257 }
2258
2259 /*************************************************************************
2260 * SQLGetDiagRecW [ODBC32.136]
2261 */
2262 SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle,
2263 SQLSMALLINT RecNumber, WCHAR *Sqlstate,
2264 SQLINTEGER *NativeError, WCHAR *MessageText,
2265 SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
2266 {
2267 TRACE("\n");
2268
2269 if (!pSQLGetDiagRecW) return SQL_ERROR;
2270 return pSQLGetDiagRecW(HandleType, Handle, RecNumber, Sqlstate, NativeError,
2271 MessageText, BufferLength, TextLength);
2272 }
2273
2274 /*************************************************************************
2275 * SQLGetStmtAttrW [ODBC32.138]
2276 */
2277 SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle,
2278 SQLINTEGER Attribute, SQLPOINTER Value,
2279 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
2280 {
2281 SQLRETURN iResult;
2282
2283 TRACE("Attribute = (%02d) Value = %p BufferLength = (%d) StringLength = %p\n",
2284 Attribute, Value, BufferLength, StringLength);
2285
2286 if (Value == NULL) {
2287 WARN("Unexpected NULL in Value return address\n");
2288 iResult = SQL_ERROR;
2289 /*
2290 } else if (StringLength == NULL) {
2291 WARN("Unexpected NULL in StringLength return address\n");
2292 iResult = SQL_ERROR;
2293 */
2294 } else {
2295 if (!pSQLGetStmtAttrW) return SQL_ERROR;
2296 iResult = pSQLGetStmtAttrW(StatementHandle, Attribute, Value, BufferLength, StringLength);
2297 TRACE("returning %d...\n", iResult);
2298 }
2299 return iResult;
2300 }
2301
2302 /*************************************************************************
2303 * SQLSetConnectAttrW [ODBC32.139]
2304 */
2305 SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
2306 SQLPOINTER Value, SQLINTEGER StringLength)
2307 {
2308 TRACE("\n");
2309
2310 if (!pSQLSetConnectAttrW) return SQL_ERROR;
2311 return pSQLSetConnectAttrW(ConnectionHandle, Attribute, Value, StringLength);
2312 }
2313
2314 /*************************************************************************
2315 * SQLColumnsW [ODBC32.140]
2316 */
2317 SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle,
2318 WCHAR *CatalogName, SQLSMALLINT NameLength1,
2319 WCHAR *SchemaName, SQLSMALLINT NameLength2,
2320 WCHAR *TableName, SQLSMALLINT NameLength3,
2321 WCHAR *ColumnName, SQLSMALLINT NameLength4)
2322 {
2323 TRACE("\n");
2324
2325 if (!pSQLColumnsW) return SQL_ERROR;
2326 return pSQLColumnsW(StatementHandle, CatalogName, NameLength1,
2327 SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
2328 }
2329
2330 /*************************************************************************
2331 * SQLDriverConnectW [ODBC32.141]
2332 */
2333 SQLRETURN WINAPI SQLDriverConnectW(
2334 SQLHDBC hdbc,
2335 SQLHWND hwnd,
2336 WCHAR *conn_str_in,
2337 SQLSMALLINT len_conn_str_in,
2338 WCHAR *conn_str_out,
2339 SQLSMALLINT conn_str_out_max,
2340 SQLSMALLINT *ptr_conn_str_out,
2341 SQLUSMALLINT driver_completion )
2342 {
2343 TRACE("ConnStrIn (%d bytes) --> %s\n", len_conn_str_in, debugstr_w(conn_str_in));
2344
2345 if (!pSQLDriverConnectW) return SQL_ERROR;
2346 return pSQLDriverConnectW(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
2347 conn_str_out_max, ptr_conn_str_out, driver_completion);
2348 }
2349
2350 /*************************************************************************
2351 * SQLGetConnectOptionW [ODBC32.142]
2352 */
2353 SQLRETURN WINAPI SQLGetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
2354 {
2355 TRACE("\n");
2356
2357 if (!pSQLGetConnectOptionW) return SQL_ERROR;
2358 return pSQLGetConnectOptionW(ConnectionHandle, Option, Value);
2359 }
2360
2361 /*************************************************************************
2362 * SQLGetInfoW [ODBC32.145]
2363 */
2364 SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle,
2365 SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
2366 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
2367 {
2368 SQLRETURN iResult;
2369
2370 TRACE("InfoType = (%02u), InfoValue = %p, BufferLength = %d bytes\n", InfoType, InfoValue, BufferLength);
2371 if (InfoValue == NULL) {
2372 WARN("Unexpected NULL in InfoValue address\n");
2373 iResult = SQL_ERROR;
2374 } else {
2375 if (!pSQLGetInfoW) return SQL_ERROR;
2376 iResult = pSQLGetInfoW(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
2377 TRACE("returning %d...\n", iResult);
2378 }
2379 return iResult;
2380 }
2381
2382 /*************************************************************************
2383 * SQLGetTypeInfoW [ODBC32.147]
2384 */
2385 SQLRETURN WINAPI SQLGetTypeInfoW(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
2386 {
2387 TRACE("\n");
2388
2389 if (!pSQLGetTypeInfoW) return SQL_ERROR;
2390 return pSQLGetTypeInfoW(StatementHandle, DataType);
2391 }
2392
2393 /*************************************************************************
2394 * SQLSetConnectOptionW [ODBC32.150]
2395 */
2396 SQLRETURN WINAPI SQLSetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLULEN Value)
2397 {
2398 TRACE("\n");
2399
2400 if (!pSQLSetConnectOptionW) return SQL_ERROR;
2401 return pSQLSetConnectOptionW(ConnectionHandle, Option, Value);
2402 }
2403
2404 /*************************************************************************
2405 * SQLSpecialColumnsW [ODBC32.152]
2406 */
2407 SQLRETURN WINAPI SQLSpecialColumnsW(SQLHSTMT StatementHandle,
2408 SQLUSMALLINT IdentifierType, SQLWCHAR *CatalogName,
2409 SQLSMALLINT NameLength1, SQLWCHAR *SchemaName,
2410 SQLSMALLINT NameLength2, SQLWCHAR *TableName,
2411 SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
2412 SQLUSMALLINT Nullable)
2413 {
2414 if (!pSQLSpecialColumnsW) return SQL_ERROR;
2415 return pSQLSpecialColumnsW(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
2416 NameLength2, TableName, NameLength3, Scope, Nullable);
2417 }
2418
2419 /*************************************************************************
2420 * SQLStatisticsW [ODBC32.153]
2421 */
2422 SQLRETURN WINAPI SQLStatisticsW(SQLHSTMT StatementHandle,
2423 SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
2424 SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
2425 SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2426 SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
2427 {
2428 TRACE("\n");
2429
2430 if (!pSQLStatisticsW) return SQL_ERROR;
2431 return pSQLStatisticsW(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
2432 TableName, NameLength3, Unique, Reserved);
2433 }
2434
2435 /*************************************************************************
2436 * SQLTablesW [ODBC32.154]
2437 */
2438 SQLRETURN WINAPI SQLTablesW(SQLHSTMT StatementHandle,
2439 SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
2440 SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
2441 SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2442 SQLWCHAR *TableType, SQLSMALLINT NameLength4)
2443 {
2444 TRACE("\n");
2445
2446 if (!pSQLTablesW) return SQL_ERROR;
2447 return pSQLTablesW(StatementHandle, CatalogName, NameLength1,
2448 SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
2449 }
2450
2451 /*************************************************************************
2452 * SQLBrowseConnectW [ODBC32.155]
2453 */
2454 SQLRETURN WINAPI SQLBrowseConnectW(
2455 SQLHDBC hdbc,
2456 SQLWCHAR *szConnStrIn,
2457 SQLSMALLINT cbConnStrIn,
2458 SQLWCHAR *szConnStrOut,
2459 SQLSMALLINT cbConnStrOutMax,
2460 SQLSMALLINT *pcbConnStrOut)
2461 {
2462 TRACE("\n");
2463
2464 if (!pSQLBrowseConnectW) return SQL_ERROR;
2465 return pSQLBrowseConnectW(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut,
2466 cbConnStrOutMax, pcbConnStrOut);
2467 }
2468
2469 /*************************************************************************
2470 * SQLColumnPrivilegesW [ODBC32.156]
2471 */
2472 SQLRETURN WINAPI SQLColumnPrivilegesW(
2473 SQLHSTMT hstmt,
2474 SQLWCHAR *szCatalogName,
2475 SQLSMALLINT cbCatalogName,
2476 SQLWCHAR *szSchemaName,
2477 SQLSMALLINT cbSchemaName,
2478 SQLWCHAR *szTableName,
2479 SQLSMALLINT cbTableName,
2480 SQLWCHAR *szColumnName,
2481 SQLSMALLINT cbColumnName)
2482 {
2483 TRACE("\n");
2484
2485 if (!pSQLColumnPrivilegesW) return SQL_ERROR;
2486 return pSQLColumnPrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2487 szTableName, cbTableName, szColumnName, cbColumnName);
2488 }
2489
2490 /*************************************************************************
2491 * SQLDataSourcesW [ODBC32.157]
2492 */
2493 SQLRETURN WINAPI SQLDataSourcesW(SQLHENV EnvironmentHandle,
2494 SQLUSMALLINT Direction, WCHAR *ServerName,
2495 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
2496 WCHAR *Description, SQLSMALLINT BufferLength2,
2497 SQLSMALLINT *NameLength2)
2498 {
2499 SQLRETURN ret;
2500
2501 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
2502
2503 if (!pSQLDataSourcesW) return SQL_ERROR;
2504
2505 ret = pSQLDataSourcesW(EnvironmentHandle, Direction, ServerName,
2506 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
2507
2508 if (TRACE_ON(odbc))
2509 {
2510 TRACE("returns: %d \t", ret);
2511 if (*NameLength1 > 0)
2512 TRACE("DataSource = %s,", debugstr_w(ServerName));
2513 if (*NameLength2 > 0)
2514 TRACE(" Description = %s", debugstr_w(Description));
2515 TRACE("\n");
2516 }
2517
2518 return ret;
2519 }
2520
2521 /*************************************************************************
2522 * SQLForeignKeysW [ODBC32.160]
2523 */
2524 SQLRETURN WINAPI SQLForeignKeysW(
2525 SQLHSTMT hstmt,
2526 SQLWCHAR *szPkCatalogName,
2527 SQLSMALLINT cbPkCatalogName,
2528 SQLWCHAR *szPkSchemaName,
2529 SQLSMALLINT cbPkSchemaName,
2530 SQLWCHAR *szPkTableName,
2531 SQLSMALLINT cbPkTableName,
2532 SQLWCHAR *szFkCatalogName,
2533 SQLSMALLINT cbFkCatalogName,
2534 SQLWCHAR *szFkSchemaName,
2535 SQLSMALLINT cbFkSchemaName,
2536 SQLWCHAR *szFkTableName,
2537 SQLSMALLINT cbFkTableName)
2538 {
2539 TRACE("\n");
2540
2541 if (!pSQLForeignKeysW) return SQL_ERROR;
2542 return pSQLForeignKeysW(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
2543 szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
2544 szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
2545 }
2546
2547 /*************************************************************************
2548 * SQLNativeSqlW [ODBC32.162]
2549 */
2550 SQLRETURN WINAPI SQLNativeSqlW(
2551 SQLHDBC hdbc,
2552 SQLWCHAR *szSqlStrIn,
2553 SQLINTEGER cbSqlStrIn,
2554 SQLWCHAR *szSqlStr,
2555 SQLINTEGER cbSqlStrMax,
2556 SQLINTEGER *pcbSqlStr)
2557 {
2558 TRACE("\n");
2559
2560 if (!pSQLNativeSqlW) return SQL_ERROR;
2561 return pSQLNativeSqlW(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
2562 }
2563
2564 /*************************************************************************
2565 * SQLPrimaryKeysW [ODBC32.165]
2566 */
2567 SQLRETURN WINAPI SQLPrimaryKeysW(
2568 SQLHSTMT hstmt,
2569 SQLWCHAR *szCatalogName,
2570 SQLSMALLINT cbCatalogName,
2571 SQLWCHAR *szSchemaName,
2572 SQLSMALLINT cbSchemaName,
2573 SQLWCHAR *szTableName,
2574 SQLSMALLINT cbTableName)
2575 {
2576 TRACE("\n");
2577
2578 if (!pSQLPrimaryKeysW) return SQL_ERROR;
2579 return pSQLPrimaryKeysW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2580 szTableName, cbTableName);
2581 }
2582
2583 /*************************************************************************
2584 * SQLProcedureColumnsW [ODBC32.166]
2585 */
2586 SQLRETURN WINAPI SQLProcedureColumnsW(
2587 SQLHSTMT hstmt,
2588 SQLWCHAR *szCatalogName,
2589 SQLSMALLINT cbCatalogName,
2590 SQLWCHAR *szSchemaName,
2591 SQLSMALLINT cbSchemaName,
2592 SQLWCHAR *szProcName,
2593 SQLSMALLINT cbProcName,
2594 SQLWCHAR *szColumnName,
2595 SQLSMALLINT cbColumnName)
2596 {
2597 TRACE("\n");
2598
2599 if (!pSQLProcedureColumnsW) return SQL_ERROR;
2600 return pSQLProcedureColumnsW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2601 szProcName, cbProcName, szColumnName, cbColumnName);
2602 }
2603
2604 /*************************************************************************
2605 * SQLProceduresW [ODBC32.167]
2606 */
2607 SQLRETURN WINAPI SQLProceduresW(
2608 SQLHSTMT hstmt,
2609 SQLWCHAR *szCatalogName,
2610 SQLSMALLINT cbCatalogName,
2611 SQLWCHAR *szSchemaName,
2612 SQLSMALLINT cbSchemaName,
2613 SQLWCHAR *szProcName,
2614 SQLSMALLINT cbProcName)
2615 {
2616 TRACE("\n");
2617
2618 if (!pSQLProceduresW) return SQL_ERROR;
2619 return pSQLProceduresW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2620 szProcName, cbProcName);
2621 }
2622
2623 /*************************************************************************
2624 * SQLTablePrivilegesW [ODBC32.170]
2625 */
2626 SQLRETURN WINAPI SQLTablePrivilegesW(
2627 SQLHSTMT hstmt,
2628 SQLWCHAR *szCatalogName,
2629 SQLSMALLINT cbCatalogName,
2630 SQLWCHAR *szSchemaName,
2631 SQLSMALLINT cbSchemaName,
2632 SQLWCHAR *szTableName,
2633 SQLSMALLINT cbTableName)
2634 {
2635 TRACE("\n");
2636
2637 if (!pSQLTablePrivilegesW) return SQL_ERROR;
2638 return pSQLTablePrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2639 szTableName, cbTableName);
2640 }
2641
2642 /*************************************************************************
2643 * SQLDriversW [ODBC32.171]
2644 */
2645 SQLRETURN WINAPI SQLDriversW(
2646 SQLHENV henv,
2647 SQLUSMALLINT fDirection,
2648 SQLWCHAR *szDriverDesc,
2649 SQLSMALLINT cbDriverDescMax,
2650 SQLSMALLINT *pcbDriverDesc,
2651 SQLWCHAR *szDriverAttributes,
2652 SQLSMALLINT cbDriverAttrMax,
2653 SQLSMALLINT *pcbDriverAttr)
2654 {
2655 TRACE("\n");
2656
2657 if (!pSQLDriversW) return SQL_ERROR;
2658 return pSQLDriversW(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
2659 szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
2660 }
2661
2662 /*************************************************************************
2663 * SQLSetDescFieldW [ODBC32.173]
2664 */
2665 SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle,
2666 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
2667 SQLPOINTER Value, SQLINTEGER BufferLength)
2668 {
2669 TRACE("\n");
2670
2671 if (!pSQLSetDescFieldW) return SQL_ERROR;
2672 return pSQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
2673 }
2674
2675 /*************************************************************************
2676 * SQLSetStmtAttrW [ODBC32.176]
2677 */
2678 SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle,
2679 SQLINTEGER Attribute, SQLPOINTER Value,
2680 SQLINTEGER StringLength)
2681 {
2682 SQLRETURN iResult;
2683 TRACE("Attribute = (%02d) Value = %p StringLength = (%d)\n",
2684 Attribute, Value, StringLength);
2685
2686 if (!pSQLSetStmtAttrW) return SQL_ERROR;
2687 iResult = pSQLSetStmtAttrW(StatementHandle, Attribute, Value, StringLength);
2688 if (iResult == SQL_ERROR && (Attribute == SQL_ROWSET_SIZE || Attribute == SQL_ATTR_ROW_ARRAY_SIZE)) {
2689 TRACE("CHEAT: returning SQL_SUCCESS to ADO...\n");
2690 iResult = SQL_SUCCESS;
2691 } else {
2692 TRACE("returning %d...\n", iResult);
2693 }
2694 return iResult;
2695 }
2696
2697
2698 /* End of file */