Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsql_psql_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QSQL_PSQL_H
6#define QSQL_PSQL_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtSql/qsqldriver.h>
20
21#ifdef QT_PLUGIN
22#define Q_EXPORT_SQLDRIVER_PSQL
23#else
24#define Q_EXPORT_SQLDRIVER_PSQL Q_SQL_EXPORT
25#endif
26
27typedef struct pg_conn PGconn;
28typedef struct pg_result PGresult;
29
30QT_BEGIN_NAMESPACE
31
32class QPSQLDriverPrivate;
33
34class Q_EXPORT_SQLDRIVER_PSQL QPSQLDriver : public QSqlDriver
35{
36 friend class QPSQLResultPrivate;
37 Q_DECLARE_PRIVATE(QPSQLDriver)
38 Q_OBJECT
39public:
40 enum Protocol {
41 VersionUnknown = -1,
42 Version6 = 6,
43 Version7 = 7,
44 Version7_1 = 8,
45 Version7_3 = 9,
46 Version7_4 = 10,
47 Version8 = 11,
48 Version8_1 = 12,
49 Version8_2 = 13,
50 Version8_3 = 14,
51 Version8_4 = 15,
52 Version9 = 16,
53 Version9_1 = 17,
54 Version9_2 = 18,
55 Version9_3 = 19,
56 Version9_4 = 20,
57 Version9_5 = 21,
58 Version9_6 = 22,
59 Version10 = 23,
60 Version11 = 24,
61 Version12 = 25,
62 UnknownLaterVersion = 100000
63 };
64
65 explicit QPSQLDriver(QObject *parent = nullptr);
66 explicit QPSQLDriver(PGconn *conn, QObject *parent = nullptr);
67 ~QPSQLDriver();
68 bool hasFeature(DriverFeature f) const override;
69 bool open(const QString &db,
70 const QString &user,
71 const QString &password,
72 const QString &host,
73 int port,
74 const QString &connOpts) override;
75 bool isOpen() const override;
76 void close() override;
77 QSqlResult *createResult() const override;
78 QStringList tables(QSql::TableType) const override;
79 QSqlIndex primaryIndex(const QString &tablename) const override;
80 QSqlRecord record(const QString &tablename) const override;
81
82 Protocol protocol() const;
83 QVariant handle() const override;
84
85 QString escapeIdentifier(const QString &identifier, IdentifierType type) const override;
86 QString formatValue(const QSqlField &field, bool trimStrings) const override;
87
88 template <bool forPreparedStatement>
89 QString formatValue(const QSqlField &field, bool trimStrings = false) const;
90
91 bool subscribeToNotification(const QString &name) override;
92 bool unsubscribeFromNotification(const QString &name) override;
93 QStringList subscribedToNotifications() const override;
94
95protected:
96 bool beginTransaction() override;
97 bool commitTransaction() override;
98 bool rollbackTransaction() override;
99
100private Q_SLOTS:
101 void _q_handleNotification();
102};
103
104QT_END_NAMESPACE
105
106#endif // QSQL_PSQL_H
QSqlDriver * create(const QString &) override
Creates and returns a QSqlDriver object for the driver called key.
Definition main.cpp:29
#define Q_EXPORT_SQLDRIVER_PSQL
Definition qsql_psql_p.h:24
struct pg_conn PGconn
Definition qsql_psql_p.h:27
struct pg_result PGresult
Definition qsql_psql_p.h:28