hkc320 2024-09-05 16:38:14 +08:00
parent 46a6e1dce5
commit f2764c656c
27 changed files with 1641 additions and 1240 deletions

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_BUILD_CONFIG_H_
#define _SQL_BUILD_CONFIG_H_ #define _SQL_BUILD_CONFIG_H_

View File

@ -1,13 +1,32 @@
/* /*
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
*
The MySQL Connector/C++ is licensed under the terms of the GPL * This program is free software; you can redistribute it and/or modify
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most * it under the terms of the GNU General Public License, version 2.0, as
MySQL Connectors. There are special exceptions to the terms and * published by the Free Software Foundation.
conditions of the GPL as it is applied to this software, see the *
FLOSS License Exception * This program is also distributed with certain software (including
<http://www.mysql.com/about/legal/licensing/foss-exception.html>. * 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 // libmysql defines HAVE_STRTOUL (on win), so we have to follow different pattern in definitions names
// to avoid annoying warnings. // to avoid annoying warnings.
@ -35,27 +54,34 @@
#define HAVE_UINT32_T 1 #define HAVE_UINT32_T 1
#define HAVE_INT64_T 1 #define HAVE_INT64_T 1
#define HAVE_UINT64_T 1 #define HAVE_UINT64_T 1
/* #undef HAVE_MS_INT8 */ #define HAVE_MS_INT8 1
/* #undef HAVE_MS_UINT8 */ #define HAVE_MS_UINT8 1
/* #undef HAVE_MS_INT16 */ #define HAVE_MS_INT16 1
/* #undef HAVE_MS_UINT16 */ #define HAVE_MS_UINT16 1
/* #undef HAVE_MS_INT32 */ #define HAVE_MS_INT32 1
/* #undef HAVE_MS_UINT32 */ #define HAVE_MS_UINT32 1
/* #undef HAVE_MS_INT64 */ #define HAVE_MS_INT64 1
/* #undef HAVE_MS_UINT64 */ #define HAVE_MS_UINT64 1
#ifdef HAVE_STDINT_H #ifdef HAVE_STDINT_H
#include <stdint.h> #include <stdint.h>
#endif #endif
#ifdef HAVE_INTTYPES_H
#if defined(HAVE_INTTYPES_H) && !defined(_WIN32)
#include <inttypes.h> #include <inttypes.h>
#endif #endif
#if defined(_WIN32) #if defined(_WIN32)
#ifndef CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES #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) #if !defined(HAVE_INT8_T) && defined(HAVE_MS_INT8)
typedef __int8 int8_t; typedef __int8 int8_t;
#endif #endif
@ -86,5 +112,6 @@ typedef __int64 int64_t;
typedef unsigned __int64 uint64_t; typedef unsigned __int64 uint64_t;
#endif #endif
#endif // _MSC_VER >= 1600
#endif // CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES #endif // CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
#endif // _WIN32 #endif // _WIN32

View File

