删除mysql头文件

This commit is contained in:
xx
2024-06-26 17:38:05 +08:00
parent d2b9463ad7
commit 7def98db4a
51 changed files with 0 additions and 19815 deletions

View File

@@ -1,106 +0,0 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_BUILD_CONFIG_H_
#define _SQL_BUILD_CONFIG_H_
#ifdef STATIC_CONCPP
#define CPPCONN_PUBLIC_FUNC
#endif
#if defined _MSC_VER
#define DLL_EXPORT __declspec(dllexport)
#define DLL_IMPORT __declspec(dllimport)
#define DLL_LOCAL
#elif __GNUC__ >= 4
#define DLL_EXPORT __attribute__ ((visibility ("default")))
#define DLL_IMPORT
#define DLL_LOCAL __attribute__ ((visibility ("hidden")))
#elif defined __SUNPRO_CC || defined __SUNPRO_C
#define DLL_EXPORT __global
#define DLL_IMPORT __global
#define DLL_LOCAL __hidden
#else
#define DLL_EXPORT
#define DLL_IMPORT
#define DLL_LOCAL
#endif
#ifndef CPPCONN_PUBLIC_FUNC
#ifdef connector_jdbc_EXPORTS
#define CPPCONN_PUBLIC_FUNC DLL_EXPORT
#else
// this is for static build
#ifdef CPPCONN_LIB_BUILD
#define CPPCONN_PUBLIC_FUNC
#else
// this is for clients using dynamic lib
#define CPPCONN_PUBLIC_FUNC DLL_IMPORT
#endif
#endif
#endif
#ifdef _MSC_VER
/*
Warning 4251 is about non dll-interface classes being used by ones exported
from our DLL (for example std lib classes or Boost ones). Following
the crowd, we ignore this issue for now.
*/
__pragma(warning (disable:4251))
#elif defined __SUNPRO_CC || defined __SUNPRO_C
#else
/*
These are triggered by, e.g., std::auto_ptr<> which is used by Boost.
*/
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif //#ifndef _SQL_BUILD_CONFIG_H_

View File

@@ -1,195 +0,0 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_CALLBACK_H_
#define _SQL_CALLBACK_H_
#include "sqlstring.h"
#include <functional>
namespace sql
{
namespace mysql
{
class MySQL_Connection;
class MySQL_Driver;
}
/*
A callback to be used with `Driver::setCallback()` to define reaction
to the user action request during WebAuthn authentication handshake.
The client library defines default reaction which prints message on stderr.
This callback can be used to change it.
Example usage:
// Use lambda
driver->setCallback(WebAuthn_Callback{[](SQLString msg){
cerr << "User action request: " << msg << endl;
}});
// Disable default behavior (and do nothing upon action request)
driver->setCallback(WebAuthn_Callback{});
// Return to default behavior
driver->setCallbacak(WebAuthn_Callback{nullptr});
// User defined callback
struct My_Callback : WebAuthn_Callback
{
void ActionRequested(SQLString) override;
}
cb;
driver->setCallback(cb);
*/
class WebAuthn_Callback
{
std::function<void(SQLString)> callback_func;
public:
/*
Create a callback that will call given lambda upon user action request.
*/
WebAuthn_Callback(std::function<void(SQLString)>&& cb)
: callback_func{std::move(cb)}
{}
/*
Create an empty callback that will do nothing upon user action request.
This disables the default callback defined by the client library.
*/
WebAuthn_Callback()
: callback_func{[](SQLString){}}
{}
/*
Create a null callback. Setting such callback has the effect of using
the default callback defined by the client library.
*/
WebAuthn_Callback(std::nullptr_t)
{}
/*
Derived class can override this method to react to user action request.
*/
virtual void ActionRequested(sql::SQLString msg)
{
if (callback_func)
callback_func(msg);
}
// Returns true if this callback is not null.
operator bool() const
{
return (bool)callback_func;
}
void operator()(sql::SQLString msg)
{
ActionRequested(msg);
}
};
/*
* Class that provides functionality allowing user code to set the
* callback functions through inheriting, passing the callback as
* constructor parameters or using lambdas.
*/
class Fido_Callback
{
std::function<void(SQLString)> callback_func = nullptr;
bool is_null = false;
public:
/**
* Constructor to set the callback as function or as lambda
*/
Fido_Callback(std::function<void(SQLString)> cb) : callback_func(cb)
{}
Fido_Callback()
{}
/**
* Constructor to reset the callback to default
*/
Fido_Callback(std::nullptr_t) : is_null(true)
{}
/**
* Override this message to receive Fido Action Requests
*/
virtual void FidoActionRequested(sql::SQLString msg)
{
if (callback_func)
callback_func(msg);
}
operator bool() const
{
return !is_null;
}
void operator()(sql::SQLString msg)
{
if (is_null)
return;
FidoActionRequested(msg);
}
friend class mysql::MySQL_Connection;
friend class mysql::MySQL_Driver;
};
} /* namespace sql */
#endif // _SQL_CONNECTION_H_

View File

@@ -1,117 +0,0 @@
/*
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// libmysql defines HAVE_STRTOUL (on win), so we have to follow different pattern in definitions names
// to avoid annoying warnings.
#define HAVE_FUNCTION_STRTOLD 1
#define HAVE_FUNCTION_STRTOLL 1
#define HAVE_FUNCTION_STRTOL 1
#define HAVE_FUNCTION_STRTOULL 1
#define HAVE_FUNCTION_STRTOUL 1
#define HAVE_FUNCTION_STRTOIMAX 1
#define HAVE_FUNCTION_STRTOUMAX 1
#define HAVE_STDINT_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_INT8_T 1
#define HAVE_UINT8_T 1
#define HAVE_INT16_T 1
#define HAVE_UINT16_T 1
#define HAVE_INT32_T 1
#define HAVE_UINT32_T 1
#define HAVE_INT32_T 1
#define HAVE_UINT32_T 1
#define HAVE_INT64_T 1
#define HAVE_UINT64_T 1
#define HAVE_MS_INT8 1
#define HAVE_MS_UINT8 1
#define HAVE_MS_INT16 1
#define HAVE_MS_UINT16 1
#define HAVE_MS_INT32 1
#define HAVE_MS_UINT32 1
#define HAVE_MS_INT64 1
#define HAVE_MS_UINT64 1
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#if defined(HAVE_INTTYPES_H) && !defined(_WIN32)
#include <inttypes.h>
#endif
#if defined(_WIN32)
#ifndef CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
#if _MSC_VER >= 1600
#include <stdint.h>
#else
#if !defined(HAVE_INT8_T) && defined(HAVE_MS_INT8)
typedef __int8 int8_t;
#endif
#ifdef HAVE_MS_UINT8
typedef unsigned __int8 uint8_t;
#endif
#ifdef HAVE_MS_INT16
typedef __int16 int16_t;
#endif
#ifdef HAVE_MS_UINT16
typedef unsigned __int16 uint16_t;
#endif
#ifdef HAVE_MS_INT32
typedef __int32 int32_t;
#endif
#ifdef HAVE_MS_UINT32
typedef unsigned __int32 uint32_t;
#endif
#ifdef HAVE_MS_INT64
typedef __int64 int64_t;
#endif
#ifdef HAVE_MS_UINT64
typedef unsigned __int64 uint64_t;
#endif
#endif // _MSC_VER >= 1600
#endif // CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
#endif // _WIN32

View File

@@ -1,285 +0,0 @@
/*
* Copyright (c) 2008, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_CONNECTION_H_
#define _SQL_CONNECTION_H_
#include <map>
#include "build_config.h"
#include "warning.h"
#include "sqlstring.h"
#include "variant.h"
/*
Options used on ConnectOptionsMap
*/
/*
Connect related
*/
#define OPT_HOSTNAME "hostName"
#define OPT_USERNAME "userName"
#define OPT_PASSWORD "password"
#define OPT_PASSWORD1 "password1"
#define OPT_PASSWORD2 "password2"
#define OPT_PASSWORD3 "password3"
#define OPT_PORT "port"
#define OPT_SOCKET "socket"
#define OPT_PIPE "pipe"
#define OPT_SCHEMA "schema"
#define OPT_MULTI_HOST "OPT_MULTI_HOST"
#define OPT_DNS_SRV "OPT_DNS_SRV"
#define OPT_NAMED_PIPE "OPT_NAMED_PIPE"
#define OPT_INIT_COMMAND "preInit"
#define OPT_POST_INIT_COMMAND "postInit"
#define OPT_LOCAL_INFILE "OPT_LOCAL_INFILE"
#define OPT_LOAD_DATA_LOCAL_DIR "OPT_LOAD_DATA_LOCAL_DIR"
/*
SSL related
*/
#define OPT_SSL_MODE "ssl-mode"
#define OPT_SSL_KEY "ssl-key"
#define OPT_SSL_CERT "ssl-cert"
#define OPT_SSL_CA "ssl-ca"
#define OPT_SSL_CAPATH "ssl-capath"
#define OPT_SSL_CIPHER "ssl-cipher"
#define OPT_SSL_CRL "ssl-crl"
#define OPT_SSL_CRLPATH "ssl-crlpath"
#define OPT_SERVER_PUBLIC_KEY "rsaKey"
#define OPT_TLS_VERSION "tls-version"
/*
Connection related
*/
#define OPT_RECONNECT "OPT_RECONNECT"
#define OPT_RETRY_COUNT "OPT_RETRY_COUNT"
#define OPT_CONNECT_TIMEOUT "OPT_CONNECT_TIMEOUT"
#define OPT_READ_TIMEOUT "OPT_READ_TIMEOUT"
#define OPT_WRITE_TIMEOUT "OPT_WRITE_TIMEOUT"
#define OPT_MAX_ALLOWED_PACKET "OPT_MAX_ALLOWED_PACKET"
#define OPT_NET_BUFFER_LENGTH "OPT_NET_BUFFER_LENGTH"
/*
Connection Attributes
*/
#define OPT_CONNECT_ATTR_ADD "OPT_CONNECT_ATTR_ADD"
#define OPT_CONNECT_ATTR_DELETE "OPT_CONNECT_ATTR_DELETE"
#define OPT_CONNECT_ATTR_RESET "OPT_CONNECT_ATTR_RESET"
/*
Authentication
*/
#define OPT_ENABLE_CLEARTEXT_PLUGIN "OPT_ENABLE_CLEARTEXT_PLUGIN"
#define OPT_CAN_HANDLE_EXPIRED_PASSWORDS "OPT_CAN_HANDLE_EXPIRED_PASSWORDS"
#define OPT_GET_SERVER_PUBLIC_KEY "OPT_GET_SERVER_PUBLIC_KEY"
#define OPT_LEGACY_AUTH "useLegacyAuth"
#define OPT_DEFAULT_AUTH "defaultAuth"
/*
Charracter set results and Metadata
*/
#define OPT_CHARACTER_SET_RESULTS "characterSetResults"
#define OPT_OPTIONAL_RESULTSET_METADATA "OPT_OPTIONAL_RESULTSET_METADATA"
#define OPT_REPORT_DATA_TRUNCATION "OPT_REPORT_DATA_TRUNCATION"
#define OPT_CHARSET_NAME "OPT_CHARSET_NAME"
#define OPT_DEFAULT_STMT_RESULT_TYPE "defaultStatementResultType"
/*
Client side options
*/
#define OPT_CLIENT_COMPRESS "CLIENT_COMPRESS"
#define OPT_CLIENT_FOUND_ROWS "CLIENT_FOUND_ROWS"
#define OPT_CLIENT_IGNORE_SIGPIPE "CLIENT_IGNORE_SIGPIPE"
#define OPT_CLIENT_IGNORE_SPACE "CLIENT_IGNORE_SPACE"
#define OPT_CLIENT_INTERACTIVE "CLIENT_INTERACTIVE"
#define OPT_CLIENT_LOCAL_FILES "CLIENT_LOCAL_FILES"
#define OPT_CLIENT_MULTI_STATEMENTS "CLIENT_MULTI_STATEMENTS"
#define OPT_CLIENT_NO_SCHEMA "CLIENT_NO_SCHEMA"
#define OPT_SET_CHARSET_DIR "charsetDir"
#define OPT_PLUGIN_DIR "pluginDir"
#define OPT_READ_DEFAULT_GROUP "readDefaultGroup"
#define OPT_READ_DEFAULT_FILE "readDefaultFile"
/*
Auth plugin options
*/
#define OPT_OCI_CONFIG_FILE "OPT_OCI_CONFIG_FILE"
#define OPT_AUTHENTICATION_KERBEROS_CLIENT_MODE \
"OPT_AUTHENTICATION_KERBEROS_CLIENT_MODE"
#define OPT_OCI_CLIENT_CONFIG_PROFILE "OPT_OCI_CLIENT_CONFIG_PROFILE"
/*
Telemetry options
*/
#define OPT_OPENTELEMETRY "OPT_OPENTELEMETRY"
namespace sql
{
typedef sql::Variant ConnectPropertyVal;
typedef std::map< sql::SQLString, ConnectPropertyVal > ConnectOptionsMap;
class DatabaseMetaData;
class PreparedStatement;
class Statement;
class Driver;
typedef enum transaction_isolation
{
TRANSACTION_NONE= 0,
TRANSACTION_READ_COMMITTED,
TRANSACTION_READ_UNCOMMITTED,
TRANSACTION_REPEATABLE_READ,
TRANSACTION_SERIALIZABLE
} enum_transaction_isolation;
enum ssl_mode
{
SSL_MODE_DISABLED= 1, SSL_MODE_PREFERRED, SSL_MODE_REQUIRED,
SSL_MODE_VERIFY_CA, SSL_MODE_VERIFY_IDENTITY
};
typedef enum opentelemetry_mode
{
OTEL_DISABLED = 1, OTEL_PREFERRED, OTEL_REQUIRED
} enum_opentelemetry_mode;
class CPPCONN_PUBLIC_FUNC Savepoint
{
/* Prevent use of these */
Savepoint(const Savepoint &);
void operator=(Savepoint &);
public:
Savepoint() {};
virtual ~Savepoint() {};
virtual int getSavepointId() = 0;
virtual sql::SQLString getSavepointName() = 0;
};
class CPPCONN_PUBLIC_FUNC Connection
{
/* Prevent use of these */
Connection(const Connection &);
void operator=(Connection &);
public:
Connection() {};
virtual ~Connection() {};
virtual void clearWarnings() = 0;
virtual Statement *createStatement() = 0;
virtual void close() = 0;
virtual void commit() = 0;
virtual bool getAutoCommit() = 0;
virtual sql::SQLString getCatalog() = 0;
virtual Driver *getDriver() = 0;
virtual sql::SQLString getSchema() = 0;
virtual sql::SQLString getClientInfo() = 0;
virtual void getClientOption(const sql::SQLString & optionName, void * optionValue) = 0;
virtual sql::SQLString getClientOption(const sql::SQLString & optionName) = 0;
virtual DatabaseMetaData * getMetaData() = 0;
virtual enum_transaction_isolation getTransactionIsolation() = 0;
virtual const SQLWarning * getWarnings() = 0;
virtual bool isClosed() = 0;
virtual bool isReadOnly() = 0;
virtual bool isValid() = 0;
virtual bool reconnect() = 0;
virtual sql::SQLString nativeSQL(const sql::SQLString& sql) = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql) = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys) = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int* columnIndexes) = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency) = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]) = 0;
virtual void releaseSavepoint(Savepoint * savepoint) = 0;
virtual void rollback() = 0;
virtual void rollback(Savepoint * savepoint) = 0;
virtual void setAutoCommit(bool autoCommit) = 0;
virtual void setCatalog(const sql::SQLString& catalog) = 0;
virtual void setSchema(const sql::SQLString& catalog) = 0;
virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue) = 0;
virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const sql::SQLString & optionValue) = 0;
virtual void setHoldability(int holdability) = 0;
virtual void setReadOnly(bool readOnly) = 0;
virtual Savepoint * setSavepoint() = 0;
virtual Savepoint * setSavepoint(const sql::SQLString& name) = 0;
virtual void setTransactionIsolation(enum_transaction_isolation level) = 0;
/* virtual void setTypeMap(Map map) = 0; */
};
} /* namespace sql */
#endif // _SQL_CONNECTION_H_

View File

@@ -1,75 +0,0 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_DATATYPE_H_
#define _SQL_DATATYPE_H_
namespace sql
{
class DataType
{
DataType();
public:
enum {
UNKNOWN = 0,
BIT,
TINYINT,
SMALLINT,
MEDIUMINT,
INTEGER,
BIGINT,
REAL,
DOUBLE,
DECIMAL,
NUMERIC,
CHAR,
BINARY,
VARCHAR,
VARBINARY,
LONGVARCHAR,
LONGVARBINARY,
TIMESTAMP,
DATE,
TIME,
YEAR,
GEOMETRY,
ENUM,
SET,
SQLNULL,
JSON
};
};
} /* namespace */
#endif /* _SQL_DATATYPE_H_ */

View File

@@ -1,106 +0,0 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_DRIVER_H_
#define _SQL_DRIVER_H_
#include "connection.h"
#include "build_config.h"
#include "callback.h"
namespace sql
{
class CPPCONN_PUBLIC_FUNC Driver
{
protected:
virtual ~Driver() {}
public:
// Attempts to make a database connection to the given URL.
virtual Connection * connect(const sql::SQLString& hostName, const sql::SQLString& userName, const sql::SQLString& password) = 0;
virtual Connection * connect(ConnectOptionsMap & options) = 0;
virtual int getMajorVersion() = 0;
virtual int getMinorVersion() = 0;
virtual int getPatchVersion() = 0;
virtual const sql::SQLString & getName() = 0;
virtual void setCallBack(sql::Fido_Callback &cb) = 0;
virtual void setCallBack(sql::Fido_Callback &&cb) = 0;
virtual void threadInit() = 0;
virtual void threadEnd() = 0;
virtual void setCallBack(sql::WebAuthn_Callback &cb) = 0;
virtual void setCallBack(sql::WebAuthn_Callback &&cb) = 0;
};
} /* namespace sql */
CPPCONN_PUBLIC_FUNC void check(const std::string &);
CPPCONN_PUBLIC_FUNC void check(const std::map<std::string,std::string> &);
/*
Checks if user standard lib is compatible with connector one
*/
inline static void check_lib()
{
check(std::string{});
check(std::map<std::string,std::string>{});
}
extern "C"
{
CPPCONN_PUBLIC_FUNC sql::Driver * _get_driver_instance_by_name(const char * const clientlib);
/* If dynamic loading is disabled in a driver then this function works just like get_driver_instance() */
inline static sql::Driver * get_driver_instance_by_name(const char * const clientlib)
{
check_lib();
return _get_driver_instance_by_name(clientlib);
}
inline static sql::Driver * get_driver_instance()
{
return get_driver_instance_by_name("");
}
}
#endif /* _SQL_DRIVER_H_ */

View File

@@ -1,147 +0,0 @@
/*
* Copyright (c) 2008, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_EXCEPTION_H_
#define _SQL_EXCEPTION_H_
#include "build_config.h"
#include <stdexcept>
#include <string>
#include <memory>
namespace sql
{
#define MEMORY_ALLOC_OPERATORS(Class) \
void* operator new(size_t size){ return ::operator new(size); } \
void* operator new(size_t, void*) noexcept; \
void* operator new(size_t, const std::nothrow_t&) noexcept; \
void* operator new[](size_t); \
void* operator new[](size_t, void*) noexcept; \
void* operator new[](size_t, const std::nothrow_t&) noexcept; \
void* operator new(size_t N, std::allocator<Class>&);
class SQLException : public std::runtime_error
{
protected:
const std::string sql_state;
const int errNo;
public:
SQLException(const SQLException& e) : std::runtime_error(e.what()), sql_state(e.sql_state), errNo(e.errNo) {}
SQLException(const std::string& reason, const std::string& SQLState, int vendorCode) :
std::runtime_error (reason ),
sql_state (SQLState ),
errNo (vendorCode)
{}
SQLException(const std::string& reason, const std::string& SQLState) : std::runtime_error(reason), sql_state(SQLState), errNo(0) {}
SQLException(const std::string& reason) : std::runtime_error(reason), sql_state("HY000"), errNo(0) {}
SQLException() : std::runtime_error(""), sql_state("HY000"), errNo(0) {}
const std::string & getSQLState() const
{
return sql_state;
}
const char * getSQLStateCStr() const
{
return sql_state.c_str();
}
int getErrorCode() const
{
return errNo;
}
virtual ~SQLException() noexcept {};
protected:
MEMORY_ALLOC_OPERATORS(SQLException)
};
struct MethodNotImplementedException : public SQLException
{
MethodNotImplementedException(const MethodNotImplementedException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
MethodNotImplementedException(const std::string& reason) : SQLException(reason, "", 0) {}
};
struct InvalidArgumentException : public SQLException
{
InvalidArgumentException(const InvalidArgumentException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
InvalidArgumentException(const std::string& reason) : SQLException(reason, "", 0) {}
};
struct InvalidInstanceException : public SQLException
{
InvalidInstanceException(const InvalidInstanceException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
InvalidInstanceException(const std::string& reason) : SQLException(reason, "", 0) {}
};
struct NonScrollableException : public SQLException
{
NonScrollableException(const NonScrollableException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
NonScrollableException(const std::string& reason) : SQLException(reason, "", 0) {}
};
struct SQLUnsupportedOptionException : public SQLException
{
SQLUnsupportedOptionException(const SQLUnsupportedOptionException& e, const std::string conn_option) :
SQLException(e.what(), e.sql_state, e.errNo),
option(conn_option )
{}
SQLUnsupportedOptionException(const std::string& reason, const std::string conn_option) :
SQLException(reason, "", 0),
option(conn_option )
{}
const char *getConnectionOption() const
{
return option.c_str();
}
~SQLUnsupportedOptionException() noexcept {};
protected:
const std::string option;
};
} /* namespace sql */
#endif /* _SQL_EXCEPTION_H_ */

View File

