usp10/tests: Add an itemisation test for Arabic numerals and punctuation.
[wine.git] / dlls / odbc32 / proxyodbc.c
blobd7ebf10ca8eeb6db9e7227ed5660cebfce5bab3b
1 /*
2 * Win32 ODBC functions
4 * Copyright 1999 Xiang Li, Corel Corporation
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.
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.
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
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.
28 #include "config.h"
29 #include "wine/port.h"
31 #include <stdarg.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <assert.h>
37 #include "windef.h"
38 #include "winbase.h"
39 #include "winreg.h"
40 #include "wine/debug.h"
41 #include "wine/library.h"
42 #include "wine/unicode.h"
44 #include "sql.h"
45 #include "sqltypes.h"
46 #include "sqlext.h"
48 static BOOL ODBC_LoadDriverManager(void);
49 static BOOL ODBC_LoadDMFunctions(void);
51 WINE_DEFAULT_DEBUG_CHANNEL(odbc);
52 WINE_DECLARE_DEBUG_CHANNEL(winediag);
54 static SQLRETURN (*pSQLAllocConnect)(SQLHENV,SQLHDBC*);
55 static SQLRETURN (*pSQLAllocEnv)(SQLHENV*);
56 static SQLRETURN (*pSQLAllocHandle)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
57 static SQLRETURN (*pSQLAllocHandleStd)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
58 static SQLRETURN (*pSQLAllocStmt)(SQLHDBC,SQLHSTMT*);
59 static SQLRETURN (*pSQLBindCol)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLLEN*);
60 static SQLRETURN (*pSQLBindParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*);
61 static SQLRETURN (*pSQLBindParameter)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
62 static SQLRETURN (*pSQLBrowseConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
63 static SQLRETURN (*pSQLBrowseConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
64 static SQLRETURN (*pSQLBulkOperations)(SQLHSTMT,SQLSMALLINT);
65 static SQLRETURN (*pSQLCancel)(SQLHSTMT);
66 static SQLRETURN (*pSQLCloseCursor)(SQLHSTMT);
67 static SQLRETURN (*pSQLColAttribute)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
68 static SQLRETURN (*pSQLColAttributeW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
69 static SQLRETURN (*pSQLColAttributes)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLINTEGER*);
70 static SQLRETURN (*pSQLColAttributesW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
71 static SQLRETURN (*pSQLColumnPrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
72 static SQLRETURN (*pSQLColumnPrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
73 static SQLRETURN (*pSQLColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
74 static SQLRETURN (*pSQLColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
75 static SQLRETURN (*pSQLConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
76 static SQLRETURN (*pSQLConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
77 static SQLRETURN (*pSQLCopyDesc)(SQLHDESC,SQLHDESC);
78 static SQLRETURN (*pSQLDataSources)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
79 static SQLRETURN (*pSQLDataSourcesA)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
80 static SQLRETURN (*pSQLDataSourcesW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
81 static SQLRETURN (*pSQLDescribeCol)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*);
82 static SQLRETURN (*pSQLDescribeColW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
83 static SQLRETURN (*pSQLDescribeParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*);
84 static SQLRETURN (*pSQLDisconnect)(SQLHDBC);
85 static SQLRETURN (*pSQLDriverConnect)(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
86 static SQLRETURN (*pSQLDriverConnectW)(SQLHDBC,SQLHWND,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
87 static SQLRETURN (*pSQLDrivers)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
88 static SQLRETURN (*pSQLDriversW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
89 static SQLRETURN (*pSQLEndTran)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT);
90 static SQLRETURN (*pSQLError)(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
91 static SQLRETURN (*pSQLErrorW)(SQLHENV,SQLHDBC,SQLHSTMT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
92 static SQLRETURN (*pSQLExecDirect)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
93 static SQLRETURN (*pSQLExecDirectW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
94 static SQLRETURN (*pSQLExecute)(SQLHSTMT);
95 static SQLRETURN (*pSQLExtendedFetch)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUINTEGER*,SQLUSMALLINT*);
96 static SQLRETURN (*pSQLFetch)(SQLHSTMT);
97 static SQLRETURN (*pSQLFetchScroll)(SQLHSTMT,SQLSMALLINT,SQLINTEGER);
98 static SQLRETURN (*pSQLForeignKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
99 static SQLRETURN (*pSQLForeignKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
100 static SQLRETURN (*pSQLFreeConnect)(SQLHDBC);
101 static SQLRETURN (*pSQLFreeEnv)(SQLHENV);
102 static SQLRETURN (*pSQLFreeHandle)(SQLSMALLINT,SQLHANDLE);
103 static SQLRETURN (*pSQLFreeStmt)(SQLHSTMT,SQLUSMALLINT);
104 static SQLRETURN (*pSQLGetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
105 static SQLRETURN (*pSQLGetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
106 static SQLRETURN (*pSQLGetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
107 static SQLRETURN (*pSQLGetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
108 static SQLRETURN (*pSQLGetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
109 static SQLRETURN (*pSQLGetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
110 static SQLRETURN (*pSQLGetData)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
111 static SQLRETURN (*pSQLGetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
112 static SQLRETURN (*pSQLGetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
113 static SQLRETURN (*pSQLGetDescRec)(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLINTEGER*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
114 static SQLRETURN (*pSQLGetDescRecW)(SQLHDESC,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
115 static SQLRETURN (*pSQLGetDiagField)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
116 static SQLRETURN (*pSQLGetDiagFieldW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
117 static SQLRETURN (*pSQLGetDiagRec)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
118 static SQLRETURN (*pSQLGetDiagRecW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
119 static SQLRETURN (*pSQLGetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
120 static SQLRETURN (*pSQLGetFunctions)(SQLHDBC,SQLUSMALLINT,SQLUSMALLINT*);
121 static SQLRETURN (*pSQLGetInfo)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
122 static SQLRETURN (*pSQLGetInfoW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
123 static SQLRETURN (*pSQLGetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
124 static SQLRETURN (*pSQLGetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
125 static SQLRETURN (*pSQLGetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLPOINTER);
126 static SQLRETURN (*pSQLGetTypeInfo)(SQLHSTMT,SQLSMALLINT);
127 static SQLRETURN (*pSQLGetTypeInfoW)(SQLHSTMT,SQLSMALLINT);
128 static SQLRETURN (*pSQLMoreResults)(SQLHSTMT);
129 static SQLRETURN (*pSQLNativeSql)(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*);
130 static SQLRETURN (*pSQLNativeSqlW)(SQLHDBC,SQLWCHAR*,SQLINTEGER,SQLWCHAR*,SQLINTEGER,SQLINTEGER*);
131 static SQLRETURN (*pSQLNumParams)(SQLHSTMT,SQLSMALLINT*);
132 static SQLRETURN (*pSQLNumResultCols)(SQLHSTMT,SQLSMALLINT*);
133 static SQLRETURN (*pSQLParamData)(SQLHSTMT,SQLPOINTER*);
134 static SQLRETURN (*pSQLParamOptions)(SQLHSTMT,SQLUINTEGER,SQLUINTEGER*);
135 static SQLRETURN (*pSQLPrepare)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
136 static SQLRETURN (*pSQLPrepareW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
137 static SQLRETURN (*pSQLPrimaryKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
138 static SQLRETURN (*pSQLPrimaryKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
139 static SQLRETURN (*pSQLProcedureColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
140 static SQLRETURN (*pSQLProcedureColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
141 static SQLRETURN (*pSQLProcedures)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
142 static SQLRETURN (*pSQLProceduresW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
143 static SQLRETURN (*pSQLPutData)(SQLHSTMT,SQLPOINTER,SQLINTEGER);
144 static SQLRETURN (*pSQLRowCount)(SQLHSTMT,SQLINTEGER*);
145 static SQLRETURN (*pSQLSetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
146 static SQLRETURN (*pSQLSetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
147 static SQLRETURN (*pSQLSetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLUINTEGER);
148 static SQLRETURN (*pSQLSetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLULEN);
149 static SQLRETURN (*pSQLSetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT);
150 static SQLRETURN (*pSQLSetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT);
151 static SQLRETURN (*pSQLSetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
152 static SQLRETURN (*pSQLSetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
153 static SQLRETURN (*pSQLSetDescRec)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLINTEGER,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER*,SQLINTEGER*);
154 static SQLRETURN (*pSQLSetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER);
155 static SQLRETURN (*pSQLSetParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*);
156 static SQLRETURN (*pSQLSetPos)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
157 static SQLRETURN (*pSQLSetScrollOptions)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUSMALLINT);
158 static SQLRETURN (*pSQLSetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
159 static SQLRETURN (*pSQLSetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
160 static SQLRETURN (*pSQLSetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLUINTEGER);
161 static SQLRETURN (*pSQLSpecialColumns)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
162 static SQLRETURN (*pSQLSpecialColumnsW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
163 static SQLRETURN (*pSQLStatistics)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
164 static SQLRETURN (*pSQLStatisticsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
165 static SQLRETURN (*pSQLTablePrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
166 static SQLRETURN (*pSQLTablePrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
167 static SQLRETURN (*pSQLTables)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
168 static SQLRETURN (*pSQLTablesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
169 static SQLRETURN (*pSQLTransact)(SQLHENV,SQLHDBC,SQLUSMALLINT);
171 #define ERROR_FREE 0
172 #define ERROR_SQLERROR 1
173 #define ERROR_LIBRARY_NOT_FOUND 2
175 static void *dmHandle;
176 static int nErrorType;
178 /***********************************************************************
179 * ODBC_ReplicateODBCInstToRegistry
181 * PARAMS
183 * RETURNS
185 * Utility to ODBC_ReplicateToRegistry to replicate the drivers of the
186 * ODBCINST.INI settings
188 * The driver settings are not replicated to the registry. If we were to
189 * replicate them we would need to decide whether to replicate all settings
190 * or to do some translation; whether to remove any entries present only in
191 * the windows registry, etc.
194 static void ODBC_ReplicateODBCInstToRegistry (SQLHENV hEnv)
196 HKEY hODBCInst;
197 LONG reg_ret;
198 BOOL success;
200 success = FALSE;
201 TRACE ("Driver settings are not currently replicated to the registry\n");
202 if ((reg_ret = RegCreateKeyExA (HKEY_LOCAL_MACHINE,
203 "Software\\ODBC\\ODBCINST.INI", 0, NULL,
204 REG_OPTION_NON_VOLATILE,
205 KEY_ALL_ACCESS /* a couple more than we need */, NULL,
206 &hODBCInst, NULL)) == ERROR_SUCCESS)
208 HKEY hDrivers;
209 if ((reg_ret = RegCreateKeyExA (hODBCInst, "ODBC Drivers", 0,
210 NULL, REG_OPTION_NON_VOLATILE,
211 KEY_ALL_ACCESS /* overkill */, NULL, &hDrivers, NULL))
212 == ERROR_SUCCESS)
214 SQLRETURN sql_ret;
215 SQLUSMALLINT dirn;
216 CHAR desc [256];
217 SQLSMALLINT sizedesc;
219 success = TRUE;
220 dirn = SQL_FETCH_FIRST;
221 while ((sql_ret = SQLDrivers (hEnv, dirn, (SQLCHAR*)desc, sizeof(desc),
222 &sizedesc, NULL, 0, NULL)) == SQL_SUCCESS ||
223 sql_ret == SQL_SUCCESS_WITH_INFO)
225 /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
226 dirn = SQL_FETCH_NEXT;
227 if (sizedesc == lstrlenA(desc))
229 HKEY hThis;
230 if ((reg_ret = RegQueryValueExA (hDrivers, desc, NULL,
231 NULL, NULL, NULL)) == ERROR_FILE_NOT_FOUND)
233 if ((reg_ret = RegSetValueExA (hDrivers, desc, 0,
234 REG_SZ, (const BYTE *)"Installed", 10)) != ERROR_SUCCESS)
236 TRACE ("Error %d replicating driver %s\n",
237 reg_ret, desc);
238 success = FALSE;
241 else if (reg_ret != ERROR_SUCCESS)
243 TRACE ("Error %d checking for %s in drivers\n",
244 reg_ret, desc);
245 success = FALSE;
247 if ((reg_ret = RegCreateKeyExA (hODBCInst, desc, 0,
248 NULL, REG_OPTION_NON_VOLATILE,
249 KEY_ALL_ACCESS, NULL, &hThis, NULL))
250 == ERROR_SUCCESS)
252 /* FIXME This is where the settings go.
253 * I suggest that if the disposition says it
254 * exists then we leave it alone. Alternatively
255 * include an extra value to flag that it is
256 * a replication of the unixODBC/iODBC/...
258 if ((reg_ret = RegCloseKey (hThis)) !=
259 ERROR_SUCCESS)
260 TRACE ("Error %d closing %s key\n", reg_ret,
261 desc);
263 else
265 TRACE ("Error %d ensuring driver key %s\n",
266 reg_ret, desc);
267 success = FALSE;
270 else
272 WARN ("Unusually long driver name %s not replicated\n",
273 desc);
274 success = FALSE;
277 if (sql_ret != SQL_NO_DATA)
279 TRACE ("Error %d enumerating drivers\n", (int)sql_ret);
280 success = FALSE;
282 if ((reg_ret = RegCloseKey (hDrivers)) != ERROR_SUCCESS)
284 TRACE ("Error %d closing hDrivers\n", reg_ret);
287 else
289 TRACE ("Error %d opening HKLM\\S\\O\\OI\\Drivers\n", reg_ret);
291 if ((reg_ret = RegCloseKey (hODBCInst)) != ERROR_SUCCESS)
293 TRACE ("Error %d closing HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
296 else
298 TRACE ("Error %d opening HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
300 if (!success)
302 WARN ("May not have replicated all ODBC drivers to the registry\n");
306 /***********************************************************************
307 * ODBC_ReplicateODBCToRegistry
309 * PARAMS
311 * RETURNS
313 * Utility to ODBC_ReplicateToRegistry to replicate either the USER or
314 * SYSTEM dsns
316 * For now simply place the "Driver description" (as returned by SQLDataSources)
317 * into the registry as the driver. This is enough to satisfy Crystal's
318 * requirement that there be a driver entry. (It doesn't seem to care what
319 * the setting is).
320 * A slightly more accurate setting would be to access the registry to find
321 * the actual driver library for the given description (which appears to map
322 * to one of the HKLM/Software/ODBC/ODBCINST.INI keys). (If you do this note
323 * that this will add a requirement that this function be called after
324 * ODBC_ReplicateODBCInstToRegistry)
326 static void ODBC_ReplicateODBCToRegistry (BOOL is_user, SQLHENV hEnv)
328 HKEY hODBC;
329 LONG reg_ret;
330 SQLRETURN sql_ret;
331 SQLUSMALLINT dirn;
332 CHAR dsn [SQL_MAX_DSN_LENGTH + 1];
333 SQLSMALLINT sizedsn;
334 CHAR desc [256];
335 SQLSMALLINT sizedesc;
336 BOOL success;
337 const char *which = is_user ? "user" : "system";
339 success = FALSE;
340 if ((reg_ret = RegCreateKeyExA (
341 is_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
342 "Software\\ODBC\\ODBC.INI", 0, NULL, REG_OPTION_NON_VOLATILE,
343 KEY_ALL_ACCESS /* a couple more than we need */, NULL, &hODBC,
344 NULL)) == ERROR_SUCCESS)
346 success = TRUE;
347 dirn = is_user ? SQL_FETCH_FIRST_USER : SQL_FETCH_FIRST_SYSTEM;
348 while ((sql_ret = SQLDataSources (hEnv, dirn,
349 (SQLCHAR*)dsn, sizeof(dsn), &sizedsn,
350 (SQLCHAR*)desc, sizeof(desc), &sizedesc)) == SQL_SUCCESS
351 || sql_ret == SQL_SUCCESS_WITH_INFO)
353 /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
354 dirn = SQL_FETCH_NEXT;
355 if (sizedsn == lstrlenA(dsn) && sizedesc == lstrlenA(desc))
357 HKEY hDSN;
358 if ((reg_ret = RegCreateKeyExA (hODBC, dsn, 0,
359 NULL, REG_OPTION_NON_VOLATILE,
360 KEY_ALL_ACCESS, NULL, &hDSN, NULL))
361 == ERROR_SUCCESS)
363 static const char DRIVERKEY[] = "Driver";
364 if ((reg_ret = RegQueryValueExA (hDSN, DRIVERKEY,
365 NULL, NULL, NULL, NULL))
366 == ERROR_FILE_NOT_FOUND)
368 if ((reg_ret = RegSetValueExA (hDSN, DRIVERKEY, 0,
369 REG_SZ, (LPBYTE)desc, sizedesc)) != ERROR_SUCCESS)
371 TRACE ("Error %d replicating description of "
372 "%s(%s)\n", reg_ret, dsn, desc);
373 success = FALSE;
376 else if (reg_ret != ERROR_SUCCESS)
378 TRACE ("Error %d checking for description of %s\n",
379 reg_ret, dsn);
380 success = FALSE;
382 if ((reg_ret = RegCloseKey (hDSN)) != ERROR_SUCCESS)
384 TRACE ("Error %d closing %s DSN key %s\n",
385 reg_ret, which, dsn);
388 else
390 TRACE ("Error %d opening %s DSN key %s\n",
391 reg_ret, which, dsn);
392 success = FALSE;
395 else
397 WARN ("Unusually long %s data source name %s (%s) not "
398 "replicated\n", which, dsn, desc);
399 success = FALSE;
402 if (sql_ret != SQL_NO_DATA)
404 TRACE ("Error %d enumerating %s datasources\n",
405 (int)sql_ret, which);
406 success = FALSE;
408 if ((reg_ret = RegCloseKey (hODBC)) != ERROR_SUCCESS)
410 TRACE ("Error %d closing %s ODBC.INI registry key\n", reg_ret,
411 which);
414 else
416 TRACE ("Error %d creating/opening %s ODBC.INI registry key\n",
417 reg_ret, which);
419 if (!success)
421 WARN ("May not have replicated all %s ODBC DSNs to the registry\n",
422 which);
426 /***********************************************************************
427 * ODBC_ReplicateToRegistry
429 * PARAMS
431 * RETURNS
433 * Unfortunately some of the functions that Windows documents as being part
434 * of the ODBC API it implements directly during compilation or something
435 * in terms of registry access functions.
436 * e.g. SQLGetInstalledDrivers queries the list at
437 * HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\ODBC Drivers
439 * This function is called when the driver manager is loaded and is used
440 * to replicate the appropriate details into the Wine registry
443 static void ODBC_ReplicateToRegistry (void)
445 SQLRETURN sql_ret;
446 SQLHENV hEnv;
448 if ((sql_ret = SQLAllocEnv (&hEnv)) == SQL_SUCCESS)
450 ODBC_ReplicateODBCInstToRegistry (hEnv);
451 ODBC_ReplicateODBCToRegistry (FALSE /* system dsns */, hEnv);
452 ODBC_ReplicateODBCToRegistry (TRUE /* user dsns */, hEnv);
454 if ((sql_ret = SQLFreeEnv (hEnv)) != SQL_SUCCESS)
456 TRACE ("Error %d freeing the SQL environment.\n", (int)sql_ret);
459 else
461 TRACE ("Error %d opening an SQL environment.\n", (int)sql_ret);
462 WARN ("The external ODBC settings have not been replicated to the"
463 " Wine registry\n");
467 /***********************************************************************
468 * DllMain [Internal] Initializes the internal 'ODBC32.DLL'.
470 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
472 TRACE("proxy ODBC: %p,%x,%p\n", hinstDLL, reason, reserved);
474 switch (reason)
476 case DLL_PROCESS_ATTACH:
477 DisableThreadLibraryCalls(hinstDLL);
478 if (ODBC_LoadDriverManager())
480 ODBC_LoadDMFunctions();
481 ODBC_ReplicateToRegistry();
483 break;
485 case DLL_PROCESS_DETACH:
486 if (reserved) break;
487 if (dmHandle) wine_dlclose(dmHandle,NULL,0);
490 return TRUE;
493 /***********************************************************************
494 * ODBC_LoadDriverManager [Internal] Load ODBC library.
496 * PARAMS
498 * RETURNS
499 * Success: TRUE
500 * Failure: FALSE
503 static BOOL ODBC_LoadDriverManager(void)
505 const char *s = getenv("LIB_ODBC_DRIVER_MANAGER");
506 char error[256];
508 TRACE("\n");
510 #ifdef SONAME_LIBODBC
511 if (!s || !s[0]) s = SONAME_LIBODBC;
512 #endif
513 if (!s || !s[0]) goto failed;
515 dmHandle = wine_dlopen(s, RTLD_LAZY | RTLD_GLOBAL, error, sizeof(error));
517 if (dmHandle != NULL)
519 nErrorType = ERROR_FREE;
520 return TRUE;
522 failed:
523 WARN("failed to open library %s: %s\n", debugstr_a(s), error);
524 nErrorType = ERROR_LIBRARY_NOT_FOUND;
525 return FALSE;
529 /***********************************************************************
530 * ODBC_LoadDMFunctions [Internal] Populate function table.
532 * PARAMS
534 * RETURNS
535 * Success: TRUE
536 * Failure: FALSE
539 static BOOL ODBC_LoadDMFunctions(void)
541 char error[256];
543 if (dmHandle == NULL)
544 return FALSE;
546 #define LOAD_FUNC(name) \
547 if ((p##name = wine_dlsym( dmHandle, #name, error, sizeof(error) ))); \
548 else WARN( "Failed to load %s: %s\n", #name, error )
550 LOAD_FUNC(SQLAllocConnect);
551 LOAD_FUNC(SQLAllocEnv);
552 LOAD_FUNC(SQLAllocHandle);
553 LOAD_FUNC(SQLAllocHandleStd);
554 LOAD_FUNC(SQLAllocStmt);
555 LOAD_FUNC(SQLBindCol);
556 LOAD_FUNC(SQLBindParam);
557 LOAD_FUNC(SQLBindParameter);
558 LOAD_FUNC(SQLBrowseConnect);
559 LOAD_FUNC(SQLBrowseConnectW);
560 LOAD_FUNC(SQLBulkOperations);
561 LOAD_FUNC(SQLCancel);
562 LOAD_FUNC(SQLCloseCursor);
563 LOAD_FUNC(SQLColAttribute);
564 LOAD_FUNC(SQLColAttributeW);
565 LOAD_FUNC(SQLColAttributes);
566 LOAD_FUNC(SQLColAttributesW);
567 LOAD_FUNC(SQLColumnPrivileges);
568 LOAD_FUNC(SQLColumnPrivilegesW);
569 LOAD_FUNC(SQLColumns);
570 LOAD_FUNC(SQLColumnsW);
571 LOAD_FUNC(SQLConnect);
572 LOAD_FUNC(SQLConnectW);
573 LOAD_FUNC(SQLCopyDesc);
574 LOAD_FUNC(SQLDataSources);
575 LOAD_FUNC(SQLDataSourcesA);
576 LOAD_FUNC(SQLDataSourcesW);
577 LOAD_FUNC(SQLDescribeCol);
578 LOAD_FUNC(SQLDescribeColW);
579 LOAD_FUNC(SQLDescribeParam);
580 LOAD_FUNC(SQLDisconnect);
581 LOAD_FUNC(SQLDriverConnect);
582 LOAD_FUNC(SQLDriverConnectW);
583 LOAD_FUNC(SQLDrivers);
584 LOAD_FUNC(SQLDriversW);
585 LOAD_FUNC(SQLEndTran);
586 LOAD_FUNC(SQLError);
587 LOAD_FUNC(SQLErrorW);
588 LOAD_FUNC(SQLExecDirect);
589 LOAD_FUNC(SQLExecDirectW);
590 LOAD_FUNC(SQLExecute);
591 LOAD_FUNC(SQLExtendedFetch);
592 LOAD_FUNC(SQLFetch);
593 LOAD_FUNC(SQLFetchScroll);
594 LOAD_FUNC(SQLForeignKeys);
595 LOAD_FUNC(SQLForeignKeysW);
596 LOAD_FUNC(SQLFreeConnect);
597 LOAD_FUNC(SQLFreeEnv);
598 LOAD_FUNC(SQLFreeHandle);
599 LOAD_FUNC(SQLFreeStmt);
600 LOAD_FUNC(SQLGetConnectAttr);
601 LOAD_FUNC(SQLGetConnectAttrW);
602 LOAD_FUNC(SQLGetConnectOption);
603 LOAD_FUNC(SQLGetConnectOptionW);
604 LOAD_FUNC(SQLGetCursorName);
605 LOAD_FUNC(SQLGetCursorNameW);
606 LOAD_FUNC(SQLGetData);
607 LOAD_FUNC(SQLGetDescField);
608 LOAD_FUNC(SQLGetDescFieldW);
609 LOAD_FUNC(SQLGetDescRec);
610 LOAD_FUNC(SQLGetDescRecW);
611 LOAD_FUNC(SQLGetDiagField);
612 LOAD_FUNC(SQLGetDiagFieldW);
613 LOAD_FUNC(SQLGetDiagRec);
614 LOAD_FUNC(SQLGetDiagRecW);
615 LOAD_FUNC(SQLGetEnvAttr);
616 LOAD_FUNC(SQLGetFunctions);
617 LOAD_FUNC(SQLGetInfo);
618 LOAD_FUNC(SQLGetInfoW);
619 LOAD_FUNC(SQLGetStmtAttr);
620 LOAD_FUNC(SQLGetStmtAttrW);
621 LOAD_FUNC(SQLGetStmtOption);
622 LOAD_FUNC(SQLGetTypeInfo);
623 LOAD_FUNC(SQLGetTypeInfoW);
624 LOAD_FUNC(SQLMoreResults);
625 LOAD_FUNC(SQLNativeSql);
626 LOAD_FUNC(SQLNativeSqlW);
627 LOAD_FUNC(SQLNumParams);
628 LOAD_FUNC(SQLNumResultCols);
629 LOAD_FUNC(SQLParamData);
630 LOAD_FUNC(SQLParamOptions);
631 LOAD_FUNC(SQLPrepare);
632 LOAD_FUNC(SQLPrepareW);
633 LOAD_FUNC(SQLPrimaryKeys);
634 LOAD_FUNC(SQLPrimaryKeysW);
635 LOAD_FUNC(SQLProcedureColumns);
636 LOAD_FUNC(SQLProcedureColumnsW);
637 LOAD_FUNC(SQLProcedures);
638 LOAD_FUNC(SQLProceduresW);
639 LOAD_FUNC(SQLPutData);
640 LOAD_FUNC(SQLRowCount);
641 LOAD_FUNC(SQLSetConnectAttr);
642 LOAD_FUNC(SQLSetConnectAttrW);
643 LOAD_FUNC(SQLSetConnectOption);
644 LOAD_FUNC(SQLSetConnectOptionW);
645 LOAD_FUNC(SQLSetCursorName);
646 LOAD_FUNC(SQLSetCursorNameW);
647 LOAD_FUNC(SQLSetDescField);
648 LOAD_FUNC(SQLSetDescFieldW);
649 LOAD_FUNC(SQLSetDescRec);
650 LOAD_FUNC(SQLSetEnvAttr);
651 LOAD_FUNC(SQLSetParam);
652 LOAD_FUNC(SQLSetPos);
653 LOAD_FUNC(SQLSetScrollOptions);
654 LOAD_FUNC(SQLSetStmtAttr);
655 LOAD_FUNC(SQLSetStmtAttrW);
656 LOAD_FUNC(SQLSetStmtOption);
657 LOAD_FUNC(SQLSpecialColumns);
658 LOAD_FUNC(SQLSpecialColumnsW);
659 LOAD_FUNC(SQLStatistics);
660 LOAD_FUNC(SQLStatisticsW);
661 LOAD_FUNC(SQLTablePrivileges);
662 LOAD_FUNC(SQLTablePrivilegesW);
663 LOAD_FUNC(SQLTables);
664 LOAD_FUNC(SQLTablesW);
665 LOAD_FUNC(SQLTransact);
666 #undef LOAD_FUNC
668 return TRUE;
672 /*************************************************************************
673 * SQLAllocConnect [ODBC32.001]
675 SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionHandle)
677 SQLRETURN ret;
678 TRACE("Env=%p\n",EnvironmentHandle);
680 if (!pSQLAllocConnect)
682 *ConnectionHandle = SQL_NULL_HDBC;
683 TRACE("Not ready\n");
684 return SQL_ERROR;
687 ret = pSQLAllocConnect(EnvironmentHandle, ConnectionHandle);
688 TRACE("Returns ret=%d, Handle %p\n",ret, *ConnectionHandle);
689 return ret;
693 /*************************************************************************
694 * SQLAllocEnv [ODBC32.002]
696 SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle)
698 SQLRETURN ret;
699 TRACE("\n");
701 if (!pSQLAllocEnv)
703 *EnvironmentHandle = SQL_NULL_HENV;
704 TRACE("Not ready\n");
705 return SQL_ERROR;
708 ret = pSQLAllocEnv(EnvironmentHandle);
709 TRACE("Returns ret=%d, Env=%p\n",ret, *EnvironmentHandle);
710 return ret;
714 /*************************************************************************
715 * SQLAllocHandle [ODBC32.024]
717 SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
719 SQLRETURN ret;
720 TRACE("(Type=%d, Handle=%p)\n",HandleType,InputHandle);
722 if (!pSQLAllocHandle)
724 if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
725 WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
727 if (HandleType == SQL_HANDLE_ENV)
728 *OutputHandle = SQL_NULL_HENV;
729 else if (HandleType == SQL_HANDLE_DBC)
730 *OutputHandle = SQL_NULL_HDBC;
731 else if (HandleType == SQL_HANDLE_STMT)
732 *OutputHandle = SQL_NULL_HSTMT;
733 else if (HandleType == SQL_HANDLE_DESC)
734 *OutputHandle = SQL_NULL_HDESC;
736 TRACE ("Not ready\n");
737 return SQL_ERROR;
740 ret = pSQLAllocHandle(HandleType, InputHandle, OutputHandle);
741 TRACE("Returns ret=%d, Handle=%p\n",ret, *OutputHandle);
742 return ret;
746 /*************************************************************************
747 * SQLAllocStmt [ODBC32.003]
749 SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandle)
751 SQLRETURN ret;
753 TRACE("(Connection=%p)\n",ConnectionHandle);
755 if (!pSQLAllocStmt)
757 *StatementHandle = SQL_NULL_HSTMT;
758 TRACE ("Not ready\n");
759 return SQL_ERROR;
762 ret = pSQLAllocStmt(ConnectionHandle, StatementHandle);
763 TRACE ("Returns ret=%d, Handle=%p\n", ret, *StatementHandle);
764 return ret;
768 /*************************************************************************
769 * SQLAllocHandleStd [ODBC32.077]
771 SQLRETURN WINAPI SQLAllocHandleStd( SQLSMALLINT HandleType,
772 SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
774 TRACE("ProxyODBC: SQLAllocHandleStd.\n");
776 if (!pSQLAllocHandleStd)
778 if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
779 WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
781 if (HandleType == SQL_HANDLE_ENV)
782 *OutputHandle = SQL_NULL_HENV;
783 else if (HandleType == SQL_HANDLE_DBC)
784 *OutputHandle = SQL_NULL_HDBC;
785 else if (HandleType == SQL_HANDLE_STMT)
786 *OutputHandle = SQL_NULL_HSTMT;
787 else if (HandleType == SQL_HANDLE_DESC)
788 *OutputHandle = SQL_NULL_HDESC;
790 return SQL_ERROR;
793 return pSQLAllocHandleStd(HandleType, InputHandle, OutputHandle);
797 /*************************************************************************
798 * SQLBindCol [ODBC32.004]
800 SQLRETURN WINAPI SQLBindCol(SQLHSTMT StatementHandle,
801 SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
802 SQLPOINTER TargetValue, SQLINTEGER BufferLength,
803 SQLLEN *StrLen_or_Ind)
805 TRACE("\n");
807 if (!pSQLBindCol)
809 TRACE ("Not ready\n");
810 return SQL_ERROR;
813 return pSQLBindCol(StatementHandle, ColumnNumber, TargetType,
814 TargetValue, BufferLength, StrLen_or_Ind);
818 /*************************************************************************
819 * SQLBindParam [ODBC32.025]
821 SQLRETURN WINAPI SQLBindParam(SQLHSTMT StatementHandle,
822 SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
823 SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
824 SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
825 SQLINTEGER *StrLen_or_Ind)
827 TRACE("\n");
829 if (!pSQLBindParam) return SQL_ERROR;
830 return pSQLBindParam(StatementHandle, ParameterNumber, ValueType,
831 ParameterType, LengthPrecision, ParameterScale,
832 ParameterValue, StrLen_or_Ind);
836 /*************************************************************************
837 * SQLCancel [ODBC32.005]
839 SQLRETURN WINAPI SQLCancel(SQLHSTMT StatementHandle)
841 TRACE("\n");
843 if (!pSQLCancel) return SQL_ERROR;
844 return pSQLCancel(StatementHandle);
848 /*************************************************************************
849 * SQLCloseCursor [ODBC32.026]
851 SQLRETURN WINAPI SQLCloseCursor(SQLHSTMT StatementHandle)
853 SQLRETURN ret;
854 TRACE("(Handle=%p)\n",StatementHandle);
856 if (!pSQLCloseCursor) return SQL_ERROR;
858 ret = pSQLCloseCursor(StatementHandle);
859 TRACE("returns %d\n",ret);
860 return ret;
864 /*************************************************************************
865 * SQLColAttribute [ODBC32.027]
867 SQLRETURN WINAPI SQLColAttribute (SQLHSTMT StatementHandle,
868 SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
869 SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
870 SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute)
872 TRACE("\n");
874 if (!pSQLColAttribute) return SQL_ERROR;
875 return pSQLColAttribute(StatementHandle, ColumnNumber, FieldIdentifier,
876 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
880 /*************************************************************************
881 * SQLColumns [ODBC32.040]
883 SQLRETURN WINAPI SQLColumns(SQLHSTMT StatementHandle,
884 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
885 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
886 SQLCHAR *TableName, SQLSMALLINT NameLength3,
887 SQLCHAR *ColumnName, SQLSMALLINT NameLength4)
889 TRACE("\n");
891 if (!pSQLColumns) return SQL_ERROR;
892 return pSQLColumns(StatementHandle, CatalogName, NameLength1,
893 SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
897 /*************************************************************************
898 * SQLConnect [ODBC32.007]
900 SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle,
901 SQLCHAR *ServerName, SQLSMALLINT NameLength1,
902 SQLCHAR *UserName, SQLSMALLINT NameLength2,
903 SQLCHAR *Authentication, SQLSMALLINT NameLength3)
905 SQLRETURN ret;
906 TRACE("(Server=%.*s)\n",NameLength1, ServerName);
908 if (!pSQLConnect) return SQL_ERROR;
910 ret = pSQLConnect(ConnectionHandle, ServerName, NameLength1,
911 UserName, NameLength2, Authentication, NameLength3);
913 TRACE("returns %d\n",ret);
914 return ret;
918 /*************************************************************************
919 * SQLCopyDesc [ODBC32.028]
921 SQLRETURN WINAPI SQLCopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandle)
923 TRACE("\n");
925 if (!pSQLCopyDesc) return SQL_ERROR;
926 return pSQLCopyDesc(SourceDescHandle, TargetDescHandle);
930 /*************************************************************************
931 * SQLDataSources [ODBC32.057]
933 SQLRETURN WINAPI SQLDataSources(SQLHENV EnvironmentHandle,
934 SQLUSMALLINT Direction, SQLCHAR *ServerName,
935 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
936 SQLCHAR *Description, SQLSMALLINT BufferLength2,
937 SQLSMALLINT *NameLength2)
939 SQLRETURN ret;
941 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
943 if (!pSQLDataSources) return SQL_ERROR;
945 ret = pSQLDataSources(EnvironmentHandle, Direction, ServerName,
946 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
948 if (TRACE_ON(odbc))
950 TRACE("returns: %d \t", ret);
951 if (NameLength1 && *NameLength1 > 0)
952 TRACE("DataSource = %s,", ServerName);
953 if (NameLength2 && *NameLength2 > 0)
954 TRACE(" Description = %s", Description);
955 TRACE("\n");
958 return ret;
961 SQLRETURN WINAPI SQLDataSourcesA(SQLHENV EnvironmentHandle,
962 SQLUSMALLINT Direction, SQLCHAR *ServerName,
963 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
964 SQLCHAR *Description, SQLSMALLINT BufferLength2,
965 SQLSMALLINT *NameLength2)
967 SQLRETURN ret;
969 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
971 if (!pSQLDataSourcesA) return SQL_ERROR;
973 ret = pSQLDataSourcesA(EnvironmentHandle, Direction, ServerName,
974 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
975 if (TRACE_ON(odbc))
977 TRACE("returns: %d \t", ret);
978 if (NameLength1 && *NameLength1 > 0)
979 TRACE("DataSource = %s,", ServerName);
980 if (NameLength2 && *NameLength2 > 0)
981 TRACE(" Description = %s", Description);
982 TRACE("\n");
985 return ret;
988 /*************************************************************************
989 * SQLDescribeCol [ODBC32.008]
991 SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle,
992 SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
993 SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
994 SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
995 SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
997 TRACE("\n");
999 if (!pSQLDescribeCol) return SQL_ERROR;
1000 return pSQLDescribeCol(StatementHandle, ColumnNumber, ColumnName,
1001 BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable);
1005 /*************************************************************************
1006 * SQLDisconnect [ODBC32.009]
1008 SQLRETURN WINAPI SQLDisconnect(SQLHDBC ConnectionHandle)
1010 SQLRETURN ret;
1011 TRACE("(Handle=%p)\n", ConnectionHandle);
1013 if (!pSQLDisconnect) return SQL_ERROR;
1015 ret = pSQLDisconnect(ConnectionHandle);
1016 TRACE("returns %d\n",ret);
1017 return ret;
1021 /*************************************************************************
1022 * SQLEndTran [ODBC32.029]
1024 SQLRETURN WINAPI SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT CompletionType)
1026 TRACE("\n");
1028 if (!pSQLEndTran) return SQL_ERROR;
1029 return pSQLEndTran(HandleType, Handle, CompletionType);
1033 /*************************************************************************
1034 * SQLError [ODBC32.010]
1036 SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle,
1037 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
1038 SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
1039 SQLCHAR *MessageText, SQLSMALLINT BufferLength,
1040 SQLSMALLINT *TextLength)
1042 TRACE("\n");
1044 if (!pSQLError) return SQL_ERROR;
1045 return pSQLError(EnvironmentHandle, ConnectionHandle, StatementHandle,
1046 Sqlstate, NativeError, MessageText, BufferLength, TextLength);
1050 /*************************************************************************
1051 * SQLExecDirect [ODBC32.011]
1053 SQLRETURN WINAPI SQLExecDirect(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
1055 TRACE("\n");
1057 if (!pSQLExecDirect) return SQL_ERROR;
1058 return pSQLExecDirect(StatementHandle, StatementText, TextLength);
1062 /*************************************************************************
1063 * SQLExecute [ODBC32.012]
1065 SQLRETURN WINAPI SQLExecute(SQLHSTMT StatementHandle)
1067 TRACE("\n");
1069 if (!pSQLExecute) return SQL_ERROR;
1070 return pSQLExecute(StatementHandle);
1074 /*************************************************************************
1075 * SQLFetch [ODBC32.013]
1077 SQLRETURN WINAPI SQLFetch(SQLHSTMT StatementHandle)
1079 TRACE("\n");
1081 if (!pSQLFetch) return SQL_ERROR;
1082 return pSQLFetch(StatementHandle);
1086 /*************************************************************************
1087 * SQLFetchScroll [ODBC32.030]
1089 SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset)
1091 TRACE("\n");
1093 if (!pSQLFetchScroll) return SQL_ERROR;
1094 return pSQLFetchScroll(StatementHandle, FetchOrientation, FetchOffset);
1098 /*************************************************************************
1099 * SQLFreeConnect [ODBC32.014]
1101 SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
1103 SQLRETURN ret;
1104 TRACE("(Handle=%p)\n",ConnectionHandle);
1106 if (!pSQLFreeConnect) return SQL_ERROR;
1108 ret = pSQLFreeConnect(ConnectionHandle);
1109 TRACE("Returns %d\n",ret);
1110 return ret;
1114 /*************************************************************************
1115 * SQLFreeEnv [ODBC32.015]
1117 SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle)
1119 SQLRETURN ret;
1120 TRACE("(Env=%p)\n",EnvironmentHandle);
1122 if (!pSQLFreeEnv) return SQL_ERROR;
1124 ret = pSQLFreeEnv(EnvironmentHandle);
1125 TRACE("Returns %d\n",ret);
1126 return ret;
1130 /*************************************************************************
1131 * SQLFreeHandle [ODBC32.031]
1133 SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
1135 SQLRETURN ret;
1136 TRACE("(Type=%d, Handle=%p)\n",HandleType,Handle);
1138 if (!pSQLFreeHandle) return SQL_ERROR;
1140 ret = pSQLFreeHandle(HandleType, Handle);
1141 TRACE ("Returns %d\n",ret);
1142 return ret;
1146 /*************************************************************************
1147 * SQLFreeStmt [ODBC32.016]
1149 SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
1151 SQLRETURN ret;
1152 TRACE("(Handle %p, Option=%d)\n",StatementHandle, Option);
1154 if (!pSQLFreeStmt) return SQL_ERROR;
1156 ret = pSQLFreeStmt(StatementHandle, Option);
1157 TRACE("Returns %d\n",ret);
1158 return ret;
1162 /*************************************************************************
1163 * SQLGetConnectAttr [ODBC32.032]
1165 SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle,
1166 SQLINTEGER Attribute, SQLPOINTER Value,
1167 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1169 TRACE("\n");
1171 if (!pSQLGetConnectAttr) return SQL_ERROR;
1172 return pSQLGetConnectAttr(ConnectionHandle, Attribute, Value,
1173 BufferLength, StringLength);
1177 /*************************************************************************
1178 * SQLGetConnectOption [ODBC32.042]
1180 SQLRETURN WINAPI SQLGetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
1182 TRACE("\n");
1184 if (!pSQLGetConnectOption) return SQL_ERROR;
1185 return pSQLGetConnectOption(ConnectionHandle, Option, Value);
1189 /*************************************************************************
1190 * SQLGetCursorName [ODBC32.017]
1192 SQLRETURN WINAPI SQLGetCursorName(SQLHSTMT StatementHandle,
1193 SQLCHAR *CursorName, SQLSMALLINT BufferLength,
1194 SQLSMALLINT *NameLength)
1196 TRACE("\n");
1198 if (!pSQLGetCursorName) return SQL_ERROR;
1199 return pSQLGetCursorName(StatementHandle, CursorName, BufferLength, NameLength);
1203 /*************************************************************************
1204 * SQLGetData [ODBC32.043]
1206 SQLRETURN WINAPI SQLGetData(SQLHSTMT StatementHandle,
1207 SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
1208 SQLPOINTER TargetValue, SQLINTEGER BufferLength,
1209 SQLINTEGER *StrLen_or_Ind)
1211 TRACE("\n");
1213 if (!pSQLGetData) return SQL_ERROR;
1214 return pSQLGetData(StatementHandle, ColumnNumber, TargetType,
1215 TargetValue, BufferLength, StrLen_or_Ind);
1219 /*************************************************************************
1220 * SQLGetDescField [ODBC32.033]
1222 SQLRETURN WINAPI SQLGetDescField(SQLHDESC DescriptorHandle,
1223 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
1224 SQLPOINTER Value, SQLINTEGER BufferLength,
1225 SQLINTEGER *StringLength)
1227 TRACE("\n");
1229 if (!pSQLGetDescField) return SQL_ERROR;
1230 return pSQLGetDescField(DescriptorHandle, RecNumber, FieldIdentifier,
1231 Value, BufferLength, StringLength);
1235 /*************************************************************************
1236 * SQLGetDescRec [ODBC32.034]
1238 SQLRETURN WINAPI SQLGetDescRec(SQLHDESC DescriptorHandle,
1239 SQLSMALLINT RecNumber, SQLCHAR *Name,
1240 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
1241 SQLSMALLINT *Type, SQLSMALLINT *SubType,
1242 SQLINTEGER *Length, SQLSMALLINT *Precision,
1243 SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
1245 TRACE("\n");
1247 if (!pSQLGetDescRec) return SQL_ERROR;
1248 return pSQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength,
1249 StringLength, Type, SubType, Length, Precision, Scale, Nullable);
1253 /*************************************************************************
1254 * SQLGetDiagField [ODBC32.035]
1256 SQLRETURN WINAPI SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
1257 SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
1258 SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
1259 SQLSMALLINT *StringLength)
1261 TRACE("\n");
1263 if (!pSQLGetDiagField) return SQL_ERROR;
1264 return pSQLGetDiagField(HandleType, Handle, RecNumber, DiagIdentifier,
1265 DiagInfo, BufferLength, StringLength);
1269 /*************************************************************************
1270 * SQLGetDiagRec [ODBC32.036]
1272 SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
1273 SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
1274 SQLINTEGER *NativeError, SQLCHAR *MessageText,
1275 SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
1277 TRACE("\n");
1279 if (!pSQLGetDiagRec) return SQL_ERROR;
1280 return pSQLGetDiagRec(HandleType, Handle, RecNumber, Sqlstate, NativeError,
1281 MessageText, BufferLength, TextLength);
1285 /*************************************************************************
1286 * SQLGetEnvAttr [ODBC32.037]
1288 SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle,
1289 SQLINTEGER Attribute, SQLPOINTER Value,
1290 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1292 TRACE("\n");
1294 if (!pSQLGetEnvAttr) return SQL_ERROR;
1295 return pSQLGetEnvAttr(EnvironmentHandle, Attribute, Value, BufferLength, StringLength);
1299 /*************************************************************************
1300 * SQLGetFunctions [ODBC32.044]
1302 SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
1304 TRACE("\n");
1306 if (!pSQLGetFunctions) return SQL_ERROR;
1307 return pSQLGetFunctions(ConnectionHandle, FunctionId, Supported);
1311 /*************************************************************************
1312 * SQLGetInfo [ODBC32.045]
1314 SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle,
1315 SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
1316 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
1318 TRACE("\n");
1320 if (!pSQLGetInfo) return SQL_ERROR;
1321 return pSQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
1325 /*************************************************************************
1326 * SQLGetStmtAttr [ODBC32.038]
1328 SQLRETURN WINAPI SQLGetStmtAttr(SQLHSTMT StatementHandle,
1329 SQLINTEGER Attribute, SQLPOINTER Value,
1330 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1332 TRACE("\n");
1334 if (!pSQLGetStmtAttr) return SQL_ERROR;
1335 return pSQLGetStmtAttr(StatementHandle, Attribute, Value, BufferLength, StringLength);
1339 /*************************************************************************
1340 * SQLGetStmtOption [ODBC32.046]
1342 SQLRETURN WINAPI SQLGetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLPOINTER Value)
1344 TRACE("\n");
1346 if (!pSQLGetStmtOption) return SQL_ERROR;
1347 return pSQLGetStmtOption(StatementHandle, Option, Value);
1351 /*************************************************************************
1352 * SQLGetTypeInfo [ODBC32.047]
1354 SQLRETURN WINAPI SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
1356 TRACE("\n");
1358 if (!pSQLGetTypeInfo) return SQL_ERROR;
1359 return pSQLGetTypeInfo(StatementHandle, DataType);
1363 /*************************************************************************
1364 * SQLNumResultCols [ODBC32.018]
1366 SQLRETURN WINAPI SQLNumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT *ColumnCount)
1368 TRACE("\n");
1370 if (!pSQLNumResultCols) return SQL_ERROR;
1371 return pSQLNumResultCols(StatementHandle, ColumnCount);
1375 /*************************************************************************
1376 * SQLParamData [ODBC32.048]
1378 SQLRETURN WINAPI SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER *Value)
1380 TRACE("\n");
1382 if (!pSQLParamData) return SQL_ERROR;
1383 return pSQLParamData(StatementHandle, Value);
1387 /*************************************************************************
1388 * SQLPrepare [ODBC32.019]
1390 SQLRETURN WINAPI SQLPrepare(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
1392 TRACE("\n");
1394 if (!pSQLPrepare) return SQL_ERROR;
1395 return pSQLPrepare(StatementHandle, StatementText, TextLength);
1399 /*************************************************************************
1400 * SQLPutData [ODBC32.049]
1402 SQLRETURN WINAPI SQLPutData(SQLHSTMT StatementHandle, SQLPOINTER Data, SQLINTEGER StrLen_or_Ind)
1404 TRACE("\n");
1406 if (!pSQLPutData) return SQL_ERROR;
1407 return pSQLPutData(StatementHandle, Data, StrLen_or_Ind);
1411 /*************************************************************************
1412 * SQLRowCount [ODBC32.020]
1414 SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLINTEGER *RowCount)
1416 TRACE("\n");
1418 if (!pSQLRowCount) return SQL_ERROR;
1419 return pSQLRowCount(StatementHandle, RowCount);
1423 /*************************************************************************
1424 * SQLSetConnectAttr [ODBC32.039]
1426 SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
1427 SQLPOINTER Value, SQLINTEGER StringLength)
1429 TRACE("\n");
1431 if (!pSQLSetConnectAttr) return SQL_ERROR;
1432 return pSQLSetConnectAttr(ConnectionHandle, Attribute, Value, StringLength);
1436 /*************************************************************************
1437 * SQLSetConnectOption [ODBC32.050]
1439 SQLRETURN WINAPI SQLSetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
1441 TRACE("\n");
1443 if (!pSQLSetConnectOption) return SQL_ERROR;
1444 return pSQLSetConnectOption(ConnectionHandle, Option, Value);
1448 /*************************************************************************
1449 * SQLSetCursorName [ODBC32.021]
1451 SQLRETURN WINAPI SQLSetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName, SQLSMALLINT NameLength)
1453 TRACE("\n");
1455 if (!pSQLSetCursorName) return SQL_ERROR;
1456 return pSQLSetCursorName(StatementHandle, CursorName, NameLength);
1460 /*************************************************************************
1461 * SQLSetDescField [ODBC32.073]
1463 SQLRETURN WINAPI SQLSetDescField(SQLHDESC DescriptorHandle,
1464 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
1465 SQLPOINTER Value, SQLINTEGER BufferLength)
1467 TRACE("\n");
1469 if (!pSQLSetDescField) return SQL_ERROR;
1470 return pSQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
1474 /*************************************************************************
1475 * SQLSetDescRec [ODBC32.074]
1477 SQLRETURN WINAPI SQLSetDescRec(SQLHDESC DescriptorHandle,
1478 SQLSMALLINT RecNumber, SQLSMALLINT Type,
1479 SQLSMALLINT SubType, SQLINTEGER Length,
1480 SQLSMALLINT Precision, SQLSMALLINT Scale,
1481 SQLPOINTER Data, SQLINTEGER *StringLength,
1482 SQLINTEGER *Indicator)
1484 TRACE("\n");
1486 if (!pSQLSetDescRec) return SQL_ERROR;
1487 return pSQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length,
1488 Precision, Scale, Data, StringLength, Indicator);
1492 /*************************************************************************
1493 * SQLSetEnvAttr [ODBC32.075]
1495 SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle,
1496 SQLINTEGER Attribute, SQLPOINTER Value,
1497 SQLINTEGER StringLength)
1499 TRACE("\n");
1501 if (!pSQLSetEnvAttr) return SQL_ERROR;
1502 return pSQLSetEnvAttr(EnvironmentHandle, Attribute, Value, StringLength);
1506 /*************************************************************************
1507 * SQLSetParam [ODBC32.022]
1509 SQLRETURN WINAPI SQLSetParam(SQLHSTMT StatementHandle,
1510 SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
1511 SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
1512 SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
1513 SQLINTEGER *StrLen_or_Ind)
1515 TRACE("\n");
1517 if (!pSQLSetParam) return SQL_ERROR;
1518 return pSQLSetParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision,
1519 ParameterScale, ParameterValue, StrLen_or_Ind);
1523 /*************************************************************************
1524 * SQLSetStmtAttr [ODBC32.076]
1526 SQLRETURN WINAPI SQLSetStmtAttr(SQLHSTMT StatementHandle,
1527 SQLINTEGER Attribute, SQLPOINTER Value,
1528 SQLINTEGER StringLength)
1530 TRACE("\n");
1532 if (!pSQLSetStmtAttr) return SQL_ERROR;
1533 return pSQLSetStmtAttr(StatementHandle, Attribute, Value, StringLength);
1537 /*************************************************************************
1538 * SQLSetStmtOption [ODBC32.051]
1540 SQLRETURN WINAPI SQLSetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
1542 TRACE("\n");
1544 if (!pSQLSetStmtOption) return SQL_ERROR;
1545 return pSQLSetStmtOption(StatementHandle, Option, Value);
1549 /*************************************************************************
1550 * SQLSpecialColumns [ODBC32.052]
1552 SQLRETURN WINAPI SQLSpecialColumns(SQLHSTMT StatementHandle,
1553 SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
1554 SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
1555 SQLSMALLINT NameLength2, SQLCHAR *TableName,
1556 SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
1557 SQLUSMALLINT Nullable)
1560 if (!pSQLSpecialColumns) return SQL_ERROR;
1561 return pSQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
1562 NameLength2, TableName, NameLength3, Scope, Nullable);
1566 /*************************************************************************
1567 * SQLStatistics [ODBC32.053]
1569 SQLRETURN WINAPI SQLStatistics(SQLHSTMT StatementHandle,
1570 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
1571 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
1572 SQLCHAR *TableName, SQLSMALLINT NameLength3,
1573 SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
1575 TRACE("\n");
1577 if (!pSQLStatistics) return SQL_ERROR;
1578 return pSQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
1579 TableName, NameLength3, Unique, Reserved);
1583 /*************************************************************************
1584 * SQLTables [ODBC32.054]
1586 SQLRETURN WINAPI SQLTables(SQLHSTMT StatementHandle,
1587 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
1588 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
1589 SQLCHAR *TableName, SQLSMALLINT NameLength3,
1590 SQLCHAR *TableType, SQLSMALLINT NameLength4)
1592 TRACE("\n");
1594 if (!pSQLTables) return SQL_ERROR;
1595 return pSQLTables(StatementHandle, CatalogName, NameLength1,
1596 SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
1600 /*************************************************************************
1601 * SQLTransact [ODBC32.023]
1603 SQLRETURN WINAPI SQLTransact(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle,
1604 SQLUSMALLINT CompletionType)
1606 TRACE("\n");
1608 if (!pSQLTransact) return SQL_ERROR;
1609 return pSQLTransact(EnvironmentHandle, ConnectionHandle, CompletionType);
1613 /*************************************************************************
1614 * SQLBrowseConnect [ODBC32.055]
1616 SQLRETURN WINAPI SQLBrowseConnect(
1617 SQLHDBC hdbc,
1618 SQLCHAR *szConnStrIn,
1619 SQLSMALLINT cbConnStrIn,
1620 SQLCHAR *szConnStrOut,
1621 SQLSMALLINT cbConnStrOutMax,
1622 SQLSMALLINT *pcbConnStrOut)
1624 TRACE("\n");
1626 if (!pSQLBrowseConnect) return SQL_ERROR;
1627 return pSQLBrowseConnect(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut);
1631 /*************************************************************************
1632 * SQLBulkOperations [ODBC32.078]
1634 SQLRETURN WINAPI SQLBulkOperations(
1635 SQLHSTMT StatementHandle,
1636 SQLSMALLINT Operation)
1638 TRACE("\n");
1640 if (!pSQLBulkOperations) return SQL_ERROR;
1641 return pSQLBulkOperations(StatementHandle, Operation);
1645 /*************************************************************************
1646 * SQLColAttributes [ODBC32.006]
1648 SQLRETURN WINAPI SQLColAttributes(
1649 SQLHSTMT hstmt,
1650 SQLUSMALLINT icol,
1651 SQLUSMALLINT fDescType,
1652 SQLPOINTER rgbDesc,
1653 SQLSMALLINT cbDescMax,
1654 SQLSMALLINT *pcbDesc,
1655 SQLINTEGER *pfDesc)
1657 TRACE("\n");
1659 if (!pSQLColAttributes) return SQL_ERROR;
1660 return pSQLColAttributes(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
1664 /*************************************************************************
1665 * SQLColumnPrivileges [ODBC32.056]
1667 SQLRETURN WINAPI SQLColumnPrivileges(
1668 SQLHSTMT hstmt,
1669 SQLCHAR *szCatalogName,
1670 SQLSMALLINT cbCatalogName,
1671 SQLCHAR *szSchemaName,
1672 SQLSMALLINT cbSchemaName,
1673 SQLCHAR *szTableName,
1674 SQLSMALLINT cbTableName,
1675 SQLCHAR *szColumnName,
1676 SQLSMALLINT cbColumnName)
1678 TRACE("\n");
1680 if (!pSQLColumnPrivileges) return SQL_ERROR;
1681 return pSQLColumnPrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1682 szTableName, cbTableName, szColumnName, cbColumnName);
1686 /*************************************************************************
1687 * SQLDescribeParam [ODBC32.058]
1689 SQLRETURN WINAPI SQLDescribeParam(
1690 SQLHSTMT hstmt,
1691 SQLUSMALLINT ipar,
1692 SQLSMALLINT *pfSqlType,
1693 SQLUINTEGER *pcbParamDef,
1694 SQLSMALLINT *pibScale,
1695 SQLSMALLINT *pfNullable)
1697 TRACE("\n");
1699 if (!pSQLDescribeParam) return SQL_ERROR;
1700 return pSQLDescribeParam(hstmt, ipar, pfSqlType, pcbParamDef, pibScale, pfNullable);
1704 /*************************************************************************
1705 * SQLExtendedFetch [ODBC32.059]
1707 SQLRETURN WINAPI SQLExtendedFetch(
1708 SQLHSTMT hstmt,
1709 SQLUSMALLINT fFetchType,
1710 SQLINTEGER irow,
1711 SQLUINTEGER *pcrow,
1712 SQLUSMALLINT *rgfRowStatus)
1714 TRACE("\n");
1716 if (!pSQLExtendedFetch) return SQL_ERROR;
1717 return pSQLExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus);
1721 /*************************************************************************
1722 * SQLForeignKeys [ODBC32.060]
1724 SQLRETURN WINAPI SQLForeignKeys(
1725 SQLHSTMT hstmt,
1726 SQLCHAR *szPkCatalogName,
1727 SQLSMALLINT cbPkCatalogName,
1728 SQLCHAR *szPkSchemaName,
1729 SQLSMALLINT cbPkSchemaName,
1730 SQLCHAR *szPkTableName,
1731 SQLSMALLINT cbPkTableName,
1732 SQLCHAR *szFkCatalogName,
1733 SQLSMALLINT cbFkCatalogName,
1734 SQLCHAR *szFkSchemaName,
1735 SQLSMALLINT cbFkSchemaName,
1736 SQLCHAR *szFkTableName,
1737 SQLSMALLINT cbFkTableName)
1739 TRACE("\n");
1741 if (!pSQLForeignKeys) return SQL_ERROR;
1742 return pSQLForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
1743 szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
1744 szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
1748 /*************************************************************************
1749 * SQLMoreResults [ODBC32.061]
1751 SQLRETURN WINAPI SQLMoreResults(SQLHSTMT hstmt)
1753 TRACE("\n");
1755 if (!pSQLMoreResults) return SQL_ERROR;
1756 return pSQLMoreResults(hstmt);
1760 /*************************************************************************
1761 * SQLNativeSql [ODBC32.062]
1763 SQLRETURN WINAPI SQLNativeSql(
1764 SQLHDBC hdbc,
1765 SQLCHAR *szSqlStrIn,
1766 SQLINTEGER cbSqlStrIn,
1767 SQLCHAR *szSqlStr,
1768 SQLINTEGER cbSqlStrMax,
1769 SQLINTEGER *pcbSqlStr)
1771 TRACE("\n");
1773 if (!pSQLNativeSql) return SQL_ERROR;
1774 return pSQLNativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
1778 /*************************************************************************
1779 * SQLNumParams [ODBC32.063]
1781 SQLRETURN WINAPI SQLNumParams(
1782 SQLHSTMT hstmt,
1783 SQLSMALLINT *pcpar)
1785 TRACE("\n");
1787 if (!pSQLNumParams) return SQL_ERROR;
1788 return pSQLNumParams(hstmt, pcpar);
1792 /*************************************************************************
1793 * SQLParamOptions [ODBC32.064]
1795 SQLRETURN WINAPI SQLParamOptions(
1796 SQLHSTMT hstmt,
1797 SQLUINTEGER crow,
1798 SQLUINTEGER *pirow)
1800 TRACE("\n");
1802 if (!pSQLParamOptions) return SQL_ERROR;
1803 return pSQLParamOptions(hstmt, crow, pirow);
1807 /*************************************************************************
1808 * SQLPrimaryKeys [ODBC32.065]
1810 SQLRETURN WINAPI SQLPrimaryKeys(
1811 SQLHSTMT hstmt,
1812 SQLCHAR *szCatalogName,
1813 SQLSMALLINT cbCatalogName,
1814 SQLCHAR *szSchemaName,
1815 SQLSMALLINT cbSchemaName,
1816 SQLCHAR *szTableName,
1817 SQLSMALLINT cbTableName)
1819 TRACE("\n");
1821 if (!pSQLPrimaryKeys) return SQL_ERROR;
1822 return pSQLPrimaryKeys(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1823 szTableName, cbTableName);
1827 /*************************************************************************
1828 * SQLProcedureColumns [ODBC32.066]
1830 SQLRETURN WINAPI SQLProcedureColumns(
1831 SQLHSTMT hstmt,
1832 SQLCHAR *szCatalogName,
1833 SQLSMALLINT cbCatalogName,
1834 SQLCHAR *szSchemaName,
1835 SQLSMALLINT cbSchemaName,
1836 SQLCHAR *szProcName,
1837 SQLSMALLINT cbProcName,
1838 SQLCHAR *szColumnName,
1839 SQLSMALLINT cbColumnName)
1841 TRACE("\n");
1843 if (!pSQLProcedureColumns) return SQL_ERROR;
1844 return pSQLProcedureColumns(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1845 szProcName, cbProcName, szColumnName, cbColumnName);
1849 /*************************************************************************
1850 * SQLProcedures [ODBC32.067]
1852 SQLRETURN WINAPI SQLProcedures(
1853 SQLHSTMT hstmt,
1854 SQLCHAR *szCatalogName,
1855 SQLSMALLINT cbCatalogName,
1856 SQLCHAR *szSchemaName,
1857 SQLSMALLINT cbSchemaName,
1858 SQLCHAR *szProcName,
1859 SQLSMALLINT cbProcName)
1861 TRACE("\n");
1863 if (!pSQLProcedures) return SQL_ERROR;
1864 return pSQLProcedures(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1865 szProcName, cbProcName);
1869 /*************************************************************************
1870 * SQLSetPos [ODBC32.068]
1872 SQLRETURN WINAPI SQLSetPos(
1873 SQLHSTMT hstmt,
1874 SQLUSMALLINT irow,
1875 SQLUSMALLINT fOption,
1876 SQLUSMALLINT fLock)
1878 TRACE("\n");
1880 if (!pSQLSetPos) return SQL_ERROR;
1881 return pSQLSetPos(hstmt, irow, fOption, fLock);
1885 /*************************************************************************
1886 * SQLTablePrivileges [ODBC32.070]
1888 SQLRETURN WINAPI SQLTablePrivileges(
1889 SQLHSTMT hstmt,
1890 SQLCHAR *szCatalogName,
1891 SQLSMALLINT cbCatalogName,
1892 SQLCHAR *szSchemaName,
1893 SQLSMALLINT cbSchemaName,
1894 SQLCHAR *szTableName,
1895 SQLSMALLINT cbTableName)
1897 TRACE("\n");
1899 if (!pSQLTablePrivileges) return SQL_ERROR;
1900 return pSQLTablePrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1901 szTableName, cbTableName);
1905 /*************************************************************************
1906 * SQLDrivers [ODBC32.071]
1908 SQLRETURN WINAPI SQLDrivers(
1909 SQLHENV henv,
1910 SQLUSMALLINT fDirection,
1911 SQLCHAR *szDriverDesc,
1912 SQLSMALLINT cbDriverDescMax,
1913 SQLSMALLINT *pcbDriverDesc,
1914 SQLCHAR *szDriverAttributes,
1915 SQLSMALLINT cbDriverAttrMax,
1916 SQLSMALLINT *pcbDriverAttr)
1918 SQLRETURN ret;
1920 TRACE("direction=%d\n", fDirection);
1922 if (!pSQLDrivers) return SQL_ERROR;
1923 ret = pSQLDrivers(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
1924 szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
1926 if (ret == SQL_NO_DATA && fDirection == SQL_FETCH_FIRST)
1927 ERR_(winediag)("No ODBC drivers could be found. "
1928 "Check the settings for your libodbc provider.\n");
1930 return ret;
1934 /*************************************************************************
1935 * SQLBindParameter [ODBC32.072]
1937 SQLRETURN WINAPI SQLBindParameter(
1938 SQLHSTMT hstmt,
1939 SQLUSMALLINT ipar,
1940 SQLSMALLINT fParamType,
1941 SQLSMALLINT fCType,
1942 SQLSMALLINT fSqlType,
1943 SQLUINTEGER cbColDef,
1944 SQLSMALLINT ibScale,
1945 SQLPOINTER rgbValue,
1946 SQLINTEGER cbValueMax,
1947 SQLINTEGER *pcbValue)
1949 TRACE("\n");
1951 if (!pSQLBindParameter) return SQL_ERROR;
1952 return pSQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale,
1953 rgbValue, cbValueMax, pcbValue);
1957 /*************************************************************************
1958 * SQLDriverConnect [ODBC32.041]
1960 SQLRETURN WINAPI SQLDriverConnect(
1961 SQLHDBC hdbc,
1962 SQLHWND hwnd,
1963 SQLCHAR *conn_str_in,
1964 SQLSMALLINT len_conn_str_in,
1965 SQLCHAR *conn_str_out,
1966 SQLSMALLINT conn_str_out_max,
1967 SQLSMALLINT *ptr_conn_str_out,
1968 SQLUSMALLINT driver_completion )
1970 TRACE("\n");
1972 if (!pSQLDriverConnect) return SQL_ERROR;
1973 return pSQLDriverConnect(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
1974 conn_str_out_max, ptr_conn_str_out, driver_completion);
1978 /*************************************************************************
1979 * SQLSetScrollOptions [ODBC32.069]
1981 SQLRETURN WINAPI SQLSetScrollOptions(
1982 SQLHSTMT statement_handle,
1983 SQLUSMALLINT f_concurrency,
1984 SQLINTEGER crow_keyset,
1985 SQLUSMALLINT crow_rowset )
1987 TRACE("\n");
1989 if (!pSQLSetScrollOptions) return SQL_ERROR;
1990 return pSQLSetScrollOptions(statement_handle, f_concurrency, crow_keyset, crow_rowset);
1993 static BOOL SQLColAttributes_KnownStringAttribute(SQLUSMALLINT fDescType)
1995 static const SQLUSMALLINT attrList[] =
1997 SQL_COLUMN_OWNER_NAME,
1998 SQL_COLUMN_QUALIFIER_NAME,
1999 SQL_COLUMN_LABEL,
2000 SQL_COLUMN_NAME,
2001 SQL_COLUMN_TABLE_NAME,
2002 SQL_COLUMN_TYPE_NAME,
2003 SQL_DESC_BASE_COLUMN_NAME,
2004 SQL_DESC_BASE_TABLE_NAME,
2005 SQL_DESC_CATALOG_NAME,
2006 SQL_DESC_LABEL,
2007 SQL_DESC_LITERAL_PREFIX,
2008 SQL_DESC_LITERAL_SUFFIX,
2009 SQL_DESC_LOCAL_TYPE_NAME,
2010 SQL_DESC_NAME,
2011 SQL_DESC_SCHEMA_NAME,
2012 SQL_DESC_TABLE_NAME,
2013 SQL_DESC_TYPE_NAME,
2015 unsigned int i;
2017 for (i = 0; i < sizeof(attrList) / sizeof(SQLUSMALLINT); i++) {
2018 if (attrList[i] == fDescType) return TRUE;
2020 return FALSE;
2023 /*************************************************************************
2024 * SQLColAttributesW [ODBC32.106]
2026 SQLRETURN WINAPI SQLColAttributesW(
2027 SQLHSTMT hstmt,
2028 SQLUSMALLINT icol,
2029 SQLUSMALLINT fDescType,
2030 SQLPOINTER rgbDesc,
2031 SQLSMALLINT cbDescMax,
2032 SQLSMALLINT *pcbDesc,
2033 SQLINTEGER *pfDesc)
2035 SQLRETURN iResult;
2037 TRACE("hstmt=%p icol=%d fDescType=%d rgbDesc=%p cbDescMax=%d pcbDesc=%p pfDesc=%p\n",
2038 hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2040 if (!pSQLColAttributesW) return SQL_ERROR;
2042 iResult = pSQLColAttributesW(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2043 if (iResult == SQL_SUCCESS && rgbDesc != NULL && SQLColAttributes_KnownStringAttribute(fDescType)) {
2045 TRACE("Dumping values fetched via SQLColAttributesW:\n");
2046 TRACE(" Attribute name : %s\n", debugstr_w(rgbDesc));
2047 TRACE(" Declared length: %d\n", *pcbDesc);
2049 if (*pcbDesc != lstrlenW(rgbDesc) * 2) {
2050 TRACE("CHEAT: resetting name length for ADO\n");
2051 *pcbDesc = lstrlenW(rgbDesc) * 2;
2054 return iResult;
2057 /*************************************************************************
2058 * SQLConnectW [ODBC32.107]
2060 SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle,
2061 WCHAR *ServerName, SQLSMALLINT NameLength1,
2062 WCHAR *UserName, SQLSMALLINT NameLength2,
2063 WCHAR *Authentication, SQLSMALLINT NameLength3)
2065 SQLRETURN ret;
2066 TRACE("(Server=%.*s)\n",NameLength1+3, debugstr_w(ServerName));
2068 if (!pSQLConnectW) return SQL_ERROR;
2070 ret = pSQLConnectW(ConnectionHandle, ServerName, NameLength1,
2071 UserName, NameLength2, Authentication, NameLength3);
2073 TRACE("returns %d\n",ret);
2074 return ret;
2077 /*************************************************************************
2078 * SQLDescribeColW [ODBC32.108]
2080 SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle,
2081 SQLUSMALLINT ColumnNumber, WCHAR *ColumnName,
2082 SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
2083 SQLSMALLINT *DataType, SQLULEN *ColumnSize,
2084 SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
2086 SQLRETURN iResult;
2087 TRACE("\n");
2089 if (!pSQLDescribeColW) return SQL_ERROR;
2091 iResult = pSQLDescribeColW(StatementHandle, ColumnNumber, ColumnName,
2092 BufferLength, NameLength, DataType, ColumnSize,
2093 DecimalDigits, Nullable);
2094 if (iResult >= 0) {
2095 TRACE("Successfully recovered the following column information:\n");
2096 TRACE("\tRequested column index: %d\n", ColumnNumber);
2097 TRACE("\tAvailable length for column name: %d\n", BufferLength);
2098 if (NameLength != NULL)
2099 TRACE("\tActual length for column name: %d\n", *NameLength);
2100 else TRACE("\tActual length for column name: (null)\n");
2101 TRACE("\tReturned column name: %s\n", debugstr_w(ColumnName));
2103 return iResult;
2106 /*************************************************************************
2107 * SQLErrorW [ODBC32.110]
2109 SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle,
2110 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
2111 WCHAR *Sqlstate, SQLINTEGER *NativeError,
2112 WCHAR *MessageText, SQLSMALLINT BufferLength,
2113 SQLSMALLINT *TextLength)
2115 TRACE("\n");
2117 if (!pSQLErrorW) return SQL_ERROR;
2118 return pSQLErrorW(EnvironmentHandle, ConnectionHandle, StatementHandle,
2119 Sqlstate, NativeError, MessageText, BufferLength, TextLength);
2122 /*************************************************************************
2123 * SQLExecDirectW [ODBC32.111]
2125 SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle,
2126 WCHAR *StatementText, SQLINTEGER TextLength)
2128 TRACE("\n");
2130 if (!pSQLExecDirectW) return SQL_ERROR;
2131 return pSQLExecDirectW(StatementHandle, StatementText, TextLength);
2134 /*************************************************************************
2135 * SQLGetCursorNameW [ODBC32.117]
2137 SQLRETURN WINAPI SQLGetCursorNameW(SQLHSTMT StatementHandle,
2138 WCHAR *CursorName, SQLSMALLINT BufferLength,
2139 SQLSMALLINT *NameLength)
2141 TRACE("\n");
2143 if (!pSQLGetCursorNameW) return SQL_ERROR;
2144 return pSQLGetCursorNameW(StatementHandle, CursorName, BufferLength, NameLength);
2147 /*************************************************************************
2148 * SQLPrepareW [ODBC32.119]
2150 SQLRETURN WINAPI SQLPrepareW(SQLHSTMT StatementHandle,
2151 WCHAR *StatementText, SQLINTEGER TextLength)
2153 TRACE("\n");
2155 if (!pSQLPrepareW) return SQL_ERROR;
2156 return pSQLPrepareW(StatementHandle, StatementText, TextLength);
2159 /*************************************************************************
2160 * SQLSetCursorNameW [ODBC32.121]
2162 SQLRETURN WINAPI SQLSetCursorNameW(SQLHSTMT StatementHandle, WCHAR *CursorName, SQLSMALLINT NameLength)
2164 TRACE("\n");
2166 if (!pSQLSetCursorNameW) return SQL_ERROR;
2167 return pSQLSetCursorNameW(StatementHandle, CursorName, NameLength);
2170 /*************************************************************************
2171 * SQLColAttributeW [ODBC32.127]
2173 SQLRETURN WINAPI SQLColAttributeW (SQLHSTMT StatementHandle,
2174 SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
2175 SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
2176 SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute)
2178 SQLRETURN iResult;
2180 TRACE("StatementHandle=%p ColumnNumber=%d FieldIdentifier=%d CharacterAttribute=%p BufferLength=%d StringLength=%p NumericAttribute=%p\n",
2181 StatementHandle, ColumnNumber, FieldIdentifier,
2182 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2184 if (!pSQLColAttributeW) return SQL_ERROR;
2186 iResult = pSQLColAttributeW(StatementHandle, ColumnNumber, FieldIdentifier,
2187 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2188 if (iResult == SQL_SUCCESS && CharacterAttribute != NULL && SQLColAttributes_KnownStringAttribute(FieldIdentifier)) {
2190 TRACE("Dumping values fetched via SQLColAttributeW:\n");
2191 TRACE(" Attribute name : %s\n", debugstr_w(rgbDesc));
2192 TRACE(" Declared length: %d\n", *pcbDesc);
2194 if (*StringLength != lstrlenW(CharacterAttribute) * 2) {
2195 TRACE("CHEAT: resetting name length for ADO\n");
2196 *StringLength = lstrlenW(CharacterAttribute) * 2;
2199 return iResult;
2202 /*************************************************************************
2203 * SQLGetConnectAttrW [ODBC32.132]
2205 SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle,
2206 SQLINTEGER Attribute, SQLPOINTER Value,
2207 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
2209 TRACE("\n");
2211 if (!pSQLGetConnectAttrW) return SQL_ERROR;
2212 return pSQLGetConnectAttrW(ConnectionHandle, Attribute, Value,
2213 BufferLength, StringLength);
2216 /*************************************************************************
2217 * SQLGetDescFieldW [ODBC32.133]
2219 SQLRETURN WINAPI SQLGetDescFieldW(SQLHDESC DescriptorHandle,
2220 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
2221 SQLPOINTER Value, SQLINTEGER BufferLength,
2222 SQLINTEGER *StringLength)
2224 TRACE("\n");
2226 if (!pSQLGetDescFieldW) return SQL_ERROR;
2227 return pSQLGetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier,
2228 Value, BufferLength, StringLength);
2231 /*************************************************************************
2232 * SQLGetDescRecW [ODBC32.134]
2234 SQLRETURN WINAPI SQLGetDescRecW(SQLHDESC DescriptorHandle,
2235 SQLSMALLINT RecNumber, WCHAR *Name,
2236 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
2237 SQLSMALLINT *Type, SQLSMALLINT *SubType,
2238 SQLLEN *Length, SQLSMALLINT *Precision,
2239 SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
2241 TRACE("\n");
2243 if (!pSQLGetDescRecW) return SQL_ERROR;
2244 return pSQLGetDescRecW(DescriptorHandle, RecNumber, Name, BufferLength,
2245 StringLength, Type, SubType, Length, Precision, Scale, Nullable);
2248 /*************************************************************************
2249 * SQLGetDiagFieldW [ODBC32.135]
2251 SQLRETURN WINAPI SQLGetDiagFieldW(SQLSMALLINT HandleType, SQLHANDLE Handle,
2252 SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
2253 SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
2254 SQLSMALLINT *StringLength)
2256 TRACE("\n");
2258 if (!pSQLGetDiagFieldW) return SQL_ERROR;
2259 return pSQLGetDiagFieldW(HandleType, Handle, RecNumber, DiagIdentifier,
2260 DiagInfo, BufferLength, StringLength);
2263 /*************************************************************************
2264 * SQLGetDiagRecW [ODBC32.136]
2266 SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle,
2267 SQLSMALLINT RecNumber, WCHAR *Sqlstate,
2268 SQLINTEGER *NativeError, WCHAR *MessageText,
2269 SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
2271 TRACE("\n");
2273 if (!pSQLGetDiagRecW) return SQL_ERROR;
2274 return pSQLGetDiagRecW(HandleType, Handle, RecNumber, Sqlstate, NativeError,
2275 MessageText, BufferLength, TextLength);
2278 /*************************************************************************
2279 * SQLGetStmtAttrW [ODBC32.138]
2281 SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle,
2282 SQLINTEGER Attribute, SQLPOINTER Value,
2283 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
2285 SQLRETURN iResult;
2287 TRACE("Attribute = (%02d) Value = %p BufferLength = (%d) StringLength = %p\n",
2288 Attribute, Value, BufferLength, StringLength);
2290 if (Value == NULL) {
2291 WARN("Unexpected NULL in Value return address\n");
2292 iResult = SQL_ERROR;
2294 } else if (StringLength == NULL) {
2295 WARN("Unexpected NULL in StringLength return address\n");
2296 iResult = SQL_ERROR;
2298 } else {
2299 if (!pSQLGetStmtAttrW) return SQL_ERROR;
2300 iResult = pSQLGetStmtAttrW(StatementHandle, Attribute, Value, BufferLength, StringLength);
2301 TRACE("returning %d...\n", iResult);
2303 return iResult;
2306 /*************************************************************************
2307 * SQLSetConnectAttrW [ODBC32.139]
2309 SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
2310 SQLPOINTER Value, SQLINTEGER StringLength)
2312 TRACE("\n");
2314 if (!pSQLSetConnectAttrW) return SQL_ERROR;
2315 return pSQLSetConnectAttrW(ConnectionHandle, Attribute, Value, StringLength);
2318 /*************************************************************************
2319 * SQLColumnsW [ODBC32.140]
2321 SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle,
2322 WCHAR *CatalogName, SQLSMALLINT NameLength1,
2323 WCHAR *SchemaName, SQLSMALLINT NameLength2,
2324 WCHAR *TableName, SQLSMALLINT NameLength3,
2325 WCHAR *ColumnName, SQLSMALLINT NameLength4)
2327 TRACE("\n");
2329 if (!pSQLColumnsW) return SQL_ERROR;
2330 return pSQLColumnsW(StatementHandle, CatalogName, NameLength1,
2331 SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
2334 /*************************************************************************
2335 * SQLDriverConnectW [ODBC32.141]
2337 SQLRETURN WINAPI SQLDriverConnectW(
2338 SQLHDBC hdbc,
2339 SQLHWND hwnd,
2340 WCHAR *conn_str_in,
2341 SQLSMALLINT len_conn_str_in,
2342 WCHAR *conn_str_out,
2343 SQLSMALLINT conn_str_out_max,
2344 SQLSMALLINT *ptr_conn_str_out,
2345 SQLUSMALLINT driver_completion )
2347 TRACE("ConnStrIn (%d bytes) --> %s\n", len_conn_str_in, debugstr_w(conn_str_in));
2349 if (!pSQLDriverConnectW) return SQL_ERROR;
2350 return pSQLDriverConnectW(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
2351 conn_str_out_max, ptr_conn_str_out, driver_completion);
2354 /*************************************************************************
2355 * SQLGetConnectOptionW [ODBC32.142]
2357 SQLRETURN WINAPI SQLGetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
2359 TRACE("\n");
2361 if (!pSQLGetConnectOptionW) return SQL_ERROR;
2362 return pSQLGetConnectOptionW(ConnectionHandle, Option, Value);
2365 /*************************************************************************
2366 * SQLGetInfoW [ODBC32.145]
2368 SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle,
2369 SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
2370 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
2372 SQLRETURN iResult;
2374 TRACE("InfoType = (%02u), InfoValue = %p, BufferLength = %d bytes\n", InfoType, InfoValue, BufferLength);
2375 if (InfoValue == NULL) {
2376 WARN("Unexpected NULL in InfoValue address\n");
2377 iResult = SQL_ERROR;
2378 } else {
2379 if (!pSQLGetInfoW) return SQL_ERROR;
2380 iResult = pSQLGetInfoW(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
2381 TRACE("returning %d...\n", iResult);
2383 return iResult;
2386 /*************************************************************************
2387 * SQLGetTypeInfoW [ODBC32.147]
2389 SQLRETURN WINAPI SQLGetTypeInfoW(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
2391 TRACE("\n");
2393 if (!pSQLGetTypeInfoW) return SQL_ERROR;
2394 return pSQLGetTypeInfoW(StatementHandle, DataType);
2397 /*************************************************************************
2398 * SQLSetConnectOptionW [ODBC32.150]
2400 SQLRETURN WINAPI SQLSetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
2402 TRACE("\n");
2404 if (!pSQLSetConnectOptionW) return SQL_ERROR;
2405 return pSQLSetConnectOptionW(ConnectionHandle, Option, Value);
2408 /*************************************************************************
2409 * SQLSpecialColumnsW [ODBC32.152]
2411 SQLRETURN WINAPI SQLSpecialColumnsW(SQLHSTMT StatementHandle,
2412 SQLUSMALLINT IdentifierType, SQLWCHAR *CatalogName,
2413 SQLSMALLINT NameLength1, SQLWCHAR *SchemaName,
2414 SQLSMALLINT NameLength2, SQLWCHAR *TableName,
2415 SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
2416 SQLUSMALLINT Nullable)
2418 if (!pSQLSpecialColumnsW) return SQL_ERROR;
2419 return pSQLSpecialColumnsW(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
2420 NameLength2, TableName, NameLength3, Scope, Nullable);
2423 /*************************************************************************
2424 * SQLStatisticsW [ODBC32.153]
2426 SQLRETURN WINAPI SQLStatisticsW(SQLHSTMT StatementHandle,
2427 SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
2428 SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
2429 SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2430 SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
2432 TRACE("\n");
2434 if (!pSQLStatisticsW) return SQL_ERROR;
2435 return pSQLStatisticsW(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
2436 TableName, NameLength3, Unique, Reserved);
2439 /*************************************************************************
2440 * SQLTablesW [ODBC32.154]
2442 SQLRETURN WINAPI SQLTablesW(SQLHSTMT StatementHandle,
2443 SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
2444 SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
2445 SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2446 SQLWCHAR *TableType, SQLSMALLINT NameLength4)
2448 TRACE("\n");
2450 if (!pSQLTablesW) return SQL_ERROR;
2451 return pSQLTablesW(StatementHandle, CatalogName, NameLength1,
2452 SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
2455 /*************************************************************************
2456 * SQLBrowseConnectW [ODBC32.155]
2458 SQLRETURN WINAPI SQLBrowseConnectW(
2459 SQLHDBC hdbc,
2460 SQLWCHAR *szConnStrIn,
2461 SQLSMALLINT cbConnStrIn,
2462 SQLWCHAR *szConnStrOut,
2463 SQLSMALLINT cbConnStrOutMax,
2464 SQLSMALLINT *pcbConnStrOut)
2466 TRACE("\n");
2468 if (!pSQLBrowseConnectW) return SQL_ERROR;
2469 return pSQLBrowseConnectW(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut,
2470 cbConnStrOutMax, pcbConnStrOut);
2473 /*************************************************************************
2474 * SQLColumnPrivilegesW [ODBC32.156]
2476 SQLRETURN WINAPI SQLColumnPrivilegesW(
2477 SQLHSTMT hstmt,
2478 SQLWCHAR *szCatalogName,
2479 SQLSMALLINT cbCatalogName,
2480 SQLWCHAR *szSchemaName,
2481 SQLSMALLINT cbSchemaName,
2482 SQLWCHAR *szTableName,
2483 SQLSMALLINT cbTableName,
2484 SQLWCHAR *szColumnName,
2485 SQLSMALLINT cbColumnName)
2487 TRACE("\n");
2489 if (!pSQLColumnPrivilegesW) return SQL_ERROR;
2490 return pSQLColumnPrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2491 szTableName, cbTableName, szColumnName, cbColumnName);
2494 /*************************************************************************
2495 * SQLDataSourcesW [ODBC32.157]
2497 SQLRETURN WINAPI SQLDataSourcesW(SQLHENV EnvironmentHandle,
2498 SQLUSMALLINT Direction, WCHAR *ServerName,
2499 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
2500 WCHAR *Description, SQLSMALLINT BufferLength2,
2501 SQLSMALLINT *NameLength2)
2503 SQLRETURN ret;
2505 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
2507 if (!pSQLDataSourcesW) return SQL_ERROR;
2509 ret = pSQLDataSourcesW(EnvironmentHandle, Direction, ServerName,
2510 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
2512 if (TRACE_ON(odbc))
2514 TRACE("returns: %d \t", ret);
2515 if (*NameLength1 > 0)
2516 TRACE("DataSource = %s,", debugstr_w(ServerName));
2517 if (*NameLength2 > 0)
2518 TRACE(" Description = %s", debugstr_w(Description));
2519 TRACE("\n");
2522 return ret;
2525 /*************************************************************************
2526 * SQLForeignKeysW [ODBC32.160]
2528 SQLRETURN WINAPI SQLForeignKeysW(
2529 SQLHSTMT hstmt,
2530 SQLWCHAR *szPkCatalogName,
2531 SQLSMALLINT cbPkCatalogName,
2532 SQLWCHAR *szPkSchemaName,
2533 SQLSMALLINT cbPkSchemaName,
2534 SQLWCHAR *szPkTableName,
2535 SQLSMALLINT cbPkTableName,
2536 SQLWCHAR *szFkCatalogName,
2537 SQLSMALLINT cbFkCatalogName,
2538 SQLWCHAR *szFkSchemaName,
2539 SQLSMALLINT cbFkSchemaName,
2540 SQLWCHAR *szFkTableName,
2541 SQLSMALLINT cbFkTableName)
2543 TRACE("\n");
2545 if (!pSQLForeignKeysW) return SQL_ERROR;
2546 return pSQLForeignKeysW(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
2547 szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
2548 szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
2551 /*************************************************************************
2552 * SQLNativeSqlW [ODBC32.162]
2554 SQLRETURN WINAPI SQLNativeSqlW(
2555 SQLHDBC hdbc,
2556 SQLWCHAR *szSqlStrIn,
2557 SQLINTEGER cbSqlStrIn,
2558 SQLWCHAR *szSqlStr,
2559 SQLINTEGER cbSqlStrMax,
2560 SQLINTEGER *pcbSqlStr)
2562 TRACE("\n");
2564 if (!pSQLNativeSqlW) return SQL_ERROR;
2565 return pSQLNativeSqlW(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
2568 /*************************************************************************
2569 * SQLPrimaryKeysW [ODBC32.165]
2571 SQLRETURN WINAPI SQLPrimaryKeysW(
2572 SQLHSTMT hstmt,
2573 SQLWCHAR *szCatalogName,
2574 SQLSMALLINT cbCatalogName,
2575 SQLWCHAR *szSchemaName,
2576 SQLSMALLINT cbSchemaName,
2577 SQLWCHAR *szTableName,
2578 SQLSMALLINT cbTableName)
2580 TRACE("\n");
2582 if (!pSQLPrimaryKeysW) return SQL_ERROR;
2583 return pSQLPrimaryKeysW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2584 szTableName, cbTableName);
2587 /*************************************************************************
2588 * SQLProcedureColumnsW [ODBC32.166]
2590 SQLRETURN WINAPI SQLProcedureColumnsW(
2591 SQLHSTMT hstmt,
2592 SQLWCHAR *szCatalogName,
2593 SQLSMALLINT cbCatalogName,
2594 SQLWCHAR *szSchemaName,
2595 SQLSMALLINT cbSchemaName,
2596 SQLWCHAR *szProcName,
2597 SQLSMALLINT cbProcName,
2598 SQLWCHAR *szColumnName,
2599 SQLSMALLINT cbColumnName)
2601 TRACE("\n");
2603 if (!pSQLProcedureColumnsW) return SQL_ERROR;
2604 return pSQLProcedureColumnsW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2605 szProcName, cbProcName, szColumnName, cbColumnName);
2608 /*************************************************************************
2609 * SQLProceduresW [ODBC32.167]
2611 SQLRETURN WINAPI SQLProceduresW(
2612 SQLHSTMT hstmt,
2613 SQLWCHAR *szCatalogName,
2614 SQLSMALLINT cbCatalogName,
2615 SQLWCHAR *szSchemaName,
2616 SQLSMALLINT cbSchemaName,
2617 SQLWCHAR *szProcName,
2618 SQLSMALLINT cbProcName)
2620 TRACE("\n");
2622 if (!pSQLProceduresW) return SQL_ERROR;
2623 return pSQLProceduresW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2624 szProcName, cbProcName);
2627 /*************************************************************************
2628 * SQLTablePrivilegesW [ODBC32.170]
2630 SQLRETURN WINAPI SQLTablePrivilegesW(
2631 SQLHSTMT hstmt,
2632 SQLWCHAR *szCatalogName,
2633 SQLSMALLINT cbCatalogName,
2634 SQLWCHAR *szSchemaName,
2635 SQLSMALLINT cbSchemaName,
2636 SQLWCHAR *szTableName,
2637 SQLSMALLINT cbTableName)
2639 TRACE("\n");
2641 if (!pSQLTablePrivilegesW) return SQL_ERROR;
2642 return pSQLTablePrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2643 szTableName, cbTableName);
2646 /*************************************************************************
2647 * SQLDriversW [ODBC32.171]
2649 SQLRETURN WINAPI SQLDriversW(
2650 SQLHENV henv,
2651 SQLUSMALLINT fDirection,
2652 SQLWCHAR *szDriverDesc,
2653 SQLSMALLINT cbDriverDescMax,
2654 SQLSMALLINT *pcbDriverDesc,
2655 SQLWCHAR *szDriverAttributes,
2656 SQLSMALLINT cbDriverAttrMax,
2657 SQLSMALLINT *pcbDriverAttr)
2659 SQLRETURN ret;
2661 TRACE("direction=%d\n", fDirection);
2663 if (!pSQLDriversW) return SQL_ERROR;
2664 ret = pSQLDriversW(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
2665 szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
2667 if (ret == SQL_NO_DATA && fDirection == SQL_FETCH_FIRST)
2668 ERR_(winediag)("No ODBC drivers could be found. "
2669 "Check the settings for your libodbc provider.\n");
2671 return ret;
2674 /*************************************************************************
2675 * SQLSetDescFieldW [ODBC32.173]
2677 SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle,
2678 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
2679 SQLPOINTER Value, SQLINTEGER BufferLength)
2681 TRACE("\n");
2683 if (!pSQLSetDescFieldW) return SQL_ERROR;
2684 return pSQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
2687 /*************************************************************************
2688 * SQLSetStmtAttrW [ODBC32.176]
2690 SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle,
2691 SQLINTEGER Attribute, SQLPOINTER Value,
2692 SQLINTEGER StringLength)
2694 SQLRETURN iResult;
2695 TRACE("Attribute = (%02d) Value = %p StringLength = (%d)\n",
2696 Attribute, Value, StringLength);
2698 if (!pSQLSetStmtAttrW) return SQL_ERROR;
2699 iResult = pSQLSetStmtAttrW(StatementHandle, Attribute, Value, StringLength);
2700 if (iResult == SQL_ERROR && (Attribute == SQL_ROWSET_SIZE || Attribute == SQL_ATTR_ROW_ARRAY_SIZE)) {
2701 TRACE("CHEAT: returning SQL_SUCCESS to ADO...\n");
2702 iResult = SQL_SUCCESS;
2703 } else {
2704 TRACE("returning %d...\n", iResult);
2706 return iResult;
2710 /* End of file */