proxyodbc.c 95 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2
/*
 * Win32 ODBC functions
3
 *
4
 * Copyright 1999 Xiang Li, Corel Corporation
Alexandre Julliard's avatar
Alexandre Julliard committed
5
 *
6 7 8 9 10 11 12 13 14 15 16 17
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 21 22 23 24 25
 *
 * NOTES:
 *   Proxy ODBC driver manager.  This manager delegates all ODBC 
 *   calls to a real ODBC driver manager named by the environment 
 *   variable LIB_ODBC_DRIVER_MANAGER, or to libodbc.so if the
 *   variable is not set.
 *
Alexandre Julliard's avatar
Alexandre Julliard committed
26 27
 */

28
#include "config.h"
29 30
#include "wine/port.h"

31
#include <stdarg.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
32 33 34
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
35
#include <assert.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
36

37
#include "windef.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
38
#include "winbase.h"
39
#include "winreg.h"
40
#include "wine/debug.h"
41
#include "wine/library.h"
42
#include "wine/unicode.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
43 44 45 46 47

#include "sql.h"
#include "sqltypes.h"
#include "sqlext.h"

48 49 50
static BOOL ODBC_LoadDriverManager(void);
static BOOL ODBC_LoadDMFunctions(void);

51
WINE_DEFAULT_DEBUG_CHANNEL(odbc);
Alexandre Julliard's avatar
Alexandre Julliard committed
52

