1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSQL_ODBC_H
5#define QSQL_ODBC_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtSql/qsqldriver.h>
19
20#if defined (Q_OS_WIN32)
21#include <QtCore/qt_windows.h>
22#endif
23
24#ifdef QT_PLUGIN
25#define Q_EXPORT_SQLDRIVER_ODBC
26#else
27#define Q_EXPORT_SQLDRIVER_ODBC Q_SQL_EXPORT
28#endif
29
30#ifdef Q_OS_UNIX
31#define HAVE_LONG_LONG 1 // force UnixODBC NOT to fall back to a struct for BIGINTs
32#endif
33
34#if defined(Q_CC_BOR)
35// workaround for Borland to make sure that SQLBIGINT is defined
36# define _MSC_VER 900
37#endif
38#include <sql.h>
39#if defined(Q_CC_BOR)
40# undef _MSC_VER
41#endif
42
43#include <sqlext.h>
44
45QT_BEGIN_NAMESPACE
46
47class QODBCDriverPrivate;
48
49class Q_EXPORT_SQLDRIVER_ODBC QODBCDriver : public QSqlDriver
50{
51 Q_DECLARE_PRIVATE(QODBCDriver)
52 Q_OBJECT
53 friend class QODBCResultPrivate;
54
55public:
56 explicit QODBCDriver(QObject *parent=nullptr);
57 QODBCDriver(SQLHANDLE env, SQLHANDLE con, QObject * parent=nullptr);
58 virtual ~QODBCDriver();
59 bool hasFeature(DriverFeature f) const override;
60 void close() override;
61 QSqlResult *createResult() const override;
62 QStringList tables(QSql::TableType) const override;
63 QSqlRecord record(const QString &tablename) const override;
64 QSqlIndex primaryIndex(const QString &tablename) const override;
65 QVariant handle() const override;
66 QString formatValue(const QSqlField &field,
67 bool trimStrings) const override;
68 bool open(const QString &db,
69 const QString &user,
70 const QString &password,
71 const QString &host,
72 int port,
73 const QString &connOpts) override;
74
75 QString escapeIdentifier(const QString &identifier, IdentifierType type) const override;
76
77 bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const override;
78
79protected:
80 bool beginTransaction() override;
81 bool commitTransaction() override;
82 bool rollbackTransaction() override;
83
84private:
85 bool endTrans();
86 void cleanup();
87};
88
89QT_END_NAMESPACE
90
91#endif // QSQL_ODBC_H
92

source code of qtbase/src/plugins/sqldrivers/odbc/qsql_odbc_p.h