KDb

MysqlDriver.h
1/* This file is part of the KDE project
2 Copyright (C) 2002 Lucijan Busch <lucijan@gmx.at>
3 Copyright (C) 2003 Daniel Molkentin <molkentin@kde.org>
4 Copyright (C) 2003 Joseph Wenninger<jowenn@kde.org>
5 Copyright (C) 2003-2016 Jarosław Staniek <staniek@kde.org>
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21*/
22
23#ifndef KDB_MYSQLDRIVER_H
24#define KDB_MYSQLDRIVER_H
25
26#include "KDbDriver.h"
27
28//! MySQL database driver.
29class MysqlDriver : public KDbDriver
30{
32
33public:
34 /*!
35 * Constructor sets database features and
36 * maps the types in KDbField::Type to the MySQL types.
37 *
38 * See: https://dev.mysql.com/doc/mysql/en/Column_types.html
39 */
40 MysqlDriver(QObject *parent, const QVariantList &args);
41
42 ~MysqlDriver() override;
43
44 /*! @return false for this driver. */
45 bool isSystemObjectName(const QString& name) const override;
46
47 /*! @return true if @a is "mysql", "information_schema" or "performance_schema". */
48 bool isSystemDatabaseName(const QString &name) const override;
49
50 //! Escape a string for use as a value
51 KDbEscapedString escapeString(const QString& str) const override;
52 KDbEscapedString escapeString(const QByteArray& str) const override;
53
54 //! Escape BLOB value @a array
55 KDbEscapedString escapeBLOB(const QByteArray& array) const override;
56
57 //! Overrides the default implementation
58 QString sqlTypeName(KDbField::Type type, const KDbField &field) const override;
59
60 //! Generates native (driver-specific) LENGTH() function call.
61 //! char_length(val) is used because length(val) in mysql returns number of bytes,
62 //! what is not right for multibyte (unicode) encodings. */
65 KDb::ExpressionCallStack *callStack) const override;
66
67 //! Generates native (driver-specific) GREATEST() and LEAST() function call.
68 //! Since MySQL's LEAST()/GREATEST() function ignores NULL values, it only returns NULL
69 //! if all the expressions evaluate to NULL. So this is used for F(v0,..,vN):
70 //! (CASE WHEN (v0) IS NULL OR .. OR (vN) IS NULL THEN NULL ELSE F(v0,..,vN) END)
71 //! where F == GREATEST or LEAST.
73 const KDbNArgExpression &args,
75 KDb::ExpressionCallStack* callStack) const override;
76
77 //! Generates native (driver-specific) UNICODE() function call.
78 //! Uses ORD(CONVERT(X USING UTF16)).
81 KDb::ExpressionCallStack* callStack) const override;
82
83 //! Generates native (driver-specific) function call for concatenation of two strings.
84 //! Uses CONCAT().
87 KDb::ExpressionCallStack* callStack) const;
88
89protected:
90 QString drv_escapeIdentifier(const QString& str) const override;
91 QByteArray drv_escapeIdentifier(const QByteArray &str) const override;
93 const KDbConnectionOptions &options) override;
94 bool drv_isSystemFieldName(const QString& name) const override;
95 bool supportsDefaultValue(const KDbField &field) const override;
96
97private:
98 static const char *keywords[];
99 QString m_longTextPrimaryKeyType;
100 Q_DISABLE_COPY(MysqlDriver)
101};
102
103#endif
The KDbBinaryExpression class represents binary operation.
Database specific connection data, e.g. host, port.
Generic options for a single connection. The options are accessible using key/value pairs....
Provides database connection, allowing queries and data modification.
Database driver's abstraction.
Definition KDbDriver.h:50
Specialized string for escaping.
Meta-data for a field.
Definition KDbField.h:72
The KDbNArgExpression class represents a base class N-argument expression.
An iterator for a list of values of query schema parameters Allows to iterate over parameters and ret...
MySQL database driver.
Definition MysqlDriver.h:30
QString drv_escapeIdentifier(const QString &str) const override
bool supportsDefaultValue(const KDbField &field) const override
KDbEscapedString concatenateFunctionToString(const KDbBinaryExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const
Generates native (driver-specific) function call for concatenation of two strings.
KDbEscapedString escapeString(const QString &str) const override
Escape a string for use as a value.
KDbConnection * drv_createConnection(const KDbConnectionData &connData, const KDbConnectionOptions &options) override
MysqlDriver(QObject *parent, const QVariantList &args)
bool isSystemDatabaseName(const QString &name) const override
QString sqlTypeName(KDbField::Type type, const KDbField &field) const override
Overrides the default implementation.
KDbEscapedString escapeBLOB(const QByteArray &array) const override
Escape BLOB value array.
bool isSystemObjectName(const QString &name) const override
bool drv_isSystemFieldName(const QString &name) const override
KDbEscapedString unicodeFunctionToString(const KDbNArgExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const override
Generates native (driver-specific) UNICODE() function call.
KDbEscapedString lengthFunctionToString(const KDbNArgExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const override
Generates native (driver-specific) LENGTH() function call.
KDbEscapedString greatestOrLeastFunctionToString(const QString &name, const KDbNArgExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const override
Generates native (driver-specific) GREATEST() and LEAST() function call.
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:07 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.