53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
static SQLRETURN (*pSQLAllocConnect)(SQLHENV,SQLHDBC*);
static SQLRETURN (*pSQLAllocEnv)(SQLHENV*);
static SQLRETURN (*pSQLAllocHandle)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
static SQLRETURN (*pSQLAllocHandleStd)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
static SQLRETURN (*pSQLAllocStmt)(SQLHDBC,SQLHSTMT*);
static SQLRETURN (*pSQLBindCol)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLBindParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*);
static SQLRETURN (*pSQLBindParameter)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLBrowseConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLBrowseConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLBulkOperations)(SQLHSTMT,SQLSMALLINT);
static SQLRETURN (*pSQLCancel)(SQLHSTMT);
static SQLRETURN (*pSQLCloseCursor)(SQLHSTMT);
static SQLRETURN (*pSQLColAttribute)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
static SQLRETURN (*pSQLColAttributeW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
static SQLRETURN (*pSQLColAttributes)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLINTEGER*);
static SQLRETURN (*pSQLColAttributesW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
static SQLRETURN (*pSQLColumnPrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLColumnPrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLCopyDesc)(SQLHDESC,SQLHDESC);
static SQLRETURN (*pSQLDataSources)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLDataSourcesW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLDescribeCol)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*);
static SQLRETURN (*pSQLDescribeColW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
static SQLRETURN (*pSQLDescribeParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*);
static SQLRETURN (*pSQLDisconnect)(SQLHDBC);
static SQLRETURN (*pSQLDriverConnect)(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
static SQLRETURN (*pSQLDriverConnectW)(SQLHDBC,SQLHWND,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
static SQLRETURN (*pSQLDrivers)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLDriversW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLEndTran)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT);
static SQLRETURN (*pSQLError)(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLErrorW)(SQLHENV,SQLHDBC,SQLHSTMT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLExecDirect)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
static SQLRETURN (*pSQLExecDirectW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
static SQLRETURN (*pSQLExecute)(SQLHSTMT);
static SQLRETURN (*pSQLExtendedFetch)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUINTEGER*,SQLUSMALLINT*);
static SQLRETURN (*pSQLFetch)(SQLHSTMT);
static SQLRETURN (*pSQLFetchScroll)(SQLHSTMT,SQLSMALLINT,SQLINTEGER);
static SQLRETURN (*pSQLForeignKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLForeignKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLFreeConnect)(SQLHDBC);
static SQLRETURN (*pSQLFreeEnv)(SQLHENV);
static SQLRETURN (*pSQLFreeHandle)(SQLSMALLINT,SQLHANDLE);
static SQLRETURN (*pSQLFreeStmt)(SQLHSTMT,SQLUSMALLINT);
static SQLRETURN (*pSQLGetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLGetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLGetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
static SQLRETURN (*pSQLGetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
static SQLRETURN (*pSQLGetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLGetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLGetData)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLGetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLGetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLGetDescRec)(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLINTEGER*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
static SQLRETURN (*pSQLGetDescRecW)(SQLHDESC,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
static SQLRETURN (*pSQLGetDiagField)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLGetDiagFieldW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLGetDiagRec)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLGetDiagRecW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLGetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLGetFunctions)(SQLHDBC,SQLUSMALLINT,SQLUSMALLINT*);
static SQLRETURN (*pSQLGetInfo)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLGetInfoW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
static SQLRETURN (*pSQLGetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLGetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLGetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLPOINTER);
static SQLRETURN (*pSQLGetTypeInfo)(SQLHSTMT,SQLSMALLINT);
static SQLRETURN (*pSQLGetTypeInfoW)(SQLHSTMT,SQLSMALLINT);
static SQLRETURN (*pSQLMoreResults)(SQLHSTMT);
static SQLRETURN (*pSQLNativeSql)(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLNativeSqlW)(SQLHDBC,SQLWCHAR*,SQLINTEGER,SQLWCHAR*,SQLINTEGER,SQLINTEGER*);
static SQLRETURN (*pSQLNumParams)(SQLHSTMT,SQLSMALLINT*);
static SQLRETURN (*pSQLNumResultCols)(SQLHSTMT,SQLSMALLINT*);
static SQLRETURN (*pSQLParamData)(SQLHSTMT,SQLPOINTER*);
static SQLRETURN (*pSQLParamOptions)(SQLHSTMT,SQLUINTEGER,SQLUINTEGER*);
static SQLRETURN (*pSQLPrepare)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
static SQLRETURN (*pSQLPrepareW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
static SQLRETURN (*pSQLPrimaryKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLPrimaryKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLProcedureColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLProcedureColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLProcedures)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLProceduresW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLPutData)(SQLHSTMT,SQLPOINTER,SQLINTEGER);
static SQLRETURN (*pSQLRowCount)(SQLHSTMT,SQLINTEGER*);
static SQLRETURN (*pSQLSetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
static SQLRETURN (*pSQLSetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
static SQLRETURN (*pSQLSetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLUINTEGER);
static SQLRETURN (*pSQLSetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLULEN);
static SQLRETURN (*pSQLSetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLSetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLSetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
static SQLRETURN (*pSQLSetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
static SQLRETURN (*pSQLSetDescRec)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLINTEGER,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER*,SQLINTEGER*);
static SQLRETURN (*pSQLSetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER);
static SQLRETURN (*pSQLSetParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*);
static SQLRETURN (*pSQLSetPos)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
static SQLRETURN (*pSQLSetScrollOptions)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUSMALLINT);
static SQLRETURN (*pSQLSetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
static SQLRETURN (*pSQLSetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
static SQLRETURN (*pSQLSetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLUINTEGER);
static SQLRETURN (*pSQLSpecialColumns)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
static SQLRETURN (*pSQLSpecialColumnsW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
static SQLRETURN (*pSQLStatistics)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
static SQLRETURN (*pSQLStatisticsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
static SQLRETURN (*pSQLTablePrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLTablePrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLTables)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLTablesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
static SQLRETURN (*pSQLTransact)(SQLHENV,SQLHDBC,SQLUSMALLINT);

#define ERROR_FREE 0
#define ERROR_SQLERROR  1
#define ERROR_LIBRARY_NOT_FOUND 2

static void *dmHandle;
static int nErrorType;
Alexandre Julliard's avatar
Alexandre Julliard committed
175

176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
/***********************************************************************
 * ODBC_ReplicateODBCInstToRegistry
 *
 * PARAMS
 *
 * RETURNS
 *
 * Utility to ODBC_ReplicateToRegistry to replicate the drivers of the
 * ODBCINST.INI settings
 *
 * The driver settings are not replicated to the registry.  If we were to 
 * replicate them we would need to decide whether to replicate all settings
 * or to do some translation; whether to remove any entries present only in
 * the windows registry, etc.
 */

static void ODBC_ReplicateODBCInstToRegistry (SQLHENV hEnv)
{
    HKEY hODBCInst;
    LONG reg_ret;
    int success;

    success = 0;
    TRACE ("Driver settings are not currently replicated to the registry\n");
    if ((reg_ret = RegCreateKeyExA (HKEY_LOCAL_MACHINE,
            "Software\\ODBC\\ODBCINST.INI", 0, NULL,
            REG_OPTION_NON_VOLATILE,
            KEY_ALL_ACCESS /* a couple more than we need */, NULL,
            &hODBCInst, NULL)) == ERROR_SUCCESS)
    {
        HKEY hDrivers;
        if ((reg_ret = RegCreateKeyExA (hODBCInst, "ODBC Drivers", 0,
                NULL, REG_OPTION_NON_VOLATILE,
                KEY_ALL_ACCESS /* overkill */, NULL, &hDrivers, NULL))
                == ERROR_SUCCESS)
        {
            SQLRETURN sql_ret;
            SQLUSMALLINT dirn;
Mike McCormack's avatar
Mike McCormack committed
214
            CHAR desc [256];
215 216 217 218
            SQLSMALLINT sizedesc;

            success = 1;
            dirn = SQL_FETCH_FIRST;
Mike McCormack's avatar
Mike McCormack committed
219
            while ((sql_ret = SQLDrivers (hEnv, dirn, (SQLCHAR*)desc, sizeof(desc),
220 221 222 223 224
                    &sizedesc, NULL, 0, NULL)) == SQL_SUCCESS ||
                    sql_ret == SQL_SUCCESS_WITH_INFO)
            {
                /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
                dirn = SQL_FETCH_NEXT;
225
                if (sizedesc == lstrlenA(desc))
226 227 228 229 230 231
                {
                    HKEY hThis;
                    if ((reg_ret = RegQueryValueExA (hDrivers, desc, NULL,
                            NULL, NULL, NULL)) == ERROR_FILE_NOT_FOUND)
                    {
                        if ((reg_ret = RegSetValueExA (hDrivers, desc, 0,
232
                                REG_SZ, (const BYTE *)"Installed", 10)) != ERROR_SUCCESS)
233
                        {
234
                            TRACE ("Error %d replicating driver %s\n",
235 236 237 238 239 240
                                    reg_ret, desc);
                            success = 0;
                        }
                    }
                    else if (reg_ret != ERROR_SUCCESS)
                    {
241
                        TRACE ("Error %d checking for %s in drivers\n",
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
                                reg_ret, desc);
                        success = 0;
                    }
                    if ((reg_ret = RegCreateKeyExA (hODBCInst, desc, 0,
                            NULL, REG_OPTION_NON_VOLATILE,
                            KEY_ALL_ACCESS, NULL, &hThis, NULL))
                            == ERROR_SUCCESS)
                    {
                        /* FIXME This is where the settings go.
                         * I suggest that if the disposition says it 
                         * exists then we leave it alone.  Alternatively
                         * include an extra value to flag that it is 
                         * a replication of the unixODBC/iODBC/...
                         */
                        if ((reg_ret = RegCloseKey (hThis)) !=
                                ERROR_SUCCESS)
258
                            TRACE ("Error %d closing %s key\n", reg_ret,
259 260 261 262
                                    desc);
                    }
                    else
                    {
263
                        TRACE ("Error %d ensuring driver key %s\n",
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
                                reg_ret, desc);
                        success = 0;
                    }
                }
                else
                {
                    WARN ("Unusually long driver name %s not replicated\n",
                            desc);
                    success = 0;
                }
            }
            if (sql_ret != SQL_NO_DATA)
            {
                TRACE ("Error %d enumerating drivers\n", (int)sql_ret);
                success = 0;
            }
            if ((reg_ret = RegCloseKey (hDrivers)) != ERROR_SUCCESS)
            {
282
                TRACE ("Error %d closing hDrivers\n", reg_ret);
283 284 285 286
            }
        }
        else
        {
287
            TRACE ("Error %d opening HKLM\\S\\O\\OI\\Drivers\n", reg_ret);
288 289 290
        }
        if ((reg_ret = RegCloseKey (hODBCInst)) != ERROR_SUCCESS)
        {
291
            TRACE ("Error %d closing HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
292 293 294 295
        }
    }
    else
    {
296
        TRACE ("Error %d opening HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
    }
    if (!success)
    {
        WARN ("May not have replicated all ODBC drivers to the registry\n");
    }
}

/***********************************************************************
 * ODBC_ReplicateODBCToRegistry
 *
 * PARAMS
 *
 * RETURNS
 *
 * Utility to ODBC_ReplicateToRegistry to replicate either the USER or 
 * SYSTEM dsns
 *
 * For now simply place the "Driver description" (as returned by SQLDataSources)
 * into the registry as the driver.  This is enough to satisfy Crystal's 
 * requirement that there be a driver entry.  (It doesn't seem to care what
 * the setting is).
 * A slightly more accurate setting would be to access the registry to find
 * the actual driver library for the given description (which appears to map
 * to one of the HKLM/Software/ODBC/ODBCINST.INI keys).  (If you do this note
 * that this will add a requirement that this function be called after
 * ODBC_ReplicateODBCInstToRegistry)
 */
static void ODBC_ReplicateODBCToRegistry (int is_user, SQLHENV hEnv)
{
    HKEY hODBC;
    LONG reg_ret;
    SQLRETURN sql_ret;
    SQLUSMALLINT dirn;
Mike McCormack's avatar
Mike McCormack committed
330
    CHAR dsn [SQL_MAX_DSN_LENGTH + 1];
331
    SQLSMALLINT sizedsn;
Mike McCormack's avatar
Mike McCormack committed
332
    CHAR desc [256];
333 334 335 336 337 338 339 340 341 342 343 344 345 346
    SQLSMALLINT sizedesc;
    int success;
    const char *which = is_user ? "user" : "system";

    success = 0;
    if ((reg_ret = RegCreateKeyExA (
            is_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
            "Software\\ODBC\\ODBC.INI", 0, NULL, REG_OPTION_NON_VOLATILE,
            KEY_ALL_ACCESS /* a couple more than we need */, NULL, &hODBC,
            NULL)) == ERROR_SUCCESS)
    {
        success = 1;
        dirn = is_user ? SQL_FETCH_FIRST_USER : SQL_FETCH_FIRST_SYSTEM;
        while ((sql_ret = SQLDataSources (hEnv, dirn,
Mike McCormack's avatar
Mike McCormack committed
347 348
                (SQLCHAR*)dsn, sizeof(dsn), &sizedsn,
                (SQLCHAR*)desc, sizeof(desc), &sizedesc)) == SQL_SUCCESS
349 350 351 352
                || sql_ret == SQL_SUCCESS_WITH_INFO)
        {
            /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
            dirn = SQL_FETCH_NEXT;
353
            if (sizedsn == lstrlenA(dsn) && sizedesc == lstrlenA(desc))
354 355 356 357 358 359 360
            {
                HKEY hDSN;
                if ((reg_ret = RegCreateKeyExA (hODBC, dsn, 0,
                        NULL, REG_OPTION_NON_VOLATILE,
                        KEY_ALL_ACCESS, NULL, &hDSN, NULL))
                        == ERROR_SUCCESS)
                {
361
                    static const char DRIVERKEY[] = "Driver";
362 363 364 365 366
                    if ((reg_ret = RegQueryValueExA (hDSN, DRIVERKEY,
                            NULL, NULL, NULL, NULL))
                            == ERROR_FILE_NOT_FOUND)
                    {
                        if ((reg_ret = RegSetValueExA (hDSN, DRIVERKEY, 0,
Mike McCormack's avatar
Mike McCormack committed
367
                                REG_SZ, (LPBYTE)desc, sizedesc)) != ERROR_SUCCESS)
368
                        {
369
                            TRACE ("Error %d replicating description of "
370 371 372 373 374 375
                                    "%s(%s)\n", reg_ret, dsn, desc);
                            success = 0;
                        }
                    }
                    else if (reg_ret != ERROR_SUCCESS)
                    {
376
                        TRACE ("Error %d checking for description of %s\n",
377 378 379 380 381
                                reg_ret, dsn);
                        success = 0;
                    }
                    if ((reg_ret = RegCloseKey (hDSN)) != ERROR_SUCCESS)
                    {
382
                        TRACE ("Error %d closing %s DSN key %s\n",
383 384 385 386 387
                                reg_ret, which, dsn);
                    }
                }
                else
                {
388
                    TRACE ("Error %d opening %s DSN key %s\n",
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
                            reg_ret, which, dsn);
                    success = 0;
                }
            }
            else
            {
                WARN ("Unusually long %s data source name %s (%s) not "
                        "replicated\n", which, dsn, desc);
                success = 0;
            }
        }
        if (sql_ret != SQL_NO_DATA)
        {
            TRACE ("Error %d enumerating %s datasources\n",
                    (int)sql_ret, which);
            success = 0;
        }
        if ((reg_ret = RegCloseKey (hODBC)) != ERROR_SUCCESS)
        {
408
            TRACE ("Error %d closing %s ODBC.INI registry key\n", reg_ret,
409 410 411 412 413
                    which);
        }
    }
    else
    {
414
        TRACE ("Error %d creating/opening %s ODBC.INI registry key\n",
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
                reg_ret, which);
    }
    if (!success)
    {
        WARN ("May not have replicated all %s ODBC DSNs to the registry\n",
                which);
    }
}

/***********************************************************************
 * ODBC_ReplicateToRegistry
 *
 * PARAMS
 *
 * RETURNS
 *
 * Unfortunately some of the functions that Windows documents as being part
 * of the ODBC API it implements directly during compilation or something
 * in terms of registry access functions.
 * e.g. SQLGetInstalledDrivers queries the list at
 * HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\ODBC Drivers
 *
 * This function is called when the driver manager is loaded and is used
 * to replicate the appropriate details into the Wine registry
 */

static void ODBC_ReplicateToRegistry (void)
{
    SQLRETURN sql_ret;
    SQLHENV hEnv;

    if ((sql_ret = SQLAllocEnv (&hEnv)) == SQL_SUCCESS)
    {
        ODBC_ReplicateODBCInstToRegistry (hEnv);
        ODBC_ReplicateODBCToRegistry (0 /* system dsns */, hEnv);
        ODBC_ReplicateODBCToRegistry (1 /* user dsns */, hEnv);

        if ((sql_ret = SQLFreeEnv (hEnv)) != SQL_SUCCESS)
        {
            TRACE ("Error %d freeing the SQL environment.\n", (int)sql_ret);
        }
    }
    else
    {
        TRACE ("Error %d opening an SQL environment.\n", (int)sql_ret);
        WARN ("The external ODBC settings have not been replicated to the"
                " Wine registry\n");
    }
}

Alexandre Julliard's avatar
Alexandre Julliard committed
465
/***********************************************************************
466
 * DllMain [Internal] Initializes the internal 'ODBC32.DLL'.
Alexandre Julliard's avatar
Alexandre Julliard committed
467 468
 *
 * PARAMS
Andreas Mohr's avatar
Andreas Mohr committed
469
 *     hinstDLL    [I] handle to the DLL's instance
Alexandre Julliard's avatar
Alexandre Julliard committed
470
 *     fdwReason   [I]
Andreas Mohr's avatar
Andreas Mohr committed
471
 *     lpvReserved [I] reserved, must be NULL
Alexandre Julliard's avatar
Alexandre Julliard committed
472 473 474 475 476 477
 *
 * RETURNS
 *     Success: TRUE
 *     Failure: FALSE
 */

478
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Alexandre Julliard's avatar
Alexandre Julliard committed
479
{
480
    TRACE("Initializing or Finalizing proxy ODBC: %p,%x,%p\n", hinstDLL, fdwReason, lpvReserved);
Alexandre Julliard's avatar
Alexandre Julliard committed
481 482 483 484

    if (fdwReason == DLL_PROCESS_ATTACH)
    {
       TRACE("Loading ODBC...\n");
485
       DisableThreadLibraryCalls(hinstDLL);
Alexandre Julliard's avatar
Alexandre Julliard committed
486
       if (ODBC_LoadDriverManager())
487
       {
Alexandre Julliard's avatar
Alexandre Julliard committed
488
          ODBC_LoadDMFunctions();
489 490
          ODBC_ReplicateToRegistry();
       }
Alexandre Julliard's avatar
Alexandre Julliard committed
491 492 493 494
    }
    else if (fdwReason == DLL_PROCESS_DETACH)
    {
      TRACE("Unloading ODBC...\n");
495
      if (dmHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
496
      {
497 498
         wine_dlclose(dmHandle,NULL,0);
         dmHandle = NULL;
Alexandre Julliard's avatar
Alexandre Julliard committed
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
      }
    }

    return TRUE;
}

/***********************************************************************
 * ODBC_LoadDriverManager [Internal] Load ODBC library.
 *
 * PARAMS
 *
 * RETURNS
 *     Success: TRUE
 *     Failure: FALSE
 */

515
static BOOL ODBC_LoadDriverManager(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
516
{
517
   const char *s = getenv("LIB_ODBC_DRIVER_MANAGER");
518
   char error[256];
Alexandre Julliard's avatar
Alexandre Julliard committed
519 520 521

   TRACE("\n");

522 523 524 525
#ifdef SONAME_LIBODBC
   if (!s || !s[0]) s = SONAME_LIBODBC;
#endif
   if (!s || !s[0]) goto failed;
Alexandre Julliard's avatar
Alexandre Julliard committed
526

527
   dmHandle = wine_dlopen(s, RTLD_LAZY | RTLD_GLOBAL, error, sizeof(error));
Alexandre Julliard's avatar
Alexandre Julliard committed
528

529
   if (dmHandle != NULL)
Alexandre Julliard's avatar
Alexandre Julliard committed
530
   {
531
      nErrorType = ERROR_FREE;
Alexandre Julliard's avatar
Alexandre Julliard committed
532 533
      return TRUE;
   }
534 535
failed:
   WARN("failed to open library %s: %s\n", debugstr_a(s), error);
536
   nErrorType = ERROR_LIBRARY_NOT_FOUND;
537
   return FALSE;
Alexandre Julliard's avatar
Alexandre Julliard committed
538 539 540 541 542 543 544 545 546 547 548 549 550
}


/***********************************************************************
 * ODBC_LoadDMFunctions [Internal] Populate function table.
 *
 * PARAMS
 *
 * RETURNS
 *     Success: TRUE
 *     Failure: FALSE
 */

551
static BOOL ODBC_LoadDMFunctions(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
552
{
553
    char error[256];
Alexandre Julliard's avatar
Alexandre Julliard committed
554

555
    if (dmHandle == NULL)
Alexandre Julliard's avatar
Alexandre Julliard committed
556 557
        return FALSE;

558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
#define LOAD_FUNC(name) \
    if ((p##name = wine_dlsym( dmHandle, #name, error, sizeof(error) ))); \
    else WARN( "Failed to load %s: %s\n", #name, error )

    LOAD_FUNC(SQLAllocConnect);
    LOAD_FUNC(SQLAllocEnv);
    LOAD_FUNC(SQLAllocHandle);
    LOAD_FUNC(SQLAllocHandleStd);
    LOAD_FUNC(SQLAllocStmt);
    LOAD_FUNC(SQLBindCol);
    LOAD_FUNC(SQLBindParam);
    LOAD_FUNC(SQLBindParameter);
    LOAD_FUNC(SQLBrowseConnect);
    LOAD_FUNC(SQLBrowseConnectW);
    LOAD_FUNC(SQLBulkOperations);
    LOAD_FUNC(SQLCancel);
    LOAD_FUNC(SQLCloseCursor);
    LOAD_FUNC(SQLColAttribute);
    LOAD_FUNC(SQLColAttributeW);
    LOAD_FUNC(SQLColAttributes);
    LOAD_FUNC(SQLColAttributesW);
    LOAD_FUNC(SQLColumnPrivileges);
    LOAD_FUNC(SQLColumnPrivilegesW);
    LOAD_FUNC(SQLColumns);
    LOAD_FUNC(SQLColumnsW);
    LOAD_FUNC(SQLConnect);
    LOAD_FUNC(SQLConnectW);
    LOAD_FUNC(SQLCopyDesc);
    LOAD_FUNC(SQLDataSources);
    LOAD_FUNC(SQLDataSourcesW);
    LOAD_FUNC(SQLDescribeCol);
    LOAD_FUNC(SQLDescribeColW);
    LOAD_FUNC(SQLDescribeParam);
    LOAD_FUNC(SQLDisconnect);
    LOAD_FUNC(SQLDriverConnect);
    LOAD_FUNC(SQLDriverConnectW);
    LOAD_FUNC(SQLDrivers);
    LOAD_FUNC(SQLDriversW);
    LOAD_FUNC(SQLEndTran);
    LOAD_FUNC(SQLError);
    LOAD_FUNC(SQLErrorW);
    LOAD_FUNC(SQLExecDirect);
    LOAD_FUNC(SQLExecDirectW);
    LOAD_FUNC(SQLExecute);
    LOAD_FUNC(SQLExtendedFetch);
    LOAD_FUNC(SQLFetch);
    LOAD_FUNC(SQLFetchScroll);
    LOAD_FUNC(SQLForeignKeys);
    LOAD_FUNC(SQLForeignKeysW);
    LOAD_FUNC(SQLFreeConnect);
    LOAD_FUNC(SQLFreeEnv);
    LOAD_FUNC(SQLFreeHandle);
    LOAD_FUNC(SQLFreeStmt);
    LOAD_FUNC(SQLGetConnectAttr);
    LOAD_FUNC(SQLGetConnectAttrW);
    LOAD_FUNC(SQLGetConnectOption);
    LOAD_FUNC(SQLGetConnectOptionW);
    LOAD_FUNC(SQLGetCursorName);
    LOAD_FUNC(SQLGetCursorNameW);
    LOAD_FUNC(SQLGetData);
    LOAD_FUNC(SQLGetDescField);
    LOAD_FUNC(SQLGetDescFieldW);
    LOAD_FUNC(SQLGetDescRec);
    LOAD_FUNC(SQLGetDescRecW);
    LOAD_FUNC(SQLGetDiagField);
    LOAD_FUNC(SQLGetDiagFieldW);
    LOAD_FUNC(SQLGetDiagRec);
    LOAD_FUNC(SQLGetDiagRecW);
    LOAD_FUNC(SQLGetEnvAttr);
    LOAD_FUNC(SQLGetFunctions);
    LOAD_FUNC(SQLGetInfo);
    LOAD_FUNC(SQLGetInfoW);
    LOAD_FUNC(SQLGetStmtAttr);
    LOAD_FUNC(SQLGetStmtAttrW);
    LOAD_FUNC(SQLGetStmtOption);
    LOAD_FUNC(SQLGetTypeInfo);
    LOAD_FUNC(SQLGetTypeInfoW);
    LOAD_FUNC(SQLMoreResults);
    LOAD_FUNC(SQLNativeSql);
    LOAD_FUNC(SQLNativeSqlW);
    LOAD_FUNC(SQLNumParams);
    LOAD_FUNC(SQLNumResultCols);
    LOAD_FUNC(SQLParamData);
    LOAD_FUNC(SQLParamOptions);
    LOAD_FUNC(SQLPrepare);
    LOAD_FUNC(SQLPrepareW);
    LOAD_FUNC(SQLPrimaryKeys);
    LOAD_FUNC(SQLPrimaryKeysW);
    LOAD_FUNC(SQLProcedureColumns);
    LOAD_FUNC(SQLProcedureColumnsW);
    LOAD_FUNC(SQLProcedures);
    LOAD_FUNC(SQLProceduresW);
    LOAD_FUNC(SQLPutData);
    LOAD_FUNC(SQLRowCount);
    LOAD_FUNC(SQLSetConnectAttr);
    LOAD_FUNC(SQLSetConnectAttrW);
    LOAD_FUNC(SQLSetConnectOption);
    LOAD_FUNC(SQLSetConnectOptionW);
    LOAD_FUNC(SQLSetCursorName);
    LOAD_FUNC(SQLSetCursorNameW);
    LOAD_FUNC(SQLSetDescField);
    LOAD_FUNC(SQLSetDescFieldW);
    LOAD_FUNC(SQLSetDescRec);
    LOAD_FUNC(SQLSetEnvAttr);
    LOAD_FUNC(SQLSetParam);
    LOAD_FUNC(SQLSetPos);
    LOAD_FUNC(SQLSetScrollOptions);
    LOAD_FUNC(SQLSetStmtAttr);
    LOAD_FUNC(SQLSetStmtAttrW);
    LOAD_FUNC(SQLSetStmtOption);
    LOAD_FUNC(SQLSpecialColumns);
    LOAD_FUNC(SQLSpecialColumnsW);
    LOAD_FUNC(SQLStatistics);
    LOAD_FUNC(SQLStatisticsW);
    LOAD_FUNC(SQLTablePrivileges);
    LOAD_FUNC(SQLTablePrivilegesW);
    LOAD_FUNC(SQLTables);
    LOAD_FUNC(SQLTablesW);
    LOAD_FUNC(SQLTransact);
#undef LOAD_FUNC
Alexandre Julliard's avatar
Alexandre Julliard committed
678 679 680 681 682 683 684 685

    return TRUE;
}


/*************************************************************************
 *				SQLAllocConnect           [ODBC32.001]
 */
686
SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
687
{
688 689
        SQLRETURN ret;
        TRACE("Env=%lx\n",EnvironmentHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
690

691
        if (!pSQLAllocConnect)
Alexandre Julliard's avatar
Alexandre Julliard committed
692 693
        {
           *ConnectionHandle = SQL_NULL_HDBC;
694
           TRACE("Not ready\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
695 696 697
           return SQL_ERROR;
        }

698
        ret = pSQLAllocConnect(EnvironmentHandle, ConnectionHandle);
699 700
        TRACE("Returns ret=%d, Handle %lx\n",ret, *ConnectionHandle);
        return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
701 702 703 704 705 706
}


/*************************************************************************
 *				SQLAllocEnv           [ODBC32.002]
 */
707
SQLRETURN WINAPI  SQLAllocEnv(SQLHENV *EnvironmentHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
708
{
709
        SQLRETURN ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
710 711
        TRACE("\n");

712
        if (!pSQLAllocEnv)
Alexandre Julliard's avatar
Alexandre Julliard committed
713 714
        {
           *EnvironmentHandle = SQL_NULL_HENV;
715
           TRACE("Not ready\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
716 717 718
           return SQL_ERROR;
        }

719
        ret = pSQLAllocEnv(EnvironmentHandle);
720 721
        TRACE("Returns ret=%d, Env=%lx\n",ret, *EnvironmentHandle);
        return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
722 723 724 725 726 727
}


/*************************************************************************
 *				SQLAllocHandle           [ODBC32.024]
 */
728
SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
729
{
730 731
        SQLRETURN ret;
        TRACE("(Type=%d, Handle=%lx)\n",HandleType,InputHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
732

733
        if (!pSQLAllocHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
734
        {
735
            if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
736
                WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
737 738 739 740 741 742 743 744 745 746

            if (HandleType == SQL_HANDLE_ENV)
                *OutputHandle = SQL_NULL_HENV;
            else if (HandleType == SQL_HANDLE_DBC)
                *OutputHandle = SQL_NULL_HDBC;
            else if (HandleType == SQL_HANDLE_STMT)
                *OutputHandle = SQL_NULL_HSTMT;
            else if (HandleType == SQL_HANDLE_DESC)
                *OutputHandle = SQL_NULL_HDESC;

747
            TRACE ("Not ready\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
748 749 750
            return SQL_ERROR;
        }

751
        ret = pSQLAllocHandle(HandleType, InputHandle, OutputHandle);
752 753
        TRACE("Returns ret=%d, Handle=%lx\n",ret, *OutputHandle);
        return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
754 755 756 757 758 759
}


/*************************************************************************
 *				SQLAllocStmt           [ODBC32.003]
 */
760
SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
761
{
762
        SQLRETURN ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
763

764
        TRACE("(Connection=%lx)\n",ConnectionHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
765

766
        if (!pSQLAllocStmt)
Alexandre Julliard's avatar
Alexandre Julliard committed
767 768
        {
           *StatementHandle = SQL_NULL_HSTMT;
769
           TRACE ("Not ready\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
770 771 772
           return SQL_ERROR;
        }

773
        ret = pSQLAllocStmt(ConnectionHandle, StatementHandle);
774 775
        TRACE ("Returns ret=%d, Handle=%lx\n", ret, *StatementHandle);
        return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
776 777 778 779 780 781
}


/*************************************************************************
 *				SQLAllocHandleStd           [ODBC32.077]
 */
782
SQLRETURN WINAPI SQLAllocHandleStd( SQLSMALLINT HandleType,
783
                                    SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
784
{
785
        TRACE("ProxyODBC: SQLAllocHandleStd.\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
786

787
        if (!pSQLAllocHandleStd)
Alexandre Julliard's avatar
Alexandre Julliard committed
788
        {
789
            if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
790
                WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
791 792 793 794 795 796 797 798 799 800 801 802 803

            if (HandleType == SQL_HANDLE_ENV)
                *OutputHandle = SQL_NULL_HENV;
            else if (HandleType == SQL_HANDLE_DBC)
                *OutputHandle = SQL_NULL_HDBC;
            else if (HandleType == SQL_HANDLE_STMT)
                *OutputHandle = SQL_NULL_HSTMT;
            else if (HandleType == SQL_HANDLE_DESC)
                *OutputHandle = SQL_NULL_HDESC;

            return SQL_ERROR;
        }

804
        return pSQLAllocHandleStd(HandleType, InputHandle, OutputHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
805 806 807 808 809 810
}


/*************************************************************************
 *				SQLBindCol           [ODBC32.004]
 */
811
SQLRETURN WINAPI SQLBindCol(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
812 813 814 815 816 817
                     SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
                     SQLPOINTER TargetValue, SQLINTEGER BufferLength,
                     SQLINTEGER *StrLen_or_Ind)
{
        TRACE("\n");

818
        if (!pSQLBindCol)
Alexandre Julliard's avatar
Alexandre Julliard committed
819
        {
820
                TRACE ("Not ready\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
821 822 823
                return SQL_ERROR;
        }

824 825
        return pSQLBindCol(StatementHandle, ColumnNumber, TargetType,
                           TargetValue, BufferLength, StrLen_or_Ind);
Alexandre Julliard's avatar
Alexandre Julliard committed
826 827 828 829 830 831
}


/*************************************************************************
 *				SQLBindParam           [ODBC32.025]
 */
832
SQLRETURN WINAPI SQLBindParam(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
833 834 835 836 837 838 839
             SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
             SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
             SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
             SQLINTEGER *StrLen_or_Ind)
{
        TRACE("\n");

840 841 842 843
        if (!pSQLBindParam) return SQL_ERROR;
        return pSQLBindParam(StatementHandle, ParameterNumber, ValueType,
                             ParameterType, LengthPrecision, ParameterScale,
                             ParameterValue, StrLen_or_Ind);
Alexandre Julliard's avatar
Alexandre Julliard committed
844 845 846 847 848 849
}


/*************************************************************************
 *				SQLCancel           [ODBC32.005]
 */
850
SQLRETURN WINAPI SQLCancel(SQLHSTMT StatementHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
851 852 853
{
        TRACE("\n");

854 855
        if (!pSQLCancel) return SQL_ERROR;
        return pSQLCancel(StatementHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
856 857 858 859 860 861
}


/*************************************************************************
 *				SQLCloseCursor           [ODBC32.026]
 */
862
SQLRETURN WINAPI  SQLCloseCursor(SQLHSTMT StatementHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
863
{
864 865
        SQLRETURN ret;
        TRACE("(Handle=%lx)\n",StatementHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
866

867
        if (!pSQLCloseCursor) return SQL_ERROR;
Alexandre Julliard's avatar
Alexandre Julliard committed
868

869
        ret = pSQLCloseCursor(StatementHandle);
870 871
        TRACE("returns %d\n",ret);
        return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
872 873 874 875 876 877
}


/*************************************************************************
 *				SQLColAttribute           [ODBC32.027]
 */
878
SQLRETURN WINAPI SQLColAttribute (SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
879 880 881 882 883 884
             SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
             SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
             SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute)
{
        TRACE("\n");

885 886 887
        if (!pSQLColAttribute) return SQL_ERROR;
        return pSQLColAttribute(StatementHandle, ColumnNumber, FieldIdentifier,
                                CharacterAttribute, BufferLength, StringLength, NumericAttribute);
Alexandre Julliard's avatar
Alexandre Julliard committed
888 889 890 891 892 893
}


/*************************************************************************
 *				SQLColumns           [ODBC32.040]
 */
894
SQLRETURN WINAPI SQLColumns(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
895 896 897 898 899 900 901
             SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
             SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
             SQLCHAR *TableName, SQLSMALLINT NameLength3,
             SQLCHAR *ColumnName, SQLSMALLINT NameLength4)
{
        TRACE("\n");

902 903 904
        if (!pSQLColumns) return SQL_ERROR;
        return pSQLColumns(StatementHandle, CatalogName, NameLength1,
                           SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
Alexandre Julliard's avatar
Alexandre Julliard committed
905 906 907 908 909 910
}


/*************************************************************************
 *				SQLConnect           [ODBC32.007]
 */
911
SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
912 913 914 915
             SQLCHAR *ServerName, SQLSMALLINT NameLength1,
             SQLCHAR *UserName, SQLSMALLINT NameLength2,
             SQLCHAR *Authentication, SQLSMALLINT NameLength3)
{
916 917
        SQLRETURN ret;
        TRACE("(Server=%.*s)\n",NameLength1, ServerName);
Alexandre Julliard's avatar
Alexandre Julliard committed
918

919
        if (!pSQLConnect) return SQL_ERROR;
Alexandre Julliard's avatar
Alexandre Julliard committed
920

921 922
        ret = pSQLConnect(ConnectionHandle, ServerName, NameLength1,
                          UserName, NameLength2, Authentication, NameLength3);
923 924 925

        TRACE("returns %d\n",ret);
        return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
926 927 928 929 930 931
}


/*************************************************************************
 *				SQLCopyDesc           [ODBC32.028]
 */
932
SQLRETURN WINAPI SQLCopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
933 934 935
{
        TRACE("\n");

936 937
        if (!pSQLCopyDesc) return SQL_ERROR;
        return pSQLCopyDesc(SourceDescHandle, TargetDescHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
938 939 940 941 942 943
}


/*************************************************************************
 *				SQLDataSources           [ODBC32.057]
 */
944
SQLRETURN WINAPI SQLDataSources(SQLHENV EnvironmentHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
945 946 947 948 949 950 951 952 953
             SQLUSMALLINT Direction, SQLCHAR *ServerName,
             SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
             SQLCHAR *Description, SQLSMALLINT BufferLength2,
             SQLSMALLINT *NameLength2)
{
        SQLRETURN ret;

        TRACE("EnvironmentHandle = %p\n", (LPVOID)EnvironmentHandle);

954
        if (!pSQLDataSources) return SQL_ERROR;
Alexandre Julliard's avatar
Alexandre Julliard committed
955

956 957
        ret = pSQLDataSources(EnvironmentHandle, Direction, ServerName,
                              BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
Alexandre Julliard's avatar
Alexandre Julliard committed
958 959 960 961 962

        if (TRACE_ON(odbc))
        {
           TRACE("returns: %d \t", ret);
           if (*NameLength1 > 0)
963
             TRACE("DataSource = %s,", ServerName);
Alexandre Julliard's avatar
Alexandre Julliard committed
964
           if (*NameLength2 > 0)
965 966
             TRACE(" Description = %s", Description);
           TRACE("\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
967 968 969 970 971 972 973 974 975
        }

        return ret;
}


/*************************************************************************
 *				SQLDescribeCol           [ODBC32.008]
 */
976
SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
977 978 979 980 981 982 983
             SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
             SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
             SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
             SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
{
        TRACE("\n");

984 985 986
        if (!pSQLDescribeCol) return SQL_ERROR;
        return pSQLDescribeCol(StatementHandle, ColumnNumber, ColumnName,
                               BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable);
Alexandre Julliard's avatar
Alexandre Julliard committed
987 988 989 990 991 992
}


/*************************************************************************
 *				SQLDisconnect           [ODBC32.009]
 */
993
SQLRETURN WINAPI SQLDisconnect(SQLHDBC ConnectionHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
994
{
995 996
        SQLRETURN ret;
        TRACE("(Handle=%lx)\n", ConnectionHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
997

998
        if (!pSQLDisconnect) return SQL_ERROR;
Alexandre Julliard's avatar
Alexandre Julliard committed
999

1000
        ret = pSQLDisconnect(ConnectionHandle);
1001 1002
        TRACE("returns %d\n",ret);
        return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
1003 1004 1005 1006 1007 1008
}


/*************************************************************************
 *				SQLEndTran           [ODBC32.029]
 */
1009
SQLRETURN WINAPI SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT CompletionType)
Alexandre Julliard's avatar
Alexandre Julliard committed
1010 1011 1012
{
        TRACE("\n");

1013 1014
        if (!pSQLEndTran) return SQL_ERROR;
        return pSQLEndTran(HandleType, Handle, CompletionType);
Alexandre Julliard's avatar
Alexandre Julliard committed
1015 1016 1017 1018 1019 1020
}


/*************************************************************************
 *				SQLError           [ODBC32.010]
 */
1021
SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1022 1023 1024 1025 1026 1027 1028
             SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
             SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
             SQLCHAR *MessageText, SQLSMALLINT BufferLength,
             SQLSMALLINT *TextLength)
{
        TRACE("\n");

1029 1030 1031
        if (!pSQLError) return SQL_ERROR;
        return pSQLError(EnvironmentHandle, ConnectionHandle, StatementHandle,
                         Sqlstate, NativeError, MessageText, BufferLength, TextLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1032 1033 1034 1035 1036 1037
}


/*************************************************************************
 *				SQLExecDirect           [ODBC32.011]
 */
1038
SQLRETURN WINAPI SQLExecDirect(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
Alexandre Julliard's avatar
Alexandre Julliard committed
1039 1040 1041
{
        TRACE("\n");

1042 1043
        if (!pSQLExecDirect) return SQL_ERROR;
        return pSQLExecDirect(StatementHandle, StatementText, TextLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1044 1045 1046 1047 1048 1049
}


/*************************************************************************
 *				SQLExecute           [ODBC32.012]
 */
1050
SQLRETURN WINAPI SQLExecute(SQLHSTMT StatementHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
1051 1052 1053
{
        TRACE("\n");

1054 1055
        if (!pSQLExecute) return SQL_ERROR;
        return pSQLExecute(StatementHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
1056 1057 1058 1059 1060 1061
}


/*************************************************************************
 *				SQLFetch           [ODBC32.013]
 */
1062
SQLRETURN WINAPI SQLFetch(SQLHSTMT StatementHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
1063 1064 1065
{
        TRACE("\n");

1066 1067
        if (!pSQLFetch) return SQL_ERROR;
        return pSQLFetch(StatementHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
1068 1069 1070 1071 1072 1073
}


/*************************************************************************
 *				SQLFetchScroll          [ODBC32.030]
 */
1074
SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset)
Alexandre Julliard's avatar
Alexandre Julliard committed
1075 1076 1077
{
        TRACE("\n");

1078 1079
        if (!pSQLFetchScroll) return SQL_ERROR;
        return pSQLFetchScroll(StatementHandle, FetchOrientation, FetchOffset);
Alexandre Julliard's avatar
Alexandre Julliard committed
1080 1081 1082 1083 1084 1085
}


/*************************************************************************
 *				SQLFreeConnect           [ODBC32.014]
 */
1086
SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
1087
{
1088 1089
        SQLRETURN ret;
        TRACE("(Handle=%lx)\n",ConnectionHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
1090

1091
        if (!pSQLFreeConnect) return SQL_ERROR;
Alexandre Julliard's avatar
Alexandre Julliard committed
1092

1093
        ret = pSQLFreeConnect(ConnectionHandle);
1094 1095
        TRACE("Returns %d\n",ret);
        return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
1096 1097 1098 1099 1100 1101
}


/*************************************************************************
 *				SQLFreeEnv           [ODBC32.015]
 */
1102
SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle)
Alexandre Julliard's avatar
Alexandre Julliard committed
1103 1104
{
        SQLRETURN ret;
1105
        TRACE("(Env=%lx)\n",EnvironmentHandle);
Alexandre Julliard's avatar
Alexandre Julliard committed
1106

1107
        if (!pSQLFreeEnv) return SQL_ERROR;
Alexandre Julliard's avatar
Alexandre Julliard committed
1108

1109
        ret = pSQLFreeEnv(EnvironmentHandle);
1110
        TRACE("Returns %d\n",ret);
Alexandre Julliard's avatar
Alexandre Julliard committed
1111 1112 1113 1114 1115 1116 1117
        return ret;
}


/*************************************************************************
 *				SQLFreeHandle           [ODBC32.031]
 */
1118
SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
Alexandre Julliard's avatar
Alexandre Julliard committed
1119 1120
{
        SQLRETURN ret;
1121
        TRACE("(Type=%d, Handle=%lx)\n",HandleType,Handle);
Alexandre Julliard's avatar
Alexandre Julliard committed
1122

1123
        if (!pSQLFreeHandle) return SQL_ERROR;
Alexandre Julliard's avatar
Alexandre Julliard committed
1124

1125
        ret = pSQLFreeHandle(HandleType, Handle);
1126
        TRACE ("Returns %d\n",ret);
Alexandre Julliard's avatar
Alexandre Julliard committed
1127 1128 1129 1130 1131 1132 1133
        return ret;
}


/*************************************************************************
 *				SQLFreeStmt           [ODBC32.016]
 */
1134
SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
Alexandre Julliard's avatar
Alexandre Julliard committed
1135
{
1136 1137
        SQLRETURN ret;
        TRACE("(Handle %lx, Option=%d)\n",StatementHandle, Option);
Alexandre Julliard's avatar
Alexandre Julliard committed
1138

1139
        if (!pSQLFreeStmt) return SQL_ERROR;
Alexandre Julliard's avatar
Alexandre Julliard committed
1140

1141
        ret = pSQLFreeStmt(StatementHandle, Option);
1142 1143
        TRACE("Returns %d\n",ret);
        return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
1144 1145 1146 1147 1148 1149
}


/*************************************************************************
 *				SQLGetConnectAttr           [ODBC32.032]
 */
1150
SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1151 1152 1153 1154 1155
             SQLINTEGER Attribute, SQLPOINTER Value,
             SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
        TRACE("\n");

1156 1157 1158
        if (!pSQLGetConnectAttr) return SQL_ERROR;
        return pSQLGetConnectAttr(ConnectionHandle, Attribute, Value,
                                  BufferLength, StringLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1159 1160 1161 1162 1163 1164
}


/*************************************************************************
 *				SQLGetConnectOption       [ODBC32.042]
 */
1165
SQLRETURN WINAPI SQLGetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
Alexandre Julliard's avatar
Alexandre Julliard committed
1166 1167 1168
{
        TRACE("\n");

1169 1170
        if (!pSQLGetConnectOption) return SQL_ERROR;
        return pSQLGetConnectOption(ConnectionHandle, Option, Value);
Alexandre Julliard's avatar
Alexandre Julliard committed
1171 1172 1173 1174 1175 1176
}


/*************************************************************************
 *				SQLGetCursorName           [ODBC32.017]
 */
1177
SQLRETURN WINAPI SQLGetCursorName(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1178 1179 1180 1181 1182
             SQLCHAR *CursorName, SQLSMALLINT BufferLength,
             SQLSMALLINT *NameLength)
{
        TRACE("\n");

1183 1184
        if (!pSQLGetCursorName) return SQL_ERROR;
        return pSQLGetCursorName(StatementHandle, CursorName, BufferLength, NameLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1185 1186 1187 1188 1189 1190
}


/*************************************************************************
 *				SQLGetData           [ODBC32.043]
 */
1191
SQLRETURN WINAPI SQLGetData(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1192 1193 1194 1195 1196 1197
             SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
             SQLPOINTER TargetValue, SQLINTEGER BufferLength,
             SQLINTEGER *StrLen_or_Ind)
{
        TRACE("\n");

1198 1199 1200
        if (!pSQLGetData) return SQL_ERROR;
        return pSQLGetData(StatementHandle, ColumnNumber, TargetType,
                           TargetValue, BufferLength, StrLen_or_Ind);
Alexandre Julliard's avatar
Alexandre Julliard committed
1201 1202 1203 1204 1205 1206
}


/*************************************************************************
 *				SQLGetDescField           [ODBC32.033]
 */
1207
SQLRETURN WINAPI SQLGetDescField(SQLHDESC DescriptorHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1208 1209 1210 1211 1212 1213
             SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
             SQLPOINTER Value, SQLINTEGER BufferLength,
             SQLINTEGER *StringLength)
{
        TRACE("\n");

1214 1215 1216
        if (!pSQLGetDescField) return SQL_ERROR;
        return pSQLGetDescField(DescriptorHandle, RecNumber, FieldIdentifier,
                                Value, BufferLength, StringLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1217 1218 1219 1220 1221 1222
}


/*************************************************************************
 *				SQLGetDescRec           [ODBC32.034]
 */
1223
SQLRETURN WINAPI SQLGetDescRec(SQLHDESC DescriptorHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1224 1225 1226 1227 1228 1229 1230 1231
             SQLSMALLINT RecNumber, SQLCHAR *Name,
             SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
             SQLSMALLINT *Type, SQLSMALLINT *SubType,
             SQLINTEGER *Length, SQLSMALLINT *Precision,
             SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
{
        TRACE("\n");

1232 1233 1234
        if (!pSQLGetDescRec) return SQL_ERROR;
        return pSQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength,
                              StringLength, Type, SubType, Length, Precision, Scale, Nullable);
Alexandre Julliard's avatar
Alexandre Julliard committed
1235 1236 1237 1238 1239 1240
}


/*************************************************************************
 *				SQLGetDiagField           [ODBC32.035]
 */
1241
SQLRETURN WINAPI SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1242 1243 1244 1245 1246 1247
             SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
             SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
             SQLSMALLINT *StringLength)
{
        TRACE("\n");

1248 1249 1250
        if (!pSQLGetDiagField) return SQL_ERROR;
        return pSQLGetDiagField(HandleType, Handle, RecNumber, DiagIdentifier,
                                DiagInfo, BufferLength, StringLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1251 1252 1253 1254 1255 1256
}


/*************************************************************************
 *				SQLGetDiagRec           [ODBC32.036]
 */
1257
SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1258 1259 1260 1261 1262 1263
             SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
             SQLINTEGER *NativeError, SQLCHAR *MessageText,
             SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
{
        TRACE("\n");

1264 1265 1266
        if (!pSQLGetDiagRec) return SQL_ERROR;
        return pSQLGetDiagRec(HandleType, Handle, RecNumber, Sqlstate, NativeError,
                              MessageText, BufferLength, TextLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1267 1268 1269 1270 1271 1272
}


/*************************************************************************
 *				SQLGetEnvAttr           [ODBC32.037]
 */
1273
SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1274 1275 1276 1277 1278
             SQLINTEGER Attribute, SQLPOINTER Value,
             SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
        TRACE("\n");

1279 1280
        if (!pSQLGetEnvAttr) return SQL_ERROR;
        return pSQLGetEnvAttr(EnvironmentHandle, Attribute, Value, BufferLength, StringLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1281 1282 1283 1284 1285 1286
}


/*************************************************************************
 *				SQLGetFunctions           [ODBC32.044]
 */
1287
SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
Alexandre Julliard's avatar
Alexandre Julliard committed
1288 1289 1290
{
        TRACE("\n");

1291 1292
        if (!pSQLGetFunctions) return SQL_ERROR;
        return pSQLGetFunctions(ConnectionHandle, FunctionId, Supported);
Alexandre Julliard's avatar
Alexandre Julliard committed
1293 1294 1295 1296 1297 1298
}


/*************************************************************************
 *				SQLGetInfo           [ODBC32.045]
 */
1299
SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1300 1301 1302 1303 1304
             SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
             SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
{
        TRACE("\n");

1305 1306
        if (!pSQLGetInfo) return SQL_ERROR;
        return pSQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1307 1308 1309 1310
}


/*************************************************************************
1311
 *				SQLGetStmtAttr           [ODBC32.038]
Alexandre Julliard's avatar
Alexandre Julliard committed
1312
 */
1313
SQLRETURN WINAPI SQLGetStmtAttr(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1314 1315 1316 1317 1318
             SQLINTEGER Attribute, SQLPOINTER Value,
             SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
        TRACE("\n");

1319 1320
        if (!pSQLGetStmtAttr) return SQL_ERROR;
        return pSQLGetStmtAttr(StatementHandle, Attribute, Value, BufferLength, StringLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1321 1322 1323 1324 1325 1326
}


/*************************************************************************
 *				SQLGetStmtOption           [ODBC32.046]
 */
1327
SQLRETURN WINAPI SQLGetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLPOINTER Value)
Alexandre Julliard's avatar
Alexandre Julliard committed
1328 1329 1330
{
        TRACE("\n");

1331 1332
        if (!pSQLGetStmtOption) return SQL_ERROR;
        return pSQLGetStmtOption(StatementHandle, Option, Value);
Alexandre Julliard's avatar
Alexandre Julliard committed
1333 1334 1335 1336
}


/*************************************************************************
1337
 *				SQLGetTypeInfo           [ODBC32.047]
Alexandre Julliard's avatar
Alexandre Julliard committed
1338
 */
1339
SQLRETURN WINAPI SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
Alexandre Julliard's avatar
Alexandre Julliard committed
1340 1341 1342
{
        TRACE("\n");

1343 1344
        if (!pSQLGetTypeInfo) return SQL_ERROR;
        return pSQLGetTypeInfo(StatementHandle, DataType);
Alexandre Julliard's avatar
Alexandre Julliard committed
1345 1346 1347 1348 1349 1350
}


/*************************************************************************
 *				SQLNumResultCols           [ODBC32.018]
 */
1351
SQLRETURN WINAPI SQLNumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT *ColumnCount)
Alexandre Julliard's avatar
Alexandre Julliard committed
1352 1353 1354
{
        TRACE("\n");

1355 1356
        if (!pSQLNumResultCols) return SQL_ERROR;
        return pSQLNumResultCols(StatementHandle, ColumnCount);
Alexandre Julliard's avatar
Alexandre Julliard committed
1357 1358 1359 1360 1361 1362
}


/*************************************************************************
 *				SQLParamData           [ODBC32.048]
 */
1363
SQLRETURN WINAPI SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER *Value)
Alexandre Julliard's avatar
Alexandre Julliard committed
1364 1365 1366
{
        TRACE("\n");

1367 1368
        if (!pSQLParamData) return SQL_ERROR;
        return pSQLParamData(StatementHandle, Value);
Alexandre Julliard's avatar
Alexandre Julliard committed
1369 1370 1371 1372 1373 1374
}


/*************************************************************************
 *				SQLPrepare           [ODBC32.019]
 */
1375
SQLRETURN WINAPI SQLPrepare(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
Alexandre Julliard's avatar
Alexandre Julliard committed
1376 1377 1378
{
        TRACE("\n");

1379 1380
        if (!pSQLPrepare) return SQL_ERROR;
        return pSQLPrepare(StatementHandle, StatementText, TextLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1381 1382 1383 1384 1385 1386
}


/*************************************************************************
 *				SQLPutData           [ODBC32.049]
 */
1387
SQLRETURN WINAPI SQLPutData(SQLHSTMT StatementHandle, SQLPOINTER Data, SQLINTEGER StrLen_or_Ind)
Alexandre Julliard's avatar
Alexandre Julliard committed
1388 1389 1390
{
        TRACE("\n");

1391 1392
        if (!pSQLPutData) return SQL_ERROR;
        return pSQLPutData(StatementHandle, Data, StrLen_or_Ind);
Alexandre Julliard's avatar
Alexandre Julliard committed
1393 1394 1395 1396 1397 1398
}


/*************************************************************************
 *				SQLRowCount           [ODBC32.020]
 */
1399
SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLINTEGER *RowCount)
Alexandre Julliard's avatar
Alexandre Julliard committed
1400 1401 1402
{
        TRACE("\n");

1403 1404
        if (!pSQLRowCount) return SQL_ERROR;
        return pSQLRowCount(StatementHandle, RowCount);
Alexandre Julliard's avatar
Alexandre Julliard committed
1405 1406 1407 1408 1409 1410
}


/*************************************************************************
 *				SQLSetConnectAttr           [ODBC32.039]
 */
1411
SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
Alexandre Julliard's avatar
Alexandre Julliard committed
1412 1413 1414 1415
        SQLPOINTER Value, SQLINTEGER StringLength)
{
        TRACE("\n");

1416 1417
        if (!pSQLSetConnectAttr) return SQL_ERROR;
        return pSQLSetConnectAttr(ConnectionHandle, Attribute, Value, StringLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1418 1419 1420 1421 1422 1423
}


/*************************************************************************
 *				SQLSetConnectOption           [ODBC32.050]
 */
1424
SQLRETURN WINAPI SQLSetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
Alexandre Julliard's avatar
Alexandre Julliard committed
1425 1426 1427
{
        TRACE("\n");

1428 1429
        if (!pSQLSetConnectOption) return SQL_ERROR;
        return pSQLSetConnectOption(ConnectionHandle, Option, Value);
Alexandre Julliard's avatar
Alexandre Julliard committed
1430 1431 1432 1433 1434 1435
}


/*************************************************************************
 *				SQLSetCursorName           [ODBC32.021]
 */
1436
SQLRETURN WINAPI SQLSetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName, SQLSMALLINT NameLength)
Alexandre Julliard's avatar
Alexandre Julliard committed
1437 1438 1439
{
        TRACE("\n");

1440 1441
        if (!pSQLSetCursorName) return SQL_ERROR;
        return pSQLSetCursorName(StatementHandle, CursorName, NameLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1442 1443 1444 1445 1446 1447
}


/*************************************************************************
 *				SQLSetDescField           [ODBC32.073]
 */
1448
SQLRETURN WINAPI SQLSetDescField(SQLHDESC DescriptorHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1449 1450 1451 1452 1453
             SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
             SQLPOINTER Value, SQLINTEGER BufferLength)
{
        TRACE("\n");

1454 1455
        if (!pSQLSetDescField) return SQL_ERROR;
        return pSQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1456 1457 1458 1459 1460 1461
}


/*************************************************************************
 *				SQLSetDescRec           [ODBC32.074]
 */
1462
SQLRETURN WINAPI SQLSetDescRec(SQLHDESC DescriptorHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1463 1464 1465 1466 1467 1468 1469 1470
             SQLSMALLINT RecNumber, SQLSMALLINT Type,
             SQLSMALLINT SubType, SQLINTEGER Length,
             SQLSMALLINT Precision, SQLSMALLINT Scale,
             SQLPOINTER Data, SQLINTEGER *StringLength,
             SQLINTEGER *Indicator)
{
        TRACE("\n");

1471 1472 1473
        if (!pSQLSetDescRec) return SQL_ERROR;
        return pSQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length,
                              Precision, Scale, Data, StringLength, Indicator);
Alexandre Julliard's avatar
Alexandre Julliard committed
1474 1475 1476 1477 1478 1479
}


/*************************************************************************
 *				SQLSetEnvAttr           [ODBC32.075]
 */
1480
SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1481 1482 1483 1484 1485
             SQLINTEGER Attribute, SQLPOINTER Value,
             SQLINTEGER StringLength)
{
        TRACE("\n");

1486 1487
        if (!pSQLSetEnvAttr) return SQL_ERROR;
        return pSQLSetEnvAttr(EnvironmentHandle, Attribute, Value, StringLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1488 1489 1490 1491 1492 1493
}


/*************************************************************************
 *				SQLSetParam           [ODBC32.022]
 */
1494
SQLRETURN WINAPI SQLSetParam(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1495 1496 1497 1498 1499 1500 1501
             SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
             SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
             SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
             SQLINTEGER *StrLen_or_Ind)
{
        TRACE("\n");

1502 1503 1504
        if (!pSQLSetParam) return SQL_ERROR;
        return pSQLSetParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision,
                            ParameterScale, ParameterValue, StrLen_or_Ind);
Alexandre Julliard's avatar
Alexandre Julliard committed
1505 1506 1507 1508 1509 1510
}


/*************************************************************************
 *				SQLSetStmtAttr           [ODBC32.076]
 */
1511
SQLRETURN WINAPI SQLSetStmtAttr(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1512 1513 1514 1515 1516
                 SQLINTEGER Attribute, SQLPOINTER Value,
                 SQLINTEGER StringLength)
{
        TRACE("\n");

1517 1518
        if (!pSQLSetStmtAttr) return SQL_ERROR;
        return pSQLSetStmtAttr(StatementHandle, Attribute, Value, StringLength);
Alexandre Julliard's avatar
Alexandre Julliard committed
1519 1520 1521 1522 1523 1524
}


/*************************************************************************
 *				SQLSetStmtOption           [ODBC32.051]
 */
1525
SQLRETURN WINAPI SQLSetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
Alexandre Julliard's avatar
Alexandre Julliard committed
1526 1527 1528
{
        TRACE("\n");

1529 1530
        if (!pSQLSetStmtOption) return SQL_ERROR;
        return pSQLSetStmtOption(StatementHandle, Option, Value);
Alexandre Julliard's avatar
Alexandre Julliard committed
1531 1532 1533 1534 1535 1536
}


/*************************************************************************
 *				SQLSpecialColumns           [ODBC32.052]
 */
1537
SQLRETURN WINAPI SQLSpecialColumns(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1538 1539 1540 1541 1542 1543 1544
             SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
             SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
             SQLSMALLINT NameLength2, SQLCHAR *TableName,
             SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
             SQLUSMALLINT Nullable)
{

1545 1546 1547
        if (!pSQLSpecialColumns) return SQL_ERROR;
        return pSQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
                                  NameLength2, TableName, NameLength3, Scope, Nullable);
Alexandre Julliard's avatar
Alexandre Julliard committed
1548 1549 1550 1551
}


/*************************************************************************
1552
 *				SQLStatistics           [ODBC32.053]
Alexandre Julliard's avatar
Alexandre Julliard committed
1553
 */
1554
SQLRETURN WINAPI SQLStatistics(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1555 1556 1557 1558 1559 1560 1561
             SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
             SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
             SQLCHAR *TableName, SQLSMALLINT NameLength3,
             SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
{
        TRACE("\n");

1562 1563 1564
        if (!pSQLStatistics) return SQL_ERROR;
        return pSQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
                              TableName, NameLength3, Unique, Reserved);
Alexandre Julliard's avatar
Alexandre Julliard committed
1565 1566 1567 1568 1569 1570
}


/*************************************************************************
 *				SQLTables           [ODBC32.054]
 */
1571
SQLRETURN WINAPI SQLTables(SQLHSTMT StatementHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1572 1573 1574 1575 1576 1577 1578
             SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
             SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
             SQLCHAR *TableName, SQLSMALLINT NameLength3,
             SQLCHAR *TableType, SQLSMALLINT NameLength4)
{
        TRACE("\n");

1579 1580 1581
        if (!pSQLTables) return SQL_ERROR;
        return pSQLTables(StatementHandle, CatalogName, NameLength1,
                          SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
Alexandre Julliard's avatar
Alexandre Julliard committed
1582 1583 1584 1585 1586 1587
}


/*************************************************************************
 *				SQLTransact           [ODBC32.023]
 */
1588
SQLRETURN WINAPI SQLTransact(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle,
Alexandre Julliard's avatar
Alexandre Julliard committed
1589 1590 1591 1592
        SQLUSMALLINT CompletionType)
{
        TRACE("\n");

1593 1594
        if (!pSQLTransact) return SQL_ERROR;
        return pSQLTransact(EnvironmentHandle, ConnectionHandle, CompletionType);
Alexandre Julliard's avatar
Alexandre Julliard committed
1595 1596 1597 1598 1599 1600
}


/*************************************************************************
 *				SQLBrowseConnect           [ODBC32.055]
 */
1601
SQLRETURN WINAPI SQLBrowseConnect(
Alexandre Julliard's avatar
Alexandre Julliard committed
1602 1603 1604 1605 1606 1607 1608 1609 1610
    SQLHDBC            hdbc,
    SQLCHAR               *szConnStrIn,
    SQLSMALLINT        cbConnStrIn,
    SQLCHAR               *szConnStrOut,
    SQLSMALLINT        cbConnStrOutMax,
    SQLSMALLINT       *pcbConnStrOut)
{
        TRACE("\n");

1611 1612
        if (!pSQLBrowseConnect) return SQL_ERROR;
        return pSQLBrowseConnect(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut);
Alexandre Julliard's avatar
Alexandre Julliard committed
1613 1614 1615 1616 1617 1618
}


/*************************************************************************
 *				SQLBulkOperations           [ODBC32.078]
 */
1619
SQLRETURN WINAPI  SQLBulkOperations(
Alexandre Julliard's avatar
Alexandre Julliard committed
1620 1621 1622 1623 1624
        SQLHSTMT                        StatementHandle,
        SQLSMALLINT                     Operation)
{
        TRACE("\n");

1625 1626
        if (!pSQLBulkOperations) return SQL_ERROR;
        return pSQLBulkOperations(StatementHandle, Operation);
Alexandre Julliard's avatar
Alexandre Julliard committed
1627 1628 1629 1630 1631 1632
}


/*************************************************************************
 *				SQLColAttributes           [ODBC32.006]
 */
1633
SQLRETURN WINAPI SQLColAttributes(
Alexandre Julliard's avatar
Alexandre Julliard committed
1634 1635 1636 1637 1638 1639 1640 1641 1642 1643
    SQLHSTMT           hstmt,
    SQLUSMALLINT       icol,
    SQLUSMALLINT       fDescType,
    SQLPOINTER         rgbDesc,
    SQLSMALLINT        cbDescMax,
    SQLSMALLINT           *pcbDesc,
    SQLINTEGER            *pfDesc)
{
        TRACE("\n");

1644 1645
        if (!pSQLColAttributes) return SQL_ERROR;
        return pSQLColAttributes(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
Alexandre Julliard's avatar
Alexandre Julliard committed
1646 1647 1648 1649 1650 1651
}


/*************************************************************************
 *				SQLColumnPrivileges           [ODBC32.056]
 */
1652
SQLRETURN WINAPI SQLColumnPrivileges(
Alexandre Julliard's avatar
Alexandre Julliard committed
1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664
    SQLHSTMT           hstmt,
    SQLCHAR               *szCatalogName,
    SQLSMALLINT        cbCatalogName,
    SQLCHAR               *szSchemaName,
    SQLSMALLINT        cbSchemaName,
    SQLCHAR               *szTableName,
    SQLSMALLINT        cbTableName,
    SQLCHAR               *szColumnName,
    SQLSMALLINT        cbColumnName)
{
        TRACE("\n");

1665 1666 1667
        if (!pSQLColumnPrivileges) return SQL_ERROR;
        return pSQLColumnPrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
                                    szTableName, cbTableName, szColumnName, cbColumnName);
Alexandre Julliard's avatar
Alexandre Julliard committed
1668 1669 1670 1671 1672 1673
}


/*************************************************************************
 *				SQLDescribeParam          [ODBC32.058]
 */
1674
SQLRETURN WINAPI SQLDescribeParam(
Alexandre Julliard's avatar
Alexandre Julliard committed
1675 1676 1677 1678 1679 1680 1681 1682 1683
    SQLHSTMT           hstmt,
    SQLUSMALLINT       ipar,
    SQLSMALLINT           *pfSqlType,
    SQLUINTEGER           *pcbParamDef,
    SQLSMALLINT           *pibScale,
    SQLSMALLINT           *pfNullable)
{
        TRACE("\n");

1684 1685
        if (!pSQLDescribeParam) return SQL_ERROR;
        return pSQLDescribeParam(hstmt, ipar, pfSqlType, pcbParamDef, pibScale, pfNullable);
Alexandre Julliard's avatar
Alexandre Julliard committed
1686 1687 1688 1689 1690 1691
}


/*************************************************************************
 *				SQLExtendedFetch           [ODBC32.059]
 */
1692
SQLRETURN WINAPI SQLExtendedFetch(
Alexandre Julliard's avatar
Alexandre Julliard committed
1693 1694 1695 1696 1697 1698 1699 1700
    SQLHSTMT           hstmt,
    SQLUSMALLINT       fFetchType,
    SQLINTEGER         irow,
    SQLUINTEGER           *pcrow,
    SQLUSMALLINT          *rgfRowStatus)
{
        TRACE("\n");

1701 1702
        if (!pSQLExtendedFetch) return SQL_ERROR;
        return pSQLExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus);
Alexandre Julliard's avatar
Alexandre Julliard committed
1703 1704 1705 1706 1707 1708
}


/*************************************************************************
 *				SQLForeignKeys           [ODBC32.060]
 */
1709
SQLRETURN WINAPI SQLForeignKeys(
Alexandre Julliard's avatar
Alexandre Julliard committed
1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725
    SQLHSTMT           hstmt,
    SQLCHAR               *szPkCatalogName,
    SQLSMALLINT        cbPkCatalogName,
    SQLCHAR               *szPkSchemaName,
    SQLSMALLINT        cbPkSchemaName,
    SQLCHAR               *szPkTableName,
    SQLSMALLINT        cbPkTableName,
    SQLCHAR               *szFkCatalogName,
    SQLSMALLINT        cbFkCatalogName,
    SQLCHAR               *szFkSchemaName,
    SQLSMALLINT        cbFkSchemaName,
    SQLCHAR               *szFkTableName,
    SQLSMALLINT        cbFkTableName)
{
        TRACE("\n");

1726 1727 1728 1729
        if (!pSQLForeignKeys) return SQL_ERROR;
        return pSQLForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
                               szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
                               szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
Alexandre Julliard's avatar
Alexandre Julliard committed
1730 1731 1732 1733 1734 1735
}


/*************************************************************************
 *				SQLMoreResults           [ODBC32.061]
 */
1736
SQLRETURN WINAPI SQLMoreResults(SQLHSTMT hstmt)
Alexandre Julliard's avatar
Alexandre Julliard committed
1737 1738 1739
{
        TRACE("\n");

1740 1741
        if (!pSQLMoreResults) return SQL_ERROR;
        return pSQLMoreResults(hstmt);
Alexandre Julliard's avatar
Alexandre Julliard committed
1742 1743 1744 1745 1746 1747
}


/*************************************************************************
 *				SQLNativeSql           [ODBC32.062]
 */
1748
SQLRETURN WINAPI SQLNativeSql(
Alexandre Julliard's avatar
Alexandre Julliard committed
1749 1750 1751 1752 1753 1754 1755 1756 1757
    SQLHDBC            hdbc,
    SQLCHAR               *szSqlStrIn,
    SQLINTEGER         cbSqlStrIn,
    SQLCHAR               *szSqlStr,
    SQLINTEGER         cbSqlStrMax,
    SQLINTEGER            *pcbSqlStr)
{
        TRACE("\n");

1758 1759
        if (!pSQLNativeSql) return SQL_ERROR;
        return pSQLNativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
Alexandre Julliard's avatar
Alexandre Julliard committed
1760 1761 1762 1763 1764 1765
}


/*************************************************************************
 *				SQLNumParams           [ODBC32.063]
 */
1766
SQLRETURN WINAPI SQLNumParams(
Alexandre Julliard's avatar
Alexandre Julliard committed
1767 1768 1769 1770 1771
    SQLHSTMT           hstmt,
    SQLSMALLINT           *pcpar)
{
        TRACE("\n");

1772 1773
        if (!pSQLNumParams) return SQL_ERROR;
        return pSQLNumParams(hstmt, pcpar);
Alexandre Julliard's avatar
Alexandre Julliard committed
1774 1775 1776 1777 1778 1779
}


/*************************************************************************
 *				SQLParamOptions           [ODBC32.064]
 */
1780
SQLRETURN WINAPI SQLParamOptions(
Alexandre Julliard's avatar
Alexandre Julliard committed
1781 1782 1783 1784 1785 1786
    SQLHSTMT           hstmt,
    SQLUINTEGER        crow,
    SQLUINTEGER           *pirow)
{
        TRACE("\n");

1787 1788
        if (!pSQLParamOptions) return SQL_ERROR;
        return pSQLParamOptions(hstmt, crow, pirow);
Alexandre Julliard's avatar
Alexandre Julliard committed
1789 1790 1791 1792 1793 1794
}


/*************************************************************************
 *				SQLPrimaryKeys           [ODBC32.065]
 */
1795
SQLRETURN WINAPI SQLPrimaryKeys(
Alexandre Julliard's avatar
Alexandre Julliard committed
1796 1797 1798 1799 1800 1801 1802 1803 1804 1805
    SQLHSTMT           hstmt,
    SQLCHAR               *szCatalogName,
    SQLSMALLINT        cbCatalogName,
    SQLCHAR               *szSchemaName,
    SQLSMALLINT        cbSchemaName,
    SQLCHAR               *szTableName,
    SQLSMALLINT        cbTableName)
{
        TRACE("\n");

1806 1807 1808
        if (!pSQLPrimaryKeys) return SQL_ERROR;
        return pSQLPrimaryKeys(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
                               szTableName, cbTableName);
Alexandre Julliard's avatar
Alexandre Julliard committed
1809 1810 1811 1812 1813 1814
}


/*************************************************************************
 *				SQLProcedureColumns           [ODBC32.066]
 */
1815
SQLRETURN WINAPI SQLProcedureColumns(
Alexandre Julliard's avatar
Alexandre Julliard committed
1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827
    SQLHSTMT           hstmt,
    SQLCHAR               *szCatalogName,
    SQLSMALLINT        cbCatalogName,
    SQLCHAR               *szSchemaName,
    SQLSMALLINT        cbSchemaName,
    SQLCHAR               *szProcName,
    SQLSMALLINT        cbProcName,
    SQLCHAR               *szColumnName,
    SQLSMALLINT        cbColumnName)
{
        TRACE("\n");

1828 1829 1830
        if (!pSQLProcedureColumns) return SQL_ERROR;
        return pSQLProcedureColumns(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
                                    szProcName, cbProcName, szColumnName, cbColumnName);
Alexandre Julliard's avatar
Alexandre Julliard committed
1831 1832 1833 1834 1835 1836
}


/*************************************************************************
 *				SQLProcedures           [ODBC32.067]
 */
1837
SQLRETURN WINAPI SQLProcedures(
Alexandre Julliard's avatar
Alexandre Julliard committed
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847
    SQLHSTMT           hstmt,
    SQLCHAR               *szCatalogName,
    SQLSMALLINT        cbCatalogName,
    SQLCHAR               *szSchemaName,
    SQLSMALLINT        cbSchemaName,
    SQLCHAR               *szProcName,
    SQLSMALLINT        cbProcName)
{
        TRACE("\n");

1848 1849 1850
        if (!pSQLProcedures) return SQL_ERROR;
        return pSQLProcedures(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
                              szProcName, cbProcName);
Alexandre Julliard's avatar
Alexandre Julliard committed
1851 1852 1853 1854 1855 1856
}


/*************************************************************************
 *				SQLSetPos           [ODBC32.068]
 */
1857
SQLRETURN WINAPI SQLSetPos(
Alexandre Julliard's avatar
Alexandre Julliard committed
1858 1859 1860 1861 1862 1863 1864
    SQLHSTMT           hstmt,
    SQLUSMALLINT       irow,
    SQLUSMALLINT       fOption,
    SQLUSMALLINT       fLock)
{
        TRACE("\n");

1865 1866
        if (!pSQLSetPos) return SQL_ERROR;
        return pSQLSetPos(hstmt, irow, fOption, fLock);
Alexandre Julliard's avatar
Alexandre Julliard committed
1867 1868 1869 1870 1871 1872
}


/*************************************************************************
 *				SQLTablePrivileges           [ODBC32.070]
 */
1873
SQLRETURN WINAPI SQLTablePrivileges(
Alexandre Julliard's avatar
Alexandre Julliard committed
1874 1875 1876 1877 1878 1879 1880 1881 1882 1883
    SQLHSTMT           hstmt,
    SQLCHAR               *szCatalogName,
    SQLSMALLINT        cbCatalogName,
    SQLCHAR               *szSchemaName,
    SQLSMALLINT        cbSchemaName,
    SQLCHAR               *szTableName,
    SQLSMALLINT        cbTableName)
{
        TRACE("\n");

1884 1885 1886
        if (!pSQLTablePrivileges) return SQL_ERROR;
        return pSQLTablePrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
                                   szTableName, cbTableName);
Alexandre Julliard's avatar
Alexandre Julliard committed
1887 1888 1889 1890 1891 1892
}


/*************************************************************************
 *				SQLDrivers           [ODBC32.071]
 */
1893
SQLRETURN WINAPI SQLDrivers(
Alexandre Julliard's avatar
Alexandre Julliard committed
1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904
    SQLHENV            henv,
    SQLUSMALLINT       fDirection,
    SQLCHAR               *szDriverDesc,
    SQLSMALLINT        cbDriverDescMax,
    SQLSMALLINT           *pcbDriverDesc,
    SQLCHAR               *szDriverAttributes,
    SQLSMALLINT        cbDriverAttrMax,
    SQLSMALLINT           *pcbDriverAttr)
{
        TRACE("\n");

1905 1906 1907
        if (!pSQLDrivers) return SQL_ERROR;
        return pSQLDrivers(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
                           szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
Alexandre Julliard's avatar
Alexandre Julliard committed
1908 1909 1910 1911 1912 1913
}


/*************************************************************************
 *				SQLBindParameter           [ODBC32.072]
 */
1914
SQLRETURN WINAPI SQLBindParameter(
Alexandre Julliard's avatar
Alexandre Julliard committed
1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927
    SQLHSTMT           hstmt,
    SQLUSMALLINT       ipar,
    SQLSMALLINT        fParamType,
    SQLSMALLINT        fCType,
    SQLSMALLINT        fSqlType,
    SQLUINTEGER        cbColDef,
    SQLSMALLINT        ibScale,
    SQLPOINTER         rgbValue,
    SQLINTEGER         cbValueMax,
    SQLINTEGER            *pcbValue)
{
        TRACE("\n");

1928 1929 1930
        if (!pSQLBindParameter) return SQL_ERROR;
        return pSQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale,
                                 rgbValue, cbValueMax, pcbValue);
Alexandre Julliard's avatar
Alexandre Julliard committed
1931 1932 1933 1934 1935 1936
}


/*************************************************************************
 *				SQLDriverConnect           [ODBC32.041]
 */
1937
SQLRETURN WINAPI SQLDriverConnect(
Alexandre Julliard's avatar
Alexandre Julliard committed
1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948
    SQLHDBC            hdbc,
    SQLHWND            hwnd,
    SQLCHAR            *conn_str_in,
    SQLSMALLINT        len_conn_str_in,
    SQLCHAR            *conn_str_out,
    SQLSMALLINT        conn_str_out_max,
    SQLSMALLINT        *ptr_conn_str_out,
    SQLUSMALLINT       driver_completion )
{
        TRACE("\n");

1949 1950 1951
        if (!pSQLDriverConnect) return SQL_ERROR;
        return pSQLDriverConnect(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
                                 conn_str_out_max, ptr_conn_str_out, driver_completion);
Alexandre Julliard's avatar
Alexandre Julliard committed
1952 1953 1954 1955 1956 1957
}


/*************************************************************************
 *				SQLSetScrollOptions           [ODBC32.069]
 */
1958
SQLRETURN WINAPI SQLSetScrollOptions(
Alexandre Julliard's avatar
Alexandre Julliard committed
1959 1960 1961 1962 1963 1964 1965
    SQLHSTMT           statement_handle,
    SQLUSMALLINT       f_concurrency,
    SQLINTEGER         crow_keyset,
    SQLUSMALLINT       crow_rowset )
{
        TRACE("\n");

1966 1967
        if (!pSQLSetScrollOptions) return SQL_ERROR;
        return pSQLSetScrollOptions(statement_handle, f_concurrency, crow_keyset, crow_rowset);
Alexandre Julliard's avatar
Alexandre Julliard committed
1968 1969
}

1970 1971
static int SQLColAttributes_KnownStringAttribute(SQLUSMALLINT fDescType)
{
1972
    static const SQLUSMALLINT attrList[] =
1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016
    {
        SQL_COLUMN_OWNER_NAME,
        SQL_COLUMN_QUALIFIER_NAME,
        SQL_COLUMN_LABEL,
        SQL_COLUMN_NAME,
        SQL_COLUMN_TABLE_NAME,
        SQL_COLUMN_TYPE_NAME,
        SQL_DESC_BASE_COLUMN_NAME,
        SQL_DESC_BASE_TABLE_NAME,
        SQL_DESC_CATALOG_NAME,
        SQL_DESC_LABEL,
        SQL_DESC_LITERAL_PREFIX,
        SQL_DESC_LITERAL_SUFFIX,
        SQL_DESC_LOCAL_TYPE_NAME,
        SQL_DESC_NAME,
        SQL_DESC_SCHEMA_NAME,
        SQL_DESC_TABLE_NAME,
        SQL_DESC_TYPE_NAME,
    };
    unsigned int i;

    for (i = 0; i < sizeof(attrList) / sizeof(SQLUSMALLINT); i++) {
        if (attrList[i] == fDescType) return 1;
    }
    return 0;
}

/*************************************************************************
 *				SQLColAttributesW          [ODBC32.106]
 */
SQLRETURN WINAPI SQLColAttributesW(
    SQLHSTMT           hstmt,
    SQLUSMALLINT       icol,
    SQLUSMALLINT       fDescType,
    SQLPOINTER         rgbDesc,
    SQLSMALLINT        cbDescMax,
    SQLSMALLINT           *pcbDesc,
    SQLINTEGER            *pfDesc)
{
        SQLRETURN iResult;

        TRACE("hstmt=0x%08lx icol=%d fDescType=%d rgbDesc=%p cbDescMax=%d pcbDesc=%p pfDesc=%p\n",
            hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);

2017 2018 2019
        if (!pSQLColAttributesW) return SQL_ERROR;

        iResult = pSQLColAttributesW(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2020 2021 2022 2023 2024 2025
        if (iResult == SQL_SUCCESS && rgbDesc != NULL && SQLColAttributes_KnownStringAttribute(fDescType)) {
        /*
            TRACE("Dumping values fetched via SQLColAttributesW:\n");
            TRACE("    Attribute name : %s\n", debugstr_w(rgbDesc));
            TRACE("    Declared length: %d\n", *pcbDesc);
        */
2026
            if (*pcbDesc != lstrlenW(rgbDesc) * 2) {
2027
                TRACE("CHEAT: resetting name length for ADO\n");
2028
                *pcbDesc = lstrlenW(rgbDesc) * 2;
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044
            }
        }
        return iResult;
}

/*************************************************************************
 *				SQLConnectW          [ODBC32.107]
 */
SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle,
             WCHAR *ServerName, SQLSMALLINT NameLength1,
             WCHAR *UserName, SQLSMALLINT NameLength2,
             WCHAR *Authentication, SQLSMALLINT NameLength3)
{
        SQLRETURN ret;
        TRACE("(Server=%.*s)\n",NameLength1+3, debugstr_w(ServerName));

2045
        if (!pSQLConnectW) return SQL_ERROR;
2046

2047 2048
        ret = pSQLConnectW(ConnectionHandle, ServerName, NameLength1,
                           UserName, NameLength2, Authentication, NameLength3);
2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065

        TRACE("returns %d\n",ret);
        return ret;
}

/*************************************************************************
 *				SQLDescribeColW          [ODBC32.108]
 */
SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle,
             SQLUSMALLINT ColumnNumber, WCHAR *ColumnName,
             SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
             SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
             SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
{
        SQLRETURN iResult;
        TRACE("\n");

2066
        if (!pSQLDescribeColW) return SQL_ERROR;
2067

2068 2069 2070
        iResult = pSQLDescribeColW(StatementHandle, ColumnNumber, ColumnName,
                                   BufferLength, NameLength, DataType, ColumnSize,
                                   DecimalDigits, Nullable);
2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093
        if (iResult >= 0) {
            TRACE("Successfully recovered the following column information:\n");
            TRACE("\tRequested column index: %d\n", ColumnNumber);
            TRACE("\tAvailable length for column name: %d\n", BufferLength);
            if (NameLength != NULL)
                TRACE("\tActual length for column name: %d\n", *NameLength);
            else TRACE("\tActual length for column name: (null)\n");
            TRACE("\tReturned column name: %s\n", debugstr_w(ColumnName));
        }
        return iResult;
}

/*************************************************************************
 *				SQLErrorW          [ODBC32.110]
 */
SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle,
             SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
             WCHAR *Sqlstate, SQLINTEGER *NativeError,
             WCHAR *MessageText, SQLSMALLINT BufferLength,
             SQLSMALLINT *TextLength)
{
        TRACE("\n");

2094 2095 2096
        if (!pSQLErrorW) return SQL_ERROR;
        return pSQLErrorW(EnvironmentHandle, ConnectionHandle, StatementHandle,
                          Sqlstate, NativeError, MessageText, BufferLength, TextLength);
2097 2098 2099 2100 2101 2102 2103 2104 2105 2106
}

/*************************************************************************
 *				SQLExecDirectW          [ODBC32.111]
 */
SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle,
    WCHAR *StatementText, SQLINTEGER TextLength)
{
        TRACE("\n");

2107 2108
        if (!pSQLExecDirectW) return SQL_ERROR;
        return pSQLExecDirectW(StatementHandle, StatementText, TextLength);
2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119
}

/*************************************************************************
 *				SQLGetCursorNameW          [ODBC32.117]
 */
SQLRETURN WINAPI SQLGetCursorNameW(SQLHSTMT StatementHandle,
             WCHAR *CursorName, SQLSMALLINT BufferLength,
             SQLSMALLINT *NameLength)
{
        TRACE("\n");

2120 2121
        if (!pSQLGetCursorNameW) return SQL_ERROR;
        return pSQLGetCursorNameW(StatementHandle, CursorName, BufferLength, NameLength);
2122 2123 2124 2125 2126 2127 2128 2129 2130 2131
}

/*************************************************************************
 *				SQLPrepareW          [ODBC32.119]
 */
SQLRETURN WINAPI SQLPrepareW(SQLHSTMT StatementHandle,
    WCHAR *StatementText, SQLINTEGER TextLength)
{
        TRACE("\n");

2132 2133
        if (!pSQLPrepareW) return SQL_ERROR;
        return pSQLPrepareW(StatementHandle, StatementText, TextLength);
2134 2135 2136 2137 2138 2139 2140 2141 2142
}

/*************************************************************************
 *				SQLSetCursorNameW          [ODBC32.121]
 */
SQLRETURN WINAPI SQLSetCursorNameW(SQLHSTMT StatementHandle, WCHAR *CursorName, SQLSMALLINT NameLength)
{
        TRACE("\n");

2143 2144
        if (!pSQLSetCursorNameW) return SQL_ERROR;
        return pSQLSetCursorNameW(StatementHandle, CursorName, NameLength);
2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160
}

/*************************************************************************
 *				SQLColAttributeW          [ODBC32.127]
 */
SQLRETURN WINAPI SQLColAttributeW (SQLHSTMT StatementHandle,
             SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
             SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
             SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute)
{
        SQLRETURN iResult;

        TRACE("StatementHandle=0x%08lx ColumnNumber=%d FieldIdentifier=%d CharacterAttribute=%p BufferLength=%d StringLength=%p NumericAttribute=%p\n",
            StatementHandle, ColumnNumber, FieldIdentifier,
            CharacterAttribute, BufferLength, StringLength, NumericAttribute);

2161
        if (!pSQLColAttributeW) return SQL_ERROR;
2162

2163 2164
        iResult = pSQLColAttributeW(StatementHandle, ColumnNumber, FieldIdentifier,
                                    CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2165 2166 2167 2168 2169 2170
        if (iResult == SQL_SUCCESS && CharacterAttribute != NULL && SQLColAttributes_KnownStringAttribute(FieldIdentifier)) {
        /*
            TRACE("Dumping values fetched via SQLColAttributeW:\n");
            TRACE("    Attribute name : %s\n", debugstr_w(rgbDesc));
            TRACE("    Declared length: %d\n", *pcbDesc);
        */
2171
            if (*StringLength != lstrlenW(CharacterAttribute) * 2) {
2172
                TRACE("CHEAT: resetting name length for ADO\n");
2173
                *StringLength = lstrlenW(CharacterAttribute) * 2;
2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187
            }
        }
        return iResult;
}

/*************************************************************************
 *				SQLGetConnectAttrW          [ODBC32.132]
 */
SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle,
             SQLINTEGER Attribute, SQLPOINTER Value,
             SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
        TRACE("\n");

2188 2189 2190
        if (!pSQLGetConnectAttrW) return SQL_ERROR;
        return pSQLGetConnectAttrW(ConnectionHandle, Attribute, Value,
                                   BufferLength, StringLength);
2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202
}

/*************************************************************************
 *				SQLGetDescFieldW          [ODBC32.133]
 */
SQLRETURN WINAPI SQLGetDescFieldW(SQLHDESC DescriptorHandle,
             SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
             SQLPOINTER Value, SQLINTEGER BufferLength,
             SQLINTEGER *StringLength)
{
        TRACE("\n");

2203 2204 2205
        if (!pSQLGetDescFieldW) return SQL_ERROR;
        return pSQLGetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier,
                                 Value, BufferLength, StringLength);
2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219
}

/*************************************************************************
 *				SQLGetDescRecW          [ODBC32.134]
 */
SQLRETURN WINAPI SQLGetDescRecW(SQLHDESC DescriptorHandle,
             SQLSMALLINT RecNumber, WCHAR *Name,
             SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
             SQLSMALLINT *Type, SQLSMALLINT *SubType,
             SQLINTEGER *Length, SQLSMALLINT *Precision,
             SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
{
        TRACE("\n");

2220 2221 2222
        if (!pSQLGetDescRecW) return SQL_ERROR;
        return pSQLGetDescRecW(DescriptorHandle, RecNumber, Name, BufferLength,
                               StringLength, Type, SubType, Length, Precision, Scale, Nullable);
2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234
}

/*************************************************************************
 *				SQLGetDiagFieldW          [ODBC32.135]
 */
SQLRETURN WINAPI SQLGetDiagFieldW(SQLSMALLINT HandleType, SQLHANDLE Handle,
             SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
             SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
             SQLSMALLINT *StringLength)
{
        TRACE("\n");

2235 2236 2237
        if (!pSQLGetDiagFieldW) return SQL_ERROR;
        return pSQLGetDiagFieldW(HandleType, Handle, RecNumber, DiagIdentifier,
                                 DiagInfo, BufferLength, StringLength);
2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249
}

/*************************************************************************
 *				SQLGetDiagRecW           [ODBC32.136]
 */
SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle,
             SQLSMALLINT RecNumber, WCHAR *Sqlstate,
             SQLINTEGER *NativeError, WCHAR *MessageText,
             SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
{
        TRACE("\n");

2250 2251 2252
        if (!pSQLGetDiagRecW) return SQL_ERROR;
        return pSQLGetDiagRecW(HandleType, Handle, RecNumber, Sqlstate, NativeError,
                               MessageText, BufferLength, TextLength);
2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275
}

/*************************************************************************
 *				SQLGetStmtAttrW          [ODBC32.138]
 */
SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle,
             SQLINTEGER Attribute, SQLPOINTER Value,
             SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
        SQLRETURN iResult;

        TRACE("Attribute = (%02ld) Value = %p BufferLength = (%ld) StringLength = %p\n",
            Attribute, Value, BufferLength, StringLength);

        if (Value == NULL) {
            WARN("Unexpected NULL in Value return address\n");
            iResult = SQL_ERROR;
/*
        } else if (StringLength == NULL) {
            WARN("Unexpected NULL in StringLength return address\n");
            iResult = SQL_ERROR;
*/
        } else {
2276 2277
            if (!pSQLGetStmtAttrW) return SQL_ERROR;
            iResult = pSQLGetStmtAttrW(StatementHandle, Attribute, Value, BufferLength, StringLength);
2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290
            TRACE("returning %d...\n", iResult);
        }
        return iResult;
}

/*************************************************************************
 *				SQLSetConnectAttrW          [ODBC32.139]
 */
SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
        SQLPOINTER Value, SQLINTEGER StringLength)
{
        TRACE("\n");

2291 2292
        if (!pSQLSetConnectAttrW) return SQL_ERROR;
        return pSQLSetConnectAttrW(ConnectionHandle, Attribute, Value, StringLength);
2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305
}

/*************************************************************************
 *				SQLColumnsW          [ODBC32.140]
 */
SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle,
             WCHAR *CatalogName, SQLSMALLINT NameLength1,
             WCHAR *SchemaName, SQLSMALLINT NameLength2,
             WCHAR *TableName, SQLSMALLINT NameLength3,
             WCHAR *ColumnName, SQLSMALLINT NameLength4)
{
        TRACE("\n");

2306 2307 2308
        if (!pSQLColumnsW) return SQL_ERROR;
        return pSQLColumnsW(StatementHandle, CatalogName, NameLength1,
                            SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325
}

/*************************************************************************
 *				SQLDriverConnectW          [ODBC32.141]
 */
SQLRETURN WINAPI SQLDriverConnectW(
    SQLHDBC            hdbc,
    SQLHWND            hwnd,
    WCHAR              *conn_str_in,
    SQLSMALLINT        len_conn_str_in,
    WCHAR              *conn_str_out,
    SQLSMALLINT        conn_str_out_max,
    SQLSMALLINT        *ptr_conn_str_out,
    SQLUSMALLINT       driver_completion )
{
        TRACE("ConnStrIn (%d bytes) --> %s\n", len_conn_str_in, debugstr_w(conn_str_in));

2326 2327 2328
        if (!pSQLDriverConnectW) return SQL_ERROR;
        return pSQLDriverConnectW(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
                                  conn_str_out_max, ptr_conn_str_out, driver_completion);
2329 2330 2331 2332 2333 2334 2335 2336 2337
}

/*************************************************************************
 *				SQLGetConnectOptionW      [ODBC32.142]
 */
SQLRETURN WINAPI SQLGetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
{
        TRACE("\n");

2338 2339
        if (!pSQLGetConnectOptionW) return SQL_ERROR;
        return pSQLGetConnectOptionW(ConnectionHandle, Option, Value);
2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355
}

/*************************************************************************
 *				SQLGetInfoW          [ODBC32.145]
 */
SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle,
             SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
             SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
{
        SQLRETURN iResult;

        TRACE("InfoType = (%02u), InfoValue = %p, BufferLength = %d bytes\n", InfoType, InfoValue, BufferLength);
        if (InfoValue == NULL) {
                WARN("Unexpected NULL in InfoValue address\n");
                iResult = SQL_ERROR;
        } else {
2356 2357
                if (!pSQLGetInfoW) return SQL_ERROR;
                iResult = pSQLGetInfoW(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369
                TRACE("returning %d...\n", iResult);
        }
        return iResult;
}

/*************************************************************************
 *				SQLGetTypeInfoW          [ODBC32.147]
 */
SQLRETURN WINAPI SQLGetTypeInfoW(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
{
        TRACE("\n");

2370 2371
        if (!pSQLGetTypeInfoW) return SQL_ERROR;
        return pSQLGetTypeInfoW(StatementHandle, DataType);
2372 2373 2374 2375 2376 2377 2378 2379 2380
}

/*************************************************************************
 *				SQLSetConnectOptionW          [ODBC32.150]
 */
SQLRETURN WINAPI SQLSetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
{
        TRACE("\n");

2381 2382
        if (!pSQLSetConnectOptionW) return SQL_ERROR;
        return pSQLSetConnectOptionW(ConnectionHandle, Option, Value);
2383 2384 2385 2386 2387 2388
}

/*************************************************************************
 *				SQLSpecialColumnsW          [ODBC32.152]
 */
SQLRETURN WINAPI SQLSpecialColumnsW(SQLHSTMT StatementHandle,
2389 2390 2391
             SQLUSMALLINT IdentifierType, SQLWCHAR *CatalogName,
             SQLSMALLINT NameLength1, SQLWCHAR *SchemaName,
             SQLSMALLINT NameLength2, SQLWCHAR *TableName,
2392 2393 2394
             SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
             SQLUSMALLINT Nullable)
{
2395 2396 2397
        if (!pSQLSpecialColumnsW) return SQL_ERROR;
        return pSQLSpecialColumnsW(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
                                   NameLength2, TableName, NameLength3, Scope, Nullable);
2398 2399 2400 2401 2402 2403
}

/*************************************************************************
 *				SQLStatisticsW          [ODBC32.153]
 */
SQLRETURN WINAPI SQLStatisticsW(SQLHSTMT StatementHandle,
2404 2405 2406
             SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
             SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
             SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2407 2408 2409 2410
             SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
{
        TRACE("\n");

2411 2412 2413
        if (!pSQLStatisticsW) return SQL_ERROR;
        return pSQLStatisticsW(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
                               TableName, NameLength3, Unique, Reserved);
2414 2415 2416 2417 2418 2419
}

/*************************************************************************
 *				SQLTablesW          [ODBC32.154]
 */
SQLRETURN WINAPI SQLTablesW(SQLHSTMT StatementHandle,
2420 2421 2422 2423
             SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
             SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
             SQLWCHAR *TableName, SQLSMALLINT NameLength3,
             SQLWCHAR *TableType, SQLSMALLINT NameLength4)
2424 2425 2426
{
        TRACE("\n");

2427 2428 2429
        if (!pSQLTablesW) return SQL_ERROR;
        return pSQLTablesW(StatementHandle, CatalogName, NameLength1,
                           SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
2430 2431 2432 2433 2434 2435 2436
}

/*************************************************************************
 *				SQLBrowseConnectW          [ODBC32.155]
 */
SQLRETURN WINAPI SQLBrowseConnectW(
    SQLHDBC            hdbc,
2437
    SQLWCHAR               *szConnStrIn,
2438
    SQLSMALLINT        cbConnStrIn,
2439
    SQLWCHAR               *szConnStrOut,
2440 2441 2442 2443 2444
    SQLSMALLINT        cbConnStrOutMax,
    SQLSMALLINT       *pcbConnStrOut)
{
        TRACE("\n");

2445 2446 2447
        if (!pSQLBrowseConnectW) return SQL_ERROR;
        return pSQLBrowseConnectW(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut,
                                  cbConnStrOutMax, pcbConnStrOut);
2448 2449 2450 2451 2452 2453 2454
}

/*************************************************************************
 *				SQLColumnPrivilegesW          [ODBC32.156]
 */
SQLRETURN WINAPI SQLColumnPrivilegesW(
    SQLHSTMT           hstmt,
2455
    SQLWCHAR               *szCatalogName,
2456
    SQLSMALLINT        cbCatalogName,
2457
    SQLWCHAR               *szSchemaName,
2458
    SQLSMALLINT        cbSchemaName,
2459
    SQLWCHAR               *szTableName,
2460
    SQLSMALLINT        cbTableName,
2461
    SQLWCHAR               *szColumnName,
2462 2463 2464 2465
    SQLSMALLINT        cbColumnName)
{
        TRACE("\n");

2466 2467 2468
        if (!pSQLColumnPrivilegesW) return SQL_ERROR;
        return pSQLColumnPrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
                                     szTableName, cbTableName, szColumnName, cbColumnName);
2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483
}

/*************************************************************************
 *				SQLDataSourcesW          [ODBC32.157]
 */
SQLRETURN WINAPI SQLDataSourcesW(SQLHENV EnvironmentHandle,
             SQLUSMALLINT Direction, WCHAR *ServerName,
             SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
             WCHAR *Description, SQLSMALLINT BufferLength2,
             SQLSMALLINT *NameLength2)
{
        SQLRETURN ret;

        TRACE("EnvironmentHandle = %p\n", (LPVOID)EnvironmentHandle);

2484
        if (!pSQLDataSourcesW) return SQL_ERROR;
2485

2486 2487
        ret = pSQLDataSourcesW(EnvironmentHandle, Direction, ServerName,
                               BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506

        if (TRACE_ON(odbc))
        {
           TRACE("returns: %d \t", ret);
           if (*NameLength1 > 0)
             TRACE("DataSource = %s,", debugstr_w(ServerName));
           if (*NameLength2 > 0)
             TRACE(" Description = %s", debugstr_w(Description));
           TRACE("\n");
        }

        return ret;
}

/*************************************************************************
 *				SQLForeignKeysW          [ODBC32.160]
 */
SQLRETURN WINAPI SQLForeignKeysW(
    SQLHSTMT           hstmt,
2507
    SQLWCHAR               *szPkCatalogName,
2508
    SQLSMALLINT        cbPkCatalogName,
2509
    SQLWCHAR               *szPkSchemaName,
2510
    SQLSMALLINT        cbPkSchemaName,
2511
    SQLWCHAR               *szPkTableName,
2512
    SQLSMALLINT        cbPkTableName,
2513
    SQLWCHAR               *szFkCatalogName,
2514
    SQLSMALLINT        cbFkCatalogName,
2515
    SQLWCHAR               *szFkSchemaName,
2516
    SQLSMALLINT        cbFkSchemaName,
2517
    SQLWCHAR               *szFkTableName,
2518 2519 2520 2521
    SQLSMALLINT        cbFkTableName)
{
        TRACE("\n");

2522 2523 2524 2525
        if (!pSQLForeignKeysW) return SQL_ERROR;
        return pSQLForeignKeysW(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
                                szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
                                szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
2526 2527 2528 2529 2530 2531 2532
}

/*************************************************************************
 *				SQLNativeSqlW          [ODBC32.162]
 */
SQLRETURN WINAPI SQLNativeSqlW(
    SQLHDBC            hdbc,
2533
    SQLWCHAR               *szSqlStrIn,
2534
    SQLINTEGER         cbSqlStrIn,
2535
    SQLWCHAR               *szSqlStr,
2536 2537 2538 2539 2540
    SQLINTEGER         cbSqlStrMax,
    SQLINTEGER            *pcbSqlStr)
{
        TRACE("\n");

2541 2542
        if (!pSQLNativeSqlW) return SQL_ERROR;
        return pSQLNativeSqlW(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
2543 2544 2545 2546 2547 2548 2549
}

/*************************************************************************
 *				SQLPrimaryKeysW          [ODBC32.165]
 */
SQLRETURN WINAPI SQLPrimaryKeysW(
    SQLHSTMT           hstmt,
2550
    SQLWCHAR               *szCatalogName,
2551
    SQLSMALLINT        cbCatalogName,
2552
    SQLWCHAR               *szSchemaName,
2553
    SQLSMALLINT        cbSchemaName,
2554
    SQLWCHAR               *szTableName,
2555 2556 2557 2558
    SQLSMALLINT        cbTableName)
{
        TRACE("\n");

2559 2560 2561
        if (!pSQLPrimaryKeysW) return SQL_ERROR;
        return pSQLPrimaryKeysW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
                                szTableName, cbTableName);
2562 2563 2564 2565 2566 2567 2568
}

/*************************************************************************
 *				SQLProcedureColumnsW          [ODBC32.166]
 */
SQLRETURN WINAPI SQLProcedureColumnsW(
    SQLHSTMT           hstmt,
2569
    SQLWCHAR               *szCatalogName,
2570
    SQLSMALLINT        cbCatalogName,
2571
    SQLWCHAR               *szSchemaName,
2572
    SQLSMALLINT        cbSchemaName,
2573
    SQLWCHAR               *szProcName,
2574
    SQLSMALLINT        cbProcName,
2575
    SQLWCHAR               *szColumnName,
2576 2577 2578 2579
    SQLSMALLINT        cbColumnName)
{
        TRACE("\n");

2580 2581 2582
        if (!pSQLProcedureColumnsW) return SQL_ERROR;
        return pSQLProcedureColumnsW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
                                     szProcName, cbProcName, szColumnName, cbColumnName);
2583 2584 2585 2586 2587 2588 2589
}

/*************************************************************************
 *				SQLProceduresW          [ODBC32.167]
 */
SQLRETURN WINAPI SQLProceduresW(
    SQLHSTMT           hstmt,
2590
    SQLWCHAR               *szCatalogName,
2591
    SQLSMALLINT        cbCatalogName,
2592
    SQLWCHAR               *szSchemaName,
2593
    SQLSMALLINT        cbSchemaName,
2594
    SQLWCHAR               *szProcName,
2595 2596 2597 2598
    SQLSMALLINT        cbProcName)
{
        TRACE("\n");

2599 2600 2601
        if (!pSQLProceduresW) return SQL_ERROR;
        return pSQLProceduresW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
                               szProcName, cbProcName);
2602 2603 2604 2605 2606 2607 2608
}

/*************************************************************************
 *				SQLTablePrivilegesW          [ODBC32.170]
 */
SQLRETURN WINAPI SQLTablePrivilegesW(
    SQLHSTMT           hstmt,
2609
    SQLWCHAR               *szCatalogName,
2610
    SQLSMALLINT        cbCatalogName,
2611
    SQLWCHAR               *szSchemaName,
2612
    SQLSMALLINT        cbSchemaName,
2613
    SQLWCHAR               *szTableName,
2614 2615 2616 2617
    SQLSMALLINT        cbTableName)
{
        TRACE("\n");

2618 2619 2620
        if (!pSQLTablePrivilegesW) return SQL_ERROR;
        return pSQLTablePrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
                                    szTableName, cbTableName);
2621 2622 2623 2624 2625 2626 2627 2628
}

/*************************************************************************
 *				SQLDriversW          [ODBC32.171]
 */
SQLRETURN WINAPI SQLDriversW(
    SQLHENV            henv,
    SQLUSMALLINT       fDirection,
2629
    SQLWCHAR               *szDriverDesc,
2630 2631
    SQLSMALLINT        cbDriverDescMax,
    SQLSMALLINT           *pcbDriverDesc,
2632
    SQLWCHAR               *szDriverAttributes,
2633 2634 2635 2636 2637
    SQLSMALLINT        cbDriverAttrMax,
    SQLSMALLINT           *pcbDriverAttr)
{
        TRACE("\n");

2638 2639 2640
        if (!pSQLDriversW) return SQL_ERROR;
        return pSQLDriversW(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
                            szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651
}

/*************************************************************************
 *				SQLSetDescFieldW          [ODBC32.173]
 */
SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle,
             SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
             SQLPOINTER Value, SQLINTEGER BufferLength)
{
        TRACE("\n");

2652 2653
        if (!pSQLSetDescFieldW) return SQL_ERROR;
        return pSQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666
}

/*************************************************************************
 *				SQLSetStmtAttrW          [ODBC32.176]
 */
SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle,
                 SQLINTEGER Attribute, SQLPOINTER Value,
                 SQLINTEGER StringLength)
{
        SQLRETURN iResult;
        TRACE("Attribute = (%02ld) Value = %p StringLength = (%ld)\n",
            Attribute, Value, StringLength);

2667 2668
        if (!pSQLSetStmtAttrW) return SQL_ERROR;
        iResult = pSQLSetStmtAttrW(StatementHandle, Attribute, Value, StringLength);
2669 2670 2671 2672 2673 2674 2675 2676 2677 2678
        if (iResult == SQL_ERROR && (Attribute == SQL_ROWSET_SIZE || Attribute == SQL_ATTR_ROW_ARRAY_SIZE)) {
            TRACE("CHEAT: returning SQL_SUCCESS to ADO...\n");
            iResult = SQL_SUCCESS;
        } else {
            TRACE("returning %d...\n", iResult);
        }
        return iResult;
}


2679
/* End of file */