@@ -1,494 +0,0 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_METADATA_H_
#define _SQL_METADATA_H_
#include <string>
#include <list>
#include "datatype.h"
#include "sqlstring.h"
namespace sql
{
class ResultSet;
class Connection;
class DatabaseMetaData
{
protected:
virtual ~DatabaseMetaData() {}
public:
enum
{
attributeNoNulls = 0,
attributeNullable,
attributeNullableUnknown
};
enum
{
bestRowTemporary = 0,
bestRowTransaction,
bestRowSession
};
enum
{
bestRowUnknown = 0,
bestRowNotPseudo,
bestRowPseudo
};
enum
{
columnNoNulls = 0,
columnNullable,
columnNullableUnknown
};
enum
{
importedKeyCascade = 0,
importedKeyInitiallyDeferred,
importedKeyInitiallyImmediate,
importedKeyNoAction,
importedKeyNotDeferrable,
importedKeyRestrict,
importedKeySetDefault,
importedKeySetNull
};
enum
{
procedureColumnIn = 0,
procedureColumnInOut,
procedureColumnOut,
procedureColumnResult,
procedureColumnReturn,
procedureColumnUnknown,
procedureNoNulls,
procedureNoResult,
procedureNullable,
procedureNullableUnknown,
procedureResultUnknown,
procedureReturnsResult
};
enum
{
sqlStateSQL99 = 0,
sqlStateXOpen
};
enum
{
tableIndexClustered = 0,
tableIndexHashed,
tableIndexOther,
tableIndexStatistic
};
enum
{
versionColumnUnknown = 0,
versionColumnNotPseudo = 1,
versionColumnPseudo = 2
};
enum
{
typeNoNulls = 0,
typeNullable = 1,
typeNullableUnknown = 2
};
enum
{
typePredNone = 0,
typePredChar = 1,
typePredBasic= 2,
typeSearchable = 3
};
virtual bool allProceduresAreCallable() = 0;
virtual bool allTablesAreSelectable() = 0;
virtual bool dataDefinitionCausesTransactionCommit() = 0;
virtual bool dataDefinitionIgnoredInTransactions() = 0;
virtual bool deletesAreDetected(int type) = 0;
virtual bool doesMaxRowSizeIncludeBlobs() = 0;
virtual ResultSet * getAttributes(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern, const sql::SQLString& attributeNamePattern) = 0;
virtual ResultSet * getBestRowIdentifier(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table, int scope, bool nullable) = 0;
virtual ResultSet * getCatalogs() = 0;
virtual const sql::SQLString& getCatalogSeparator() = 0;
virtual const sql::SQLString& getCatalogTerm() = 0;
virtual ResultSet * getColumnPrivileges(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table, const sql::SQLString& columnNamePattern) = 0;
virtual ResultSet * getColumns(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern, const sql::SQLString& columnNamePattern) = 0;
virtual Connection * getConnection() = 0;
virtual ResultSet * getCrossReference(const sql::SQLString& primaryCatalog, const sql::SQLString& primarySchema, const sql::SQLString& primaryTable, const sql::SQLString& foreignCatalog, const sql::SQLString& foreignSchema, const sql::SQLString& foreignTable) = 0;
virtual unsigned int getDatabaseMajorVersion() = 0;
virtual unsigned int getDatabaseMinorVersion() = 0;
virtual unsigned int getDatabasePatchVersion() = 0;
virtual const sql::SQLString& getDatabaseProductName() = 0;
virtual SQLString getDatabaseProductVersion() = 0;
virtual int getDefaultTransactionIsolation() = 0;
virtual unsigned int getDriverMajorVersion() = 0;
virtual unsigned int getDriverMinorVersion() = 0;
virtual unsigned int getDriverPatchVersion() = 0;
virtual const sql::SQLString& getDriverName() = 0;
virtual const sql::SQLString& getDriverVersion() = 0;
virtual ResultSet * getExportedKeys(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0;
virtual const sql::SQLString& getExtraNameCharacters() = 0;
virtual const sql::SQLString& getIdentifierQuoteString() = 0;
virtual ResultSet * getImportedKeys(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0;
virtual ResultSet * getIndexInfo(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table, bool unique, bool approximate) = 0;
virtual unsigned int getCDBCMajorVersion() = 0;
virtual unsigned int getCDBCMinorVersion() = 0;
virtual unsigned int getMaxBinaryLiteralLength() = 0;
virtual unsigned int getMaxCatalogNameLength() = 0;
virtual unsigned int getMaxCharLiteralLength() = 0;
virtual unsigned int getMaxColumnNameLength() = 0;
virtual unsigned int getMaxColumnsInGroupBy() = 0;
virtual unsigned int getMaxColumnsInIndex() = 0;
virtual unsigned int getMaxColumnsInOrderBy() = 0;
virtual unsigned int getMaxColumnsInSelect() = 0;
virtual unsigned int getMaxColumnsInTable() = 0;
virtual unsigned int getMaxConnections() = 0;
virtual unsigned int getMaxCursorNameLength() = 0;
virtual unsigned int getMaxIndexLength() = 0;
virtual unsigned int getMaxProcedureNameLength() = 0;
virtual unsigned int getMaxRowSize() = 0;
virtual unsigned int getMaxSchemaNameLength() = 0;
virtual unsigned int getMaxStatementLength() = 0;
virtual unsigned int getMaxStatements() = 0;
virtual unsigned int getMaxTableNameLength() = 0;
virtual unsigned int getMaxTablesInSelect() = 0;
virtual unsigned int getMaxUserNameLength() = 0;
virtual const sql::SQLString& getNumericFunctions() = 0;
virtual ResultSet * getPrimaryKeys(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0;
virtual ResultSet * getProcedureColumns(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& procedureNamePattern, const sql::SQLString& columnNamePattern) = 0;
virtual ResultSet * getProcedures(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& procedureNamePattern) = 0;
virtual const sql::SQLString& getProcedureTerm() = 0;
virtual int getResultSetHoldability() = 0;
virtual ResultSet * getSchemas() = 0;
virtual const sql::SQLString& getSchemaTerm() = 0;
virtual ResultSet * getSchemaCollation(const sql::SQLString& catalog, const sql::SQLString& schemaPattern) = 0;
virtual ResultSet * getSchemaCharset(const sql::SQLString& catalog, const sql::SQLString& schemaPattern) = 0;
virtual const sql::SQLString& getSearchStringEscape() = 0;
virtual const sql::SQLString& getSQLKeywords() = 0;
virtual int getSQLStateType() = 0;
virtual const sql::SQLString& getStringFunctions() = 0;
virtual ResultSet * getSuperTables(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
virtual ResultSet * getSuperTypes(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern) = 0;
virtual const sql::SQLString& getSystemFunctions() = 0;
virtual ResultSet * getTablePrivileges(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
virtual ResultSet * getTables(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern, std::list<sql::SQLString> &types) = 0;
virtual ResultSet * getTableTypes() = 0;
virtual ResultSet * getTableCollation(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
virtual ResultSet * getTableCharset(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
virtual const sql::SQLString& getTimeDateFunctions() = 0;
virtual ResultSet * getTypeInfo() = 0;
virtual ResultSet * getUDTs(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern, std::list<int> &types) = 0;
virtual SQLString getURL() = 0;
virtual SQLString getUserName() = 0;
virtual ResultSet * getVersionColumns(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0;
virtual bool insertsAreDetected(int type) = 0;
virtual bool isCatalogAtStart() = 0;
virtual bool isReadOnly() = 0;
virtual bool locatorsUpdateCopy() = 0;
virtual bool nullPlusNonNullIsNull() = 0;
virtual bool nullsAreSortedAtEnd() = 0;
virtual bool nullsAreSortedAtStart() = 0;
virtual bool nullsAreSortedHigh() = 0;
virtual bool nullsAreSortedLow() = 0;
virtual bool othersDeletesAreVisible(int type) = 0;
virtual bool othersInsertsAreVisible(int type) = 0;
virtual bool othersUpdatesAreVisible(int type) = 0;
virtual bool ownDeletesAreVisible(int type) = 0;
virtual bool ownInsertsAreVisible(int type) = 0;
virtual bool ownUpdatesAreVisible(int type) = 0;
virtual bool storesLowerCaseIdentifiers() = 0;
virtual bool storesLowerCaseQuotedIdentifiers() = 0;
virtual bool storesMixedCaseIdentifiers() = 0;
virtual bool storesMixedCaseQuotedIdentifiers() = 0;
virtual bool storesUpperCaseIdentifiers() = 0;
virtual bool storesUpperCaseQuotedIdentifiers() = 0;
virtual bool supportsAlterTableWithAddColumn() = 0;
virtual bool supportsAlterTableWithDropColumn() = 0;
virtual bool supportsANSI92EntryLevelSQL() = 0;
virtual bool supportsANSI92FullSQL() = 0;
virtual bool supportsANSI92IntermediateSQL() = 0;
virtual bool supportsBatchUpdates() = 0;
virtual bool supportsCatalogsInDataManipulation() = 0;
virtual bool supportsCatalogsInIndexDefinitions() = 0;
virtual bool supportsCatalogsInPrivilegeDefinitions() = 0;
virtual bool supportsCatalogsInProcedureCalls() = 0;
virtual bool supportsCatalogsInTableDefinitions() = 0;
virtual bool supportsColumnAliasing() = 0;
virtual bool supportsConvert() = 0;
virtual bool supportsConvert(int fromType, int toType) = 0;
virtual bool supportsCoreSQLGrammar() = 0;
virtual bool supportsCorrelatedSubqueries() = 0;
virtual bool supportsDataDefinitionAndDataManipulationTransactions() = 0;
virtual bool supportsDataManipulationTransactionsOnly() = 0;
virtual bool supportsDifferentTableCorrelationNames() = 0;
virtual bool supportsExpressionsInOrderBy() = 0;
virtual bool supportsExtendedSQLGrammar() = 0;
virtual bool supportsFullOuterJoins() = 0;
virtual bool supportsGetGeneratedKeys() = 0;
virtual bool supportsGroupBy() = 0;
virtual bool supportsGroupByBeyondSelect() = 0;
virtual bool supportsGroupByUnrelated() = 0;
virtual bool supportsIntegrityEnhancementFacility() = 0;
virtual bool supportsLikeEscapeClause() = 0;
virtual bool supportsLimitedOuterJoins() = 0;
virtual bool supportsMinimumSQLGrammar() = 0;
virtual bool supportsMixedCaseIdentifiers() = 0;
virtual bool supportsMixedCaseQuotedIdentifiers() = 0;
virtual bool supportsMultipleOpenResults() = 0;
virtual bool supportsMultipleResultSets() = 0;
virtual bool supportsMultipleTransactions() = 0;
virtual bool supportsNamedParameters() = 0;
virtual bool supportsNonNullableColumns() = 0;
virtual bool supportsOpenCursorsAcrossCommit() = 0;
virtual bool supportsOpenCursorsAcrossRollback() = 0;
virtual bool supportsOpenStatementsAcrossCommit() = 0;
virtual bool supportsOpenStatementsAcrossRollback() = 0;
virtual bool supportsOrderByUnrelated() = 0;
virtual bool supportsOuterJoins() = 0;
virtual bool supportsPositionedDelete() = 0;
virtual bool supportsPositionedUpdate() = 0;
virtual bool supportsResultSetConcurrency(int type, int concurrency) = 0;
virtual bool supportsResultSetHoldability(int holdability) = 0;
virtual bool supportsResultSetType(int type) = 0;
virtual bool supportsSavepoints() = 0;
virtual bool supportsSchemasInDataManipulation() = 0;
virtual bool supportsSchemasInIndexDefinitions() = 0;
virtual bool supportsSchemasInPrivilegeDefinitions() = 0;
virtual bool supportsSchemasInProcedureCalls() = 0;
virtual bool supportsSchemasInTableDefinitions() = 0;
virtual bool supportsSelectForUpdate() = 0;
virtual bool supportsStatementPooling() = 0;
virtual bool supportsStoredProcedures() = 0;
virtual bool supportsSubqueriesInComparisons() = 0;
virtual bool supportsSubqueriesInExists() = 0;
virtual bool supportsSubqueriesInIns() = 0;
virtual bool supportsSubqueriesInQuantifieds() = 0;
virtual bool supportsTableCorrelationNames() = 0;
virtual bool supportsTransactionIsolationLevel(int level) = 0;
virtual bool supportsTransactions() = 0;
virtual bool supportsTypeConversion() = 0; /* SDBC */
virtual bool supportsUnion() = 0;
virtual bool supportsUnionAll() = 0;
virtual bool updatesAreDetected(int type) = 0;
virtual bool usesLocalFilePerTable() = 0;
virtual bool usesLocalFiles() = 0;
virtual ResultSet *getSchemata(const sql::SQLString& catalogName = "") = 0;
virtual ResultSet *getSchemaObjects(const sql::SQLString& catalogName = "",
const sql::SQLString& schemaName = "",
const sql::SQLString& objectType = "",
bool includingDdl = true,
const sql::SQLString& objectName = "",
const sql::SQLString& contextTableName = "") = 0;
virtual ResultSet *getSchemaObjectTypes() = 0;
};
} /* namespace sql */
#endif /* _SQL_METADATA_H_ */

View File

@@ -1,84 +0,0 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_PARAMETER_METADATA_H_
#define _SQL_PARAMETER_METADATA_H_
#include "sqlstring.h"
namespace sql
{
class ParameterMetaData
{
public:
enum
{
parameterModeIn,
parameterModeInOut,
parameterModeOut,
parameterModeUnknown
};
enum
{
parameterNoNulls,
parameterNullable,
parameterNullableUnknown
};
virtual sql::SQLString getParameterClassName(unsigned int param) = 0;
virtual int getParameterCount() = 0;
virtual int getParameterMode(unsigned int param) = 0;
virtual int getParameterType(unsigned int param) = 0;
virtual sql::SQLString getParameterTypeName(unsigned int param) = 0;
virtual int getPrecision(unsigned int param) = 0;
virtual int getScale(unsigned int param) = 0;
virtual int isNullable(unsigned int param) = 0;
virtual bool isSigned(unsigned int param) = 0;
protected:
virtual ~ParameterMetaData() {}
};
} /* namespace sql */
#endif /* _SQL_PARAMETER_METADATA_H_ */

View File

@@ -1,99 +0,0 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_PREPARED_STATEMENT_H_
#define _SQL_PREPARED_STATEMENT_H_
#include <iostream>
#include "statement.h"
namespace sql
{
class Connection;
class ResultSet;
class ResultSetMetaData;
class ParameterMetaData;
class PreparedStatement : public Statement
{
public:
virtual ~PreparedStatement() {}
virtual void clearParameters() = 0;
virtual bool execute(const sql::SQLString& sql) = 0;
virtual bool execute() = 0;
virtual ResultSet *executeQuery(const sql::SQLString& sql) = 0;
virtual ResultSet *executeQuery() = 0;
virtual int executeUpdate(const sql::SQLString& sql) = 0;
virtual int executeUpdate() = 0;
virtual ResultSetMetaData * getMetaData() = 0;
virtual ParameterMetaData * getParameterMetaData() = 0;
virtual bool getMoreResults() = 0;
virtual void setBigInt(unsigned int parameterIndex, const sql::SQLString& value) = 0;
virtual void setBlob(unsigned int parameterIndex, std::istream * blob) = 0;
virtual void setBoolean(unsigned int parameterIndex, bool value) = 0;
virtual void setDateTime(unsigned int parameterIndex, const sql::SQLString& value) = 0;
virtual void setDouble(unsigned int parameterIndex, double value) = 0;
virtual void setInt(unsigned int parameterIndex, int32_t value) = 0;
virtual void setUInt(unsigned int parameterIndex, uint32_t value) = 0;
virtual void setInt64(unsigned int parameterIndex, int64_t value) = 0;
virtual void setUInt64(unsigned int parameterIndex, uint64_t value) = 0;
virtual void setNull(unsigned int parameterIndex, int sqlType) = 0;
virtual void setString(unsigned int parameterIndex, const sql::SQLString& value) = 0;
virtual PreparedStatement * setResultSetType(sql::ResultSet::enum_type type) = 0;
};
} /* namespace sql */
#endif /* _SQL_PREPARED_STATEMENT_H_ */

View File

@@ -1,188 +0,0 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_RESULTSET_H_
#define _SQL_RESULTSET_H_
#include "config.h"
#include <list>
#include <map>
#include <iostream>
#include "sqlstring.h"
#include "resultset_metadata.h"
namespace sql
{
class Statement;
class RowID
{
public:
virtual ~RowID() {}
};
class ResultSet
{
public:
enum
{
CLOSE_CURSORS_AT_COMMIT,
HOLD_CURSORS_OVER_COMMIT
};
enum
{
CONCUR_READ_ONLY,
CONCUR_UPDATABLE
};
enum
{
FETCH_FORWARD,
FETCH_REVERSE,
FETCH_UNKNOWN
};
typedef enum
{
TYPE_FORWARD_ONLY,
TYPE_SCROLL_INSENSITIVE,
TYPE_SCROLL_SENSITIVE
} enum_type;
virtual ~ResultSet() {}
virtual bool absolute(int row) = 0;
virtual void afterLast() = 0;
virtual void beforeFirst() = 0;
virtual void cancelRowUpdates() = 0;
virtual void clearWarnings() = 0;
virtual void close() = 0;
virtual uint32_t findColumn(const sql::SQLString& columnLabel) const = 0;
virtual bool first() = 0;
virtual std::istream * getBlob(uint32_t columnIndex) const = 0;
virtual std::istream * getBlob(const sql::SQLString& columnLabel) const = 0;
virtual bool getBoolean(uint32_t columnIndex) const = 0;
virtual bool getBoolean(const sql::SQLString& columnLabel) const = 0;
virtual int getConcurrency() = 0;
virtual SQLString getCursorName() = 0;
virtual long double getDouble(uint32_t columnIndex) const = 0;
virtual long double getDouble(const sql::SQLString& columnLabel) const = 0;
virtual int getFetchDirection() = 0;
virtual size_t getFetchSize() = 0;
virtual int getHoldability() = 0;
virtual int32_t getInt(uint32_t columnIndex) const = 0;
virtual int32_t getInt(const sql::SQLString& columnLabel) const = 0;
virtual uint32_t getUInt(uint32_t columnIndex) const = 0;
virtual uint32_t getUInt(const sql::SQLString& columnLabel) const = 0;
virtual int64_t getInt64(uint32_t columnIndex) const = 0;
virtual int64_t getInt64(const sql::SQLString& columnLabel) const = 0;
virtual uint64_t getUInt64(uint32_t columnIndex) const = 0;
virtual uint64_t getUInt64(const sql::SQLString& columnLabel) const = 0;
virtual ResultSetMetaData * getMetaData() const = 0;
virtual size_t getRow() const = 0;
virtual RowID * getRowId(uint32_t columnIndex) = 0;
virtual RowID * getRowId(const sql::SQLString & columnLabel) = 0;
virtual const Statement * getStatement() const = 0;
virtual SQLString getString(uint32_t columnIndex) const = 0;
virtual SQLString getString(const sql::SQLString& columnLabel) const = 0;
virtual enum_type getType() const = 0;
virtual void getWarnings() = 0;
virtual void insertRow() = 0;
virtual bool isAfterLast() const = 0;
virtual bool isBeforeFirst() const = 0;
virtual bool isClosed() const = 0;
virtual bool isFirst() const = 0;
virtual bool isLast() const = 0;
virtual bool isNull(uint32_t columnIndex) const = 0;
virtual bool isNull(const sql::SQLString& columnLabel) const = 0;
virtual bool last() = 0;
virtual bool next() = 0;
virtual void moveToCurrentRow() = 0;
virtual void moveToInsertRow() = 0;
virtual bool previous() = 0;
virtual void refreshRow() = 0;
virtual bool relative(int rows) = 0;
virtual bool rowDeleted() = 0;
virtual bool rowInserted() = 0;
virtual bool rowUpdated() = 0;
virtual void setFetchSize(size_t rows) = 0;
virtual size_t rowsCount() const = 0;
virtual bool wasNull() const = 0;
};
} /* namespace sql */
#endif /* _SQL_RESULTSET_H_ */

View File

@@ -1,107 +0,0 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_RESULTSET_METADATA_H_
#define _SQL_RESULTSET_METADATA_H_
#include "sqlstring.h"
#include "datatype.h"
namespace sql
{
class ResultSetMetaData
{
public:
enum
{
columnNoNulls,
columnNullable,
columnNullableUnknown
};
virtual SQLString getCatalogName(unsigned int column) = 0;
virtual unsigned int getColumnCount() = 0;
virtual unsigned int getColumnDisplaySize(unsigned int column) = 0;
virtual SQLString getColumnLabel(unsigned int column) = 0;
virtual SQLString getColumnName(unsigned int column) = 0;
virtual int getColumnType(unsigned int column) = 0;
virtual SQLString getColumnTypeName(unsigned int column) = 0;
virtual SQLString getColumnCharset(unsigned int columnIndex) = 0;
virtual SQLString getColumnCollation(unsigned int columnIndex) = 0;
virtual unsigned int getPrecision(unsigned int column) = 0;
virtual unsigned int getScale(unsigned int column) = 0;
virtual SQLString getSchemaName(unsigned int column) = 0;
virtual SQLString getTableName(unsigned int column) = 0;
virtual bool isAutoIncrement(unsigned int column) = 0;
virtual bool isCaseSensitive(unsigned int column) = 0;
virtual bool isCurrency(unsigned int column) = 0;
virtual bool isDefinitelyWritable(unsigned int column) = 0;
virtual int isNullable(unsigned int column) = 0;
virtual bool isNumeric(unsigned int column) = 0;
virtual bool isReadOnly(unsigned int column) = 0;
virtual bool isSearchable(unsigned int column) = 0;
virtual bool isSigned(unsigned int column) = 0;
virtual bool isWritable(unsigned int column) = 0;
virtual bool isZerofill(unsigned int column) = 0;
protected:
virtual ~ResultSetMetaData() {}
};
} /* namespace sql */
#endif /* _SQL_RESULTSET_METADATA_H_ */

View File

@@ -1,251 +0,0 @@
/*
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_STRING_H_
#define _SQL_STRING_H_
#include <string>
#include <algorithm>
#include "build_config.h"
#include <iostream>
namespace sql
{
class SQLString
{
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
std::string realStr;
#ifdef _WIN32
#pragma warning(pop)
#endif
public:
#ifdef _WIN32
//TODO something less dirty-hackish.
static const size_t npos = static_cast<std::string::size_type>(-1);
#else
static const size_t npos = std::string::npos;
#endif
~SQLString() {}
SQLString() {}
SQLString(const SQLString & other) : realStr(other.realStr) {}
SQLString(const std::string & other) : realStr(other) {}
SQLString(const char other[]) : realStr(other) {}
SQLString(const char * s, size_t n) : realStr(s, n) {}
// Needed for stuff like SQLString str= "char * string constant"
const SQLString & operator=(const char * s)
{
realStr = s;
return *this;
}
const SQLString & operator=(const std::string & rhs)
{
realStr = rhs;
return *this;
}
const SQLString & operator=(const SQLString & rhs)
{
realStr = rhs.realStr;
return *this;
}
// Conversion to st::string. Comes in play for stuff like std::string str= SQLString_var;
operator const std::string &() const
{
return realStr;
}
/** For access std::string methods. Not sure we need it. Makes it look like some smart ptr.
possibly operator* - will look even more like smart ptr */
std::string * operator ->()
{
return & realStr;
}
int compare(const SQLString& str) const
{
return realStr.compare(str.realStr);
}
int compare(const char * s) const
{
return realStr.compare(s);
}
int compare(size_t pos1, size_t n1, const char * s) const
{
return realStr.compare(pos1, n1, s);
}
int caseCompare(const SQLString &s) const
{
std::string tmp(realStr), str(s);
std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
return tmp.compare(str);
}
int caseCompare(const char * s) const
{
std::string tmp(realStr), str(s);
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
return tmp.compare(str);
}
int caseCompare(size_t pos1, size_t n1, const char * s) const
{
std::string tmp(realStr.c_str() + pos1, n1), str(s);
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
return tmp.compare(str);
}
const std::string & asStdString() const
{
return realStr;
}
const char * c_str() const
{
return realStr.c_str();
}
size_t length() const
{
return realStr.length();
}
SQLString & append(const std::string & str)
{
realStr.append(str);
return *this;
}
SQLString & append(const char * s)
{
realStr.append(s);
return *this;
}
const char& operator[](size_t pos) const
{
return realStr[pos];
}
size_t find(char c, size_t pos = 0) const
{
return realStr.find(c, pos);
}
size_t find(const SQLString & s, size_t pos = 0) const
{
return realStr.find(s.realStr, pos);
}
SQLString substr(size_t pos = 0, size_t n = npos) const
{
return realStr.substr(pos, n);
}
const SQLString& replace(size_t pos1, size_t n1, const SQLString & s)
{
realStr.replace(pos1, n1, s.realStr);
return *this;
}
size_t find_first_of(char c, size_t pos = 0) const
{
return realStr.find_first_of(c, pos);
}
size_t find_last_of(char c, size_t pos = npos) const
{
return realStr.find_last_of(c, pos);
}
const SQLString & operator+=(const SQLString & op2)
{
realStr += op2.realStr;
return *this;
}
};
/*
Operators that can and have to be not a member.
*/
inline const SQLString operator+(const SQLString & op1, const SQLString & op2)
{
return sql::SQLString(op1.asStdString() + op2.asStdString());
}
inline bool operator ==(const SQLString & op1, const SQLString & op2)
{
return (op1.asStdString() == op2.asStdString());
}
inline bool operator !=(const SQLString & op1, const SQLString & op2)
{
return (op1.asStdString() != op2.asStdString());
}
inline bool operator <(const SQLString & op1, const SQLString & op2)
{
return op1.asStdString() < op2.asStdString();
}
}// namespace sql
namespace std
{
// operator << for SQLString output
inline ostream & operator << (ostream & os, const sql::SQLString & str )
{
return os << str.asStdString();
}
}
#endif

View File

@@ -1,117 +0,0 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_STATEMENT_H_
#define _SQL_STATEMENT_H_
#include "config.h"
#include "resultset.h"
#include <string>
namespace sql
{
class ResultSet;
class Connection;
class SQLWarning;
class Statement
{
public:
virtual ~Statement() {};
virtual Connection * getConnection() = 0;
virtual void cancel() = 0;
virtual void clearWarnings() = 0;
virtual void close() = 0;
virtual bool execute(const sql::SQLString& sql) = 0;
virtual ResultSet * executeQuery(const sql::SQLString& sql) = 0;
virtual int executeUpdate(const sql::SQLString& sql) = 0;
virtual size_t getFetchSize() = 0;
virtual unsigned int getMaxFieldSize() = 0;
virtual uint64_t getMaxRows() = 0;
virtual bool getMoreResults() = 0;
virtual unsigned int getQueryTimeout() = 0;
virtual ResultSet * getResultSet() = 0;
virtual sql::ResultSet::enum_type getResultSetType() = 0;
virtual uint64_t getUpdateCount() = 0;
virtual const SQLWarning * getWarnings() = 0;
virtual void setCursorName(const sql::SQLString & name) = 0;
virtual void setEscapeProcessing(bool enable) = 0;
virtual void setFetchSize(size_t rows) = 0;
virtual void setMaxFieldSize(unsigned int max) = 0;
virtual void setMaxRows(unsigned int max) = 0;
virtual void setQueryTimeout(unsigned int seconds) = 0;
virtual Statement * setResultSetType(sql::ResultSet::enum_type type) = 0;
virtual int setQueryAttrBigInt(const sql::SQLString &name, const sql::SQLString& value) = 0;
virtual int setQueryAttrBoolean(const sql::SQLString &name, bool value) = 0;
virtual int setQueryAttrDateTime(const sql::SQLString &name, const sql::SQLString& value) = 0;
virtual int setQueryAttrDouble(const sql::SQLString &name, double value) = 0;
virtual int setQueryAttrInt(const sql::SQLString &name, int32_t value) = 0;
virtual int setQueryAttrUInt(const sql::SQLString &name, uint32_t value) = 0;
virtual int setQueryAttrInt64(const sql::SQLString &name, int64_t value) = 0;
virtual int setQueryAttrUInt64(const sql::SQLString &name, uint64_t value) = 0;
virtual int setQueryAttrNull(const sql::SQLString &name) = 0;
virtual int setQueryAttrString(const sql::SQLString &name, const sql::SQLString& value) = 0;
virtual void clearAttributes() = 0;
};
} /* namespace sql */
#endif /* _SQL_STATEMENT_H_ */

View File

@@ -1,324 +0,0 @@
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_VARIANT_H_
#define _SQL_VARIANT_H_
#include <string>
#include <map>
#include <list>
#include <algorithm>
#include <typeinfo>
#include "build_config.h"
#include "sqlstring.h"
#include "exception.h"
namespace sql
{
class BaseVariantImpl
{
public:
BaseVariantImpl (void *ptr, sql::SQLString vtype) :
cvptr(ptr),
vTypeName(vtype)
{}
virtual ~BaseVariantImpl() {
cvptr=NULL;
}
virtual BaseVariantImpl* Clone()=0;
template<class T>
T* get() const {
if (typeid(T).name() == typeid(void).name()) {
return static_cast< T * > (cvptr);
}
if ((vTypeName == typeid(std::string).name() &&
typeid(T).name() == typeid(sql::SQLString).name()) ||
(vTypeName == typeid(sql::SQLString).name() &&
typeid(T).name() == typeid(std::string).name()) ||
(vTypeName == typeid(std::map< std::string, std::string >).name() &&
typeid(T).name() ==
typeid(std::map< sql::SQLString, sql::SQLString >).name()) ||
(vTypeName ==
typeid(std::map< sql::SQLString, sql::SQLString >).name() &&
typeid(T).name() ==
typeid(std::map< std::string, std::string >).name()) ||
(vTypeName == typeid(std::list< std::string >).name() &&
typeid(T).name() ==
typeid(std::list< sql::SQLString >).name()) ||
(vTypeName ==
typeid(std::list< sql::SQLString >).name() &&
typeid(T).name() ==
typeid(std::list< std::string >).name()))
{
return static_cast< T * > (cvptr);
}
if (typeid(T).name() != vTypeName) {
throw sql::InvalidArgumentException("Variant type doesn't match.");
}
return static_cast< T * > (cvptr);
}
protected:
void *cvptr;
sql::SQLString vTypeName;
};
template<class T>
class VariantImpl : public BaseVariantImpl
{
public:
VariantImpl(T i) : BaseVariantImpl(new T(i), typeid(i).name()) {}
~VariantImpl() {
destroy_content();
}
VariantImpl(VariantImpl& that) : BaseVariantImpl(that) {
copy_content(that);
}
VariantImpl& operator=(VariantImpl& that) {
if (this != &that) {
destroy_content();
if (cvptr == NULL) {
copy_content(that);
}
}
return *this;
}
virtual VariantImpl* Clone() {
return new VariantImpl(*this);
}
private:
void destroy_content() {
T *tmp=static_cast< T * >(cvptr);
if (tmp) {
delete tmp;
cvptr=NULL;
}
}
void copy_content(BaseVariantImpl& that) {
cvptr=new T (*(static_cast< T * > (that.get< void >())));
}
};
template<class T>
class VariantMap : public BaseVariantImpl
{
public:
VariantMap(T i) : BaseVariantImpl(new T(i), typeid(i).name()) {}
~VariantMap() {
destroy_content();
}
VariantMap(VariantMap& that) : BaseVariantImpl(that) {
if (this != &that) {
copy_content(that);
}
}
VariantMap& operator=(VariantMap& that) {
if (this != &that) {
destroy_content();
copy_content(that);
}
return *this;
}
virtual VariantMap* Clone() {
return new VariantMap(*this);
}
private:
void destroy_content() {
T *tmp=static_cast< T *> (cvptr);
if (tmp) {
tmp->clear();
delete tmp;
cvptr=NULL;
}
}
void copy_content(VariantMap& var) {
T *tmp=static_cast< T *> (var.cvptr);
if (tmp) {
cvptr=new T();
typename T::const_iterator cit=tmp->begin();
while(cit != tmp->end()) {
(static_cast< T * >(cvptr))->insert(
std::make_pair(sql::SQLString(cit->first),
sql::SQLString(cit->second)));
++cit;
}
}
}
};
template<class T>
class VariantList : public BaseVariantImpl
{
public:
VariantList(T i) : BaseVariantImpl(new T(i), typeid(i).name()) {}
~VariantList() {
destroy_content();
}
VariantList(VariantList& that) : BaseVariantImpl(that) {
if (this != &that) {
copy_content(that);
}
}
VariantList& operator=(VariantList& that) {
if (this != &that) {
destroy_content();
copy_content(that);
}
return *this;
}
virtual VariantList* Clone() {
return new VariantList(*this);
}
private:
void destroy_content()
{
T *tmp=static_cast< T *> (cvptr);
if (tmp) {
tmp->clear();
delete tmp;
cvptr=NULL;
}
}
void copy_content(VariantList& var)
{
T *tmp=static_cast< T *> (var.cvptr);
if (tmp) {
cvptr=new T();
typename T::const_iterator cit=tmp->begin();
while(cit != tmp->end()) {
(static_cast< T * >(cvptr))->push_back(sql::SQLString(*cit));
++cit;
}
}
}
};
class CPPCONN_PUBLIC_FUNC Variant
{
public:
Variant(const int &i=0) :
variant(new VariantImpl< int >(i)) {}
Variant(const double &i) :
variant(new VariantImpl< double >(i)) {}
Variant(const bool &i) :
variant(new VariantImpl< bool >(i)) {}
Variant(const char* i) :
variant(new VariantImpl< sql::SQLString >(i)) {}
Variant(const std::string &i) :
variant(new VariantImpl< sql::SQLString >(i)) {}
Variant(const sql::SQLString &i) :
variant(new VariantImpl< sql::SQLString >(i)) {}
Variant(const std::list< std::string > &i) :
variant(new VariantList< std::list < std::string > >(i)) {}
Variant(const std::list< sql::SQLString > &i) :
variant(new VariantList< std::list < sql::SQLString > >(i)) {}
Variant(const std::map< std::string, std::string > &i) :
variant(new VariantMap< std::map< std::string, std::string > >(i)) {}
Variant(const std::map< sql::SQLString, sql::SQLString > &i) :
variant(new VariantMap< std::map< sql::SQLString, sql::SQLString > >(i)) {}
~Variant() {
if (variant) {
delete variant;
variant=0;
}
}
Variant(const Variant& that) {
if (this != &that) {
variant=that.variant->Clone();
}
}
Variant& operator=(const Variant& that) {
if (this != &that) {
delete variant;
variant=that.variant->Clone();
}
return *this;
}
template<class T>
T* get() const {
return variant->get<T>();
}
private:
BaseVariantImpl *variant;
};
} /* namespace sql */
#endif /* _SQL_VARIANT_H_ */

View File

@@ -1,53 +0,0 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* */
#define MYCPPCONN_DM_MAJOR_VERSION 8
#define MYCPPCONN_DM_MINOR_VERSION 2
#define MYCPPCONN_DM_PATCH_VERSION 0
#define MYCPPCONN_DM_VERSION "8.2.0"
#define MYCPPCONN_DM_VERSION_ID 8020000
#define MYSQL_CONCPP_LICENSE "GPL-2.0"
#define MYSQL_CONCPP_VERSION_MAJOR 8
#define MYSQL_CONCPP_VERSION_MINOR 2
#define MYSQL_CONCPP_VERSION_MICRO 0
#define MYSQL_CONCPP_VERSION_NUMBER 8020000
/* Driver version info */
#define MYCPPCONN_STATIC_MYSQL_VERSION "8.2.0"
#define MYCPPCONN_STATIC_MYSQL_VERSION_ID 80200
#define MYCPPCONN_BOOST_VERSION

View File

@@ -1,80 +0,0 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SQL_WARNING_H_
#define _SQL_WARNING_H_
#include <stdexcept>
#include <string>
#include <memory>
#include "sqlstring.h"
namespace sql
{
#ifdef _WIN32
#pragma warning (disable : 4290)
//warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
#endif
class SQLWarning
{
public:
SQLWarning(){}
virtual const sql::SQLString & getMessage() const = 0;
virtual const sql::SQLString & getSQLState() const = 0;
virtual int getErrorCode() const = 0;
virtual const SQLWarning * getNextWarning() const = 0;
virtual void setNextWarning(const SQLWarning * _next) = 0;
protected:
virtual ~SQLWarning(){};
SQLWarning(const SQLWarning&){};
private:
const SQLWarning & operator = (const SQLWarning & rhs);
};
} /* namespace sql */
#endif /* _SQL_WARNING_H_ */

View File

@@ -1,233 +0,0 @@
/*
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MYSQL_CONNECTION_H_
#define _MYSQL_CONNECTION_H_
#include "cppconn/connection.h"
#include <memory>
#if(_WIN32 && CONCPP_BUILD_SHARED)
extern std::string driver_dll_path;
#endif
namespace sql
{
namespace mysql
{
class CPPCONN_PUBLIC_FUNC MySQL_Savepoint : public sql::Savepoint
{
sql::SQLString name;
public:
MySQL_Savepoint(const sql::SQLString &savepoint);
virtual ~MySQL_Savepoint() {}
int getSavepointId();
sql::SQLString getSavepointName();
private:
/* Prevent use of these */
MySQL_Savepoint(const MySQL_Savepoint &);
void operator=(MySQL_Savepoint &);
};
class MySQL_DebugLogger;
struct MySQL_ConnectionData; /* PIMPL */
class MySQL_Statement;
class MySQL_Prepared_Statement;
namespace NativeAPI
{
class NativeConnectionWrapper;
}
class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection
{
friend MySQL_Statement;
friend MySQL_Prepared_Statement;
MySQL_Statement * createServiceStmt();
public:
MySQL_Connection(Driver * _driver,
::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy,
const sql::SQLString& hostName,
const sql::SQLString& userName,
const sql::SQLString& password);
MySQL_Connection(Driver * _driver, ::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy,
std::map< sql::SQLString, sql::ConnectPropertyVal > & options);
virtual ~MySQL_Connection();
void clearWarnings();
void close();
void commit();
sql::Statement * createStatement();
sql::SQLString escapeString(const sql::SQLString &);
bool getAutoCommit();
sql::SQLString getCatalog();
Driver *getDriver();
sql::SQLString getSchema();
sql::SQLString getClientInfo();
void getClientOption(const sql::SQLString & optionName, void * optionValue);
sql::SQLString getClientOption(const sql::SQLString & optionName);
sql::DatabaseMetaData * getMetaData();
enum_transaction_isolation getTransactionIsolation();
const SQLWarning * getWarnings();
bool isClosed();
bool isReadOnly();
bool isValid();
bool reconnect();
sql::SQLString nativeSQL(const sql::SQLString& sql);
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql);
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys);
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int columnIndexes[]);
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency);
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability);
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]);
void releaseSavepoint(Savepoint * savepoint) ;
void rollback();
void rollback(Savepoint * savepoint);
void setAutoCommit(bool autoCommit);
void setCatalog(const sql::SQLString& catalog);
void setSchema(const sql::SQLString& catalog);
sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue);
sql::Connection * setClientOption(const sql::SQLString & optionName, const sql::SQLString & optionValue);
void setHoldability(int holdability);
void setReadOnly(bool readOnly);
sql::Savepoint * setSavepoint();
sql::Savepoint * setSavepoint(const sql::SQLString& name);
void setTransactionIsolation(enum_transaction_isolation level);
virtual sql::SQLString getSessionVariable(const sql::SQLString & varname);
virtual void setSessionVariable(const sql::SQLString & varname, const sql::SQLString & value);
virtual void setSessionVariable(const sql::SQLString & varname, unsigned int value);
virtual sql::SQLString getLastStatementInfo();
sql::SQLString getCurrentUser();
private:
/* We do not really think this class has to be subclassed*/
void checkClosed();
void init(std::map< sql::SQLString, sql::ConnectPropertyVal > & properties);
Driver * driver;
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
std::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy;
#ifdef _WIN32
#pragma warning(pop)
#endif
/* statement handle to execute queries initiated by driver. Perhaps it is
a good idea to move it to a separate helper class */
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
std::unique_ptr< ::sql::mysql::MySQL_Statement > service;
std::unique_ptr< ::sql::mysql::MySQL_ConnectionData > intern; /* pimpl */
#ifdef _WIN32
#pragma warning(pop)
#endif
/* We need to store the user name for telemetry */
SQLString currentUser;
/* Prevent use of these */
MySQL_Connection(const MySQL_Connection &);
void operator=(MySQL_Connection &);
};
} /* namespace mysql */
} /* namespace sql */
#endif // _MYSQL_CONNECTION_H_
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/

