=== modified file 'CMakeLists.txt' --- CMakeLists.txt revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ CMakeLists.txt 2014-12-12 13:14:20 +0000 @@ -64,6 +64,21 @@ #----------------- # CPPFLAGS, CXXFLAGS and LDFLAGS from the environment +IF(CMAKE_ENABLE_C++11) + INCLUDE(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) + IF(COMPILER_SUPPORTS_CXX11) + MESSAGE(STATUS "Compiler supports C++11. Adding -std=c++11 flags") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + ELSEIF(COMPILER_SUPPORTS_CXX0X) + MESSAGE(STATUS "Compiler supports C++11. Adding -std=c++0x flag.") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + ELSE() + MESSAGE(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} doesn't support C++11. Please use a different compiler.") + ENDIF(COMPILER_SUPPORTS_CXX11) +ENDIF(CMAKE_ENABLE_C++11) + SET(MYSQLCPPCONN_COMPILE_FLAGS_ENV "$ENV{CPPFLAGS} ${MYSQL_CXXFLAGS} $ENV{CXXFLAGS}") MESSAGE(STATUS "Environment compile flags: ${MYSQLCPPCONN_COMPILE_FLAGS_ENV}") === modified file 'driver/mysql_art_resultset.cpp' --- driver/mysql_art_resultset.h revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ driver/mysql_art_resultset.h 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -124,7 +124,7 @@ typedef std::vector< MyVal > row_t; typedef std::list< row_t > rset_t; - MySQL_ArtResultSet(const StringList& fn, rset_t * const rset, boost::shared_ptr< MySQL_DebugLogger > & l); + MySQL_ArtResultSet(const StringList& fn, boost::shared_ptr< rset_t > &rset, boost::shared_ptr< MySQL_DebugLogger > & l); virtual ~MySQL_ArtResultSet(); bool absolute(int row); @@ -248,7 +248,7 @@ public: unsigned int num_fields; - boost::scoped_ptr< MySQL_ArtResultSet::rset_t > rset; + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rset; rset_t::iterator current_record; bool started; === modified file 'driver/mysql_connection.cpp' --- driver/mysql_art_resultset.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ driver/mysql_art_resultset.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -196,7 +196,7 @@ /* {{{ MySQL_ArtResultSet::MySQL_ArtResultSet() -I- */ -MySQL_ArtResultSet::MySQL_ArtResultSet(const StringList& fn, rset_t * const rs, boost::shared_ptr< MySQL_DebugLogger > & l) +MySQL_ArtResultSet::MySQL_ArtResultSet(const StringList& fn, boost::shared_ptr< rset_t > &rs, boost::shared_ptr< MySQL_DebugLogger > & l) : num_fields(static_cast(fn.size())), rset(rs), current_record(rset->begin()), started(false), field_index_to_name_map(new sql::SQLString[num_fields]), num_rows(rset->size()), row_position(0), is_closed(false), logger(l) === modified file 'driver/mysql_art_resultset.h' --- driver/mysql_connection.h revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ driver/mysql_connection.h 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -178,7 +178,7 @@ a good idea to move it to a separate helper class */ boost::scoped_ptr< ::sql::mysql::MySQL_Statement > service; - MySQL_ConnectionData * intern; /* pimpl */ + boost::scoped_ptr< ::sql::mysql::MySQL_ConnectionData > intern; /* pimpl */ /* Prevent use of these */ MySQL_Connection(const MySQL_Connection &); === modified file 'driver/mysql_metadata.cpp' --- driver/mysql_connection.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ driver/mysql_connection.cpp 2014-12-12 13:20:01 +0000 @@ -119,13 +119,13 @@ /* {{{ MySQL_Connection::MySQL_Connection() -I- */ MySQL_Connection::MySQL_Connection(Driver * _driver, - ::sql::mysql::NativeAPI::NativeConnectionWrapper& _proxy, - const sql::SQLString& hostName, - const sql::SQLString& userName, - const sql::SQLString& password) - : driver (_driver), - proxy (&_proxy), - intern (NULL) + ::sql::mysql::NativeAPI::NativeConnectionWrapper& _proxy, + const sql::SQLString& hostName, + const sql::SQLString& userName, + const sql::SQLString& password) + : driver (_driver), + proxy (&_proxy), + intern (NULL) { sql::ConnectOptionsMap connection_properties; connection_properties["hostName"] = hostName; @@ -133,15 +133,10 @@ connection_properties["password"] = password; boost::shared_ptr< MySQL_DebugLogger > tmp_logger(new MySQL_DebugLogger()); - std::auto_ptr< MySQL_ConnectionData > tmp_intern(new MySQL_ConnectionData(tmp_logger)); - intern = tmp_intern.get(); + intern.reset(new MySQL_ConnectionData(tmp_logger)); service.reset(createServiceStmt()); - init(connection_properties); - // No exception so far, thus intern can still point to the MySQL_ConnectionData object - // and in the dtor we will clean it up - tmp_intern.release(); } /* }}} */ @@ -153,15 +148,10 @@ : driver(_driver), proxy(&_proxy), intern(NULL) { boost::shared_ptr tmp_logger(new MySQL_DebugLogger()); - std::auto_ptr< MySQL_ConnectionData > tmp_intern(new MySQL_ConnectionData(tmp_logger)); - intern = tmp_intern.get(); + intern.reset(new MySQL_ConnectionData(tmp_logger)); service.reset(createServiceStmt()); - init(properties); - // No exception so far, thus intern can still point to the MySQL_ConnectionData object - // and in the dtor we will clean it up - tmp_intern.release(); } /* }}} */ @@ -178,8 +168,6 @@ { CPP_ENTER_WL(intern->logger, "MySQL_Connection::~MySQL_Connection"); } - - delete intern; } /* }}} */ === modified file 'driver/mysql_connection.h' --- driver/mysql_metadata.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ driver/mysql_metadata.cpp 2014-12-12 13:18:37 +0000 @@ -30,6 +30,7 @@ #include #include +#include #include #include "mysql_util.h" #include "mysql_connection.h" @@ -1429,7 +1430,7 @@ rs_field_data.push_back("NAME"); rs_field_data.push_back("DDL"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); while (native_rs->next()) { MySQL_ArtResultSet::row_t rs_data_row; @@ -1544,9 +1545,7 @@ rs_data->push_back(rs_data_row); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -1557,7 +1556,7 @@ MySQL_ConnectionMetaData::getSchemaObjectTypes() { CPP_ENTER("MySQL_ConnectionMetaData::getSchemaObjectTypes"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; rs_field_data.push_back("OBJECT_TYPE"); @@ -1583,9 +1582,7 @@ rs_data->push_back(rs_data_row); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -1657,7 +1654,7 @@ const sql::SQLString& /*typeNamePattern*/, const sql::SQLString& /*attributeNamePattern*/) { CPP_ENTER("MySQL_ConnectionMetaData::getAttributes"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; @@ -1683,9 +1680,7 @@ rs_field_data.push_back("SCOPE_TABLE"); rs_field_data.push_back("SOURCE_DATA_TYPE"); - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -1697,7 +1692,7 @@ const sql::SQLString& table, int /* scope */, bool /* nullable */) { CPP_ENTER("MySQL_ConnectionMetaData::getBestRowIdentifier"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; rs_field_data.push_back("SCOPE"); @@ -1733,9 +1728,7 @@ } } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -1745,7 +1738,7 @@ sql::ResultSet * MySQL_ConnectionMetaData::getCatalogs() { - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; @@ -1757,9 +1750,7 @@ rs_data->push_back(rs_data_row); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -1808,7 +1799,7 @@ rs_field_data.push_back("PRIVILEGE"); rs_field_data.push_back("IS_GRANTABLE"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); connection->getClientOption("metadataUseInfoSchema", (void *) &use_info_schema); @@ -1885,9 +1876,7 @@ } } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -1904,7 +1893,7 @@ sql::SQLString escapedTableNamePattern = connection->escapeString(tableNamePattern); sql::SQLString escapedColumnNamePattern = connection->escapeString(columnNamePattern); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; @@ -2107,9 +2096,7 @@ } } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -2136,7 +2123,7 @@ primaryCatalog.c_str(), foreignCatalog.c_str(), primarySchema.c_str(), foreignSchema.c_str(), primaryTable.c_str(), foreignTable.c_str()); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; rs_field_data.push_back("PKTABLE_CAT"); @@ -2240,9 +2227,7 @@ rs_data->push_back(rs_data_row); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } else { throw sql::MethodNotImplementedException("MySQL_ConnectionMetaData::getCrossReference"); @@ -2373,7 +2358,7 @@ { CPP_ENTER("MySQL_ConnectionMetaData::getExportedKeys"); CPP_INFO_FMT("catalog=%s schema=%s table=%s", catalog.c_str(), schema.c_str(), table.c_str()); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; rs_field_data.push_back("PKTABLE_CAT"); @@ -2474,9 +2459,7 @@ rs_data->push_back(rs_data_row); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } else { throw sql::MethodNotImplementedException("MySQL_ConnectionMetaData::getExportedKeys"); @@ -2661,7 +2644,7 @@ { CPP_ENTER("MySQL_ConnectionMetaData::getImportedKeys"); CPP_INFO_FMT("catalog=%s schema=%s table=%s", catalog.c_str(), schema.c_str(), table.c_str()); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; @@ -2831,9 +2814,7 @@ rs_data.get()->sort(compareImportedKeys); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -2858,7 +2839,7 @@ const sql::SQLString& table, bool unique, bool /* approximate */) { CPP_ENTER("MySQL_ConnectionMetaData::getIndexInfo"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; @@ -2968,9 +2949,7 @@ rs_data.get()->sort(compareIndexInfo); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -3225,7 +3204,7 @@ rs_field_data.push_back("PK_NAME"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); connection->getClientOption("metadataUseInfoSchema", (void *) &use_info_schema); @@ -3283,9 +3262,7 @@ } } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -3306,7 +3283,7 @@ rs_field_data.push_back("PK_NAME"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); connection->getClientOption("metadataUseInfoSchema", (void *) &use_info_schema); @@ -3371,9 +3348,7 @@ } } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -3404,11 +3379,9 @@ rs_field_data.push_back("NULLABLE"); rs_field_data.push_back("REMARKS"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; #endif } @@ -3434,7 +3407,7 @@ rs_field_data.push_back("REMARKS"); rs_field_data.push_back("PROCEDURE_TYPE"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); char procRetNoRes[5]; my_i_to_a(procRetNoRes, sizeof(procRetNoRes) - 1, procedureNoResult); @@ -3537,9 +3510,7 @@ } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -3571,7 +3542,7 @@ MySQL_ConnectionMetaData::getSchemas() { CPP_ENTER("MySQL_ConnectionMetaData::getSchemas"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; @@ -3597,9 +3568,7 @@ rs_data->push_back(rs_data_row); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -3626,7 +3595,7 @@ sql::SQLString escapedSchemaPattern = connection->escapeString(schemaPattern); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; rs_field_data.push_back("SCHEMA_CAT"); @@ -3649,9 +3618,7 @@ rs_data->push_back(rs_data_row); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -3667,7 +3634,7 @@ sql::SQLString escapedSchemaPattern = connection->escapeString(schemaPattern); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; rs_field_data.push_back("SCHEMA_CAT"); @@ -3690,9 +3657,7 @@ rs_data->push_back(rs_data_row); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -3804,11 +3769,9 @@ rs_field_data.push_back("TABLE_NAME"); rs_field_data.push_back("SUPERTABLE_NAME"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -3828,11 +3791,9 @@ rs_field_data.push_back("SUPERTYPE_SCHEM"); rs_field_data.push_back("SUPERTYPE_NAME"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -3925,7 +3886,7 @@ rs_field_data.push_back("PRIVILEGE"); rs_field_data.push_back("IS_GRANTABLE"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list< sql::SQLString > tableTypes; @@ -3978,9 +3939,7 @@ } } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -3997,7 +3956,7 @@ sql::SQLString escapedSchemaPattern = connection->escapeString(schemaPattern); sql::SQLString escapedTableNamePattern = connection->escapeString(tableNamePattern); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; rs_field_data.push_back("TABLE_CAT"); @@ -4087,9 +4046,7 @@ } } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -4106,7 +4063,7 @@ std::list rs_field_data; rs_field_data.push_back("TABLE_TYPE"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); for (unsigned int i = 0; i < 3; ++i) { if (server_version >= requiredVersion[i]) { @@ -4117,9 +4074,7 @@ } } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -4137,7 +4092,7 @@ sql::SQLString escapedSchemaPattern = connection->escapeString(schemaPattern); sql::SQLString escapedTableNamePattern = connection->escapeString(tableNamePattern); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; rs_field_data.push_back("TABLE_CAT"); @@ -4162,9 +4117,7 @@ rs_data->push_back(rs_data_row); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -4182,7 +4135,7 @@ sql::SQLString escapedSchemaPattern = connection->escapeString(schemaPattern); sql::SQLString escapedTableNamePattern = connection->escapeString(tableNamePattern); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); std::list rs_field_data; rs_field_data.push_back("TABLE_CAT"); @@ -4209,9 +4162,7 @@ rs_data->push_back(rs_data_row); } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -4262,7 +4213,7 @@ rs_field_data.push_back("SQL_DATETIME_SUB"); rs_field_data.push_back("NUM_PREC_RADIX"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); int i = 0; while (mysqlc_types[i].typeName) { @@ -4292,9 +4243,7 @@ ++i; } - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -4315,11 +4264,9 @@ rs_field_data.push_back("DATA_TYPE"); rs_field_data.push_back("REMARKS"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ @@ -4366,11 +4313,9 @@ rs_field_data.push_back("DECIMAL_DIGITS"); rs_field_data.push_back("PSEUDO_COLUMN"); - std::auto_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); + boost::shared_ptr< MySQL_ArtResultSet::rset_t > rs_data(new MySQL_ArtResultSet::rset_t()); - MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data.get(), logger); - // If there is no exception we can release otherwise on function exit memory will be freed - rs_data.release(); + MySQL_ArtResultSet * ret = new MySQL_ArtResultSet(rs_field_data, rs_data, logger); return ret; } /* }}} */ === modified file 'driver/mysql_resultbind.cpp' --- driver/mysql_resultbind.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ driver/mysql_resultbind.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -35,6 +35,8 @@ #include +#include + namespace sql { namespace mysql @@ -159,7 +161,7 @@ len.reset(new unsigned long[num_fields]); memset(len.get(), 0, sizeof(unsigned long) * num_fields); - std::auto_ptr< NativeAPI::NativeResultsetWrapper > resultMeta(proxy->result_metadata()); + boost::scoped_ptr< NativeAPI::NativeResultsetWrapper > resultMeta(proxy->result_metadata()); for (unsigned int i = 0; i < num_fields; ++i) { MYSQL_FIELD * field = resultMeta->fetch_field(); === modified file 'driver/mysql_resultset.h' --- driver/mysql_resultset.h revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ driver/mysql_resultset.h 2014-12-12 13:14:20 +0000 @@ -28,6 +28,7 @@ #define _MYSQL_RESULTSET_H_ #include +#include #include #include @@ -66,7 +67,7 @@ boost::shared_ptr< MySQL_DebugLogger > logger; - std::auto_ptr< MySQL_ResultSetMetaData > rs_meta; + boost::scoped_ptr< MySQL_ResultSetMetaData > rs_meta; sql::ResultSet::enum_type resultset_type; === modified file 'examples/connect.cpp' --- examples/connect.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/connect.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -36,6 +36,8 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++. You might not use it but directly include directly the different @@ -72,10 +74,10 @@ try { sql::Driver * driver = sql::mysql::get_driver_instance(); /* Using the Driver to create a connection */ - std::auto_ptr< sql::Connection > con(driver->connect(url, user, pass)); + boost::scoped_ptr< sql::Connection > con(driver->connect(url, user, pass)); /* Creating a "simple" statement - "simple" = not a prepared statement */ - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); /* Create a test table demonstrating the use of sql::Statement.execute() */ stmt->execute("USE " + database); @@ -101,7 +103,7 @@ Run a query which returns exactly one result set like SELECT Stored procedures (CALL) may return more than one result set */ - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id, label FROM test ORDER BY id ASC")); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id, label FROM test ORDER BY id ASC")); cout << "#\t Running 'SELECT id, label FROM test ORDER BY id ASC'" << endl; /* Number of rows in the result set */ @@ -127,7 +129,7 @@ { /* Fetching again but using type convertion methods */ - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id FROM test ORDER BY id DESC")); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id FROM test ORDER BY id DESC")); cout << "#\t Fetching 'SELECT id FROM test ORDER BY id DESC' using type conversion" << endl; row = 0; while (res->next()) { @@ -150,7 +152,7 @@ } { - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id, label FROM test WHERE id = 100")); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id, label FROM test WHERE id = 100")); res->next(); if ((res->getInt("id") != 100) || (res->getString("label") != "y")) { === modified file 'examples/connection_meta_schemaobj.cpp' --- examples/connection_meta_schemaobj.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/connection_meta_schemaobj.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -38,6 +38,8 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++ */ #include /* Connection parameter and sample data */ @@ -75,7 +77,7 @@ cout << driver->getMajorVersion() << "." << driver->getMinorVersion(); cout << "." << driver->getPatchVersion() << endl; - std::auto_ptr< sql::Connection > con(driver->connect(url, user, pass)); + boost::scoped_ptr< sql::Connection > con(driver->connect(url, user, pass)); sql::DatabaseMetaData * con_meta = con->getMetaData(); cout << "# CDBC (API) major version = " << con_meta->getCDBCMajorVersion() << endl; @@ -90,7 +92,7 @@ NOTE Connector C++ defines catalog = n/a, schema = MySQL database */ cout << "# List of available schemata/databases: "; - std::auto_ptr< sql::ResultSet > res(con_meta->getSchemas()); + boost::scoped_ptr< sql::ResultSet > res(con_meta->getSchemas()); /* just for fun... of course you can scroll and fetch in whatever order you want */ res->afterLast(); @@ -108,7 +110,7 @@ { /* What object types does getSchemaObjects support? */ cout << "# Supported Object types: "; - std::auto_ptr< sql::ResultSet > res(con_meta->getSchemaObjectTypes()); + boost::scoped_ptr< sql::ResultSet > res(con_meta->getSchemaObjectTypes()); while (res->next()) { cout << res->getString(1); if (!res->isLast()) { @@ -121,7 +123,7 @@ } - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); stmt->execute("USE " + database); stmt->execute("DROP TABLE IF EXISTS test1"); stmt->execute("CREATE TABLE test1(id INT, label CHAR(1))"); @@ -129,7 +131,7 @@ stmt->execute("CREATE TABLE test2(id INT, label CHAR(1))"); /* "" = empty string requests all types of objects */ - std::auto_ptr< sql::ResultSet > res(con_meta->getSchemaObjects(con->getCatalog(), con->getSchema(), "")); + boost::scoped_ptr< sql::ResultSet > res(con_meta->getSchemaObjects(con->getCatalog(), con->getSchema(), "")); row = 1; sql::ResultSetMetaData * res_meta = res->getMetaData(); while (res->next()) { @@ -217,7 +219,7 @@ cout << "#\t\t isSigned() = " << res_meta->isSigned(5) << endl; cout << "#\t\t isWritable() = " << res_meta->isWritable(5) << endl; - std::auto_ptr< sql::ResultSet > res_tables(con_meta->getTables(con->getCatalog(), database, "t%", table_types)); + boost::scoped_ptr< sql::ResultSet > res_tables(con_meta->getTables(con->getCatalog(), database, "t%", table_types)); sql::ResultSetMetaData * res_meta_tables = res_tables->getMetaData(); cout << "#" << endl; @@ -235,7 +237,7 @@ cout << "#" << endl; res_tables->first(); - std::auto_ptr< sql::ResultSet > res_columns(con_meta->getColumns(con->getCatalog(), database, "test1", "%")); + boost::scoped_ptr< sql::ResultSet > res_columns(con_meta->getColumns(con->getCatalog(), database, "test1", "%")); cout << "#" << "Columns in the table 'test1'..." << endl; cout << "#\t rowsCount() = " << res_columns->rowsCount() << endl; === modified file 'examples/debug_output.cpp' --- examples/debug_output.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/debug_output.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -81,6 +81,8 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++ */ #include /* Connection parameter and sample data */ @@ -106,7 +108,7 @@ try { /* Using the Driver to create a connection */ driver = sql::mysql::get_driver_instance(); - std::auto_ptr< sql::Connection > con(driver->connect(host, user, pass)); + boost::scoped_ptr< sql::Connection > con(driver->connect(host, user, pass)); /* Activate debug trace of the MySQL Client Library (C-API) @@ -116,12 +118,12 @@ con->setSchema(database); - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); stmt->execute("DROP TABLE IF EXISTS test"); stmt->execute("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label CHAR(1))"); cout << "#\t Test table created" << endl; - std::auto_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)")); + boost::scoped_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)")); for (i = 0; i < EXAMPLE_NUM_TEST_ROWS; i++) { prep_stmt->setInt(1, test_data[i].id); prep_stmt->setString(2, test_data[i].label); === modified file 'examples/dynamic_load.cpp' --- examples/dynamic_load.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/dynamic_load.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -35,12 +35,14 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++ */ #include /* Connection parameter and sample data */ #include "examples.h" -static void validateResultSet(std::auto_ptr< sql::ResultSet > & res, struct _test_data *min, struct _test_data *max); +static void validateResultSet(boost::scoped_ptr< sql::ResultSet > & res, struct _test_data *min, struct _test_data *max); using namespace std; @@ -104,10 +106,10 @@ connection_properties["password"] = pass; connection_properties["schema"] = database; - std::auto_ptr< sql::Connection > con(driver->connect(connection_properties)); + boost::scoped_ptr< sql::Connection > con(driver->connect(connection_properties)); /* Creating a "simple" statement - "simple" = not a prepared statement */ - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); stmt->execute("DROP TABLE IF EXISTS test"); stmt->execute("CREATE TABLE test(id INT, label CHAR(1))"); cout << "#\t Test table created" << endl; @@ -143,7 +145,7 @@ */ cout << "#\t Testing sql::Statement based resultset" << endl; { - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id, label FROM test ORDER BY id ASC")); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id, label FROM test ORDER BY id ASC")); validateResultSet(res, &min, &max); } @@ -151,8 +153,8 @@ cout << "#\t Testing sql::PreparedStatment based resultset" << endl; { - std::auto_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("SELECT id, label FROM test ORDER BY id ASC")); - std::auto_ptr< sql::ResultSet > res(prep_stmt->executeQuery()); + boost::scoped_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("SELECT id, label FROM test ORDER BY id ASC")); + boost::scoped_ptr< sql::ResultSet > res(prep_stmt->executeQuery()); validateResultSet(res, &min, &max); } @@ -191,7 +193,7 @@ return EXIT_SUCCESS; } -static void validateRow(std::auto_ptr< sql::ResultSet > & res, struct _test_data *exp) +static void validateRow(boost::scoped_ptr< sql::ResultSet > & res, struct _test_data *exp) { stringstream msg; @@ -206,7 +208,7 @@ } } -static void validateResultSet(std::auto_ptr< sql::ResultSet > & res, struct _test_data *min, struct _test_data *max) { +static void validateResultSet(boost::scoped_ptr< sql::ResultSet > & res, struct _test_data *min, struct _test_data *max) { size_t row; === modified file 'examples/exceptions.cpp' --- examples/exceptions.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/exceptions.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -35,6 +35,8 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++. You might not use it but directly include directly the different @@ -65,11 +67,11 @@ try { /* Using the Driver to create a connection */ driver = sql::mysql::get_driver_instance(); - std::auto_ptr< sql::Connection > con(driver->connect(host, user, pass)); + boost::scoped_ptr< sql::Connection > con(driver->connect(host, user, pass)); /* Run in autocommit mode */ con->setAutoCommit(1); - std::auto_ptr< sql::Savepoint > savepoint(NULL); + boost::scoped_ptr< sql::Savepoint > savepoint(NULL); try { // It makes no sense to set a savepoint in autocommit mode savepoint.reset(con->setSavepoint(string("before_insert"))); @@ -82,7 +84,7 @@ con->setSchema(database); - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); stmt->execute("DROP TABLE IF EXISTS test"); stmt->execute("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label CHAR(1))"); cout << "#\t Test table created" << endl; @@ -106,7 +108,7 @@ savepoint.reset(con->setSavepoint(string("before_insert"))); { - std::auto_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)")); + boost::scoped_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)")); for (i = 0; i < EXAMPLE_NUM_TEST_ROWS; i++) { prep_stmt->setInt(1, test_data[i].id); prep_stmt->setString(2, test_data[i].label); @@ -115,7 +117,7 @@ } try { - std::auto_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)")); + boost::scoped_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)")); prep_stmt->setInt(1, test_data[0].id); /* This will cause a duplicate index error */ prep_stmt->executeUpdate(); === modified file 'examples/prepared_statement.cpp' --- examples/prepared_statement.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/prepared_statement.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -63,6 +63,8 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++. You might not use it but directly include directly the different @@ -73,8 +75,8 @@ /* Connection parameter and sample data */ #include "examples.h" -bool prepare_execute(std::auto_ptr< sql::Connection > & con, const char *sql); -sql::Statement* emulate_prepare_execute(std::auto_ptr< sql::Connection > & con, const char *sql); +bool prepare_execute(boost::scoped_ptr< sql::Connection > & con, const char *sql); +sql::Statement* emulate_prepare_execute(boost::scoped_ptr< sql::Connection > & con, const char *sql); using namespace std; @@ -100,10 +102,10 @@ try { /* Using the Driver to create a connection */ driver = sql::mysql::get_driver_instance(); - std::auto_ptr< sql::Connection > con(driver->connect(url, user, pass)); + boost::scoped_ptr< sql::Connection > con(driver->connect(url, user, pass)); /* The usage of USE is not supported by the prepared statement protocol */ - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); stmt->execute("USE " + database); /* @@ -124,7 +126,7 @@ the example program will continue to do it to demonstrate the (ab)use of prepared statements (and to prove that you really can do more than SELECT with PS). */ - std::auto_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("DROP TABLE IF EXISTS test")); + boost::scoped_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("DROP TABLE IF EXISTS test")); prep_stmt->execute(); prepare_execute(con, "CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label CHAR(1))"); @@ -153,9 +155,9 @@ cout << "#\t Test table populated" << endl; /* We will reuse the SELECT a bit later... */ - std::auto_ptr< sql::PreparedStatement > prep_select(con->prepareStatement("SELECT id, label FROM test ORDER BY id ASC")); + boost::scoped_ptr< sql::PreparedStatement > prep_select(con->prepareStatement("SELECT id, label FROM test ORDER BY id ASC")); cout << "#\t Running 'SELECT id, label FROM test ORDER BY id ASC'" << endl; - std::auto_ptr< sql::ResultSet > res(prep_select->executeQuery()); + boost::scoped_ptr< sql::ResultSet > res(prep_select->executeQuery()); row = 0; while (res->next()) { cout << "#\t\t Row " << row << " - id = " << res->getInt("id"); @@ -278,7 +280,7 @@ } -bool prepare_execute(std::auto_ptr< sql::Connection > & con, const char *sql) +bool prepare_execute(boost::scoped_ptr< sql::Connection > & con, const char *sql) { sql::PreparedStatement * prep_stmt; @@ -290,7 +292,7 @@ } -sql::Statement* emulate_prepare_execute(std::auto_ptr< sql::Connection > & con, const char *sql) +sql::Statement* emulate_prepare_execute(boost::scoped_ptr< sql::Connection > & con, const char *sql) { sql::PreparedStatement *prep_stmt; sql::Statement *stmt = NULL; === modified file 'examples/pthreads.cpp' --- examples/pthreads.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/pthreads.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -102,7 +102,7 @@ int main(int argc, const char **argv) { sql::Driver *driver; - std::auto_ptr< sql::Connection > con; + boost::scoped_ptr< sql::Connection > con; url = (argc >= 2) ? argv[1] : EXAMPLE_HOST; user = (argc >= 3) ? argv[2] : EXAMPLE_USER; @@ -128,10 +128,10 @@ cout << "Main thread: creating thread 1..." << endl; /* A little bloat. - We don't want global auto_ptr objects. Therefore + We don't want global scoped_ptr objects. Therefore we wrap the object in an object. An alternative would have been to use global sql::Driver, sql::Connection - objects [plain objects and no auto_ptr] but then + objects [plain objects and no scoped_ptr] but then we'd have to add bloat for making sure we explicitly delete them, e.g. in case of an exception. It is not nice in either case. Let's use parameter struct. @@ -191,8 +191,8 @@ void* thread_one_action(void *arg) { int status; - std::auto_ptr< sql::Statement > stmt; - std::auto_ptr< sql::ResultSet > res; + boost::scoped_ptr< sql::Statement > stmt; + boost::scoped_ptr< sql::ResultSet > res; struct st_worker_thread_param *handles = (struct st_worker_thread_param*) arg; @@ -241,4 +241,4 @@ thread_finished = 1; return NULL; -} \ No newline at end of file +} === modified file 'examples/resultset.cpp' --- examples/resultset.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/resultset.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -35,12 +35,14 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++ */ #include /* Connection parameter and sample data */ #include "examples.h" -static void validateResultSet(std::auto_ptr< sql::ResultSet > & res, struct _test_data *min, struct _test_data *max); +static void validateResultSet(boost::scoped_ptr< sql::ResultSet > & res, struct _test_data *min, struct _test_data *max); using namespace std; @@ -66,12 +68,12 @@ try { /* Using the Driver to create a connection */ driver = sql::mysql::get_driver_instance(); - std::auto_ptr< sql::Connection > con(driver->connect(url, user, pass)); + boost::scoped_ptr< sql::Connection > con(driver->connect(url, user, pass)); con->setSchema(database); /* Creating a "simple" statement - "simple" = not a prepared statement */ - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); stmt->execute("DROP TABLE IF EXISTS test"); stmt->execute("CREATE TABLE test(id INT, label CHAR(1))"); cout << "#\t Test table created" << endl; @@ -107,7 +109,7 @@ */ cout << "#\t Testing sql::Statement based resultset" << endl; { - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id, label FROM test ORDER BY id ASC")); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id, label FROM test ORDER BY id ASC")); validateResultSet(res, &min, &max); } @@ -115,8 +117,8 @@ cout << "#\t Testing sql::PreparedStatment based resultset" << endl; { - std::auto_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("SELECT id, label FROM test ORDER BY id ASC")); - std::auto_ptr< sql::ResultSet > res(prep_stmt->executeQuery()); + boost::scoped_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("SELECT id, label FROM test ORDER BY id ASC")); + boost::scoped_ptr< sql::ResultSet > res(prep_stmt->executeQuery()); validateResultSet(res, &min, &max); } @@ -155,7 +157,7 @@ return EXIT_SUCCESS; } -static void validateRow(std::auto_ptr< sql::ResultSet > & res, struct _test_data *exp) +static void validateRow(boost::scoped_ptr< sql::ResultSet > & res, struct _test_data *exp) { stringstream msg; @@ -170,7 +172,7 @@ } } -static void validateResultSet(std::auto_ptr< sql::ResultSet > & res, struct _test_data *min, struct _test_data *max) { +static void validateResultSet(boost::scoped_ptr< sql::ResultSet > & res, struct _test_data *min, struct _test_data *max) { size_t row; === modified file 'examples/resultset_binary.cpp' --- examples/resultset_binary.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/resultset_binary.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -35,6 +35,8 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++ */ #include /* Connection parameter and sample data */ @@ -64,12 +66,12 @@ try { /* Using the Driver to create a connection */ driver = sql::mysql::get_driver_instance(); - std::auto_ptr< sql::Connection > con(driver->connect(url, user, pass)); + boost::scoped_ptr< sql::Connection > con(driver->connect(url, user, pass)); con->setSchema(database); /* Creating a "simple" statement - "simple" = not a prepared statement */ - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); stmt->execute("DROP TABLE IF EXISTS test"); stmt->execute("CREATE TABLE test(id INT, label CHAR(1), col_binary BINARY(4), col_varbinary VARBINARY(10))"); cout << "#\t Test table created" << endl; @@ -98,7 +100,7 @@ cout << "#\t Testing sql::Statement based resultset" << endl; { - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT * FROM test ORDER BY id ASC")); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT * FROM test ORDER BY id ASC")); int row = 0; while (res->next()) { cout << "#\t\t Row " << row << ", getRow() " << res->getRow(); === modified file 'examples/resultset_meta.cpp' --- examples/resultset_meta.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/resultset_meta.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -36,6 +36,8 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++. You might not use it but directly include directly the different @@ -46,7 +48,7 @@ /* Connection parameter and sample data */ #include "examples.h" -static void printResultSetMetaData(std::auto_ptr< sql::ResultSet > &res, std::auto_ptr< sql::ResultSet > &ps_res); +static void printResultSetMetaData(boost::scoped_ptr< sql::ResultSet > &res, boost::scoped_ptr< sql::ResultSet > &ps_res); using namespace std; @@ -70,12 +72,12 @@ try { /* Using the Driver to create a conection */ - std::auto_ptr< sql::Connection > con(sql::mysql::get_driver_instance()->connect(url, user, pass)); + boost::scoped_ptr< sql::Connection > con(sql::mysql::get_driver_instance()->connect(url, user, pass)); con->setSchema(database); /* Create a test table demonstrating the use of sql::Statement.execute() */ - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); stmt->execute("DROP TABLE IF EXISTS test"); stmt->execute("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label CHAR(1))"); cout << "#\t Test table created" << endl; @@ -92,25 +94,25 @@ cout << "#\t Test table populated" << endl; { - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id AS column_alias, label FROM test AS table_alias LIMIT 1")); - std::auto_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("SELECT id AS column_alias, label FROM test AS table_alias LIMIT 1")); - std::auto_ptr< sql::ResultSet > ps_res(prep_stmt->executeQuery()); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id AS column_alias, label FROM test AS table_alias LIMIT 1")); + boost::scoped_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("SELECT id AS column_alias, label FROM test AS table_alias LIMIT 1")); + boost::scoped_ptr< sql::ResultSet > ps_res(prep_stmt->executeQuery()); cout << "#\t SELECT id AS column_alias, label FROM test AS table_alias LIMIT 1" << endl; printResultSetMetaData(res, ps_res); } { - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT 1.01, 'Hello world!'")); - std::auto_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("SELECT 1.01, 'Hello world!'")); - std::auto_ptr< sql::ResultSet > ps_res(prep_stmt->executeQuery()); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT 1.01, 'Hello world!'")); + boost::scoped_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("SELECT 1.01, 'Hello world!'")); + boost::scoped_ptr< sql::ResultSet > ps_res(prep_stmt->executeQuery()); cout << "#\t SELECT 1.01, 'Hello world!'" << endl; printResultSetMetaData(res, ps_res); } { - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("DESCRIBE test")); - std::auto_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("DESCRIBE test")); - std::auto_ptr< sql::ResultSet > ps_res(prep_stmt->executeQuery()); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("DESCRIBE test")); + boost::scoped_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("DESCRIBE test")); + boost::scoped_ptr< sql::ResultSet > ps_res(prep_stmt->executeQuery()); cout << "# \tDESCRIBE test" << endl; printResultSetMetaData(res, ps_res); } @@ -156,7 +158,7 @@ * Prints all meta data associated with an result set * */ -static void printResultSetMetaData(std::auto_ptr< sql::ResultSet > &res, std::auto_ptr< sql::ResultSet > &ps_res) +static void printResultSetMetaData(boost::scoped_ptr< sql::ResultSet > &res, boost::scoped_ptr< sql::ResultSet > &ps_res) { /* ResultSetMetaData object */ sql::ResultSetMetaData * meta; === modified file 'examples/resultset_types.cpp' --- examples/resultset_types.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/resultset_types.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -35,6 +35,8 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++ */ #include /* Connection parameter and sample data */ @@ -72,10 +74,10 @@ try { /* Using the Driver to create a connection */ driver = sql::mysql::get_driver_instance(); - std::auto_ptr< sql::Connection > con(driver->connect(url, user, pass)); + boost::scoped_ptr< sql::Connection > con(driver->connect(url, user, pass)); con->setSchema(database); - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); stmt->execute("DROP TABLE IF EXISTS test"); /* @@ -89,7 +91,7 @@ "c_long BIGINT, c_double DOUBLE, c_null INT DEFAULT NULL)"); cout << "#\t Test table created" << endl; - std::auto_ptr< sql::PreparedStatement> prep_stmt( + boost::scoped_ptr< sql::PreparedStatement> prep_stmt( con->prepareStatement("INSERT INTO test(id, label, c_bool, c_long, " " c_double) VALUES (?, ?, ?, ?, ?)")); @@ -113,7 +115,7 @@ } cout << "#\t Test table populated" << endl; - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id, label, c_bool, c_long, c_double, c_null FROM test ORDER BY id ASC")); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT id, label, c_bool, c_long, c_double, c_null FROM test ORDER BY id ASC")); while (res->next()) { /* sql::ResultSet.rowsCount() returns size_t */ size_t row = res->getRow() - 1; === modified file 'examples/standalone_example.cpp' --- examples/standalone_example.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/standalone_example.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -56,6 +56,8 @@ #include #include +#include + /* Include directly the different @@ -94,11 +96,11 @@ try { sql::Driver * driver = sql::mysql::get_driver_instance(); /* Using the Driver to create a connection */ - std::auto_ptr< sql::Connection > con(driver->connect(url, user, pass)); + boost::scoped_ptr< sql::Connection > con(driver->connect(url, user, pass)); con->setSchema(database); - std::auto_ptr< sql::Statement > stmt(con->createStatement()); - std::auto_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT 'Welcome to Connector/C++' AS _message")); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::ResultSet > res(stmt->executeQuery("SELECT 'Welcome to Connector/C++' AS _message")); cout << "\t... running 'SELECT 'Welcome to Connector/C++' AS _message'" << endl; while (res->next()) { cout << "\t... MySQL replies: " << res->getString("_message") << endl; === modified file 'examples/statement.cpp' --- examples/statement.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ examples/statement.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -35,6 +35,8 @@ #include #include +#include + /* Public interface of the MySQL Connector/C++ */ #include /* Connection parameter and sample data */ @@ -68,11 +70,11 @@ try { /* Using the Driver to create a connection */ driver = sql::mysql::get_driver_instance(); - std::auto_ptr< sql::Connection > con(driver->connect(url, user, pass)); + boost::scoped_ptr< sql::Connection > con(driver->connect(url, user, pass)); con->setSchema(database); /* Creating a "simple" statement - "simple" = not a prepared statement */ - std::auto_ptr< sql::Statement > stmt(con->createStatement()); + boost::scoped_ptr< sql::Statement > stmt(con->createStatement()); /* Create a test table demonstrating the use of sql::Statement.execute() */ stmt->execute("DROP TABLE IF EXISTS test"); @@ -105,7 +107,7 @@ NOTE: If stmt.getMoreResults() would be implemented already one would use a do { ... } while (stmt.getMoreResults()) loop */ - std::auto_ptr< sql::ResultSet > res(stmt->getResultSet()); + boost::scoped_ptr< sql::ResultSet > res(stmt->getResultSet()); row = 0; while (res->next()) { cout << "#\t\t Row " << row << " - id = " << res->getInt("id"); === modified file 'test/CJUnitTestsPort/BaseTestFixture.h' --- test/CJUnitTestsPort/BaseTestFixture.h revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/CJUnitTestsPort/BaseTestFixture.h 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -29,6 +29,7 @@ #define _BASE_TEST_FIXTURE_ #include +#include #include "resources.h" #include @@ -52,10 +53,10 @@ namespace testsuite { -typedef std::auto_ptr Connection; -typedef std::auto_ptr PreparedStatement; -typedef std::auto_ptr Statement; -typedef std::auto_ptr ResultSet; +typedef boost::scoped_ptr Connection; +typedef boost::scoped_ptr PreparedStatement; +typedef boost::scoped_ptr Statement; +typedef boost::scoped_ptr ResultSet; typedef sql::Driver Driver; typedef sql::ResultSetMetaData * ResultSetMetaData; typedef sql::DatabaseMetaData * DatabaseMetaData; @@ -106,7 +107,7 @@ bool instanceof(value_type type); }; -typedef std::auto_ptr Object; +typedef boost::scoped_ptr Object; value_object * getObject(sql::ResultSet * rs, int colNum); === modified file 'test/CJUnitTestsPort/simple/BlobTest.cpp' --- test/CJUnitTestsPort/simple/BlobTest.h revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/CJUnitTestsPort/simple/BlobTest.h 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -25,6 +25,7 @@ #include +#include #include "../../common/file.h" @@ -46,7 +47,7 @@ private: typedef BaseTestFixture super; - std::auto_ptr testBlobFile; + boost::scoped_ptr testBlobFile; bool realFrameworkTiming; === modified file 'test/framework/test_listener.h' --- test/CJUnitTestsPort/simple/BlobTest.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/CJUnitTestsPort/simple/BlobTest.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -28,7 +28,6 @@ #include #include "BlobTest.h" -#include #define BYTE_MAX_VALUE 255 #define BYTE_MIN_VALUE 0 === modified file 'test/CJUnitTestsPort/simple/BlobTest.h' --- test/framework/test_listener.h revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/framework/test_listener.h 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -33,6 +33,8 @@ #include #include +#include + #include "start_options.h" #include "test_tapOutputter.h" #include @@ -53,7 +55,7 @@ { CCPP_SINGLETON(TestsListener); - std::auto_ptr outputter; + boost::scoped_ptr outputter; String curSuiteName; String curTestName; === modified file 'test/test_common.cpp' --- test/test_common.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/test_common.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -34,6 +34,8 @@ #include #endif +#include + /* __FUNCTION__/__func__ is not portable. We do not promise that our example definition covers each and every compiler. @@ -119,9 +121,9 @@ /* {{{ */ -static bool populate_blob_table(std::auto_ptr & conn, std::string database) +static bool populate_blob_table(boost::scoped_ptr & conn, std::string database) { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); stmt->execute("USE " + database); @@ -143,9 +145,9 @@ /* {{{ */ -static bool populate_test_table(std::auto_ptr & conn, std::string database) +static bool populate_test_table(boost::scoped_ptr & conn, std::string database) { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); stmt->execute("USE " + database); @@ -172,9 +174,9 @@ /* {{{ */ -static bool populate_TX_test_table(std::auto_ptr & conn, std::string database) +static bool populate_TX_test_table(boost::scoped_ptr & conn, std::string database) { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); stmt->execute("USE " + database); @@ -194,21 +196,21 @@ /* {{{ */ -static bool populate_test_table_PS(std::auto_ptr & conn, std::string database) +static bool populate_test_table_PS(boost::scoped_ptr & conn, std::string database) { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); stmt1->execute("USE " + database); - std::auto_ptr stmt2(conn->prepareStatement("DROP TABLE IF EXISTS test_function")); + boost::scoped_ptr stmt2(conn->prepareStatement("DROP TABLE IF EXISTS test_function")); ensure("stmt2 is NULL", stmt2.get() != NULL); stmt2->executeUpdate(); - std::auto_ptr stmt3(conn->prepareStatement("CREATE TABLE test_function(a integer unsigned not null, b integer, c integer default null, d char(10), e varchar(10) character set utf8 collate utf8_bin)")); + boost::scoped_ptr stmt3(conn->prepareStatement("CREATE TABLE test_function(a integer unsigned not null, b integer, c integer default null, d char(10), e varchar(10) character set utf8 collate utf8_bin)")); ensure("stmt3 is NULL", stmt3.get() != NULL); stmt3->executeUpdate(); - std::auto_ptr stmt4(conn->prepareStatement("INSERT INTO test_function (a,b,c,d,e) VALUES(1, 111, NULL, '222', 'xyz')")); + boost::scoped_ptr stmt4(conn->prepareStatement("INSERT INTO test_function (a,b,c,d,e) VALUES(1, 111, NULL, '222', 'xyz')")); ensure("stmt4 is NULL", stmt4.get() != NULL); stmt4->executeUpdate(); @@ -218,21 +220,21 @@ /* {{{ */ -static bool populate_TX_test_table_PS(std::auto_ptr & conn, std::string database) +static bool populate_TX_test_table_PS(boost::scoped_ptr & conn, std::string database) { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt is NULL", stmt1.get() != NULL); stmt1->execute("USE " + database); - std::auto_ptr stmt2(conn->prepareStatement("DROP TABLE IF EXISTS test_function_tx")); + boost::scoped_ptr stmt2(conn->prepareStatement("DROP TABLE IF EXISTS test_function_tx")); ensure("stmt2 is NULL", stmt2.get() != NULL); stmt2->executeUpdate(); - std::auto_ptr stmt3(conn->prepareStatement("CREATE TABLE test_function_tx(a integer unsigned not null, b integer, c integer default null, d char(10), e varchar(10) character set utf8 collate utf8_bin) engine = innodb")); + boost::scoped_ptr stmt3(conn->prepareStatement("CREATE TABLE test_function_tx(a integer unsigned not null, b integer, c integer default null, d char(10), e varchar(10) character set utf8 collate utf8_bin) engine = innodb")); ensure("stmt3 is NULL", stmt3.get() != NULL); stmt3->executeUpdate(); - std::auto_ptr stmt4(conn->prepareStatement("INSERT INTO test_function_tx (a,b,c,d,e) VALUES(1, 111, NULL, '222', 'xyz')")); + boost::scoped_ptr stmt4(conn->prepareStatement("INSERT INTO test_function_tx (a,b,c,d,e) VALUES(1, 111, NULL, '222', 'xyz')")); ensure("stmt4 is NULL", stmt4.get() != NULL); stmt4->executeUpdate(); @@ -242,17 +244,17 @@ /* {{{ */ -static bool populate_test_table_PS_integers(std::auto_ptr & conn, std::string database) +static bool populate_test_table_PS_integers(boost::scoped_ptr & conn, std::string database) { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); stmt1->execute("USE " + database); - std::auto_ptr stmt2(conn->prepareStatement("DROP TABLE IF EXISTS test_function_int")); + boost::scoped_ptr stmt2(conn->prepareStatement("DROP TABLE IF EXISTS test_function_int")); ensure("stmt2 is NULL", stmt2.get() != NULL); stmt2->executeUpdate(); - std::auto_ptr stmt3(conn->prepareStatement("CREATE TABLE test_function_int(i integer, i_uns integer unsigned, b bigint, b_uns bigint unsigned)")); + boost::scoped_ptr stmt3(conn->prepareStatement("CREATE TABLE test_function_int(i integer, i_uns integer unsigned, b bigint, b_uns bigint unsigned)")); ensure("stmt3 is NULL", stmt3.get() != NULL); stmt3->executeUpdate(); @@ -262,7 +264,7 @@ /* {{{ */ -static void test_autocommit(std::auto_ptr & conn) +static void test_autocommit(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { @@ -282,15 +284,15 @@ /* {{{ */ -static void test_connection_0(std::auto_ptr & conn) +static void test_connection_0(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { char buff[64]; - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); - std::auto_ptr rset1(stmt1->executeQuery("SELECT CONNECTION_ID()")); + boost::scoped_ptr rset1(stmt1->executeQuery("SELECT CONNECTION_ID()")); ensure("res1 is NULL", rset1.get() != NULL); ensure("res1 is empty", rset1->next() != false); @@ -308,7 +310,7 @@ */ } try { - std::auto_ptr rset2(stmt1->executeQuery("SELECT CONNECTION_ID()")); + boost::scoped_ptr rset2(stmt1->executeQuery("SELECT CONNECTION_ID()")); ensure("no exception", false); } catch (sql::SQLException &) { ensure("Exception correctly thrown", true); @@ -325,28 +327,28 @@ /* {{{ */ -static void test_connection_1(std::auto_ptr & conn, std::string database) +static void test_connection_1(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); ensure("connection is closed", !conn->isClosed()); conn->setAutoCommit(false); ensure("Data not populated", true == populate_TX_test_table(conn, database)); - std::auto_ptr rset1(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset1(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res1 is NULL", rset1.get() != NULL); ensure("res1 is empty", rset1->next() != false); int count_full_before = rset1->getInt(1); ensure_equal_int("res1 has more rows ", rset1->next(), false); std::string savepointName("firstSavePoint"); - std::auto_ptr savepoint(conn->setSavepoint(savepointName)); + boost::scoped_ptr savepoint(conn->setSavepoint(savepointName)); populate_TX_insert_data(stmt1.get()); - std::auto_ptr rset2(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset2(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res2 is NULL", rset2.get() != NULL); ensure_equal_int("res2 is empty", rset2->next(), true); int count_full_after = rset2->getInt(1); @@ -354,7 +356,7 @@ ensure_equal_int("wrong number of rows", count_full_after, (count_full_before * 2)); conn->rollback(savepoint.get()); - std::auto_ptr rset3(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset3(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res3 is NULL", rset3.get() != NULL); ensure_equal_int("res3 is empty", rset3->next(), true); int count_full_after_rollback = rset3->getInt(1); @@ -385,11 +387,11 @@ /* {{{ */ -static void test_connection_2(std::auto_ptr & conn, std::string database) +static void test_connection_2(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt1 is NULL", stmt.get() != NULL); ensure("Wrong catalog", conn->getCatalog() == "def" || conn->getCatalog() == ""); @@ -419,7 +421,7 @@ /* {{{ */ -static void test_connection_3(std::auto_ptr & conn, std::string user) +static void test_connection_3(boost::scoped_ptr & conn, std::string user) { ENTER_FUNCTION(); try { @@ -436,11 +438,11 @@ /* {{{ */ -static void test_statement_0(std::auto_ptr & conn) +static void test_statement_0(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("AutoCommit", conn.get() == stmt->getConnection()); } catch (sql::SQLException &e) { printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); @@ -453,11 +455,11 @@ /* {{{ Test simple update statement against statement object */ -static void test_statement_1(std::auto_ptr & conn, std::auto_ptr & conn2, std::string database) +static void test_statement_1(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); @@ -465,7 +467,7 @@ ensure("False returned for SELECT", false); /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); stmt2->execute("DROP TABLE test_function"); @@ -484,11 +486,11 @@ /* {{{ Test simple query against statement object */ -static void test_statement_2(std::auto_ptr & conn, std::auto_ptr & conn2, std::string database) +static void test_statement_2(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); @@ -496,7 +498,7 @@ ensure("False returned for SELECT", false); /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); stmt2->execute("DROP TABLE test_function"); @@ -515,17 +517,17 @@ /* {{{ Test executeQuery() - returning a result set*/ -static void test_statement_3(std::auto_ptr & conn, std::auto_ptr & conn2, std::string database) +static void test_statement_3(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); /* Get a result set */ try { - std::auto_ptr rset(stmt->executeQuery("SELECT * FROM test_function")); + boost::scoped_ptr rset(stmt->executeQuery("SELECT * FROM test_function")); ensure("NULL returned for result set", rset.get() != NULL); } catch (sql::SQLException &e) { printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); @@ -534,7 +536,7 @@ } /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); stmt2->execute("DROP TABLE test_function"); @@ -553,17 +555,17 @@ /* {{{ Test executeQuery() - returning empty result set */ -static void test_statement_4(std::auto_ptr & conn, std::auto_ptr & conn2, std::string database) +static void test_statement_4(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); /* Get a result set */ try { - std::auto_ptr rset(stmt->executeQuery("SELECT * FROM test_function WHERE 1=2")); + boost::scoped_ptr rset(stmt->executeQuery("SELECT * FROM test_function WHERE 1=2")); ensure("NULL returned for result set", rset.get() != NULL); ensure_equal_int("Non-empty result set", false, rset->next()); @@ -574,7 +576,7 @@ } /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); stmt2->execute("DROP TABLE test_function"); @@ -593,17 +595,17 @@ /* {{{ Test executeQuery() - use it for inserting, should generate an exception */ -static void test_statement_5(std::auto_ptr & conn, std::auto_ptr & conn2, std::string database) +static void test_statement_5(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); /* Get a result set */ try { - std::auto_ptr rset(stmt->executeQuery("INSERT INTO test_function VALUES(2,200)")); + boost::scoped_ptr rset(stmt->executeQuery("INSERT INTO test_function VALUES(2,200)")); ensure("NULL returned for result set", rset.get() == NULL); ensure_equal_int("Non-empty result set", false, rset->next()); } catch (sql::SQLException &) { @@ -613,7 +615,7 @@ ++total_errors; } /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); stmt2->execute("DROP TABLE test_function"); @@ -632,11 +634,11 @@ /* {{{ Test executeUpdate() - check the returned value */ -static void test_statement_6(std::auto_ptr & conn, std::auto_ptr & conn2, std::string database) +static void test_statement_6(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); @@ -649,7 +651,7 @@ } /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); stmt2->execute("DROP TABLE test_function"); @@ -668,11 +670,11 @@ /* {{{ Test executeUpdate() - execute a SELECT, should get an exception */ -static void test_statement_7(std::auto_ptr & conn, std::auto_ptr & conn2, std::string database) +static void test_statement_7(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); @@ -688,7 +690,7 @@ } /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); stmt2->execute("DROP TABLE test_function"); @@ -709,11 +711,11 @@ #if 0 /* {{{ Test getFetchSize() - should return int value */ /* XXX: Test fails because getFetchSize() is not implemented*/ -static void test_statement_xx(std::auto_ptr & conn, std::auto_ptr & conn2) +static void test_statement_xx(boost::scoped_ptr & conn, boost::scoped_ptr & conn2) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("fetchSize is negative", stmt->getFetchSize() > 0); @@ -732,11 +734,11 @@ /* {{{ Test setFetchSize() - set and get the value */ /* XXX: Doesn't pass because setFetchSize() is unimplemented */ -static void test_statement_xx(std::auto_ptr & conn) +static void test_statement_xx(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); int setFetchSize = 50; @@ -759,11 +761,11 @@ /* {{{ Test setFetchSize() - set negative value and expect an exception */ /* XXX: Doesn't pass because setFetchSize() is unimplemented */ -static void test_statement_xx(std::auto_ptr & conn) +static void test_statement_xx(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); try { @@ -788,11 +790,11 @@ /* {{{ Test setQueryTimeout() - set negative value and expect an exception */ /* XXX: Doesn't pass because setQueryTimeout() is unimplemented */ -static void test_statement_xx(std::auto_ptr & conn) +static void test_statement_xx(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); try { @@ -815,22 +817,22 @@ /* {{{ Test getResultSet() - execute() a query and get the result set */ -static void test_statement_8(std::auto_ptr & conn, std::auto_ptr & conn2, std::string database) +static void test_statement_8(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); ensure("sql::Statement::execute returned false", true == stmt->execute("SELECT * FROM test_function")); - std::auto_ptr rset(stmt->getResultSet()); + boost::scoped_ptr rset(stmt->getResultSet()); ensure("rset is NULL", rset.get() != NULL); /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); stmt2->execute("DROP TABLE test_function"); @@ -848,22 +850,22 @@ /* {{{ Test getResultSet() - execute() an update query and get the result set - should be empty */ -static void test_statement_9(std::auto_ptr & conn, std::auto_ptr & conn2, std::string database) +static void test_statement_9(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); ensure("sql::Statement::execute returned true", false == stmt->execute("UPDATE test_function SET a = 222")); - std::auto_ptr rset(stmt->getResultSet()); + boost::scoped_ptr rset(stmt->getResultSet()); ensure("rset is not NULL", rset.get() == NULL); /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); stmt2->execute("DROP TABLE test_function"); @@ -882,15 +884,15 @@ /* {{{ Test metadata usage after result set has been closed */ -static void test_statement_10(std::auto_ptr & conn, std::auto_ptr & conn2, std::string database) +static void test_statement_10(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("stmt is NULL", stmt.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); - std::auto_ptr res(stmt->executeQuery("SELECT * FROM test_function")); + boost::scoped_ptr res(stmt->executeQuery("SELECT * FROM test_function")); ensure("ResultSet is empty", res->rowsCount() > 0); sql::ResultSetMetaData * meta = res->getMetaData(); ensure("Error while reading a row ", res->next()); @@ -903,7 +905,7 @@ // exception correctly thrown } /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); stmt2->execute("DROP TABLE test_function"); @@ -922,14 +924,14 @@ /* {{{ */ -static void test_result_set_0(std::auto_ptr & conn) +static void test_result_set_0(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); ensure("AutoCommit", conn.get() == stmt->getConnection()); - std::auto_ptr result(stmt->setResultSetType(sql::ResultSet::TYPE_SCROLL_INSENSITIVE)->executeQuery("SELECT 1, 2, 3")); + boost::scoped_ptr result(stmt->setResultSetType(sql::ResultSet::TYPE_SCROLL_INSENSITIVE)->executeQuery("SELECT 1, 2, 3")); ensure_equal_int("isFirst", result->isFirst(), false); @@ -945,18 +947,18 @@ /* {{{ */ -static void test_result_set_1(std::auto_ptr & conn) +static void test_result_set_1(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); stmt1->setResultSetType(sql::ResultSet::TYPE_SCROLL_INSENSITIVE); - std::auto_ptr rset1(stmt1->executeQuery("SELECT 1")); + boost::scoped_ptr rset1(stmt1->executeQuery("SELECT 1")); ensure("res1 is NULL", rset1.get() != NULL); - std::auto_ptr rset2(stmt1->executeQuery("SELECT 1")); + boost::scoped_ptr rset2(stmt1->executeQuery("SELECT 1")); ensure("res2 is NULL", rset2.get() != NULL); ensure("res1 is empty", rset1->next() != false); @@ -972,16 +974,16 @@ /* {{{ */ -static void test_result_set_2(std::auto_ptr & conn, std::string database) +static void test_result_set_2(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); ensure("Data not populated", true == populate_test_table(conn, database)); - std::auto_ptr rset1(stmt1->executeQuery("SELECT 1")); + boost::scoped_ptr rset1(stmt1->executeQuery("SELECT 1")); ensure("res1 is NULL", rset1.get() != NULL); ensure_equal_int("res1 is empty", rset1->next(), true); ensure_equal_int("res1 is empty", rset1->next(), false); @@ -1000,11 +1002,11 @@ /* {{{ */ -static void test_result_set_3(std::auto_ptr & conn, std::string database) +static void test_result_set_3(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); ensure_equal("sql::Connection differs", conn.get(), stmt1->getConnection()); @@ -1013,7 +1015,7 @@ ensure("Data not populated", true == populate_TX_test_table(conn, database)); - std::auto_ptr rset1(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset1(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res1 is NULL", rset1.get() != NULL); ensure("res1 is empty", rset1->next() != false); int count_full_before = rset1->getInt(1); @@ -1024,7 +1026,7 @@ stmt1->executeUpdate("DELETE FROM test_function_tx WHERE 1"), count_full_before); - std::auto_ptr rset2(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset2(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res2 is NULL", rset2.get() != NULL); ensure("res2 is empty", rset2->next() != false); ensure("Table not empty after delete", rset2->getInt(1) == 0); @@ -1032,7 +1034,7 @@ stmt1->getConnection()->rollback(); - std::auto_ptr rset3(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset3(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res3 is NULL", rset3.get() != NULL); ensure("res3 is empty", rset3->next() != false); int count_full_after = rset3->getInt(1); @@ -1046,7 +1048,7 @@ count_full_before); stmt1->getConnection()->commit(); - std::auto_ptr rset4(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset4(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res4 is NULL", rset4.get() != NULL); ensure("res4 is empty", rset4->next() != false); ensure("Table not empty after delete", rset4->getInt(1) == 0); @@ -1066,11 +1068,11 @@ /* {{{ Test commit and rollback (autocommit on) */ -static void test_result_set_4(std::auto_ptr & conn, std::string database) +static void test_result_set_4(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); ensure_equal("sql::Connection differs", conn.get(), stmt1->getConnection()); @@ -1080,7 +1082,7 @@ ensure_equal_int("Data not populated", true, populate_TX_test_table(conn, database)); - std::auto_ptr rset1(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset1(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res1 is NULL", rset1.get() != NULL); ensure_equal_int("res1 is empty", rset1->next(), true); int count_full_before = rset1->getInt(1); @@ -1091,7 +1093,7 @@ stmt1->executeUpdate("DELETE FROM test_function_tx WHERE 1"), count_full_before); - std::auto_ptr rset2(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset2(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res2 is NULL", rset2.get() != NULL); ensure_equal_int("res2 is empty", rset2->next(), true); ensure_equal_int("Table not empty after delete", rset2->getInt(1), 0); @@ -1100,7 +1102,7 @@ /* In autocommit on, this is a no-op */ stmt1->getConnection()->rollback(); - std::auto_ptr rset3(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset3(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res3 is NULL", rset3.get() != NULL); ensure_equal_int("res3 is empty", rset3->next(), true); ensure_equal_int("Rollback didn't work", rset3->getInt(1), 0); @@ -1115,7 +1117,7 @@ /* In autocommit on, this is a no-op */ stmt1->getConnection()->commit(); - std::auto_ptr rset4(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset4(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res4 is NULL", rset4.get() != NULL); ensure_equal_int("res4 is empty", rset4->next(), true); ensure_equal_int("Table not empty after delete", rset4->getInt(1), 0); @@ -1128,7 +1130,7 @@ count_full_before); /* In autocommit iff, this is an op */ stmt1->getConnection()->rollback(); - std::auto_ptr rset5(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset5(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx")); ensure("res5 is NULL", rset5.get() != NULL); ensure_equal_int("res5 is empty", rset5->next(), true); ensure_equal_int("Table empty after delete", rset5->getInt(1), count_full_before); @@ -1148,15 +1150,15 @@ /* {{{ Test multistatement off - send two queries in one call */ -static void test_result_set_5(std::auto_ptr & conn) +static void test_result_set_5(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); try { - std::auto_ptr rset1(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx; DELETE FROM test_function_tx")); + boost::scoped_ptr rset1(stmt1->executeQuery("SELECT COUNT(*) FROM test_function_tx; DELETE FROM test_function_tx")); ensure("ERR: Exception not thrown", false); } catch (sql::SQLException &) {} } catch (sql::SQLException &e) { @@ -1247,18 +1249,18 @@ /* {{{ Test out of bound extraction of data */ -static void test_result_set_6(std::auto_ptr & conn, std::string database) +static void test_result_set_6(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); ensure_equal("sql::Connection differs", conn.get(), stmt1->getConnection()); ensure("Data not populated", true == populate_TX_test_table(conn, database)); - std::auto_ptr rset1(stmt1->executeQuery("SELECT COUNT(*) AS 'count of rows' FROM test_function_tx")); + boost::scoped_ptr rset1(stmt1->executeQuery("SELECT COUNT(*) AS 'count of rows' FROM test_function_tx")); ensure("res1 is NULL", rset1.get() != NULL); test_result_set_check_out_of_bound(rset1.get()); @@ -1275,22 +1277,22 @@ /* {{{ Test out of bound extraction of data - PS version */ -static void test_result_set_7(std::auto_ptr & conn, std::string database) +static void test_result_set_7(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { ensure("Data not populated", true == populate_TX_test_table(conn, database)); - std::auto_ptr stmt1(conn->prepareStatement("SELECT COUNT(*) AS 'count of rows' FROM test_function_tx")); + boost::scoped_ptr stmt1(conn->prepareStatement("SELECT COUNT(*) AS 'count of rows' FROM test_function_tx")); ensure("stmt1 is NULL", stmt1.get() != NULL); ensure_equal("sql::Connection differs", conn.get(), stmt1->getConnection()); - std::auto_ptr rset1(stmt1->executeQuery()); + boost::scoped_ptr rset1(stmt1->executeQuery()); ensure("res1 is NULL", rset1.get() != NULL); test_result_set_check_out_of_bound(rset1.get()); - std::auto_ptr stmt2(conn->prepareStatement("DROP TABLE test_function_tx")); + boost::scoped_ptr stmt2(conn->prepareStatement("DROP TABLE test_function_tx")); stmt2->execute(); } catch (sql::SQLException &e) { printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); @@ -1303,12 +1305,12 @@ /* {{{ Test commit and rollback (autocommit on) - PS version */ -static void test_result_set_8(std::auto_ptr & conn, std::string database) +static void test_result_set_8(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { int count_full_before; - std::auto_ptr stmt0(conn->prepareStatement("SELECT 1")); + boost::scoped_ptr stmt0(conn->prepareStatement("SELECT 1")); ensure("stmt0 is NULL", stmt0.get() != NULL); ensure_equal("sql::Connection differs", conn.get(), stmt0->getConnection()); @@ -1317,19 +1319,19 @@ conn->setAutoCommit(true); ensure("Data not populated", true == populate_TX_test_table_PS(conn, database)); - std::auto_ptr stmt1(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx")); - std::auto_ptr rset1(stmt1->executeQuery()); + boost::scoped_ptr stmt1(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset1(stmt1->executeQuery()); ensure("res1 is NULL", rset1.get() != NULL); ensure_equal_int("res1 is empty", rset1->next(), true); count_full_before = rset1->getInt(1); ensure_equal_int("res1 has more rows ", rset1->next(), false); - std::auto_ptr stmt2(conn->prepareStatement("DELETE FROM test_function_tx WHERE 1")); + boost::scoped_ptr stmt2(conn->prepareStatement("DELETE FROM test_function_tx WHERE 1")); /* Let's delete and then rollback */ ensure_equal_int("Deleted less rows", stmt2->executeUpdate(), count_full_before); - std::auto_ptr stmt3(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx")); - std::auto_ptr rset2(stmt3->executeQuery()); + boost::scoped_ptr stmt3(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset2(stmt3->executeQuery()); ensure("res2 is NULL", rset2.get() != NULL); ensure_equal_int("res2 is empty", rset2->next(), true); ensure_equal_int("Table not empty after delete", rset2->getInt(1), 0); @@ -1338,8 +1340,8 @@ /* In autocommit on, this is a no-op */ stmt1->getConnection()->rollback(); - std::auto_ptr stmt4(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx")); - std::auto_ptr rset3(stmt4->executeQuery()); + boost::scoped_ptr stmt4(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset3(stmt4->executeQuery()); ensure("res3 is NULL", rset3.get() != NULL); ensure_equal_int("res3 is empty", rset3->next(), true); ensure_equal_int("Rollback didn't work", rset3->getInt(1), 0); @@ -1347,15 +1349,15 @@ ensure("Data not populated", true == populate_TX_test_table_PS(conn, database)); - std::auto_ptr stmt5(conn->prepareStatement("DELETE FROM test_function_tx WHERE 1")); + boost::scoped_ptr stmt5(conn->prepareStatement("DELETE FROM test_function_tx WHERE 1")); /* Let's delete and then rollback */ ensure_equal_int("Deleted less rows", stmt5->executeUpdate(), count_full_before); /* In autocommit on, this is a no-op */ stmt1->getConnection()->commit(); - std::auto_ptr stmt6(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx")); - std::auto_ptr rset4(stmt6->executeQuery()); + boost::scoped_ptr stmt6(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset4(stmt6->executeQuery()); ensure("res4 is NULL", rset4.get() != NULL); ensure_equal_int("res4 is empty", rset4->next(), true); ensure_equal_int("Rollback didn't work", rset4->getInt(1), 0); @@ -1363,20 +1365,20 @@ conn->setAutoCommit(false); ensure("Data not populated", true == populate_TX_test_table_PS(conn, database)); - std::auto_ptr stmt7(conn->prepareStatement("DELETE FROM test_function_tx WHERE 1")); + boost::scoped_ptr stmt7(conn->prepareStatement("DELETE FROM test_function_tx WHERE 1")); /* Let's delete and then rollback */ ensure("Deleted less rows", stmt7->executeUpdate() == count_full_before); /* In autocommit iff, this is an op */ stmt1->getConnection()->rollback(); - std::auto_ptr stmt8(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx")); - std::auto_ptr rset5(stmt8->executeQuery()); + boost::scoped_ptr stmt8(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx")); + boost::scoped_ptr rset5(stmt8->executeQuery()); ensure("res5 is NULL", rset5.get() != NULL); ensure_equal_int("res5 is empty", rset5->next(), true); ensure_equal_int("Rollback didn't work", rset5->getInt(1), 0); ensure_equal_int("res5 has more rows ", rset5->next(), false); - std::auto_ptr stmt9(conn->prepareStatement("DROP TABLE test_function_tx")); + boost::scoped_ptr stmt9(conn->prepareStatement("DROP TABLE test_function_tx")); stmt1->execute(); conn->setAutoCommit(old_commit_mode); @@ -1391,13 +1393,13 @@ /* {{{ Test multistatement off - send two queries in one call - PS version */ -static void test_result_set_9(std::auto_ptr & conn) +static void test_result_set_9(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { try { - std::auto_ptr stmt1(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx; DELETE FROM test_function_tx")); + boost::scoped_ptr stmt1(conn->prepareStatement("SELECT COUNT(*) FROM test_function_tx; DELETE FROM test_function_tx")); ensure("ERR: Exception not thrown", false); } catch (sql::SQLException &) {} } catch (sql::SQLException &e) { @@ -1411,11 +1413,11 @@ /* {{{ Test multiresults - SP with normal and prepared statement */ -static void test_result_set_10(std::auto_ptr & conn, std::string database) +static void test_result_set_10(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt0(conn->createStatement()); + boost::scoped_ptr stmt0(conn->createStatement()); ensure("stmt0 is NULL", stmt0.get() != NULL); stmt0->execute("USE " + database); @@ -1423,21 +1425,21 @@ /* Doesn't work with libmysql - a limitation of the library, might work with mysqlnd if it lies under */ { /* Create procedure is not supported for preparing */ - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); stmt1->execute("DROP PROCEDURE IF EXISTS CPP1"); stmt1->execute("CREATE PROCEDURE CPP1() SELECT 42"); - std::auto_ptr stmt2(conn->prepareStatement("CALL CPP1()")); + boost::scoped_ptr stmt2(conn->prepareStatement("CALL CPP1()")); stmt2->execute(); - std::auto_ptr rset1(stmt2->getResultSet()); + boost::scoped_ptr rset1(stmt2->getResultSet()); ensure("res1 is NULL", rset1.get() != NULL); ensure_equal_int("res1 is empty", rset1->next(), true); eensure_equal_intsure("Wrong data", rset1->getInt(1), 42); ensure_equal_int("res1 has more rows ", rset1->next(), false); /* Here comes the status result set*/ - std::auto_ptr rset2(stmt2->getResultSet()); + boost::scoped_ptr rset2(stmt2->getResultSet()); ensure("res2 is not NULL", rset2.get() == NULL); /* drop procedure is not supported for preparing */ @@ -1445,19 +1447,19 @@ } { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); stmt1->execute("DROP PROCEDURE IF EXISTS CPP1"); stmt1->execute("CREATE PROCEDURE CPP1() SELECT 42"); stmt1->execute("CALL CPP1()"); - std::auto_ptr rset1(stmt1->getResultSet()); + boost::scoped_ptr rset1(stmt1->getResultSet()); ensure("res1 is NULL", rset1.get() != NULL); ensure_equal_int("res1 is empty", rset1->next(), true); ensure_equal_int("Wrong data", rset1->getInt(1), 42); ensure_equal_int("res1 has more rows ", rset1->next(), false); /* Here comes the status result set*/ - std::auto_ptr rset2(stmt1->getResultSet()); + boost::scoped_ptr rset2(stmt1->getResultSet()); ensure_equal_int("res2 is not NULL", rset2.get(), NULL); stmt1->execute("DROP PROCEDURE CPP1"); @@ -1474,17 +1476,17 @@ /* {{{ getMetadata() */ -static void test_result_set_11(std::auto_ptr & conn, std::string database) +static void test_result_set_11(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt1(conn->createStatement()); + boost::scoped_ptr stmt1(conn->createStatement()); ensure("stmt1 is NULL", stmt1.get() != NULL); stmt1->setResultSetType(sql::ResultSet::TYPE_SCROLL_INSENSITIVE); ensure("Data not populated", true == populate_test_table(conn, database)); - std::auto_ptr rset1(stmt1->executeQuery("SELECT * FROM test_function")); + boost::scoped_ptr rset1(stmt1->executeQuery("SELECT * FROM test_function")); ensure("res1 is NULL", rset1.get() != NULL); ensure("res1 is empty", rset1->next() != false); stmt1->execute("set @old_charset_res=@@session.character_set_results"); @@ -1545,15 +1547,15 @@ #if 0 /* {{{ General test 0 */ -static void test_general_0(std::auto_ptr & conn) +static void test_general_0(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { sql::DatabaseMetaData * meta = conn->getMetaData(); - std::auto_ptr rset(meta->getSchemata()); + boost::scoped_ptr rset(meta->getSchemata()); while (rset->next()) { - std::auto_ptr rset2(meta->getSchemaObjects("", rset->getString("schema_name"))); + boost::scoped_ptr rset2(meta->getSchemaObjects("", rset->getString("schema_name"))); while (rset2->next()) { rset2->getString("object_type").c_str(); @@ -1571,11 +1573,11 @@ /* {{{ General test 1 */ -static void test_general_1(std::auto_ptr & conn) +static void test_general_1(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); stmt->execute("DROP TABLE IF EXISTS test.product"); stmt->execute("CREATE TABLE test.product(idproduct INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(80))"); @@ -1583,12 +1585,12 @@ conn->setAutoCommit(0); - std::auto_ptr prepStmt(conn->prepareStatement("INSERT INTO test.product (idproduct, name) VALUES(?, ?)")); + boost::scoped_ptr prepStmt(conn->prepareStatement("INSERT INTO test.product (idproduct, name) VALUES(?, ?)")); prepStmt->setInt(1, 1); prepStmt->setString(2, "The answer is 42"); prepStmt->executeUpdate(); - std::auto_ptr rset1(stmt->executeQuery("SELECT * FROM test.product")); + boost::scoped_ptr rset1(stmt->executeQuery("SELECT * FROM test.product")); ensure_equal_int("Empty result set", rset1->next(), true); ensure("Wrong data", !rset1->getString(2).compare("The answer is 42")); @@ -1597,7 +1599,7 @@ conn->rollback(); - std::auto_ptr rset2(stmt->executeQuery("SELECT * FROM test.product")); + boost::scoped_ptr rset2(stmt->executeQuery("SELECT * FROM test.product")); ensure_equal_int("Non-Empty result set", rset1->next(), false); @@ -1613,14 +1615,14 @@ #endif /* {{{ */ -static void test_prep_statement_0(std::auto_ptr & conn) +static void test_prep_statement_0(boost::scoped_ptr & conn) { ENTER_FUNCTION(); try { try { - std::auto_ptr stmt(conn->prepareStatement("SELECT 1")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT 1")); stmt->execute(); - std::auto_ptr rset1(stmt->getResultSet()); + boost::scoped_ptr rset1(stmt->getResultSet()); } catch (sql::SQLException &e) { printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); printf("# "); @@ -1628,7 +1630,7 @@ } try { - std::auto_ptr stmt(conn->prepareStatement("SELECT ?")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT ?")); } catch (sql::SQLException &e) { printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); printf("# "); @@ -1637,7 +1639,7 @@ /* Bind but don't execute. There should be no leak */ try { - std::auto_ptr stmt(conn->prepareStatement("SELECT ?, ?, ?")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT ?, ?, ?")); stmt->setInt(1, 1); } catch (sql::SQLException &e) { printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); @@ -1647,7 +1649,7 @@ /* Bind two different types for the same column. There should be no leak */ try { - std::auto_ptr stmt(conn->prepareStatement("SELECT ?")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT ?")); stmt->setString(1, "Hello MySQL"); stmt->setInt(1, 42); stmt->execute(); @@ -1659,7 +1661,7 @@ /* Execute without fetching the result set. The connector should clean the wire */ try { - std::auto_ptr stmt(conn->prepareStatement("SELECT ?, ?, ?, ?")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT ?, ?, ?, ?")); stmt->setInt(1, 1); stmt->setDouble(2, 2.25); stmt->setString(3, "Здрасти МySQL"); @@ -1674,11 +1676,11 @@ #if 0 /* Bind one parameter less than needed - NULL should be sent to the server . Check also multibyte fetching. */ try { - std::auto_ptr stmt(conn->prepareStatement("SELECT ? as \"Здравей_МySQL\" , ?, ?")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT ? as \"Здравей_МySQL\" , ?, ?")); stmt->setInt(3, 42); stmt->setString(1, "Здравей МySQL! Как си?"); stmt->execute(); - std::auto_ptr rset(stmt->getResultSet()); + boost::scoped_ptr rset(stmt->getResultSet()); ensure("No result set", rset.get() != NULL); ensure("Result set is empty", rset->next() != false); ensure("Incorrect value for col 1", rset->getInt(2) == 0 && true == rset->wasNull()); @@ -1696,10 +1698,10 @@ #endif /* try double ::execute() */ try { - std::auto_ptr stmt(conn->prepareStatement("SELECT ?")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT ?")); stmt->setString(1, "Hello World"); for (int i = 0; i < 100; ++i) { - std::auto_ptr rset(stmt->executeQuery()); + boost::scoped_ptr rset(stmt->executeQuery()); } } catch (sql::SQLException &e) { printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); @@ -1710,31 +1712,31 @@ /* Test clearParameters() */ { try { - std::auto_ptr stmt(conn->prepareStatement("SELECT ?")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT ?")); stmt->setInt(1, 13); - std::auto_ptr rs(stmt->executeQuery()); + boost::scoped_ptr rs(stmt->executeQuery()); } catch (sql::SQLException &e) { printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); printf("# "); ++total_errors; } try { - std::auto_ptr stmt(conn->prepareStatement("SELECT ?")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT ?")); stmt->setInt(1, 13); stmt->clearParameters(); - std::auto_ptr rs(stmt->executeQuery()); + boost::scoped_ptr rs(stmt->executeQuery()); ensure("Exception not thrown", false); } catch (sql::SQLException &) {} } /* try clearParameters() call */ { - std::auto_ptr stmt(conn->prepareStatement("SELECT ?, ?, ?, NULL")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT ?, ?, ?, NULL")); try { stmt->setInt(3, 42); stmt->setString(1, "Hello MYSQL"); stmt->setDouble(2, 1.25); - std::auto_ptr rset(stmt->executeQuery()); + boost::scoped_ptr rset(stmt->executeQuery()); ensure("No result set", rset.get() != NULL); ensure("Result set is empty", rset->next() != false); @@ -1756,10 +1758,10 @@ } } try { - std::auto_ptr stmt(conn->prepareStatement("SELECT ?")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT ?")); stmt->setInt(1, 1); stmt->execute(); - std::auto_ptr rset(stmt->getResultSet()); + boost::scoped_ptr rset(stmt->getResultSet()); } catch (sql::SQLException &) { printf("\n# ERR: Caught sql::SQLException at %s::%d\n", CPPCONN_FUNC, __LINE__); printf("# "); @@ -1777,28 +1779,28 @@ /* {{{ Test simple update statement against statement object */ -static void test_prep_statement_1(std::auto_ptr & conn, std::auto_ptr & conn2, const std::string & database) +static void test_prep_statement_1(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, const std::string & database) { ENTER_FUNCTION(); try { - std::auto_ptr stmt0(conn->prepareStatement("SELECT 1, 2, 3")); + boost::scoped_ptr stmt0(conn->prepareStatement("SELECT 1, 2, 3")); ensure("stmt0 is NULL", stmt0.get() != NULL); ensure("Data not populated", true == populate_test_table_PS(conn, database)); - std::auto_ptr stmt1(conn->prepareStatement("SELECT * FROM test_function")); + boost::scoped_ptr stmt1(conn->prepareStatement("SELECT * FROM test_function")); ensure("stmt1 is NULL", stmt1.get() != NULL); if (false == stmt1->execute()) { ensure("False returned for SELECT", false); } - std::auto_ptr rset(stmt1->getResultSet()); + boost::scoped_ptr rset(stmt1->getResultSet()); /* Clean */ - std::auto_ptr stmt2(conn2->createStatement()); + boost::scoped_ptr stmt2(conn2->createStatement()); ensure("stmt2 is NULL", stmt2.get() != NULL); stmt2->execute("USE " + database); - std::auto_ptr stmt3(conn2->prepareStatement("DROP TABLE test_function")); + boost::scoped_ptr stmt3(conn2->prepareStatement("DROP TABLE test_function")); ensure("stmt3 is NULL", stmt3.get() != NULL); stmt3->execute(); } catch (sql::SQLException &e) { @@ -1816,20 +1818,20 @@ /* {{{ Test simple update statement against statement object */ -static void test_prep_statement_2(std::auto_ptr & conn, std::string database) +static void test_prep_statement_2(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { populate_test_table_PS_integers(conn, database); try { - std::auto_ptr stmt(conn->prepareStatement("SELECT '1")); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT '1")); ensure("ERR: Exception not thrown", false); } catch (sql::SQLException &) {} /* USE still cannot be prepared */ try { - std::auto_ptr stmt(conn->prepareStatement("USE " + database)); + boost::scoped_ptr stmt(conn->prepareStatement("USE " + database)); ensure("ERR: Exception not thrown", false); } catch (sql::SQLException &) {} @@ -1848,7 +1850,7 @@ /* {{{ Test simple update statement against statement object */ -static void test_prep_statement_3(std::auto_ptr & conn, std::auto_ptr & conn2, const std::string & database) +static void test_prep_statement_3(boost::scoped_ptr & conn, boost::scoped_ptr & conn2, const std::string & database) { ENTER_FUNCTION(); try { @@ -1864,7 +1866,7 @@ ensure("Data not populated", true == populate_test_table_PS_integers(conn, database)); - std::auto_ptr stmt1(conn->prepareStatement("INSERT INTO test_function_int (i, i_uns, b, b_uns) VALUES(?,?,?,?)")); + boost::scoped_ptr stmt1(conn->prepareStatement("INSERT INTO test_function_int (i, i_uns, b, b_uns) VALUES(?,?,?,?)")); ensure("stmt0 is NULL", stmt1.get() != NULL); stmt1->clearParameters(); stmt1->setInt(1, static_cast(r1_c1)); @@ -1880,11 +1882,11 @@ ensure("True returned for INSERT", false == stmt1->execute()); { - std::auto_ptr stmt2(conn->prepareStatement("SELECT i, i_uns, b, b_uns FROM test_function_int")); + boost::scoped_ptr stmt2(conn->prepareStatement("SELECT i, i_uns, b, b_uns FROM test_function_int")); ensure("stmt1 is NULL", stmt2.get() != NULL); ensure("False returned for SELECT", stmt2->execute()); - std::auto_ptr rset(stmt2->getResultSet()); + boost::scoped_ptr rset(stmt2->getResultSet()); ensure("No first line", rset->next()); ensure_equal_int64("Different data", rset->getInt("i"), r1_c1); @@ -1917,11 +1919,11 @@ } { - std::auto_ptr stmt2(conn->createStatement()); + boost::scoped_ptr stmt2(conn->createStatement()); ensure("stmt1 is NULL", stmt2.get() != NULL); ensure("False returned for SELECT", stmt2->execute("SELECT i, i_uns, b, b_uns FROM test_function_int")); - std::auto_ptr rset(stmt2->getResultSet()); + boost::scoped_ptr rset(stmt2->getResultSet()); ensure("No first line", rset->next()); ensure_equal_int64("Different data", rset->getInt("i"), r1_c1); @@ -1954,11 +1956,11 @@ } /* Clean */ - std::auto_ptr stmt4(conn2->createStatement()); + boost::scoped_ptr stmt4(conn2->createStatement()); ensure("stmt4 is NULL", stmt4.get() != NULL); stmt4->execute("USE " + database); - std::auto_ptr stmt5(conn2->prepareStatement("DROP TABLE test_function_int")); + boost::scoped_ptr stmt5(conn2->prepareStatement("DROP TABLE test_function_int")); ensure("stmt5 is NULL", stmt5.get() != NULL); stmt5->execute(); } catch (sql::SQLException &e) { @@ -1976,30 +1978,30 @@ /* {{{ Tests blob with PS */ -static void test_prep_statement_blob(std::auto_ptr & conn, std::string database) +static void test_prep_statement_blob(boost::scoped_ptr & conn, std::string database) { ENTER_FUNCTION(); try { populate_blob_table(conn, database); /* USE still cannot be prepared */ - std::auto_ptr use_stmt(conn->createStatement()); + boost::scoped_ptr use_stmt(conn->createStatement()); use_stmt->execute("USE " + database); - std::auto_ptr stmt(conn->prepareStatement("INSERT INTO test_blob VALUES(?)")); + boost::scoped_ptr stmt(conn->prepareStatement("INSERT INTO test_blob VALUES(?)")); std::string value("A\0B", sizeof("A\0B") - 1); std::istringstream tmp_blob(value); stmt->setBlob(1, &tmp_blob); stmt->execute(); - std::auto_ptr stmt2(conn->createStatement()); + boost::scoped_ptr stmt2(conn->createStatement()); stmt2->execute("SELECT * FROM test_blob"); - std::auto_ptr rset2(stmt2->getResultSet()); + boost::scoped_ptr rset2(stmt2->getResultSet()); ensure("res2 is NULL", rset2.get() != NULL); ensure_equal_int("res2 is empty", rset2->next(), true); ensure_equal_str("Wrong data", rset2->getString(1), value); - std::auto_ptr blob(rset2->getBlob(1)); + boost::scoped_ptr blob(rset2->getBlob(1)); std::string::iterator it; for (it = value.begin() ; it < value.end(); ++it) { if ((blob->rdstate() & std::istream::eofbit)) { @@ -2099,8 +2101,8 @@ std::list< std::list< std::string > >::const_iterator expectedPrivilegesList_it = expectedPrivilegesList.begin(); try { - std::auto_ptr root_conn(get_connection(host, user, pass)); - std::auto_ptr root_stmt(root_conn->createStatement()); + boost::scoped_ptr root_conn(get_connection(host, user, pass)); + boost::scoped_ptr root_stmt(root_conn->createStatement()); #if DEBUG_TABLE_PRIVS std::cout << std::endl << plain_user_w_host << std::endl; #endif @@ -2112,9 +2114,9 @@ Put it in a block, so the connection will be closed before we start dropping the user and the table try { - std::auto_ptr user_conn(get_connection(host, plain_user, "pass")); - std::auto_ptr user_conn_meta(user_conn->getMetaData()); - std::auto_ptr res(user_conn_meta->getTablePrivileges("", "%", "%")); + boost::scoped_ptr user_conn(get_connection(host, plain_user, "pass")); + boost::scoped_ptr user_conn_meta(user_conn->getMetaData()); + boost::scoped_ptr res(user_conn_meta->getTablePrivileges("", "%", "%")); #if DEBUG_TABLE_PRIVS @@ -2170,7 +2172,7 @@ */ /* {{{ Invoke as many "not implemented" methods as possible for better code coverage (and to make sure we keep CHANGES current) */ -static void test_not_implemented_connection(std::auto_ptr & conn) +static void test_not_implemented_connection(boost::scoped_ptr & conn) { ENTER_FUNCTION(); @@ -2255,12 +2257,12 @@ } /* }}} */ -static void test_not_implemented_statement(std::auto_ptr & conn, const std::string & database) +static void test_not_implemented_statement(boost::scoped_ptr & conn, const std::string & database) { ENTER_FUNCTION(); std::string bar("foo"); - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); stmt->execute("USE " + database); try { @@ -2354,7 +2356,7 @@ } /* }}} */ -static void test_not_implemented_conn_meta(std::auto_ptr & conn) +static void test_not_implemented_conn_meta(boost::scoped_ptr & conn) { ENTER_FUNCTION(); @@ -2403,16 +2405,16 @@ } /* }}} */ -static void test_not_implemented_ps(std::auto_ptr & conn, const std::string & database) +static void test_not_implemented_ps(boost::scoped_ptr & conn, const std::string & database) { ENTER_FUNCTION(); std::string bar("jedervernunft"); - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); stmt->execute("USE " + database); - std::auto_ptr ps1(conn->prepareStatement("SELECT 1")); - std::auto_ptr ps2(conn->prepareStatement("SELECT ?")); + boost::scoped_ptr ps1(conn->prepareStatement("SELECT 1")); + boost::scoped_ptr ps2(conn->prepareStatement("SELECT ?")); ps2->setInt(1, 2); try { @@ -2542,445 +2544,445 @@ /* }}} */ -static void test_not_implemented_resultset(std::auto_ptr & conn) -{ - ENTER_FUNCTION(); - - std::string bar("foo"); - std::auto_ptr stmt(conn->createStatement()); - std::auto_ptr res(stmt->executeQuery("SELECT 1 AS 'a'")); - - try { - // cancelRowUpdates() - try { - ++total_tests; - res->cancelRowUpdates(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getConcurrency() - try { - ++total_tests; - res->getConcurrency(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getCursorName() - try { - ++total_tests; - res->getCursorName(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getFetchDirection() - try { - ++total_tests; - res->getFetchDirection(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getFetchSize() - try { - ++total_tests; - res->getFetchSize(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getHoldability() - try { - ++total_tests; - res->getHoldability(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getRowId(unsigned int) - try { - ++total_tests; - res->getRowId(1); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getRowId(const std::string &) - try { - ++total_tests; - res->getRowId(bar); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // insertRow() - try { - ++total_tests; - res->insertRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // moveToCurrentRow() - try { - ++total_tests; - res->moveToCurrentRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // moveToInsertRow() - try { - ++total_tests; - res->moveToInsertRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // refreshRow() - try { - ++total_tests; - res->refreshRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // rowDeleted() - try { - ++total_tests; - res->rowDeleted(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // rowInserted() - try { - ++total_tests; - res->rowInserted(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // rowUpdated() - try { - ++total_tests; - res->rowUpdated(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // setFetchSize(size_t /* rows */) - try { - ++total_tests; - res->setFetchSize(1); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - } catch (sql::SQLException &e) { - printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); - printf("# "); - ++total_errors; - } catch (...) { - printf("\n# ERR: Caught unknown exception at %s::%d\n", CPPCONN_FUNC, __LINE__); - printf("# "); - ++total_errors; - } - LEAVE_FUNCTION(); -} -/* }}} */ - - -static void test_not_implemented_ps_resultset(std::auto_ptr & conn) -{ - ENTER_FUNCTION(); - - std::string bar("foo"); - std::auto_ptr stmt(conn->prepareStatement("SELECT 1 AS 'a'")); - std::auto_ptr res(stmt->executeQuery()); - - try { - // cancelRowUpdates() - try { - ++total_tests; - res->cancelRowUpdates(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getConcurrency() - try { - ++total_tests; - res->getConcurrency(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getCursorName() - try { - ++total_tests; - res->getCursorName(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getFetchDirection() - try { - ++total_tests; - res->getFetchDirection(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getFetchSize() - try { - ++total_tests; - res->getFetchSize(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getHoldability() - try { - ++total_tests; - res->getHoldability(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getRowId(unsigned int) - try { - ++total_tests; - res->getRowId(1); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getRowId(const std::string &) - try { - ++total_tests; - res->getRowId(bar); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // insertRow() - try { - ++total_tests; - res->insertRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // moveToCurrentRow() - try { - ++total_tests; - res->moveToCurrentRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // moveToInsertRow() - try { - ++total_tests; - res->moveToInsertRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // refreshRow() - try { - ++total_tests; - res->refreshRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // rowDeleted() - try { - ++total_tests; - res->rowDeleted(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // rowInserted() - try { - ++total_tests; - res->rowInserted(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // rowUpdated() - try { - ++total_tests; - res->rowUpdated(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // setFetchSize(size_t /* rows */) - try { - ++total_tests; - res->setFetchSize(1); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - } catch (sql::SQLException &e) { - printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); - printf("# "); - ++total_errors; - } catch (...) { - printf("\n# ERR: Caught unknown exception at %s::%d\n", CPPCONN_FUNC, __LINE__); - printf("# "); - ++total_errors; - } - LEAVE_FUNCTION(); -} -/* }}} */ - -static void test_not_implemented_cs_resultset(std::auto_ptr & conn) -{ - ENTER_FUNCTION(); - - std::string bar("foo"); - sql::DatabaseMetaData * conn_meta = conn->getMetaData(); - std::auto_ptr res(conn_meta->getSchemaObjectTypes()); - - try { - // cancelRowUpdates() - try { - ++total_tests; - res->cancelRowUpdates(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getConcurrency() - try { - ++total_tests; - res->getConcurrency(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getCursorName() - try { - ++total_tests; - res->getCursorName(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getFetchDirection() - try { - ++total_tests; - res->getFetchDirection(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getFetchSize() - try { - ++total_tests; - res->getFetchSize(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getHoldability() - try { - ++total_tests; - res->getHoldability(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getRowId(unsigned int) - try { - ++total_tests; - res->getRowId(1); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // getRowId(const std::string &) - try { - ++total_tests; - res->getRowId(bar); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // insertRow() - try { - ++total_tests; - res->insertRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // moveToCurrentRow() - try { - ++total_tests; - res->moveToCurrentRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // moveToInsertRow() - try { - ++total_tests; - res->moveToInsertRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // refreshRow() - try { - ++total_tests; - res->refreshRow(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // rowDeleted() - try { - ++total_tests; - res->rowDeleted(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // rowInserted() - try { - ++total_tests; - res->rowInserted(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // rowUpdated() - try { - ++total_tests; - res->rowUpdated(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - // setFetchSize(size_t /* rows */) - try { - ++total_tests; - res->setFetchSize(1); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - } catch (sql::SQLException &e) { - printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); - printf("# "); - ++total_errors; - } catch (...) { - printf("\n# ERR: Caught unknown exception at %s::%d\n", CPPCONN_FUNC, __LINE__); - printf("# "); - ++total_errors; - } - LEAVE_FUNCTION(); -} -/* }}} */ - -static void test_not_implemented_rs_meta(std::auto_ptr & conn) -{ - ENTER_FUNCTION(); - - std::string bar("foo"); - std::auto_ptr stmt(conn->createStatement()); - std::auto_ptr res(stmt->executeQuery("SELECT 1 AS 'a'")); - - try { - try { - ++total_tests; - res->cancelRowUpdates(); - ensure("ERR: Exception not thrown", false); - } catch (sql::MethodNotImplementedException &) {} - - } catch (sql::SQLException &e) { - printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); - printf("# "); - ++total_errors; - } catch (...) { - printf("\n# ERR: Caught unknown exception at %s::%d\n", CPPCONN_FUNC, __LINE__); - printf("# "); - ++total_errors; - } - LEAVE_FUNCTION(); -} -/* }}} */ - - -static void test_not_implemented_cs_rs_meta(std::auto_ptr & conn) -{ - ENTER_FUNCTION(); - - std::string bar("foo"); - sql::DatabaseMetaData * conn_meta = conn->getMetaData(); - std::auto_ptr res(conn_meta->getSchemaObjectTypes()); +static void test_not_implemented_resultset(boost::scoped_ptr & conn) +{ + ENTER_FUNCTION(); + + std::string bar("foo"); + boost::scoped_ptr stmt(conn->createStatement()); + boost::scoped_ptr res(stmt->executeQuery("SELECT 1 AS 'a'")); + + try { + // cancelRowUpdates() + try { + ++total_tests; + res->cancelRowUpdates(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getConcurrency() + try { + ++total_tests; + res->getConcurrency(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getCursorName() + try { + ++total_tests; + res->getCursorName(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getFetchDirection() + try { + ++total_tests; + res->getFetchDirection(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getFetchSize() + try { + ++total_tests; + res->getFetchSize(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getHoldability() + try { + ++total_tests; + res->getHoldability(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getRowId(unsigned int) + try { + ++total_tests; + res->getRowId(1); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getRowId(const std::string &) + try { + ++total_tests; + res->getRowId(bar); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // insertRow() + try { + ++total_tests; + res->insertRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // moveToCurrentRow() + try { + ++total_tests; + res->moveToCurrentRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // moveToInsertRow() + try { + ++total_tests; + res->moveToInsertRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // refreshRow() + try { + ++total_tests; + res->refreshRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // rowDeleted() + try { + ++total_tests; + res->rowDeleted(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // rowInserted() + try { + ++total_tests; + res->rowInserted(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // rowUpdated() + try { + ++total_tests; + res->rowUpdated(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // setFetchSize(size_t /* rows */) + try { + ++total_tests; + res->setFetchSize(1); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + } catch (sql::SQLException &e) { + printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); + printf("# "); + ++total_errors; + } catch (...) { + printf("\n# ERR: Caught unknown exception at %s::%d\n", CPPCONN_FUNC, __LINE__); + printf("# "); + ++total_errors; + } + LEAVE_FUNCTION(); +} +/* }}} */ + + +static void test_not_implemented_ps_resultset(boost::scoped_ptr & conn) +{ + ENTER_FUNCTION(); + + std::string bar("foo"); + boost::scoped_ptr stmt(conn->prepareStatement("SELECT 1 AS 'a'")); + boost::scoped_ptr res(stmt->executeQuery()); + + try { + // cancelRowUpdates() + try { + ++total_tests; + res->cancelRowUpdates(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getConcurrency() + try { + ++total_tests; + res->getConcurrency(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getCursorName() + try { + ++total_tests; + res->getCursorName(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getFetchDirection() + try { + ++total_tests; + res->getFetchDirection(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getFetchSize() + try { + ++total_tests; + res->getFetchSize(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getHoldability() + try { + ++total_tests; + res->getHoldability(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getRowId(unsigned int) + try { + ++total_tests; + res->getRowId(1); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getRowId(const std::string &) + try { + ++total_tests; + res->getRowId(bar); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // insertRow() + try { + ++total_tests; + res->insertRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // moveToCurrentRow() + try { + ++total_tests; + res->moveToCurrentRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // moveToInsertRow() + try { + ++total_tests; + res->moveToInsertRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // refreshRow() + try { + ++total_tests; + res->refreshRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // rowDeleted() + try { + ++total_tests; + res->rowDeleted(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // rowInserted() + try { + ++total_tests; + res->rowInserted(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // rowUpdated() + try { + ++total_tests; + res->rowUpdated(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // setFetchSize(size_t /* rows */) + try { + ++total_tests; + res->setFetchSize(1); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + } catch (sql::SQLException &e) { + printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); + printf("# "); + ++total_errors; + } catch (...) { + printf("\n# ERR: Caught unknown exception at %s::%d\n", CPPCONN_FUNC, __LINE__); + printf("# "); + ++total_errors; + } + LEAVE_FUNCTION(); +} +/* }}} */ + +static void test_not_implemented_cs_resultset(boost::scoped_ptr & conn) +{ + ENTER_FUNCTION(); + + std::string bar("foo"); + sql::DatabaseMetaData * conn_meta = conn->getMetaData(); + boost::scoped_ptr res(conn_meta->getSchemaObjectTypes()); + + try { + // cancelRowUpdates() + try { + ++total_tests; + res->cancelRowUpdates(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getConcurrency() + try { + ++total_tests; + res->getConcurrency(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getCursorName() + try { + ++total_tests; + res->getCursorName(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getFetchDirection() + try { + ++total_tests; + res->getFetchDirection(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getFetchSize() + try { + ++total_tests; + res->getFetchSize(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getHoldability() + try { + ++total_tests; + res->getHoldability(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getRowId(unsigned int) + try { + ++total_tests; + res->getRowId(1); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // getRowId(const std::string &) + try { + ++total_tests; + res->getRowId(bar); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // insertRow() + try { + ++total_tests; + res->insertRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // moveToCurrentRow() + try { + ++total_tests; + res->moveToCurrentRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // moveToInsertRow() + try { + ++total_tests; + res->moveToInsertRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // refreshRow() + try { + ++total_tests; + res->refreshRow(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // rowDeleted() + try { + ++total_tests; + res->rowDeleted(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // rowInserted() + try { + ++total_tests; + res->rowInserted(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // rowUpdated() + try { + ++total_tests; + res->rowUpdated(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + // setFetchSize(size_t /* rows */) + try { + ++total_tests; + res->setFetchSize(1); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + } catch (sql::SQLException &e) { + printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); + printf("# "); + ++total_errors; + } catch (...) { + printf("\n# ERR: Caught unknown exception at %s::%d\n", CPPCONN_FUNC, __LINE__); + printf("# "); + ++total_errors; + } + LEAVE_FUNCTION(); +} +/* }}} */ + +static void test_not_implemented_rs_meta(boost::scoped_ptr & conn) +{ + ENTER_FUNCTION(); + + std::string bar("foo"); + boost::scoped_ptr stmt(conn->createStatement()); + boost::scoped_ptr res(stmt->executeQuery("SELECT 1 AS 'a'")); + + try { + try { + ++total_tests; + res->cancelRowUpdates(); + ensure("ERR: Exception not thrown", false); + } catch (sql::MethodNotImplementedException &) {} + + } catch (sql::SQLException &e) { + printf("\n# ERR: Caught sql::SQLException at %s::%d [%s] (%d/%s)\n", CPPCONN_FUNC, __LINE__, e.what(), e.getErrorCode(), e.getSQLStateCStr()); + printf("# "); + ++total_errors; + } catch (...) { + printf("\n# ERR: Caught unknown exception at %s::%d\n", CPPCONN_FUNC, __LINE__); + printf("# "); + ++total_errors; + } + LEAVE_FUNCTION(); +} +/* }}} */ + + +static void test_not_implemented_cs_rs_meta(boost::scoped_ptr & conn) +{ + ENTER_FUNCTION(); + + std::string bar("foo"); + sql::DatabaseMetaData * conn_meta = conn->getMetaData(); + boost::scoped_ptr res(conn_meta->getSchemaObjectTypes()); sql::ResultSetMetaData * meta = res->getMetaData(); try { @@ -3027,7 +3029,7 @@ { printf("1..%d\n#\n", loops); - std::auto_ptr conn, conn2; + boost::scoped_ptr conn, conn2; int last_error_total = 0; int i; @@ -3070,10 +3072,10 @@ // printf("# "); try { - std::auto_ptr stmt(conn->createStatement()); + boost::scoped_ptr stmt(conn->createStatement()); stmt->execute("SHOW ENGINES"); { - std::auto_ptr rset(stmt->getResultSet()); + boost::scoped_ptr rset(stmt->getResultSet()); int found = 0; while (rset->next()) { if (rset->getString("Engine") == "InnoDB" && (rset->getString("Support") == "YES" || rset->getString("Support") == "DEFAULT")) { === modified file 'test/unit/classes/connection.cpp' --- test/unit/classes/connection.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/unit/classes/connection.cpp 2014-12-12 13:14:20 +0000 @@ -33,6 +33,7 @@ #include #include +#include #include namespace testsuite @@ -286,7 +287,7 @@ try { std::string value(""); - std::auto_ptr< sql::mysql::MySQL_Connection > my_con(dynamic_cast (driver->connect(url, user, passwd))); + boost::scoped_ptr< sql::mysql::MySQL_Connection > my_con(dynamic_cast (driver->connect(url, user, passwd))); value=my_con->getSessionVariable("sql_mode"); my_con->setSessionVariable("sql_mode", "ANSI"); === modified file 'test/unit/classes/connectionmetadata.cpp' --- test/unit/classes/connectionmetadata.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/unit/classes/connectionmetadata.cpp 2014-12-12 13:14:20 +0000 @@ -557,19 +557,18 @@ void connectionmetadata::getConnection() { logMsg("connectionmetadata::getConnection() - MySQL_ConnectionMetaData::getConnection"); - Connection same_con; + sql::Connection *same_con; try { stmt.reset(con->createStatement()); stmt->execute("SET @this_is_my_connection_id=101"); DatabaseMetaData * dbmeta=con->getMetaData(); - same_con.reset(dbmeta->getConnection()); + same_con= dbmeta->getConnection(); stmt.reset(same_con->createStatement()); res.reset(stmt->executeQuery("SELECT @this_is_my_connection_id AS _connection_id")); ASSERT(res->next()); ASSERT_EQUALS(101, res->getInt("_connection_id")); ASSERT_EQUALS(res->getInt(1), res->getInt("_connection_id")); - same_con.release(); // if the same don't clean it, it will be double free } catch (sql::SQLException &e) { === modified file 'test/unit/classes/preparedstatement.cpp' --- test/unit/classes/preparedstatement.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/unit/classes/preparedstatement.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -1432,7 +1432,7 @@ ASSERT_EQUALS(res->getString("col1"), blob_input_stream.str()); ASSERT_EQUALS(res->getString("col1"), blob_input); - std::auto_ptr< std::istream > blob_output_stream(res->getBlob(2)); + boost::scoped_ptr< std::istream > blob_output_stream(res->getBlob(2)); blob_output_stream->seekg(std::ios::beg); blob_output_stream->get(blob_output, offset + 1); ASSERT_EQUALS(blob_input_stream.str(), blob_output); === modified file 'test/unit/classes/savepoint.cpp' --- test/unit/classes/savepoint.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/unit/classes/savepoint.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -32,6 +32,8 @@ #include "savepoint.h" #include +#include + namespace testsuite { namespace classes @@ -44,7 +46,7 @@ try { con->setAutoCommit(true); - std::auto_ptr< sql::Savepoint > sp(con->setSavepoint("mysavepoint")); + boost::scoped_ptr< sql::Savepoint > sp(con->setSavepoint("mysavepoint")); FAIL("You should not be able to set a savepoint in autoCommit mode"); } catch (sql::SQLException &) @@ -54,7 +56,7 @@ try { con->setAutoCommit(false); - std::auto_ptr< sql::Savepoint > sp(con->setSavepoint("mysavepoint")); + boost::scoped_ptr< sql::Savepoint > sp(con->setSavepoint("mysavepoint")); try { sp->getSavepointId(); @@ -79,7 +81,7 @@ try { con->setAutoCommit(false); - std::auto_ptr< sql::Savepoint > sp(con->setSavepoint("mysavepoint")); + boost::scoped_ptr< sql::Savepoint > sp(con->setSavepoint("mysavepoint")); ASSERT_EQUALS("mysavepoint", sp->getSavepointName()); con->releaseSavepoint(sp.get()); } === modified file 'test/unit/example/example.cpp' --- test/unit/example/example.cpp revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/unit/example/example.cpp 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -78,17 +78,17 @@ /* Connection, Statement and ResultSet are typedefs from unit_fixture.h: - typedef std::auto_ptr Connection; - typedef std::auto_ptr PreparedStatement; - typedef std::auto_ptr ParameterMetaData; - typedef std::auto_ptr Statement; - typedef std::auto_ptr Savepoint; - typedef std::auto_ptr ResultSet; + typedef boost::scoped_ptr Connection; + typedef boost::scoped_ptr PreparedStatement; + typedef boost::scoped_ptr ParameterMetaData; + typedef boost::scoped_ptr Statement; + typedef boost::scoped_ptr Savepoint; + typedef boost::scoped_ptr ResultSet; typedef sql::Driver Driver; - typedef std::auto_ptr ResultSetMetaData; - typedef std::auto_ptr DatabaseMetaData; + typedef boost::scoped_ptr ResultSetMetaData; + typedef boost::scoped_ptr DatabaseMetaData; - Do yourself a favour and use auto_ptr in tests! + Do yourself a favour and use boost::scoped_ptr in tests! */ Connection my_con(getConnection()); Statement my_stmt(my_con->createStatement()); === modified file 'test/unit/unit_fixture.h' --- test/unit/unit_fixture.h revid:hemant.dangi@oracle.com-20141201101949-52eih37czyv7ywit +++ test/unit/unit_fixture.h 2014-12-12 13:14:20 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 , like most @@ -33,15 +33,17 @@ #include #include +#include + namespace testsuite { /* TODO - document */ -typedef std::auto_ptr Connection; -typedef std::auto_ptr PreparedStatement; +typedef boost::scoped_ptr Connection; +typedef boost::scoped_ptr PreparedStatement; typedef sql::ParameterMetaData ParameterMetaData; -typedef std::auto_ptr Statement; -typedef std::auto_ptr Savepoint; -typedef std::auto_ptr ResultSet; +typedef boost::scoped_ptr Statement; +typedef boost::scoped_ptr Savepoint; +typedef boost::scoped_ptr ResultSet; typedef sql::Driver Driver; typedef sql::ResultSetMetaData ResultSetMetaData; typedef sql::DatabaseMetaData DatabaseMetaData; @@ -308,7 +310,7 @@ * Returns a Connector/C++ connection object * * Note: you are responsible for handling the object, you might - * want to use typedef std::auto_ptrcon(getConnection()) + * want to use typedef boost::scoped_ptrcon(getConnection()) * or similar for convenience reasons. * * @throws SQLException &