@ -1,42 +1,49 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_CONNECTION_H_
#define _SQL_CONNECTION_H_ #define _SQL_CONNECTION_H_
#include <map> #include <map>
#include <boost/variant.hpp>
#include "build_config.h" #include "build_config.h"
#include "warning.h" #include "warning.h"
#include "sqlstring.h" #include "sqlstring.h"
#include "variant.h"
namespace sql namespace sql
{ {
typedef sql::Variant ConnectPropertyVal;
typedef boost::variant<int, double, bool, sql::SQLString > ConnectPropertyVal;
typedef std::map< sql::SQLString, ConnectPropertyVal > ConnectOptionsMap; typedef std::map< sql::SQLString, ConnectPropertyVal > ConnectOptionsMap;
@ -47,107 +54,121 @@ class Driver;
typedef enum transaction_isolation typedef enum transaction_isolation
{ {
TRANSACTION_NONE= 0, TRANSACTION_NONE= 0,
TRANSACTION_READ_COMMITTED, TRANSACTION_READ_COMMITTED,
TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_UNCOMMITTED,
TRANSACTION_REPEATABLE_READ, TRANSACTION_REPEATABLE_READ,
TRANSACTION_SERIALIZABLE TRANSACTION_SERIALIZABLE
} enum_transaction_isolation; } enum_transaction_isolation;
enum ssl_mode
{
SSL_MODE_DISABLED= 1, SSL_MODE_PREFERRED, SSL_MODE_REQUIRED,
SSL_MODE_VERIFY_CA, SSL_MODE_VERIFY_IDENTITY
};
class Savepoint class Savepoint
{ {
/* Prevent use of these */ /* Prevent use of these */
Savepoint(const Savepoint &); Savepoint(const Savepoint &);
void operator=(Savepoint &); void operator=(Savepoint &);
public: public:
Savepoint() {}; Savepoint() {};
virtual ~Savepoint() {}; virtual ~Savepoint() {};
virtual int getSavepointId() = 0; virtual int getSavepointId() = 0;
virtual sql::SQLString getSavepointName() = 0; virtual sql::SQLString getSavepointName() = 0;
}; };
class CPPCONN_PUBLIC_FUNC Connection class CPPCONN_PUBLIC_FUNC Connection
{ {
/* Prevent use of these */ /* Prevent use of these */
Connection(const Connection &); Connection(const Connection &);
void operator=(Connection &); void operator=(Connection &);
public: public:
Connection() {}; Connection() {};
virtual ~Connection() {}; virtual ~Connection() {};
virtual void clearWarnings() = 0; virtual void clearWarnings() = 0;
virtual Statement *createStatement() = 0; virtual Statement *createStatement() = 0;
virtual void close() = 0; virtual void close() = 0;
virtual void commit() = 0; virtual void commit() = 0;
virtual bool getAutoCommit() = 0; virtual bool getAutoCommit() = 0;
virtual sql::SQLString getCatalog() = 0; virtual sql::SQLString getCatalog() = 0;
virtual Driver *getDriver() = 0; virtual Driver *getDriver() = 0;
virtual sql::SQLString getSchema() = 0; virtual sql::SQLString getSchema() = 0;
virtual sql::SQLString getClientInfo() = 0; virtual sql::SQLString getClientInfo() = 0;
virtual void getClientOption(const sql::SQLString & optionName, void * optionValue) = 0; virtual void getClientOption(const sql::SQLString & optionName, void * optionValue) = 0;
virtual DatabaseMetaData * getMetaData() = 0; virtual sql::SQLString getClientOption(const sql::SQLString & optionName) = 0;
virtual enum_transaction_isolation getTransactionIsolation() = 0; virtual DatabaseMetaData * getMetaData() = 0;
virtual const SQLWarning * getWarnings() = 0; virtual enum_transaction_isolation getTransactionIsolation() = 0;
virtual bool isClosed() = 0; virtual const SQLWarning * getWarnings() = 0;
virtual bool isReadOnly() = 0; virtual bool isClosed() = 0;
virtual sql::SQLString nativeSQL(const sql::SQLString& sql) = 0; virtual bool isReadOnly() = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql) = 0; virtual bool isValid() = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys) = 0; virtual bool reconnect() = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int* columnIndexes) = 0; virtual sql::SQLString nativeSQL(const sql::SQLString& sql) = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency) = 0; virtual PreparedStatement * prepareStatement(const sql::SQLString& sql) = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) = 0; virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys) = 0;
virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]) = 0; virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int* columnIndexes) = 0;
virtual void releaseSavepoint(Savepoint * savepoint) = 0; virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency) = 0;
virtual void rollback() = 0; virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) = 0;
virtual void rollback(Savepoint * savepoint) = 0; virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]) = 0;
virtual void setAutoCommit(bool autoCommit) = 0; virtual void releaseSavepoint(Savepoint * savepoint) = 0;
virtual void setCatalog(const sql::SQLString& catalog) = 0; virtual void rollback() = 0;
virtual void setSchema(const sql::SQLString& catalog) = 0; virtual void rollback(Savepoint * savepoint) = 0;
virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue) = 0; virtual void setAutoCommit(bool autoCommit) = 0;
virtual void setHoldability(int holdability) = 0; virtual void setCatalog(const sql::SQLString& catalog) = 0;
virtual void setReadOnly(bool readOnly) = 0; virtual void setSchema(const sql::SQLString& catalog) = 0;
virtual Savepoint * setSavepoint() = 0; virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue) = 0;
virtual Savepoint * setSavepoint(const sql::SQLString& name) = 0; virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const sql::SQLString & optionValue) = 0;
virtual void setTransactionIsolation(enum_transaction_isolation level) = 0; virtual void setHoldability(int holdability) = 0;
/* virtual void setTypeMap(Map map) = 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 */ } /* namespace sql */

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_DATATYPE_H_
#define _SQL_DATATYPE_H_ #define _SQL_DATATYPE_H_
@ -30,35 +38,36 @@ namespace sql
class DataType class DataType
{ {
DataType(); DataType();
public: public:
enum { enum {
UNKNOWN = 0, UNKNOWN = 0,
BIT, BIT,
TINYINT, TINYINT,
SMALLINT, SMALLINT,
MEDIUMINT, MEDIUMINT,
INTEGER, INTEGER,
BIGINT, BIGINT,
REAL, REAL,
DOUBLE, DOUBLE,
DECIMAL, DECIMAL,
NUMERIC, NUMERIC,
CHAR, CHAR,
BINARY, BINARY,
VARCHAR, VARCHAR,
VARBINARY, VARBINARY,
LONGVARCHAR, LONGVARCHAR,
LONGVARBINARY, LONGVARBINARY,
TIMESTAMP, TIMESTAMP,
DATE, DATE,
TIME, TIME,
YEAR, YEAR,
GEOMETRY, GEOMETRY,
ENUM, ENUM,
SET, SET,
SQLNULL SQLNULL,
}; JSON
};
}; };
} /* namespace */ } /* namespace */

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_DRIVER_H_
#define _SQL_DRIVER_H_ #define _SQL_DRIVER_H_
@ -34,35 +42,35 @@ namespace sql
class CPPCONN_PUBLIC_FUNC Driver class CPPCONN_PUBLIC_FUNC Driver
{ {
protected: protected:
virtual ~Driver() {} virtual ~Driver() {}
public: public:
// Attempts to make a database connection to the given URL. // 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(const sql::SQLString& hostName, const sql::SQLString& userName, const sql::SQLString& password) = 0;
virtual Connection * connect(ConnectOptionsMap & options) = 0; virtual Connection * connect(ConnectOptionsMap & options) = 0;
virtual int getMajorVersion() = 0; virtual int getMajorVersion() = 0;
virtual int getMinorVersion() = 0; virtual int getMinorVersion() = 0;
virtual int getPatchVersion() = 0; virtual int getPatchVersion() = 0;
virtual const sql::SQLString & getName() = 0; virtual const sql::SQLString & getName() = 0;
virtual void threadInit() = 0; virtual void threadInit() = 0;
virtual void threadEnd() = 0; virtual void threadEnd() = 0;
}; };
} /* namespace sql */ } /* namespace sql */
extern "C" extern "C"
{ {
CPPCONN_PUBLIC_FUNC sql::Driver * get_driver_instance(); CPPCONN_PUBLIC_FUNC sql::Driver * get_driver_instance();
/* If dynamic loading is disabled in a driver then this function works just like get_driver_instance() */ /* If dynamic loading is disabled in a driver then this function works just like get_driver_instance() */
CPPCONN_PUBLIC_FUNC sql::Driver * get_driver_instance_by_name(const char * const clientlib); CPPCONN_PUBLIC_FUNC sql::Driver * get_driver_instance_by_name(const char * const clientlib);
} }
#endif /* _SQL_DRIVER_H_ */ #endif /* _SQL_DRIVER_H_ */

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_EXCEPTION_H_
#define _SQL_EXCEPTION_H_ #define _SQL_EXCEPTION_H_
@ -33,15 +41,26 @@
namespace sql namespace sql
{ {
#if (__cplusplus < 201103L)
#define MEMORY_ALLOC_OPERATORS(Class) \ #define MEMORY_ALLOC_OPERATORS(Class) \
void* operator new(size_t size) throw (std::bad_alloc) { return ::operator new(size); } \ void* operator new(size_t size) throw (std::bad_alloc) { return ::operator new(size); } \
void* operator new(size_t, void*) throw(); \ void* operator new(size_t, void*) throw(); \
void* operator new(size_t, const std::nothrow_t&) throw(); \ void* operator new(size_t, const std::nothrow_t&) throw(); \
void* operator new[](size_t) throw (std::bad_alloc); \ void* operator new[](size_t) throw (std::bad_alloc); \
void* operator new[](size_t, void*) throw(); \ void* operator new[](size_t, void*) throw(); \
void* operator new[](size_t, const std::nothrow_t&) throw(); \ void* operator new[](size_t, const std::nothrow_t&) throw(); \
void* operator new(size_t N, std::allocator<Class>&); void* operator new(size_t N, std::allocator<Class>&);
#else
#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>&);
#endif
#ifdef _WIN32 #ifdef _WIN32
#pragma warning (disable : 4290) #pragma warning (disable : 4290)
//warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow) //warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
@ -56,71 +75,94 @@ class CPPCONN_PUBLIC_FUNC SQLException : public std::runtime_error
#pragma warning(pop) #pragma warning(pop)
#endif #endif
protected: protected:
const std::string sql_state; const std::string sql_state;
const int errNo; const int errNo;
public: public:
SQLException(const SQLException& e) : std::runtime_error(e.what()), sql_state(e.sql_state), errNo(e.errNo) {} 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) : SQLException(const std::string& reason, const std::string& SQLState, int vendorCode) :
std::runtime_error (reason ), std::runtime_error (reason ),
sql_state (SQLState ), sql_state (SQLState ),
errNo (vendorCode) 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, 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(const std::string& reason) : std::runtime_error(reason), sql_state("HY000"), errNo(0) {}
SQLException() : std::runtime_error(""), sql_state("HY000"), errNo(0) {} SQLException() : std::runtime_error(""), sql_state("HY000"), errNo(0) {}
const std::string & getSQLState() const const std::string & getSQLState() const
{ {
return sql_state; return sql_state;
} }
const char * getSQLStateCStr() const const char * getSQLStateCStr() const
{ {
return sql_state.c_str(); return sql_state.c_str();
} }
int getErrorCode() const int getErrorCode() const
{ {
return errNo; return errNo;
} }
virtual ~SQLException() throw () {}; virtual ~SQLException() throw () {};
protected: protected:
MEMORY_ALLOC_OPERATORS(SQLException) MEMORY_ALLOC_OPERATORS(SQLException)
}; };
struct CPPCONN_PUBLIC_FUNC MethodNotImplementedException : public SQLException struct CPPCONN_PUBLIC_FUNC MethodNotImplementedException : public SQLException
{ {
MethodNotImplementedException(const MethodNotImplementedException& e) : SQLException(e.what(), e.sql_state, e.errNo) { } MethodNotImplementedException(const MethodNotImplementedException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
MethodNotImplementedException(const std::string& reason) : SQLException(reason, "", 0) {} MethodNotImplementedException(const std::string& reason) : SQLException(reason, "", 0) {}
}; };
struct CPPCONN_PUBLIC_FUNC InvalidArgumentException : public SQLException struct CPPCONN_PUBLIC_FUNC InvalidArgumentException : public SQLException
{ {
InvalidArgumentException(const InvalidArgumentException& e) : SQLException(e.what(), e.sql_state, e.errNo) { } InvalidArgumentException(const InvalidArgumentException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
InvalidArgumentException(const std::string& reason) : SQLException(reason, "", 0) {} InvalidArgumentException(const std::string& reason) : SQLException(reason, "", 0) {}
}; };
struct CPPCONN_PUBLIC_FUNC InvalidInstanceException : public SQLException struct CPPCONN_PUBLIC_FUNC InvalidInstanceException : public SQLException
{ {
InvalidInstanceException(const InvalidInstanceException& e) : SQLException(e.what(), e.sql_state, e.errNo) { } InvalidInstanceException(const InvalidInstanceException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
InvalidInstanceException(const std::string& reason) : SQLException(reason, "", 0) {} InvalidInstanceException(const std::string& reason) : SQLException(reason, "", 0) {}
}; };
struct CPPCONN_PUBLIC_FUNC NonScrollableException : public SQLException struct CPPCONN_PUBLIC_FUNC NonScrollableException : public SQLException
{ {
NonScrollableException(const NonScrollableException& e) : SQLException(e.what(), e.sql_state, e.errNo) { } NonScrollableException(const NonScrollableException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
NonScrollableException(const std::string& reason) : SQLException(reason, "", 0) {} NonScrollableException(const std::string& reason) : SQLException(reason, "", 0) {}
}; };
struct CPPCONN_PUBLIC_FUNC 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() throw () {};
protected:
const std::string option;
};
} /* namespace sql */ } /* namespace sql */
#endif /* _SQL_EXCEPTION_H_ */ #endif /* _SQL_EXCEPTION_H_ */

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_METADATA_H_
#define _SQL_METADATA_H_ #define _SQL_METADATA_H_
@ -37,438 +45,446 @@ class ResultSet;
class DatabaseMetaData class DatabaseMetaData
{ {
protected: protected:
virtual ~DatabaseMetaData() {} virtual ~DatabaseMetaData() {}
public: public:
enum enum
{ {
attributeNoNulls = 0, attributeNoNulls = 0,
attributeNullable, attributeNullable,
attributeNullableUnknown attributeNullableUnknown
}; };
enum enum
{ {
bestRowTemporary = 0, bestRowTemporary = 0,
bestRowTransaction, bestRowTransaction,
bestRowSession bestRowSession
}; };
enum enum
{ {
bestRowUnknown = 0, bestRowUnknown = 0,
bestRowNotPseudo, bestRowNotPseudo,
bestRowPseudo bestRowPseudo
}; };
enum enum
{ {
columnNoNulls = 0, columnNoNulls = 0,
columnNullable, columnNullable,
columnNullableUnknown columnNullableUnknown
}; };
enum enum
{ {
importedKeyCascade = 0, importedKeyCascade = 0,
importedKeyInitiallyDeferred, importedKeyInitiallyDeferred,
importedKeyInitiallyImmediate, importedKeyInitiallyImmediate,
importedKeyNoAction, importedKeyNoAction,
importedKeyNotDeferrable, importedKeyNotDeferrable,
importedKeyRestrict, importedKeyRestrict,
importedKeySetDefault, importedKeySetDefault,
importedKeySetNull importedKeySetNull
}; };
enum enum
{ {
procedureColumnIn = 0, procedureColumnIn = 0,
procedureColumnInOut, procedureColumnInOut,
procedureColumnOut, procedureColumnOut,
procedureColumnResult, procedureColumnResult,
procedureColumnReturn, procedureColumnReturn,
procedureColumnUnknown, procedureColumnUnknown,
procedureNoNulls, procedureNoNulls,
procedureNoResult, procedureNoResult,
procedureNullable, procedureNullable,
procedureNullableUnknown, procedureNullableUnknown,
procedureResultUnknown, procedureResultUnknown,
procedureReturnsResult procedureReturnsResult
}; };
enum enum
{ {
sqlStateSQL99 = 0, sqlStateSQL99 = 0,
sqlStateXOpen sqlStateXOpen
}; };
enum enum
{ {
tableIndexClustered = 0, tableIndexClustered = 0,
tableIndexHashed, tableIndexHashed,
tableIndexOther, tableIndexOther,
tableIndexStatistic tableIndexStatistic
}; };
enum enum
{ {
versionColumnUnknown = 0, versionColumnUnknown = 0,
versionColumnNotPseudo = 1, versionColumnNotPseudo = 1,
versionColumnPseudo = 2 versionColumnPseudo = 2
}; };
enum enum
{ {
typeNoNulls = 0, typeNoNulls = 0,
typeNullable = 1, typeNullable = 1,
typeNullableUnknown = 2 typeNullableUnknown = 2
}; };
enum enum
{ {
typePredNone = 0, typePredNone = 0,
typePredChar = 1, typePredChar = 1,
typePredBasic= 2, typePredBasic= 2,
typeSearchable = 3 typeSearchable = 3
}; };
virtual bool allProceduresAreCallable() = 0; virtual bool allProceduresAreCallable() = 0;
virtual bool allTablesAreSelectable() = 0; virtual bool allTablesAreSelectable() = 0;
virtual bool dataDefinitionCausesTransactionCommit() = 0; virtual bool dataDefinitionCausesTransactionCommit() = 0;
virtual bool dataDefinitionIgnoredInTransactions() = 0; virtual bool dataDefinitionIgnoredInTransactions() = 0;
virtual bool deletesAreDetected(int type) = 0; virtual bool deletesAreDetected(int type) = 0;
virtual bool doesMaxRowSizeIncludeBlobs() = 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 * 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 * getBestRowIdentifier(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table, int scope, bool nullable) = 0;
virtual ResultSet * getCatalogs() = 0; virtual ResultSet * getCatalogs() = 0;
virtual const sql::SQLString& getCatalogSeparator() = 0; virtual const sql::SQLString& getCatalogSeparator() = 0;
virtual const sql::SQLString& getCatalogTerm() = 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 * 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 ResultSet * getColumns(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern, const sql::SQLString& columnNamePattern) = 0;
virtual Connection * getConnection() = 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 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 getDatabaseMajorVersion() = 0;
virtual unsigned int getDatabaseMinorVersion() = 0; virtual unsigned int getDatabaseMinorVersion() = 0;
virtual unsigned int getDatabasePatchVersion() = 0; virtual unsigned int getDatabasePatchVersion() = 0;
virtual const sql::SQLString& getDatabaseProductName() = 0; virtual const sql::SQLString& getDatabaseProductName() = 0;
virtual SQLString getDatabaseProductVersion() = 0; virtual SQLString getDatabaseProductVersion() = 0;
virtual int getDefaultTransactionIsolation() = 0; virtual int getDefaultTransactionIsolation() = 0;
virtual unsigned int getDriverMajorVersion() = 0; virtual unsigned int getDriverMajorVersion() = 0;
virtual unsigned int getDriverMinorVersion() = 0; virtual unsigned int getDriverMinorVersion() = 0;
virtual unsigned int getDriverPatchVersion() = 0; virtual unsigned int getDriverPatchVersion() = 0;
virtual const sql::SQLString& getDriverName() = 0; virtual const sql::SQLString& getDriverName() = 0;
virtual const sql::SQLString& getDriverVersion() = 0; virtual const sql::SQLString& getDriverVersion() = 0;
virtual ResultSet * getExportedKeys(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 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& getExtraNameCharacters() = 0;
virtual const sql::SQLString& getIdentifierQuoteString() = 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 * 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 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 getCDBCMajorVersion() = 0;
virtual unsigned int getCDBCMinorVersion() = 0; virtual unsigned int getCDBCMinorVersion() = 0;
virtual unsigned int getMaxBinaryLiteralLength() = 0; virtual unsigned int getMaxBinaryLiteralLength() = 0;
virtual unsigned int getMaxCatalogNameLength() = 0; virtual unsigned int getMaxCatalogNameLength() = 0;
virtual unsigned int getMaxCharLiteralLength() = 0; virtual unsigned int getMaxCharLiteralLength() = 0;
virtual unsigned int getMaxColumnNameLength() = 0; virtual unsigned int getMaxColumnNameLength() = 0;
virtual unsigned int getMaxColumnsInGroupBy() = 0; virtual unsigned int getMaxColumnsInGroupBy() = 0;
virtual unsigned int getMaxColumnsInIndex() = 0; virtual unsigned int getMaxColumnsInIndex() = 0;
virtual unsigned int getMaxColumnsInOrderBy() = 0; virtual unsigned int getMaxColumnsInOrderBy() = 0;
virtual unsigned int getMaxColumnsInSelect() = 0; virtual unsigned int getMaxColumnsInSelect() = 0;
virtual unsigned int getMaxColumnsInTable() = 0; virtual unsigned int getMaxColumnsInTable() = 0;
virtual unsigned int getMaxConnections() = 0; virtual unsigned int getMaxConnections() = 0;
virtual unsigned int getMaxCursorNameLength() = 0; virtual unsigned int getMaxCursorNameLength() = 0;
virtual unsigned int getMaxIndexLength() = 0; virtual unsigned int getMaxIndexLength() = 0;
virtual unsigned int getMaxProcedureNameLength() = 0; virtual unsigned int getMaxProcedureNameLength() = 0;
virtual unsigned int getMaxRowSize() = 0; virtual unsigned int getMaxRowSize() = 0;
virtual unsigned int getMaxSchemaNameLength() = 0; virtual unsigned int getMaxSchemaNameLength() = 0;
virtual unsigned int getMaxStatementLength() = 0; virtual unsigned int getMaxStatementLength() = 0;
virtual unsigned int getMaxStatements() = 0; virtual unsigned int getMaxStatements() = 0;
virtual unsigned int getMaxTableNameLength() = 0; virtual unsigned int getMaxTableNameLength() = 0;
virtual unsigned int getMaxTablesInSelect() = 0; virtual unsigned int getMaxTablesInSelect() = 0;
virtual unsigned int getMaxUserNameLength() = 0; virtual unsigned int getMaxUserNameLength() = 0;
virtual const sql::SQLString& getNumericFunctions() = 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 * 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 * 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 ResultSet * getProcedures(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& procedureNamePattern) = 0;
virtual const sql::SQLString& getProcedureTerm() = 0; virtual const sql::SQLString& getProcedureTerm() = 0;
virtual int getResultSetHoldability() = 0; virtual int getResultSetHoldability() = 0;
virtual ResultSet * getSchemas() = 0; virtual ResultSet * getSchemas() = 0;
virtual const sql::SQLString& getSchemaTerm() = 0; virtual const sql::SQLString& getSchemaTerm() = 0;
virtual const sql::SQLString& getSearchStringEscape() = 0; virtual ResultSet * getSchemaCollation(const sql::SQLString& catalog, const sql::SQLString& schemaPattern) = 0;
virtual const sql::SQLString& getSQLKeywords() = 0; virtual ResultSet * getSchemaCharset(const sql::SQLString& catalog, const sql::SQLString& schemaPattern) = 0;
virtual int getSQLStateType() = 0; virtual const sql::SQLString& getSearchStringEscape() = 0;
virtual const sql::SQLString& getStringFunctions() = 0; virtual const sql::SQLString& getSQLKeywords() = 0;
virtual ResultSet * getSuperTables(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0; virtual int getSQLStateType() = 0;
virtual ResultSet * getSuperTypes(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern) = 0; virtual const sql::SQLString& getStringFunctions() = 0;
virtual const sql::SQLString& getSystemFunctions() = 0; virtual ResultSet * getSuperTables(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
virtual ResultSet * getTablePrivileges(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 ResultSet * getTables(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern, std::list<sql::SQLString> &types) = 0; virtual const sql::SQLString& getSystemFunctions() = 0;
virtual ResultSet * getTableTypes() = 0; virtual ResultSet * getTablePrivileges(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
virtual const sql::SQLString& getTimeDateFunctions() = 0; virtual ResultSet * getTables(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern, std::list<sql::SQLString> &types) = 0;
virtual ResultSet * getTypeInfo() = 0; virtual ResultSet * getTableTypes() = 0;
virtual ResultSet * getUDTs(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern, std::list<int> &types) = 0; virtual ResultSet * getTableCollation(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
virtual SQLString getURL() = 0; virtual ResultSet * getTableCharset(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
virtual SQLString getUserName() = 0; virtual const sql::SQLString& getTimeDateFunctions() = 0;
virtual ResultSet * getVersionColumns(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0; virtual ResultSet * getTypeInfo() = 0;
virtual bool insertsAreDetected(int type) = 0; virtual ResultSet * getUDTs(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern, std::list<int> &types) = 0;
virtual bool isCatalogAtStart() = 0; virtual SQLString getURL() = 0;
virtual bool isReadOnly() = 0; virtual SQLString getUserName() = 0;
virtual bool locatorsUpdateCopy() = 0; virtual ResultSet * getVersionColumns(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0;
virtual bool nullPlusNonNullIsNull() = 0; virtual bool insertsAreDetected(int type) = 0;
virtual bool nullsAreSortedAtEnd() = 0; virtual bool isCatalogAtStart() = 0;
virtual bool nullsAreSortedAtStart() = 0; virtual bool isReadOnly() = 0;
virtual bool nullsAreSortedHigh() = 0; virtual bool locatorsUpdateCopy() = 0;
virtual bool nullsAreSortedLow() = 0; virtual bool nullPlusNonNullIsNull() = 0;
virtual bool othersDeletesAreVisible(int type) = 0; virtual bool nullsAreSortedAtEnd() = 0;
virtual bool othersInsertsAreVisible(int type) = 0; virtual bool nullsAreSortedAtStart() = 0;
virtual bool othersUpdatesAreVisible(int type) = 0; virtual bool nullsAreSortedHigh() = 0;
virtual bool ownDeletesAreVisible(int type) = 0; virtual bool nullsAreSortedLow() = 0;
virtual bool ownInsertsAreVisible(int type) = 0; virtual bool othersDeletesAreVisible(int type) = 0;
virtual bool ownUpdatesAreVisible(int type) = 0; virtual bool othersInsertsAreVisible(int type) = 0;
virtual bool storesLowerCaseIdentifiers() = 0; virtual bool othersUpdatesAreVisible(int type) = 0;
virtual bool storesLowerCaseQuotedIdentifiers() = 0; virtual bool ownDeletesAreVisible(int type) = 0;
virtual bool storesMixedCaseIdentifiers() = 0; virtual bool ownInsertsAreVisible(int type) = 0;
virtual bool storesMixedCaseQuotedIdentifiers() = 0; virtual bool ownUpdatesAreVisible(int type) = 0;
virtual bool storesUpperCaseIdentifiers() = 0; virtual bool storesLowerCaseIdentifiers() = 0;
virtual bool storesUpperCaseQuotedIdentifiers() = 0; virtual bool storesLowerCaseQuotedIdentifiers() = 0;
virtual bool supportsAlterTableWithAddColumn() = 0; virtual bool storesMixedCaseIdentifiers() = 0;
virtual bool supportsAlterTableWithDropColumn() = 0; virtual bool storesMixedCaseQuotedIdentifiers() = 0;
virtual bool supportsANSI92EntryLevelSQL() = 0; virtual bool storesUpperCaseIdentifiers() = 0;
virtual bool supportsANSI92FullSQL() = 0; virtual bool storesUpperCaseQuotedIdentifiers() = 0;
virtual bool supportsANSI92IntermediateSQL() = 0; virtual bool supportsAlterTableWithAddColumn() = 0;
virtual bool supportsBatchUpdates() = 0; virtual bool supportsAlterTableWithDropColumn() = 0;
virtual bool supportsCatalogsInDataManipulation() = 0; virtual bool supportsANSI92EntryLevelSQL() = 0;
virtual bool supportsCatalogsInIndexDefinitions() = 0; virtual bool supportsANSI92FullSQL() = 0;
virtual bool supportsCatalogsInPrivilegeDefinitions() = 0; virtual bool supportsANSI92IntermediateSQL() = 0;
virtual bool supportsCatalogsInProcedureCalls() = 0; virtual bool supportsBatchUpdates() = 0;
virtual bool supportsCatalogsInTableDefinitions() = 0; virtual bool supportsCatalogsInDataManipulation() = 0;
virtual bool supportsColumnAliasing() = 0; virtual bool supportsCatalogsInIndexDefinitions() = 0;
virtual bool supportsConvert() = 0; virtual bool supportsCatalogsInPrivilegeDefinitions() = 0;
virtual bool supportsConvert(int fromType, int toType) = 0; virtual bool supportsCatalogsInProcedureCalls() = 0;
virtual bool supportsCoreSQLGrammar() = 0; virtual bool supportsCatalogsInTableDefinitions() = 0;
virtual bool supportsCorrelatedSubqueries() = 0; virtual bool supportsColumnAliasing() = 0;
virtual bool supportsDataDefinitionAndDataManipulationTransactions() = 0; virtual bool supportsConvert() = 0;
virtual bool supportsDataManipulationTransactionsOnly() = 0; virtual bool supportsConvert(int fromType, int toType) = 0;
virtual bool supportsDifferentTableCorrelationNames() = 0; virtual bool supportsCoreSQLGrammar() = 0;
virtual bool supportsExpressionsInOrderBy() = 0; virtual bool supportsCorrelatedSubqueries() = 0;
virtual bool supportsExtendedSQLGrammar() = 0; virtual bool supportsDataDefinitionAndDataManipulationTransactions() = 0;
virtual bool supportsFullOuterJoins() = 0; virtual bool supportsDataManipulationTransactionsOnly() = 0;
virtual bool supportsGetGeneratedKeys() = 0; virtual bool supportsDifferentTableCorrelationNames() = 0;
virtual bool supportsGroupBy() = 0; virtual bool supportsExpressionsInOrderBy() = 0;
virtual bool supportsGroupByBeyondSelect() = 0; virtual bool supportsExtendedSQLGrammar() = 0;
virtual bool supportsGroupByUnrelated() = 0; virtual bool supportsFullOuterJoins() = 0;
virtual bool supportsIntegrityEnhancementFacility() = 0; virtual bool supportsGetGeneratedKeys() = 0;
virtual bool supportsLikeEscapeClause() = 0; virtual bool supportsGroupBy() = 0;
virtual bool supportsLimitedOuterJoins() = 0; virtual bool supportsGroupByBeyondSelect() = 0;
virtual bool supportsMinimumSQLGrammar() = 0; virtual bool supportsGroupByUnrelated() = 0;
virtual bool supportsMixedCaseIdentifiers() = 0; virtual bool supportsIntegrityEnhancementFacility() = 0;
virtual bool supportsMixedCaseQuotedIdentifiers() = 0; virtual bool supportsLikeEscapeClause() = 0;
virtual bool supportsMultipleOpenResults() = 0; virtual bool supportsLimitedOuterJoins() = 0;
virtual bool supportsMultipleResultSets() = 0; virtual bool supportsMinimumSQLGrammar() = 0;
virtual bool supportsMultipleTransactions() = 0; virtual bool supportsMixedCaseIdentifiers() = 0;
virtual bool supportsNamedParameters() = 0; virtual bool supportsMixedCaseQuotedIdentifiers() = 0;
virtual bool supportsNonNullableColumns() = 0; virtual bool supportsMultipleOpenResults() = 0;
virtual bool supportsOpenCursorsAcrossCommit() = 0; virtual bool supportsMultipleResultSets() = 0;
virtual bool supportsOpenCursorsAcrossRollback() = 0; virtual bool supportsMultipleTransactions() = 0;
virtual bool supportsOpenStatementsAcrossCommit() = 0; virtual bool supportsNamedParameters() = 0;
virtual bool supportsOpenStatementsAcrossRollback() = 0; virtual bool supportsNonNullableColumns() = 0;
virtual bool supportsOrderByUnrelated() = 0; virtual bool supportsOpenCursorsAcrossCommit() = 0;
virtual bool supportsOuterJoins() = 0; virtual bool supportsOpenCursorsAcrossRollback() = 0;
virtual bool supportsPositionedDelete() = 0; virtual bool supportsOpenStatementsAcrossCommit() = 0;
virtual bool supportsPositionedUpdate() = 0; virtual bool supportsOpenStatementsAcrossRollback() = 0;
virtual bool supportsResultSetConcurrency(int type, int concurrency) = 0; virtual bool supportsOrderByUnrelated() = 0;
virtual bool supportsResultSetHoldability(int holdability) = 0; virtual bool supportsOuterJoins() = 0;
virtual bool supportsResultSetType(int type) = 0; virtual bool supportsPositionedDelete() = 0;
virtual bool supportsSavepoints() = 0; virtual bool supportsPositionedUpdate() = 0;
virtual bool supportsSchemasInDataManipulation() = 0; virtual bool supportsResultSetConcurrency(int type, int concurrency) = 0;
virtual bool supportsSchemasInIndexDefinitions() = 0; virtual bool supportsResultSetHoldability(int holdability) = 0;
virtual bool supportsSchemasInPrivilegeDefinitions() = 0; virtual bool supportsResultSetType(int type) = 0;
virtual bool supportsSchemasInProcedureCalls() = 0; virtual bool supportsSavepoints() = 0;
virtual bool supportsSchemasInTableDefinitions() = 0; virtual bool supportsSchemasInDataManipulation() = 0;
virtual bool supportsSelectForUpdate() = 0; virtual bool supportsSchemasInIndexDefinitions() = 0;
virtual bool supportsStatementPooling() = 0; virtual bool supportsSchemasInPrivilegeDefinitions() = 0;
virtual bool supportsStoredProcedures() = 0; virtual bool supportsSchemasInProcedureCalls() = 0;
virtual bool supportsSubqueriesInComparisons() = 0; virtual bool supportsSchemasInTableDefinitions() = 0;
virtual bool supportsSubqueriesInExists() = 0; virtual bool supportsSelectForUpdate() = 0;
virtual bool supportsSubqueriesInIns() = 0; virtual bool supportsStatementPooling() = 0;
virtual bool supportsSubqueriesInQuantifieds() = 0; virtual bool supportsStoredProcedures() = 0;
virtual bool supportsTableCorrelationNames() = 0; virtual bool supportsSubqueriesInComparisons() = 0;
virtual bool supportsTransactionIsolationLevel(int level) = 0; virtual bool supportsSubqueriesInExists() = 0;
virtual bool supportsTransactions() = 0; virtual bool supportsSubqueriesInIns() = 0;
virtual bool supportsTypeConversion() = 0; /* SDBC */ virtual bool supportsSubqueriesInQuantifieds() = 0;
virtual bool supportsUnion() = 0; virtual bool supportsTableCorrelationNames() = 0;
virtual bool supportsUnionAll() = 0; virtual bool supportsTransactionIsolationLevel(int level) = 0;
virtual bool updatesAreDetected(int type) = 0; virtual bool supportsTransactions() = 0;
virtual bool usesLocalFilePerTable() = 0; virtual bool supportsTypeConversion() = 0; /* SDBC */
virtual bool usesLocalFiles() = 0; virtual bool supportsUnion() = 0;
virtual ResultSet *getSchemata(const sql::SQLString& catalogName = "") = 0; virtual bool supportsUnionAll() = 0;
virtual ResultSet *getSchemaObjects(const sql::SQLString& catalogName = "", virtual bool updatesAreDetected(int type) = 0;
const sql::SQLString& schemaName = "",
const sql::SQLString& objectType = "",
bool includingDdl = true,
const sql::SQLString& objectName = "",
const sql::SQLString& contextTableName = "") = 0;
virtual ResultSet *getSchemaObjectTypes() = 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;
}; };

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_PARAMETER_METADATA_H_
#define _SQL_PARAMETER_METADATA_H_ #define _SQL_PARAMETER_METADATA_H_
@ -34,40 +42,40 @@ namespace sql
class ParameterMetaData class ParameterMetaData
{ {
public: public:
enum enum
{ {
parameterModeIn, parameterModeIn,
parameterModeInOut, parameterModeInOut,
parameterModeOut, parameterModeOut,
parameterModeUnknown parameterModeUnknown
}; };
enum enum
{ {
parameterNoNulls, parameterNoNulls,
parameterNullable, parameterNullable,
parameterNullableUnknown parameterNullableUnknown
}; };
virtual sql::SQLString getParameterClassName(unsigned int param) = 0; virtual sql::SQLString getParameterClassName(unsigned int param) = 0;
virtual int getParameterCount() = 0; virtual int getParameterCount() = 0;
virtual int getParameterMode(unsigned int param) = 0; virtual int getParameterMode(unsigned int param) = 0;
virtual int getParameterType(unsigned int param) = 0; virtual int getParameterType(unsigned int param) = 0;
virtual sql::SQLString getParameterTypeName(unsigned int param) = 0; virtual sql::SQLString getParameterTypeName(unsigned int param) = 0;
virtual int getPrecision(unsigned int param) = 0; virtual int getPrecision(unsigned int param) = 0;
virtual int getScale(unsigned int param) = 0; virtual int getScale(unsigned int param) = 0;
virtual int isNullable(unsigned int param) = 0; virtual int isNullable(unsigned int param) = 0;
virtual bool isSigned(unsigned int param) = 0; virtual bool isSigned(unsigned int param) = 0;
protected: protected:
virtual ~ParameterMetaData() {} virtual ~ParameterMetaData() {}
}; };

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_PREPARED_STATEMENT_H_
@ -41,46 +49,48 @@ class ParameterMetaData;
class PreparedStatement : public Statement class PreparedStatement : public Statement
{ {
public: public:
virtual ~PreparedStatement() {} virtual ~PreparedStatement() {}
virtual void clearParameters() = 0; virtual void clearParameters() = 0;
virtual bool execute(const sql::SQLString& sql) = 0; virtual bool execute(const sql::SQLString& sql) = 0;
virtual bool execute() = 0; virtual bool execute() = 0;
virtual ResultSet *executeQuery(const sql::SQLString& sql) = 0; virtual ResultSet *executeQuery(const sql::SQLString& sql) = 0;
virtual ResultSet *executeQuery() = 0; virtual ResultSet *executeQuery() = 0;
virtual int executeUpdate(const sql::SQLString& sql) = 0; virtual int executeUpdate(const sql::SQLString& sql) = 0;
virtual int executeUpdate() = 0; virtual int executeUpdate() = 0;
virtual ResultSetMetaData * getMetaData() = 0; virtual ResultSetMetaData * getMetaData() = 0;
virtual ParameterMetaData * getParameterMetaData() = 0; virtual ParameterMetaData * getParameterMetaData() = 0;
virtual void setBigInt(unsigned int parameterIndex, const sql::SQLString& value) = 0; virtual bool getMoreResults() = 0;
virtual void setBlob(unsigned int parameterIndex, std::istream * blob) = 0; virtual void setBigInt(unsigned int parameterIndex, const sql::SQLString& value) = 0;
virtual void setBoolean(unsigned int parameterIndex, bool value) = 0; virtual void setBlob(unsigned int parameterIndex, std::istream * blob) = 0;
virtual void setDateTime(unsigned int parameterIndex, const sql::SQLString& value) = 0; virtual void setBoolean(unsigned int parameterIndex, bool value) = 0;
virtual void setDouble(unsigned int parameterIndex, double value) = 0; virtual void setDateTime(unsigned int parameterIndex, const sql::SQLString& value) = 0;
virtual void setInt(unsigned int parameterIndex, int32_t value) = 0; virtual void setDouble(unsigned int parameterIndex, double value) = 0;
virtual void setUInt(unsigned int parameterIndex, uint32_t value) = 0; virtual void setInt(unsigned int parameterIndex, int32_t value) = 0;
virtual void setInt64(unsigned int parameterIndex, int64_t value) = 0; virtual void setUInt(unsigned int parameterIndex, uint32_t value) = 0;
virtual void setUInt64(unsigned int parameterIndex, uint64_t value) = 0; virtual void setInt64(unsigned int parameterIndex, int64_t value) = 0;
virtual void setNull(unsigned int parameterIndex, int sqlType) = 0; virtual void setUInt64(unsigned int parameterIndex, uint64_t value) = 0;
virtual void setString(unsigned int parameterIndex, const sql::SQLString& value) = 0; virtual void setNull(unsigned int parameterIndex, int sqlType) = 0;
virtual PreparedStatement * setResultSetType(sql::ResultSet::enum_type type) = 0; virtual void setString(unsigned int parameterIndex, const sql::SQLString& value) = 0;
virtual PreparedStatement * setResultSetType(sql::ResultSet::enum_type type) = 0;
}; };

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_RESULTSET_H_
#define _SQL_RESULTSET_H_ #define _SQL_RESULTSET_H_
@ -42,137 +50,137 @@ class Statement;
class RowID class RowID
{ {
public: public:
virtual ~RowID() {} virtual ~RowID() {}
}; };
class ResultSet class ResultSet
{ {
public: public:
enum enum
{ {
CLOSE_CURSORS_AT_COMMIT, CLOSE_CURSORS_AT_COMMIT,
HOLD_CURSORS_OVER_COMMIT HOLD_CURSORS_OVER_COMMIT
}; };
enum enum
{ {
CONCUR_READ_ONLY, CONCUR_READ_ONLY,
CONCUR_UPDATABLE CONCUR_UPDATABLE
}; };
enum enum
{ {
FETCH_FORWARD, FETCH_FORWARD,
FETCH_REVERSE, FETCH_REVERSE,
FETCH_UNKNOWN FETCH_UNKNOWN
}; };
typedef enum typedef enum
{ {
TYPE_FORWARD_ONLY, TYPE_FORWARD_ONLY,
TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_INSENSITIVE,
TYPE_SCROLL_SENSITIVE TYPE_SCROLL_SENSITIVE
} enum_type; } enum_type;
virtual ~ResultSet() {} virtual ~ResultSet() {}
virtual bool absolute(int row) = 0; virtual bool absolute(int row) = 0;
virtual void afterLast() = 0; virtual void afterLast() = 0;
virtual void beforeFirst() = 0; virtual void beforeFirst() = 0;
virtual void cancelRowUpdates() = 0; virtual void cancelRowUpdates() = 0;
virtual void clearWarnings() = 0; virtual void clearWarnings() = 0;
virtual void close() = 0; virtual void close() = 0;
virtual uint32_t findColumn(const sql::SQLString& columnLabel) const = 0; virtual uint32_t findColumn(const sql::SQLString& columnLabel) const = 0;
virtual bool first() = 0; virtual bool first() = 0;
virtual std::istream * getBlob(uint32_t columnIndex) const = 0; virtual std::istream * getBlob(uint32_t columnIndex) const = 0;
virtual std::istream * getBlob(const sql::SQLString& columnLabel) const = 0; virtual std::istream * getBlob(const sql::SQLString& columnLabel) const = 0;
virtual bool getBoolean(uint32_t columnIndex) const = 0; virtual bool getBoolean(uint32_t columnIndex) const = 0;
virtual bool getBoolean(const sql::SQLString& columnLabel) const = 0; virtual bool getBoolean(const sql::SQLString& columnLabel) const = 0;
virtual int getConcurrency() = 0; virtual int getConcurrency() = 0;
virtual SQLString getCursorName() = 0; virtual SQLString getCursorName() = 0;
virtual long double getDouble(uint32_t columnIndex) const = 0; virtual long double getDouble(uint32_t columnIndex) const = 0;
virtual long double getDouble(const sql::SQLString& columnLabel) const = 0; virtual long double getDouble(const sql::SQLString& columnLabel) const = 0;
virtual int getFetchDirection() = 0; virtual int getFetchDirection() = 0;
virtual size_t getFetchSize() = 0; virtual size_t getFetchSize() = 0;
virtual int getHoldability() = 0; virtual int getHoldability() = 0;
virtual int32_t getInt(uint32_t columnIndex) const = 0; virtual int32_t getInt(uint32_t columnIndex) const = 0;
virtual int32_t getInt(const sql::SQLString& columnLabel) 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(uint32_t columnIndex) const = 0;
virtual uint32_t getUInt(const sql::SQLString& columnLabel) 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(uint32_t columnIndex) const = 0;
virtual int64_t getInt64(const sql::SQLString& columnLabel) 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(uint32_t columnIndex) const = 0;
virtual uint64_t getUInt64(const sql::SQLString& columnLabel) const = 0; virtual uint64_t getUInt64(const sql::SQLString& columnLabel) const = 0;
virtual ResultSetMetaData * getMetaData() const = 0; virtual ResultSetMetaData * getMetaData() const = 0;
virtual size_t getRow() const = 0; virtual size_t getRow() const = 0;
virtual RowID * getRowId(uint32_t columnIndex) = 0; virtual RowID * getRowId(uint32_t columnIndex) = 0;
virtual RowID * getRowId(const sql::SQLString & columnLabel) = 0; virtual RowID * getRowId(const sql::SQLString & columnLabel) = 0;
virtual const Statement * getStatement() const = 0; virtual const Statement * getStatement() const = 0;
virtual SQLString getString(uint32_t columnIndex) const = 0; virtual SQLString getString(uint32_t columnIndex) const = 0;
virtual SQLString getString(const sql::SQLString& columnLabel) const = 0; virtual SQLString getString(const sql::SQLString& columnLabel) const = 0;
virtual enum_type getType() const = 0; virtual enum_type getType() const = 0;
virtual void getWarnings() = 0; virtual void getWarnings() = 0;
virtual void insertRow() = 0; virtual void insertRow() = 0;
virtual bool isAfterLast() const = 0; virtual bool isAfterLast() const = 0;
virtual bool isBeforeFirst() const = 0; virtual bool isBeforeFirst() const = 0;
virtual bool isClosed() const = 0; virtual bool isClosed() const = 0;
virtual bool isFirst() const = 0; virtual bool isFirst() const = 0;
virtual bool isLast() const = 0; virtual bool isLast() const = 0;
virtual bool isNull(uint32_t columnIndex) const = 0; virtual bool isNull(uint32_t columnIndex) const = 0;
virtual bool isNull(const sql::SQLString& columnLabel) const = 0; virtual bool isNull(const sql::SQLString& columnLabel) const = 0;
virtual bool last() = 0; virtual bool last() = 0;
virtual bool next() = 0; virtual bool next() = 0;
virtual void moveToCurrentRow() = 0; virtual void moveToCurrentRow() = 0;
virtual void moveToInsertRow() = 0; virtual void moveToInsertRow() = 0;
virtual bool previous() = 0; virtual bool previous() = 0;
virtual void refreshRow() = 0; virtual void refreshRow() = 0;
virtual bool relative(int rows) = 0; virtual bool relative(int rows) = 0;
virtual bool rowDeleted() = 0; virtual bool rowDeleted() = 0;
virtual bool rowInserted() = 0; virtual bool rowInserted() = 0;
virtual bool rowUpdated() = 0; virtual bool rowUpdated() = 0;
virtual void setFetchSize(size_t rows) = 0; virtual void setFetchSize(size_t rows) = 0;
virtual size_t rowsCount() const = 0; virtual size_t rowsCount() const = 0;
virtual bool wasNull() const = 0; virtual bool wasNull() const = 0;
}; };
} /* namespace sql */ } /* namespace sql */

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_RESULTSET_METADATA_H_
#define _SQL_RESULTSET_METADATA_H_ #define _SQL_RESULTSET_METADATA_H_
@ -34,57 +42,63 @@ namespace sql
class ResultSetMetaData class ResultSetMetaData
{ {
public: public:
enum enum
{ {
columnNoNulls, columnNoNulls,
columnNullable, columnNullable,
columnNullableUnknown columnNullableUnknown
}; };
virtual SQLString getCatalogName(unsigned int column) = 0; virtual SQLString getCatalogName(unsigned int column) = 0;
virtual unsigned int getColumnCount() = 0; virtual unsigned int getColumnCount() = 0;
virtual unsigned int getColumnDisplaySize(unsigned int column) = 0; virtual unsigned int getColumnDisplaySize(unsigned int column) = 0;
virtual SQLString getColumnLabel(unsigned int column) = 0; virtual SQLString getColumnLabel(unsigned int column) = 0;
virtual SQLString getColumnName(unsigned int column) = 0; virtual SQLString getColumnName(unsigned int column) = 0;
virtual int getColumnType(unsigned int column) = 0; virtual int getColumnType(unsigned int column) = 0;
virtual SQLString getColumnTypeName(unsigned int column) = 0; virtual SQLString getColumnTypeName(unsigned int column) = 0;
virtual unsigned int getPrecision(unsigned int column) = 0; virtual SQLString getColumnCharset(unsigned int columnIndex) = 0;
virtual unsigned int getScale(unsigned int column) = 0; virtual SQLString getColumnCollation(unsigned int columnIndex) = 0;
virtual SQLString getSchemaName(unsigned int column) = 0; virtual unsigned int getPrecision(unsigned int column) = 0;
virtual SQLString getTableName(unsigned int column) = 0; virtual unsigned int getScale(unsigned int column) = 0;
virtual bool isAutoIncrement(unsigned int column) = 0; virtual SQLString getSchemaName(unsigned int column) = 0;
virtual bool isCaseSensitive(unsigned int column) = 0; virtual SQLString getTableName(unsigned int column) = 0;
virtual bool isCurrency(unsigned int column) = 0; virtual bool isAutoIncrement(unsigned int column) = 0;
virtual bool isDefinitelyWritable(unsigned int column) = 0; virtual bool isCaseSensitive(unsigned int column) = 0;
virtual int isNullable(unsigned int column) = 0; virtual bool isCurrency(unsigned int column) = 0;
virtual bool isReadOnly(unsigned int column) = 0; virtual bool isDefinitelyWritable(unsigned int column) = 0;
virtual bool isSearchable(unsigned int column) = 0; virtual int isNullable(unsigned int column) = 0;
virtual bool isSigned(unsigned int column) = 0; virtual bool isNumeric(unsigned int column) = 0;
virtual bool isWritable(unsigned int column) = 0; virtual bool isReadOnly(unsigned int column) = 0;
virtual bool isZerofill(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: protected:
virtual ~ResultSetMetaData() {} virtual ~ResultSetMetaData() {}
}; };

View File

@ -1,175 +1,208 @@
/* /*
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_STRING_H_
#define _SQL_STRING_H_ #define _SQL_STRING_H_
#include <string> #include <string>
#include <algorithm>
#include "build_config.h" #include "build_config.h"
#include <iostream> #include <iostream>
namespace sql namespace sql
{ {
class CPPCONN_PUBLIC_FUNC SQLString class CPPCONN_PUBLIC_FUNC SQLString
{ {
std::string realStr; std::string realStr;
public: public:
#ifdef _WIN32 #ifdef _WIN32
//TODO something less dirty-hackish. //TODO something less dirty-hackish.
static const size_t npos = static_cast<std::string::size_type>(-1); static const size_t npos = static_cast<std::string::size_type>(-1);
#else #else
static const size_t npos = std::string::npos; static const size_t npos = std::string::npos;
#endif #endif
~SQLString() {} ~SQLString() {}
SQLString() {} SQLString() {}
SQLString(const SQLString & other) : realStr(other.realStr) {} SQLString(const SQLString & other) : realStr(other.realStr) {}
SQLString(const std::string & other) : realStr(other) {} SQLString(const std::string & other) : realStr(other) {}
SQLString(const char other[]) : realStr(other) {} SQLString(const char other[]) : realStr(other) {}
SQLString(const char * s, size_t n) : realStr(s, n) {} SQLString(const char * s, size_t n) : realStr(s, n) {}
// Needed for stuff like SQLString str= "char * string constant" // Needed for stuff like SQLString str= "char * string constant"
const SQLString & operator=(const char * s) const SQLString & operator=(const char * s)
{ {
realStr = s; realStr = s;
return *this; return *this;
} }
const SQLString & operator=(const std::string & rhs) const SQLString & operator=(const std::string & rhs)
{ {
realStr = rhs; realStr = rhs;
return *this; return *this;
} }
const SQLString & operator=(const SQLString & rhs) const SQLString & operator=(const SQLString & rhs)
{ {
realStr = rhs.realStr; realStr = rhs.realStr;
return *this; return *this;
} }
// Conversion to st::string. Comes in play for stuff like std::string str= SQLString_var; // Conversion to st::string. Comes in play for stuff like std::string str= SQLString_var;
operator const std::string &() const operator const std::string &() const
{ {
return realStr; return realStr;
} }
/** For access std::string methods. Not sure we need it. Makes it look like some smart ptr. /** 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 */ possibly operator* - will look even more like smart ptr */
std::string * operator ->() std::string * operator ->()
{ {
return & realStr; return & realStr;
} }
int compare(const SQLString& str) const int compare(const SQLString& str) const
{ {
return realStr.compare(str.realStr); return realStr.compare(str.realStr);
} }
int compare(const char * s) const int compare(const char * s) const
{ {
return realStr.compare(s); return realStr.compare(s);
} }
int compare(size_t pos1, size_t n1, const char * s) const int compare(size_t pos1, size_t n1, const char * s) const
{ {
return realStr.compare(pos1, n1, s); return realStr.compare(pos1, n1, s);
} }
const std::string & asStdString() const int caseCompare(const SQLString &s) const
{ {
return realStr; 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);
}
const char * c_str() const int caseCompare(const char * s) const
{ {
return realStr.c_str(); 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);
}
size_t length() const int caseCompare(size_t pos1, size_t n1, const char * s) const
{ {
return realStr.length(); 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);
}
SQLString & append(const std::string & str) const std::string & asStdString() const
{ {
realStr.append(str); return realStr;
return *this; }
}
SQLString & append(const char * s) const char * c_str() const
{ {
realStr.append(s); return realStr.c_str();
return *this; }
}
const char& operator[](size_t pos) const size_t length() const
{ {
return realStr[pos]; return realStr.length();
} }
size_t find(char c, size_t pos = 0) const SQLString & append(const std::string & str)
{ {
return realStr.find(c, pos); realStr.append(str);
} return *this;
}
size_t find(const SQLString & s, size_t pos = 0) const SQLString & append(const char * s)
{ {
return realStr.find(s.realStr, pos); realStr.append(s);
} return *this;
}
SQLString substr(size_t pos = 0, size_t n = npos) const const char& operator[](size_t pos) const
{ {
return realStr.substr(pos, n); return realStr[pos];
} }
const SQLString& replace(size_t pos1, size_t n1, const SQLString & s) size_t find(char c, size_t pos = 0) const
{ {
realStr.replace(pos1, n1, s.realStr); return realStr.find(c, pos);
return *this; }
}
size_t find_first_of(char c, size_t pos = 0) const size_t find(const SQLString & s, size_t pos = 0) const
{ {
return realStr.find_first_of(c, pos); return realStr.find(s.realStr, pos);
} }
size_t find_last_of(char c, size_t pos = npos) const SQLString substr(size_t pos = 0, size_t n = npos) const
{ {
return realStr.find_last_of(c, pos); return realStr.substr(pos, n);
} }
const SQLString & operator+=(const SQLString & op2) const SQLString& replace(size_t pos1, size_t n1, const SQLString & s)
{ {
realStr += op2.realStr; realStr.replace(pos1, n1, s.realStr);
return *this; 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;
}
}; };
@ -178,22 +211,22 @@ namespace sql
*/ */
inline const SQLString operator+(const SQLString & op1, const SQLString & op2) inline const SQLString operator+(const SQLString & op1, const SQLString & op2)
{ {
return sql::SQLString(op1.asStdString() + op2.asStdString()); return sql::SQLString(op1.asStdString() + op2.asStdString());
} }
inline bool operator ==(const SQLString & op1, const SQLString & op2) inline bool operator ==(const SQLString & op1, const SQLString & op2)
{ {
return (op1.asStdString() == op2.asStdString()); return (op1.asStdString() == op2.asStdString());
} }
inline bool operator !=(const SQLString & op1, const SQLString & op2) inline bool operator !=(const SQLString & op1, const SQLString & op2)
{ {
return (op1.asStdString() != op2.asStdString()); return (op1.asStdString() != op2.asStdString());
} }
inline bool operator <(const SQLString & op1, const SQLString & op2) inline bool operator <(const SQLString & op1, const SQLString & op2)
{ {
return op1.asStdString() < op2.asStdString(); return op1.asStdString() < op2.asStdString();
} }
@ -202,10 +235,10 @@ inline bool operator <(const SQLString & op1, const SQLString & op2)
namespace std namespace std
{ {
// operator << for SQLString output // operator << for SQLString output
inline ostream & operator << (ostream & os, const sql::SQLString & str ) inline ostream & operator << (ostream & os, const sql::SQLString & str )
{ {
return os << str.asStdString(); return os << str.asStdString();
} }
} }
#endif #endif

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_STATEMENT_H_
#define _SQL_STATEMENT_H_ #define _SQL_STATEMENT_H_
@ -41,53 +49,53 @@ class SQLWarning;
class Statement class Statement
{ {
public: public:
virtual ~Statement() {}; virtual ~Statement() {};
virtual Connection * getConnection() = 0; virtual Connection * getConnection() = 0;
virtual void cancel() = 0; virtual void cancel() = 0;
virtual void clearWarnings() = 0; virtual void clearWarnings() = 0;
virtual void close() = 0; virtual void close() = 0;
virtual bool execute(const sql::SQLString& sql) = 0; virtual bool execute(const sql::SQLString& sql) = 0;
virtual ResultSet * executeQuery(const sql::SQLString& sql) = 0; virtual ResultSet * executeQuery(const sql::SQLString& sql) = 0;
virtual int executeUpdate(const sql::SQLString& sql) = 0; virtual int executeUpdate(const sql::SQLString& sql) = 0;
virtual size_t getFetchSize() = 0; virtual size_t getFetchSize() = 0;
virtual unsigned int getMaxFieldSize() = 0; virtual unsigned int getMaxFieldSize() = 0;
virtual uint64_t getMaxRows() = 0; virtual uint64_t getMaxRows() = 0;
virtual bool getMoreResults() = 0; virtual bool getMoreResults() = 0;
virtual unsigned int getQueryTimeout() = 0; virtual unsigned int getQueryTimeout() = 0;
virtual ResultSet * getResultSet() = 0; virtual ResultSet * getResultSet() = 0;
virtual sql::ResultSet::enum_type getResultSetType() = 0; virtual sql::ResultSet::enum_type getResultSetType() = 0;
virtual uint64_t getUpdateCount() = 0; virtual uint64_t getUpdateCount() = 0;
virtual const SQLWarning * getWarnings() = 0; virtual const SQLWarning * getWarnings() = 0;
virtual void setCursorName(const sql::SQLString & name) = 0; virtual void setCursorName(const sql::SQLString & name) = 0;
virtual void setEscapeProcessing(bool enable) = 0; virtual void setEscapeProcessing(bool enable) = 0;
virtual void setFetchSize(size_t rows) = 0; virtual void setFetchSize(size_t rows) = 0;
virtual void setMaxFieldSize(unsigned int max) = 0; virtual void setMaxFieldSize(unsigned int max) = 0;
virtual void setMaxRows(unsigned int max) = 0; virtual void setMaxRows(unsigned int max) = 0;
virtual void setQueryTimeout(unsigned int seconds) = 0; virtual void setQueryTimeout(unsigned int seconds) = 0;
virtual Statement * setResultSetType(sql::ResultSet::enum_type type) = 0; virtual Statement * setResultSetType(sql::ResultSet::enum_type type) = 0;
}; };
} /* namespace sql */ } /* namespace sql */

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _SQL_WARNING_H_
#define _SQL_WARNING_H_ #define _SQL_WARNING_H_
@ -43,26 +51,26 @@ class SQLWarning
{ {
public: public:
SQLWarning(){} SQLWarning(){}
virtual const sql::SQLString & getMessage() const = 0; virtual const sql::SQLString & getMessage() const = 0;
virtual const sql::SQLString & getSQLState() const = 0; virtual const sql::SQLString & getSQLState() const = 0;
virtual int getErrorCode() const = 0; virtual int getErrorCode() const = 0;
virtual const SQLWarning * getNextWarning() const = 0; virtual const SQLWarning * getNextWarning() const = 0;
virtual void setNextWarning(const SQLWarning * _next) = 0; virtual void setNextWarning(const SQLWarning * _next) = 0;
protected: protected:
virtual ~SQLWarning(){}; virtual ~SQLWarning(){};
SQLWarning(const SQLWarning& e){}; SQLWarning(const SQLWarning&){};
private: private:
const SQLWarning & operator = (const SQLWarning & rhs); const SQLWarning & operator = (const SQLWarning & rhs);
}; };

View File

@ -46,19 +46,6 @@
#include "httpdef.h" #include "httpdef.h"
#include "http_content.h" #include "http_content.h"
namespace hv {
struct NetAddr {
std::string ip;
int port;
std::string ipport() {
return hv::asprintf("%s:%d", ip.c_str(), port);
}
};
}
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
// Cookie: sessionid=1; domain=.example.com; path=/; max-age=86400; secure; httponly // Cookie: sessionid=1; domain=.example.com; path=/; max-age=86400; secure; httponly
struct HV_EXPORT HttpCookie { struct HV_EXPORT HttpCookie {
@ -297,6 +284,7 @@ public:
void* Content() { void* Content() {
if (content == NULL && body.size() != 0) { if (content == NULL && body.size() != 0) {
content = (void*)body.data(); content = (void*)body.data();
content_length = body.size();
} }
return content; return content;
} }

View File

@ -72,11 +72,9 @@ int main() {
return 200; return 200;
}); });
HttpServer server; HttpServer server(&service);
server.registerHttpService(&service);
server.setPort(8080);
server.setThreadNum(4); server.setThreadNum(4);
server.run(); server.run(":8080");
return 0; return 0;
} }
*/ */
@ -130,12 +128,20 @@ public:
return setSslCtx(ssl_ctx); return setSslCtx(ssl_ctx);
} }
int run(bool wait = true) { // run(":8080")
// run("0.0.0.0:8080")
// run("[::]:8080")
int run(const char* ip_port = NULL, bool wait = true) {
if (ip_port) {
hv::NetAddr listen_addr(ip_port);
if (listen_addr.ip.size() != 0) setHost(listen_addr.ip.c_str());
if (listen_addr.port != 0) setPort(listen_addr.port);
}
return http_server_run(this, wait); return http_server_run(this, wait);
} }
int start() { int start(const char* ip_port = NULL) {
return run(false); return run(ip_port, false);
} }
int stop() { int stop() {

View File

@ -60,6 +60,7 @@ public:
if (ret != 0) { if (ret != 0) {
perror("bind"); perror("bind");
} }
hio_set_localaddr(channel->io(), &local_addr.sa, SOCKADDR_LEN(&local_addr));
return ret; return ret;
} }

View File

@ -10,7 +10,7 @@
#endif #endif
#ifndef HAVE_STDATOMIC_H #ifndef HAVE_STDATOMIC_H
#define HAVE_STDATOMIC_H 1 #define HAVE_STDATOMIC_H 0
#endif #endif
#ifndef HAVE_SYS_TYPES_H #ifndef HAVE_SYS_TYPES_H
@ -22,7 +22,7 @@
#endif #endif
#ifndef HAVE_SYS_TIME_H #ifndef HAVE_SYS_TIME_H
#define HAVE_SYS_TIME_H 1 #define HAVE_SYS_TIME_H 0
#endif #endif
#ifndef HAVE_FCNTL_H #ifndef HAVE_FCNTL_H
@ -30,11 +30,11 @@
#endif #endif
#ifndef HAVE_PTHREAD_H #ifndef HAVE_PTHREAD_H
#define HAVE_PTHREAD_H 1 #define HAVE_PTHREAD_H 0
#endif #endif
#ifndef HAVE_ENDIAN_H #ifndef HAVE_ENDIAN_H
#define HAVE_ENDIAN_H 1 #define HAVE_ENDIAN_H 0
#endif #endif
#ifndef HAVE_SYS_ENDIAN_H #ifndef HAVE_SYS_ENDIAN_H
@ -54,46 +54,49 @@
#endif #endif
#ifndef HAVE_CLOCK_GETTIME #ifndef HAVE_CLOCK_GETTIME
#define HAVE_CLOCK_GETTIME 1 #define HAVE_CLOCK_GETTIME 0
#endif #endif
#ifndef HAVE_GETTIMEOFDAY #ifndef HAVE_GETTIMEOFDAY
#define HAVE_GETTIMEOFDAY 1 #define HAVE_GETTIMEOFDAY 0
#endif #endif
#ifndef HAVE_PTHREAD_SPIN_LOCK #ifndef HAVE_PTHREAD_SPIN_LOCK
#define HAVE_PTHREAD_SPIN_LOCK 1 #define HAVE_PTHREAD_SPIN_LOCK 0
#endif #endif
#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK #ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
#define HAVE_PTHREAD_MUTEX_TIMEDLOCK 1 #define HAVE_PTHREAD_MUTEX_TIMEDLOCK 0
#endif #endif
#ifndef HAVE_SEM_TIMEDWAIT #ifndef HAVE_SEM_TIMEDWAIT
#define HAVE_SEM_TIMEDWAIT 1 #define HAVE_SEM_TIMEDWAIT 0
#endif #endif
#ifndef HAVE_PIPE #ifndef HAVE_PIPE
#define HAVE_PIPE 1 #define HAVE_PIPE 0
#endif #endif
#ifndef HAVE_SOCKETPAIR #ifndef HAVE_SOCKETPAIR
#define HAVE_SOCKETPAIR 1 #define HAVE_SOCKETPAIR 0
#endif #endif
#ifndef HAVE_EVENTFD #ifndef HAVE_EVENTFD
#define HAVE_EVENTFD 1 #define HAVE_EVENTFD 0
#endif #endif
#ifndef HAVE_SETPROCTITLE #ifndef HAVE_SETPROCTITLE
#define HAVE_SETPROCTITLE 0 #define HAVE_SETPROCTITLE 0
#endif #endif
/* #undef WITH_OPENSSL */ #define WITH_OPENSSL 1
/* #undef WITH_GNUTLS */ /* #undef WITH_GNUTLS */
/* #undef WITH_MBEDTLS */ /* #undef WITH_MBEDTLS */
/* #undef ENABLE_UDS */ /* #undef ENABLE_UDS */
/* #undef USE_MULTIMAP */ /* #undef USE_MULTIMAP */
#define WITH_WEPOLL 1
/* #undef WITH_KCP */ /* #undef WITH_KCP */
#endif // HV_CONFIG_H_ #endif // HV_CONFIG_H_

View File

@ -31,7 +31,8 @@ typedef void (*hclose_cb) (hio_t* io);
typedef enum { typedef enum {
HLOOP_STATUS_STOP, HLOOP_STATUS_STOP,
HLOOP_STATUS_RUNNING, HLOOP_STATUS_RUNNING,
HLOOP_STATUS_PAUSE HLOOP_STATUS_PAUSE,
HLOOP_STATUS_DESTROY
} hloop_status_e; } hloop_status_e;
typedef enum { typedef enum {

View File

@ -75,6 +75,18 @@ HV_EXPORT std::string trim_pairs(const std::string& str, const char* pairs = PAI
HV_EXPORT std::string replace(const std::string& str, const std::string& find, const std::string& rep); HV_EXPORT std::string replace(const std::string& str, const std::string& find, const std::string& rep);
HV_EXPORT std::string replaceAll(const std::string& str, const std::string& find, const std::string& rep); HV_EXPORT std::string replaceAll(const std::string& str, const std::string& find, const std::string& rep);
struct HV_EXPORT NetAddr {
std::string ip;
int port;
NetAddr() : port(0) {}
NetAddr(const std::string& _ip, int _port) : ip(_ip), port(_port) {}
NetAddr(const std::string& ipport) { from_string(ipport); }
void from_string(const std::string& ipport);
std::string to_string();
};
} // end namespace hv } // end namespace hv
#endif // HV_STRING_H_ #endif // HV_STRING_H_

View File

@ -29,6 +29,7 @@ struct mqtt_client_s {
unsigned char alloced_ssl_ctx: 1; // intern unsigned char alloced_ssl_ctx: 1; // intern
unsigned char connected : 1; unsigned char connected : 1;
unsigned short keepalive; unsigned short keepalive;
int ping_cnt;
char client_id[64]; char client_id[64];
// will // will
mqtt_message_t* will; mqtt_message_t* will;
@ -125,4 +126,210 @@ HV_EXPORT int mqtt_client_unsubscribe(mqtt_client_t* cli,
END_EXTERN_C END_EXTERN_C
#ifdef __cplusplus
#include <functional>
#include <map>
#include <mutex>
#include <string>
namespace hv {
// @usage examples/mqtt/mqtt_client_test.cpp
class MqttClient {
public:
mqtt_client_t* client;
// callbacks
typedef std::function<void(MqttClient*)> MqttCallback;
typedef std::function<void(MqttClient*, mqtt_message_t*)> MqttMessageCallback;
MqttCallback onConnect;
MqttCallback onClose;
MqttMessageCallback onMessage;
MqttClient(hloop_t* loop = NULL) {
client = mqtt_client_new(loop);
}
~MqttClient() {
if (client) {
mqtt_client_free(client);
client = NULL;
}
}
void run() {
mqtt_client_set_callback(client, on_mqtt);
mqtt_client_set_userdata(client, this);
mqtt_client_run(client);
}
void stop() {
mqtt_client_stop(client);
}
void setID(const char* id) {
mqtt_client_set_id(client, id);
}
void setWill(mqtt_message_t* will) {
mqtt_client_set_will(client, will);
}
void setAuth(const char* username, const char* password) {
mqtt_client_set_auth(client, username, password);
}
void setPingInterval(int sec) {
client->keepalive = sec;
}
int lastError() {
return mqtt_client_get_last_error(client);
}
// SSL/TLS
int setSslCtx(hssl_ctx_t ssl_ctx) {
return mqtt_client_set_ssl_ctx(client, ssl_ctx);
}
int newSslCtx(hssl_ctx_opt_t* opt) {
return mqtt_client_new_ssl_ctx(client, opt);
}
void setReconnect(reconn_setting_t* reconn) {
mqtt_client_set_reconnect(client, reconn);
}
void setConnectTimeout(int ms) {
mqtt_client_set_connect_timeout(client, ms);
}
int connect(const char* host, int port = DEFAULT_MQTT_PORT, int ssl = 0) {
return mqtt_client_connect(client, host, port, ssl);
}
int reconnect() {
return mqtt_client_reconnect(client);
}
int disconnect() {
return mqtt_client_disconnect(client);
}
bool isConnected() {
return mqtt_client_is_connected(client);
}
int publish(mqtt_message_t* msg, MqttCallback ack_cb = NULL) {
int mid = mqtt_client_publish(client, msg);
if (msg->qos > 0 && mid >= 0 && ack_cb) {
setAckCallback(mid, ack_cb);
}
return mid;
}
int publish(const std::string& topic, const std::string& payload, int qos = 0, int retain = 0, MqttCallback ack_cb = NULL) {
mqtt_message_t msg;
memset(&msg, 0, sizeof(msg));
msg.topic_len = topic.size();
msg.topic = topic.c_str();
msg.payload_len = payload.size();
msg.payload = payload.c_str();
msg.qos = qos;
msg.retain = retain;
return publish(&msg, ack_cb);
}
int subscribe(const char* topic, int qos = 0, MqttCallback ack_cb = NULL) {
int mid = mqtt_client_subscribe(client, topic, qos);
if (qos > 0 && mid >= 0 && ack_cb) {
setAckCallback(mid, ack_cb);
}
return mid;
}
int unsubscribe(const char* topic, MqttCallback ack_cb = NULL) {
int mid = mqtt_client_unsubscribe(client, topic);
if (mid >= 0 && ack_cb) {
setAckCallback(mid, ack_cb);
}
return mid;
}
protected:
void setAckCallback(int mid, MqttCallback cb) {
ack_cbs_mutex.lock();
ack_cbs[mid] = std::move(cb);
ack_cbs_mutex.unlock();
}
void invokeAckCallback(int mid) {
MqttCallback ack_cb = NULL;
ack_cbs_mutex.lock();
auto iter = ack_cbs.find(mid);
if (iter != ack_cbs.end()) {
ack_cb = std::move(iter->second);
ack_cbs.erase(iter);
}
ack_cbs_mutex.unlock();
if (ack_cb) ack_cb(this);
}
static void on_mqtt(mqtt_client_t* cli, int type) {
MqttClient* client = (MqttClient*)mqtt_client_get_userdata(cli);
// printf("on_mqtt type=%d\n", type);
switch(type) {
case MQTT_TYPE_CONNECT:
// printf("mqtt connected!\n");
break;
case MQTT_TYPE_DISCONNECT:
// printf("mqtt disconnected!\n");
if (client->onClose) {
client->onClose(client);
}
break;
case MQTT_TYPE_CONNACK:
// printf("mqtt connack!\n");
if (client->onConnect) {
client->onConnect(client);
}
break;
case MQTT_TYPE_PUBLISH:
if (client->onMessage) {
client->onMessage(client, &cli->message);
}
break;
case MQTT_TYPE_PUBACK: /* qos = 1 */
// printf("mqtt puback mid=%d\n", cli->mid);
client->invokeAckCallback(cli->mid);
break;
case MQTT_TYPE_PUBREC: /* qos = 2 */
// printf("mqtt pubrec mid=%d\n", cli->mid);
// wait MQTT_TYPE_PUBCOMP
break;
case MQTT_TYPE_PUBCOMP: /* qos = 2 */
// printf("mqtt pubcomp mid=%d\n", cli->mid);
client->invokeAckCallback(cli->mid);
break;
case MQTT_TYPE_SUBACK:
// printf("mqtt suback mid=%d\n", cli->mid);
client->invokeAckCallback(cli->mid);
break;
case MQTT_TYPE_UNSUBACK:
// printf("mqtt unsuback mid=%d\n", cli->mid);
client->invokeAckCallback(cli->mid);
break;
default:
break;
}
}
private:
// mid => ack callback
std::map<int, MqttCallback> ack_cbs;
std::mutex ack_cbs_mutex;
};
}
#endif
#endif // HV_MQTT_CLIENT_H_ #endif // HV_MQTT_CLIENT_H_

View File

@ -21,7 +21,7 @@
#define _LIBICONV_H #define _LIBICONV_H
#define _LIBICONV_VERSION 0x0111 /* version number: (major<<8) + minor */ #define _LIBICONV_VERSION 0x0111 /* version number: (major<<8) + minor */
extern int _libiconv_version; /* Likewise */ extern __declspec (dllimport) int _libiconv_version; /* Likewise */
/* We would like to #include any system header file which could define /* We would like to #include any system header file which could define
iconv_t, 1. in order to eliminate the risk that the user gets compilation iconv_t, 1. in order to eliminate the risk that the user gets compilation

View File

@ -2,22 +2,33 @@
This file is part of the GNU CHARSET Library. This file is part of the GNU CHARSET Library.
The GNU CHARSET Library is free software; you can redistribute it and/or The GNU CHARSET Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version. License, or (at your option) any later version.
The GNU CHARSET Library is distributed in the hope that it will be useful, The GNU CHARSET Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Library General Public License
along with the GNU CHARSET Library; see the file COPYING.LIB. If not, along with the GNU CHARSET Library; see the file COPYING.LIB. If not,
see <https://www.gnu.org/licenses/>. */ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _LIBCHARSET_H #ifndef _LIBCHARSET_H
#define _LIBCHARSET_H #define _LIBCHARSET_H
#ifdef LIBCHARSET_STATIC
#define LIBCHARSET_DLL_EXPORTED
#else /* LIBCHARSET_STATIC */
#ifdef BUILDING_LIBCHARSET
#define LIBCHARSET_DLL_EXPORTED __declspec(dllexport)
#else
#define LIBCHARSET_DLL_EXPORTED __declspec(dllimport)
#endif
#endif /* LIBCHARSET_STATIC */
#include <localcharset.h> #include <localcharset.h>
@ -33,8 +44,8 @@ extern "C" {
by the corresponding pathname with the current prefix instead. Both by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use "" prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */ instead of "/"). */
extern void libcharset_set_relocation_prefix (const char *orig_prefix, extern LIBCHARSET_DLL_EXPORTED void libcharset_set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix); const char *curr_prefix);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,23 +1,34 @@
/* Determine a canonical name for the current locale's character encoding. /* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2003, 2009-2019 Free Software Foundation, Inc. Copyright (C) 2000-2003 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library. This file is part of the GNU CHARSET Library.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option) by the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Library General Public
along with this program; if not, see <https://www.gnu.org/licenses/>. */ License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef _LOCALCHARSET_H #ifndef _LOCALCHARSET_H
#define _LOCALCHARSET_H #define _LOCALCHARSET_H
#ifdef LIBCHARSET_STATIC
#define LIBCHARSET_DLL_EXPORTED
#else /* LIBCHARSET_STATIC */
#ifdef BUILDING_LIBCHARSET
#define LIBCHARSET_DLL_EXPORTED __declspec(dllexport)
#else
#define LIBCHARSET_DLL_EXPORTED __declspec(dllimport)
#endif
#endif /* LIBCHARSET_STATIC */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -25,108 +36,11 @@ extern "C" {
/* Determine the current locale's character encoding, and canonicalize it /* Determine the current locale's character encoding, and canonicalize it
into one of the canonical names listed below. into one of the canonical names listed in config.charset.
The result must not be freed; it is statically allocated. The result The result must not be freed; it is statically allocated.
becomes invalid when setlocale() is used to change the global locale, or
when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
is changed; threads in multithreaded programs should not do this.
If the canonical name cannot be determined, the result is a non-canonical If the canonical name cannot be determined, the result is a non-canonical
name. */ name. */
extern const char * locale_charset (void); extern LIBCHARSET_DLL_EXPORTED const char * locale_charset (void);
/* About GNU canonical names for character encodings:
Every canonical name must be supported by GNU libiconv. Support by GNU libc
is also desirable.
The name is case insensitive. Usually an upper case MIME charset name is
preferred.
The current list of these GNU canonical names is:
name MIME? used by which systems
(darwin = Mac OS X, windows = native Windows)
ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin
ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
ISO-8859-3 Y glibc solaris cygwin
ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin
ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
ISO-8859-6 Y glibc aix hpux solaris cygwin
ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
ISO-8859-8 Y glibc aix hpux osf solaris cygwin zos
ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin zos
ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
ISO-8859-14 glibc cygwin
ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin
KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin
KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
KOI8-T glibc
CP437 dos
CP775 dos
CP850 aix osf dos
CP852 dos
CP855 dos
CP856 aix
CP857 dos
CP861 dos
CP862 dos
CP864 dos
CP865 dos
CP866 freebsd netbsd openbsd darwin dos
CP869 dos
CP874 windows dos
CP922 aix
CP932 aix cygwin windows dos
CP943 aix zos
CP949 osf darwin windows dos
CP950 windows dos
CP1046 aix
CP1124 aix
CP1125 dos
CP1129 aix
CP1131 freebsd darwin
CP1250 windows
CP1251 glibc hpux solaris freebsd netbsd openbsd darwin cygwin windows
CP1252 aix windows
CP1253 windows
CP1254 windows
CP1255 glibc windows
CP1256 windows
CP1257 windows
GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin zos
EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin zos
EUC-TW glibc aix hpux irix osf solaris netbsd
BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin zos
BIG5-HKSCS glibc hpux solaris netbsd darwin
GBK glibc aix osf solaris freebsd darwin cygwin windows dos
GB18030 glibc hpux solaris freebsd netbsd darwin
SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
JOHAB glibc solaris windows
TIS-620 glibc aix hpux osf solaris cygwin zos
VISCII Y glibc
TCVN5712-1 glibc
ARMSCII-8 glibc freebsd netbsd darwin
GEORGIAN-PS glibc cygwin
PT154 glibc netbsd cygwin
HP-ROMAN8 hpux
HP-ARABIC8 hpux
HP-GREEK8 hpux
HP-HEBREW8 hpux
HP-TURKISH8 hpux
HP-KANA8 hpux
DEC-KANJI osf
DEC-HANYU osf
UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin zos
Note: Names which are not marked as being a MIME name should not be used in
Internet protocols for information interchange (mail, news, etc.).
Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
must understand both names and treat them as equivalent.
*/
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,32 +1,41 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _MYSQL_CONNECTION_H_
#define _MYSQL_CONNECTION_H_ #define _MYSQL_CONNECTION_H_
#include <cppconn/connection.h> #include <cppconn/connection.h>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
namespace sql namespace sql
{ {
@ -35,25 +44,26 @@ namespace mysql
class MySQL_Savepoint : public sql::Savepoint class MySQL_Savepoint : public sql::Savepoint
{ {
sql::SQLString name; sql::SQLString name;
public: public:
MySQL_Savepoint(const sql::SQLString &savepoint); MySQL_Savepoint(const sql::SQLString &savepoint);
virtual ~MySQL_Savepoint() {} virtual ~MySQL_Savepoint() {}
int getSavepointId(); int getSavepointId();
sql::SQLString getSavepointName(); sql::SQLString getSavepointName();
private: private:
/* Prevent use of these */ /* Prevent use of these */
MySQL_Savepoint(const MySQL_Savepoint &); MySQL_Savepoint(const MySQL_Savepoint &);
void operator=(MySQL_Savepoint &); void operator=(MySQL_Savepoint &);
}; };
class MySQL_DebugLogger; class MySQL_DebugLogger;
class MySQL_ConnectionData; /* PIMPL */ struct MySQL_ConnectionData; /* PIMPL */
class MySQL_Statement;
namespace NativeAPI namespace NativeAPI
{ {
@ -62,105 +72,123 @@ class NativeConnectionWrapper;
class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection
{ {
MySQL_Statement * createServiceStmt();
public: public:
MySQL_Connection(Driver * _driver, MySQL_Connection(Driver * _driver,
::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy, ::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy,
const sql::SQLString& hostName, const sql::SQLString& hostName,
const sql::SQLString& userName, const sql::SQLString& userName,
const sql::SQLString& password); const sql::SQLString& password);
MySQL_Connection(Driver * _driver, ::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy, MySQL_Connection(Driver * _driver, ::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy,
std::map< sql::SQLString, sql::ConnectPropertyVal > & options); std::map< sql::SQLString, sql::ConnectPropertyVal > & options);
virtual ~MySQL_Connection(); virtual ~MySQL_Connection();
void clearWarnings(); void clearWarnings();
void close(); void close();
void commit(); void commit();
sql::Statement * createStatement(); sql::Statement * createStatement();
sql::SQLString escapeString(const sql::SQLString &); sql::SQLString escapeString(const sql::SQLString &);
bool getAutoCommit(); bool getAutoCommit();
sql::SQLString getCatalog(); sql::SQLString getCatalog();
Driver *getDriver(); Driver *getDriver();
sql::SQLString getSchema(); sql::SQLString getSchema();
sql::SQLString getClientInfo(); sql::SQLString getClientInfo();
void getClientOption(const sql::SQLString & optionName, void * optionValue); void getClientOption(const sql::SQLString & optionName, void * optionValue);
sql::DatabaseMetaData * getMetaData(); sql::SQLString getClientOption(const sql::SQLString & optionName);
enum_transaction_isolation getTransactionIsolation(); sql::DatabaseMetaData * getMetaData();
const SQLWarning * getWarnings(); enum_transaction_isolation getTransactionIsolation();
bool isClosed(); const SQLWarning * getWarnings();
bool isReadOnly(); bool isClosed();
sql::SQLString nativeSQL(const sql::SQLString& sql); bool isReadOnly();
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql); bool isValid();
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys); bool reconnect();
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int columnIndexes[]); sql::SQLString nativeSQL(const sql::SQLString& sql);
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency); sql::PreparedStatement * prepareStatement(const sql::SQLString& sql);
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability); sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys);
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]); sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int columnIndexes[]);
void releaseSavepoint(Savepoint * savepoint) ; sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency);
void rollback(); sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability);
void rollback(Savepoint * savepoint); sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]);
void setAutoCommit(bool autoCommit); void releaseSavepoint(Savepoint * savepoint) ;
void setCatalog(const sql::SQLString& catalog); void rollback();
void setSchema(const sql::SQLString& catalog); void rollback(Savepoint * savepoint);
sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue); void setAutoCommit(bool autoCommit);
void setHoldability(int holdability); void setCatalog(const sql::SQLString& catalog);
void setReadOnly(bool readOnly); void setSchema(const sql::SQLString& catalog);
sql::Savepoint * setSavepoint(); sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue);
sql::Savepoint * setSavepoint(const sql::SQLString& name); sql::Connection * setClientOption(const sql::SQLString & optionName, const sql::SQLString & optionValue);
void setTransactionIsolation(enum_transaction_isolation level); void setHoldability(int holdability);
sql::SQLString getSessionVariable(const sql::SQLString & varname); void setReadOnly(bool readOnly);
void setSessionVariable(const sql::SQLString & varname, const sql::SQLString & value); sql::Savepoint * setSavepoint();
protected: sql::Savepoint * setSavepoint(const sql::SQLString& name);
void checkClosed();
void init(std::map< sql::SQLString, sql::ConnectPropertyVal > & properties);
Driver * driver; void setTransactionIsolation(enum_transaction_isolation level);
boost::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy;
MySQL_ConnectionData * intern; /* pimpl */ 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();
private: private:
/* Prevent use of these */ /* We do not really think this class has to be subclassed*/
MySQL_Connection(const MySQL_Connection &); void checkClosed();
void operator=(MySQL_Connection &); void init(std::map< sql::SQLString, sql::ConnectPropertyVal > & properties);
Driver * driver;
boost::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy;
/* statement handle to execute queries initiated by driver. Perhaps it is
a good idea to move it to a separate helper class */
boost::scoped_ptr< ::sql::mysql::MySQL_Statement > service;
boost::scoped_ptr< ::sql::mysql::MySQL_ConnectionData > intern; /* pimpl */
/* Prevent use of these */
MySQL_Connection(const MySQL_Connection &);
void operator=(MySQL_Connection &);
}; };
} /* namespace mysql */ } /* namespace mysql */