View File

@@ -1,162 +0,0 @@
/*
* Copyright (c) 2008, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MYSQL_DRIVER_H_
#define _MYSQL_DRIVER_H_
#include "cppconn/driver.h"
#include <memory>
extern "C"
{
CPPCONN_PUBLIC_FUNC void * sql_mysql_get_driver_instance();
}
namespace sql
{
namespace mysql
{
namespace NativeAPI
{
class NativeDriverWrapper;
}
//class sql::mysql::NativeAPI::NativeDriverWrapper;
class CPPCONN_PUBLIC_FUNC MySQL_Driver : public sql::Driver
{
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
std::unique_ptr< ::sql::mysql::NativeAPI::NativeDriverWrapper > proxy;
#ifdef _WIN32
#pragma warning(pop)
#endif
/*
Note: With current implementation `fido_callback` and `fido_callback_store`
are not really used and should be removed after deprecation of Fido
authentication plugin and when ABI can be changed.
*/
::sql::Fido_Callback* fido_callback = nullptr;
::sql::Fido_Callback fido_callback_store;
/*
Callback function to be called by WebAuthn authentication plugin to notify
the user.
Note: Currently the same callback can be used wih deprecated Fido
authentication plugin.
Note: The `fido_callback` pointer is re-used as a flag to indicate if
the callback was set by a user and its type (WebAuthn vs. Fido).
*/
std::function<void(SQLString)> webauthn_callback;
public:
MySQL_Driver();
MySQL_Driver(const ::sql::SQLString & clientLib);
virtual ~MySQL_Driver();
sql::Connection * connect(const sql::SQLString& hostName, const sql::SQLString& userName, const sql::SQLString& password) override;
sql::Connection * connect(sql::ConnectOptionsMap & options) override;
int getMajorVersion() override;
int getMinorVersion() override;
int getPatchVersion() override;
const sql::SQLString & getName() override;
void setCallBack(sql::Fido_Callback &cb) override;
void setCallBack(sql::Fido_Callback &&cb) override;
void setCallBack(sql::WebAuthn_Callback &cb) override;
void setCallBack(sql::WebAuthn_Callback &&cb) override;
void threadInit() override;
void threadEnd() override;
private:
/* Prevent use of these */
MySQL_Driver(const MySQL_Driver &);
void operator=(MySQL_Driver &);
struct WebAuthn_Callback_Setter;
friend WebAuthn_Callback_Setter;
friend MySQL_Connection;
};
/** We do not hide the function if MYSQLCLIENT_STATIC_BINDING(or anything else) not defined
because the counterpart C function is declared in the cppconn and is always visible.
If dynamic loading is not enabled then its result is just like of get_driver_instance()
*/
CPPCONN_PUBLIC_FUNC MySQL_Driver * _get_driver_instance_by_name(const char * const clientlib);
inline static MySQL_Driver * get_driver_instance_by_name(const char * const clientlib)
{
check_lib();
return sql::mysql::_get_driver_instance_by_name(clientlib);
}
inline static MySQL_Driver * get_driver_instance()
{
return sql::mysql::get_driver_instance_by_name("");
}
inline static MySQL_Driver *get_mysql_driver_instance() { return get_driver_instance(); }
} /* namespace mysql */
} /* namespace sql */
#endif // _MYSQL_DRIVER_H_
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/

View File

@@ -1,58 +0,0 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MYSQL_ERROR_H_
#define _MYSQL_ERROR_H_
namespace sql
{
namespace mysql
{
/* Driver specific errors */
enum DRIVER_ERROR {
/* Underlying client library(cl) can't deal with expired password.
Raised when password actually expires */
deCL_CANT_HANDLE_EXP_PWD= 820
};
} /* namespace mysql */
} /* namespace sql */
#endif /* _MYSQL_ERROR_H_ */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/

View File

@@ -1,50 +0,0 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../jdbc/mysql_connection.h"
#include "../jdbc/mysql_driver.h"
#include "../jdbc/mysql_error.h"
#include "../jdbc/cppconn/build_config.h"
#include "../jdbc/cppconn/callback.h"
#include "../jdbc/cppconn/config.h"
#include "../jdbc/cppconn/connection.h"
#include "../jdbc/cppconn/datatype.h"
#include "../jdbc/cppconn/driver.h"
#include "../jdbc/cppconn/exception.h"
#include "../jdbc/cppconn/metadata.h"
#include "../jdbc/cppconn/parameter_metadata.h"
#include "../jdbc/cppconn/prepared_statement.h"
#include "../jdbc/cppconn/resultset.h"
#include "../jdbc/cppconn/resultset_metadata.h"
#include "../jdbc/cppconn/statement.h"
#include "../jdbc/cppconn/sqlstring.h"
#include "../jdbc/cppconn/warning.h"
#include "../jdbc/cppconn/version_info.h"
#include "../jdbc/cppconn/variant.h"

View File

@@ -1,68 +0,0 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQL_COMMON_H
#define MYSQL_COMMON_H
#undef min
#undef max
//disable c++17 iterator warnings
#define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
/*
Common definitions and declarations that are needed by public headers.
Note: Any common stuff that is needed only by the implementation, should be
kept in the common/ folder, either as headers or source files.
*/
#include "common_constants.h"
#include "common/api.h"
#include "common/error.h"
#include "common/util.h"
#include "common/value.h"
#include "common/settings.h"
PUSH_SYS_WARNINGS
#include <cassert>
POP_SYS_WARNINGS
/*
On Windows, dependency on the sockets library can be handled using
#pragma comment directive.
*/
#ifdef _WIN32
#pragma comment(lib,"ws2_32")
#endif
#endif

View File

@@ -1,181 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_COMMON_API_H
#define MYSQLX_COMMON_API_H
/*
X DevAPI ABI version and revision
=================================
All public symbols inside mysqlx namespace should be defined inside
MYSQLX_ABI_BEGIN(X,Y) ... MYSQLX_ABI_END(X,Y) block, where X.Y is the
ABI version of the symbol. This puts the symbol inside mysqlx::abiX::rY
namespace.
The current ABI version is determined by MYSQLX_ABI_X_Y macros below. Using
inline namespace ensures that symbol reference mysqlx::foo resolves
to mysqlx::abiX::rY::foo, where X.Y is the current ABI version.
Declarations below ensure, that each ABI revision namespace includes all
symbols from previous revisions (via using namespace declaration).
If the same symbol is defined for several revisions of the ABI, the latest
one will shadow other definitions but earlier revisions will be also present
to be used by old code. This way backward ABI compatibility can be maintained.
*/
/*
When new ABI version or revision is added, the corresponding
MYSQLX_ABI_MAJOR/MINOR_X macro needs to be added below. The macros for the
latest ABI version and revision should expand to "inline", other MSQLX_ABI_*
macros should have empty expansion. For example,
after adding revision ABI 2.1 these macros should look as follows:
#define MYSQLX_ABI_MAJOR_2 inline // current ABI version
#define MYSQLX_ABI_MINOR_0
#define MYSQLX_ABI_MINOR_1 inline // current ABI revision
TODO: Auto-generate this based on information in version.cmake
*/
#define MYSQLX_ABI_MAJOR_2 inline // current ABI version
#define MYSQLX_ABI_MINOR_0 inline // current ABI revision
#define MYSQLX_ABI_BEGIN(X,Y) \
MYSQLX_ABI_MAJOR_ ## X namespace abi ## X { \
MYSQLX_ABI_MINOR_ ## Y namespace r ## Y {
#define MYSQLX_ABI_END(X,Y) }}
#define MYSQLX_ABI(X,Y) mysqlx::abi##X::r##Y
#ifdef __cplusplus
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
namespace internal {
}
namespace common {
}
MYSQLX_ABI_END(2,0)
/*
When new revision 1 of the current ABI 2 is added, the following declarations
should be added. They import all revision 0 symbols into revision 1. Symbols
that have changed should be defined inside
MYSQLX_ABI_BEGIN(2,1) ... MYSQLX_ABI_END(2,1) and they will
shadow the corresponding revision 0 symbol.
MYSQLX_ABI_BEGIN(2,1)
using namespace r0;
namespace internal {
using namespace r0::internal;
}
namespace common {
using namespace r0::common;
}
MYSQLX_ABI_END(2,1)
*/
}
#endif // __cplusplus
/*
Macros for declaring public API
===============================
API function declarations should be decorated with PUBLIC_API prefix. API
classes should have PUBLIC_API marker between the "class" keyword and
the class name.
See: https://gcc.gnu.org/wiki/Visibility
TODO: Use better name than PUBLIC_API - not all public API classes should
be decorated with these declarations but only these whose implementation
is inside the library (so, not the ones which are implemented in headers).
*/
#if defined _MSC_VER
#define DLL_EXPORT __declspec(dllexport)
#define DLL_IMPORT __declspec(dllimport)
#define DLL_LOCAL
#elif __GNUC__ >= 4
#define DLL_EXPORT __attribute__ ((visibility ("default")))
#define DLL_IMPORT
#define DLL_LOCAL __attribute__ ((visibility ("hidden")))
#elif defined __SUNPRO_CC || defined __SUNPRO_C
#define DLL_EXPORT __global
#define DLL_IMPORT __global
#define DLL_LOCAL __hidden
#else
#define DLL_EXPORT
#define DLL_IMPORT
#define DLL_LOCAL
#endif
#if defined CONCPP_BUILD_SHARED
#define PUBLIC_API DLL_EXPORT
#define INTERNAL DLL_LOCAL
#elif defined CONCPP_BUILD_STATIC
#define PUBLIC_API
#define INTERNAL
#elif !defined STATIC_CONCPP
#define PUBLIC_API DLL_IMPORT
#define INTERNAL
#else
#define PUBLIC_API
#define INTERNAL
#endif
#endif

View File

@@ -1,99 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_COMMON_ERROR_H
#define MYSQLX_COMMON_ERROR_H
/*
TODO: Error handling infrastructure for XDevAPI and X DevAPI for C still
needs to be done. Current code is just a temporary hack.
*/
#include "api.h"
#include "util.h"
PUSH_SYS_WARNINGS
#include <string>
#include <stdexcept>
#include <ostream>
#include <memory>
#include <forward_list>
#include <string.h> // for memcpy
#include <utility> // std::move etc
POP_SYS_WARNINGS
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
namespace common {
/**
Base class for connector errors.
@internal
TODO: Derive from std::system_error and introduce proper
error codes.
@endinternal
@ingroup devapi
*/
class Error : public std::runtime_error
{
public:
Error(const char *msg)
: std::runtime_error(msg)
{}
};
inline
std::ostream& operator<<(std::ostream &out, const Error &e)
{
out << e.what();
return out;
}
inline
void throw_error(const char *msg)
{
throw Error(msg);
}
} // common
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,346 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_COMMON_OP_IF_H
#define MYSQLX_COMMON_OP_IF_H
/*
This file defines a hierarchy of abstract interfaces for objects that
represent database operations. The base interface is the Executable_if for
any operation that can be executed. Other interfaces in the hierarchy allow
specifying more details of the operation.
Note: Header op_impl.h defines implementations of these interfaces used
in the connector.
*/
#include "api.h"
#include "../common_constants.h"
#include <string>
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
namespace common {
class Result_init;
class Value;
#define LOCK_MODE(X,N) X = N,
enum Lock_mode
{
LOCK_MODE_LIST(LOCK_MODE)
};
#define LOCK_CONTENTION(X,N) X = N,
enum class Lock_contention
{
LOCK_CONTENTION_LIST(LOCK_CONTENTION)
};
/*
Abstract interface for internal implementations of an executable object.
The execute() method returns a Result_init object which can be
used to construct a result instance.
Implementation of an executable object holds a description of the operation
that should be executed. Executable objects can be copied (for example
by copy assignment operation) and in this case a new copy of the current
description of the operation should be created by clone() method. After
cloning, the 2 executable implementations can be modified and executed
independently.
See various Op_xxx classes defined for example in operation.h to see examples
of executable object implementations. Note that these Op_xxx classes do
not directly inherit from Executable_if. Instead they use a whole hierarchy
of implementation classes based on Executable_if. But in the end, each
implementation of an executable object defines the execute() method that
executes given operation using all the information collected using other
methods of the implementation class.
*/
struct Executable_if
{
/*
Execute the operation and return reference to object which implements
Result_init interface. Such object is then used to construct a result
instance.
*/
virtual Result_init& execute() = 0;
virtual Executable_if *clone() const = 0;
virtual ~Executable_if() {}
};
/*
The XXX_if classes defined below form a hierarchy of interfaces, based
on Executable_if, for internal implementations of various crud operations.
The concrete implementations, like Op_collection_find defined in
operation.h, implements one of the top interfaces in this hierarchy but
the hierarchy allows casting the implementation down to the layer
implementing particular aspect of the operation. For example
Limit_if interface allows setting limit and offset for returned/affected
rows/documents, which is common for different CRUD operations.
*/
struct Bind_if : public Executable_if
{
using string = std::string;
// Add value for named parameter
virtual void add_param(const string&, const Value&) = 0;
// Add value for positional parameter
virtual void add_param(Value) = 0;
virtual void clear_params() = 0;
};
struct Limit_if : public Bind_if
{
virtual void set_offset(unsigned) = 0;
virtual void clear_offset() = 0;
virtual void set_limit(unsigned) = 0;
virtual void clear_limit() = 0;
};
struct Sort_if : public Limit_if
{
using string = std::string;
enum direction_t { ASC, DESC };
virtual void add_sort(const string &expr, direction_t dir) = 0;
virtual void add_sort(const string&) = 0;
virtual void clear_sort() = 0;
};
struct Having_if : public Sort_if
{
using string = std::string;
virtual void set_having(const string&) = 0;
virtual void clear_having() = 0;
};
struct Group_by_if : public Having_if
{
using string = std::string;
virtual void add_group_by(const string&) = 0;
virtual void clear_group_by() = 0;
};
struct Proj_if : public Group_by_if
{
using string = std::string;
/*
Add projection specification for a table query. It is an expression with
optional "AS <alias>" suffix.
*/
virtual void add_proj(const string&) = 0;
/*
Set projection for a document query. It is a JSON-like string but document
field values are interpreted as expressions.
*/
virtual void set_proj(const string&) = 0;
virtual void clear_proj() = 0;
};
template <class Base>
struct Select_if : public Base
{
using string = std::string;
// Set expression to select rows/documents.
virtual void set_where(const string&) = 0;
// Define lock mode for rows/documents returned by the query.
virtual void set_lock_mode(Lock_mode, Lock_contention) = 0;
virtual void clear_lock_mode() = 0;
};
// --------------------------------------------------------------------------
struct Collection_find_if : public Select_if<Proj_if>
{};
/*
Interface to internal implementations of CRUD add operation.
*/
struct Collection_add_if : public Executable_if
{
/*
Note: Current implementation only supports sending
documents in form of UTF8 JSON strings.
*/
virtual void add_json(const std::string&) = 0;
virtual void clear_docs() = 0;
};
struct Collection_remove_if : public Select_if<Sort_if>
{};
/*
Interface to internal implementations of CRUD modify operation.
Methods `add_operation` are used to pass to the implementation object
the modifications requested by the user.
*/
struct Collection_modify_if : public Select_if<Sort_if>
{
using string = std::string;
enum Operation
{
SET,
UNSET,
ARRAY_INSERT,
ARRAY_APPEND,
ARRAY_DELETE,
MERGE_PATCH
};
virtual void add_operation(Operation, const string&, const Value&) = 0;
virtual void add_operation(Operation, const string&) = 0;
virtual void clear_modifications() = 0;
};
// --------------------------------------------------------------------------
/*
Interface to be implemented by internal implementations of
table insert operation.
*/
template <class Row_impl>
struct Table_insert_if : public Executable_if
{
using string = std::string;
/*
Pass to the implementation names of columns specified by
the user. Columns are passed one-by-one in the order in
which they were specified.
*/
virtual void add_column(const string&) = 0;
virtual void clear_columns() = 0;
/*
Pass to the implementation a row that should be inserted
into the table. Several rows can be passed.
TODO: use move semantics instead
*/
virtual void add_row(const Row_impl&) = 0;
virtual void clear_rows() = 0;
};
/*
Interface to be implemented by internal implementations
of table CRUD select operation.
Method `add_where` is used to report selection criteria
to the implementation.
*/
struct Table_select_if : public Select_if<Proj_if>
{};
/*
Interface to be implemented by internal implementations
of table CRUD remove operation.
Selection criteria which selects rows to be removed is
passed to the implementation using `set_where` method.
Note: setting where condition to empty string removes it.
*/
struct Table_remove_if : public Select_if<Sort_if>
{};
/*
Interface to be implemented by internal implementations of
table CRUD update operation. Such update operation sets values
of fields in a row. Name of the column that should be set and
expression defining new value are reported to the implementation
using method `add_set`.
*/
struct Table_update_if : public Table_remove_if
{
using string = std::string;
virtual void add_set(const string&, const Value&) = 0;
virtual void clear_modifications() = 0;
};
} // internal
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,427 +0,0 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_COMMON_SETTINGS_H
#define MYSQLX_COMMON_SETTINGS_H
/*
Classes and code handling session settings. They are used to process session
creation options, check their consistency and present the settings in the
form expected by CDK.
Known session options and their values are defined
in mysql_common_constants.h header as SESSION_OPTION_LIST() and accompanying
macros.
*/
#include "../common_constants.h"
#include "value.h"
PUSH_SYS_WARNINGS
#include <vector>
#include <map>
#include <bitset>
#include <sstream>
POP_SYS_WARNINGS
namespace cdk {
namespace ds {
class Multi_source;
struct Attr_processor;
}}
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
namespace common {
/*
Class for storing session configuration settings.
*/
class PUBLIC_API Settings_impl
{
public:
/*
Enumerations with available session options and their values.
*/
#define SETTINGS_OPT_ENUM_str(X,N) X = N,
#define SETTINGS_OPT_ENUM_num(X,N) X = N,
#define SETTINGS_OPT_ENUM_any(X,N) X = N,
#define SETTINGS_OPT_ENUM_bool(X,N) X = N,
enum Session_option_impl{
SESSION_OPTION_LIST(SETTINGS_OPT_ENUM)
LAST
};
/*
Enumerations with available client options and their values.
*/
#define CLIENT_OPT_IMPL_ENUM_str(X,N) X = -N,
#define CLIENT_OPT_IMPL_ENUM_bool(X,N) X = -N,
#define CLIENT_OPT_IMPL_ENUM_num(X,N) X = -N,
#define CLIENT_OPT_IMPL_ENUM_any(X,N) X = -N,
enum Client_option_impl {
CLIENT_OPTION_LIST(CLIENT_OPT_IMPL_ENUM)
};
static const char* option_name(int opt);
#define SETTINGS_VAL_ENUM(X,N) X = N,
enum class SSL_mode {
SSL_MODE_LIST(SETTINGS_VAL_ENUM)
LAST
};
static const char* ssl_mode_name(SSL_mode mode);
enum class Auth_method {
AUTH_METHOD_LIST(SETTINGS_VAL_ENUM)
LAST
};
static const char* auth_method_name(Auth_method method);
enum class Compression_mode {
COMPRESSION_MODE_LIST(SETTINGS_VAL_ENUM)
LAST
};
static const char* compression_mode_name(Compression_mode mode);
protected:
using Value = common::Value;
using opt_val_t = std::pair<int, Value>;
// TODO: use multimap instead?
using option_list_t = std::vector<opt_val_t>;
using connection_attr = std::map<std::string,std::string>;
using iterator = option_list_t::const_iterator;
public:
/*
Examine settings stored in this object.
*/
bool has_option(int) const;
const Value& get(int) const;
// Iterating over options stored in this object.
iterator begin() const
{
return m_data.m_options.cbegin();
}
iterator end() const
{
return m_data.m_options.cend();
}
/*
Clear individual or all settings.
*/
void clear();
void erase(int);
/*
Session options include connection options that specify data source
(one or many) for which given session is created. This method initializes
CDK Multi_source object to describe the data source(s) based on the
connection options.
*/
void get_data_source(cdk::ds::Multi_source&);
void get_attributes(cdk::ds::Attr_processor&);
// Set options based on URI
void set_from_uri(const std::string &);
// Set Client options based on JSON object
void set_client_opts(const std::string &);
// Set Client options from othe Settings object
void set_client_opts(const Settings_impl &);
/*
Public API has no methods to directly set individual options. Instead,
to change session settings implementation should create a Setter object
and use its methods to do the changes. A Settings_impl::Setter object
provides "transactional" semantics for changing session options -- only
consistent option changes modify the original Settings_impl object.
Note: This Setter class is defined in "implementation" header
common/settings.h. The public API leaves it undefined.
*/
class Setter;
protected:
struct PUBLIC_API Data
{
Data()
{
init_connection_attr();
}
DLL_WARNINGS_PUSH
option_list_t m_options;
connection_attr m_connection_attr;
DLL_WARNINGS_POP
unsigned m_host_cnt = 0;
bool m_user_priorities = false;
bool m_ssl_ca = false;
SSL_mode m_ssl_mode = SSL_mode::LAST;
bool m_tcpip = false; // set to true if TCPIP connection was specified
bool m_sock = false; // set to true if socket connection was specified
bool m_tls_vers = false;
bool m_tls_ciphers = false;
bool m_compression_algorithms = false;
void erase(int);
void init_connection_attr();
void clear_connection_attr();
};
Data m_data;
};
#define SETTINGS_OPT_NAME_str(X,N) case N: return #X;
#define SETTINGS_OPT_NAME_bool(X,N) case N: return #X;
#define SETTINGS_OPT_NAME_num(X,N) case N: return #X;
#define SETTINGS_OPT_NAME_any(X,N) case N: return #X;
#define SETTINGS_OPT_NAME_bool(X,N) case N: return #X;
#define CLIENT_OPT_NAME_str(X,N) case -N: return #X;
#define CLIENT_OPT_NAME_bool(X,N) case -N: return #X;
#define CLIENT_OPT_NAME_num(X,N) case -N: return #X;
#define CLIENT_OPT_NAME_any(X,N) case -N: return #X;
inline
const char* Settings_impl::option_name(int opt)
{
switch (opt)
{
SESSION_OPTION_LIST(SETTINGS_OPT_NAME)
CLIENT_OPTION_LIST(CLIENT_OPT_NAME)
default:
return nullptr;
}
}
#define SETTINGS_VAL_NAME(X,N) case N: return #X;
inline
const char* Settings_impl::ssl_mode_name(SSL_mode mode)
{
switch (unsigned(mode))
{
SSL_MODE_LIST(SETTINGS_VAL_NAME)
default:
return nullptr;
}
}
inline
const char* Settings_impl::auth_method_name(Auth_method method)
{
switch (unsigned(method))
{
AUTH_METHOD_LIST(SETTINGS_VAL_NAME)
default:
return nullptr;
}
}
inline
const char* Settings_impl::compression_mode_name(Compression_mode mode)
{
switch (unsigned(mode))
{
COMPRESSION_MODE_LIST(SETTINGS_VAL_NAME)
default:
return nullptr;
}
}
/*
Note: For options that can repeat, returns the last value.
*/
inline
const common::Value& Settings_impl::get(int opt) const
{
using std::find_if;
auto it = find_if(m_data.m_options.crbegin(), m_data.m_options.crend(),
[opt](opt_val_t el) -> bool { return el.first == opt; }
);
static Value null_value;
if (it == m_data.m_options.crend())
return null_value;
return it->second;
}
inline
bool Settings_impl::has_option(int opt) const
{
// For options whose value is a list, we return true if we know the option
// was set even if no actual values are stored in m_options, which is the
// case when option value is an empty list.
switch (opt)
{
case Session_option_impl::TLS_VERSIONS:
if (m_data.m_tls_vers)
return true;
break;
case Session_option_impl::TLS_CIPHERSUITES:
if (m_data.m_tls_ciphers)
return true;
break;
case Session_option_impl::COMPRESSION_ALGORITHMS:
if (m_data.m_compression_algorithms)
return true;
break;
default:
break;
}
return m_data.m_options.cend() !=
find_if(m_data.m_options.cbegin(), m_data.m_options.cend(),
[opt](opt_val_t el) -> bool { return el.first == opt; }
);
}
inline
void Settings_impl::erase(int opt)
{
m_data.erase(opt);
}
/*
Note: Removes all occurrences of the given option. Also updates the context
used for checking option consistency.
*/
inline
void Settings_impl::Data::erase(int opt)
{
remove_from(m_options,
[opt](opt_val_t el) -> bool
{
return el.first == opt;
}
);
/*
TODO: removing HOST from multi-host settings can leave "orphaned"
PORT/PRIORITY settings. Do we correctly detect that?
*/
switch (opt)
{
case Session_option_impl::HOST:
m_host_cnt = 0;
FALLTHROUGH;
case Session_option_impl::PORT:
if (0 == m_host_cnt)
m_tcpip = false;
break;
case Session_option_impl::SOCKET:
m_sock = false;
break;
case Session_option_impl::PRIORITY:
m_user_priorities = false;
break;
case Session_option_impl::SSL_CA:
m_ssl_ca = false;
break;
case Session_option_impl::SSL_MODE:
m_ssl_mode = SSL_mode::LAST;
break;
case Session_option_impl::CONNECTION_ATTRIBUTES:
clear_connection_attr();
break;
default:
break;
}
}
} // common namespace
MYSQLX_ABI_END(2,0)
} // mysqlx namespace
#endif

View File

@@ -1,414 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_COMMON_UTIL_H
#define MYSQLX_COMMON_UTIL_H
#include "api.h"
#include <limits>
/*
Macros used to disable warnings for fragments of code.
*/
#if defined _MSC_VER
#define PRAGMA(X) __pragma(X)
#define DISABLE_WARNING(W) PRAGMA(warning (disable:W))
#define DIAGNOSTIC_PUSH PRAGMA(warning (push))
#define DIAGNOSTIC_POP PRAGMA(warning (pop))
#elif defined __GNUC__ || defined __clang__
#define PRAGMA(X) _Pragma(#X)
#define DISABLE_WARNING(W) PRAGMA(GCC diagnostic ignored #W)
#if defined __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#define DIAGNOSTIC_PUSH PRAGMA(GCC diagnostic push)
#define DIAGNOSTIC_POP PRAGMA(GCC diagnostic pop)
#else
#define DIAGNOSTIC_PUSH
#define DIAGNOSTIC_POP
#endif
#else
#define PRAGMA(X)
#define DISABLE_WARNING(W)
#define DIAGNOSTIC_PUSH
#define DIAGNOSTIC_POP
#endif
/*
Macros to disable compile warnings in system headers. Put
PUSH_SYS_WARNINGS/POP_SYS_WARNINGS around sytem header includes.
*/
#if defined _MSC_VER
/*
Warning 4350 is triggered by std::shared_ptr<> implementation
- see https://msdn.microsoft.com/en-us/library/0eestyah.aspx
Warning 4365 conversion from 'type_1' to 'type_2', signed/unsigned mismatch
- see https://msdn.microsoft.com/en-us/library/ms173683.aspx
Warning 4774 format string expected in argument <position> is not a
string literal
*/
#define PUSH_SYS_WARNINGS \
PRAGMA(warning (push,2)) \
DISABLE_WARNING(4350) \
DISABLE_WARNING(4738) \
DISABLE_WARNING(4548) \
DISABLE_WARNING(4365) \
DISABLE_WARNING(4774) \
DISABLE_WARNING(4244)
#else
#define PUSH_SYS_WARNINGS DIAGNOSTIC_PUSH
#endif
#define POP_SYS_WARNINGS DIAGNOSTIC_POP
PUSH_SYS_WARNINGS
#include <string>
#include <stdexcept>
#include <ostream>
#include <memory>
#include <forward_list>
#include <string.h> // for memcpy
#include <utility> // std::move etc
#include <algorithm>
#include <functional>
#include <type_traits>
POP_SYS_WARNINGS
/*
Macro to be used to disable "implicit fallthrough" gcc warning
<https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>
*/
#ifndef FALLTHROUGH
# ifdef __GNUC__
# if __GNUC__ < 7
# define FALLTHROUGH // fallthrough
# else
# if __cplusplus >= 201703L
# define FALLTHROUGH [[fallthrough]] // C++17
# elif __cplusplus >= 201103L
# define FALLTHROUGH [[gnu::fallthrough]] // C++11 and C++14
# else
# define FALLTHROUGH __attribute__((fallthrough))
# endif
# endif
# else
# define FALLTHROUGH // fallthrough
# endif
#endif //FALLTHROUGH
/*
Note: we add throw statement to the definition of THROW() so that compiler won't
complain if it is used in contexts where, e.g., a value should be returned from
a function.
*/
#undef THROW
#ifdef THROW_AS_ASSERT
#define THROW(MSG) do { assert(false && (MSG)); throw (MSG); } while(false)
#else
#define THROW(MSG) do { throw_error(MSG); throw (MSG); } while(false)
#endif
/*
Macros used to disable warnings for fragments of code.
*/
#undef PRAGMA
#undef DISABLE_WARNING
#undef DIAGNOSTIC_PUSH
#undef DIAGNOSTIC_POP
#if defined _MSC_VER
#define PRAGMA(X) __pragma(X)
#define DISABLE_WARNING(W) PRAGMA(warning(disable : W))
#define DIAGNOSTIC_PUSH PRAGMA(warning(push))
#define DIAGNOSTIC_POP PRAGMA(warning(pop))
#elif defined __GNUC__ || defined __clang__
#define PRAGMA(X) _Pragma(#X)
#define DISABLE_WARNING(W) PRAGMA(GCC diagnostic ignored #W)
#if defined __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#define DIAGNOSTIC_PUSH PRAGMA(GCC diagnostic push)
#define DIAGNOSTIC_POP PRAGMA(GCC diagnostic pop)
#else
#define DIAGNOSTIC_PUSH
#define DIAGNOSTIC_POP
#endif
#else
#define PRAGMA(X)
#define DISABLE_WARNING(W)
#define DIAGNOSTIC_PUSH
#define DIAGNOSTIC_POP
#endif
/*
On Windows, MSVC issues warnings if public API class definition uses
another class which is not exported as public API (either as a base class
or type of member). This is indeed dangerous because client code might get
the class definition wrong if the non-exported component is not available or
(worse) is defined in a different way than the same component during connector
build time.
We can not completely avoid these warnings because for some API classes we
use standard C++ library classes as components. For example, we use
std::shared_ptr<> a lot. We can not modify standard library headers to export
these classes. As is the common practice, we ignore this issue assuming that
the code that uses our connector is built with the same C++ runtime
implementation as the one used to build the connector. To silence the warnings,
uses of standard library classes in our public API classes should be surrounded
with DLL_WARNINGS_PUSH/POP macros.
*/
#if defined _MSC_VER
#define DLL_WARNINGS_PUSH DIAGNOSTIC_PUSH \
DISABLE_WARNING(4251) \
DISABLE_WARNING(4275)
#define DLL_WARNINGS_POP DIAGNOSTIC_POP
#else
#define DLL_WARNINGS_PUSH
#define DLL_WARNINGS_POP
#endif
/*
A dirty trick to help Doxygen to process 'enum class' declarations, which
are not fully supported. Thus we replace them by plain 'enum' when processing
sources by Doxygen.
*/
#ifdef DOXYGEN
#define enum_class enum
#else
#define enum_class enum class
#endif
/*
Macro to put at the end of other macros that define lists of items. This is
another dirty trick for Doxygen to hide from it a documentation of the last
item in the list. Otherwise, in a situation like this:
#define ITEM_LIST(X) \
X(item1) \
...
X(itemN) /##< Doc for last item #/
Doxegen treats the documentation of the last item as documentation for
the whole ITEM_LIST() macro. This does not happen if END_LIST is added at
the end:
#define ITEM_LIST(X) \
X(item1) \
...
X(itemN) /##< Doc for last item #/ \
END_LIST
*/
#define END_LIST
#ifdef __cplusplus
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
namespace common {
/*
Convenience for checking numeric limits (to be used when doing numeric
casts).
TODO: Maybe more templates are needed for the case where T is a float/double
type and U is an integer type or vice versa.
*/
template <
typename T, typename U,
typename std::enable_if<std::is_unsigned<U>::value>::type* = nullptr
>
inline
bool check_num_limits(U val)
{
using UT = typename std::make_unsigned<T>::type;
return !(val > (UT)std::numeric_limits<T>::max());
}
template <
typename T, typename U,
typename std::enable_if<std::is_unsigned<T>::value>::type* = nullptr,
typename std::enable_if<!std::is_unsigned<U>::value>::type* = nullptr
>
inline
bool check_num_limits(U val)
{
return !(val < 0) && !(val > std::numeric_limits<T>::max());
}
template <
typename T, typename U,
typename std::enable_if<!std::is_unsigned<T>::value>::type* = nullptr,
typename std::enable_if<!std::is_unsigned<U>::value>::type* = nullptr
>
inline
bool check_num_limits(U val)
{
return
!((val > std::numeric_limits<T>::max())
|| (val < std::numeric_limits<T>::lowest()));
}
#define ASSERT_NUM_LIMITS(T,V) assert(::mysqlx::common::check_num_limits<T>(V))
inline
std::string to_upper(const std::string &val)
{
using std::transform;
std::string uc_val;
uc_val.resize(val.size());
transform(val.begin(), val.end(), uc_val.begin(), ::toupper);
return uc_val;
}
inline
std::string to_lower(const std::string &val)
{
using std::transform;
std::string uc_val;
uc_val.resize(val.size());
transform(val.begin(), val.end(), uc_val.begin(), ::tolower);
return uc_val;
}
} // common
namespace common {
#ifdef USE_NATIVE_BYTE
using ::byte;
#else
typedef unsigned char byte;
#endif
class nocopy
{
public:
nocopy(const nocopy&) = delete;
nocopy& operator=(const nocopy&) = delete;
protected:
nocopy() {}
};
class Printable
{
virtual void print(std::ostream&) const = 0;
friend std::ostream& operator<<(std::ostream&, const Printable&);
};
inline
std::ostream& operator<<(std::ostream &out, const Printable &obj)
{
obj.print(out);
return out;
}
} // common
namespace common {
using std::find_if;
/*
Remove from a container all elements that satisfy the given predicate.
*/
template <class CONT, class PRED>
void remove_from(CONT &cont, PRED pred)
{
using It = typename CONT::iterator;
It end = std::remove_if(cont.begin(), cont.end(), pred);
cont.erase(end, cont.end());
}
} // common
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif // __cplusplus
#endif

View File

@@ -1,323 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_COMMON_VALUE_H
#define MYSQLX_COMMON_VALUE_H
#include "api.h"
#include "error.h"
#include "util.h"
PUSH_SYS_WARNINGS
#include <string>
POP_SYS_WARNINGS
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
namespace common {
class Value_conv;
/*
Class representing a polymorphic value of one of the supported types.
TODO: Extend it with array and document types (currently these are implemented
in derived mysqlx::Value class of DevAPI).
TODO: When storing raw bytes, currently they are copied inside the Value
object. Consider if this can be avoided.
*/
class PUBLIC_API Value
: public virtual Printable
{
public:
enum Type
{
VNULL, ///< Null value
UINT64, ///< Unsigned integer
INT64, ///< Signed integer
FLOAT, ///< Float number
DOUBLE, ///< Double number
BOOL, ///< Boolean
STRING, ///< String (utf8)
USTRING, ///< Wide string (utf16)
RAW, ///< Raw bytes
EXPR, ///< String to be interpreted as an expression
JSON, ///< JSON string
};
using string = std::string;
protected:
Type m_type;
// TODO: Use std::variant to save space
DLL_WARNINGS_PUSH
std::string m_str;
std::u16string m_ustr;
DLL_WARNINGS_POP
union {
double v_double = 0.0;
float v_float;
int64_t v_sint;
uint64_t v_uint;
bool v_bool;
} m_val;
void print(std::ostream&) const override;
template <typename T>
Value(Type type, T &&init)
: Value(std::forward<T>(init))
{
m_type = type;
}
public:
// Construct a NULL item
Value() : m_type(VNULL)
{}
// Construct an item from a string
Value(const std::string& str) : m_type(STRING), m_str(str)
{
m_val.v_bool = false;
}
Value(const std::u16string &str)
: m_type(USTRING), m_ustr(str)
{
m_val.v_bool = false;
}
// Construct an item from a signed 64-bit integer
Value(int64_t v) : m_type(INT64)
{ m_val.v_sint = v; }
// Construct an item from an unsigned 64-bit integer
Value(uint64_t v) : m_type(UINT64)
{ m_val.v_uint = v; }
// Construct an item from a float
Value(float v) : m_type(FLOAT)
{ m_val.v_float = v; }
// Construct an item from a double
Value(double v) : m_type(DOUBLE)
{ m_val.v_double = v; }
// Construct an item from a bool
Value(bool v) : m_type(BOOL)
{ m_val.v_bool = v; }
// Construct an item from bytes
Value(const byte *ptr, size_t len) : m_type(RAW)
{
// Note: bytes are copied to m_str member.
m_str.assign((const char*)ptr, len);
}
// Other numeric conversions
template <
typename T,
typename std::enable_if<std::is_unsigned<T>::value>::type* = nullptr
>
Value(T val)
: Value(uint64_t(val))
{}
template <
typename T,
typename std::enable_if<!std::is_unsigned<T>::value>::type* = nullptr,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr
>
Value(T val)
: Value(int64_t(val))
{}
bool is_null() const
{
return VNULL == m_type;
}
bool get_bool() const
{
switch (m_type)
{
case BOOL: return m_val.v_bool;
case UINT64: return 0 != m_val.v_uint;
case INT64: return 0 != m_val.v_sint;
default:
throw Error("Can not convert to Boolean value");
}
}
uint64_t get_uint() const
{
if (UINT64 != m_type && INT64 != m_type && BOOL != m_type)
throw Error("Can not convert to integer value");
if (BOOL == m_type)
return m_val.v_bool ? 1 : 0;
if (INT64 == m_type && 0 > m_val.v_sint)
throw Error("Converting negative integer to unsigned value");
uint64_t val = (UINT64 == m_type ? m_val.v_uint : (uint64_t)m_val.v_sint);
return val;
}
int64_t get_sint() const
{
if (INT64 == m_type)
return m_val.v_sint;
uint64_t val = get_uint();
if (!check_num_limits<int64_t>(val))
throw Error("Value cannot be converted to signed integer number");
return val;
}
float get_float() const
{
switch (m_type)
{
case INT64: return 1.0F*m_val.v_sint;
case UINT64: return 1.0F*m_val.v_uint;
case FLOAT: return m_val.v_float;
default:
throw Error("Value cannot be converted to float number");
}
}
double get_double() const
{
switch (m_type)
{
case INT64: return 1.0*m_val.v_sint;
case UINT64: return 1.0*m_val.v_uint;
case FLOAT: return m_val.v_float;
case DOUBLE: return m_val.v_double;
default:
throw Error("Value can not be converted to double number");
}
}
/*
Note: In general this method returns raw value representation as obtained
from the server, which is stored in m_str member. If a non-string value was
not obtained from the server, there is no raw representation for it and
error is thrown. String values always have raw representation which is
either utf8 or utf16 encoding. Strings obtained from the server use utf8 as
raw representation. For strings created by user code this might be either
utf8 or utf16, depending on how string was created.
*/
const byte* get_bytes(size_t *size) const
{
switch (m_type)
{
case USTRING:
if (!m_ustr.empty())
{
if (size)
*size = m_ustr.size() * sizeof(char16_t);
return (const byte*)m_ustr.data();
}
FALLTHROUGH;
default:
if (m_str.empty())
throw Error("Value cannot be converted to raw bytes");
FALLTHROUGH;
case RAW:
case STRING:
if (size)
*size = m_str.length();
return (const byte*)m_str.data();
}
}
// Note: these methods perform utf8 conversions as necessary.
const std::string& get_string() const;
const std::u16string& get_ustring() const;
Type get_type() const
{
return m_type;
}
private:
/*
Note: Avoid implicit conversion from pointer types to bool.
Without this declaration, Value(bool) constructor is invoked
for pointer types. Here we declare and hide an explicit constructor
for pointer types which prevents compiler to pick Value(bool).
*/
template <typename T>
Value(const T*);
public:
friend Value_conv;
struct Access;
friend Access;
};
} // common
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,345 +0,0 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQL_COMMON_CONSTANTS_H
#define MYSQL_COMMON_CONSTANTS_H
#include "version_info.h"
#define DEFAULT_MYSQL_PORT 3306
#define DEFAULT_MYSQLX_PORT 33060
// ----------------------------------------------------------------------------
/*
Common constants
================
Warning: Values of these constants are part of the public API. Changing them
is a non backward compatible API change.
Note: Value of 0 is reserved for special uses and thus constant values
are always > 0.
Note: the empty END_LIST macro at the end of list macros helps Doxygen
correctly interpret documentation for the list item.
*/
#define OPT_STR(X,Y,N) X##_str(Y,N)
#define OPT_BOOL(X,Y,N) X##_bool(Y,N)
#define OPT_NUM(X,Y,N) X##_num(Y,N)
#define OPT_ANY(X,Y,N) X##_any(Y,N)
#undef END_LIST
#define END_LIST
#define CLIENT_OPTION_LIST(x) \
OPT_BOOL(x,POOLING,1) /*!< disable/enable the pool. (Enabled by default)*/ \
OPT_NUM(x,POOL_MAX_SIZE,2) /*!< size of the pool. (Defaults to 25)*/ \
OPT_NUM(x,POOL_QUEUE_TIMEOUT,3) /*!< timeout for waiting for a connection in
the pool (ms). (No timeout by default)*/ \
OPT_NUM(x,POOL_MAX_IDLE_TIME,4)/*!< time for a connection to be in the pool
without being used (ms).(Will not expire by default)*/ \
END_LIST
#define SESSION_OPTION_LIST(x) \
OPT_STR(x,URI,1) /*!< connection URI or string */ \
/*! DNS name of the host, IPv4 address or IPv6 address */ \
OPT_STR(x,HOST,2) \
OPT_NUM(x,PORT,3) /*!< X Plugin port to connect to */ \
/*!
Assign a priority (a number in range 1 to 100) to the last specified
host; these priorities are used to determine the order in which multiple
hosts are tried by the connection fail-over logic (see description
of `Session` class)
*/ \
OPT_NUM(x,PRIORITY,4) \
OPT_STR(x,USER,5) /*!< user name */ \
OPT_STR(x,PWD,6) /*!< password */ \
OPT_STR(x,DB,7) /*!< default database */ \
/*!
Specify \ref SSLMode option to be used. In plain C code the value
should be a `#mysqlx_ssl_mode_t` enum constant.
*/ \
OPT_ANY(x,SSL_MODE,8) \
/*! path to a PEM file specifying trusted root certificates*/ \
OPT_STR(x,SSL_CA,9) \
/*!
Authentication method to use, see \ref AuthMethod. In plain C code the value
should be a `#mysqlx_auth_method_t` enum constant.
*/ \
OPT_ANY(x,AUTH,10) \
OPT_STR(x,SOCKET,11) /*!< unix socket path */ \
/*!
Sets connection timeout in milliseconds. In C++ code can be also set to
a `std::chrono::duration` value.
*/ \
OPT_NUM(x,CONNECT_TIMEOUT,12) \
/*!
Specifies connection attributes (key-value pairs) to be sent when a session
is created. The value is a JSON string (in C++ code can be also a `DbDoc`
object) defining additional attributes to be sent on top of the default
ones. Setting this option to `false` (in C++ code) or NULL (in plain C code)
disables sending any connection attributes (including the default ones).
Setting it to `true` (in C++ code) or empty string (in plain C code)
requests sending only the default attributes which is also the default
behavior when this option is not set.
*/ \
OPT_STR(x,CONNECTION_ATTRIBUTES,13) \
/*!
List of allowed TLS protocol versions, such as "TLSv1.2". The value is a
string with comma separated versions. In C++ code it can also be an
iterable container with versions.
*/ \
OPT_STR(x,TLS_VERSIONS, 14) \
/*!
List of allowed TLS cipher suites. The value is a string with
comma separated IANA cipher suitenames (such as
"TLS_RSA_WITH_3DES_EDE_CBC_SHA"). In C++ code it can also be an iterable
container with names.
Unknown cipher suites are silently ignored.
*/ \
OPT_STR(x,TLS_CIPHERSUITES, 15) \
/*!
If enabled (true) will check hostname for DNS SRV record and use its
configuration (hostname, port, priority and weight) to connect.
*/ \
OPT_BOOL(x, DNS_SRV, 16) \
OPT_ANY(x,COMPRESSION,17) /*!< enable or disable compression */ \
/*!
Specify compression algorithms in order of preference
*/ \
OPT_STR(x,COMPRESSION_ALGORITHMS,18) \
/*!
Path to a directory containing PEM files specifying trusted root
certificates.
*/ \
OPT_STR(x,SSL_CAPATH,19) \
/*! Path to a PEM file containing certificate revocation lists*/ \
OPT_STR(x,SSL_CRL,20) \
/*!
Path to a directory containing PEM files with certificate revocation
lists
*/ \
OPT_STR(x,SSL_CRLPATH,21) \
END_LIST
/*
Names for options supported in the query part of a connection string and
how they map to session options above.
Note: when adding new options to this list, also update doxygen docs
for mysqlx::SessionSettings URL ctor (include\mysqlx\devapi\settings.h) and
for mysqlx_get_session_from_url() (include\mysqlx\xapi.h).
*/
#define URI_OPTION_LIST(X) \
X("ssl-mode", SSL_MODE) \
X("ssl-ca", SSL_CA) \
X("ssl-capath", SSL_CAPATH) \
X("ssl-crl", SSL_CRL) \
X("ssl-crlpath", SSL_CRLPATH) \
X("auth", AUTH) \
X("connect-timeout", CONNECT_TIMEOUT) \
X("connection-attributes",CONNECTION_ATTRIBUTES)\
X("tls-version", TLS_VERSIONS) \
X("tls-versions", TLS_VERSIONS) \
X("tls-ciphersuites", TLS_CIPHERSUITES) \
X("compression", COMPRESSION) \
X("compression-algorithms", COMPRESSION_ALGORITHMS) \
END_LIST
#define SSL_MODE_LIST(x) \
x(DISABLED,1) /*!< Establish an unencrypted connection. */ \
x(REQUIRED,2) /*!< Establish a secure connection if the server supports
secure connections. The connection attempt fails if a
secure connection cannot be established. This is the
default if `SSL_MODE` is not specified. */ \
x(VERIFY_CA,3) /*!< Like `REQUIRED`, but additionally verify the server
TLS certificate against the configured Certificate
Authority (CA) certificates (defined by `SSL_CA`
Option). The connection attempt fails if no valid
matching CA certificates are found.*/ \
x(VERIFY_IDENTITY,4) /*!< Like `VERIFY_CA`, but additionally verify that the
server certificate matches the host to which the
connection is attempted.*/\
END_LIST
#define AUTH_METHOD_LIST(x)\
x(PLAIN,1) /*!< Plain text authentication method. The password is
sent as a clear text. This method is used by
default in encrypted connections. */ \
x(MYSQL41,2) /*!< Authentication method supported by MySQL 4.1 and newer.
The password is hashed before being sent to the server.
This authentication method works over unencrypted
connections */ \
x(EXTERNAL,3) /*!< External authentication when the server establishes
the user authenticity by other means such as SSL/x509
certificates. Currently not supported by X Plugin */ \
x(SHA256_MEMORY,4) /*!< Authentication using SHA256 password hashes stored in
server-side cache. This authentication method works
over unencrypted connections.
*/ \
END_LIST
/*
Types that can be reported by MySQL server.
*/
#define RESULT_TYPE_LIST(X) \
X(BIT, 1) \
X(TINYINT, 2) \
X(SMALLINT, 3) \
X(MEDIUMINT, 4) \
X(INT, 5) \
X(BIGINT, 6) \
X(FLOAT, 7) \
X(DECIMAL, 8) \
X(DOUBLE, 9) \
X(JSON, 10) \
X(STRING, 11) \
X(BYTES, 12) \
X(TIME, 13) \
X(DATE, 14) \
X(DATETIME, 15) \
X(TIMESTAMP, 16) \
X(SET, 17) \
X(ENUM, 18) \
X(GEOMETRY, 19) \
END_LIST
/*
Check options for an updatable view.
@see https://dev.mysql.com/doc/refman/en/view-check-option.html
*/
#define VIEW_CHECK_OPTION_LIST(x) \
x(CASCADED,1) \
x(LOCAL,2) \
END_LIST
/*
Algorithms used to process views.
@see https://dev.mysql.com/doc/refman/en/view-algorithms.html
*/
#define VIEW_ALGORITHM_LIST(x) \
x(UNDEFINED,1) \
x(MERGE,2) \
x(TEMPTABLE,3) \
END_LIST
/*
View security settings.
@see https://dev.mysql.com/doc/refman/en/stored-programs-security.html
*/
#define VIEW_SECURITY_LIST(x) \
x(DEFINER,1) \
x(INVOKER,2) \
END_LIST
#define LOCK_MODE_LIST(X) \
X(SHARED,1) /*!< Sets a shared mode lock on any rows that
are read. Other sessions can read the rows,
but cannot modify them until your transaction
commits. If any of these rows were changed by
another transaction that has not yet committed,
your query waits until that transaction ends
and then uses the latest values. */ \
X(EXCLUSIVE,2) /*!< For index records the search encounters,
locks the rows and any associated index entries, the same
as if you issued an UPDATE statement for those rows. Other
transactions are blocked from updating those rows,
from doing locking in LOCK_SHARED, or from reading
the data in certain transaction isolation levels. */ \
END_LIST
#define LOCK_CONTENTION_LIST(X) \
X(DEFAULT,0) /*!< Block query until existing row locks are released. */ \
X(NOWAIT,1) /*!< Return error if lock could not be obtained immediately. */ \
X(SKIP_LOCKED,2) /*!< Execute query immediately, excluding items that are
locked from the query results. */ \
END_LIST
#define COMPRESSION_MODE_LIST(x) \
x(DISABLED,1) /*!< Disables the compression. */ \
x(PREFERRED,2) /*!< Request compression, but not return error
if compression is requested, but could not be
used */ \
x(REQUIRED,3) /*!< Request compression and return error if
compression is not supported by the server */ \
END_LIST
// ----------------------------------------------------------------------------
#define COLLECTION_OPTIONS_OPTION(X)\
X(REUSE,1) /*!< Use existing collection. Expects a boolean value. */ \
X(VALIDATION,2) /*!< Collection validation options. Expects
CollectionValidation or a json string.*/ \
END_LIST
#define COLLECTION_VALIDATION_OPTION(X)\
X(SCHEMA,1) /*!< Collection validation schema, as defined by
https://dev.mysql.com/doc/refman/8.0/en/json-validation-functions.html#function_json-schema-valid
*/ \
X(LEVEL,2) /*!< Defines level of validation on the collection, see
\ref CollectionValidation_Level "CollectionValidation::Level".
In plain C code the value should be
\ref opt_collection_validation_level "mysqlx_collection_validation_level_t".
*/ \
END_LIST
// Schema Validation Level
//Windows defines STRICT as a macro... undefine it
#ifdef STRICT
#undef STRICT
#endif
#define COLLECTION_VALIDATION_LEVEL(X)\
X(OFF,1) /*!< No validation will be done on the collection. */ \
X(STRICT,2) /*!< All collection documents have to comply to validation schema.
*/ \
END_LIST
#endif

View File