View File

@ -1,26 +1,34 @@
/* /*
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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
*/
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
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
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_ #ifndef _MYSQL_DRIVER_H_
#define _MYSQL_DRIVER_H_ #define _MYSQL_DRIVER_H_
@ -40,41 +48,41 @@ namespace mysql
{ {
namespace NativeAPI namespace NativeAPI
{ {
class NativeDriverWrapper; class NativeDriverWrapper;
} }
//class sql::mysql::NativeAPI::NativeDriverWrapper; //class sql::mysql::NativeAPI::NativeDriverWrapper;
class CPPCONN_PUBLIC_FUNC MySQL_Driver : public sql::Driver class CPPCONN_PUBLIC_FUNC MySQL_Driver : public sql::Driver
{ {
boost::scoped_ptr< ::sql::mysql::NativeAPI::NativeDriverWrapper > proxy; boost::scoped_ptr< ::sql::mysql::NativeAPI::NativeDriverWrapper > proxy;
public: public:
MySQL_Driver(); MySQL_Driver();
MySQL_Driver(const ::sql::SQLString & clientLib); MySQL_Driver(const ::sql::SQLString & clientLib);
virtual ~MySQL_Driver(); virtual ~MySQL_Driver();
sql::Connection * connect(const sql::SQLString& hostName, const sql::SQLString& userName, const sql::SQLString& password); sql::Connection * connect(const sql::SQLString& hostName, const sql::SQLString& userName, const sql::SQLString& password);
sql::Connection * connect(sql::ConnectOptionsMap & options); sql::Connection * connect(sql::ConnectOptionsMap & options);
int getMajorVersion(); int getMajorVersion();
int getMinorVersion(); int getMinorVersion();
int getPatchVersion(); int getPatchVersion();
const sql::SQLString & getName(); const sql::SQLString & getName();
void threadInit(); void threadInit();
void threadEnd(); void threadEnd();
private: private:
/* Prevent use of these */ /* Prevent use of these */
MySQL_Driver(const MySQL_Driver &); MySQL_Driver(const MySQL_Driver &);
void operator=(MySQL_Driver &); void operator=(MySQL_Driver &);
}; };
/** We do not hide the function if MYSQLCLIENT_STATIC_BINDING(or anything else) not defined /** We do not hide the function if MYSQLCLIENT_STATIC_BINDING(or anything else) not defined

View File

@ -7,6 +7,8 @@
#ifndef ZCONF_H #ifndef ZCONF_H
#define ZCONF_H #define ZCONF_H
/* #undef Z_PREFIX */
/* #undef Z_HAVE_UNISTD_H */
/* /*
* If you *really* need a unique prefix for all types and library functions, * If you *really* need a unique prefix for all types and library functions,
@ -433,11 +435,11 @@ typedef uLong FAR uLongf;
typedef unsigned long z_crc_t; typedef unsigned long z_crc_t;
#endif #endif
#if 1 /* was set to #if 1 by ./configure */ #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_UNISTD_H # define Z_HAVE_UNISTD_H
#endif #endif
#if 1 /* was set to #if 1 by ./configure */ #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_STDARG_H # define Z_HAVE_STDARG_H
#endif #endif