@@ -1,208 +0,0 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_COLLATIONS_H
#define MYSQLX_COLLATIONS_H
#include "common.h"
/*
Import Lists of built-in character sets and collations supported by MySQL
Server.
*/
#include "mysql_charsets.h"
#include "mysql_collations.h"
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
/*
Enumeration of known character sets. For each character set CS listed
in CDK_CS_LIST() macro, there is CharacterSet::CS constant in this
enumeration.
*/
enum class CharacterSet : unsigned short
{
#undef CS
#define CS_ENUM(CS) CS,
CDK_CS_LIST(CS_ENUM)
};
#define CS_NAME_SWITCH(CS) case CharacterSet::CS: return #CS;
/**
Returns name of a character set given by its id.
@ingroup devapi_res
*/
inline
const char* characterSetName(CharacterSet id)
{
switch (id)
{
CDK_CS_LIST(CS_NAME_SWITCH)
default:
THROW("Unknown character set id");
}
}
/**
Structure that provides information about character set collation.
For each known collation COLL over character set CS, there is static object
`Collation<CS>::%COLL` of type `CollationInfo` which describes
collation COLL. For example `Collation<CharacterSet::latin1>::%swedish_ci` is
an `CollationInfo` object which describes the `swedish_ci` collation over
`latin1` character set.
@ingroup devapi_res
*/
struct CollationInfo
{
/// Numeric collation id, as used by MySQL server.
unsigned id() const { return m_id; }
/// String name of a collation, such as "latin1_generic_ci".
const char *getName() const { return m_name; }
/// Id of the character set of this collation.
CharacterSet getCharacterSet() const { return m_cs; }
/**
Returns true if given collation is case sensitive. Binary
collations are assumed to be case sensitive.
*/
bool isCaseSensitive() const { return m_case != case_ci; }
/// Returns true if this is binary collation.
bool isBinary() const { return m_case == case_bin; }
bool operator==(const CollationInfo &other) const
{
return m_id == other.m_id;
}
bool operator!=(const CollationInfo &other) const
{
return !operator==(other);
}
private:
enum coll_case { case_bin, case_ci, case_cs };
CharacterSet m_cs;
unsigned m_id;
coll_case m_case;
const char *m_name;
public:
struct Access;
friend Access;
};
template <CharacterSet CS> struct Collation;
/*
The Collation<CS>::COLL constants are generated from information provided by
COLLATION_XXX() macros.Each line X(CS, ID, COLL, CASE) in the expansion of
a COLLATION_XXX() macro declares collation with name COLL for character set
CS. ID is the MySQL id number for the collation. CASE is one of ci, cs or bin
and indicates whether it is case insensitive, sensitive or binary collation,
respectively.
*/
/*
Generate declarations of Collation<CS>::COLL constants using
COLLATINS_XXX() macros. The list CS_LIST() is processed using
COLL_DECL() macro, which for each character set CS declares
specialization Collation<CS> of the Collation<> template and
declares collation constants within this specialization.
The collation constant declarations are generated by processing
COLLATIONS_CS() list with COLL_CONST() macro. The name of each
constant is generated by COLL_CONST_NAME() macro. The convention
used is that case insensitive and case sensitive collations get
a _ci or _cs suffix, respectively, while binary collation constant
have no suffix to the collation name.
Collation constants declared here are defined in file result.cc.
*/
#define COLL_DECL(CS) \
template<> struct Collation<CharacterSet::CS> \
{ COLLATIONS_##CS(COLL_CONST) }; \
#define COLL_CONST(CS,ID,COLL,CASE) \
static PUBLIC_API const CollationInfo COLL_CONST_NAME(COLL,CASE);
#define COLL_CONST_NAME(COLL,CASE) COLL_CONST_NAME_##CASE(COLL)
#define COLL_CONST_NAME_bin(COLL) COLL
#define COLL_CONST_NAME_ci(COLL) COLL##_ci
#define COLL_CONST_NAME_ai_ci(COLL) COLL##_ai_ci
#define COLL_CONST_NAME_cs(COLL) COLL##_cs
#define COLL_CONST_NAME_as_cs(COLL) COLL##_as_cs
#define COLL_CONST_NAME_as_ci(COLL) COLL##_as_ci
#define COLL_CONST_NAME_as_cs_ks(COLL) COLL##_as_cs_ks
// Add utf8mb4 alias for bin collation for compatibility
#undef COLLATIONS_utf8mb4_EXTRA
#define COLLATIONS_utf8mb4_EXTRA \
static PUBLIC_API const CollationInfo utf8mb4;
CDK_CS_LIST(COLL_DECL)
#undef COLLATIONS_utf8mb4_EXTRA
#define COLLATIONS_utf8mb4_EXTRA
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,606 +0,0 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_COLLECTION_CRUD_H
#define MYSQLX_COLLECTION_CRUD_H
/**
@file
Declarations for CRUD operations on document collections.
Classes declared here represent CRUD operations on a document
collection. An Object of a class such as CollectionAdd represents
a "yet-to-be-executed" operation and stores all the parameters of the
operation. The operation is sent to server for execution only when
`execute()` method is called.
The following classes for collection CRUD operations are defined:
- CollectionAdd
- CollectionRemove
- CollectionFind
- CollectionModify
CRUD operation objects can be created directly, or assigned from
result of DevAPI methods that create such operations:
~~~~~~
CollectionAdd add_op(coll);
CollectionFind find_op = coll.find(...).sort(...);
~~~~~~
CRUD operation objects have methods which can modify the operation
before it gets executed. For example `CollectionAdd::add()`
appends a document to the list of documents that should be added
by the given CollectionAdd operation. These methods can be chained
as allowed by the fluent API grammar.
@internal
The order of fluent API calls is expressed by base classes, such as
Collection_find_base, which are composed from CRUD templates defined
in crud.h. The order of templates determines the allowed order of fluent
API calls.
*/
#include "common.h"
#include "result.h"
#include "executable.h"
#include "crud.h"
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
class Session;
class Collection;
class Table;
template<>
PUBLIC_API common::Value Value::get<common::Value>() const;
// ----------------------------------------------------------------------
/*
Adding documents to a collection
================================
*/
class CollectionAdd;
namespace internal {
/*
Note: using empty class instead of alias/typedef to help Doxygen correctly
expand templates.
*/
struct Collection_add_base
: public Executable<Result, CollectionAdd>
{};
}
/**
An operation which adds documents to a collection.
Documents to be added by this operation are specified with various variants
of `add()` method.
Each document must have a unique identifier which is stored in `_id`
field of the document. Document identifiers are character strings no longer
than 32 characters. If added document does not have `_id` field, a unique
identifier is generated for it. Document identifier generated by a given
collection add operation can be examined using `Result::getDocumentIds()`
method. Generated document identifiers are strings of 32 hexadecimal digits,
like this one `0512020981044082E6119DFA0E4C0584`.
@note Generated document identifiers are based on UUIDs but they are not
valid UUIDs (fields are reversed).
@ingroup devapi_op
@internal
The various `add()` methods are implemented in terms of `do_add()` method
defined by Collection_add_detail class. This method passes documents to
the internal implementation object.
*/
class CollectionAdd
: public internal::Collection_add_base
, internal::Collection_add_detail
{
public:
/**
Create an empty add operation for the given collection.
*/
CollectionAdd(Collection &coll)
{
try {
reset(internal::Crud_factory::mk_add(coll));
}
CATCH_AND_WRAP
}
CollectionAdd(const internal::Collection_add_base &other)
{
internal::Collection_add_base::operator=(other);
}
CollectionAdd(internal::Collection_add_base &&other)
{
internal::Collection_add_base::operator=(std::move(other));
}
using internal::Collection_add_base::operator=;
/**
Add all documents from a range defined by two iterators.
*/
template <typename It>
CollectionAdd& add(const It &begin, const It &end)
{
try {
do_add(get_impl(), begin, end);
return *this;
}
CATCH_AND_WRAP
}
/**
Add all documents within given container.
Any container type for which `std::begin()`/`std::end()` are defined
should work.
*/
template <class Container>
CollectionAdd& add(const Container &c)
{
try {
do_add(get_impl(), c);
return *this;
}
CATCH_AND_WRAP
}
/**
Add document(s) to a collection.
Documents can be described by JSON strings or DbDoc objects.
*/
template <typename... Types>
CollectionAdd& add(const Types&... docs)
{
try {
do_add(get_impl(), docs...);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Collection_add_if;
Impl* get_impl()
{
return static_cast<Impl*>(internal::Collection_add_base::get_impl());
}
};
// ----------------------------------------------------------------------
/*
Removing documents from a collection
====================================
*/
class CollectionRemove;
namespace internal {
struct Collection_remove_cmd
: public Executable<Result, CollectionRemove>
{};
struct Collection_remove_base
: public Sort< Limit< Bind_parameters< Collection_remove_cmd > > >
{};
} // internal namespace
/**
An operation which removes documents from a collection.
@ingroup devapi_op
@internal
Note: All methods that modify remove operation are defined by the base
class.
*/
class CollectionRemove
: public internal::Collection_remove_base
{
public:
/**
Create an operation which removes selected documnets from the given
collection.
Documents to be removed are specified by the given Boolean expression.
*/
CollectionRemove(Collection &coll, const string &expr)
{
try {
reset(internal::Crud_factory::mk_remove(coll, expr));
}
CATCH_AND_WRAP
}
CollectionRemove(const internal::Collection_remove_cmd &other)
{
internal::Collection_remove_cmd::operator=(other);
}
CollectionRemove(internal::Collection_remove_cmd &&other)
{
internal::Collection_remove_cmd::operator=(std::move(other));
}
using internal::Collection_remove_cmd::operator=;
};
// ----------------------------------------------------------------------
/*
Searching for documents in a collection
=======================================
*/
class CollectionFind;
namespace internal {
struct Collection_find_cmd
: public Executable<DocResult, CollectionFind>
{};
struct Collection_find_base
: public Group_by< Having< Sort< Limit< Offset< Bind_parameters<
Set_lock< Collection_find_cmd, common::Collection_find_if >
> > > > > >
{};
} // internal namespace
/**
An operation which returns all or selected documents from a collection.
@ingroup devapi_op
*/
class CollectionFind
: public internal::Collection_find_base
, internal::Collection_find_detail
{
using Operation = internal::Collection_find_base;
public:
/**
Create an operation which returns all documents from the given collection.
*/
CollectionFind(Collection &coll)
{
try {
reset(internal::Crud_factory::mk_find(coll));
}
CATCH_AND_WRAP
}
/**
Create an operation which returns selected documents from the given
collection.
Documents to be returned are specified by the given Boolean expression.
*/
CollectionFind(Collection &coll, const string &expr)
{
try {
reset(internal::Crud_factory::mk_find(coll, expr));
}
CATCH_AND_WRAP
}
CollectionFind(const internal::Collection_find_cmd &other)
{
internal::Collection_find_cmd::operator=(other);
}
CollectionFind(internal::Collection_find_cmd &&other)
{
internal::Collection_find_cmd::operator=(std::move(other));
}
using internal::Collection_find_cmd::operator=;
public:
/**
Specify a projection for the documents returned by this operation.
Projection is either a single document expression given by `expr(<string>)`
or a list (or collection) of strings of the form
`"<expression> AS <path>"`. In the latter case each `<expression>`
is evaluated and `<path>` specifies where to put the value of
the expression in the resulting document (see `CollectionModify` for more
information about document paths).
*/
template <typename... Expr>
Operation& fields(Expr... proj)
{
try {
get_impl()->clear_proj();
do_fields(get_impl(), proj...);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Collection_find_if;
Impl* get_impl()
{
return static_cast<Impl*>(internal::Collection_find_base::get_impl());
}
};
// ----------------------------------------------------------------------
/*
Modifying documents in a collection
===================================
*/
class CollectionModify;
namespace internal {
class CollectionReplace;
struct Collection_modify_cmd
: public Executable<Result, CollectionModify>
{};
struct Collection_modify_base
: public Sort< Limit< Bind_parameters< Collection_modify_cmd > > >
{};
} // internal namespace
/**
An operation which modifies all or selected documents in a collection.
Note that in operations such as `set()`, `unset()`, `arrayInsert()` and
`arrayAppend()` the field argument is specified as a document path. It can be
a simple field name, but it can be a more complex expression like
`$.foo.bar[3]`. One consequence of this is that document field names that
contain spaces or other special characters need to be quoted, for example one
needs to use this form
```
.unset("\"field name with spaces\"")
```
as `.unset("field name with spaces")` would be an invalid document path
expression.
Note also that wildcard paths that use `*` or `**` are not valid for these
operations that modify documents.
See [MySQL Reference Manual](https://dev.mysql.com/doc/refman/en/json.html#json-path-syntax)
for more information on document path syntax supported by MySQL server.
@ingroup devapi_op
*/
class CollectionModify
: public internal::Collection_modify_base
{
public:
/**
Create an operation which modifies selected documents in the given
collection.
Documents to be modified are specified by the given Boolean expression.
*/
CollectionModify(Collection &coll, const string &expr)
{
try {
reset(internal::Crud_factory::mk_modify(coll, expr));
}
CATCH_AND_WRAP
}
CollectionModify(const internal::Collection_modify_cmd &other)
{
internal::Collection_modify_cmd::operator=(other);
}
CollectionModify(internal::Collection_modify_cmd &&other)
{
internal::Collection_modify_cmd::operator=(std::move(other));
}
using internal::Collection_modify_cmd::operator=;
/**
Set the given field in a document to the given value.
The field is given by a document path. The value can be either a direct
literal, `DbDoc` instance or an expression given as `expr(<string>)`, to be
evaluated on the server.
*/
CollectionModify& set(const Field &field, const Value &val)
{
try {
get_impl()->add_operation(Impl::SET, field,
val.get<common::Value>());
return *this;
}
CATCH_AND_WRAP
}
/**
Remove the given field from a document.
The field is given by a document path.
*/
CollectionModify& unset(const Field &field)
{
try {
get_impl()->add_operation(Impl::UNSET, field);
return *this;
}
CATCH_AND_WRAP
}
/**
Insert a value into an array field of a document.
The `field` parameter should be a document path pointing at a location
inside an array field. The given value is inserted at this position.
*/
CollectionModify& arrayInsert(const Field &field, const Value &val)
{
try {
get_impl()->add_operation(Impl::ARRAY_INSERT, field,
val.get<common::Value>());
return *this;
}
CATCH_AND_WRAP
}
/**
Append a value to an array field of a document.
The `field` parameter should be a document path pointing at an array
field inside the document. The given value is appended at the end of the
array.
*/
CollectionModify& arrayAppend(const Field &field, const Value &val)
{
try {
get_impl()->add_operation(Impl::ARRAY_APPEND, field,
val.get<common::Value>());
return *this;
}
CATCH_AND_WRAP
}
/**
Apply JSON Patch to a target JSON document.
The JSON Patch format is defined by
<a href=https://tools.ietf.org/html/rfc7386>RFC7386</a>.
A document patch is similar to a JSON object, with the key difference that
document field values can be nested expressions in addition to literal
values.
The patch contains instructions of how the source document is to be modified
producing a derived document. By default, all fields from the source
document are copied to the resulting document. If patch sets a field to NULL,
the field of that name in the source is skipped from the result, identifiers
and function calls are evaluated against the original source document.
*/
CollectionModify& patch(const string &val)
{
try {
get_impl()->add_operation(
Impl::MERGE_PATCH, "$", (const common::Value&)expr(val)
);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Collection_modify_if;
Impl* get_impl()
{
return static_cast<Impl*>(internal::Collection_modify_base::get_impl());
}
};
MYSQLX_ABI_END(2,0)
} // mysqlx namespace
#endif

View File

@@ -1,879 +0,0 @@
/*
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_COMMON_H
#define MYSQLX_COMMON_H
#include "../common.h"
PUSH_SYS_WARNINGS
#include <string>
#include <stdexcept>
#include <ostream>
#include <memory>
#include <forward_list>
#include <string.h> // for memcpy
#include <utility> // std::move etc
POP_SYS_WARNINGS
#define CATCH_AND_WRAP \
catch (const ::mysqlx::Error&) { throw; } \
catch (const std::out_of_range&) { throw; } \
catch (const std::exception &e) \
{ throw ::mysqlx::Error(e.what()); } \
catch (const char *e) \
{ throw ::mysqlx::Error(e); } \
catch (...) \
{ throw ::mysqlx::Error("Unknown exception"); } \
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
using std::out_of_range;
using common::byte;
class Value;
/**
Base class for connector errors.
@internal
TODO: Derive from std::system_error and introduce proper
error codes.
@endinternal
@ingroup devapi
*/
// TODO: Make it header-only class somehow...
DLL_WARNINGS_PUSH
class PUBLIC_API Error : public common::Error
{
DLL_WARNINGS_POP
public:
Error(const char *msg)
: common::Error(msg)
{}
};
inline
void throw_error(const char *msg)
{
throw Error(msg);
}
/**
A wrapper around std::wstring that can perform
conversions from/to different character encodings
used by MySQL.
Currently only utf-8 encoding is supported.
@ingroup devapi_aux
*/
class string : public std::u16string
{
struct Impl
{
PUBLIC_API static std::string to_utf8(const string&);
PUBLIC_API static void from_utf8(string&, const std::string&);
PUBLIC_API static std::u32string to_ucs4(const string&);
PUBLIC_API static void from_ucs4(string&, const std::u32string&);
PUBLIC_API static std::wstring to_wide(const string&);
PUBLIC_API static void from_wide(string&, const std::wstring&);
};
template <typename T>
struct traits
{};
public:
string() {}
string(const string&) = default;
string(string&&) = default;
string& operator=(const string&) = default;
string& operator=(string&&) = default;
using std::u16string::basic_string;
string(const std::u16string &other) : std::u16string(other) {}
string(std::u16string &&other) : std::u16string(std::move(other)) {}
template <typename C>
string(const C *other)
{
try {
if (!other)
return;
std::basic_string<C> str(other);
traits<C>::from_str(*this, str);
}
CATCH_AND_WRAP
}
template <typename C>
string(const std::basic_string<C> &other)
{
try {
traits<C>::from_str(*this, other);
}
CATCH_AND_WRAP
}
template <typename C>
operator std::basic_string<C>() const
{
try {
return traits<C>::to_str(*this);
}
CATCH_AND_WRAP
}
friend bool operator==(const string&lhs, const string&rhs)
{
return operator==((const std::u16string&)lhs, (const std::u16string&)rhs);
}
friend bool operator!=(const string&lhs, const string&rhs)
{
return !(lhs == rhs);
}
// Note: These are needed to help overload resolution :/
friend bool operator==(const string &lhs, const char16_t *rhs)
{
return lhs == string(rhs);
}
friend bool operator==(const char16_t *lhs, const string &rhs)
{
return string(lhs) == rhs;
}
friend bool operator!=(const string &lhs, const char16_t *rhs)
{
return !(lhs == rhs);
}
friend bool operator!=(const char16_t *lhs, const string &rhs)
{
return !(lhs == rhs);
}
};
template<>
struct string::traits<char>
{
using string = std::string;
static void from_str(mysqlx::string &to, const string &from)
{
Impl::from_utf8(to, from);
}
static string to_str(const mysqlx::string &from)
{
return Impl::to_utf8(from);
}
};
template<>
struct string::traits<wchar_t>
{
using string = std::wstring;
static void from_str(mysqlx::string &to, const string &from)
{
Impl::from_wide(to, from);
}
static string to_str(const mysqlx::string &from)
{
return Impl::to_wide(from);
}
};
template<>
struct string::traits<char32_t>
{
using string = std::u32string;
static void from_str(mysqlx::string &to, const string &from)
{
Impl::from_ucs4(to, from);
}
static string to_str(const mysqlx::string &from)
{
return Impl::to_ucs4(from);
}
};
inline
std::ostream& operator<<(std::ostream &out, const string &str)
{
const std::string utf8(str);
out << utf8;
return out;
}
typedef unsigned long col_count_t;
typedef unsigned long row_count_t;
/**
Class representing a region of memory holding raw bytes.
Method `begin()` returns pointer to the first byte in the
region, `end()` to one past the last byte in the region.
@note An instance of `bytes` does not store the bytes -
it merely describes a region of memory and is equivalent
to a pair of pointers. It is very cheap to copy `bytes` and
pass them by value.
@note This class extends std::pair<byte *, size_t> to make
it consistent with how memory regions are described by
std::get_temporary_buffer(). It is also possible to initialize
a `bytes` instance by buffer returned from
std::get_temporary_buffer(), as follows:
bytes buf = std::get_temporary_buffer<byte>(size);
@ingroup devapi_aux
*/
class bytes : public std::pair<const byte*, size_t>
{
public:
bytes(const byte *beg_, const byte *end_)
: pair(beg_, end_ - beg_)
{}
bytes(const byte *beg, size_t len) : pair(beg, len)
{}
bytes(const char *str) : pair((const byte*)str, 0)
{
if (nullptr != str)
second = strlen(str);
}
bytes(std::pair<const byte*, size_t> buf) : pair(buf)
{}
bytes() : pair(nullptr, 0)
{}
bytes(const bytes &) = default;
virtual const byte* begin() const { return first; }
virtual const byte* end() const { return first + second; }
size_t length() const { return second; }
size_t size() const { return length(); }
class Access;
friend Access;
};
/*
Infrastructure for type-agnostic handling of lists
==================================================
Template internal::List_initializer<> defined below is used to return lists
of values from public API method so that user can store this list in
a container of his choice. The only requirement is that the container instance
should be constructible from two iterators defining a range of elements
(such constructors exists for standard STL containers, for example).
Thus, given a public API method foo() which returns a List_initializer<> for
lists of elements of type X, user can do the following:
My_container cont = foo();
The container will be constructed as if this code was executed:
My_container cont = My_container(begin, end);
where begin and end are STL iterators defining a range of elements of type X.
This is implemented by defining templated conversion operator.
Apart from initializing containers, values of List_initializer<> type can
be iterated using a range loop:
for(X &el : foo()) { ... }
Otherwise, user should not be able to use List_initializer<> values directly.
*/
namespace internal {
/*
Iterator template.
It defines an STL input iterator which is implemented using an
implementation object of some type Impl. It is assumed that Impl
has the following methods:
void iterator_start() - puts iterator in "before begin" position;
bool iterator_next() - moves iterator to next position, returns
false if it was not possible;
Value_type iterator_get() - gets current value.
An implementation object must be passed to iterator constructor. Iterator
stores only a pointer to this implementation (so it must exist as long as
iterator is used).
*/
template<
typename Impl,
typename T = typename std::iterator_traits<Impl>::value_type,
typename Distance = typename std::iterator_traits<T*>::difference_type,
typename Pointer = typename std::iterator_traits<T*>::pointer,
typename Reference = typename std::iterator_traits<T*>::reference
>
struct Iterator
{
public:
using iterator_category = std::input_iterator_tag;
using value_type = T;
using difference_type = Distance;
using pointer = Pointer;
using reference = Reference;
protected:
typename std::remove_reference<Impl>::type *m_impl = NULL;
bool m_at_end = false;
public:
Iterator(Impl &impl) : m_impl(&impl) {
m_impl->iterator_start();
m_at_end = !m_impl->iterator_next();
}
Iterator()
: m_at_end(true)
{}
bool operator==(const Iterator &other) const
{
return (m_at_end && other.m_at_end);
}
bool operator !=(const Iterator &other) const
{
/*
Compares only if both iterators are at the end
of the sequence.
*/
return !(m_at_end && other.m_at_end);
}
Iterator& operator++()
{
try {
if (m_impl && !m_at_end)
m_at_end = !m_impl->iterator_next();
return *this;
}
CATCH_AND_WRAP
}
T operator*() const
{
if (!m_impl || m_at_end)
THROW("Attempt to dereference null iterator");
try {
return m_impl->iterator_get();
}
CATCH_AND_WRAP
}
friend Impl;
};
/*
List_initializer object can be used to initialize a container of
arbitrary type U with list of items taken from a source object.
It is assumed that the source object type Source defines iterator
type and that std::begin/end() return iterators to the beginning
and end of the sequence. The container type U is assumed to have
a constructor from begin/end iterator.
List_iterator defines begin/end() methods, so it is possible to
iterate over the sequence without storing it in any container.
*/
template <class Source>
class List_initializer
{
protected:
Source m_src;
friend Source;
public:
/*
Arguments given to the constructor are passed to the internal
m_src object.
*/
template <typename... Ty>
List_initializer(Ty&&... args)
: m_src(std::forward<Ty>(args)...)
{}
/*
Narrow the set of types for which this template is instantiated
to avoid ambiguous conversion errors. It is important to disallow
conversion to std::initializer_list<> because this conversion path
is considered when assigning to STL containers.
*/
template <
typename U
, typename std::enable_if<
!std::is_same< U, std::initializer_list<typename U::value_type> >::value
>::type* = nullptr
>
operator U()
{
try {
return U(std::begin(m_src), std::end(m_src));
}
CATCH_AND_WRAP
}
auto begin() -> decltype(std::begin(m_src))
{
try {
return std::begin(m_src);
}
CATCH_AND_WRAP
}
auto end() const -> decltype(std::end(m_src))
{
try {
return std::end(m_src);
}
CATCH_AND_WRAP
}
};
template <typename T>
struct iterator_traits
{
using value_type = typename std::remove_reference<T>::type;
using difference_type
= typename std::iterator_traits<value_type*>::difference_type;
using pointer
= typename std::iterator_traits<value_type*>::pointer;
using reference
= typename std::iterator_traits<value_type*>::reference;
};
/*
This helper template adapts class Impl to be used as a source for
List_initializer<> template.
Class Impl should be suitable for the Iterator<> template which is used to
build iterators required by List_initializer<>. That is, Impl should
implement iterator_start(), iteratore_next() etc (see Iterator<>).
*/
template<
typename Impl,
typename Value_type = typename Impl::Value,
typename Distance = typename iterator_traits<Value_type>::difference_type,
typename Pointer = typename iterator_traits<Value_type>::pointer,
typename Reference = typename iterator_traits<Value_type>::reference
>
class List_source
{
protected:
Impl m_impl;
public:
template <typename... Ty>
List_source(Ty&&... args)
: m_impl(std::forward<Ty>(args)...)
{}
using iterator = Iterator<Impl, Value_type, Distance, Pointer, Reference>;
iterator begin()
{
return iterator(m_impl);
}
iterator end() const
{
return iterator();
}
};
/*
A template used to adapt an object of class Impl that represents an array of
values accessed via operator[] to be used as source for List_initializer<>
template. This template uses instance of Impl to implement the iterator
methods iterator_start(), so that it can be used with Iterator<> template.
*/
template <typename Impl, typename Value_type = typename Impl::Value>
class Array_src_impl
{
protected:
Impl m_impl;
size_t m_pos = 0;
bool m_at_begin = true;
public:
template <typename... Ty>
Array_src_impl(Ty&&... args)
: m_impl(std::forward<Ty>(args)...)
{}
void iterator_start()
{
m_pos = 0;
m_at_begin = true;
}
bool iterator_next()
{
if (m_at_begin)
m_at_begin = false;
else
m_pos++;
return m_pos < size();
}
Value_type iterator_get()
{
return operator[](m_pos);
}
Value_type operator[](size_t pos)
{
return m_impl[pos];
}
size_t size() const
{
return m_impl.size();
}
};
/*
This template adapts an object of type Impl holding an array of values as
a source for List_initializer<> template. It combines List_source<> and
Array_src_impl<> adapters.
*/
template<
typename Impl,
typename Value_type = typename Impl::Value,
typename Distance = typename iterator_traits<Value_type>::difference_type,
typename Pointer = typename iterator_traits<Value_type>::pointer,
typename Reference = typename iterator_traits<Value_type>::reference
>
class Array_source
: public List_source<
Array_src_impl<Impl, Value_type>,
Value_type,
Distance,
Pointer,
Reference
>
{
using Base = List_source<
Array_src_impl<Impl, Value_type>,
Value_type,
Distance,
Pointer,
Reference
>;
using Base::m_impl;
public:
using
List_source<
Array_src_impl<Impl, Value_type>,
Value_type,
Distance,
Pointer,
Reference
>::List_source;
Value_type operator[](size_t pos)
{
return m_impl[pos];
}
size_t size() const
{
return m_impl.size();
}
};
} // internal
/*
Infrastructure for handling variable argument lists
===================================================
See documentation of Args_processor<> template.
*/
namespace internal {
/*
Type trait which checks if std::begin()/end() work on objects of given
class C, so that it can be used as a range to iterate over.
TODO: Make it work also with user-defined begin()/end() functions.
TODO: Make it work with plain C arrays. For example:
int vals[] = { 1, 2, 3 }
process_args(data, vals)
*/
template <class C>
class is_range
{
/*
Note: This overload is taken into account only if std::begin(X) and
std::end(X) expressions are valid.
*/
template <class X>
static std::true_type
test(
decltype(std::begin(*((X*)nullptr)))*,
decltype(std::end(*((X*)nullptr)))*
);
template <class X>
static std::false_type test(...);
public:
static const bool value = std::is_same<
std::true_type,
decltype(test<C>(nullptr, nullptr))
>::value;
};
/*
Class template to be used for uniform processing of variable argument lists
in public API methods. This template handles the cases where arguments
are specified directly as a list:
method(arg1, arg2, ..., argN)
or they are taken from a container such as std::list:
method(container)
or they are taken from a range of items described by two iterators:
method(begin, end)
A class B that is using this template to define a varargs method 'foo'
should define it as follows:
template <typename... T>
X foo(T... args)
{
Args_processor<B>::process_args(m_impl, args...);
return ...;
}
Process_args() is a static method of Args_processor<> and therefore
additional context data is passed to it as the first argument. By default
this context is a pointer to internal implementation object, as defined
by the base class B. The process_args() methods does all the necessary
processing of the variable argument list, passing the resulting items
one-by-one to B::process_one() method. Base class B must define this
static method, which takes the context and one data item as arguments.
B::process_one() method can have overloads that handle different types
of data items.
See devapi/detail/crud.h for usage examples.
*/
template <class Base, class D = typename Base::Impl*>
class Args_processor
{
public:
/*
Check if item of type T can be passed to Base::process_one()
*/
template <typename T>
class can_process
{
template <typename X>
static std::true_type
test(decltype(Base::process_one(*(D*)nullptr, *(X*)nullptr))*);
template <typename X>
static std::false_type test(...);
public:
static const bool value
= std::is_same< std::true_type, decltype(test<T>(nullptr)) >::value;
};
public:
/*
Process items from a container.
*/
template <
typename C,
typename std::enable_if<is_range<C>::value>::type* = nullptr,
typename std::enable_if<!can_process<C>::value>::type* = nullptr
>
static void process_args(D data, C container)
{
// TODO: use (const) reference to avoid copying instances?
for (auto el : container)
{
Base::process_one(data, el);
}
}
/*
If process_args(data, a, b) is called and a,b are of the same type It
which can not be passed to Base::process_one() then we assume that a and
b are iterators that describe a range of elements to process.
*/
template <
typename It,
typename std::enable_if<!can_process<It>::value>::type* = nullptr
>
static void process_args(D data, const It &begin, const It &end)
{
for (It it = begin; it != end; ++it)
{
Base::process_one(data, *it);
}
}
/*
Process elements given as a varargs list.
*/
template <
typename T,
typename... R,
typename std::enable_if<can_process<T>::value>::type* = nullptr
>
static void process_args(D data, T first, R&&... rest)
{
process_args1(data, first, std::forward<R>(rest)...);
}
private:
template <
typename T,
typename... R,
typename std::enable_if<can_process<T>::value>::type* = nullptr
>
static void process_args1(D data, T first, R&&... rest)
{
Base::process_one(data, first);
process_args1(data, std::forward<R>(rest)...);
}
static void process_args1(D)
{}
};
} // internal namespace
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,508 +0,0 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_CRUD_H
#define MYSQLX_CRUD_H
/**
@file
Common templates used to define CRUD operation classes.
*/
#include "common.h"
#include "detail/crud.h"
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
class Session;
class Collection;
class Table;
namespace internal {
/*
Factory for constructing concrete implementations of various CRUD
operations. All these implementations implement the base Executable_if
interface.
Note: The caller of mk_xxx() method takes ownership of the returned
implementation object.
*/
struct PUBLIC_API Crud_factory
{
using Impl = common::Executable_if;
static Impl* mk_add(Collection &coll);
static Impl* mk_remove(Collection &coll, const string &expr);
static Impl* mk_find(Collection &coll);
static Impl* mk_find(Collection &coll, const string &expr);
static Impl* mk_modify(Collection &coll, const string &expr);
static Impl* mk_insert(Table &tbl);
static Impl* mk_select(Table &tbl);
static Impl* mk_update(Table &tbl);
static Impl* mk_remove(Table &tbl);
static Impl* mk_sql(Session &sess, const string &sql);
};
} // internal
/*
Different CRUD operation classes derive from `Executable` which defines
the `execute()` method that executes given operation. Derived classes
define additional methods that can modify the operation before it gets
executed.
The hierarchy of classes reflects the grammar that defines the order in which
fluent API calls can be done. It is built using templates, such as Offset<>
below, which add one API call on top of base class which defines remaining
API calls that can be called later. For example, type
Limit< Offset< Executable<...> > >
represents an operation for which first .limit() can be called, followed by
.offset() and then finally .execute(). See classes like
Collection_find_base in collection_crud.h for more examples.
Each template assumes that its base class defines method 'get_impl()' which
returns a pointer to the internal implementation object. It also assumes that
this implementation is of appropriate type and can be casted to
the appropriate interface type. For example Limit<> template assumes
that the implementation type can be casted to Limit_if type.
*/
/**
@brief The LockContention enum defines constants for defining
the row locking contention for `Set_lock::lockExclusive()`
and `Set_lock::lockShared()` methods.
@see https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html#innodb-locking-reads-nowait-skip-locked
*/
enum_class LockContention
{
#define DEVAPI_LOCK_CONTENTION_ENUM(X,N) X = N,
LOCK_CONTENTION_LIST(DEVAPI_LOCK_CONTENTION_ENUM)
};
namespace internal {
/**
Template for defining fluent api for CRUD operations.
*/
template <class Base>
class Offset
: public Base
{
using Operation = Base;
public:
/**
Skip the given number of items (rows or documents) before starting
to perform the operation.
*/
Operation& offset(unsigned rows)
{
try {
get_impl()->set_offset(rows);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Limit_if;
Impl* get_impl()
{
return static_cast<Impl*>(Base::get_impl());
}
};
/// @copydoc Offset
template <class Base>
class Limit
: public Base
{
using Operation = Base;
public:
/**
%Limit the operation to the given number of items (rows or documents).
*/
Operation& limit(unsigned items)
{
try {
get_impl()->set_limit(items);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Limit_if;
Impl* get_impl()
{
return static_cast<Impl*>(Base::get_impl());
}
};
/// @copydoc Offset
template <class Base>
class Sort
: public Base
, Sort_detail
{
using Operation = Base;
public:
/**
Specify ordering of documents in a query results.
Arguments are one or more strings of the form `"<expr> <dir>"` where
`<expr>` gives the value to sort on and `<dir>` is a sorting direction
`ASC` or `DESC`.
*/
template <typename...Type>
Operation& sort(Type... spec)
{
try {
get_impl()->clear_sort();
add_sort(get_impl(), spec...);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Sort_if;
Impl* get_impl()
{
return static_cast<Impl*>(Base::get_impl());
}
};
/// @copydoc Offset
template <class Base>
class Order_by
: public Base
, Sort_detail
{
using Operation = Base;
public:
/**
Specify ordering of rows in a query results.
Arguments are one or more strings of the form `"<expr> <dir>"` where
`<expr>` gives the value to sort on and `<dir>` is a sorting direction
`ASC` or `DESC`.
*/
template <typename...Type>
Operation& orderBy(Type... spec)
{
try {
get_impl()->clear_sort();
add_sort(get_impl(), spec...);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Sort_if;
Impl* get_impl()
{
return static_cast<Impl*>(Base::get_impl());
}
};
/// @copydoc Offset
template <class Base>
class Having
: public Base
{
using Operation = Base;
public:
/**
Specify filter over grouped results of a query.
The argument is a Boolean expression which can use aggregation functions.
*/
Operation& having(const string& having_spec)
{
try {
get_impl()->set_having(having_spec);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Having_if;
Impl* get_impl()
{
return static_cast<Impl*>(Base::get_impl());
}
};
/// @copydoc Offset
template <class Base>
class Group_by
: public Base
, Group_by_detail
{
using Operation = Base;
public:
/**
Specify grouping of items in a query result.
Arguments are a one or more expressions. Documents/rows for which
expressions evaluate to the same value are grouped together.
*/
template <typename... Expr>
Operation& groupBy(Expr... group_by_spec)
{
try {
get_impl()->clear_group_by();
do_group_by(get_impl(), group_by_spec...);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Group_by_if;
Impl* get_impl()
{
return static_cast<Impl*>(Base::get_impl());
}
};
/// @copydoc Offset
template <class Base>
class Bind_placeholders
: public Base
, Bind_detail
{
using BindOperation = Bind_placeholders;
public:
/**
Specify values for '?' placeholders in a query.
One or more values can be specified in a single call to bind(). A query
can be executed only if values for all placeholders have been specified.
*/
template <typename... Types>
BindOperation& bind(Types&&... vals)
{
try {
add_params(get_impl(), std::forward<Types>(vals)...);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Bind_if;
Impl* get_impl()
{
return static_cast<Impl*>(Base::get_impl());
}
};
/// @copydoc Offset
template <class Base>
class Bind_parameters
: public Base
{
using BindOperation = Bind_parameters;
using Operation = Base;
public:
/**
Bind parameter with given name to the given value.
A statement or query can be executed only if all named parameters used by
it are bound to values.
*/
BindOperation& bind(const string &parameter, const Value &val)
{
//TODO: Protocol supports Document and Array... but common::Values doesn't!
if (Value::DOCUMENT == val.getType())
throw_error("Can not bind a parameter to a document");
if (Value::ARRAY == val.getType())
throw_error("Can not bind a parameter to an array");
try {
get_impl()->add_param(parameter, (const common::Value&)val);
return *this;
}
CATCH_AND_WRAP
}
/**
Bind parameters to values given by a map from parameter
names to their values.
*/
template <class Map>
Operation& bind(const Map &args)
{
for (const auto &keyval : args)
{
bind(keyval.first, keyval.second);
}
return *this;
}
protected:
using Impl = common::Bind_if;
Impl* get_impl()
{
return static_cast<Impl*>(Base::get_impl());
}
};
/// @copydoc Offset
template <class Base, class IMPL>
class Set_lock
: public Base
{
using Operation = Base;
public:
/**
Set a shared mode lock on any rows/documents that are read.
Other sessions can read, but not modify locked rows/documents.
*/
Operation&
lockShared(LockContention contention= LockContention::DEFAULT)
{
get_impl()->set_lock_mode(common::Lock_mode::SHARED,
common::Lock_contention((unsigned)contention));
return *this;
}
/**
Set an exclusive mode lock on any rows/documents that are read.
Other sessions are blocked from modifying, locking, or reading the data
in certain transaction isolation levels. The lock is released
when the transaction is committed or rolled back.
*/
Operation&
lockExclusive(LockContention contention = LockContention::DEFAULT)
{
get_impl()->set_lock_mode(common::Lock_mode::EXCLUSIVE,
common::Lock_contention((unsigned)contention));
return *this;
}
protected:
using Impl = IMPL;
Impl* get_impl()
{
return static_cast<Impl*>(Base::get_impl());
}
};
} // internal
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,280 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_DETAIL_CRUD_H
#define MYSQLX_DETAIL_CRUD_H
/**
@file
Details for public API classes representing CRUD operations.
*/
#include "../common.h"
#include "../executable.h"
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
namespace internal {
struct PUBLIC_API Bind_detail
{
protected:
using Impl = common::Bind_if;
using Args_prc = Args_processor<Bind_detail, Impl*>;
static void process_one(Impl *impl, const Value &val)
{
impl->add_param((const common::Value&)val);
}
template <typename... T>
static void add_params(Impl *impl, T&&... vals)
{
Args_prc::process_args(impl, std::forward<T>(vals)...);
}
friend Args_prc;
};
struct PUBLIC_API Sort_detail
{
protected:
using Impl = common::Sort_if;
using Args_prc = Args_processor<Sort_detail, Impl*>;
static void process_one(Impl *impl, const string &ord_spec)
{
impl->add_sort(ord_spec);
}
template <typename... T>
static void add_sort(Impl *impl, T... args)
{
Args_prc::process_args(impl, args...);
}
friend Args_prc;
};
struct PUBLIC_API Group_by_detail
{
protected:
using Impl = common::Group_by_if;
using Args_prc = Args_processor<Group_by_detail, Impl*>;
static void process_one(Impl *impl, const string &spec)
{
impl->add_group_by(spec);
}
template <typename... T>
static void do_group_by(Impl *impl, T... args)
{
Args_prc::process_args(impl, args...);
}
friend Args_prc;
};
struct PUBLIC_API Proj_detail
{
protected:
using Impl = common::Proj_if;
using Args_prc = Args_processor<Proj_detail, Impl*>;
static void process_one(Impl *impl, const string &spec)
{
impl->add_proj(spec);
}
template <typename... T>
static void add_proj(Impl *impl, T... proj_spec)
{
Args_prc::process_args(impl, proj_spec...);
}
friend Args_prc;
};
struct PUBLIC_API Collection_add_detail
{
protected:
using Impl = common::Collection_add_if;
using Args_prc = Args_processor<Collection_add_detail, Impl*>;
static void process_one(Impl *impl, const string &json)
{
impl->add_json(json);
}
static void process_one(Impl *impl, const DbDoc &doc)
{
// TODO: Do it better when we support sending structured
// document descriptions to the server.
std::ostringstream buf;
buf << doc;
// Note: utf8 conversion using mysqlx::string.
impl->add_json(mysqlx::string(buf.str()));
}
template <typename... T>
static void do_add(Impl *impl, T... args)
{
Args_prc::process_args(impl, args...);
}
friend Args_prc;
};
struct PUBLIC_API Collection_find_detail
{
protected:
using Impl = common::Proj_if;
using Args_prc = Args_processor<Collection_find_detail, Impl*>;
static void process_one(Impl *impl, const string &proj)
{
impl->add_proj(proj);
}
static void do_fields(Impl *impl, const Expression &proj)
{
impl->set_proj(proj.get<string>());
}
/*
Note: If e is an expression (of type Expression) then only
.fields(e) is valid - the multi-argument variant .fields(e,...)
should be disabled.
*/
template <
typename T, typename... R,
typename std::enable_if<!std::is_same<T, Expression>::value>::type* = nullptr
>
static void do_fields(Impl *impl, T first, R... rest)
{
Args_prc::process_args(impl, first, rest...);
}
friend Args_prc;
};
struct PUBLIC_API Table_insert_detail
{
protected:
using Row_impl = internal::Row_detail::Impl;
using Impl = common::Table_insert_if<Row_impl>;
/*
Helper methods which pass column/row information to the
internal implementation object.
*/
struct Add_column
{
static void process_one(Impl *impl, const string &col)
{
impl->add_column(col);
}
};
struct Add_value
{
using Impl = std::pair<Row, unsigned>;
static void process_one(Impl *impl, const mysqlx::Value &val)
{
impl->first.set((impl->second)++, val);
}
};
struct Add_row
{
static void process_one(Impl *impl, const Row &row)
{
impl->add_row(*row.m_impl);
}
};
template <typename... T>
static void add_columns(Impl *impl, T... args)
{
Args_processor<Add_column, Impl*>::process_args(impl, args...);
}
template <typename... T>
static void add_rows(Impl *impl, T... args)
{
Args_processor<Add_row, Impl*>::process_args(impl, args...);
}
template <typename... T>
static void add_values(Impl *impl, T... args)
{
Add_value::Impl row{ {}, 0 };
Args_processor<Add_value>::process_args(&row, args...);
Add_row::process_one(impl, row.first);
}
friend Args_processor<Add_column, Impl*>;
friend Args_processor<Add_row, Impl*>;
friend Args_processor<Add_value, Impl*>;
};
using Table_select_detail = Proj_detail;
} // internal
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,77 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_DETAIL_ERROR_H
#define MYSQLX_DETAIL_ERROR_H
/**
@file
Classes used to access query and command execution results.
*/
#include "../common.h"
//#include <memory>
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
namespace internal {
class Result_detail;
class Warning_detail
: public virtual common::Printable
{
protected:
byte m_level;
uint16_t m_code;
string m_msg;
Warning_detail(Warning_detail&&) = default;
Warning_detail(const Warning_detail&) = default;
Warning_detail(byte level, uint16_t code, const std::string &msg)
: m_level(level), m_code(code), m_msg(msg)
{}
void print(std::ostream &) const override;
friend Result_detail;
};
} // internal namespace
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,470 +0,0 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_DETAIL_RESULT_H
#define MYSQLX_DETAIL_RESULT_H
/**
@file
Details for public API result classes.
*/
#include "../common.h"
#include "../error.h"
#include "../document.h"
#include "../row.h"
#include "../collations.h"
#include <deque>
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
class RowResult;
class Column;
class Columns;
class Session;
namespace common {
class Result_init;
class Column_info;
class Result_impl;
} // common
namespace internal {
struct Session_detail;
class PUBLIC_API Result_detail
{
// Disable copy semantics for result classes.
Result_detail(const Result_detail&) = delete;
Result_detail& operator=(const Result_detail&) = delete;
public:
using Impl = common::Result_impl;
protected:
Result_detail(common::Result_init&);
// Note: move semantics is implemented by move assignment operator.
Result_detail(Result_detail &&other)
{
operator=(std::move(other));
}
Result_detail& operator=(Result_detail&&);
Result_detail() = default;
virtual ~Result_detail();
Impl& get_impl();
const Impl& get_impl() const
{
return const_cast<Result_detail*>(this)->get_impl();
}
void check_result() const;
uint64_t get_affected_rows() const;
uint64_t get_auto_increment() const;
using DocIdList = internal::List_initializer<const std::vector<std::string>&>;
DocIdList get_generated_ids() const;
// Handling multi-results
bool has_data() const;
// Note: needs to be called before accessing the first result set.
bool next_result();
protected:
Impl *m_impl = nullptr;
bool m_owns_impl = false;
/*
Source for WarningList initializer.
*/
struct Warning_src
{
using Value = Warning;
Result_detail &m_res;
Warning_src(Result_detail &res)
: m_res(res)
{}
size_t size() const
{
return m_res.get_warning_count();
}
Warning operator[](size_t pos)
{
return m_res.get_warning(pos);
}
};
public:
using WarningList = internal::List_initializer<Array_source<Warning_src>>;
protected:
unsigned get_warning_count() const;
Warning get_warning(size_t pos);
WarningList get_warnings()
{
get_warning_count();
return { *this };
}
public:
friend Session_detail;
friend List_initializer<Result_detail>;
};
/*
This class keeps a reference to column information stored in a
common::Column_info<> instance. The meta-data is exposed in format expected
by X DevAPI meta-data access methods. In particualr the CDK type and encoding
format information is translated to X DevAPI type information. For example,
a CDK column of type FLOAT can be reported as DevAPI type FLOAT, DOUBLE
or DECIMAL, depending on the encoding format that was reported by CDK. This
translation happens in Column::getType() method.
Additional encoding information is exposed via other methods such as
is_signed().
*/
class PUBLIC_API Column_detail
: virtual common::Printable
{
protected:
using Impl = common::Column_info;
const Impl *m_impl = nullptr;
Column_detail(const Impl *impl)
: m_impl(impl)
{}
const Impl& get_impl() const
{
assert(m_impl);
return *m_impl;
}
string get_name() const;
string get_label() const;
string get_schema_name() const;
string get_table_name() const;
string get_table_label() const;
// Note: should return values of mysqlx::Type enum constants
unsigned get_type() const;
CharacterSet get_charset() const;
const CollationInfo& get_collation() const;
unsigned long get_length() const;
unsigned short get_decimals() const;
bool is_signed() const;
bool is_padded() const;
void print(std::ostream&) const override;
protected:
Column_detail() = default;
Column_detail(const Column_detail&) = default;
Column_detail(Column_detail&&) = default;
Column_detail& operator=(const Column_detail&) = default;
public:
friend Impl;
friend Result_detail;
friend RowResult;
struct INTERNAL Access;
friend Access;
};
/*
A wrapper around column meta-data class COL that adds copy semantics
and default ctor. This is required by Columns_detail class which uses
an STL container to store data for several columns.
*/
template <class COL>
struct Column_storage
: public COL
{
Column_storage(const typename COL::Impl *impl)
: COL(impl)
{}
// Note: these members are needed to use it with std::deque<>
Column_storage() = default;
Column_storage(const Column_storage&) = default;
Column_storage& operator=(const Column_storage&) = default;
};
template <class COLS> class Row_result_detail;
/*
Class holding meta-data information for all columns in a result.
Template parameter COL is a class used to store information about a single
column. It is made into template parameter because full definition of
the actuall mysqlx::Column class is not available in this header.
Note: Because this class is implemented using std::deque<>, we wrap COL
class with the Column_storage<> wrapper to provide copy semantics and default
ctor required by this STL container.
*/
template <class COL>
class Columns_detail
: public std::deque<Column_storage<COL>>
{
Columns_detail(const Columns_detail&) = delete;
protected:
Columns_detail() = default;
Columns_detail(Columns_detail&&) = default;
Columns_detail& operator=(Columns_detail&&) = default;
void init(const internal::Result_detail::Impl&);
///@cond IGNORE
friend internal::Row_result_detail<Columns>;
///@endcond
};
/*
COLS is a class used to store information about result columns. It is made
into template parameter because the actual mysqlx::Columns class, with
the public API for accessing column information, is defined in the top-level
header devapi/result.h.
The COLS class should have move semantics to enable move-semantics for result
objects.
*/
template <class COLS>
class Row_result_detail
: public Result_detail
{
public:
using iterator = Iterator<Row_result_detail, Row>;
using RowList = List_initializer<Row_result_detail&>;
using Columns = COLS;
iterator begin()
{
return iterator(*this);
}
iterator end() const
{
return iterator();
}
private:
// Row iterator implementation
Row m_row;
using Value = Row;
void iterator_start() {}
bool iterator_next();
Value iterator_get()
{
return m_row;
}
protected:
Row_result_detail() = default;
Row_result_detail(common::Result_init&);
Row_result_detail(Row_result_detail&&) = default;
Row_result_detail& operator=(Row_result_detail&&) = default;
RowList get_rows()
{
/*
Construct RowList instance passing reference to this Row_result_detail
object which acts as a source for the list initializer.
*/
return *this;
}
row_count_t row_count();
Row get_row()
{
if (!iterator_next())
return Row();
return iterator_get();
}
private:
// Storage for result column information.
Columns m_cols;
protected:
col_count_t col_count() const;
const Column& get_column(col_count_t) const;
const Columns& get_columns() const;
bool next_result()
{
bool rc = Result_detail::next_result();
if (rc)
m_cols.init(get_impl());
return rc;
}
friend iterator;
friend RowResult;
friend Columns;
};
// Document based results
// ----------------------
class PUBLIC_API Doc_result_detail
: public Result_detail
{
public:
using iterator = Iterator<Doc_result_detail, DbDoc>;
using DocList = List_initializer<Doc_result_detail&>;
iterator begin()
{
return iterator(*this);
}
iterator end() const
{
return iterator();
}
private:
// iterator implementation
DbDoc m_cur_doc;
void iterator_start() {}
bool iterator_next();
DbDoc iterator_get()
{
return m_cur_doc;
}
protected:
Doc_result_detail() = default;
Doc_result_detail(common::Result_init &init)
: Result_detail(init)
{}
DbDoc get_doc()
{
if (!iterator_next())
return DbDoc();
return iterator_get();
}
uint64_t count();
DocList get_docs()
{
return *this;
}
friend Impl;
friend iterator;
};
} // internal namespace
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,114 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_DETAIL_ROW_H
#define MYSQLX_DETAIL_ROW_H
/**
@file
Details for Row class.
*/
#include "../common.h"
#include "../document.h"
#include <memory>
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
class Columns;
namespace internal {
template <class COLS> class Row_result_detail;
struct Table_insert_detail;
class PUBLIC_API Row_detail
{
protected:
class INTERNAL Impl;
DLL_WARNINGS_PUSH
std::shared_ptr<Impl> m_impl;
DLL_WARNINGS_POP
Row_detail() = default;
Row_detail(std::shared_ptr<Impl> &&impl)
{
m_impl = std::move(impl);
}
col_count_t col_count() const;
bytes get_bytes(col_count_t) const;
Value& get_val(col_count_t);
void clear()
{
m_impl.reset();
}
Impl& get_impl();
const Impl& get_impl() const
{
return const_cast<Row_detail*>(this)->get_impl();
}
void ensure_impl();
using Args_prc = Args_processor<Row_detail, std::pair<Impl*, col_count_t>*>;
template<typename... Types>
void set_values(col_count_t pos, Types... args)
{
ensure_impl();
assert(m_impl);
std::pair<Impl*, col_count_t> data{ m_impl.get(), pos };
Args_prc::process_args(&data, args...);
}
static void process_one(std::pair<Impl*, col_count_t>*, const Value &val);
friend Table_insert_detail;
friend Row_result_detail<Columns>;
friend Args_prc;
};
} // internal namespace
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,426 +0,0 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_DETAIL_SESSION_H
#define MYSQLX_DETAIL_SESSION_H
#include "../common.h"
#include "../crud.h"
#include <set>
namespace cdk {
class Session;
}
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
class Value;
class Session;
class Schema;
class Table;
class Collection;
class CollectionOptions;
namespace common {
class Session_impl;
class Session_pool;
using Shared_session_pool = std::shared_ptr<Session_pool>;
class Result_init;
class Result_impl;
}
namespace internal {
class Schema_detail;
using Client_impl = common::Session_pool;
using Shared_client_impl = std::shared_ptr<Client_impl>;
using Session_impl = common::Session_impl;
using Shared_session_impl = std::shared_ptr<common::Session_impl>;
/*
Base class for database objects. Can't be used alone.
*/
class PUBLIC_API Db_obj_base
{
protected:
DLL_WARNINGS_PUSH
Shared_session_impl m_sess;
string m_name;
DLL_WARNINGS_POP
Db_obj_base(const Shared_session_impl& sess, const string& name)
: m_sess(sess), m_name(name)
{}
virtual ~Db_obj_base()
{}
};
class PUBLIC_API Collection_detail
: public Db_obj_base
{
protected:
Collection_detail(const Shared_session_impl &sess, const string &name)
: Db_obj_base(sess, name)
{}
virtual Schema_detail& get_schema() = 0;
Result add_or_replace_one(const string &id, Value&&, bool);
void index_drop(const string &name);
void index_create(const string &name, Value &&spec);
};
// ---------------------------------------------------------------------------
/*
Base class for classes to be used by common::List_source<> which get item
from query results.
It assumes that the first column in the results contains string
data. An instance of this class iterates over the string data in the
result until all rows are consumed.
Derived class must send the query to the server and set m_res member to point
at the result of this query.
*/
struct PUBLIC_API Query_src
{
using Value = string;
using Res_impl = common::Result_impl;
Res_impl *m_res = nullptr;
const void *m_row = nullptr;
public:
Query_src()
{}
Query_src(Query_src &&other)
: m_res(other.m_res)
{
// Note: only one instance of Query_src owns m_res.
other.m_res = nullptr;
}
Query_src(const Query_src&) = delete;
virtual ~Query_src();
virtual void iterator_start()
{
assert(m_res);
}
bool iterator_next();
string iterator_get();
};
// ---------------------------------------------------------------------------
class PUBLIC_API Schema_detail
: public Db_obj_base
{
protected:
enum Obj_type { COLLECTION, TABLE };
/*
Sources for lists of schema objects and their names.
When constructing a source, a SQL style patter on object names is
given as ctor parameter -- only object matching the pattern are listed.
Name_src accepts a parameter which tells whether names of tables or
collections should be listed.
*/
struct PUBLIC_API Name_src
: public Query_src
{
const Schema &m_schema;
Name_src(const Schema&, Obj_type, const string &pattern);
};
struct PUBLIC_API Collection_src
: Name_src
{
using Value = Collection;
Collection_src(const Schema &sch, const string &pattern)
: Name_src(sch, COLLECTION, pattern)
{}
using Name_src::iterator_start;
using Name_src::iterator_next;
Collection iterator_get();
};
struct PUBLIC_API Table_src
: Name_src
{
using Value = Table;
Table_src(const Schema &sch, const string &pattern)
: Name_src(sch, TABLE, pattern)
{}
using Name_src::iterator_start;
using Name_src::iterator_next;
Table iterator_get();
};
Schema_detail(const Shared_session_impl &sess, const string &name)
: Db_obj_base(sess, name)
{}
public:
using CollectionList = List_initializer<List_source<Collection_src>>;
using TableList = List_initializer<List_source<Table_src>>;
using StringList = List_initializer<List_source<Name_src>>;
protected:
void create_collection(const mysqlx::string &name,
CollectionOptions options);
void modify_collection(const mysqlx::string &name,
CollectionOptions options);
void drop_collection(const string &name);
friend Collection_detail;
struct Access;
friend Access;
};
/*
Class representing an SQL statement that can be executed on the server.
*/
struct SQL_statement;
using SQL_statement_cmd = Executable<SqlResult, SQL_statement>;
struct SQL_statement
: public Bind_placeholders< SQL_statement_cmd >
{
SQL_statement(Session *sess, const string &query)
{
assert(sess);
try {
reset(internal::Crud_factory::mk_sql(*sess, query));
}
CATCH_AND_WRAP
}
SQL_statement(SQL_statement_cmd &other)
{
SQL_statement_cmd::operator=(other);
}
SQL_statement(SQL_statement_cmd &&other)
{
SQL_statement_cmd::operator=(std::move(other));
}
};
struct Session_detail;
struct PUBLIC_API Client_detail
{
// Disable copy semantics for client class.
Client_detail(const Client_detail&) = delete;
Client_detail& operator=(const Client_detail&) = delete;
Client_detail(common::Settings_impl &settings);
//Client_detail(common::Settings_impl &&settings);
void close();
protected:
Client_detail(Client_detail && other)
{
m_impl = other.m_impl;
other.m_impl.reset();
}
common::Shared_session_pool& get_session_pool();
struct INTERNAL Impl;
DLL_WARNINGS_PUSH
Shared_client_impl m_impl = NULL;
DLL_WARNINGS_POP
friend Session;
};
struct PUBLIC_API Session_detail
{
// Disable copy semantics for session class.
Session_detail(const Session_detail&) = delete;
Session_detail& operator=(const Session_detail&) = delete;
/*
Sources for lists of schemata and schema names. Only schemata matching
the given SQL-style pattern are listed.
*/
struct PUBLIC_API Name_src
: public Query_src
{
const Session &m_sess;
Name_src(const Session&, const string &pattern);
};
struct PUBLIC_API Schema_src
: Name_src
{
using Value = Schema;
Schema_src(Session &sess, const string &pattern)
: Name_src(sess, pattern)
{}
Schema_src(Session &sess)
: Schema_src(sess, "%")
{}
using Name_src::iterator_start;
using Name_src::iterator_next;
Schema iterator_get();
};
public:
using SchemaList = List_initializer<List_source<Schema_src>>;
protected:
Session_detail(Session_detail && other)
{
m_impl = other.m_impl;
other.m_impl.reset();
}
struct INTERNAL Impl;
/*
Note: Session implementation is shared with result objects because it
must exists as long as result implementation exists. This means that
even when session object is deleted, its implementation can still hang
around.
*/
DLL_WARNINGS_PUSH
Shared_session_impl m_impl = NULL;
DLL_WARNINGS_POP
Session_detail(common::Settings_impl&);
Session_detail(common::Shared_session_pool&);
virtual ~Session_detail()
{
try {
if (m_impl)
close();
}
catch (...) {}
}
void create_schema(const string &name, bool reuse);
void drop_schema(const string &name);
string get_default_schema_name();
void start_transaction();
void commit();
void rollback(const string &sp = string());
string savepoint_set(const string &sp = string());
void savepoint_remove(const string&);
common::Session_impl& get_impl()
{
if (!m_impl)
THROW("Invalid session");
return *m_impl;
}
INTERNAL cdk::Session& get_cdk_session();
void close();
/*
Do necessary cleanups before sending new command to the server.
*/
void prepare_for_cmd();
public:
/// @cond IGNORED
friend Result_detail::Impl;
friend internal::Crud_factory;
/// @endcond
};
} // internal namespace
MYSQLX_ABI_END(2,0)
} // mysqlx namespace
#endif

View File

@@ -1,276 +0,0 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_DETAIL_SETTINGS_H
#define MYSQLX_DETAIL_SETTINGS_H
#include "../common.h"
#include "../document.h"
#include <chrono>
#include <list>
#include <chrono>
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
namespace internal {
/*
Note: Options and SSLMode enumerations are given by Traits template parameter
to allow defining (and documenting) them in the main settings.h header.
*/
template <typename Traits>
class Settings_detail
: public common::Settings_impl
{
using Value = mysqlx::Value;
using Option = typename Traits::Options;
using COption = typename Traits::COptions;
using SSLMode = typename Traits::SSLMode;
using AuthMethod = typename Traits::AuthMethod;
using CompressionMode = typename Traits::CompressionMode;
public:
template <bool session_only, typename OPT, typename... Ty>
void set(OPT opt, Ty&&... rest)
{
do_set(get_options<session_only>(opt, std::forward<Ty>(rest)...));
}
protected:
/*
Declare options that require specific type of value (mostly enumerations).
For such options we do not accept setting them to arbitrary values. Instead
an overload of opt_val() with appropriate type will be used to set value
of the option.
*/
#define OPT_VAL_TYPE(X) \
X(SSL_MODE,SSLMode) \
X(AUTH,AuthMethod)
#define CHECK_OPT(Opt,Type) \
if (opt == Session_option_impl::Opt) \
throw Error(#Opt "setting requires value of type " #Type);
/*
Store option value in Value object (with basic run-time type checks)
TODO: More precise type checking using per-option types.
*/
static Value opt_val(int opt, Value &&val)
{
OPT_VAL_TYPE(CHECK_OPT)
return std::move(val);
}
/*
For types which are not convertible to Value, but can be converted to string
go through string conversion.
*/
static Value opt_val(int opt, std::nullptr_t)
{
return opt_val(opt, Value());
}
template <
typename V,
typename std::enable_if<std::is_convertible<V, string>::value>::type*
= nullptr
>
static Value opt_val(int opt, V &&val)
{
return opt_val(opt, Value(string(val)));
}
static Value opt_val(int opt, SSLMode m)
{
if (opt != Session_option_impl::SSL_MODE)
throw Error(
"SessionSettings::SSLMode value can only be used on SSL_MODE setting."
);
return unsigned(m);
}
static Value opt_val(int opt, AuthMethod m)
{
if (opt != Session_option_impl::AUTH)
throw Error(
"SessionSettings::AuthMethod value can only be used on AUTH setting."
);
return unsigned(m);
}
static Value opt_val(int opt, CompressionMode m)
{
if (opt != Session_option_impl::COMPRESSION)
throw Error(
"SessionSettings::CompressionMode value can only be used on COMPRESSION setting."
);
return unsigned(m);
}
// Note: is_range<C> is true for string types, which should not be treated
// as arrays of characters, but as single Values.
template <
typename C,
typename std::enable_if<is_range<C>::value>::type* = nullptr,
typename std::enable_if<!std::is_convertible<C,Value>::value>::type*
= nullptr
>
static Value opt_val(int , const C &container)
{
return Value(std::begin(container), std::end(container));
}
template<typename _Rep, typename _Period>
static Value opt_val(
int opt, const std::chrono::duration<_Rep, _Period> &duration
)
{
if (opt != Session_option_impl::CONNECT_TIMEOUT &&
opt != Client_option_impl::POOL_QUEUE_TIMEOUT &&
opt != Client_option_impl::POOL_MAX_IDLE_TIME)
{
std::stringstream err_msg;
err_msg << "Option " << option_name(opt) << " does not accept time value";
throw_error(err_msg.str().c_str());
}
return Value(std::chrono::duration_cast<std::chrono::milliseconds>(duration)
.count());
}
// Handle values that are directly convertible to Value.
template <
typename V,
typename std::enable_if<std::is_convertible<V,int>::value>::type*
= nullptr,
typename std::enable_if<std::is_convertible<V,Value>::value>::type*
= nullptr
>
static Value opt_val(int opt, V &&val)
{
return opt_val(opt, Value(val));
}
using session_opt_val_t = std::pair<int, Value>;
using session_opt_list_t = std::list<session_opt_val_t>;
/*
Set list of options with consistency checks.
This operation is atomic - settings are changed only if all options could
be set without error, otherwise settings remain unchanged.
*/
void do_set(session_opt_list_t&&);
// Note: for ABI compatibility
void PUBLIC_API do_set(std::list<std::pair<int, common::Value>>&&);
/*
Templates that collect varargs list of options into opt_list_t list
that can be passed to do_set().
*/
template<bool session_only>
static session_opt_list_t get_options()
{
return {};
}
/*
Note: if we ever support options without values, another overload is
needed: get_options(Option opt, Option opt1, R&... rest).
*/
template <
bool session_only, typename V, typename... Ty,
typename std::enable_if<session_only, int>::type* = nullptr
>
static session_opt_list_t get_options(Option opt, V&& val, Ty&&... rest)
{
int oo(static_cast<int>(opt));
session_opt_list_t opts = get_options<session_only>(std::forward<Ty>(rest)...);
opts.emplace_front(oo,
Settings_detail::opt_val(oo, std::forward<V>(val))
);
return opts;
}
template <
bool session_only, typename V, typename... Ty,
typename std::enable_if<!session_only, int>::type* = nullptr
>
static session_opt_list_t get_options(COption opt, V&& val, Ty&&... rest)
{
int oo(static_cast<int>(opt));
session_opt_list_t opts = get_options<session_only>(std::forward<Ty>(rest)...);
opts.emplace_front(
oo,
Settings_detail::opt_val(oo, std::forward<V>(val))
);
return opts;
}
/*
Note: Methods below rely on the fact that DevAPI SessionOption constants
have the same numeric values as common::Settings_impl::Option ones.
*/
bool has_option(COption opt) const
{
return Settings_impl::has_option(opt);
}
Value get(COption opt)
{
return Settings_impl::get(opt);
}
};
} // internal namespace
MYSQLX_ABI_END(2,0)
} // mysqlx namespace
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,153 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_ERROR_H
#define MYSQLX_ERROR_H
/**
@file
Classes used to access query and command execution results.
*/
#include "common.h"
#include "detail/error.h"
#include <memory>
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
/**
An error, warning or other diagnostic information reported by server
when executing queries or statements. The information can be printed to
output stream using `<<` operator.
@note Normally, errors reported by server are not represented by `Warning`
instances but instead they are thrown as instances of `mysqlx::Error`.
@ingroup devapi
*/
class Warning
: public virtual common::Printable
, internal::Warning_detail
{
public:
/// Type of diagnostic information.
enum Level {
LEVEL_ERROR, ///< %Error
LEVEL_WARNING, ///< %Warning
LEVEL_INFO ///< Other information
};
private:
Warning(Level level, uint16_t code, const string &msg)
: Warning_detail(byte(level), code, msg)
{
}
Warning(Warning_detail &&init)
: Warning_detail(std::move(init))
{}
void print(std::ostream &out) const
{
try {
Warning_detail::print(out);
}
CATCH_AND_WRAP
}
public:
/**
Return level of the diagnostic info stored in this object.
*/
Level getLevel() const
{
return Level(m_level);
}
/**
Return error/warning code reported by server.
*/
uint16_t getCode() const
{
return m_code;
}
/**
Return diagnostic message reported by server.
*/
const string& getMessage() const
{
return m_msg;
}
///@cond IGNORE
friend internal::Result_detail;
///@endcond
struct Access;
friend Access;
};
inline
void internal::Warning_detail::print(std::ostream &out) const
{
switch (Warning::Level(m_level))
{
case Warning::LEVEL_ERROR: out << "Error"; break;
case Warning::LEVEL_WARNING: out << "Warning"; break;
case Warning::LEVEL_INFO: out << "Info"; break;
default: out << "<Unknown>"; break;
}
if (m_code)
out << " " << m_code;
out << ": " << m_msg;
}
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,171 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_EXECUTABLE_H
#define MYSQLX_EXECUTABLE_H
/**
@file
Class representing executable statements.
*/
#include "common.h"
#include "result.h"
#include "../common/op_if.h"
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
using std::ostream;
/**
Represents an operation that can be executed.
Creating an operation does not involve any communication with the server.
Only when `execute()` method is called operation is sent to the server
for execution.
The template parameter `Res` is the type of result that
is returned by `execute()` method.
A derived class must create an implementation object for the operation and
set it using reset() method. Such implementation object should implement
common::Executable_if interface.
*/
template <class Res, class Op>
class Executable
{
private:
using Impl = common::Executable_if;
std::unique_ptr<Impl> m_impl;
protected:
Executable() = default;
void reset(Impl *impl)
{
m_impl.reset(impl);
}
/*
Copy semantics implementation: the current state of the other executable
object (of its implementation, to be precise) is copied to this new
instance. After that the two executables are independent objects describing
the same operation.
*/
void reset(const Executable &other)
{
if (m_impl.get() != other.m_impl.get()) m_impl.reset(other.m_impl->clone());
}
void reset(const Executable &&other)
{
m_impl.reset(other.m_impl->clone());
}
void check_if_valid() const
{
if (!m_impl)
throw Error("Attempt to use invalid operation");
}
Impl* get_impl()
{
check_if_valid();
return m_impl.get();
}
public:
Executable(const Executable &other)
{
operator=(other);
}
Executable(Executable &&other)
{
operator=(std::move(other));
}
virtual ~Executable() {}
Executable& operator=(const Executable &other)
{
try {
reset(other);
return *this;
}
CATCH_AND_WRAP
}
Executable& operator=(Executable &&other)
{
try {
reset(std::move(other));
return *this;
}
CATCH_AND_WRAP
}
/// Execute given operation and return its result.
virtual Res execute()
{
try {
check_if_valid();
/*
Note: The implementation object's execute() methods returns a reference
to a common::Result_init object which provides information about
the session and pending server reply. The returned Res instance should
be constructible from such Result_init reference.
*/
return m_impl->execute();
}
CATCH_AND_WRAP
}
struct Access;
friend Access;
};
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,84 +0,0 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
Lists of character sets known to CDK string codec (see codec.h).
Note: Keep this file in sync with <mysql/cdk/charsets.h>
*/
#ifndef MYSQLX_MYSQL_CHARSETS_H
#define MYSQLX_MYSQL_CHARSETS_H
#define CDK_CS_LIST(X) \
X(big5) \
X(dec8) \
X(cp850) \
X(hp8) \
X(koi8r) \
X(latin1) \
X(latin2) \
X(swe7) \
X(ascii) \
X(ujis) \
X(sjis) \
X(hebrew) \
X(tis620) \
X(euckr) \
X(koi8u) \
X(gb2312) \
X(greek) \
X(cp1250) \
X(gbk) \
X(latin5) \
X(armscii8) \
X(utf8mb3) \
X(ucs2) \
X(cp866) \
X(keybcs2) \
X(macce) \
X(macroman) \
X(cp852) \
X(latin7) \
X(utf8mb4) \
X(cp1251) \
X(utf16) \
X(utf16le) \
X(cp1256) \
X(cp1257) \
X(utf32) \
X(binary) \
X(geostd8) \
X(cp932) \
X(eucjpms) \
X(gb18030) \
#endif

View File

@@ -1,427 +0,0 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
Lists of collations used by MySQL Server and its protocols. These lists
define mapping from MySQL collation ID to charset ID.
Note: Keep this file in sync with <mysql/cdk/protocol/mysqlx/collations.h>
*/
#ifndef MYSQLX_MYSQL_COLLATIONS_H
#define MYSQLX_MYSQL_COLLATIONS_H
/*
Each line X(CS, ID, COLL, SENSITIVITY) in the expansion of
a COLLATION_XXX() macro declares collation with name COLL for character set
CS. ID is the MySQL id number for the collation. SENSITIVITY is either 'bin'
for binary collations or a combination of sensitivity flags such as 'ai_ci',
using the same conventions as the ones used in MySQL collation names.
Note: CS, COLL and SENSITIVITY are used to reconstruct the full MySQL name of
the collation and should follow the same naming conventions (with few
exceptions that we handle separately)
*/
#define COLLATIONS_big5(X) \
X(big5,1,chinese,ci) \
X(big5,84,bin,bin) \
#define COLLATIONS_dec8(X) \
X(dec8,3,swedish,ci) \
X(dec8,69,bin,bin) \
#define COLLATIONS_cp850(X) \
X(cp850,4,general,ci) \
X(cp850,80,bin,bin) \
#define COLLATIONS_hp8(X) \
X(hp8,6,english,ci) \
X(hp8,72,bin,bin) \
#define COLLATIONS_koi8r(X) \
X(koi8r,7,general,ci) \
X(koi8r,74,bin,bin) \
#define COLLATIONS_latin1(X) \
X(latin1,5,german1,ci) \
X(latin1,8,swedish,ci) \
X(latin1,15,danish,ci) \
X(latin1,31,german2,ci) \
X(latin1,47,bin,bin) \
X(latin1,48,general,ci) \
X(latin1,49,general,cs) \
X(latin1,94,spanish,ci) \
#define COLLATIONS_latin2(X) \
X(latin2,2,czech,cs) \
X(latin2,9,general,ci) \
X(latin2,21,hungarian,ci) \
X(latin2,27,croatian,ci) \
X(latin2,77,bin,bin) \
#define COLLATIONS_swe7(X) \
X(swe7,10,swedish,ci) \
X(swe7,82,bin,bin) \
#define COLLATIONS_ascii(X) \
X(ascii,11,general,ci) \
X(ascii,65,bin,bin) \
#define COLLATIONS_ujis(X) \
X(ujis,12,japanese,ci) \
X(ujis,91,bin,bin) \
#define COLLATIONS_sjis(X) \
X(sjis,13,japanese,ci) \
X(sjis,88,bin,bin) \
#define COLLATIONS_hebrew(X) \
X(hebrew,16,general,ci) \
X(hebrew,71,bin,bin) \
#define COLLATIONS_tis620(X) \
X(tis620,18,thai,ci) \
X(tis620,89,bin,bin) \
#define COLLATIONS_euckr(X) \
X(euckr,19,korean,ci) \
X(euckr,85,bin,bin) \
#define COLLATIONS_koi8u(X) \
X(koi8u,22,general,ci) \
X(koi8u,75,bin,bin) \
#define COLLATIONS_gb2312(X) \
X(gb2312,24,chinese,ci) \
X(gb2312,86,bin,bin) \
#define COLLATIONS_greek(X) \
X(greek,25,general,ci) \
X(greek,70,bin,bin) \
#define COLLATIONS_cp1250(X) \
X(cp1250,26,general,ci) \
X(cp1250,34,czech,cs) \
X(cp1250,44,croatian,ci) \
X(cp1250,66,bin,bin) \
X(cp1250,99,polish,ci) \
#define COLLATIONS_gbk(X) \
X(gbk,28,chinese,ci) \
X(gbk,87,bin,bin) \
#define COLLATIONS_latin5(X) \
X(latin5,30,turkish,ci) \
X(latin5,78,bin,bin) \
#define COLLATIONS_armscii8(X) \
X(armscii8,32,general,ci) \
X(armscii8,64,bin,bin) \
#define COLLATIONS_utf8mb3(X) \
X(utf8mb3,33,general,ci) \
X(utf8mb3,76,tolower,ci) \
X(utf8mb3,83,bin,bin) \
X(utf8mb3,192,unicode,ci) \
X(utf8mb3,193,icelandic,ci) \
X(utf8mb3,194,latvian,ci) \
X(utf8mb3,195,romanian,ci) \
X(utf8mb3,196,slovenian,ci) \
X(utf8mb3,197,polish,ci) \
X(utf8mb3,198,estonian,ci) \
X(utf8mb3,199,spanish,ci) \
X(utf8mb3,200,swedish,ci) \
X(utf8mb3,201,turkish,ci) \
X(utf8mb3,202,czech,ci) \
X(utf8mb3,203,danish,ci) \
X(utf8mb3,204,lithuanian,ci) \
X(utf8mb3,205,slovak,ci) \
X(utf8mb3,206,spanish2,ci) \
X(utf8mb3,207,roman,ci) \
X(utf8mb3,208,persian,ci) \
X(utf8mb3,209,esperanto,ci) \
X(utf8mb3,210,hungarian,ci) \
X(utf8mb3,211,sinhala,ci) \
X(utf8mb3,212,german2,ci) \
X(utf8mb3,213,croatian,ci) \
X(utf8mb3,214,unicode_520,ci) \
X(utf8mb3,215,vietnamese,ci) \
X(utf8mb3,223,general_mysql500,ci) \
#define COLLATIONS_ucs2(X) \
X(ucs2,35,general,ci) \
X(ucs2,90,bin,bin) \
X(ucs2,128,unicode,ci) \
X(ucs2,129,icelandic,ci) \
X(ucs2,130,latvian,ci) \
X(ucs2,131,romanian,ci) \
X(ucs2,132,slovenian,ci) \
X(ucs2,133,polish,ci) \
X(ucs2,134,estonian,ci) \
X(ucs2,135,spanish,ci) \
X(ucs2,136,swedish,ci) \
X(ucs2,137,turkish,ci) \
X(ucs2,138,czech,ci) \
X(ucs2,139,danish,ci) \
X(ucs2,140,lithuanian,ci) \
X(ucs2,141,slovak,ci) \
X(ucs2,142,spanish2,ci) \
X(ucs2,143,roman,ci) \
X(ucs2,144,persian,ci) \
X(ucs2,145,esperanto,ci) \
X(ucs2,146,hungarian,ci) \
X(ucs2,147,sinhala,ci) \
X(ucs2,148,german2,ci) \
X(ucs2,149,croatian,ci) \
X(ucs2,150,unicode_520,ci) \
X(ucs2,151,vietnamese,ci) \
X(ucs2,159,general_mysql500,ci) \
#define COLLATIONS_cp866(X) \
X(cp866,36,general,ci) \
X(cp866,68,bin,bin) \
#define COLLATIONS_keybcs2(X) \
X(keybcs2,37,general,ci) \
X(keybcs2,73,bin,bin) \
#define COLLATIONS_macce(X) \
X(macce,38,general,ci) \
X(macce,43,bin,bin) \
#define COLLATIONS_macroman(X) \
X(macroman,39,general,ci) \
X(macroman,53,bin,bin) \
#define COLLATIONS_cp852(X) \
X(cp852,40,general,ci) \
X(cp852,81,bin,bin) \
#define COLLATIONS_latin7(X) \
X(latin7,20,estonian,cs) \
X(latin7,41,general,ci) \
X(latin7,42,general,cs) \
X(latin7,79,bin,bin) \
#define COLLATIONS_utf8mb4(X) \
X(utf8mb4,255,uca0900,ai_ci) \
X(utf8mb4,278,uca0900,as_cs) \
X(utf8mb4,46,bin,bin) \
X(utf8mb4,245,croatian,ci) \
X(utf8mb4,266,cs_0900,ai_ci) \
X(utf8mb4,289,cs_0900,as_cs) \
X(utf8mb4,234,czech,ci) \
X(utf8mb4,235,danish,ci) \
X(utf8mb4,267,da_0900,ai_ci) \
X(utf8mb4,290,da_0900,as_cs) \
X(utf8mb4,256,de_pb_0900,ai_ci) \
X(utf8mb4,279,de_pb_0900,as_cs) \
X(utf8mb4,273,eo_0900,ai_ci) \
X(utf8mb4,296,eo_0900,as_cs) \
X(utf8mb4,241,esperanto,ci) \
X(utf8mb4,230,estonian,ci) \
X(utf8mb4,263,es_0900,ai_ci) \
X(utf8mb4,286,es_0900,as_cs) \
X(utf8mb4,270,es_trad_0900,ai_ci) \
X(utf8mb4,293,es_trad_0900,as_cs) \
X(utf8mb4,262,et_0900,ai_ci) \
X(utf8mb4,285,et_0900,as_cs) \
X(utf8mb4,45,general,ci) \
X(utf8mb4,244,german2,ci) \
X(utf8mb4,275,hr_0900,ai_ci) \
X(utf8mb4,298,hr_0900,as_cs) \
X(utf8mb4,242,hungarian,ci) \
X(utf8mb4,274,hu_0900,ai_ci) \
X(utf8mb4,297,hu_0900,as_cs) \
X(utf8mb4,225,icelandic,ci) \
X(utf8mb4,257,is_0900,ai_ci) \
X(utf8mb4,280,is_0900,as_cs) \
X(utf8mb4,303,ja_0900,as_cs) \
X(utf8mb4,226,latvian,ci) \
X(utf8mb4,271,la_0900,ai_ci) \
X(utf8mb4,294,la_0900,as_cs) \
X(utf8mb4,236,lithuanian,ci) \
X(utf8mb4,268,lt_0900,ai_ci) \
X(utf8mb4,291,lt_0900,as_cs) \
X(utf8mb4,258,lv_0900,ai_ci) \
X(utf8mb4,281,lv_0900,as_cs) \
X(utf8mb4,240,persian,ci) \
X(utf8mb4,261,pl_0900,ai_ci) \
X(utf8mb4,284,pl_0900,as_cs) \
X(utf8mb4,229,polish,ci) \
X(utf8mb4,227,romanian,ci) \
X(utf8mb4,239,roman,ci) \
X(utf8mb4,259,ro_0900,ai_ci) \
X(utf8mb4,282,ro_0900,as_cs) \
X(utf8mb4,243,sinhala,ci) \
X(utf8mb4,269,sk_0900,ai_ci) \
X(utf8mb4,292,sk_0900,as_cs) \
X(utf8mb4,237,slovak,ci) \
X(utf8mb4,228,slovenian,ci) \
X(utf8mb4,260,sl_0900,ai_ci) \
X(utf8mb4,283,sl_0900,as_cs) \
X(utf8mb4,238,spanish2,ci) \
X(utf8mb4,231,spanish,ci) \
X(utf8mb4,264,sv_0900,ai_ci) \
X(utf8mb4,287,sv_0900,as_cs) \
X(utf8mb4,232,swedish,ci) \
X(utf8mb4,265,tr_0900,ai_ci) \
X(utf8mb4,288,tr_0900,as_cs) \
X(utf8mb4,233,turkish,ci) \
X(utf8mb4,246,unicode_520,ci) \
X(utf8mb4,224,unicode,ci) \
X(utf8mb4,247,vietnamese,ci) \
X(utf8mb4,277,vi_0900,ai_ci) \
X(utf8mb4,300,vi_0900,as_cs) \
X(utf8mb4,304,ja_0900,as_cs_ks) \
X(utf8mb4,305,uca0900,as_ci) \
X(utf8mb4,306,ru_0900,ai_ci) \
X(utf8mb4,307,ru_0900,as_cs) \
X(utf8mb4,308,zh_0900,as_cs) \
X(utf8mb4,309,uca0900,bin) \
X(utf8mb4,310,nb_0900,ai_ci) \
X(utf8mb4,311,nb_0900,as_cs) \
X(utf8mb4,312,nn_0900,ai_ci) \
X(utf8mb4,313,nn_0900,as_cs) \
X(utf8mb4,314,sr_latn_0900,ai_ci) \
X(utf8mb4,315,sr_latn_0900,as_cs) \
X(utf8mb4,316,bs_0900,ai_ci) \
X(utf8mb4,317,bs_0900,as_cs) \
X(utf8mb4,318,bg_0900,ai_ci) \
X(utf8mb4,319,bg_0900,as_cs) \
X(utf8mb4,320,gl_0900,ai_ci) \
X(utf8mb4,321,gl_0900,as_cs) \
X(utf8mb4,322,mn_cyrl_0900,ai_ci) \
X(utf8mb4,323,mn_cyrl_0900,as_cs) \
COLLATIONS_utf8mb4_EXTRA
#define COLLATIONS_utf8mb4_EXTRA
#define COLLATIONS_cp1251(X) \
X(cp1251,14,bulgarian,ci) \
X(cp1251,23,ukrainian,ci) \
X(cp1251,50,bin,bin) \
X(cp1251,51,general,ci) \
X(cp1251,52,general,cs) \
#define COLLATIONS_utf16(X) \
X(utf16,54,general,ci) \
X(utf16,55,bin,bin) \
X(utf16,101,unicode,ci) \
X(utf16,102,icelandic,ci) \
X(utf16,103,latvian,ci) \
X(utf16,104,romanian,ci) \
X(utf16,105,slovenian,ci) \
X(utf16,106,polish,ci) \
X(utf16,107,estonian,ci) \
X(utf16,108,spanish,ci) \
X(utf16,109,swedish,ci) \
X(utf16,110,turkish,ci) \
X(utf16,111,czech,ci) \
X(utf16,112,danish,ci) \
X(utf16,113,lithuanian,ci) \
X(utf16,114,slovak,ci) \
X(utf16,115,spanish2,ci) \
X(utf16,116,roman,ci) \
X(utf16,117,persian,ci) \
X(utf16,118,esperanto,ci) \
X(utf16,119,hungarian,ci) \
X(utf16,120,sinhala,ci) \
X(utf16,121,german2,ci) \
X(utf16,122,croatian,ci) \
X(utf16,123,unicode_520,ci) \
X(utf16,124,vietnamese,ci) \
#define COLLATIONS_utf16le(X) \
X(utf16le,56,general,ci) \
X(utf16le,62,bin,bin) \
#define COLLATIONS_cp1256(X) \
X(cp1256,57,general,ci) \
X(cp1256,67,bin,bin) \
#define COLLATIONS_cp1257(X) \
X(cp1257,29,lithuanian,ci) \
X(cp1257,58,bin,bin) \
X(cp1257,59,general,ci) \
#define COLLATIONS_utf32(X) \
X(utf32,60,general,ci) \
X(utf32,61,bin,bin) \
X(utf32,160,unicode,ci) \
X(utf32,161,icelandic,ci) \
X(utf32,162,latvian,ci) \
X(utf32,163,romanian,ci) \
X(utf32,164,slovenian,ci) \
X(utf32,165,polish,ci) \
X(utf32,166,estonian,ci) \
X(utf32,167,spanish,ci) \
X(utf32,168,swedish,ci) \
X(utf32,169,turkish,ci) \
X(utf32,170,czech,ci) \
X(utf32,171,danish,ci) \
X(utf32,172,lithuanian,ci) \
X(utf32,173,slovak,ci) \
X(utf32,174,spanish2,ci) \
X(utf32,175,roman,ci) \
X(utf32,176,persian,ci) \
X(utf32,177,esperanto,ci) \
X(utf32,178,hungarian,ci) \
X(utf32,179,sinhala,ci) \
X(utf32,180,german2,ci) \
X(utf32,181,croatian,ci) \
X(utf32,182,unicode_520,ci) \
X(utf32,183,vietnamese,ci) \
#define COLLATIONS_binary(X) \
X(binary,63,bin,bin) \
#define COLLATIONS_geostd8(X) \
X(geostd8,92,general,ci) \
X(geostd8,93,bin,bin) \
#define COLLATIONS_cp932(X) \
X(cp932,95,japanese,ci) \
X(cp932,96,bin,bin) \
#define COLLATIONS_eucjpms(X) \
X(eucjpms,97,japanese,ci) \
X(eucjpms,98,bin,bin) \
#define COLLATIONS_gb18030(X) \
X(gb18030,248,chinese,ci) \
X(gb18030,249,bin,bin) \
X(gb18030,250,unicode_520,ci) \
#endif

View File

@@ -1,908 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_RESULT_H
#define MYSQLX_RESULT_H
/**
@file
Classes used to access query and command execution results.
*/
#include "common.h"
#include "document.h"
#include "row.h"
#include "collations.h"
#include "detail/result.h"
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
using std::ostream;
class Session;
class Schema;
class Collection;
class Result;
class Row;
class RowResult;
class SqlResult;
class DbDoc;
class DocResult;
template <class Res, class Op> class Executable;
namespace internal {
/*
A wrapper which adds methods common for all result classes.
*/
template <class Base>
class Result_common
: protected Base
{
using WarningList = internal::Result_detail::WarningList;
public:
/// Get the number of warnings stored in the result.
unsigned getWarningsCount() const
{
try {
return Base::get_warning_count();
}
CATCH_AND_WRAP
}
/// Get a list of warnings stored in the result.
WarningList getWarnings()
{
try {
return Base::get_warnings();
}
CATCH_AND_WRAP
}
/// Get the warning at the given, 0-based position.
// TODO: Change arg type to size_t?
Warning getWarning(unsigned pos)
{
try {
return Base::get_warning(pos);
}
CATCH_AND_WRAP
}
// TODO: expose this in the API?
//using WarningsIterator = Result_detail::iterator;
/**
Get the count of affected items (rows or doucuments) from manipulation statements.
*/
uint64_t getAffectedItemsCount() const
{
try {
return Result_detail::get_affected_rows();
} CATCH_AND_WRAP
}
protected:
// Wrap base ctors/assginment with catch handlers
Result_common()
try
: Base()
{}
CATCH_AND_WRAP
Result_common(Result_common &&other)
try
: Base(std::move(other))
{}
CATCH_AND_WRAP
Result_common& operator=(Result_common &&other)
try
{
Base::operator=(std::move(other));
return *this;
}
CATCH_AND_WRAP
Result_common(common::Result_init &init)
try
: Base(init)
{}
CATCH_AND_WRAP
};
} // internal namespace
/**
Represents a result of an operation that does not return data.
A generic result which can be returned by operations which only
modify data.
A `Result` instance can store the result of executing an operation:
~~~~~~
Result res = operation.execute();
~~~~~~
Storing another result in a `Result` instance overwrites
the previous result.
@note A `Result` object should be used by at most one thread at a time. It is
not safe to call its methods by several threads simultaneously. It is
responsibility of the user to ensure this using a synchronization mechanism
such as mutexes.
@ingroup devapi_res
*/
class Result
: public internal::Result_common<internal::Result_detail>
{
public:
Result() = default;
/**
Get the auto-increment value if one was generated by a table insert
statement.
*/
uint64_t getAutoIncrementValue() const
{
try {
return Result_detail::get_auto_increment();
} CATCH_AND_WRAP
}
/**
Return a list of identifiers of multiple documents added to a collection,
generated by the server.
*/
DocIdList getGeneratedIds() const
{
try {
return Result_detail::get_generated_ids();
} CATCH_AND_WRAP
}
private:
Result(common::Result_init &init)
: Result_common(init)
{}
template <class Res, class Op>
friend class Executable;
friend Collection;
};
// Row based results
// -----------------
/**
Types that can be reported in result meta-data.
These correspond to MySQL server datatypes described [here]
(https://dev.mysql.com/doc/refman/8.0/en/data-types.html).
@ingroup devapi_res
*/
enum class Type : unsigned short
{
#undef TYPE_ENUM
#define TYPE_ENUM(X,N) X=N,
RESULT_TYPE_LIST(TYPE_ENUM)
};
/*
Note: Normally we would put these docs in the RESULT_TYPE_LIST macro
but it would pollute documentation of methods like typeName() below
that also use this macro.
*/
/// @var Type::BIT
/// See <https://dev.mysql.com/doc/refman/8.0/en/bit-type.html>
/// @var Type::TINYINT
/// See <https://dev.mysql.com/doc/refman/8.0/en/integer-types.html>
/// @var Type::SMALLINT
/// See <https://dev.mysql.com/doc/refman/8.0/en/integer-types.html>
/// @var Type::MEDIUMINT
/// See <https://dev.mysql.com/doc/refman/8.0/en/integer-types.html>
/// @var Type::INT
/// See <https://dev.mysql.com/doc/refman/8.0/en/integer-types.html>
/// @var Type::BIGINT
/// See <https://dev.mysql.com/doc/refman/8.0/en/integer-types.html>
/// @var Type::FLOAT
/// See <https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html>
/// @var Type::DECIMAL
/// See <https://dev.mysql.com/doc/refman/8.0/en/fixed-point-types.html>
/// @var Type::DOUBLE
/// See <https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html>
/// @var Type::JSON
/// See <https://dev.mysql.com/doc/refman/8.0/en/json.html>
/// @var Type::STRING
/// See <https://dev.mysql.com/doc/refman/8.0/en/string-types.html>
/// @var Type::BYTES
/// See <https://dev.mysql.com/doc/refman/8.0/en/string-types.html>
/// @var Type::TIME
/// See <https://dev.mysql.com/doc/refman/8.0/en/date-and-time-types.html>
/// @var Type::DATE
/// See <https://dev.mysql.com/doc/refman/8.0/en/date-and-time-types.html>
/// @var Type::DATETIME
/// See <https://dev.mysql.com/doc/refman/8.0/en/date-and-time-types.html>
/// @var Type::TIMESTAMP
/// See <https://dev.mysql.com/doc/refman/8.0/en/date-and-time-types.html>
/// @var Type::SET
/// See <https://dev.mysql.com/doc/refman/8.0/en/set.html>
/// @var Type::ENUM
/// See <https://dev.mysql.com/doc/refman/8.0/en/enum.html>
/// @var Type::GEOMETRY
/// See <https://dev.mysql.com/doc/refman/8.0/en/spatial-types.html>
/**
Return name of a given type.
@ingroup devapi_res
*/
inline
const char* typeName(Type t)
{
#define TYPE_NAME(T,X) case Type::T: return #T;
switch (t)
{
RESULT_TYPE_LIST(TYPE_NAME)
default:
THROW("Unknown type");
}
}
inline
std::ostream& operator<<(std::ostream &out, Type t)
{
return out << typeName(t);
}
/**
Provides meta-data for a single result column.
@ingroup devapi_res
*/
class Column
: public virtual common::Printable
, private internal::Column_detail
{
public:
string getSchemaName() const ///< TODO
{
try {
return Column_detail::get_schema_name();
}
CATCH_AND_WRAP
}
string getTableName() const ///< TODO
{
try {
return Column_detail::get_table_name();
}
CATCH_AND_WRAP
}
string getTableLabel() const ///< TODO
{
try {
return Column_detail::get_table_label();
}
CATCH_AND_WRAP
}
string getColumnName() const ///< TODO
{
try {
return Column_detail::get_name();
}
CATCH_AND_WRAP
}
string getColumnLabel() const ///< TODO
{
try {
return Column_detail::get_label();
}
CATCH_AND_WRAP
}
Type getType() const ///< TODO
{
try {
return Type(Column_detail::get_type());
}
CATCH_AND_WRAP
}
/**
Get column length
@return The maximum length of data in the column in bytes, as reported
by the server.
@note Because the column length is returned as byte length, it could be
confusing with the multi-byte character sets. For instance, with UTF8MB4
the length of VARCHAR(100) column is reported as 400 because each character
is 4 bytes long.
*/
unsigned long getLength() const
{
try {
return Column_detail::get_length();
}
CATCH_AND_WRAP
}
unsigned short getFractionalDigits() const ///< TODO
{
try {
return Column_detail::get_decimals();
}
CATCH_AND_WRAP
}
bool isNumberSigned() const ///< TODO
{
try {
return Column_detail::is_signed();
}
CATCH_AND_WRAP
}
CharacterSet getCharacterSet() const ///< TODO
{
try {
return Column_detail::get_charset();
}
CATCH_AND_WRAP
}
/// TODO
std::string getCharacterSetName() const
{
try {
return characterSetName(getCharacterSet());
}
CATCH_AND_WRAP
}
const CollationInfo& getCollation() const ///< TODO
{
try {
return Column_detail::get_collation();
}
CATCH_AND_WRAP
}
/// TODO
std::string getCollationName() const
{
try {
return getCollation().getName();
}
CATCH_AND_WRAP
}
/// TODO
bool isPadded() const
{
try {
return Column_detail::is_padded();
}
CATCH_AND_WRAP
}
protected:
using Column_detail::Impl;
Column(const Impl *impl)
try
: Column_detail(impl)
{}
CATCH_AND_WRAP
Column() = default;
Column(const Column&) = default;
Column(Column&&) = default;
Column& operator=(const Column&) = default;
void print(std::ostream &out) const
{
// TODO: not sure if this code will be called by operator<<.
try {
Column_detail::print(out);
}
CATCH_AND_WRAP
}
public:
friend RowResult;
struct INTERNAL Access;
friend Access;
};
/*
Extern declarations for Columns_detail<Column> template specialization
elements that are defined in result.cc.
Note: "extern template" works with MSVC but not with GCC.
*/
namespace internal {
template<> PUBLIC_API
void Columns_detail<Column>::init(const Result_detail::Impl&);
} // internal
extern template PUBLIC_API
void internal::Columns_detail<Column>::init(
const internal::Result_detail::Impl &impl
);
class Columns
: private internal::Columns_detail<Column>
{
public:
using Columns_detail::operator[];
using Columns_detail::iterator;
using Columns_detail::begin;
using Columns_detail::end;
private:
using Columns_detail::init;
// note: Required by Row_result_detail
Columns() = default;
Columns(Columns&&) = default;
Columns& operator=(Columns&&) = default;
///@cond IGNORE
friend internal::Row_result_detail<Columns>;
///@endcond
};
/*
Extern declarations for Row_result_detail<Columns> template specialization
elements that are defined in result.cc.
*/
namespace internal {
template<> PUBLIC_API
bool Row_result_detail<Columns>::iterator_next();
template<> PUBLIC_API
col_count_t Row_result_detail<Columns>::col_count() const;
template<> PUBLIC_API
Row_result_detail<Columns>::Row_result_detail(
common::Result_init &init
);
template<> PUBLIC_API
auto Row_result_detail<Columns>::get_column(col_count_t pos) const
-> const Column&;
template<> PUBLIC_API
auto internal::Row_result_detail<Columns>::get_columns() const
-> const Columns&;
template<> PUBLIC_API
row_count_t internal::Row_result_detail<Columns>::row_count();
} // internal
/**
%Result of an operation that returns rows.
A `RowResult` object gives sequential access to the rows contained in
the result. It is possible to get the rows one-by-one, or fetch and store
all of them at once. One can iterate over the rows using range loop:
`for (Row r : result) ...`.
@ingroup devapi_res
*/
class RowResult
: public internal::Result_common<internal::Row_result_detail<Columns>>
{
public:
using Columns = mysqlx::Columns;
RowResult() = default;
/// Return the number of fields in each row.
col_count_t getColumnCount() const
{
try {
return Row_result_detail::col_count();
}
CATCH_AND_WRAP
}
/// Return `Column` object describing the given column of the result.
const Column& getColumn(col_count_t pos) const
{
try {
return Row_result_detail::get_column(pos);
}
CATCH_AND_WRAP
}
/**
Return meta-data for all result columns.
TODO: explain ownership
*/
const Columns& getColumns() const
{
try {
return Row_result_detail::get_columns();
}
CATCH_AND_WRAP
}
/**
Return the current row and move to the next one in the sequence.
If there are no more rows in this result, returns a null `Row` instance.
*/
Row fetchOne()
{
try {
return Row_result_detail::get_row();
}
CATCH_AND_WRAP
}
/**
Return all remaining rows
%Result of this method can be stored in a container such as
`std::list<Row>`. Rows that have already been fetched using `fetchOne()` are
not included in the result of `fetchAll()`.
*/
RowList fetchAll()
{
try {
return Row_result_detail::get_rows();
}
CATCH_AND_WRAP
}
/**
Returns the number of rows contained in the result.
The method counts only the rows that were not yet fetched and are still
available in the result.
*/
row_count_t count()
{
try {
return Row_result_detail::row_count();
}
CATCH_AND_WRAP
}
/*
Iterate over rows (range-for support).
Rows that have been fetched using iterator are not available when
calling fetchOne() or fetchAll()
*/
iterator begin()
{
try {
return Row_result_detail::begin();
}
CATCH_AND_WRAP
}
iterator end() const
{
try {
return Row_result_detail::end();
}
CATCH_AND_WRAP
}
private:
RowResult(common::Result_init &init)
: Result_common(init)
{}
public:
template <class Res, class Op> friend class Executable;
friend SqlResult;
friend DocResult;
};
/**
%Result of an SQL query or command.
In general, an SQL query or command can return multiple results (for example,
a call to a stored procedure). Additionally, each or only some of these
results can contain row data. A `SqlResult` object gives a sequential access
to all results of a multi-result. Method `nextResult()` moves to the next
result in the sequence, if present. Methods of `RowResult` are used to access
row data of the current result (if it contains data).
@note A `SqlResult` object should be used by at most one thread at a time.
It is not safe to call its methods by several threads simultaneously. It is
responsibility of the user to ensure this using a synchronization mechanism
such as mutexes.
@ingroup devapi_res
*/
class SqlResult
: public RowResult
{
public:
SqlResult() = default;
/**
Tell if the current result contains row data.
If this is the case, rows can be accessed using `RowResult` interface.
Otherwise calling `RowResult` methods throws an error.
*/
bool hasData() const
{
try {
return Result_detail::has_data();
}
CATCH_AND_WRAP
}
/**
Move to the next result, if there is one.
Returns true if the next result is available, false if there are no more
results in the reply. Calling `nextResult()` discards the current result.
If it has any rows that has not yet been fetched, these rows are also
discarded.
*/
bool nextResult()
{
try {
return Row_result_detail::next_result();
}
CATCH_AND_WRAP
}
/**
Get the auto-increment value if one was generated by a table insert
statement.
*/
uint64_t getAutoIncrementValue()
{
try {
return Result_detail::get_auto_increment();
}
CATCH_AND_WRAP
}
private:
SqlResult(common::Result_init &init)
: RowResult(init)
{}
template <class Res, class Op>
friend class Executable;
};
// Document based results
// ----------------------
/**
%Result of an operation that returns documents.
A `DocResult` object gives sequential access to the documents contained in
the result. It is possible to get the documents one-by-one, or fetch and store
all of them at once. One can iterate over the documents using range loop:
`for (DbDoc d : result) ...`.
@note A `DocResult` object should be used by at most one thread at a time.
It is not safe to call its methods by several threads simultaneously. It is
responsibility of the user to ensure this using a synchronization mechanism
such as mutexes.
@ingroup devapi_res
*/
class DocResult
: public internal::Result_common<internal::Doc_result_detail>
{
public:
DocResult() = default;
/**
Return the current document and move to the next one in the sequence.
If there are no more documents in this result, returns a null document.
*/
DbDoc fetchOne()
{
try {
return Doc_result_detail::get_doc();
}
CATCH_AND_WRAP
}
/**
Return all remaining documents.
%Result of this method can be stored in a container such as
`std::list<DbDoc>`. Documents that have already been fetched using
`fetchOne()` are not included in the result of `fetchAll()`.
*/
DocList fetchAll()
{
try {
return Doc_result_detail::get_docs();
}
CATCH_AND_WRAP
}
/**
Returns the number of documents contained in the result.
The method counts only the documents that were not yet fetched and are still
available in the result.
*/
uint64_t count()
{
try {
return Doc_result_detail::count();
}
CATCH_AND_WRAP
}
/*
Iterate over documents (range-for support).
Documents that have been fetched using iterator are not available when
calling fetchOne() or fetchAll()
*/
using iterator = Doc_result_detail::iterator;
iterator begin()
{
try {
return Doc_result_detail::begin();
}
CATCH_AND_WRAP
}
iterator end() const
{
try {
return Doc_result_detail::end();
}
CATCH_AND_WRAP
}
private:
DocResult(common::Result_init &init)
: Result_common(init)
{}
friend DbDoc;
template <class Res, class Op>
friend class Executable;
};
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,244 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_ROW_H
#define MYSQLX_ROW_H
/**
@file
TODO
*/
#include "common.h"
#include "document.h"
#include "detail/row.h"
#include <memory>
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
/**
Represents a single row from a result that contains rows.
Such a row consists of a number of fields, each storing single
value. The number of fields and types of values stored in each
field are described by `RowResult` instance that produced this
row.
Values of fields can be accessed with `get()` method or using
`row[pos]` expression. Fields are identified by 0-based position.
It is also possible to get raw bytes representing value of a
given field with `getBytes()` method.
@sa `Value` class.
@todo Support for iterating over row fields with range-for loop.
@ingroup devapi_res
*/
class Row
: private internal::Row_detail
{
Row(internal::Row_detail &&other)
try
: Row_detail(std::move(other))
{}
CATCH_AND_WRAP
public:
Row() {}
template<typename T, typename... Types>
explicit Row(T val, Types... vals)
{
try {
Row_detail::set_values(0, val, vals...);
}
CATCH_AND_WRAP
}
col_count_t colCount() const
{
try {
return Row_detail::col_count();
}
CATCH_AND_WRAP
}
/**
Get raw bytes representing value of row field at position `pos`.
The raw bytes are as received from the server. In genral the value
is represented using x-protocol encoding that corresponds to the
type and other meta-data of the given column. This meta-data can
be accessed via `Column` object returned by `RowResult#getColumn()`
method.
The x-protocol represenation of different value types is documented
[here]
(https://dev.mysql.com/doc/dev/mysql-server/latest/structMysqlx_1_1Resultset_1_1ColumnMetaData.html).
Most types reported by `Column#getType()` method correspond to an x-protocol
value type of the same name.
All integer types use the x-protocol UINT or SINT encoding, which is
the protobuf variant encoding together with zig-zag encoding for the
signed case
(see <https://developers.google.com/protocol-buffers/docs/encoding>)
STRING values are encoded using the character set encoding as reported
by `Column#getCharacterSet()` method of the corresponding `Column` object
(usually `utf8mb4`).
JSON data is represented as a JSON string. ENUM values are represented
as strings with enum constant names. Values of type DATE and TIMESTAMP
use the same representation as DATETIME, with time part empty in case
of DATE values. GEOMETRY values use the internal geometry storage
format described
[here]
(https://dev.mysql.com/doc/refman/8.0/en/gis-data-formats.html).
Note that raw representation of BYTES and STRING values has an extra
0x00 byte added at the end, which is not part of the originial data.
It is used to distinguish null values from empty byte sequences.
@returns null bytes range if given field is NULL.
@throws out_of_range if given row was not fetched from server.
*/
bytes getBytes(col_count_t pos) const
{
try {
return Row_detail::get_bytes(pos);
}
CATCH_AND_WRAP
}
/**
Get reference to row field at position `pos`.
@throws out_of_range if given field does not exist in the row.
*/
Value& get(col_count_t pos)
{
try {
return Row_detail::get_val(pos);
}
CATCH_AND_WRAP
}
/**
Set value of row field at position `pos`.
Creates new field if it does not exist.
@returns Reference to the field that was set.
*/
Value& set(col_count_t pos, const Value &val)
{
try {
Row_detail::set_values(pos, val);
return Row_detail::get_val(pos);
}
CATCH_AND_WRAP
}
/**
Get const reference to row field at position `pos`.
This is const version of method `get()`.
@throws out_of_range if given field does not exist in the row.
*/
const Value& operator[](col_count_t pos) const
{
return const_cast<Row*>(this)->get(pos);
}
/**
Get modifiable reference to row field at position `pos`.
The field is created if it does not exist. In this case
the initial value of the field is NULL.
*/
Value& operator[](col_count_t pos)
{
ensure_impl();
try {
return get(pos);
}
catch (const out_of_range&)
{
return set(pos, Value());
}
}
/// Check if this row contains fields or is null.
bool isNull() const { return NULL == m_impl; }
operator bool() const { return !isNull(); }
void clear()
{
try {
Row_detail::clear();
}
CATCH_AND_WRAP
}
private:
using internal::Row_detail::m_impl;
/// @cond IGNORED
friend internal::Row_result_detail<Columns>;
friend internal::Table_insert_detail;
/// @endcond
};
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,516 +0,0 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_TABLE_CRUD_H
#define MYSQLX_TABLE_CRUD_H
/**
@file
Crud operations on tables.
Classes declared here represent CRUD operations on a table. They are
analogous to collection CRUD operation classes defined in collection_crud.h.
The following classes for table CRUD operations are defined:
- TableInsert
- TableRemove
- TableSelect
- TableUpdate
CRUD operation objects can be created directly, or assigned from
result of DevAPI methods that create such operations:
~~~~~~
TableInsert insert_op(table);
TableSelect select_op = table.select(...).orderBy(...);
~~~~~~
CRUD operation objects have methods which can modify the operation
before it gets executed. For example `TableInsert::values()`
appends a row to the list of rows that should be inserted into a table
by the given TableInsert operation. These methods can be chained
as allowed by the fluent API grammar.
*/
#include "common.h"
#include "result.h"
#include "executable.h"
#include "crud.h"
namespace mysqlx {
MYSQLX_ABI_BEGIN(2,0)
class Table;
// ---------------------------------------------------------------------------
class TableInsert;
namespace internal {
struct Table_insert_base
: public Executable<Result, TableInsert>
{};
}
/**
An operation which inserts rows into a table.
This class defines methods that specify the rows to be inserted into
the table.
@todo Check that every row passed to .values() call has
the same number of values. The column count should match
the one in insert(c1,...) call. For insert() without column
list, it should match the number of columns in the table.
@ingroup devapi_op
*/
class TableInsert
: public internal::Table_insert_base
, internal::Table_insert_detail
{
protected:
template <class... Cols>
TableInsert(Table &table, const Cols&... cols)
: TableInsert(table)
{
add_columns(get_impl(), cols...);
}
public:
// Create operation which inserts rows into given table.
TableInsert(Table &table)
{
try {
reset(internal::Crud_factory::mk_insert(table));
}
CATCH_AND_WRAP
}
TableInsert(const internal::Table_insert_base &other)
{
internal::Table_insert_base::operator=(other);
}
TableInsert(internal::Table_insert_base &&other)
{
internal::Table_insert_base::operator=(std::move(other));
}
using internal::Table_insert_base::operator=;
/// Add the given row to the list of rows to be inserted.
virtual TableInsert& values(const Row &row)
{
try {
add_rows(get_impl(), row);
return *this;
}
CATCH_AND_WRAP
}
/**
Add a single row consisting of the specified values to the list of
rows to be inserted.
*/
template<typename... Types>
TableInsert& values(Types... rest)
{
try {
add_values(get_impl(), rest...);
return *this;
}
CATCH_AND_WRAP
}
/**
Add rows from a container such as vector or list.
*/
template<typename Container>
TableInsert& rows(const Container &cont)
{
try {
add_rows(get_impl(), cont);
return *this;
}
CATCH_AND_WRAP
}
/**
Add rows from a range given by two iterators.
*/
template<typename It>
TableInsert& rows(const It &begin, const It &end)
{
try {
add_rows(get_impl(), begin, end);
return *this;
}
CATCH_AND_WRAP
}
/**
Add the given list of rows.
*/
template<typename... Types>
TableInsert& rows(const Row &first, Types... rest)
{
try {
add_rows(get_impl(), first, rest...);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Table_insert_detail::Impl;
Impl* get_impl()
{
return static_cast<Impl*>(internal::Table_insert_base::get_impl());
}
///@cond IGNORED
friend Table;
///@endcond
};
// ---------------------------------------------------------------------------
class TableSelect;
namespace internal {
class Op_view_create_alter;
struct Table_select_cmd
: public Executable<RowResult, TableSelect>
{};
struct Table_select_base
: public Group_by < Having < Order_by < Limit < Offset< Bind_parameters<
Set_lock< Table_select_cmd, common::Table_select_if >
> > > > > >
{};
}
/**
An operation which selects rows from a table.
The class defines various methods, such as `where()`, to specify which rows
should be returned and in which order.
For each row the operation can return all fields from the
row or a set of values defined by projection expressions
specified when the operation was created.
@ingroup devapi_op
*/
class TableSelect
: public internal::Table_select_base
, internal::Table_select_detail
{
using Operation = Table_select_base;
public:
TableSelect(Table &table)
{
try {
reset(internal::Crud_factory::mk_select(table));
}
CATCH_AND_WRAP
}
template <typename...PROJ>
TableSelect(Table &table, const PROJ&... proj)
: TableSelect(table)
{
try {
add_proj(get_impl(), proj...);
}
CATCH_AND_WRAP
}
TableSelect(const internal::Table_select_cmd &other)
{
internal::Table_select_cmd::operator=(other);
}
TableSelect(internal::Table_select_cmd &&other)
{
internal::Table_select_cmd::operator=(std::move(other));
}
using internal::Table_select_cmd::operator=;
/**
Specify row selection criteria.
The criteria is specified as a Boolean expression string.
*/
Operation& where(const string& expr)
{
try {
get_impl()->set_where(expr);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Table_select_if;
Impl* get_impl()
{
return static_cast<Impl*>(internal::Table_select_base::get_impl());
}
///@cond IGNORED
friend Table;
friend internal::Op_view_create_alter;
///@endcond
};
// ---------------------------------------------------------------------------
class TableUpdate;
namespace internal {
struct Table_update_cmd
: public Executable<Result, TableUpdate>
{};
struct Table_update_base
: public Order_by< Limit< Bind_parameters< Table_update_cmd > > >
{};
}
/**
An operation which updates rows stored in a table.
Methods of this clas specify modifications to be applied to each row as well
as the set of rows that should be modified.
@ingroup devapi_op
*/
class TableUpdate
: public internal::Table_update_base
{
using Operation = internal::Table_update_base;
TableUpdate(Table& table)
{
try {
reset(internal::Crud_factory::mk_update(table));
}
CATCH_AND_WRAP
}
public:
TableUpdate(Table &table, const string &expr)
: TableUpdate(table)
{
where(expr);
}
TableUpdate(const internal::Table_update_cmd &other)
{
internal::Table_update_cmd::operator=(other);
}
TableUpdate(internal::Table_update_cmd &&other)
{
internal::Table_update_cmd::operator=(std::move(other));
}
using internal::Table_update_cmd::operator=;
/**
Set the given field in a row to the given value.
The value can be either a direct literal or an expression given
as `expr(<string>)`, to be evaluated in the server.
*/
TableUpdate& set(const string& field, const Value &val)
{
try {
get_impl()->add_set(field, (const common::Value&)val);
return *this;
}
CATCH_AND_WRAP
}
/**
Specify selection criteria for rows that should be updated.
*/
Operation& where(const string& expr)
{
try {
get_impl()->set_where(expr);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Table_update_if;
Impl* get_impl()
{
return static_cast<Impl*>(internal::Table_update_base::get_impl());
}
///@cond IGNORED
friend Table;
///@endcond
};
// ---------------------------------------------------------------------------
class TableRemove;
namespace internal {
struct Table_remove_cmd
: public Executable<Result, TableRemove>
{};
struct Table_remove_base
: Order_by< Limit< Bind_parameters< Table_remove_cmd > > >
{};
}
/**
An operation which removes rows from a table.
The class defines methods to specify which rows should be removed.
@ingroup devapi_op
*/
class TableRemove
: public internal::Table_remove_base
{
using Operation = internal::Table_remove_base;
TableRemove(Table& table)
{
try {
reset(internal::Crud_factory::mk_remove(table));
}
CATCH_AND_WRAP
}
public:
TableRemove(Table &table, const string &expr)
: TableRemove(table)
{
where(expr);
}
TableRemove(const internal::Table_remove_cmd &other)
{
internal::Table_remove_cmd::operator=(other);
}
TableRemove(internal::Table_remove_cmd &&other)
{
internal::Table_remove_cmd::operator=(std::move(other));
}
using internal::Table_remove_cmd::operator=;
/**
Specify selection criteria for rows to be removed.
*/
Operation& where(const string &expr)
{
try {
get_impl()->set_where(expr);
return *this;
}
CATCH_AND_WRAP
}
protected:
using Impl = common::Table_remove_if;
Impl* get_impl()
{
return static_cast<Impl*>(internal::Table_remove_base::get_impl());
}
///@cond IGNORED
friend Table;
///@endcond
};
MYSQLX_ABI_END(2,0)
} // mysqlx
#endif

View File

@@ -1,56 +0,0 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0, as
* published by the Free Software Foundation.
*
* This program is also distributed with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an
* additional permission to link the program and your derivative works
* with the separately licensed software that they have included with
* MySQL.
*
* Without limiting anything contained in the foregoing, this file,
* which is part of MySQL Connector/C++, is also subject to the
* Universal FOSS Exception, version 1.0, a copy of which can be found at
* http://oss.oracle.com/licenses/universal-foss-exception.
*
* This program 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 General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MYSQLX_COMMON_VERSION_INFO
#define MYSQLX_COMMON_VERSION_INFO
/*
Version information which is used for example for default
connection attributes.
When build system is configured by cmake, a new file is generated
from this one with version and license values substituted by
cmake and build system is configured so that the generated
header takes precedence over this one. But code can be built even
if header with real values was not generated - in that case the
values specified here will be used.
*/
#define MYSQL_CONCPP_NAME "mysql-connector-cpp"
#define MYSQL_CONCPP_VERSION "8.2.0"
#define MYSQL_CONCPP_LICENSE "GPL-2.0"
#define MYSQL_CONCPP_VERSION_MAJOR 8
#define MYSQL_CONCPP_VERSION_MINOR 2
#define MYSQL_CONCPP_VERSION_MICRO 0
#define MYSQL_CONCPP_VERSION_NUMBER 8020000
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff