diff --git a/CMakeLists.txt b/CMakeLists.txt index 2062f9aaf..f186d24ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ SET(CMAKE_SKIP_BUILD_RPATH FALSE) # (but later on when installing) SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -SET(CMAKE_INSTALL_RPATH "${INSTALL_ENGINE}/lib") +SET(CMAKE_INSTALL_RPATH "${INSTALL_ENGINE}/lib;${INSTALL_ENGINE}/mysql/lib") # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH @@ -69,6 +69,11 @@ IF("${isSystemDir}" STREQUAL "-1") SET(CMAKE_INSTALL_RPATH "${INSTALL_ENGINE}/lib") ENDIF("${isSystemDir}" STREQUAL "-1") +LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${SERVER_SOURCE_ROOT_DIR}/libmysql/" isSystemDir) +IF("${isSystemDir}" STREQUAL "-1") + SET(CMAKE_INSTALL_RPATH "${INSTALL_ENGINE}/mysql/lib") +ENDIF("${isSystemDir}" STREQUAL "-1") + INCLUDE (configureEngine.cmake) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/releasenum.in ${CMAKE_CURRENT_BINARY_DIR}/build/releasenum @ONLY IMMEDIATE) @@ -125,7 +130,7 @@ SET (ENGINE_TOOLSDIR "${INSTALL_ENGINE}/tools") SET (ENGINE_COMMON_LIBS messageqcpp loggingcpp configcpp idbboot ${Boost_LIBRARIES} xml2 pthread rt) SET (ENGINE_OAM_LIBS oamcpp alarmmanager) SET (ENGINE_BRM_LIBS brm idbdatafile cacheutils rwlock ${ENGINE_OAM_LIBS} ${ENGINE_COMMON_LIBS}) -SET (ENGINE_EXEC_LIBS joblist execplan windowfunction joiner rowgroup funcexp udfsdk dataconvert common compress mysqlcl_idb querystats querytele thrift threadpool ${ENGINE_BRM_LIBS}) +SET (ENGINE_EXEC_LIBS joblist execplan windowfunction joiner rowgroup funcexp udfsdk dataconvert common compress querystats querytele thrift threadpool ${ENGINE_BRM_LIBS}) SET (ENGINE_WRITE_LIBS ddlpackageproc ddlpackage dmlpackageproc dmlpackage writeengine writeengineclient idbdatafile cacheutils ${ENGINE_EXEC_LIBS}) SET (ENGINE_COMMON_LDFLAGS "") diff --git a/dbcon/joblist/CMakeLists.txt b/dbcon/joblist/CMakeLists.txt index 989c3b798..bebe6584a 100644 --- a/dbcon/joblist/CMakeLists.txt +++ b/dbcon/joblist/CMakeLists.txt @@ -61,7 +61,7 @@ set(joblist_LIB_SRCS add_library(joblist SHARED ${joblist_LIB_SRCS}) -target_link_libraries(joblist ${NETSNMP_LIBRARIES}) +target_link_libraries(joblist ${NETSNMP_LIBRARIES} -L${SERVER_SOURCE_ROOT_DIR}/libmysql/ libmysqlclient_r.so) set_target_properties(joblist PROPERTIES VERSION 1.0.0 SOVERSION 1) diff --git a/dbcon/joblist/crossenginestep.cpp b/dbcon/joblist/crossenginestep.cpp index 98098fe62..1a384ef73 100644 --- a/dbcon/joblist/crossenginestep.cpp +++ b/dbcon/joblist/crossenginestep.cpp @@ -17,6 +17,7 @@ // $Id: crossenginestep.cpp 9709 2013-07-20 06:08:46Z xlou $ +#include "crossenginestep.h" #include //#define NDEBUG #include @@ -55,89 +56,68 @@ using namespace querytele; #include "jobstep.h" #include "jlf_common.h" -#include "crossenginestep.h" - -#include "libdrizzle-2.0/drizzle.h" -#include "libdrizzle-2.0/drizzle_client.h" namespace joblist { -DrizzleMySQL::DrizzleMySQL() : fDrzp(NULL), fDrzcp(NULL), fDrzrp(NULL) +LibMySQL::LibMySQL() : fCon(NULL), fRes(NULL) { } -DrizzleMySQL::~DrizzleMySQL() +LibMySQL::~LibMySQL() { - if (fDrzrp) + if (fRes) { - drizzle_result_free(fDrzrp); + mysql_free_result(fRes); } - fDrzrp = NULL; + fRes = NULL; - if (fDrzcp) + if (fCon) { - drizzle_con_close(fDrzcp); - drizzle_con_free(fDrzcp); + mysql_close(fCon); } - fDrzcp = NULL; - - if (fDrzp) - { - drizzle_free(fDrzp); - } - fDrzp = NULL; + fCon = NULL; } -int DrizzleMySQL::init(const char* h, unsigned int p, const char* u, const char* w, const char* d) +int LibMySQL::init(const char* h, unsigned int p, const char* u, const char* w, const char* d) { - int ret = -1; + int ret = 0; - fDrzp = drizzle_create(); - if (fDrzp != NULL) + fCon = mysql_init(NULL); + if (fCon != NULL) { - fDrzcp = drizzle_con_add_tcp(fDrzp, h, p, u, w, d, DRIZZLE_CON_MYSQL); - if (fDrzcp != NULL) + if (mysql_real_connect(fCon, h, u, w, d, p, NULL, 0) == NULL) { - ret = drizzle_con_connect(fDrzcp); - if (ret != 0) - fErrStr = "fatal error in drizzle_con_connect()"; - } - else - { - fErrStr = "fatal error in drizzle_con_add_tcp()"; + fErrStr = "fatal error in mysql_real_connect()"; + ret = mysql_errno(fCon); } } else { - fErrStr = "fatal error in drizzle_create()"; + fErrStr = "fatal error in mysql_init()"; + ret = -1; } return ret; } -int DrizzleMySQL::run(const char* query) +int LibMySQL::run(const char* query) { int ret = 0; - drizzle_return_t drzret; - fDrzrp = drizzle_query_str(fDrzcp, fDrzrp, query, &drzret); - if (drzret == 0 && fDrzrp != NULL) + if (mysql_query(fCon, query) != 0) { - ret = drzret = drizzle_result_buffer(fDrzrp); - if (drzret != 0) - fErrStr = "fatal error reading result from crossengine client lib"; - } - else - { - fErrStr = "fatal error executing query in crossengine client lib"; - if (drzret != 0) - ret = drzret; - else - ret = -1; + fErrStr = "fatal error reading result from crossengine client lib"; + ret = -1; } + fRes = mysql_use_result(fCon); + if (fRes == NULL) + { + fErrStr = "fatal error reading result from crossengine client lib"; + ret = -1; + } return ret; } @@ -164,13 +144,13 @@ CrossEngineStep::CrossEngineStep( fExtendedInfo = "CES: "; getMysqldInfo(jobInfo); fQtc.stepParms().stepType = StepTeleStats::T_CES; - drizzle = new DrizzleMySQL(); + mysql = new LibMySQL(); } CrossEngineStep::~CrossEngineStep() { - delete drizzle; + delete mysql; } @@ -463,20 +443,20 @@ void CrossEngineStep::execute() sts.total_units_of_work = 1; postStepStartTele(sts); - ret = drizzle->init(fHost.c_str(), fPort, fUser.c_str(), fPasswd.c_str(), fSchema.c_str()); + ret = mysql->init(fHost.c_str(), fPort, fUser.c_str(), fPasswd.c_str(), fSchema.c_str()); if (ret != 0) - handleMySqlError(drizzle->getError().c_str(), ret); + handleMySqlError(mysql->getError().c_str(), ret); string query(makeQuery()); fLogger->logMessage(logging::LOG_TYPE_INFO, "QUERY to foreign engine: " + query); if (traceOn()) cout << "QUERY: " << query << endl; - ret = drizzle->run(query.c_str()); + ret = mysql->run(query.c_str()); if (ret != 0) - handleMySqlError(drizzle->getError().c_str(), ret); + handleMySqlError(mysql->getError().c_str(), ret); - int num_fields = drizzle->getFieldCount(); + int num_fields = mysql->getFieldCount(); char** rowIn; // input //shared_array rgDataDelivered; // output @@ -497,7 +477,7 @@ void CrossEngineStep::execute() bool doFE3 = (fFeSelects.size() > 0); if (!doFE1 && !doFE3) { - while ((rowIn = drizzle->nextRow()) && !cancelled()) + while ((rowIn = mysql->nextRow()) && !cancelled()) { for(int i = 0; i < num_fields; i++) setField(i, rowIn[i], fRowDelivered); @@ -514,7 +494,7 @@ void CrossEngineStep::execute() rgDataFe1.reset(new uint8_t[rowFe1.getSize()]); rowFe1.setData(rgDataFe1.get()); - while ((rowIn = drizzle->nextRow()) && !cancelled()) + while ((rowIn = mysql->nextRow()) && !cancelled()) { // Parse the columns used in FE1 first, the other column may not need be parsed. for(int i = 0; i < num_fields; i++) @@ -549,7 +529,7 @@ void CrossEngineStep::execute() rgDataFe3.reset(new uint8_t[rowFe3.getSize()]); rowFe3.setData(rgDataFe3.get()); - while ((rowIn = drizzle->nextRow()) && !cancelled()) + while ((rowIn = mysql->nextRow()) && !cancelled()) { for(int i = 0; i < num_fields; i++) setField(i, rowIn[i], rowFe3); @@ -577,7 +557,7 @@ void CrossEngineStep::execute() rgDataFe3.reset(new uint8_t[rowFe3.getSize()]); rowFe3.setData(rgDataFe3.get()); - while ((rowIn = drizzle->nextRow()) && !cancelled()) + while ((rowIn = mysql->nextRow()) && !cancelled()) { // Parse the columns used in FE1 first, the other column may not need be parsed. for(int i = 0; i < num_fields; i++) @@ -609,7 +589,7 @@ void CrossEngineStep::execute() //INSERT_ADAPTER(fOutputDL, rgDataDelivered); fOutputDL->insert(rgDataDelivered); - fRowsRetrieved = drizzle->getRowCount(); + fRowsRetrieved = mysql->getRowCount(); } catch (IDBExcept& iex) { diff --git a/dbcon/joblist/crossenginestep.h b/dbcon/joblist/crossenginestep.h index a0f21cc50..be83f6c2e 100644 --- a/dbcon/joblist/crossenginestep.h +++ b/dbcon/joblist/crossenginestep.h @@ -21,13 +21,15 @@ #ifndef JOBLIST_CROSSENGINESTEP_H #define JOBLIST_CROSSENGINESTEP_H +#include +#include + #include #include "jobstep.h" #include "primitivestep.h" -#include "libdrizzle-2.0/drizzle.h" -#include "libdrizzle-2.0/drizzle_client.h" +using namespace std; // forward reference namespace execplan @@ -44,11 +46,11 @@ class FuncExp; namespace joblist { -class DrizzleMySQL +class LibMySQL { public: - DrizzleMySQL(); - ~DrizzleMySQL(); + LibMySQL(); + ~LibMySQL(); // init: host port username passwd db int init(const char*, unsigned int, const char*, const char*, const char*); @@ -56,16 +58,15 @@ public: // run the query int run(const char* q); - int getFieldCount() { return drizzle_result_column_count(fDrzrp); } - int getRowCount() { return drizzle_result_row_count(fDrzrp); } - char** nextRow() { return drizzle_row_next(fDrzrp); } - const string& getError() { return fErrStr; } + int getFieldCount() { return mysql_num_fields(fRes); } + int getRowCount() { return mysql_num_rows(fRes); } + char** nextRow() { return mysql_fetch_row(fRes); } + const std::string& getError() { return fErrStr; } private: - drizzle_st* fDrzp; - drizzle_con_st* fDrzcp; - drizzle_result_st* fDrzrp; - string fErrStr; + MYSQL* fCon; + MYSQL_RES* fRes; + std::string fErrStr; }; /** @brief class CrossEngineStep @@ -212,7 +213,7 @@ protected: rowgroup::RowGroup fRowGroupFe3; funcexp::FuncExp* fFeInstance; - DrizzleMySQL* drizzle; + LibMySQL* mysql; }; diff --git a/dbcon/joblist/jlf_graphics.cpp b/dbcon/joblist/jlf_graphics.cpp index c81898ee3..59837069f 100644 --- a/dbcon/joblist/jlf_graphics.cpp +++ b/dbcon/joblist/jlf_graphics.cpp @@ -17,12 +17,13 @@ // $Id: jlf_graphics.cpp 9550 2013-05-17 23:58:07Z xlou $ +// Cross engine at the top due to MySQL includes +#include "crossenginestep.h" #include using namespace std; #include "joblist.h" #include "primitivestep.h" -#include "crossenginestep.h" #include "subquerystep.h" #include "windowfunctionstep.h" #include "tupleaggregatestep.h" diff --git a/dbcon/joblist/jlf_tuplejoblist.cpp b/dbcon/joblist/jlf_tuplejoblist.cpp index ed9bacc99..efac6ea8f 100644 --- a/dbcon/joblist/jlf_tuplejoblist.cpp +++ b/dbcon/joblist/jlf_tuplejoblist.cpp @@ -17,7 +17,8 @@ // $Id: jlf_tuplejoblist.cpp 9728 2013-07-26 22:08:20Z xlou $ - +// Cross engine needs to be at the top due to MySQL includes +#include "crossenginestep.h" #include #include #include @@ -55,7 +56,6 @@ using namespace dataconvert; #include "limitedorderby.h" #include "jobstep.h" #include "primitivestep.h" -#include "crossenginestep.h" #include "expressionstep.h" #include "subquerystep.h" #include "tupleaggregatestep.h" diff --git a/dbcon/joblist/joblist.cpp b/dbcon/joblist/joblist.cpp index e4da0e568..f70b81541 100644 --- a/dbcon/joblist/joblist.cpp +++ b/dbcon/joblist/joblist.cpp @@ -18,7 +18,8 @@ // $Id: joblist.cpp 9655 2013-06-25 23:08:13Z xlou $ - +// Cross engine needs to be at the top due to MySQL includes +#include "crossenginestep.h" #include "errorcodes.h" #include #include @@ -34,7 +35,6 @@ using namespace execplan; #include "errorids.h" #include "jobstep.h" #include "primitivestep.h" -#include "crossenginestep.h" #include "subquerystep.h" #include "tupleaggregatestep.h" #include "tupleannexstep.h" diff --git a/dbcon/joblist/tupleaggregatestep.cpp b/dbcon/joblist/tupleaggregatestep.cpp index 595cb174d..eb6f438d8 100644 --- a/dbcon/joblist/tupleaggregatestep.cpp +++ b/dbcon/joblist/tupleaggregatestep.cpp @@ -19,6 +19,9 @@ //#define NDEBUG +// Cross engine needs to be at top due to MySQL includes +#include "crossenginestep.h" + #include #include #include @@ -61,7 +64,6 @@ using namespace querytele; #include "primitivestep.h" #include "subquerystep.h" #include "tuplehashjoin.h" -#include "crossenginestep.h" #include "tupleaggregatestep.h" //#include "stopwatch.cpp" diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 744f6b40e..d12f37864 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -16,7 +16,6 @@ add_subdirectory(udfsdk) add_subdirectory(compress) add_subdirectory(batchloader) add_subdirectory(ddlcleanup) -add_subdirectory(mysqlcl_idb) add_subdirectory(querystats) add_subdirectory(windowfunction) add_subdirectory(idbdatafile) diff --git a/utils/mysqlcl_idb/CMakeLists.txt b/utils/mysqlcl_idb/CMakeLists.txt deleted file mode 100644 index 0ef0b5f97..000000000 --- a/utils/mysqlcl_idb/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ - -include_directories( /usr/include/libxml2 ${ENGINE_COMMON_INCLUDES} ) - - -########### next target ############### - -set(mysqlcl_idb_LIB_SRCS - column.cc - command.cc - conn.cc - conn_uds.cc - drizzle.cc - field.cc - handshake.cc - pack.cc - query.cc - result.cc - row.cc - sha1.cc - state.cc) - -add_library(mysqlcl_idb SHARED ${mysqlcl_idb_LIB_SRCS}) - -set_target_properties(mysqlcl_idb PROPERTIES VERSION 1.0.0 SOVERSION 1) - -install(TARGETS mysqlcl_idb DESTINATION ${ENGINE_LIBDIR} COMPONENT libs) - diff --git a/utils/mysqlcl_idb/Makefile.am b/utils/mysqlcl_idb/Makefile.am deleted file mode 100644 index d3e0231a0..000000000 --- a/utils/mysqlcl_idb/Makefile.am +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (C) 2014 InfiniDB, Inc. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; version 2 of -# the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. - -# $Id$ -## Process this file with automake to produce Makefile.in - -AM_CPPFLAGS = $(idb_common_includes) $(idb_cppflags) -AM_CFLAGS = $(idb_cflags) -AM_CXXFLAGS = $(idb_cxxflags) -AM_LDFLAGS = -version-info 1:0:0 $(idb_ldflags) -lib_LTLIBRARIES = libmysqlcl_idb.la -libmysqlcl_idb_la_CPPFLAGS = -I/usr/include/libxml2 $(AM_CPPFLAGS) -libmysqlcl_idb_la_SOURCES = \ - column.cc \ - command.cc \ - conn.cc \ - conn_uds.cc \ - drizzle.cc \ - field.cc \ - handshake.cc \ - pack.cc \ - query.cc \ - result.cc \ - row.cc \ - sha1.cc \ - state.cc -include_HEADERS = - -test: - -coverage: - -leakcheck: - -docs: - -bootstrap: install-data-am - -install-data-hook: - cp -Rpf libdrizzle-2.0 $(DESTDIR)$(includedir) diff --git a/utils/mysqlcl_idb/column.cc b/utils/mysqlcl_idb/column.cc deleted file mode 100644 index 371ea685f..000000000 --- a/utils/mysqlcl_idb/column.cc +++ /dev/null @@ -1,1208 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -/** - * @file - * @brief Column definitions - */ - -#include - -/* - * Private variables. - */ - -static drizzle_column_type_t _column_type_drizzle_map_to[]= -{ - DRIZZLE_COLUMN_TYPE_TINY, - DRIZZLE_COLUMN_TYPE_LONG, - DRIZZLE_COLUMN_TYPE_DOUBLE, - DRIZZLE_COLUMN_TYPE_NULL, - DRIZZLE_COLUMN_TYPE_TIMESTAMP, - DRIZZLE_COLUMN_TYPE_LONGLONG, - DRIZZLE_COLUMN_TYPE_DATETIME, - DRIZZLE_COLUMN_TYPE_NEWDATE, - DRIZZLE_COLUMN_TYPE_VARCHAR, - DRIZZLE_COLUMN_TYPE_NEWDECIMAL, - DRIZZLE_COLUMN_TYPE_ENUM, - DRIZZLE_COLUMN_TYPE_BLOB -}; - -static drizzle_column_type_drizzle_t _column_type_drizzle_map_from[]= -{ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 0 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_BOOLEAN, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_DOUBLE, - DRIZZLE_COLUMN_TYPE_DRIZZLE_NULL, - DRIZZLE_COLUMN_TYPE_DRIZZLE_TIMESTAMP, - DRIZZLE_COLUMN_TYPE_DRIZZLE_LONGLONG, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 10 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_DATETIME, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_DATE, - DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 20 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 30 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 40 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 50 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 60 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 70 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 80 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 90 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 100 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 110 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 120 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 130 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 140 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 150 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 160 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 170 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 180 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 190 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 200 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 210 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 220 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 230 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 240 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_NEWDECIMAL, - DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 250 */ - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX -}; - -/* - * Common definitions - */ - -drizzle_column_st *drizzle_column_create(drizzle_result_st *result, - drizzle_column_st *column) -{ - if (result == NULL) - { - return NULL; - } - - if (column == NULL) - { - column= new (std::nothrow) drizzle_column_st; - - if (column == NULL) - { - return NULL; - } - - column->result= result; - /* SET BELOW: column->next */ - column->prev= NULL; - column->options.is_allocated= true; - column->catalog[0]= '\0'; - column->schema[0]= '\0'; - column->table[0]= '\0'; - column->orig_table[0]= '\0'; - column->name[0]= '\0'; - column->orig_name[0]= '\0'; - column->charset= 0; - column->size= 0; - column->max_size= 0; - column->type= static_cast(0); - column->flags= drizzle_column_flags_t(); - column->decimals= 0; - /* UNSET: column->default_value */ - column->default_value_size= 0; - } - else - { - column->result = result; - /* SET BELOW: column->next */ - column->prev = NULL; - column->options.is_allocated= false; - column->catalog[0] = '\0'; - column->schema[0] = '\0'; - column->table[0] = '\0'; - column->orig_table[0] = '\0'; - column->name[0] = '\0'; - column->orig_name[0] = '\0'; - column->charset = 0; - column->size = 0; - column->max_size = 0; - column->type = static_cast(0); - column->flags = drizzle_column_flags_t(); - column->decimals = 0; - /* UNSET: column->default_value */ - column->default_value_size = 0; - } - - column->result= result; - - if (result->column_list) - result->column_list->prev= column; - column->next= result->column_list; - result->column_list= column; - - return column; -} - -void drizzle_column_free(drizzle_column_st *column) -{ - if (column == NULL) - { - return; - } - - if (column->result->column_list == column) - { - column->result->column_list= column->next; - } - - if (column->prev) - { - column->prev->next= column->next; - } - - if (column->next) - { - column->next->prev= column->prev; - } - - if (column->options.is_allocated) - { - delete column; - } -} - -drizzle_result_st *drizzle_column_drizzle_result(drizzle_column_st *column) -{ - if (column == NULL) - { - return NULL; - } - - return column->result; -} - -const char *drizzle_column_catalog(drizzle_column_st *column) -{ - if (column == NULL) - { - return NULL; - } - - return column->catalog; -} - -const char *drizzle_column_shema(drizzle_column_st *column) -{ - if (column == NULL) - { - return NULL; - } - - return column->schema; -} - -const char *drizzle_column_db(drizzle_column_st *column) -{ - return drizzle_column_shema(column); -} - -const char *drizzle_column_table(drizzle_column_st *column) -{ - if (column == NULL) - { - return NULL; - } - - return column->table; -} - -const char *drizzle_column_orig_table(drizzle_column_st *column) -{ - if (column == NULL) - { - return NULL; - } - - return column->orig_table; -} - -const char *drizzle_column_name(drizzle_column_st *column) -{ - if (column == NULL) - { - return NULL; - } - - return column->name; -} - -const char *drizzle_column_orig_name(drizzle_column_st *column) -{ - if (column == NULL) - { - return NULL; - } - - return column->orig_name; -} - -drizzle_charset_t drizzle_column_charset(drizzle_column_st *column) -{ - if (column == NULL) - { - return 0; - } - - return column->charset; -} - -uint32_t drizzle_column_size(drizzle_column_st *column) -{ - if (column == NULL) - { - return 0; - } - - return column->size; -} - -size_t drizzle_column_max_size(drizzle_column_st *column) -{ - if (column == NULL) - { - return 0; - } - - return column->max_size; -} - -void drizzle_column_set_max_size(drizzle_column_st *column, size_t size) -{ - if (column == NULL) - { - return; - } - - column->max_size= size; -} - -drizzle_column_type_t drizzle_column_type(drizzle_column_st *column) -{ - if (column == NULL) - { - return drizzle_column_type_t(); - } - - return column->type; -} - -drizzle_column_type_drizzle_t drizzle_column_type_drizzle(drizzle_column_st *column) -{ - if (column == NULL) - { - return drizzle_column_type_drizzle_t(); - } - - return _column_type_drizzle_map_from[column->type]; -} - -int drizzle_column_flags(drizzle_column_st *column) -{ - if (column == NULL) - { - return 0; - } - - return column->flags; -} - -uint8_t drizzle_column_decimals(drizzle_column_st *column) -{ - if (column == NULL) - { - return 0; - } - - return column->decimals; -} - -const uint8_t *drizzle_column_default_value(drizzle_column_st *column, - size_t *size) -{ - *size= column->default_value_size; - return column->default_value; -} - -/* - * Client definitions - */ - -drizzle_return_t drizzle_column_skip(drizzle_result_st *result) -{ - if (result == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - if (drizzle_state_none(result->con)) - { - result->options|= DRIZZLE_RESULT_SKIP_COLUMN; - - drizzle_state_push(result->con, drizzle_state_column_read); - drizzle_state_push(result->con, drizzle_state_packet_read); - } - drizzle_return_t ret= drizzle_state_loop(result->con); - result->options&= ~DRIZZLE_RESULT_SKIP_COLUMN; - return ret; -} - -drizzle_return_t drizzle_column_skip_all(drizzle_result_st *result) -{ - if (result == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - for (uint16_t it= 1; it <= result->column_count; it++) - { - drizzle_return_t ret= drizzle_column_skip(result); - if (ret != DRIZZLE_RETURN_OK) - { - return ret; - } - } - - return DRIZZLE_RETURN_OK; -} - -drizzle_column_st *drizzle_column_read(drizzle_result_st *result, - drizzle_column_st *column, - drizzle_return_t *ret_ptr) -{ - if (result == NULL) - { - return NULL; - } - - if (drizzle_state_none(result->con)) - { - result->column= column; - - drizzle_state_push(result->con, drizzle_state_column_read); - drizzle_state_push(result->con, drizzle_state_packet_read); - } - - *ret_ptr= drizzle_state_loop(result->con); - return result->column; -} - -drizzle_return_t drizzle_column_buffer(drizzle_result_st *result) -{ - if (result == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - drizzle_return_t ret; - - if (result->column_buffer == NULL) - { - if (result->column_count == 0) - { - result->options|= DRIZZLE_RESULT_BUFFER_COLUMN; - return DRIZZLE_RETURN_OK; - } - - result->column_buffer= new (std::nothrow) drizzle_column_st[result->column_count]; - - if (result->column_buffer == NULL) - { - return DRIZZLE_RETURN_MEMORY; - } - } - - /* No while body, just keep calling to buffer columns. */ - while (drizzle_column_read(result, - &(result->column_buffer[result->column_current]), - &ret) != NULL && ret == DRIZZLE_RETURN_OK) - { } - - if (ret == DRIZZLE_RETURN_OK) - { - result->column_current= 0; - result->options|= DRIZZLE_RESULT_BUFFER_COLUMN; - } - - return ret; -} - -drizzle_column_st *drizzle_column_next(drizzle_result_st *result) -{ - if (result == NULL) - { - return NULL; - } - - if (result->column_current == result->column_count) - { - return NULL; - } - - result->column_current++; - return &(result->column_buffer[result->column_current - 1]); -} - -drizzle_column_st *drizzle_column_prev(drizzle_result_st *result) -{ - if (result->column_current == 0) - return NULL; - - result->column_current--; - return &(result->column_buffer[result->column_current]); -} - -void drizzle_column_seek(drizzle_result_st *result, uint16_t column) -{ - if (result == NULL) - { - return; - } - - if (column <= result->column_count) - { - result->column_current= column; - } -} - -drizzle_column_st *drizzle_column_index(drizzle_result_st *result, uint16_t column) -{ - if (result == NULL) - { - return NULL; - } - - if (column >= result->column_count) - { - return NULL; - } - - return &(result->column_buffer[column]); -} - -uint16_t drizzle_column_current(drizzle_result_st *result) -{ - if (result == NULL) - { - return 0; - } - - return result->column_current; -} - -/* - * Server definitions - */ - -drizzle_return_t drizzle_column_write(drizzle_result_st *result, - drizzle_column_st *column) -{ - if (result == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - if (drizzle_state_none(result->con)) - { - result->column= column; - - drizzle_state_push(result->con, drizzle_state_column_write); - } - - return drizzle_state_loop(result->con); -} - -void drizzle_column_set_catalog(drizzle_column_st *column, const char *catalog) -{ - if (column == NULL) - { - return; - } - - if (catalog == NULL) - { - column->catalog[0]= 0; - } - else - { - strncpy(column->catalog, catalog, DRIZZLE_MAX_CATALOG_SIZE); - column->catalog[DRIZZLE_MAX_CATALOG_SIZE - 1]= 0; - } -} - -void drizzle_column_set_schema(drizzle_column_st *column, const char *schema) -{ - if (column == NULL) - { - return; - } - - if (schema == NULL) - { - column->schema[0]= 0; - } - else - { - strncpy(column->schema, schema, DRIZZLE_MAX_DB_SIZE); - column->schema[DRIZZLE_MAX_DB_SIZE - 1]= 0; - } -} - -void drizzle_column_set_db(drizzle_column_st *column, const char *schema) -{ - drizzle_column_set_schema(column, schema); -} - - -void drizzle_column_set_table(drizzle_column_st *column, const char *table) -{ - if (column == NULL) - { - return; - } - - if (table == NULL) - { - column->table[0]= 0; - } - else - { - strncpy(column->table, table, DRIZZLE_MAX_TABLE_SIZE); - column->table[DRIZZLE_MAX_TABLE_SIZE - 1]= 0; - } -} - -void drizzle_column_set_orig_table(drizzle_column_st *column, - const char *orig_table) -{ - if (column == NULL) - { - return; - } - - if (orig_table == NULL) - column->orig_table[0]= 0; - else - { - strncpy(column->orig_table, orig_table, DRIZZLE_MAX_TABLE_SIZE); - column->orig_table[DRIZZLE_MAX_TABLE_SIZE - 1]= 0; - } -} - -void drizzle_column_set_name(drizzle_column_st *column, const char *name) -{ - if (column == NULL) - { - return; - } - - if (name == NULL) - column->name[0]= 0; - else - { - strncpy(column->name, name, DRIZZLE_MAX_COLUMN_NAME_SIZE); - column->name[DRIZZLE_MAX_COLUMN_NAME_SIZE - 1]= 0; - } -} - -void drizzle_column_set_orig_name(drizzle_column_st *column, - const char *orig_name) -{ - if (column == NULL) - { - return; - } - - if (orig_name == NULL) - column->orig_name[0]= 0; - else - { - strncpy(column->orig_name, orig_name, DRIZZLE_MAX_COLUMN_NAME_SIZE); - column->orig_name[DRIZZLE_MAX_COLUMN_NAME_SIZE - 1]= 0; - } -} - -void drizzle_column_set_charset(drizzle_column_st *column, - drizzle_charset_t charset) -{ - if (column == NULL) - { - return; - } - - column->charset= charset; -} - -void drizzle_column_set_size(drizzle_column_st *column, uint32_t size) -{ - if (column == NULL) - { - return; - } - - column->size= size; -} - -void drizzle_column_set_type(drizzle_column_st *column, - drizzle_column_type_t type) -{ - if (column == NULL) - { - return; - } - - column->type= type; -} - -void drizzle_column_set_flags(drizzle_column_st *column, - int flags) -{ - if (column == NULL) - { - return; - } - - column->flags= flags; -} - -void drizzle_column_set_decimals(drizzle_column_st *column, uint8_t decimals) -{ - if (column == NULL) - { - return; - } - - column->decimals= decimals; -} - -void drizzle_column_set_default_value(drizzle_column_st *column, - const uint8_t *default_value, - size_t size) -{ - if (column == NULL) - { - return; - } - - if (default_value == NULL) - { - column->default_value[0]= 0; - } - else - { - if (size < DRIZZLE_MAX_DEFAULT_VALUE_SIZE) - { - memcpy(column->default_value, default_value, size); - column->default_value[size]= 0; - column->default_value_size= size; - } - else - { - memcpy(column->default_value, default_value, - DRIZZLE_MAX_DEFAULT_VALUE_SIZE - 1); - column->default_value[DRIZZLE_MAX_DEFAULT_VALUE_SIZE - 1]= 0; - column->default_value_size= DRIZZLE_MAX_DEFAULT_VALUE_SIZE; - } - } -} - -/* - * Internal state functions. - */ - -drizzle_return_t drizzle_state_column_read(drizzle_con_st *con) -{ - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - drizzle_column_st *column; - drizzle_column_type_drizzle_t drizzle_type; - - drizzle_log_debug(con->drizzle, "drizzle_state_column_read"); - - /* Assume the entire column packet will fit in the buffer. */ - if (con->buffer_size < con->packet_size) - { - drizzle_state_push(con, drizzle_state_read); - return DRIZZLE_RETURN_OK; - } - - if (con->packet_size == 5 && con->buffer_ptr[0] == 254) - { - /* EOF packet marking end of columns. */ - con->result->column= NULL; - con->result->warning_count= drizzle_get_byte2(con->buffer_ptr + 1); - con->status= (drizzle_con_status_t)drizzle_get_byte2(con->buffer_ptr + 3); - con->buffer_ptr+= 5; - con->buffer_size-= 5; - - drizzle_state_pop(con); - } - else if (con->result->options & DRIZZLE_RESULT_SKIP_COLUMN) - { - con->buffer_ptr+= con->packet_size; - con->buffer_size-= con->packet_size; - con->packet_size= 0; - con->result->column_count++; - - drizzle_state_pop(con); - } - else - { - column= drizzle_column_create(con->result, con->result->column); - if (column == NULL) - return DRIZZLE_RETURN_MEMORY; - - con->result->column= column; - - /* These functions can only fail if they need to read data, but we know we - buffered the entire packet, so ignore returns. */ - (void)drizzle_unpack_string(con, column->catalog, DRIZZLE_MAX_CATALOG_SIZE); - (void)drizzle_unpack_string(con, column->schema, DRIZZLE_MAX_DB_SIZE); - (void)drizzle_unpack_string(con, column->table, DRIZZLE_MAX_TABLE_SIZE); - (void)drizzle_unpack_string(con, column->orig_table, - DRIZZLE_MAX_TABLE_SIZE); - (void)drizzle_unpack_string(con, column->name, - DRIZZLE_MAX_COLUMN_NAME_SIZE); - (void)drizzle_unpack_string(con, column->orig_name, - DRIZZLE_MAX_COLUMN_NAME_SIZE); - - /* Skip one filler byte. */ - column->charset= (drizzle_charset_t)drizzle_get_byte2(con->buffer_ptr + 1); - column->size= drizzle_get_byte4(con->buffer_ptr + 3); - - if (con->options & DRIZZLE_CON_MYSQL) - column->type= (drizzle_column_type_t)con->buffer_ptr[7]; - else - { - drizzle_type= (drizzle_column_type_drizzle_t)con->buffer_ptr[7]; - if (drizzle_type >= DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX) - drizzle_type= DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX; - column->type= _column_type_drizzle_map_to[drizzle_type]; - } - - column->flags= drizzle_get_byte2(con->buffer_ptr + 8); - if (column->type <= DRIZZLE_COLUMN_TYPE_INT24 && - column->type != DRIZZLE_COLUMN_TYPE_TIMESTAMP) - { - column->flags|= DRIZZLE_COLUMN_FLAGS_NUM; - } - - column->decimals= con->buffer_ptr[10]; - /* Skip two reserved bytes. */ - - con->buffer_ptr+= 13; - con->buffer_size-= 13; - con->packet_size-= 13; - - if (con->packet_size > 0) - { - drizzle_column_set_default_value(column, con->buffer_ptr, - con->packet_size); - - con->buffer_ptr+= con->packet_size; - con->buffer_size-= con->packet_size; - } - else - column->default_value[0]= 0; - - con->result->column_current++; - - drizzle_state_pop(con); - } - - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_column_write(drizzle_con_st *con) -{ - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - uint8_t *start= con->buffer_ptr + con->buffer_size; - uint8_t *ptr; - drizzle_column_st *column= con->result->column; - - drizzle_log_debug(con->drizzle, "drizzle_state_column_write"); - - /* Calculate max packet size. */ - con->packet_size= 9 + strlen(column->catalog) - + 9 + strlen(column->schema) - + 9 + strlen(column->table) - + 9 + strlen(column->orig_table) - + 9 + strlen(column->name) - + 9 + strlen(column->orig_name) - + 1 /* Unused */ - + 2 /* Charset */ - + 4 /* Size */ - + 1 /* Type */ - + 2 /* Flags */ - + 1 /* Decimals */ - + 2 /* Unused */ - + column->default_value_size; - - /* Assume the entire column packet will fit in the buffer. */ - if ((con->packet_size + 4) > DRIZZLE_MAX_BUFFER_SIZE) - { - drizzle_set_error(con->drizzle, "drizzle_state_column_write", - "buffer too small:%zu", con->packet_size + 4); - return DRIZZLE_RETURN_INTERNAL_ERROR; - } - - /* Flush buffer if there is not enough room. */ - if (((size_t)DRIZZLE_MAX_BUFFER_SIZE - (size_t)(start - con->buffer)) < - con->packet_size) - { - drizzle_state_push(con, drizzle_state_write); - return DRIZZLE_RETURN_OK; - } - - /* Store packet size at the end since it may change. */ - ptr= start; - ptr[3]= con->packet_number; - con->packet_number++; - ptr+= 4; - - ptr= drizzle_pack_string(column->catalog, ptr); - ptr= drizzle_pack_string(column->schema, ptr); - ptr= drizzle_pack_string(column->table, ptr); - ptr= drizzle_pack_string(column->orig_table, ptr); - ptr= drizzle_pack_string(column->name, ptr); - ptr= drizzle_pack_string(column->orig_name, ptr); - - /* This unused byte is set to 12 for some reason. */ - ptr[0]= 12; - ptr++; - - drizzle_set_byte2(ptr, column->charset); - ptr+= 2; - - drizzle_set_byte4(ptr, column->size); - ptr+= 4; - - if (con->options & DRIZZLE_CON_MYSQL) - { - ptr[0]= column->type; - } - else - { - ptr[0]= _column_type_drizzle_map_from[column->type]; - } - ptr++; - - drizzle_set_byte2(ptr, column->flags); - ptr+= 2; - - ptr[0]= column->decimals; - ptr++; - - memset(ptr, 0, 2); - ptr+= 2; - - if (column->default_value_size > 0) - { - memcpy(ptr, column->default_value, column->default_value_size); - ptr+= column->default_value_size; - } - - con->packet_size= ((size_t)(ptr - start) - 4); - con->buffer_size+= (4 + con->packet_size); - - /* Store packet size now. */ - drizzle_set_byte3(start, con->packet_size); - - con->result->column_current++; - - drizzle_state_pop(con); - - return DRIZZLE_RETURN_OK; -} diff --git a/utils/mysqlcl_idb/command.cc b/utils/mysqlcl_idb/command.cc deleted file mode 100644 index d86d3c152..000000000 --- a/utils/mysqlcl_idb/command.cc +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -/** - * @file - * @brief Command definitions - */ - -#include - -/* - * Private variables. - */ - -static drizzle_command_drizzle_t _command_drizzle_map[]= -{ - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_QUIT, - DRIZZLE_COMMAND_DRIZZLE_INIT_DB, - DRIZZLE_COMMAND_DRIZZLE_QUERY, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_SHUTDOWN, - DRIZZLE_COMMAND_DRIZZLE_END, // STATISTICS - DRIZZLE_COMMAND_DRIZZLE_END, // PROCESS_INFO - DRIZZLE_COMMAND_DRIZZLE_END, // CONNECT - DRIZZLE_COMMAND_DRIZZLE_KILL,// PROCESS_KILL - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_PING, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END, - DRIZZLE_COMMAND_DRIZZLE_END -}; - -/* - * State Definitions - */ - -drizzle_return_t drizzle_state_command_read(drizzle_con_st *con) -{ - drizzle_log_debug(con->drizzle, "drizzle_state_command_read"); - - if (con->buffer_size == 0) - { - drizzle_state_push(con, drizzle_state_read); - return DRIZZLE_RETURN_OK; - } - - if (con->command_total == 0) - { - con->command= (drizzle_command_t)(con->buffer_ptr[0]); - con->buffer_ptr++; - con->buffer_size--; - - con->command_total= (con->packet_size - 1); - } - - if (con->buffer_size < (con->command_total - con->command_offset)) - { - con->command_size= con->buffer_size; - con->command_offset+= con->command_size; - } - else - { - con->command_size= (con->command_total - con->command_offset); - con->command_offset= con->command_total; - } - - con->command_data= con->buffer_ptr; - con->buffer_ptr+= con->command_size; - con->buffer_size-= con->command_size; - - if (con->command_offset == con->command_total) - { - drizzle_state_pop(con); - } - else - { - return DRIZZLE_RETURN_PAUSE; - } - - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_command_write(drizzle_con_st *con) -{ - uint8_t *start; - uint8_t *ptr; - size_t free_size; - drizzle_return_t ret; - - drizzle_log_debug(con->drizzle, "drizzle_state_command_write"); - - if (con->command_data == NULL && con->command_total != 0 && - con->command != DRIZZLE_COMMAND_CHANGE_USER) - { - return DRIZZLE_RETURN_PAUSE; - } - - if (con->buffer_size == 0) - { - con->buffer_ptr= con->buffer; - start= con->buffer; - } - else - start= con->buffer_ptr + con->buffer_size; - - if (con->command_offset == 0) - { - /* Make sure we can fit the largest non-streaming packet, currently a - DRIZZLE_COMMAND_CHANGE_USER command. */ - - con->packet_size= 1 /* Command */ - + strlen(con->user) + 1 - + 1 /* Scramble size */ - + DRIZZLE_MAX_SCRAMBLE_SIZE - + strlen(con->schema) +1; - - /* Flush buffer if there is not enough room. */ - free_size= (size_t)DRIZZLE_MAX_BUFFER_SIZE - (size_t)(start - con->buffer); - if (free_size < con->packet_size) - { - drizzle_state_push(con, drizzle_state_write); - return DRIZZLE_RETURN_OK; - } - - /* Store packet size at the end since it may change. */ - con->packet_number= 1; - ptr= start; - ptr[3]= 0; - if (con->options & DRIZZLE_CON_MYSQL) - { - ptr[4]= uint8_t(con->command); - } - else - { - ptr[4]= uint8_t(_command_drizzle_map[con->command]); - } - ptr+= 5; - - if (con->command == DRIZZLE_COMMAND_CHANGE_USER) - { - ptr= drizzle_pack_auth(con, ptr, &ret); - if (ret != DRIZZLE_RETURN_OK) - return ret; - - con->buffer_size+= (4 + con->packet_size); - } - else if (con->command_total == 0) - { - con->packet_size= 1; - con->buffer_size+= 5; - } - else - { - con->packet_size= 1 + con->command_total; - free_size-= 5; - - /* Copy as much of the data in as we can into the write buffer. */ - if (con->command_size <= free_size) - { - memcpy(ptr, con->command_data, con->command_size); - con->command_offset= con->command_size; - con->command_data= NULL; - con->buffer_size+= 5 + con->command_size; - } - else - { - memcpy(ptr, con->command_data, free_size); - con->command_offset= free_size; - con->command_data+= free_size; - con->command_size-= free_size; - con->buffer_size+= 5 + free_size; - } - } - - /* Store packet size now. */ - drizzle_set_byte3(start, con->packet_size); - } - else - { - /* Write directly from the caller buffer for the rest. */ - con->buffer_ptr= con->command_data; - con->buffer_size= con->command_size; - con->command_offset+= con->command_size; - con->command_data= NULL; - } - - if (con->command_offset == con->command_total) - { - drizzle_state_pop(con); - - if (!(con->options & (DRIZZLE_CON_RAW_PACKET | - DRIZZLE_CON_NO_RESULT_READ)) && - con->command != DRIZZLE_COMMAND_FIELD_LIST) - { - drizzle_state_push(con, drizzle_state_result_read); - drizzle_state_push(con, drizzle_state_packet_read); - } - } - - drizzle_state_push(con, drizzle_state_write); - - return DRIZZLE_RETURN_OK; -} diff --git a/utils/mysqlcl_idb/conn.cc b/utils/mysqlcl_idb/conn.cc deleted file mode 100644 index dc671b322..000000000 --- a/utils/mysqlcl_idb/conn.cc +++ /dev/null @@ -1,1733 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -/** - * @file - * @brief Connection Definitions - */ - -#include - -/** - * @addtogroup drizzle_con_static Static Connection Declarations - * @ingroup drizzle_con - * @{ - */ - -/** - * Set socket options for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Standard drizzle return value. - */ -static drizzle_return_t _con_setsockopt(drizzle_con_st *con); - -/** @} */ - -/* - * Common Definitions - */ - -int drizzle_con_fd(const drizzle_con_st *con) -{ - return con->fd; -} - -drizzle_return_t drizzle_con_set_fd(drizzle_con_st *con, int fd) -{ - con->fd= fd; - - drizzle_return_t ret= _con_setsockopt(con); - if (ret != DRIZZLE_RETURN_OK) - con->drizzle->last_errno= errno; - - return ret; -} - -void drizzle_con_close(drizzle_con_st *con) -{ - if (con->fd == -1) - return; - - (void)closesocket(con->fd); - con->fd= -1; - - con->options&= ~DRIZZLE_CON_READY; - con->packet_number= 0; - con->buffer_ptr= con->buffer; - con->buffer_size= 0; - con->events= 0; - con->revents= 0; - - drizzle_state_reset(con); -} - -drizzle_return_t drizzle_con_set_events(drizzle_con_st *con, short events) -{ - if ((con->events | events) == con->events) - return DRIZZLE_RETURN_OK; - - con->events|= events; - - if (con->drizzle->event_watch_fn != NULL) - { - drizzle_return_t ret= con->drizzle->event_watch_fn(con, con->events, - con->drizzle->event_watch_context); - if (ret != DRIZZLE_RETURN_OK) - { - drizzle_con_close(con); - return ret; - } - } - - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_con_set_revents(drizzle_con_st *con, short revents) -{ - if (revents != 0) - con->options|= DRIZZLE_CON_IO_READY; - - con->revents= revents; - - /* Remove external POLLOUT watch if we didn't ask for it. Otherwise we spin - forever until another POLLIN state change. This is much more efficient - than removing POLLOUT on every state change since some external polling - mechanisms need to use a system call to change flags (like Linux epoll). */ - if (revents & POLLOUT && !(con->events & POLLOUT) && - con->drizzle->event_watch_fn != NULL) - { - drizzle_return_t ret= con->drizzle->event_watch_fn(con, con->events, - con->drizzle->event_watch_context); - if (ret != DRIZZLE_RETURN_OK) - { - drizzle_con_close(con); - return ret; - } - } - - con->events&= (short)~revents; - - return DRIZZLE_RETURN_OK; -} - -drizzle_st *drizzle_con_drizzle(const drizzle_con_st *con) -{ - return con->drizzle; -} - -const char *drizzle_con_error(const drizzle_con_st *con) -{ - return drizzle_error(con->drizzle); -} - -int drizzle_con_errno(const drizzle_con_st *con) -{ - return drizzle_errno(con->drizzle); -} - -uint16_t drizzle_con_error_code(const drizzle_con_st *con) -{ - return drizzle_error_code(con->drizzle); -} - -const char *drizzle_con_sqlstate(const drizzle_con_st *con) -{ - return drizzle_sqlstate(con->drizzle); -} - -int drizzle_con_options(const drizzle_con_st *con) -{ - return con->options; -} - -void drizzle_con_set_options(drizzle_con_st *con, int options) -{ - con->options= options; -} - -void drizzle_con_add_options(drizzle_con_st *con, int options) -{ - con->options|= options; - - /* If asking for the experimental Drizzle protocol, clean the MySQL flag. */ - if (con->options & DRIZZLE_CON_EXPERIMENTAL) - { - con->options&= ~DRIZZLE_CON_MYSQL; - } -} - -void drizzle_con_remove_options(drizzle_con_st *con, int options) -{ - con->options&= ~options; -} - -const char *drizzle_con_host(const drizzle_con_st *con) -{ - if (con == NULL) - { - return NULL; - } - - if (con->socket_type == DRIZZLE_CON_SOCKET_TCP) - { - if (con->socket.tcp.host == NULL && !(con->options & DRIZZLE_CON_LISTEN)) - { - return DRIZZLE_DEFAULT_TCP_HOST; - } - - return con->socket.tcp.host; - } - - return NULL; -} - -in_port_t drizzle_con_port(const drizzle_con_st *con) -{ - if (con->socket_type == DRIZZLE_CON_SOCKET_TCP) - { - if (con->socket.tcp.port != 0) - return con->socket.tcp.port; - - if (con->options & DRIZZLE_CON_MYSQL) - return DRIZZLE_DEFAULT_TCP_PORT_MYSQL; - - return DRIZZLE_DEFAULT_TCP_PORT; - } - - return 0; -} - -void drizzle_con_set_tcp(drizzle_con_st *con, const char *host, in_port_t port) -{ - drizzle_con_reset_addrinfo(con); - - con->socket_type= DRIZZLE_CON_SOCKET_TCP; - - if (host == NULL) - { - con->socket.tcp.host= NULL; - } - else - { - con->socket.tcp.host= con->socket.tcp.host_buffer; - strncpy(con->socket.tcp.host, host, NI_MAXHOST); - con->socket.tcp.host[NI_MAXHOST - 1]= 0; - } - - con->socket.tcp.port= port; -} - -const char *drizzle_con_user(const drizzle_con_st *con) -{ - if (con == NULL) - { - return NULL; - } - - return con->user; -} - -const char *drizzle_con_password(const drizzle_con_st *con) -{ - if (con == NULL) - { - return NULL; - } - - return con->password; -} - -void drizzle_con_set_auth(drizzle_con_st *con, const char *user, const char *password) -{ - if (con == NULL) - { - return; - } - - if (user == NULL) - { - con->user[0]= 0; - } - else - { - strncpy(con->user, user, DRIZZLE_MAX_USER_SIZE); - con->user[DRIZZLE_MAX_USER_SIZE - 1]= 0; - } - - if (password == NULL) - { - con->password[0]= 0; - } - else - { - strncpy(con->password, password, DRIZZLE_MAX_PASSWORD_SIZE); - con->password[DRIZZLE_MAX_PASSWORD_SIZE - 1]= 0; - } -} - -const char *drizzle_con_schema(const drizzle_con_st *con) -{ - if (con == NULL) - { - return NULL; - } - - return con->schema; -} - -const char *drizzle_con_db(const drizzle_con_st *con) -{ - return drizzle_con_schema(con); -} - -void drizzle_con_set_schema(drizzle_con_st *con, const char *schema) -{ - if (con == NULL) - { - return; - } - - if (schema == NULL) - { - con->schema[0]= 0; - } - else - { - strncpy(con->schema, schema, DRIZZLE_MAX_DB_SIZE); - con->schema[DRIZZLE_MAX_DB_SIZE - 1]= 0; - } -} - -void drizzle_con_set_db(drizzle_con_st *con, const char *schema) -{ - drizzle_con_set_schema(con, schema); -} - -void *drizzle_con_context(const drizzle_con_st *con) -{ - if (con == NULL) - { - return NULL; - } - - return con->context; -} - -void drizzle_con_set_context(drizzle_con_st *con, void *context) -{ - if (con == NULL) - { - return; - } - - con->context= context; -} - -void drizzle_con_set_context_free_fn(drizzle_con_st *con, - drizzle_con_context_free_fn *function) -{ - if (con == NULL) - { - return; - } - - con->context_free_fn= function; -} - -uint8_t drizzle_con_protocol_version(const drizzle_con_st *con) -{ - if (con == NULL) - { - return 0; - } - - return con->protocol_version; -} - -const char *drizzle_con_server_version(const drizzle_con_st *con) -{ - if (con == NULL) - { - return NULL; - } - - return con->server_version; -} - -uint32_t drizzle_con_server_version_number(const drizzle_con_st *con) -{ - if (con == NULL || con->server_version) - { - return 0; - } - - const char *current= con->server_version; - - char *end; - uint32_t major= (uint32_t)strtoul(current, &end, 10); - current= end + 1; - - uint32_t minor= (uint32_t)strtoul(current, &end, 10); - current= end + 1; - - uint32_t version= (uint32_t)strtoul(current, &end, 10); - - return (major * 10000) + (minor * 100) + version; -} - -uint32_t drizzle_con_thread_id(const drizzle_con_st *con) -{ - if (con == NULL) - { - return 0; - } - - return con->thread_id; -} - -const uint8_t *drizzle_con_scramble(const drizzle_con_st *con) -{ - if (con == NULL) - { - return 0; - } - - return con->scramble; -} - -int drizzle_con_capabilities(const drizzle_con_st *con) -{ - if (con == NULL) - { - return 0; - } - - return con->capabilities; -} - -drizzle_charset_t drizzle_con_charset(const drizzle_con_st *con) -{ - if (con == NULL) - { - return drizzle_charset_t(); - } - - return con->charset; -} - -drizzle_con_status_t drizzle_con_status(const drizzle_con_st *con) -{ - if (con == NULL) - { - return drizzle_con_status_t(); - } - - return con->status; -} - -uint32_t drizzle_con_max_packet_size(const drizzle_con_st *con) -{ - if (con == NULL) - { - return 0; - } - - return con->max_packet_size; -} - -/* - * Client Definitions - */ - -drizzle_return_t drizzle_con_connect(drizzle_con_st *con) -{ - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - if (con->options & DRIZZLE_CON_READY) - { - return DRIZZLE_RETURN_OK; - } - - if (drizzle_state_none(con)) - { - if (!(con->options & DRIZZLE_CON_RAW_PACKET)) - { - drizzle_state_push(con, drizzle_state_handshake_server_read); - drizzle_state_push(con, drizzle_state_packet_read); - } - - drizzle_state_push(con, drizzle_state_connect); - drizzle_state_push(con, drizzle_state_addrinfo); - } - - return drizzle_state_loop(con); -} - -drizzle_result_st *drizzle_con_quit(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr) -{ - return drizzle_con_command_write(con, result, DRIZZLE_COMMAND_QUIT, NULL, 0, - 0, ret_ptr); -} - -drizzle_result_st *drizzle_quit(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr) -{ - return drizzle_con_quit(con, result, ret_ptr); -} - -drizzle_result_st *drizzle_con_select_db(drizzle_con_st *con, - drizzle_result_st *result, - const char *db, - drizzle_return_t *ret_ptr) -{ - drizzle_con_set_db(con, db); - return drizzle_con_command_write(con, result, DRIZZLE_COMMAND_INIT_DB, - db, strlen(db), strlen(db), ret_ptr); -} - -drizzle_result_st *drizzle_select_db(drizzle_con_st *con, - drizzle_result_st *result, - const char *db, - drizzle_return_t *ret_ptr) -{ - return drizzle_con_select_db(con, result, db, ret_ptr); -} - -drizzle_result_st *drizzle_con_shutdown(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr) -{ - if (con == NULL) - { - return NULL; - } - - if (con->options & DRIZZLE_CON_MYSQL) - { - return drizzle_con_command_write(con, result, DRIZZLE_COMMAND_SHUTDOWN, - "0", 1, 1, ret_ptr); - } - - return drizzle_con_command_write(con, result, DRIZZLE_COMMAND_SHUTDOWN, NULL, - 0, 0, ret_ptr); -} - -drizzle_result_st *drizzle_shutdown(drizzle_con_st *con, - drizzle_result_st *result, uint32_t, - drizzle_return_t *ret_ptr) -{ - return drizzle_con_shutdown(con, result, ret_ptr); -} - -drizzle_result_st *drizzle_kill(drizzle_con_st *con, - drizzle_result_st *result, - uint32_t query_id, - drizzle_return_t *ret_ptr) -{ - uint32_t sent= htonl(query_id); - return drizzle_con_command_write(con, result, DRIZZLE_COMMAND_PROCESS_KILL, - &sent, sizeof(uint32_t), sizeof(uint32_t), ret_ptr); -} - -drizzle_result_st *drizzle_con_ping(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr) -{ - return drizzle_con_command_write(con, result, DRIZZLE_COMMAND_PING, NULL, 0, - 0, ret_ptr); -} - -drizzle_result_st *drizzle_ping(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr) -{ - return drizzle_con_ping(con, result, ret_ptr); -} - -drizzle_result_st *drizzle_con_command_write(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_command_t command, - const void *data, size_t size, - size_t total, - drizzle_return_t *ret_ptr) -{ - if (con == NULL) - { - return NULL; - } - - drizzle_return_t unused; - if (ret_ptr == NULL) - { - ret_ptr= &unused; - } - - if ((con->options & DRIZZLE_CON_READY) == 0) - { - if (con->options & DRIZZLE_CON_RAW_PACKET) - { - drizzle_set_error(con->drizzle, "drizzle_command_write", "connection not ready"); - *ret_ptr= DRIZZLE_RETURN_NOT_READY; - return NULL; - } - - *ret_ptr= drizzle_con_connect(con); - if (*ret_ptr != DRIZZLE_RETURN_OK) - { - return NULL; - } - } - - if (drizzle_state_none(con)) - { - if (con->options & (DRIZZLE_CON_RAW_PACKET | DRIZZLE_CON_NO_RESULT_READ)) - { - con->result= NULL; - } - else - { - for (drizzle_result_st *old_result= con->result_list; old_result != NULL; old_result= old_result->next) - { - if (result == old_result) - { - drizzle_set_error(con->drizzle, "drizzle_command_write", "result struct already in use"); - *ret_ptr= DRIZZLE_RETURN_INTERNAL_ERROR; - return NULL; - } - } - - con->result= drizzle_result_create_with(con, result); - if (con->result == NULL) - { - *ret_ptr= DRIZZLE_RETURN_MEMORY; - return NULL; - } - } - - con->command= command; - con->command_data= (uint8_t *)data; - con->command_size= size; - con->command_offset= 0; - con->command_total= total; - - drizzle_state_push(con, drizzle_state_command_write); - } - else if (con->command_data == NULL) - { - con->command_data= (uint8_t *)data; - con->command_size= size; - } - - *ret_ptr= drizzle_state_loop(con); - if (*ret_ptr == DRIZZLE_RETURN_PAUSE) - { - *ret_ptr= DRIZZLE_RETURN_OK; - } - else if (*ret_ptr != DRIZZLE_RETURN_OK && - *ret_ptr != DRIZZLE_RETURN_IO_WAIT && - *ret_ptr != DRIZZLE_RETURN_ERROR_CODE) - { - drizzle_result_free(con->result); - con->result= result; - } - - return con->result; -} - -/* - * Server Definitions - */ - -drizzle_return_t drizzle_con_listen(drizzle_con_st *con) -{ - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - if (con->options & DRIZZLE_CON_READY) - { - return DRIZZLE_RETURN_OK; - } - - if (drizzle_state_none(con)) - { - drizzle_state_push(con, drizzle_state_listen); - drizzle_state_push(con, drizzle_state_addrinfo); - } - - return drizzle_state_loop(con); -} - -int drizzle_con_backlog(const drizzle_con_st *con) -{ - if (con == NULL) - { - return 0; - } - - return con->backlog; -} - -void drizzle_con_set_backlog(drizzle_con_st *con, int backlog) -{ - if (con == NULL) - { - return; - } - - con->backlog= backlog; -} - -void drizzle_con_set_protocol_version(drizzle_con_st *con, uint8_t protocol_version) -{ - if (con == NULL) - { - return; - } - - con->protocol_version= protocol_version; -} - -void drizzle_con_set_server_version(drizzle_con_st *con, - const char *server_version) -{ - if (con == NULL) - { - return; - } - - if (server_version == NULL) - { - con->server_version[0]= 0; - } - else - { - strncpy(con->server_version, server_version, - DRIZZLE_MAX_SERVER_VERSION_SIZE); - con->server_version[DRIZZLE_MAX_SERVER_VERSION_SIZE - 1]= 0; - } -} - -void drizzle_con_set_thread_id(drizzle_con_st *con, uint32_t thread_id) -{ - if (con == NULL) - { - return; - } - - con->thread_id= thread_id; -} - -void drizzle_con_set_scramble(drizzle_con_st *con, const uint8_t *scramble) -{ - if (con == NULL) - { - return; - } - - if (scramble == NULL) - { - con->scramble= NULL; - } - else - { - con->scramble= con->scramble_buffer; - memcpy(con->scramble, scramble, DRIZZLE_MAX_SCRAMBLE_SIZE); - } -} - -void drizzle_con_set_capabilities(drizzle_con_st *con, - int capabilities) -{ - if (con == NULL) - { - return; - } - - con->capabilities= capabilities; -} - -void drizzle_con_set_charset(drizzle_con_st *con, drizzle_charset_t charset) -{ - if (con == NULL) - { - return; - } - - con->charset= charset; -} - -void drizzle_con_set_status(drizzle_con_st *con, drizzle_con_status_t status) -{ - if (con == NULL) - { - return; - } - - con->status= status; -} - -void drizzle_con_set_max_packet_size(drizzle_con_st *con, - uint32_t max_packet_size) -{ - if (con == NULL) - { - return; - } - - con->max_packet_size= max_packet_size; -} - -void drizzle_con_copy_handshake(drizzle_con_st *con, drizzle_con_st *from) -{ - if (con == NULL) - { - return; - } - - drizzle_con_set_auth(con, from->user, NULL); - drizzle_con_set_scramble(con, from->scramble); - drizzle_con_set_db(con, from->schema); - drizzle_con_set_protocol_version(con, from->protocol_version); - drizzle_con_set_server_version(con, from->server_version); - drizzle_con_set_thread_id(con, from->thread_id); - drizzle_con_set_scramble(con, from->scramble); - drizzle_con_set_capabilities(con, from->capabilities); - drizzle_con_set_charset(con, from->charset); - drizzle_con_set_status(con, from->status); - drizzle_con_set_max_packet_size(con, from->max_packet_size); -} - -void *drizzle_con_command_read(drizzle_con_st *con, - drizzle_command_t *command, size_t *offset, - size_t *size, size_t *total, - drizzle_return_t *ret_ptr) -{ - if (con == NULL) - { - return NULL; - } - - drizzle_return_t unused; - if (ret_ptr == NULL) - { - ret_ptr= &unused; - } - - if (drizzle_state_none(con)) - { - con->packet_number= 0; - con->command_offset= 0; - con->command_total= 0; - - drizzle_state_push(con, drizzle_state_command_read); - drizzle_state_push(con, drizzle_state_packet_read); - } - - *offset= con->command_offset; - - *ret_ptr= drizzle_state_loop(con); - if (*ret_ptr == DRIZZLE_RETURN_PAUSE) - *ret_ptr= DRIZZLE_RETURN_OK; - - *command= con->command; - *size= con->command_size; - *total= con->command_total; - - return con->command_data; -} - -void *drizzle_con_command_buffer(drizzle_con_st *con, - drizzle_command_t *command, size_t *total, - drizzle_return_t *ret_ptr) -{ - size_t offset= 0; - size_t size= 0; - - if (con == NULL) - { - return NULL; - } - - drizzle_return_t unused; - if (ret_ptr == NULL) - { - ret_ptr= &unused; - } - - size_t total_unused; - if (total == NULL) - { - total= &total_unused; - } - - uint8_t *command_data= - static_cast(drizzle_con_command_read(con, command, &offset, - &size, total, ret_ptr)); - if (*ret_ptr != DRIZZLE_RETURN_OK) - { - return NULL; - } - - if (command_data == NULL) - { - *total= 0; - return NULL; - } - - if (con->command_buffer == NULL) - { - con->command_buffer= new (std::nothrow) uint8_t[(*total) + 1]; - - if (con->command_buffer == NULL) - { - *total= 0; - *ret_ptr= DRIZZLE_RETURN_MEMORY; - return NULL; - } - } - - memcpy(con->command_buffer + offset, command_data, size); - - while ((offset + size) != (*total)) - { - command_data= (uint8_t *)drizzle_con_command_read(con, command, &offset, - &size, total, ret_ptr); - if (*ret_ptr != DRIZZLE_RETURN_OK) - { - return NULL; - } - - memcpy(con->command_buffer + offset, command_data, size); - } - - command_data= con->command_buffer; - con->command_buffer= NULL; - command_data[*total]= 0; - - return command_data; -} - -void drizzle_con_command_buffer_free(uint8_t *command_buffer) -{ - delete[] command_buffer; -} - -/* - * Local Definitions - */ - -void drizzle_con_reset_addrinfo(drizzle_con_st *con) -{ - switch (con->socket_type) - { - case DRIZZLE_CON_SOCKET_TCP: - if (con->socket.tcp.addrinfo != NULL) - { - freeaddrinfo(con->socket.tcp.addrinfo); - con->socket.tcp.addrinfo= NULL; - } - break; - - case DRIZZLE_CON_SOCKET_UDS: - con->socket.uds.addrinfo.ai_addr= NULL; - break; - - default: - break; - } - - con->addrinfo_next= NULL; -} - -/* - * State Definitions - */ - -drizzle_return_t drizzle_state_addrinfo(drizzle_con_st *con) -{ - drizzle_con_tcp_st *tcp; - const char *host; - char port[NI_MAXSERV]; - struct addrinfo ai; - int ret; - - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - drizzle_log_debug(con->drizzle, "drizzle_state_addrinfo"); - - switch (con->socket_type) - { - case DRIZZLE_CON_SOCKET_TCP: - tcp= &(con->socket.tcp); - - if (tcp->addrinfo != NULL) - { - freeaddrinfo(tcp->addrinfo); - tcp->addrinfo= NULL; - } - - if (tcp->port != 0) - { - snprintf(port, NI_MAXSERV, "%u", tcp->port); - } - else if (con->options & DRIZZLE_CON_MYSQL) - { - snprintf(port, NI_MAXSERV, "%u", DRIZZLE_DEFAULT_TCP_PORT_MYSQL); - } - else - { - snprintf(port, NI_MAXSERV, "%u", DRIZZLE_DEFAULT_TCP_PORT); - } - port[NI_MAXSERV-1]= 0; - - memset(&ai, 0, sizeof(ai)); - ai.ai_socktype= SOCK_STREAM; - ai.ai_protocol= IPPROTO_TCP; - ai.ai_flags = AI_PASSIVE; - ai.ai_family = AF_UNSPEC; - - if (con->options & DRIZZLE_CON_LISTEN) - { - host= tcp->host; - } - else - { - if (tcp->host == NULL) - host= DRIZZLE_DEFAULT_TCP_HOST; - else - host= tcp->host; - } - - ret= getaddrinfo(host, port, &ai, &(tcp->addrinfo)); - if (ret != 0) - { - drizzle_set_error(con->drizzle, "drizzle_state_addrinfo", - "getaddrinfo:%s", gai_strerror(ret)); - return DRIZZLE_RETURN_GETADDRINFO; - } - - con->addrinfo_next= tcp->addrinfo; - - break; - - case DRIZZLE_CON_SOCKET_UDS: - con->addrinfo_next= &(con->socket.uds.addrinfo); - break; - } - - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_connect(drizzle_con_st *con) -{ - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - drizzle_log_debug(con->drizzle, "drizzle_state_connect"); - - if (con->fd != -1) - { - (void)closesocket(con->fd); - con->fd= -1; - } - - if (con->addrinfo_next == NULL) - { - drizzle_set_error(con->drizzle, "drizzle_state_connect", - "could not connect"); - drizzle_state_reset(con); - return DRIZZLE_RETURN_COULD_NOT_CONNECT; - } - - con->fd= socket(con->addrinfo_next->ai_family, - con->addrinfo_next->ai_socktype, - con->addrinfo_next->ai_protocol); - if (con->fd == -1) - { - drizzle_set_error(con->drizzle, "drizzle_state_connect", "socket:%d", - errno); - con->drizzle->last_errno= errno; - return DRIZZLE_RETURN_ERRNO; - } - - drizzle_return_t dret= _con_setsockopt(con); - if (dret != DRIZZLE_RETURN_OK) - { - con->drizzle->last_errno= errno; - return dret; - } - - while (1) - { - int ret= connect(con->fd, con->addrinfo_next->ai_addr, con->addrinfo_next->ai_addrlen); - -#ifdef _WIN32 -#define EINPROGRESS 1 -#define ECONNREFUSED 2 -#define ENETUNREACH 3 -#define ETIMEDOUT 4 -#define ECONNRESET 5 -#define EADDRINUSE 6 -#define EOPNOTSUPP 7 -#define ENOPROTOOPT 8 - errno = WSAGetLastError(); - switch(errno) { - case WSAEINVAL: - case WSAEALREADY: - case WSAEWOULDBLOCK: - errno= EINPROGRESS; - break; - case WSAECONNREFUSED: - errno= ECONNREFUSED; - break; - case WSAENETUNREACH: - errno= ENETUNREACH; - break; - case WSAETIMEDOUT: - errno= ETIMEDOUT; - break; - case WSAECONNRESET: - errno= ECONNRESET; - break; - case WSAEADDRINUSE: - errno= EADDRINUSE; - break; - case WSAEOPNOTSUPP: - errno= EOPNOTSUPP; - break; - case WSAENOPROTOOPT: - errno= ENOPROTOOPT; - break; - default: - break; - } -#endif /* _WIN32 */ - - drizzle_log_crazy(con->drizzle, "connect return=%d errno=%d", ret, errno); - - if (ret == 0) - { - con->addrinfo_next= NULL; - break; - } - - if (errno == EAGAIN || errno == EINTR) - continue; - - if (errno == EINPROGRESS) - { - drizzle_state_pop(con); - drizzle_state_push(con, drizzle_state_connecting); - return DRIZZLE_RETURN_OK; - } - - if (errno == ECONNREFUSED || errno == ENETUNREACH || errno == ETIMEDOUT) - { - con->addrinfo_next= con->addrinfo_next->ai_next; - return DRIZZLE_RETURN_OK; - } - - drizzle_set_error(con->drizzle, "drizzle_state_connect", "connect:%d", - errno); - con->drizzle->last_errno= errno; - return DRIZZLE_RETURN_ERRNO; - } - - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_connecting(drizzle_con_st *con) -{ - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - drizzle_log_debug(con->drizzle, "drizzle_state_connecting"); - - while (1) - { - if (con->revents & POLLOUT) - { - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; - } - else if (con->revents & (POLLERR | POLLHUP | POLLNVAL)) - { - con->revents= 0; - drizzle_state_pop(con); - drizzle_state_push(con, drizzle_state_connect); - con->addrinfo_next= con->addrinfo_next->ai_next; - return DRIZZLE_RETURN_OK; - } - - drizzle_return_t ret= drizzle_con_set_events(con, POLLOUT); - if (ret != DRIZZLE_RETURN_OK) - return ret; - - if (con->drizzle->options.is_non_blocking) - { - return DRIZZLE_RETURN_IO_WAIT; - } - - ret= drizzle_con_wait(con->drizzle); - if (ret != DRIZZLE_RETURN_OK) - { - return ret; - } - } -} - -drizzle_return_t drizzle_state_read(drizzle_con_st *con) -{ - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - drizzle_log_debug(con->drizzle, "drizzle_state_read"); - - if (con->buffer_size == 0) - con->buffer_ptr= con->buffer; - else if ((con->buffer_ptr - con->buffer) > (DRIZZLE_MAX_BUFFER_SIZE / 2)) - { - memmove(con->buffer, con->buffer_ptr, con->buffer_size); - con->buffer_ptr= con->buffer; - } - - if ((con->revents & POLLIN) == 0 && - (con->drizzle->options.is_non_blocking)) - { - /* non-blocking mode: return IO_WAIT instead of attempting to read. This - * avoids reading immediately after writing a command, which typically - * returns EAGAIN. This improves performance. */ - drizzle_return_t ret= drizzle_con_set_events(con, POLLIN); - if (ret != DRIZZLE_RETURN_OK) - { - return ret; - } - return DRIZZLE_RETURN_IO_WAIT; - } - - while (1) - { - size_t available_buffer= (size_t)DRIZZLE_MAX_BUFFER_SIZE - - ((size_t)(con->buffer_ptr - con->buffer) + con->buffer_size); - ssize_t read_size = recv(con->fd, (char *)con->buffer_ptr + con->buffer_size, - available_buffer, 0); -#ifdef _WIN32 - errno = WSAGetLastError(); - switch(errno) { - case WSAENOTCONN: - case WSAEWOULDBLOCK: - errno= EAGAIN; - break; - case WSAEINVAL: - case WSAEALREADY: - errno= EINPROGRESS; - break; - case WSAECONNREFUSED: - errno= ECONNREFUSED; - break; - case WSAENETUNREACH: - errno= ENETUNREACH; - break; - case WSAETIMEDOUT: - errno= ETIMEDOUT; - break; - case WSAECONNRESET: - errno= ECONNRESET; - break; - case WSAEADDRINUSE: - errno= EADDRINUSE; - break; - case WSAEOPNOTSUPP: - errno= EOPNOTSUPP; - break; - case WSAENOPROTOOPT: - errno= ENOPROTOOPT; - break; - default: - break; - } -#endif /* _WIN32 */ - - drizzle_log_crazy(con->drizzle, "read fd=%d return=%zd errno=%d", con->fd, - read_size, errno); - - if (read_size == 0) - { - drizzle_set_error(con->drizzle, "drizzle_state_read", - "lost connection to server (EOF)"); - return DRIZZLE_RETURN_LOST_CONNECTION; - } - else if (read_size == -1) - { - if (errno == EAGAIN) - { - /* clear the read ready flag */ - con->revents&= ~POLLIN; - drizzle_return_t ret= drizzle_con_set_events(con, POLLIN); - if (ret != DRIZZLE_RETURN_OK) - { - return ret; - } - - if (con->drizzle->options.is_non_blocking) - { - return DRIZZLE_RETURN_IO_WAIT; - } - - ret= drizzle_con_wait(con->drizzle); - if (ret != DRIZZLE_RETURN_OK) - { - return ret; - } - - continue; - } - else if (errno == ECONNREFUSED) - { - con->revents= 0; - drizzle_state_pop(con); - drizzle_state_push(con, drizzle_state_connect); - con->addrinfo_next= con->addrinfo_next->ai_next; - return DRIZZLE_RETURN_OK; - } - else if (errno == EINTR) - continue; - else if (errno == EPIPE || errno == ECONNRESET) - { - drizzle_set_error(con->drizzle, "drizzle_state_read", - "lost connection to server (%d)", errno); - return DRIZZLE_RETURN_LOST_CONNECTION; - } - - drizzle_set_error(con->drizzle, "drizzle_state_read", "read:%d", errno); - con->drizzle->last_errno= errno; - return DRIZZLE_RETURN_ERRNO; - } - - /* clear the "read ready" flag if we read all available data. */ - if ((size_t) read_size < available_buffer) con->revents&= ~POLLIN; - con->buffer_size+= (size_t)read_size; - break; - } - - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_write(drizzle_con_st *con) -{ - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - drizzle_log_debug(con->drizzle, "drizzle_state_write"); - - while (con->buffer_size != 0) - { - ssize_t write_size = send(con->fd,(char *) con->buffer_ptr, con->buffer_size, 0); - -#ifdef _WIN32 - errno = WSAGetLastError(); - switch(errno) { - case WSAENOTCONN: - case WSAEWOULDBLOCK: - errno= EAGAIN; - break; - case WSAEINVAL: - case WSAEALREADY: - errno= EINPROGRESS; - break; - case WSAECONNREFUSED: - errno= ECONNREFUSED; - break; - case WSAENETUNREACH: - errno= ENETUNREACH; - break; - case WSAETIMEDOUT: - errno= ETIMEDOUT; - break; - case WSAECONNRESET: - errno= ECONNRESET; - break; - case WSAEADDRINUSE: - errno= EADDRINUSE; - break; - case WSAEOPNOTSUPP: - errno= EOPNOTSUPP; - break; - case WSAENOPROTOOPT: - errno= ENOPROTOOPT; - break; - default: - break; - } -#endif /* _WIN32 */ - - drizzle_log_crazy(con->drizzle, "write fd=%d return=%zd errno=%d", con->fd, - write_size, errno); - - if (write_size == 0) - { - drizzle_set_error(con->drizzle, "drizzle_state_write", - "lost connection to server (EOF)"); - return DRIZZLE_RETURN_LOST_CONNECTION; - } - else if (write_size == -1) - { - if (errno == EAGAIN) - { - drizzle_return_t ret= drizzle_con_set_events(con, POLLOUT); - if (ret != DRIZZLE_RETURN_OK) - { - return ret; - } - - if (con->drizzle->options.is_non_blocking) - { - return DRIZZLE_RETURN_IO_WAIT; - } - - ret= drizzle_con_wait(con->drizzle); - if (ret != DRIZZLE_RETURN_OK) - { - return ret; - } - - continue; - } - else if (errno == EINTR) - { - continue; - } - else if (errno == EPIPE || errno == ECONNRESET) - { - drizzle_set_error(con->drizzle, "drizzle_state_write", - "lost connection to server (%d)", errno); - return DRIZZLE_RETURN_LOST_CONNECTION; - } - - drizzle_set_error(con->drizzle, "drizzle_state_write", "write:%d", errno); - con->drizzle->last_errno= errno; - return DRIZZLE_RETURN_ERRNO; - } - - con->buffer_ptr+= write_size; - con->buffer_size-= (size_t)write_size; - if (con->buffer_size == 0) - break; - } - - con->buffer_ptr= con->buffer; - - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_listen(drizzle_con_st *con) -{ - char host[NI_MAXHOST]; - char port[NI_MAXSERV]; - int ret; - int fd; - int opt; - drizzle_con_st *new_con; - - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - - for (; con->addrinfo_next != NULL; - con->addrinfo_next= con->addrinfo_next->ai_next) - { - ret= getnameinfo(con->addrinfo_next->ai_addr, - con->addrinfo_next->ai_addrlen, host, NI_MAXHOST, port, - NI_MAXSERV, NI_NUMERICHOST | NI_NUMERICSERV); - if (ret != 0) - { - drizzle_set_error(con->drizzle, "drizzle_state_listen", "getnameinfo:%s", - gai_strerror(ret)); - return DRIZZLE_RETURN_GETADDRINFO; - } - - /* Call to socket() can fail for some getaddrinfo results, try another. */ - fd= socket(con->addrinfo_next->ai_family, con->addrinfo_next->ai_socktype, - con->addrinfo_next->ai_protocol); - if (fd == -1) - { - drizzle_log_info(con->drizzle, "could not listen on %s:%s", host, port); - drizzle_set_error(con->drizzle, "drizzle_state_listen", "socket:%d", - errno); - continue; - } - - opt= 1; -#ifdef _WIN32 - ret= setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,(const char*) &opt, sizeof(opt)); -#else - ret= setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); -#endif /* _WIN32 */ - if (ret == -1) - { - closesocket(fd); - drizzle_set_error(con->drizzle, "drizzle_state_listen", "setsockopt:%d", - errno); - return DRIZZLE_RETURN_ERRNO; - } - - ret= bind(fd, con->addrinfo_next->ai_addr, con->addrinfo_next->ai_addrlen); - if (ret == -1) - { - closesocket(fd); - drizzle_set_error(con->drizzle, "drizzle_state_listen", "bind:%d", errno); - if (errno == EADDRINUSE) - { - if (con->fd == -1) - { - drizzle_log_info(con->drizzle, "could not listen on %s:%s", host, - port); - } - - continue; - } - - return DRIZZLE_RETURN_ERRNO; - } - - if (listen(fd, con->backlog) == -1) - { - closesocket(fd); - drizzle_set_error(con->drizzle, "drizzle_state_listen", "listen:%d", - errno); - return DRIZZLE_RETURN_ERRNO; - } - - if (con->fd == -1) - { - con->fd= fd; - new_con= con; - } - else - { - new_con= drizzle_con_clone(con->drizzle, con); - if (new_con == NULL) - { - closesocket(fd); - return DRIZZLE_RETURN_MEMORY; - } - - new_con->fd= fd; - } - - /* Wait for read events on the listening socket. */ - drizzle_return_t driz_ret= drizzle_con_set_events(new_con, POLLIN); - if (ret != DRIZZLE_RETURN_OK) - { - drizzle_con_free(new_con); - return driz_ret; - } - - drizzle_log_info(con->drizzle, "listening on %s:%s", host, port); - } - - /* Report last socket() error if we couldn't find an address to bind. */ - if (con->fd == -1) - { - return DRIZZLE_RETURN_ERRNO; - } - - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; -} - -/* - * Static Definitions - */ - -static drizzle_return_t _con_setsockopt(drizzle_con_st *con) -{ - int ret; - struct linger linger; - struct timeval waittime; - - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - - ret= 1; - -#ifdef _WIN32 - ret= setsockopt(con->fd, IPPROTO_TCP, TCP_NODELAY, (const char*)&ret, - (socklen_t)sizeof(int)); -#else - ret= setsockopt(con->fd, IPPROTO_TCP, TCP_NODELAY, &ret, - (socklen_t)sizeof(int)); -#endif /* _WIN32 */ - - if (ret == -1 && errno != EOPNOTSUPP) - { - drizzle_set_error(con->drizzle, "_con_setsockopt", - "setsockopt:TCP_NODELAY:%d", errno); - return DRIZZLE_RETURN_ERRNO; - } - - linger.l_onoff= 1; - linger.l_linger= DRIZZLE_DEFAULT_SOCKET_TIMEOUT; - -#ifdef _WIN32 - ret= setsockopt(con->fd, SOL_SOCKET, SO_LINGER, (const char*)&linger, - (socklen_t)sizeof(struct linger)); -#else - ret= setsockopt(con->fd, SOL_SOCKET, SO_LINGER, &linger, - (socklen_t)sizeof(struct linger)); -#endif /* _WIN32 */ - - if (ret == -1) - { - drizzle_set_error(con->drizzle, "_con_setsockopt", - "setsockopt:SO_LINGER:%d", errno); - return DRIZZLE_RETURN_ERRNO; - } - - waittime.tv_sec= DRIZZLE_DEFAULT_SOCKET_TIMEOUT; - waittime.tv_usec= 0; - -#ifdef _WIN32 - ret= setsockopt(con->fd, SOL_SOCKET, SO_SNDTIMEO, (const char*)&waittime, - (socklen_t)sizeof(struct timeval)); -#else - ret= setsockopt(con->fd, SOL_SOCKET, SO_SNDTIMEO, &waittime, - (socklen_t)sizeof(struct timeval)); -#endif /* _WIN32 */ - - if (ret == -1 && errno != ENOPROTOOPT) - { - drizzle_set_error(con->drizzle, "_con_setsockopt", - "setsockopt:SO_SNDTIMEO:%d", errno); - return DRIZZLE_RETURN_ERRNO; - } - -#ifdef _WIN32 - ret= setsockopt(con->fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&waittime, - (socklen_t)sizeof(struct timeval)); -#else - ret= setsockopt(con->fd, SOL_SOCKET, SO_RCVTIMEO, &waittime, - (socklen_t)sizeof(struct timeval)); -#endif /* _WIN32 */ - - if (ret == -1 && errno != ENOPROTOOPT) - { - drizzle_set_error(con->drizzle, "_con_setsockopt", - "setsockopt:SO_RCVTIMEO:%d", errno); - return DRIZZLE_RETURN_ERRNO; - } - - ret= DRIZZLE_DEFAULT_SOCKET_SEND_SIZE; -#ifdef _WIN32 - ret= setsockopt(con->fd, SOL_SOCKET, SO_SNDBUF, (const char*)&ret, (socklen_t)sizeof(int)); -#else - ret= setsockopt(con->fd, SOL_SOCKET, SO_SNDBUF, &ret, (socklen_t)sizeof(int)); -#endif /* _WIN32 */ - if (ret == -1) - { - drizzle_set_error(con->drizzle, "_con_setsockopt", - "setsockopt:SO_SNDBUF:%d", errno); - return DRIZZLE_RETURN_ERRNO; - } - - ret= DRIZZLE_DEFAULT_SOCKET_RECV_SIZE; -#ifdef _WIN32 - ret= setsockopt(con->fd, SOL_SOCKET, SO_RCVBUF, (const char*)&ret, (socklen_t)sizeof(int)); -#else - ret= setsockopt(con->fd, SOL_SOCKET, SO_RCVBUF, &ret, (socklen_t)sizeof(int)); -#endif /* _WIN32 */ - if (ret == -1) - { - drizzle_set_error(con->drizzle, "_con_setsockopt", - "setsockopt:SO_RCVBUF:%d", errno); - return DRIZZLE_RETURN_ERRNO; - } - -#if defined (_WIN32) - { - unsigned long asyncmode; - asyncmode= 1; - ioctlsocket(con->fd, FIONBIO, &asyncmode); - } -#else - ret= fcntl(con->fd, F_GETFL, 0); - if (ret == -1) - { - drizzle_set_error(con->drizzle, "_con_setsockopt", "fcntl:F_GETFL:%d", - errno); - return DRIZZLE_RETURN_ERRNO; - } - - ret= fcntl(con->fd, F_SETFL, ret | O_NONBLOCK); - if (ret == -1) - { - drizzle_set_error(con->drizzle, "_con_setsockopt", "fcntl:F_SETFL:%d", - errno); - return DRIZZLE_RETURN_ERRNO; - } -#endif - - return DRIZZLE_RETURN_OK; -} diff --git a/utils/mysqlcl_idb/conn_uds.cc b/utils/mysqlcl_idb/conn_uds.cc deleted file mode 100644 index 6aa69517f..000000000 --- a/utils/mysqlcl_idb/conn_uds.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @file - * @brief Connection Definitions for Unix Domain Sockets - */ - -#include - -const char *drizzle_con_uds(const drizzle_con_st *con) -{ - if (con->socket_type == DRIZZLE_CON_SOCKET_UDS) - { - if (con->socket.uds.sockaddr.sun_path[0] != 0) - return con->socket.uds.sockaddr.sun_path; - - if (con->options & DRIZZLE_CON_MYSQL) - return DRIZZLE_DEFAULT_UDS_MYSQL; - - return DRIZZLE_DEFAULT_UDS; - } - - return NULL; -} - -void drizzle_con_set_uds(drizzle_con_st *con, const char *uds) -{ - drizzle_con_reset_addrinfo(con); - - con->socket_type= DRIZZLE_CON_SOCKET_UDS; - - if (uds == NULL) - uds= ""; - - con->socket.uds.sockaddr.sun_family= AF_UNIX; - strncpy(con->socket.uds.sockaddr.sun_path, uds, - sizeof(con->socket.uds.sockaddr.sun_path)); - con->socket.uds.sockaddr.sun_path[sizeof(con->socket.uds.sockaddr.sun_path) - 1]= 0; - - con->socket.uds.addrinfo.ai_family= AF_UNIX; - con->socket.uds.addrinfo.ai_socktype= SOCK_STREAM; - con->socket.uds.addrinfo.ai_protocol= 0; - con->socket.uds.addrinfo.ai_addrlen= sizeof(struct sockaddr_un); - con->socket.uds.addrinfo.ai_addr= (struct sockaddr *)&(con->socket.uds.sockaddr); -} diff --git a/utils/mysqlcl_idb/drizzle.cc b/utils/mysqlcl_idb/drizzle.cc deleted file mode 100644 index d4fb36d4c..000000000 --- a/utils/mysqlcl_idb/drizzle.cc +++ /dev/null @@ -1,761 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @file - * @brief Drizzle Definitions - */ - -#include - -/** - * @addtogroup drizzle_static Static Drizzle Declarations - * @ingroup drizzle - * @{ - */ - -/** - * Names of the verbose levels provided. - */ -static const char *_verbose_name[DRIZZLE_VERBOSE_MAX]= -{ - "NEVER", - "FATAL", - "ERROR", - "INFO", - "DEBUG", - "CRAZY" -}; - -/** @} */ - -/* - * Common Definitions - */ - -const char *drizzle_version() -{ - return PACKAGE_VERSION; -} - -const char *drizzle_bugreport() -{ - return PACKAGE_BUGREPORT; -} - -const char *drizzle_verbose_name(drizzle_verbose_t verbose) -{ - if (verbose >= DRIZZLE_VERBOSE_MAX) - { - return "UNKNOWN"; - } - - return _verbose_name[verbose]; -} - -drizzle_st *drizzle_create() -{ -#if defined(_WIN32) - /* if it is MS windows, invoke WSAStartup */ - WSADATA wsaData; - if ( WSAStartup( MAKEWORD(2,2), &wsaData ) != 0 ) - printf("Error at WSAStartup()\n"); -#else - struct sigaction act; - memset(&act, 0, sizeof(act)); - - act.sa_handler = SIG_IGN; - sigaction(SIGPIPE, &act, NULL); -#endif - - drizzle_st *drizzle= new (std::nothrow) drizzle_st; - - if (drizzle == NULL) - { - return NULL; - } - - /* @todo remove this default free flag with new API. */ - drizzle->options.is_free_objects= true; - drizzle->error_code= 0; - - /* drizzle->options set above */ - drizzle->verbose= DRIZZLE_VERBOSE_NEVER; - drizzle->con_count= 0; - drizzle->pfds_size= 0; - drizzle->query_count= 0; - drizzle->query_new= 0; - drizzle->query_running= 0; - drizzle->last_errno= 0; - drizzle->timeout= -1; - drizzle->con_list= NULL; - drizzle->context= NULL; - drizzle->context_free_fn= NULL; - drizzle->event_watch_fn= NULL; - drizzle->event_watch_context= NULL; - drizzle->log_fn= NULL; - drizzle->log_context= NULL; - drizzle->pfds= NULL; - drizzle->query_list= NULL; - drizzle->sqlstate[0]= 0; - drizzle->last_error[0]= 0; - - return drizzle; -} - -drizzle_st *drizzle_clone(const drizzle_st *source) -{ - drizzle_st *drizzle= drizzle_create(); - if (drizzle == NULL) - { - return NULL; - } - - for (drizzle_con_st* con= source->con_list; con != NULL; con= con->next) - { - if (drizzle_con_clone(drizzle, con) == NULL) - { - drizzle_free(drizzle); - return NULL; - } - } - - return drizzle; -} - -void drizzle_free(drizzle_st *drizzle) -{ - if (drizzle->context != NULL && drizzle->context_free_fn != NULL) - { - drizzle->context_free_fn(drizzle, drizzle->context); - } - - if (drizzle->options.is_free_objects) - { - drizzle_con_free_all(drizzle); - drizzle_query_free_all(drizzle); - } - else if (drizzle->options.is_assert_dangling) - { - assert(drizzle->con_list == NULL); - assert(drizzle->query_list == NULL); - } - - free(drizzle->pfds); - - delete drizzle; -#if defined(_WIN32) - /* if it is MS windows, invoke WSACleanup() at the end*/ - WSACleanup(); -#endif -} - -const char *drizzle_error(const drizzle_st *drizzle) -{ - return drizzle->last_error; -} - -drizzle_return_t drizzle_set_option(drizzle_st *drizzle, drizzle_options_t arg, bool set) -{ - switch (arg) - { - case DRIZZLE_NON_BLOCKING: - drizzle->options.is_non_blocking= set; - return DRIZZLE_RETURN_OK; - - case DRIZZLE_FREE_OBJECTS: - return DRIZZLE_RETURN_OK; - - case DRIZZLE_ASSERT_DANGLING: - return DRIZZLE_RETURN_OK; - - default: - break; - } - - return DRIZZLE_RETURN_INVALID_ARGUMENT; -} - -int drizzle_errno(const drizzle_st *drizzle) -{ - return drizzle->last_errno; -} - -uint16_t drizzle_error_code(const drizzle_st *drizzle) -{ - return drizzle->error_code; -} - -const char *drizzle_sqlstate(const drizzle_st *drizzle) -{ - return drizzle->sqlstate; -} - -void *drizzle_context(const drizzle_st *drizzle) -{ - return drizzle->context; -} - -void drizzle_set_context(drizzle_st *drizzle, void *context) -{ - drizzle->context= context; -} - -void drizzle_set_context_free_fn(drizzle_st *drizzle, - drizzle_context_free_fn *function) -{ - drizzle->context_free_fn= function; -} - -int drizzle_timeout(const drizzle_st *drizzle) -{ - return drizzle->timeout; -} - -void drizzle_set_timeout(drizzle_st *drizzle, int timeout) -{ - drizzle->timeout= timeout; -} - -drizzle_verbose_t drizzle_verbose(const drizzle_st *drizzle) -{ - return drizzle->verbose; -} - -void drizzle_set_verbose(drizzle_st *drizzle, drizzle_verbose_t verbose) -{ - drizzle->verbose= verbose; -} - -void drizzle_set_log_fn(drizzle_st *drizzle, drizzle_log_fn *function, - void *context) -{ - drizzle->log_fn= function; - drizzle->log_context= context; -} - -void drizzle_set_event_watch_fn(drizzle_st *drizzle, - drizzle_event_watch_fn *function, - void *context) -{ - drizzle->event_watch_fn= function; - drizzle->event_watch_context= context; -} - -drizzle_con_st *drizzle_con_create(drizzle_st *drizzle) -{ - if (drizzle == NULL) - { - return NULL; - } - - drizzle_con_st *con= new (std::nothrow) drizzle_con_st; - - if (con == NULL) - { - return NULL; - } - - if (drizzle->con_list != NULL) - { - drizzle->con_list->prev= con; - } - - con->next= drizzle->con_list; - con->prev= NULL; - drizzle->con_list= con; - drizzle->con_count++; - - con->packet_number= 0; - con->protocol_version= 0; - con->state_current= 0; - con->events= 0; - con->revents= 0; - con->capabilities= DRIZZLE_CAPABILITIES_NONE; - con->charset= 0; - con->command= DRIZZLE_COMMAND_SLEEP; - con->options|= DRIZZLE_CON_MYSQL; - con->socket_type= DRIZZLE_CON_SOCKET_TCP; - con->status= DRIZZLE_CON_STATUS_NONE; - con->max_packet_size= DRIZZLE_MAX_PACKET_SIZE; - con->result_count= 0; - con->thread_id= 0; - con->backlog= DRIZZLE_DEFAULT_BACKLOG; - con->fd= -1; - con->buffer_size= 0; - con->command_offset= 0; - con->command_size= 0; - con->command_total= 0; - con->packet_size= 0; - con->addrinfo_next= NULL; - con->buffer_ptr= con->buffer; - con->command_buffer= NULL; - con->command_data= NULL; - con->context= NULL; - con->context_free_fn= NULL; - con->drizzle= drizzle; - /* con->next set above */ - /* con->prev set above */ - con->query= NULL; - /* con->result doesn't need to be set */ - con->result_list= NULL; - con->scramble= NULL; - con->socket.tcp.addrinfo= NULL; - con->socket.tcp.host= NULL; - con->socket.tcp.port= 0; - /* con->buffer doesn't need to be set */ - con->schema[0]= 0; - con->password[0]= 0; - /* con->scramble_buffer doesn't need to be set */ - con->server_version[0]= 0; - /* con->state_stack doesn't need to be set */ - con->user[0]= 0; - - return con; -} - -drizzle_con_st *drizzle_con_clone(drizzle_st *drizzle, drizzle_con_st *source) -{ - drizzle_con_st *con= drizzle_con_create(drizzle); - if (con == NULL) - { - return NULL; - } - - /* Clear "operational" options such as IO status. */ - con->options|= (source->options & ~(DRIZZLE_CON_ALLOCATED|DRIZZLE_CON_READY| - DRIZZLE_CON_NO_RESULT_READ|DRIZZLE_CON_IO_READY| - DRIZZLE_CON_LISTEN)); - con->backlog= source->backlog; - strcpy(con->schema, source->schema); - strcpy(con->password, source->password); - strcpy(con->user, source->user); - - switch (source->socket_type) - { - case DRIZZLE_CON_SOCKET_TCP: - drizzle_con_set_tcp(con, source->socket.tcp.host, source->socket.tcp.port); - break; - - case DRIZZLE_CON_SOCKET_UDS: - drizzle_con_set_uds(con, source->socket.uds.sockaddr.sun_path); - break; - } - - return con; -} - -void drizzle_con_free(drizzle_con_st *con) -{ - if (con->context != NULL && con->context_free_fn != NULL) - { - con->context_free_fn(con, con->context); - } - - if (con->drizzle->options.is_free_objects) - { - drizzle_result_free_all(con); - } - else if (con->drizzle->options.is_assert_dangling) - { - assert(con->result_list == NULL); - } - - if (con->fd != -1) - { - drizzle_con_close(con); - } - - drizzle_con_reset_addrinfo(con); - - if (con->drizzle->con_list == con) - { - con->drizzle->con_list= con->next; - } - if (con->prev != NULL) - { - con->prev->next= con->next; - } - if (con->next != NULL) - { - con->next->prev= con->prev; - } - con->drizzle->con_count--; - - delete con; -} - -void drizzle_con_free_all(drizzle_st *drizzle) -{ - while (drizzle->con_list != NULL) - { - drizzle_con_free(drizzle->con_list); - } -} - -drizzle_return_t drizzle_con_wait(drizzle_st *drizzle) -{ - struct pollfd *pfds; - int ret; - drizzle_return_t dret; - - if (drizzle->pfds_size < drizzle->con_count) - { - pfds= (struct pollfd *)realloc(drizzle->pfds, drizzle->con_count * sizeof(struct pollfd)); - if (pfds == NULL) - { - drizzle_set_error(drizzle, "drizzle_con_wait", "realloc"); - return DRIZZLE_RETURN_MEMORY; - } - - drizzle->pfds= pfds; - drizzle->pfds_size= drizzle->con_count; - } - else - { - pfds= drizzle->pfds; - } - - uint32_t x= 0; - for (drizzle_con_st* con= drizzle->con_list; con != NULL; con= con->next) - { - if (con->events == 0) - continue; - - pfds[x].fd= con->fd; - pfds[x].events= con->events; - pfds[x].revents= 0; - x++; - } - - if (x == 0) - { - drizzle_set_error(drizzle, "drizzle_con_wait", - "no active file descriptors"); - return DRIZZLE_RETURN_NO_ACTIVE_CONNECTIONS; - } - - while (1) - { - drizzle_log_crazy(drizzle, "poll count=%d timeout=%d", x, - drizzle->timeout); - - ret= poll(pfds, x, drizzle->timeout); - - drizzle_log_crazy(drizzle, "poll return=%d errno=%d", ret, errno); - - if (ret == -1) - { - if (errno == EINTR) - continue; - - drizzle_set_error(drizzle, "drizzle_con_wait", "poll:%d", errno); - drizzle->last_errno= errno; - return DRIZZLE_RETURN_ERRNO; - } - - break; - } - - if (ret == 0) - { - drizzle_set_error(drizzle, "drizzle_con_wait", "timeout reached"); - return DRIZZLE_RETURN_TIMEOUT; - } - - x= 0; - for (drizzle_con_st* con= drizzle->con_list; con != NULL; con= con->next) - { - if (con->events == 0) - continue; - - dret= drizzle_con_set_revents(con, pfds[x].revents); - if (dret != DRIZZLE_RETURN_OK) - return dret; - - x++; - } - - return DRIZZLE_RETURN_OK; -} - -drizzle_con_st *drizzle_con_ready(drizzle_st *drizzle) -{ - /* We can't keep state between calls since connections may be removed during - processing. If this list ever gets big, we may want something faster. */ - - for (drizzle_con_st* con= drizzle->con_list; con != NULL; con= con->next) - { - if (con->options & DRIZZLE_CON_IO_READY) - { - con->options&= ~DRIZZLE_CON_IO_READY; - return con; - } - } - return NULL; -} - -drizzle_con_st *drizzle_con_ready_listen(drizzle_st *drizzle) -{ - /* We can't keep state between calls since connections may be removed during - processing. If this list ever gets big, we may want something faster. */ - - for (drizzle_con_st* con= drizzle->con_list; con != NULL; con= con->next) - { - if ((con->options & (DRIZZLE_CON_IO_READY | DRIZZLE_CON_LISTEN)) == - (DRIZZLE_CON_IO_READY | DRIZZLE_CON_LISTEN)) - { - con->options&= ~DRIZZLE_CON_IO_READY; - return con; - } - } - return NULL; -} - -/* - * Client Definitions - */ - -drizzle_con_st *drizzle_con_add_tcp(drizzle_st *drizzle, - const char *host, in_port_t port, - const char *user, const char *password, - const char *db, - drizzle_con_options_t options) -{ - drizzle_con_st *con= drizzle_con_create(drizzle); - if (con == NULL) - { - return NULL; - } - - drizzle_con_set_tcp(con, host, port); - drizzle_con_set_auth(con, user, password); - drizzle_con_set_db(con, db); - drizzle_con_add_options(con, options); - - return con; -} - -drizzle_con_st *drizzle_con_add_uds(drizzle_st *drizzle, - const char *uds, const char *user, - const char *password, const char *db, - drizzle_con_options_t options) -{ - drizzle_con_st *con= drizzle_con_create(drizzle); - if (con == NULL) - { - return NULL; - } - - drizzle_con_set_uds(con, uds); - drizzle_con_set_auth(con, user, password); - drizzle_con_set_db(con, db); - drizzle_con_add_options(con, options); - - return con; -} - -/* - * Server Definitions - */ - -drizzle_con_st *drizzle_con_add_tcp_listen(drizzle_st *drizzle, - const char *host, in_port_t port, - int backlog, - drizzle_con_options_t options) -{ - drizzle_con_st *con= drizzle_con_create(drizzle); - if (con == NULL) - { - return NULL; - } - - drizzle_con_set_tcp(con, host, port); - drizzle_con_set_backlog(con, backlog); - drizzle_con_add_options(con, options | DRIZZLE_CON_LISTEN); - - return con; -} - -drizzle_con_st *drizzle_con_add_uds_listen(drizzle_st *drizzle, - const char *uds, int backlog, - drizzle_con_options_t options) -{ - drizzle_con_st *con= drizzle_con_create(drizzle); - if (con == NULL) - { - return NULL; - } - - drizzle_con_set_uds(con, uds); - drizzle_con_set_backlog(con, backlog); - drizzle_con_add_options(con, options | DRIZZLE_CON_LISTEN); - - return con; -} - -drizzle_con_st *drizzle_con_accept(drizzle_st *drizzle, - drizzle_return_t *ret_ptr) -{ - drizzle_return_t unused; - if (ret_ptr == NULL) - { - ret_ptr= &unused; - } - - while (1) - { - if (drizzle_con_st* ready= drizzle_con_ready_listen(drizzle)) - { - int fd= accept(ready->fd, NULL, NULL); - - drizzle_con_st *con= drizzle_con_create(drizzle); - if (con == NULL) - { - (void)closesocket(fd); - *ret_ptr= DRIZZLE_RETURN_MEMORY; - return NULL; - } - - *ret_ptr= drizzle_con_set_fd(con, fd); - if (*ret_ptr != DRIZZLE_RETURN_OK) - { - (void)closesocket(fd); - return NULL; - } - - if (ready->options & DRIZZLE_CON_MYSQL) - drizzle_con_add_options(con, DRIZZLE_CON_MYSQL); - - *ret_ptr= DRIZZLE_RETURN_OK; - return con; - } - - if (drizzle->options.is_non_blocking) - { - *ret_ptr= DRIZZLE_RETURN_IO_WAIT; - return NULL; - } - - for (drizzle_con_st* ready= drizzle->con_list; ready != NULL; ready= ready->next) - { - if (ready->options & DRIZZLE_CON_LISTEN) - { - drizzle_con_set_events(ready, POLLIN); - } - } - - *ret_ptr= drizzle_con_wait(drizzle); - if (*ret_ptr != DRIZZLE_RETURN_OK) - { - return NULL; - } - } -} - -/* - * Local Definitions - */ - -void drizzle_set_error(drizzle_st *drizzle, const char *function, - const char *format, ...) -{ - if (drizzle == NULL) - { - return; - } - char log_buffer[DRIZZLE_MAX_ERROR_SIZE]; - - size_t size= strlen(function); - char* ptr= (char *)memcpy(log_buffer, function, size); - ptr+= size; - ptr[0]= ':'; - size++; - ptr++; - - va_list args; - va_start(args, format); - int written= vsnprintf(ptr, DRIZZLE_MAX_ERROR_SIZE - size, format, args); - va_end(args); - - if (written < 0) - { - size= DRIZZLE_MAX_ERROR_SIZE; - } - else - { - size+= written; - } - - if (size >= DRIZZLE_MAX_ERROR_SIZE) - { - size= DRIZZLE_MAX_ERROR_SIZE - 1; - } - log_buffer[size]= 0; - - if (drizzle->log_fn == NULL) - { - memcpy(drizzle->last_error, log_buffer, size + 1); - } - else - { - drizzle->log_fn(log_buffer, DRIZZLE_VERBOSE_ERROR, drizzle->log_context); - } -} - -void drizzle_log(drizzle_st *drizzle, drizzle_verbose_t verbose, - const char *format, va_list args) -{ - char log_buffer[DRIZZLE_MAX_ERROR_SIZE]; - - if (drizzle == NULL) - { - return; - } - - if (drizzle->log_fn == NULL) - { - printf("%5s: ", drizzle_verbose_name(verbose)); - vprintf(format, args); - printf("\n"); - } - else - { - vsnprintf(log_buffer, DRIZZLE_MAX_ERROR_SIZE, format, args); - log_buffer[DRIZZLE_MAX_ERROR_SIZE-1]= 0; - drizzle->log_fn(log_buffer, verbose, drizzle->log_context); - } -} diff --git a/utils/mysqlcl_idb/field.cc b/utils/mysqlcl_idb/field.cc deleted file mode 100644 index 3af7e4d5d..000000000 --- a/utils/mysqlcl_idb/field.cc +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @file - * @brief Field definitions - */ - -#include - -/* - * Client definitions - */ - -drizzle_field_t drizzle_field_read(drizzle_result_st *result, size_t *offset, - size_t *size, size_t *total, - drizzle_return_t *ret_ptr) -{ - if (drizzle_state_none(result->con)) - { - if (result->field_current == result->column_count) - { - *ret_ptr= DRIZZLE_RETURN_ROW_END; - return NULL; - } - - drizzle_state_push(result->con, drizzle_state_field_read); - } - - *ret_ptr= drizzle_state_loop(result->con); - if (*ret_ptr == DRIZZLE_RETURN_OK && - result->options & DRIZZLE_RESULT_ROW_BREAK) - { - *ret_ptr= DRIZZLE_RETURN_ROW_BREAK; - } - - *offset= result->field_offset; - *size= result->field_size; - *total= result->field_total; - - return result->field; -} - -drizzle_field_t drizzle_field_buffer(drizzle_result_st *result, size_t *total, - drizzle_return_t *ret_ptr) -{ - size_t offset= 0; - size_t size= 0; - - drizzle_return_t unused; - if (ret_ptr == NULL) - { - ret_ptr= &unused; - } - - drizzle_field_t field= drizzle_field_read(result, &offset, &size, total, ret_ptr); - if (*ret_ptr != DRIZZLE_RETURN_OK) - { - return NULL; - } - - if (field == NULL) - { - *total= 0; - return NULL; - } - - if (result->field_buffer == NULL) - { - result->field_buffer= new (std::nothrow) drizzle_field_t_type[(*total) + 1]; - - if (result->field_buffer == NULL) - { - *ret_ptr= DRIZZLE_RETURN_MEMORY; - *total= 0; - return NULL; - } - } - - memcpy(result->field_buffer + offset, field, size); - - while ((offset + size) != (*total)) - { - field= drizzle_field_read(result, &offset, &size, total, ret_ptr); - if (*ret_ptr != DRIZZLE_RETURN_OK) - { - return NULL; - } - - memcpy(result->field_buffer + offset, field, size); - } - - field= result->field_buffer; - result->field_buffer= NULL; - field[*total]= 0; - - return field; -} - -void drizzle_field_free(drizzle_field_t field) -{ - delete[] field; -} - -/* - * Server definitions - */ - -drizzle_return_t drizzle_field_write(drizzle_result_st *result, - const drizzle_field_t field, size_t size, - size_t total) -{ - drizzle_return_t ret; - - if (drizzle_state_none(result->con)) - { - if (result->options & DRIZZLE_RESULT_ROW_BREAK) - { - result->options&= ~DRIZZLE_RESULT_ROW_BREAK; - result->field= field; - result->field_size= size; - } - else - { - result->field= field; - result->field_size= size; - result->field_offset= 0; - result->field_total= total; - } - - drizzle_state_push(result->con, drizzle_state_field_write); - } - else if (result->field == NULL) - { - result->field= field; - result->field_size= size; - } - - ret= drizzle_state_loop(result->con); - if (ret == DRIZZLE_RETURN_PAUSE) - ret= DRIZZLE_RETURN_OK; - - return ret; -} - -/* - * Internal state functions. - */ - -drizzle_return_t drizzle_state_field_read(drizzle_con_st *con) -{ - drizzle_return_t ret; - - drizzle_log_debug(con->drizzle, "drizzle_state_field_read"); - - if (con->buffer_size == 0) - { - drizzle_state_push(con, drizzle_state_read); - return DRIZZLE_RETURN_OK; - } - - con->result->field_offset+= con->result->field_size; - if (con->result->field_offset == con->result->field_total) - { - con->result->field_offset= 0; - con->result->field_size= 0; - - con->result->field_total= (size_t)drizzle_unpack_length(con, &ret); - if (ret == DRIZZLE_RETURN_NULL_SIZE) - { - con->result->field= NULL; - con->result->field_current++; - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; - } - else if (ret != DRIZZLE_RETURN_OK) - { - if (ret == DRIZZLE_RETURN_IO_WAIT) - { - drizzle_state_push(con, drizzle_state_read); - return DRIZZLE_RETURN_OK; - } - - return ret; - } - - drizzle_log_debug(con->drizzle, - "field_offset= %zu, field_size= %zu, field_total= %zu", - con->result->field_offset, con->result->field_size, - con->result->field_total); - - if ((size_t)(con->buffer_size) >= con->result->field_total) - con->result->field_size= con->result->field_total; - else - con->result->field_size= con->buffer_size; - } - else - { - if ((con->result->field_offset + con->buffer_size) >= - con->result->field_total) - { - con->result->field_size= (con->result->field_total - - con->result->field_offset); - } - else - con->result->field_size= con->buffer_size; - } - - /* This is a special case when a row is larger than the packet size. */ - if (con->result->field_size > (size_t)con->packet_size) - { - con->result->field_size= con->packet_size; - - if (con->options & DRIZZLE_CON_RAW_PACKET) - con->result->options|= DRIZZLE_RESULT_ROW_BREAK; - else - { - drizzle_state_pop(con); - drizzle_state_push(con, drizzle_state_packet_read); - drizzle_state_push(con, drizzle_state_field_read); - } - } - - con->result->field= (char *)con->buffer_ptr; - con->buffer_ptr+= con->result->field_size; - con->buffer_size-= con->result->field_size; - con->packet_size-= con->result->field_size; - - drizzle_log_debug(con->drizzle, - "field_offset= %zu, field_size= %zu, field_total= %zu", - con->result->field_offset, con->result->field_size, - con->result->field_total); - - if ((con->result->field_offset + con->result->field_size) == - con->result->field_total) - { - if (con->result->column_buffer != NULL && - con->result->column_buffer[con->result->field_current].max_size < - con->result->field_total) - { - con->result->column_buffer[con->result->field_current].max_size= - con->result->field_total; - } - - con->result->field_current++; - } - - if (con->result->field_total == 0 || con->result->field_size > 0 || - con->packet_size == 0) - { - drizzle_state_pop(con); - } - - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_field_write(drizzle_con_st *con) -{ - uint8_t *start= con->buffer_ptr + con->buffer_size; - uint8_t *ptr; - size_t free_size; - drizzle_result_st *result= con->result; - - drizzle_log_debug(con->drizzle, "drizzle_state_field_write"); - - if (result->field == NULL && result->field_total != 0) - return DRIZZLE_RETURN_PAUSE; - - free_size= (size_t)DRIZZLE_MAX_BUFFER_SIZE - (size_t)(start - con->buffer); - ptr= start; - - if (result->field_offset == 0) - { - /* Make sure we can fit the max length and 1 byte of data in (9 + 1). */ - if (free_size < 10) - { - drizzle_state_push(con, drizzle_state_write); - return DRIZZLE_RETURN_OK; - } - - if (result->field == NULL) - { - ptr[0]= 251; - ptr++; - } - else if (result->field_total == 0) - { - ptr[0]= 0; - ptr++; - } - else - ptr= drizzle_pack_length(result->field_total, ptr); - - free_size-= (size_t)(ptr - start); - con->buffer_size+= (size_t)(ptr - start); - con->packet_size-= (size_t)(ptr - start); - } - else if (result->field_size > DRIZZLE_BUFFER_COPY_THRESHOLD) - { - /* Flush the internal buffer first. */ - if (con->buffer_size != 0) - { - drizzle_state_push(con, drizzle_state_write); - return DRIZZLE_RETURN_OK; - } - - /* We do this to write directly from the field buffer to avoid memcpy(). */ - con->buffer_ptr= (uint8_t *)result->field; - con->buffer_size= result->field_size; - con->packet_size-= result->field_size; - result->field_offset+= result->field_size; - result->field= NULL; - - if (result->field_offset == result->field_total) - drizzle_state_pop(con); - else if (con->packet_size == 0) - { - con->result->options|= DRIZZLE_RESULT_ROW_BREAK; - drizzle_state_pop(con); - } - - drizzle_state_push(con, drizzle_state_write); - return DRIZZLE_RETURN_OK; - } - - if (result->field_size == 0) - drizzle_state_pop(con); - else - { - if (result->field_size < free_size) - free_size= result->field_size; - - memcpy(ptr, result->field, free_size); - result->field_offset+= free_size; - con->buffer_size+= free_size; - con->packet_size-= free_size; - - if (result->field_offset == result->field_total) - { - result->field= NULL; - drizzle_state_pop(con); - } - else - { - if (con->packet_size == 0) - { - con->result->options|= DRIZZLE_RESULT_ROW_BREAK; - drizzle_state_pop(con); - } - - if (result->field_size == free_size) - result->field= NULL; - else - { - result->field+= free_size; - result->field_size-= free_size; - drizzle_state_push(con, drizzle_state_write); - } - } - } - - return DRIZZLE_RETURN_OK; -} diff --git a/utils/mysqlcl_idb/handshake.cc b/utils/mysqlcl_idb/handshake.cc deleted file mode 100644 index 6a2d725d0..000000000 --- a/utils/mysqlcl_idb/handshake.cc +++ /dev/null @@ -1,612 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @file - * @brief Handshake Definitions - */ - -#include - -/* - * Client Definitions - */ - -drizzle_return_t drizzle_handshake_server_read(drizzle_con_st *con) -{ - if (drizzle_state_none(con)) - { - drizzle_state_push(con, drizzle_state_handshake_server_read); - drizzle_state_push(con, drizzle_state_packet_read); - } - - return drizzle_state_loop(con); -} - -drizzle_return_t drizzle_handshake_client_write(drizzle_con_st *con) -{ - if (drizzle_state_none(con)) - { - drizzle_state_push(con, drizzle_state_write); - drizzle_state_push(con, drizzle_state_handshake_client_write); - } - - return drizzle_state_loop(con); -} - -/* - * Server Definitions - */ - -drizzle_return_t drizzle_handshake_server_write(drizzle_con_st *con) -{ - if (drizzle_state_none(con)) - { - drizzle_state_push(con, drizzle_state_write); - drizzle_state_push(con, drizzle_state_handshake_server_write); - } - - return drizzle_state_loop(con); -} - -drizzle_return_t drizzle_handshake_client_read(drizzle_con_st *con) -{ - if (drizzle_state_none(con)) - { - drizzle_state_push(con, drizzle_state_handshake_client_read); - drizzle_state_push(con, drizzle_state_packet_read); - } - - return drizzle_state_loop(con); -} - -/* - * State Definitions - */ - -drizzle_return_t drizzle_state_handshake_server_read(drizzle_con_st *con) -{ - uint8_t *ptr; - int extra_length; - unsigned char* packet_end; - - drizzle_log_debug(con->drizzle, "drizzle_state_handshake_server_read"); - - /* Assume the entire handshake packet will fit in the buffer. */ - if (con->buffer_size < con->packet_size) - { - drizzle_state_push(con, drizzle_state_read); - return DRIZZLE_RETURN_OK; - } - - if (con->packet_size < 46) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_server_read", - "bad packet size:>=46:%zu", con->packet_size); - return DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET; - } - - packet_end= con->buffer_ptr + con->packet_size; - con->protocol_version= con->buffer_ptr[0]; - con->buffer_ptr++; - - if (con->protocol_version != 10) - { - /* This is a special case where the server determines that authentication - will be impossible and denies any attempt right away. */ - if (con->protocol_version == 255) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_server_read", - "%.*s", (int32_t)con->packet_size - 3, - con->buffer_ptr + 2); - return DRIZZLE_RETURN_AUTH_FAILED; - } - - drizzle_set_error(con->drizzle, "drizzle_state_handshake_server_read", - "protocol version not supported:%d", - con->protocol_version); - return DRIZZLE_RETURN_PROTOCOL_NOT_SUPPORTED; - } - - /* Look for null-terminated server version string. */ - ptr= (uint8_t *)memchr(con->buffer_ptr, 0, con->buffer_size - 1); - if (ptr == NULL) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_server_read", - "server version string not found"); - return DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET; - } - - if (con->packet_size < (46 + (size_t)(ptr - con->buffer_ptr))) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_server_read", - "bad packet size:%zu:%zu", - (46 + (size_t)(ptr - con->buffer_ptr)), con->packet_size); - return DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET; - } - - strncpy(con->server_version, (char *)con->buffer_ptr, - DRIZZLE_MAX_SERVER_VERSION_SIZE); - con->server_version[DRIZZLE_MAX_SERVER_VERSION_SIZE - 1]= 0; - con->buffer_ptr+= ((ptr - con->buffer_ptr) + 1); - - con->thread_id= (uint32_t)drizzle_get_byte4(con->buffer_ptr); - con->buffer_ptr+= 4; - - con->scramble= con->scramble_buffer; - memcpy(con->scramble, con->buffer_ptr, 8); - /* Skip scramble and filler. */ - con->buffer_ptr+= 9; - - /* Even though drizzle_capabilities is more than 2 bytes, the protocol only - allows for 2. This means some capabilities are not possible during this - handshake step. The options beyond 2 bytes are for client response only. */ - con->capabilities= (drizzle_capabilities_t)drizzle_get_byte2(con->buffer_ptr); - con->buffer_ptr+= 2; - - if (con->options & DRIZZLE_CON_MYSQL && - !(con->capabilities & DRIZZLE_CAPABILITIES_PROTOCOL_41)) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_server_read", - "protocol version not supported, must be MySQL 4.1+"); - return DRIZZLE_RETURN_PROTOCOL_NOT_SUPPORTED; - } - - con->charset= con->buffer_ptr[0]; - con->buffer_ptr+= 1; - - con->status= (drizzle_con_status_t)drizzle_get_byte2(con->buffer_ptr); - /* Skip status and filler. */ - con->buffer_ptr+= 15; - - memcpy(con->scramble + 8, con->buffer_ptr, 12); - con->buffer_ptr+= 13; - - /* MySQL 5.5 adds "mysql_native_password" after the server greeting. */ - extra_length= packet_end - con->buffer_ptr; - assert(extra_length >= 0); - if (extra_length > DRIZZLE_MAX_SERVER_EXTRA_SIZE - 1) - extra_length= DRIZZLE_MAX_SERVER_EXTRA_SIZE - 1; - memcpy(con->server_extra, (char *)con->buffer_ptr, extra_length); - con->server_extra[extra_length]= 0; - - con->buffer_size-= con->packet_size; - if (con->buffer_size != 0) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_server_read", - "unexpected data after packet:%zu", con->buffer_size); - return DRIZZLE_RETURN_UNEXPECTED_DATA; - } - - con->buffer_ptr= con->buffer; - - drizzle_state_pop(con); - - if (!(con->options & DRIZZLE_CON_RAW_PACKET)) - { - drizzle_state_push(con, drizzle_state_handshake_result_read); - drizzle_state_push(con, drizzle_state_packet_read); - drizzle_state_push(con, drizzle_state_write); - drizzle_state_push(con, drizzle_state_handshake_client_write); - } - - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_handshake_server_write(drizzle_con_st *con) -{ - uint8_t *ptr; - - drizzle_log_debug(con->drizzle, "drizzle_state_handshake_server_write"); - - /* Calculate max packet size. */ - con->packet_size= 1 /* Protocol version */ - + strlen(con->server_version) + 1 - + 4 /* Thread ID */ - + 8 /* Scramble */ - + 1 /* NULL */ - + 2 /* Capabilities */ - + 1 /* Language */ - + 2 /* Status */ - + 13 /* Unused */ - + 12 /* Scramble */ - + 1; /* NULL */ - - /* Assume the entire handshake packet will fit in the buffer. */ - if ((con->packet_size + 4) > DRIZZLE_MAX_BUFFER_SIZE) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_server_write", - "buffer too small:%zu", con->packet_size + 4); - return DRIZZLE_RETURN_INTERNAL_ERROR; - } - - ptr= con->buffer_ptr; - - /* Store packet size and packet number first. */ - drizzle_set_byte3(ptr, con->packet_size); - ptr[3]= 0; - con->packet_number= 1; - ptr+= 4; - - ptr[0]= con->protocol_version; - ptr++; - - memcpy(ptr, con->server_version, strlen(con->server_version)); - ptr+= strlen(con->server_version); - - ptr[0]= 0; - ptr++; - - drizzle_set_byte4(ptr, con->thread_id); - ptr+= 4; - - if (con->scramble == NULL) - memset(ptr, 0, 8); - else - memcpy(ptr, con->scramble, 8); - ptr+= 8; - - ptr[0]= 0; - ptr++; - - if (con->options & DRIZZLE_CON_MYSQL) - con->capabilities|= DRIZZLE_CAPABILITIES_PROTOCOL_41; - - /* We can only send two bytes worth, this is a protocol limitation. */ - drizzle_set_byte2(ptr, con->capabilities); - ptr+= 2; - - ptr[0]= con->charset; - ptr++; - - drizzle_set_byte2(ptr, con->status); - ptr+= 2; - - memset(ptr, 0, 13); - ptr+= 13; - - if (con->scramble == NULL) - memset(ptr, 0, 12); - else - memcpy(ptr, con->scramble + 8, 12); - ptr+= 12; - - ptr[0]= 0; - ptr++; - - con->buffer_size+= (4 + con->packet_size); - - /* Make sure we packed it correctly. */ - if ((size_t)(ptr - con->buffer_ptr) != (4 + con->packet_size)) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_server_write", - "error packing server handshake:%zu:%zu", - (size_t)(ptr - con->buffer_ptr), 4 + con->packet_size); - return DRIZZLE_RETURN_INTERNAL_ERROR; - } - - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_handshake_client_read(drizzle_con_st *con) -{ - size_t real_size; - uint8_t *ptr; - uint8_t scramble_size; - - drizzle_log_debug(con->drizzle, "drizzle_state_handshake_client_read"); - - /* Assume the entire handshake packet will fit in the buffer. */ - if (con->buffer_size < con->packet_size) - { - drizzle_state_push(con, drizzle_state_read); - return DRIZZLE_RETURN_OK; - } - - /* This is the minimum packet size. */ - if (con->packet_size < 34) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_read", - "bad packet size:>=34:%zu", con->packet_size); - return DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET; - } - - real_size= 34; - - con->capabilities= drizzle_get_byte4(con->buffer_ptr); - con->buffer_ptr+= 4; - - if (con->options & DRIZZLE_CON_MYSQL && - !(con->capabilities & DRIZZLE_CAPABILITIES_PROTOCOL_41)) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_read", - "protocol version not supported, must be MySQL 4.1+"); - return DRIZZLE_RETURN_PROTOCOL_NOT_SUPPORTED; - } - - con->max_packet_size= (uint32_t)drizzle_get_byte4(con->buffer_ptr); - con->buffer_ptr+= 4; - - con->charset= con->buffer_ptr[0]; - con->buffer_ptr+= 1; - - /* Skip unused. */ - con->buffer_ptr+= 23; - - /* Look for null-terminated user string. */ - ptr= (uint8_t *)memchr(con->buffer_ptr, 0, con->buffer_size - 32); - if (ptr == NULL) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_read", - "user string not found"); - return DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET; - } - - if (con->buffer_ptr == ptr) - { - con->user[0]= 0; - con->buffer_ptr++; - } - else - { - real_size+= (size_t)(ptr - con->buffer_ptr); - if (con->packet_size < real_size) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_read", - "bad packet size:>=%zu:%zu", real_size, - con->packet_size); - return DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET; - } - - strncpy(con->user, (char *)con->buffer_ptr, DRIZZLE_MAX_USER_SIZE); - con->user[DRIZZLE_MAX_USER_SIZE - 1]= 0; - con->buffer_ptr+= ((ptr - con->buffer_ptr) + 1); - } - - scramble_size= con->buffer_ptr[0]; - con->buffer_ptr+= 1; - - if (scramble_size == 0) - { - con->scramble= NULL; - } - else - { - if (scramble_size != DRIZZLE_MAX_SCRAMBLE_SIZE) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_read", - "wrong scramble size"); - return DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET; - } - - real_size+= scramble_size; - con->scramble= con->scramble_buffer; - memcpy(con->scramble, con->buffer_ptr, DRIZZLE_MAX_SCRAMBLE_SIZE); - - con->buffer_ptr+= DRIZZLE_MAX_SCRAMBLE_SIZE; - } - - /* Look for null-terminated schema string. */ - if ((34 + strlen(con->user) +scramble_size) == con->packet_size) - { - con->schema[0]= 0; - } - else - { - ptr= (uint8_t *)memchr(con->buffer_ptr, 0, con->buffer_size - - (34 + strlen(con->user) + scramble_size)); - if (ptr == NULL) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_read", - "schema string not found"); - return DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET; - } - - real_size+= ((size_t)(ptr - con->buffer_ptr) + 1); - if (con->packet_size != real_size) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_read", - "bad packet size:%zu:%zu", real_size, con->packet_size); - return DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET; - } - - if (con->buffer_ptr == ptr) - { - con->schema[0]= 0; - con->buffer_ptr++; - } - else - { - strncpy(con->schema, (char *)con->buffer_ptr, DRIZZLE_MAX_DB_SIZE); - con->schema[DRIZZLE_MAX_DB_SIZE - 1]= 0; - con->buffer_ptr+= ((ptr - con->buffer_ptr) + 1); - } - } - - con->buffer_size-= con->packet_size; - if (con->buffer_size != 0) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_read", - "unexpected data after packet:%zu", con->buffer_size); - return DRIZZLE_RETURN_UNEXPECTED_DATA; - } - - con->buffer_ptr= con->buffer; - - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_handshake_client_write(drizzle_con_st *con) -{ - uint8_t *ptr; - int capabilities; - - drizzle_log_debug(con->drizzle, "drizzle_state_handshake_client_write"); - - /* Calculate max packet size. */ - con->packet_size= 4 /* Capabilities */ - + 4 /* Max packet size */ - + 1 /* Charset */ - + 23 /* Unused */ - + strlen(con->user) + 1 - + 1 /* Scramble size */ - + DRIZZLE_MAX_SCRAMBLE_SIZE - + strlen(con->schema) + 1; - - /* Assume the entire handshake packet will fit in the buffer. */ - if ((con->packet_size + 4) > DRIZZLE_MAX_BUFFER_SIZE) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_write", - "buffer too small:%zu", con->packet_size + 4); - return DRIZZLE_RETURN_INTERNAL_ERROR; - } - - ptr= con->buffer_ptr; - - /* Store packet size at the end since it may change. */ - ptr[3]= con->packet_number; - con->packet_number++; - ptr+= 4; - - if (con->options & DRIZZLE_CON_MYSQL) - { - con->capabilities|= DRIZZLE_CAPABILITIES_PROTOCOL_41; - } - - capabilities= con->capabilities & DRIZZLE_CAPABILITIES_CLIENT; - if (!(con->options & DRIZZLE_CON_FOUND_ROWS)) - capabilities&= ~DRIZZLE_CAPABILITIES_FOUND_ROWS; - - if (con->options & DRIZZLE_CON_INTERACTIVE) - { - capabilities|= DRIZZLE_CAPABILITIES_INTERACTIVE; - } - - if (con->options & DRIZZLE_CON_MULTI_STATEMENTS) - { - capabilities|= DRIZZLE_CAPABILITIES_MULTI_STATEMENTS; - } - - if (con->options & DRIZZLE_CON_AUTH_PLUGIN) - { - capabilities|= DRIZZLE_CAPABILITIES_PLUGIN_AUTH; - } - - capabilities&= ~(DRIZZLE_CAPABILITIES_COMPRESS | DRIZZLE_CAPABILITIES_SSL); - if (con->schema[0] == 0) - { - capabilities&= ~DRIZZLE_CAPABILITIES_CONNECT_WITH_DB; - } - - drizzle_set_byte4(ptr, capabilities); - ptr+= 4; - - drizzle_set_byte4(ptr, con->max_packet_size); - ptr+= 4; - - ptr[0]= con->charset; - ptr++; - - memset(ptr, 0, 23); - ptr+= 23; - - drizzle_return_t ret; - ptr= drizzle_pack_auth(con, ptr, &ret); - if (ret != DRIZZLE_RETURN_OK) - { - return ret; - } - - con->buffer_size+= (4 + con->packet_size); - - /* Make sure we packed it correctly. */ - if ((size_t)(ptr - con->buffer_ptr) != (4 + con->packet_size)) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_write", - "error packing client handshake:%zu:%zu", - (size_t)(ptr - con->buffer_ptr), 4 + con->packet_size); - return DRIZZLE_RETURN_INTERNAL_ERROR; - } - - /* Store packet size now. */ - drizzle_set_byte3(con->buffer_ptr, con->packet_size); - - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_handshake_result_read(drizzle_con_st *con) -{ - drizzle_result_st *result; - - drizzle_log_debug(con->drizzle, "drizzle_state_handshake_result_read"); - - if ((result= drizzle_result_create(con)) == NULL) - { - return DRIZZLE_RETURN_MEMORY; - } - - con->result= result; - - drizzle_return_t ret= drizzle_state_result_read(con); - if (drizzle_state_none(con)) - { - if (ret == DRIZZLE_RETURN_OK) - { - if (drizzle_result_eof(result)) - { - drizzle_set_error(con->drizzle, "drizzle_state_handshake_result_read", - "old insecure authentication mechanism not supported"); - ret= DRIZZLE_RETURN_AUTH_FAILED; - } - else - { - con->options|= DRIZZLE_CON_READY; - } - } - } - - drizzle_result_free(result); - - if (ret == DRIZZLE_RETURN_ERROR_CODE) - { - return DRIZZLE_RETURN_HANDSHAKE_FAILED; - } - - return ret; -} diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/column.h b/utils/mysqlcl_idb/libdrizzle-2.0/column.h deleted file mode 100644 index 05aed97e7..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/column.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Column Declarations - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_column Column Declarations - * @ingroup drizzle_client_interface - * @ingroup drizzle_server_interface - * - * These functions are used to get detailed column information. This information - * is usually sent as the first part of a result set. There are multiple ways - * for column information to be buffered depending on the functions being used. - * @{ - */ - -/** - * Initialize a column structure. - */ -DRIZZLE_API -drizzle_column_st *drizzle_column_create(drizzle_result_st *result, - drizzle_column_st *column); - -/** - * Free a column structure. - */ -DRIZZLE_API -void drizzle_column_free(drizzle_column_st *column); - -/** - * Get the drizzle_result_st struct that the column belongs to. - */ -DRIZZLE_API -drizzle_result_st *drizzle_column_drizzle_result(drizzle_column_st *column); - -/** - * Get catalog name for a column. - */ -DRIZZLE_API -const char *drizzle_column_catalog(drizzle_column_st *column); - -/** - * Get schema name for a column. - */ -DRIZZLE_API -const char *drizzle_column_shema(drizzle_column_st *column); - -DRIZZLE_API -const char *drizzle_column_db(drizzle_column_st *column); - -/** - * Get table name for a column. - */ -DRIZZLE_API -const char *drizzle_column_table(drizzle_column_st *column); - -/** - * Get original table name for a column. - */ -DRIZZLE_API -const char *drizzle_column_orig_table(drizzle_column_st *column); - -/** - * Get column name for a column. - */ -DRIZZLE_API -const char *drizzle_column_name(drizzle_column_st *column); - -/** - * Get original column name for a column. - */ -DRIZZLE_API -const char *drizzle_column_orig_name(drizzle_column_st *column); - -/** - * Get charset for a column. - */ -DRIZZLE_API -drizzle_charset_t drizzle_column_charset(drizzle_column_st *column); - -/** - * Get size of a column. - */ -DRIZZLE_API -uint32_t drizzle_column_size(drizzle_column_st *column); - -/** - * Get max size of a column. - */ -DRIZZLE_API -size_t drizzle_column_max_size(drizzle_column_st *column); - -/** - * Set max size of a column. - */ -DRIZZLE_API -void drizzle_column_set_max_size(drizzle_column_st *column, size_t size); - -/** - * Get the type of a column. - */ -DRIZZLE_API -drizzle_column_type_t drizzle_column_type(drizzle_column_st *column); - -/** - * Get the Drizzle type of a column. - */ -DRIZZLE_API -drizzle_column_type_drizzle_t drizzle_column_type_drizzle(drizzle_column_st *column); - -/** - * Get flags for a column. - */ -DRIZZLE_API -int drizzle_column_flags(drizzle_column_st *column); - -/** - * Get the number of decimals for numeric columns. - */ -DRIZZLE_API -uint8_t drizzle_column_decimals(drizzle_column_st *column); - -/** - * Get default value for a column. - */ -DRIZZLE_API -const uint8_t *drizzle_column_default_value(drizzle_column_st *column, - size_t *size); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/column_client.h b/utils/mysqlcl_idb/libdrizzle-2.0/column_client.h deleted file mode 100644 index ec7b0cfd4..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/column_client.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -/** - * @file - * @brief Column Declarations for Clients - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_column_client Column Declarations for Clients - * @ingroup drizzle_client_interface - * - * These functions are used to get detailed column information. This information - * is usually sent as the first part of a result set. There are both buffered - * and unbuffered functions provided. - * @{ - */ - -/** - * Skip a column in result. - */ -DRIZZLE_API -drizzle_return_t drizzle_column_skip(drizzle_result_st *result); - -/** - * Skip all columns in a result. - */ -DRIZZLE_API -drizzle_return_t drizzle_column_skip_all(drizzle_result_st *result); - -/** - * Read column information. - * - * @param[in,out] result pointer to the structure to read from. - * @param[out] column pointer to the structure to contain the information. - * @param[out] ret_ptr Standard libdrizzle return value. - * @return column if there is valid data, NULL if there are no more columns. - */ -DRIZZLE_API -drizzle_column_st *drizzle_column_read(drizzle_result_st *result, - drizzle_column_st *column, - drizzle_return_t *ret_ptr); - -/** - * Buffer all columns in result structure. - */ -DRIZZLE_API -drizzle_return_t drizzle_column_buffer(drizzle_result_st *result); - -/** - * Get next buffered column from a result structure. - */ -DRIZZLE_API -drizzle_column_st *drizzle_column_next(drizzle_result_st *result); - -/** - * Get previous buffered column from a result structure. - */ -DRIZZLE_API -drizzle_column_st *drizzle_column_prev(drizzle_result_st *result); - -/** - * Seek to the given buffered column in a result structure. - */ -DRIZZLE_API -void drizzle_column_seek(drizzle_result_st *result, uint16_t column); - -/** - * Get the given buffered column from a result structure. - */ -DRIZZLE_API -drizzle_column_st *drizzle_column_index(drizzle_result_st *result, - uint16_t column); - -/** - * Get current column number in a buffered or unbuffered result. - */ -DRIZZLE_API -uint16_t drizzle_column_current(drizzle_result_st *result); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/column_server.h b/utils/mysqlcl_idb/libdrizzle-2.0/column_server.h deleted file mode 100644 index 264de40d1..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/column_server.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Column Declarations for Servers - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_column_server Column Declarations for Servers - * @ingroup drizzle_server_interface - * - * These functions allow you to send column information over a connection. - * @{ - */ - -/** - * Write column information. - */ -DRIZZLE_API -drizzle_return_t drizzle_column_write(drizzle_result_st *result, - drizzle_column_st *column); - -/** - * Set catalog name for a column. - */ -DRIZZLE_API -void drizzle_column_set_catalog(drizzle_column_st *column, const char *catalog); - -/** - * Set database name for a column. - */ -DRIZZLE_API -void drizzle_column_set_db(drizzle_column_st *column, const char *db); - -DRIZZLE_API -void drizzle_column_set_schema(drizzle_column_st *column, const char *schema); - -/** - * Set table name for a column. - */ -DRIZZLE_API -void drizzle_column_set_table(drizzle_column_st *column, const char *table); - -/** - * Set original table name for a column. - */ -DRIZZLE_API -void drizzle_column_set_orig_table(drizzle_column_st *column, - const char *orig_table); - -/** - * Set column name for a column. - */ -DRIZZLE_API -void drizzle_column_set_name(drizzle_column_st *column, const char *name); - -/** - * Set original column name for a column. - */ -DRIZZLE_API -void drizzle_column_set_orig_name(drizzle_column_st *column, - const char *orig_name); - -/** - * Set charset for a column. - */ -DRIZZLE_API -void drizzle_column_set_charset(drizzle_column_st *column, - drizzle_charset_t charset); - -/** - * Set size of a column. - */ -DRIZZLE_API -void drizzle_column_set_size(drizzle_column_st *column, uint32_t size); - -/** - * Set the type of a column. - */ -DRIZZLE_API -void drizzle_column_set_type(drizzle_column_st *column, - drizzle_column_type_t type); - -/** - * Set flags for a column. - */ -DRIZZLE_API -void drizzle_column_set_flags(drizzle_column_st *column, - int flags); - -/** - * Set the number of decimals for numeric columns. - */ -DRIZZLE_API -void drizzle_column_set_decimals(drizzle_column_st *column, uint8_t decimals); - -/** - * Set default value for a column. - */ -DRIZZLE_API -void drizzle_column_set_default_value(drizzle_column_st *column, - const uint8_t *default_value, - size_t size); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/command.h b/utils/mysqlcl_idb/libdrizzle-2.0/command.h deleted file mode 100644 index f4feed2eb..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/command.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2011 Brian Aker (brian@tangent.org) - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -/** - * @ingroup drizzle_command - * Commands for drizzle_command functions. - */ -enum drizzle_command_t -{ - DRIZZLE_COMMAND_SLEEP, /* Not used currently. */ - DRIZZLE_COMMAND_QUIT, - DRIZZLE_COMMAND_INIT_DB, - DRIZZLE_COMMAND_QUERY, - DRIZZLE_COMMAND_FIELD_LIST, /* Deprecated. */ - DRIZZLE_COMMAND_CREATE_DB, /* Deprecated. */ - DRIZZLE_COMMAND_DROP_DB, /* Deprecated. */ - DRIZZLE_COMMAND_REFRESH, - DRIZZLE_COMMAND_SHUTDOWN, - DRIZZLE_COMMAND_STATISTICS, - DRIZZLE_COMMAND_PROCESS_INFO, /* Deprecated. */ - DRIZZLE_COMMAND_CONNECT, /* Not used currently. */ - DRIZZLE_COMMAND_PROCESS_KILL, /* Deprecated. */ - DRIZZLE_COMMAND_DEBUG, - DRIZZLE_COMMAND_PING, - DRIZZLE_COMMAND_TIME, /* Not used currently. */ - DRIZZLE_COMMAND_DELAYED_INSERT, /* Not used currently. */ - DRIZZLE_COMMAND_CHANGE_USER, - DRIZZLE_COMMAND_BINLOG_DUMP, /* Not used currently. */ - DRIZZLE_COMMAND_TABLE_DUMP, /* Not used currently. */ - DRIZZLE_COMMAND_CONNECT_OUT, /* Not used currently. */ - DRIZZLE_COMMAND_REGISTER_SLAVE, /* Not used currently. */ - DRIZZLE_COMMAND_STMT_PREPARE, /* Not used currently. */ - DRIZZLE_COMMAND_STMT_EXECUTE, /* Not used currently. */ - DRIZZLE_COMMAND_STMT_SEND_LONG_DATA, /* Not used currently. */ - DRIZZLE_COMMAND_STMT_CLOSE, /* Not used currently. */ - DRIZZLE_COMMAND_STMT_RESET, /* Not used currently. */ - DRIZZLE_COMMAND_SET_OPTION, /* Not used currently. */ - DRIZZLE_COMMAND_STMT_FETCH, /* Not used currently. */ - DRIZZLE_COMMAND_DAEMON, /* Not used currently. */ - DRIZZLE_COMMAND_END /* Not used currently. */ -}; - -#ifndef __cplusplus -typedef enum drizzle_command_t drizzle_command_t; -#endif - -/** - * @ingroup drizzle_command - * Commands for the Drizzle protocol functions. - */ -enum drizzle_command_drizzle_t -{ - DRIZZLE_COMMAND_DRIZZLE_SLEEP, - DRIZZLE_COMMAND_DRIZZLE_QUIT, - DRIZZLE_COMMAND_DRIZZLE_INIT_DB, - DRIZZLE_COMMAND_DRIZZLE_QUERY, - DRIZZLE_COMMAND_DRIZZLE_SHUTDOWN, - DRIZZLE_COMMAND_DRIZZLE_CONNECT, - DRIZZLE_COMMAND_DRIZZLE_PING, - DRIZZLE_COMMAND_DRIZZLE_KILL, - DRIZZLE_COMMAND_DRIZZLE_END -}; - -#ifndef __cplusplus -typedef enum drizzle_command_drizzle_t drizzle_command_drizzle_t; -#endif - diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/command_client.h b/utils/mysqlcl_idb/libdrizzle-2.0/command_client.h deleted file mode 100644 index fe02dbb68..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/command_client.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Command Declarations for Clients - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_command_client Command Declarations for Clients - * @ingroup drizzle_client_interface - * - * These functions are used to issue commands on a connection. Normal SQL - * queries are issued using the drizzle_query* functions defined in query.h. - * @{ - */ - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/command_server.h b/utils/mysqlcl_idb/libdrizzle-2.0/command_server.h deleted file mode 100644 index df6b5cf5c..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/command_server.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Command Declarations for Servers - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_command_server Command Declarations for Servers - * @ingroup drizzle_server_interface - * - * These functions allow you to read comands on a connection. - * @{ - */ - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/common.h b/utils/mysqlcl_idb/libdrizzle-2.0/common.h deleted file mode 100644 index ac97c197e..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/common.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @file - * @brief System Include Files - */ - -#pragma once - -#include - -#include -#include - -#include -#include -#include -#ifndef _WIN32 -# include -# include -# include -#endif -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -#define random() rand() -#define srandom(a) srand(a) -#define get_socket_errno() WSAGetLastError() -#else -#define INVALID_SOCKET -1 -#define SOCKET_ERROR -1 -#define closesocket(a) close(a) -#define get_socket_errno() errno -#endif - -#ifndef PACKAGE_BUGREPORT -#define PACKAGE_BUGREPORT "drizzle@drizzle.org" -#endif - -#ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "2.0" -#endif - -#ifdef __cplusplus -# include -# ifndef UINT32_MAX -const unsigned int UINT32_MAX=std::numeric_limits::max(); -# endif -#endif - diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/conn.h b/utils/mysqlcl_idb/libdrizzle-2.0/conn.h deleted file mode 100644 index 3d4f0fa0b..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/conn.h +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Connection Declarations - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_con Connection Declarations - * @ingroup drizzle_client_interface - * @ingroup drizzle_server_interface - * @{ - */ - -/** - * Get file descriptor for connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return File descriptor of connection, or -1 if not active. - */ -DRIZZLE_API -int drizzle_con_fd(const drizzle_con_st *con); - -/** - * Use given file descriptor for connction. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] fd File descriptor for connection. - * @return Standard drizzle return value. - */ -DRIZZLE_API -drizzle_return_t drizzle_con_set_fd(drizzle_con_st *con, int fd); - -/** - * Close a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - */ -DRIZZLE_API -void drizzle_con_close(drizzle_con_st *con); - -/** - * Set events to be watched for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] events Bitfield of poll() events to watch. - * @return Standard drizzle return value. - */ -DRIZZLE_API -drizzle_return_t drizzle_con_set_events(drizzle_con_st *con, short events); - -/** - * Set events that are ready for a connection. This is used with the external - * event callbacks. See drizzle_set_event_watch_fn(). - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] revents Bitfield of poll() events that were detected. - * @return Standard drizzle return value. - */ -DRIZZLE_API -drizzle_return_t drizzle_con_set_revents(drizzle_con_st *con, short revents); - -/** - * Get the drizzle_st struct that the connection belongs to. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Drizzle object that this connection is part of. - */ -DRIZZLE_API -drizzle_st *drizzle_con_drizzle(const drizzle_con_st *con); - -/** - * Return an error string for last error encountered. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Pointer to static buffer in library that holds an error string. - */ -DRIZZLE_API -const char *drizzle_con_error(const drizzle_con_st *con); - -/** - * Value of errno in the case of a DRIZZLE_RETURN_ERRNO return value. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return An errno value as defined in your system errno.h file. - */ -DRIZZLE_API -int drizzle_con_errno(const drizzle_con_st *con); - -/** - * Get server defined error code for the last result read. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return An error code given back in the server response. - */ -DRIZZLE_API -uint16_t drizzle_con_error_code(const drizzle_con_st *con); - -/** - * Get SQL state code for the last result read. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return A SQLSTATE code given back in the server response. - */ -DRIZZLE_API -const char *drizzle_con_sqlstate(const drizzle_con_st *con); - -/** - * Get options for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Options set for the connection structure. - */ -DRIZZLE_API -int drizzle_con_options(const drizzle_con_st *con); - -/** - * Set options for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] options Available options for connection structure to set. - */ -DRIZZLE_API -void drizzle_con_set_options(drizzle_con_st *con, - int options); - -/** - * Add options for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] options Available options for connection structure to set. - */ -DRIZZLE_API -void drizzle_con_add_options(drizzle_con_st *con, - int options); - -/** - * Remove options for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] options Available options for connection structure to remove. - */ -DRIZZLE_API -void drizzle_con_remove_options(drizzle_con_st *con, - int options); - -/** - * Get TCP host for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Host this connection is configured for, or NULL if not set. - */ -DRIZZLE_API -const char *drizzle_con_host(const drizzle_con_st *con); - -/** - * Get TCP port for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Port this connection is configured for, 0 if not set. - */ -DRIZZLE_API -in_port_t drizzle_con_port(const drizzle_con_st *con); - -/** - * Set TCP host and port for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] host Host to use for this connection, NULL for default value. - * @param[in] port Port to use for this connection, 0 for default value. - */ -DRIZZLE_API -void drizzle_con_set_tcp(drizzle_con_st *con, const char *host, in_port_t port); - -/** - * Get unix domain socket for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Unix domain socket set for this connection, NULL if not set. - */ -DRIZZLE_API -const char *drizzle_con_uds(const drizzle_con_st *con); - -/** - * Set unix domain socket for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] uds Unix domain socket to use for this connection, NULL for - * defailt value. - */ -DRIZZLE_API -void drizzle_con_set_uds(drizzle_con_st *con, const char *uds); - -/** - * Get username for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return User associated with this connection. - */ -DRIZZLE_API -const char *drizzle_con_user(const drizzle_con_st *con); - -/** - * Get password for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Password associated with this connection. - */ -DRIZZLE_API -const char *drizzle_con_password(const drizzle_con_st *con); - -/** - * Set username and password for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] user Username to use for this connection. - * @param[in] password Password to use for this connection. - */ -DRIZZLE_API -void drizzle_con_set_auth(drizzle_con_st *con, const char *user, - const char *password); - -/** - * Get database for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Database associated with this connection. - */ -DRIZZLE_API -const char *drizzle_con_schema(const drizzle_con_st *con); - -DRIZZLE_API -const char *drizzle_con_db(const drizzle_con_st *con); - -/** - * Set database for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] schema Database to use with this connection. - */ -DRIZZLE_API -void drizzle_con_set_schema(drizzle_con_st *con, const char *schema); - -DRIZZLE_API -void drizzle_con_set_db(drizzle_con_st *con, const char *schema); - -/** - * Get application context pointer for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Application context with this connection. - */ -DRIZZLE_API -void *drizzle_con_context(const drizzle_con_st *con); - -/** - * Set application context pointer for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] context Application context to use with this connection. - */ -DRIZZLE_API -void drizzle_con_set_context(drizzle_con_st *con, void *context); - -/** - * Set callback function when the context pointer should be freed. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] function Function to call to clean up connection context. - */ -DRIZZLE_API -void drizzle_con_set_context_free_fn(drizzle_con_st *con, - drizzle_con_context_free_fn *function); - -/** - * Get protocol version for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Protocol version for connection. - */ -DRIZZLE_API -uint8_t drizzle_con_protocol_version(const drizzle_con_st *con); - -/** - * Get server version string for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Server version string for connection. - */ -DRIZZLE_API -const char *drizzle_con_server_version(const drizzle_con_st *con); - -/** - * Get server version number for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Server version number for connection. - */ -DRIZZLE_API -uint32_t drizzle_con_server_version_number(const drizzle_con_st *con); - -/** - * Get thread ID for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Thread ID for connection. - */ -DRIZZLE_API -uint32_t drizzle_con_thread_id(const drizzle_con_st *con); - -/** - * Get scramble buffer for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Scramble buffer for connection. - */ -DRIZZLE_API -const uint8_t *drizzle_con_scramble(const drizzle_con_st *con); - -/** - * Get capabilities for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Capabilities for connection. - */ -DRIZZLE_API -int drizzle_con_capabilities(const drizzle_con_st *con); - -/** - * Get character set for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Character set for connection. - */ -DRIZZLE_API -drizzle_charset_t drizzle_con_charset(const drizzle_con_st *con); - -/** - * Get status for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Status for connection. - */ -DRIZZLE_API -drizzle_con_status_t drizzle_con_status(const drizzle_con_st *con); - -/** - * Get max packet size for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Max packet size for connection. - */ -DRIZZLE_API -uint32_t drizzle_con_max_packet_size(const drizzle_con_st *con); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/conn_client.h b/utils/mysqlcl_idb/libdrizzle-2.0/conn_client.h deleted file mode 100644 index ef9a435e4..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/conn_client.h +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Connection Declarations for Clients - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_con_client Connection Declarations for Clients - * @ingroup drizzle_client_interface - * @{ - */ - -/** - * Connect to server. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Standard drizzle return value. - */ -DRIZZLE_API -drizzle_return_t drizzle_con_connect(drizzle_con_st *con); - -/** - * Send quit command to server for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] result Caller allocated structure, or NULL to allocate one. - * @param[out] ret_ptr Standard drizzle return value. - * @return On success, a pointer to the (possibly allocated) structure. On - * failure this will be NULL. - */ -DRIZZLE_API -drizzle_result_st *drizzle_con_quit(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr); - -/** - * @todo Remove this with next major API change. - */ -DRIZZLE_API -drizzle_result_st *drizzle_quit(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr); - -/** - * Select a new default database for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] result Caller allocated structure, or NULL to allocate one. - * @param[in] db Default database to select. - * @param[out] ret_ptr Standard drizzle return value. - * @return On success, a pointer to the (possibly allocated) structure. On - * failure this will be NULL. - */ -DRIZZLE_API -drizzle_result_st *drizzle_con_select_db(drizzle_con_st *con, - drizzle_result_st *result, - const char *db, - drizzle_return_t *ret_ptr); - -/** - * @todo Remove this with next major API change. - */ -DRIZZLE_API -drizzle_result_st *drizzle_select_db(drizzle_con_st *con, - drizzle_result_st *result, - const char *db, - drizzle_return_t *ret_ptr); - -/** - * Send a shutdown message to the server. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] result Caller allocated structure, or NULL to allocate one. - * @param[out] ret_ptr Standard drizzle return value. - * @return On success, a pointer to the (possibly allocated) structure. On - * failure this will be NULL. - */ -DRIZZLE_API -drizzle_result_st *drizzle_con_shutdown(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr); - -DRIZZLE_API -drizzle_result_st *drizzle_kill(drizzle_con_st *con, - drizzle_result_st *result, - uint32_t query_id, - drizzle_return_t *ret_ptr); - -/** - * @todo Remove this with next major API change. - */ -#define DRIZZLE_SHUTDOWN_DEFAULT 0 -DRIZZLE_API -drizzle_result_st *drizzle_shutdown(drizzle_con_st *con, - drizzle_result_st *result, uint32_t level, - drizzle_return_t *ret_ptr); - -/** - * Send a ping request to the server. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] result Caller allocated structure, or NULL to allocate one. - * @param[out] ret_ptr Standard drizzle return value. - * @return On success, a pointer to the (possibly allocated) structure. On - * failure this will be NULL. - */ -DRIZZLE_API -drizzle_result_st *drizzle_con_ping(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr); - -/** - * @todo Remove this with next major API change. - */ -DRIZZLE_API -drizzle_result_st *drizzle_ping(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr); - -/** - * Send raw command to server, possibly in parts. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] result Caller allocated structure, or NULL to allocate one. - * @param[in] command Command to run on server. - * @param[in] data Data to send along with the command. - * @param[in] size Size of the current chunk of data being sent. - * @param[in] total Total size of all data being sent for command. - * @param[out] ret_ptr Standard drizzle return value. - * @return On success, a pointer to the (possibly allocated) structure. On - * failure this will be NULL. - */ -DRIZZLE_API -drizzle_result_st *drizzle_con_command_write(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_command_t command, - const void *data, size_t size, - size_t total, - drizzle_return_t *ret_ptr); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/conn_local.h b/utils/mysqlcl_idb/libdrizzle-2.0/conn_local.h deleted file mode 100644 index c152ee075..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/conn_local.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Local Connection Declarations - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_con_local Local Connection Declarations - * @ingroup drizzle_con - * @{ - */ - -/** - * Clear address info, freeing structs if needed. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - */ -DRIZZLE_LOCAL -void drizzle_con_reset_addrinfo(drizzle_con_st *con); - -/** - * Check if state stack is empty. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return True if empty, false if something is on the stack. - */ -static inline bool drizzle_state_none(drizzle_con_st *con) -{ - return con->state_current == 0; -} - -/** - * Push a function onto the stack. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] function Function to push. - */ -static inline void drizzle_state_push(drizzle_con_st *con, - drizzle_state_fn *function) -{ - /* The maximum stack depth can be determined at compile time, so bump this - constant if needed to avoid the dynamic memory management. */ - assert(con->state_current < DRIZZLE_STATE_STACK_SIZE); - con->state_stack[con->state_current]= function; - con->state_current++; -} - -/** - * Pop a function off of the stack. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - */ -static inline void drizzle_state_pop(drizzle_con_st *con) -{ - con->state_current--; -} - -/** - * Reset the stack so it is empty. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - */ -static inline void drizzle_state_reset(drizzle_con_st *con) -{ - con->state_current= 0; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/conn_server.h b/utils/mysqlcl_idb/libdrizzle-2.0/conn_server.h deleted file mode 100644 index f990a9b37..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/conn_server.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Connection Declarations for Servers - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_con_server Connection Declarations for Servers - * @ingroup drizzle_server_interface - * - * These functions extend the core connection functions with a set of functions - * for server application use. These functions allow you to set raw handshake - * information for use with the handshake write functions. - * @{ - */ - -/** - * Put a connection into listening mode. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Standard drizzle return value. - */ -DRIZZLE_API -drizzle_return_t drizzle_con_listen(drizzle_con_st *con); - -/** - * Get connection backlog queue length. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Backlog for connection - */ -DRIZZLE_API -int drizzle_con_backlog(const drizzle_con_st *con); - -/** - * Set connection backlog queue length. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] backlog Backlog to use for connection - */ -DRIZZLE_API -void drizzle_con_set_backlog(drizzle_con_st *con, int backlog); - -/** - * Set protocol version for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] protocol_version Protocol version to use for connection - */ -DRIZZLE_API -void drizzle_con_set_protocol_version(drizzle_con_st *con, - uint8_t protocol_version); - -/** - * Set server version string for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] server_version Server version to use for connection - */ -DRIZZLE_API -void drizzle_con_set_server_version(drizzle_con_st *con, - const char *server_version); - -/** - * Set thread ID for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] thread_id Thread ID to use for connection - */ -DRIZZLE_API -void drizzle_con_set_thread_id(drizzle_con_st *con, uint32_t thread_id); - -/** - * Set scramble buffer for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] scramble Scramble to use for connection - */ -DRIZZLE_API -void drizzle_con_set_scramble(drizzle_con_st *con, const uint8_t *scramble); - -/** - * Set capabilities for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] capabilities Capabilities to use for connection - */ -DRIZZLE_API -void drizzle_con_set_capabilities(drizzle_con_st *con, - int capabilities); - -/** - * Set charset for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] charset Character set to use for connection - */ -DRIZZLE_API -void drizzle_con_set_charset(drizzle_con_st *con, drizzle_charset_t charset); - -/** - * Set status for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] status Status to use for connection - */ -DRIZZLE_API -void drizzle_con_set_status(drizzle_con_st *con, drizzle_con_status_t status); - -/** - * Set max packet size for a connection. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] max_packet_size Max packet size to use for connection - */ -DRIZZLE_API -void drizzle_con_set_max_packet_size(drizzle_con_st *con, - uint32_t max_packet_size); - -/** - * Copy all handshake information from one connection into another. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[in] from Connection structure to copy from. - */ -DRIZZLE_API -void drizzle_con_copy_handshake(drizzle_con_st *con, drizzle_con_st *from); - -/** - * Read command without buffering. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[out] command Command that was read. - * @param[out] offset Where the data being returned begins in the command data. - * @param[out] size The size of the data chunk being returned. - * @param[out] total The total size of all command data being read. - * @param[out] ret_ptr Standard drizzle return value. - * @return On success, a pointer to an internal buffer with the command data. - * It will be *size bytes in length. - */ -DRIZZLE_API -void *drizzle_con_command_read(drizzle_con_st *con, - drizzle_command_t *command, size_t *offset, - size_t *size, size_t *total, - drizzle_return_t *ret_ptr); - -/** - * Read command and buffer it. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @param[out] command Command that was read. - * @param[out] total The total size of all command data being read. - * @param[out] ret_ptr Standard drizzle return value. - * @return On success, allocated buffer that holds the command data of length - * *total. - */ -DRIZZLE_API -void *drizzle_con_command_buffer(drizzle_con_st *con, - drizzle_command_t *command, size_t *total, - drizzle_return_t *ret_ptr); - -DRIZZLE_API -void drizzle_con_command_buffer_free(uint8_t *command_buffer); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/constants.h b/utils/mysqlcl_idb/libdrizzle-2.0/constants.h deleted file mode 100644 index ffb44a665..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/constants.h +++ /dev/null @@ -1,474 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2011 Brian Aker (brian@tangent.org) - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Defines, typedefs, enums, and macros - */ - -#include - -#ifdef __cplusplus - -#include - -extern "C" { - -#endif - -/** - * @addtogroup drizzle_constants Constants - * @ingroup drizzle_client_interface - * @ingroup drizzle_server_interface - * @{ - */ - -/* Defines. */ -#define DRIZZLE_DEFAULT_TCP_HOST "localhost" -#define DRIZZLE_DEFAULT_TCP_PORT 4427 -#define DRIZZLE_DEFAULT_TCP_PORT_MYSQL 4427 -#define DRIZZLE_DEFAULT_UDS "/tmp/drizzle.sock" -#define DRIZZLE_DEFAULT_UDS_MYSQL "/tmp/mysql.sock" -#define DRIZZLE_DEFAULT_BACKLOG 64 -#define DRIZZLE_BUFFER_COPY_THRESHOLD 8192 -#define DRIZZLE_ROW_GROW_SIZE 8192 -#define DRIZZLE_STATE_STACK_SIZE 8 -#define DRIZZLE_DEFAULT_SOCKET_TIMEOUT 10 -#define DRIZZLE_DEFAULT_SOCKET_SEND_SIZE 32768 -#define DRIZZLE_DEFAULT_SOCKET_RECV_SIZE 32768 -#define DRIZZLE_MYSQL_PASSWORD_HASH 41 - -#include -#include -#include -#include -#include - -/** @} */ - -/** - * @ingroup drizzle_con - * Options for drizzle_con_st. - */ -enum drizzle_con_options_t -{ - DRIZZLE_CON_NONE= 0, - DRIZZLE_CON_ALLOCATED= (1 << 0), // DEPRECATED - DRIZZLE_CON_MYSQL= (1 << 1), - DRIZZLE_CON_RAW_PACKET= (1 << 2), - DRIZZLE_CON_RAW_SCRAMBLE= (1 << 3), - DRIZZLE_CON_READY= (1 << 4), - DRIZZLE_CON_NO_RESULT_READ= (1 << 5), - DRIZZLE_CON_IO_READY= (1 << 6), - DRIZZLE_CON_LISTEN= (1 << 7), - DRIZZLE_CON_EXPERIMENTAL= (1 << 8), - DRIZZLE_CON_FOUND_ROWS= (1 << 9), - DRIZZLE_CON_INTERACTIVE= (1 << 11), - DRIZZLE_CON_MULTI_STATEMENTS= (1 << 12), - DRIZZLE_CON_AUTH_PLUGIN= (1 << 13) -}; - -#ifndef __cplusplus -typedef enum drizzle_con_options_t drizzle_con_options_t; -#endif - -/** - * @ingroup drizzle_con - * Socket types for drizzle_con_st. - */ -enum drizzle_con_socket_t -{ - DRIZZLE_CON_SOCKET_TCP, - DRIZZLE_CON_SOCKET_UDS -}; - -#ifndef __cplusplus -typedef enum drizzle_con_socket_t drizzle_con_socket_t; -#endif - -/** - * @ingroup drizzle_con - * Status flags for drizle_con_st. - */ -enum drizzle_con_status_t -{ - DRIZZLE_CON_STATUS_NONE= 0, - DRIZZLE_CON_STATUS_IN_TRANS= (1 << 0), - DRIZZLE_CON_STATUS_AUTOCOMMIT= (1 << 1), - DRIZZLE_CON_STATUS_MORE_RESULTS_EXISTS= (1 << 3), - DRIZZLE_CON_STATUS_QUERY_NO_GOOD_INDEX_USED= (1 << 4), - DRIZZLE_CON_STATUS_QUERY_NO_INDEX_USED= (1 << 5), - DRIZZLE_CON_STATUS_CURSOR_EXISTS= (1 << 6), - DRIZZLE_CON_STATUS_LAST_ROW_SENT= (1 << 7), - DRIZZLE_CON_STATUS_DB_DROPPED= (1 << 8), - DRIZZLE_CON_STATUS_NO_BACKSLASH_ESCAPES= (1 << 9), - DRIZZLE_CON_STATUS_QUERY_WAS_SLOW= (1 << 10) -}; - -#ifndef __cplusplus -typedef enum drizzle_con_status_t drizzle_con_status_t; -#endif - -/** - * @ingroup drizzle_con - * Capabilities for drizzle_con_st. - */ -enum drizzle_capabilities_t -{ - DRIZZLE_CAPABILITIES_NONE= 0, - DRIZZLE_CAPABILITIES_LONG_PASSWORD= (1 << 0), - DRIZZLE_CAPABILITIES_FOUND_ROWS= (1 << 1), - DRIZZLE_CAPABILITIES_LONG_FLAG= (1 << 2), - DRIZZLE_CAPABILITIES_CONNECT_WITH_DB= (1 << 3), - DRIZZLE_CAPABILITIES_NO_SCHEMA= (1 << 4), - DRIZZLE_CAPABILITIES_COMPRESS= (1 << 5), - DRIZZLE_CAPABILITIES_ODBC= (1 << 6), - DRIZZLE_CAPABILITIES_LOCAL_FILES= (1 << 7), - DRIZZLE_CAPABILITIES_IGNORE_SPACE= (1 << 8), - DRIZZLE_CAPABILITIES_PROTOCOL_41= (1 << 9), - DRIZZLE_CAPABILITIES_INTERACTIVE= (1 << 10), - DRIZZLE_CAPABILITIES_SSL= (1 << 11), - DRIZZLE_CAPABILITIES_IGNORE_SIGPIPE= (1 << 12), - DRIZZLE_CAPABILITIES_TRANSACTIONS= (1 << 13), - DRIZZLE_CAPABILITIES_RESERVED= (1 << 14), - DRIZZLE_CAPABILITIES_SECURE_CONNECTION= (1 << 15), - DRIZZLE_CAPABILITIES_MULTI_STATEMENTS= (1 << 16), - DRIZZLE_CAPABILITIES_MULTI_RESULTS= (1 << 17), - DRIZZLE_CAPABILITIES_PS_MULTI_RESULTS= (1 << 18), - DRIZZLE_CAPABILITIES_PLUGIN_AUTH= (1 << 19), - DRIZZLE_CAPABILITIES_SSL_VERIFY_SERVER_CERT= (1 << 30), - DRIZZLE_CAPABILITIES_REMEMBER_OPTIONS= (1 << 31), - DRIZZLE_CAPABILITIES_CLIENT= (DRIZZLE_CAPABILITIES_LONG_PASSWORD | - DRIZZLE_CAPABILITIES_FOUND_ROWS | - DRIZZLE_CAPABILITIES_LONG_FLAG | - DRIZZLE_CAPABILITIES_CONNECT_WITH_DB | - DRIZZLE_CAPABILITIES_PLUGIN_AUTH | - DRIZZLE_CAPABILITIES_TRANSACTIONS | - DRIZZLE_CAPABILITIES_PROTOCOL_41 | - DRIZZLE_CAPABILITIES_SECURE_CONNECTION) -}; - -#ifndef __cplusplus -typedef enum drizzle_capabilities_t drizzle_capabilities_t; -#endif - -/** - * @ingroup drizzle_query - * States for drizle_query_st. - */ -enum drizzle_query_state_t -{ - DRIZZLE_QUERY_STATE_INIT, - DRIZZLE_QUERY_STATE_QUERY, - DRIZZLE_QUERY_STATE_RESULT, - DRIZZLE_QUERY_STATE_DONE -}; - -#ifndef __cplusplus -enum drizzle_query_state_t drizzle_query_state_t; -#endif - -/** - * @ingroup drizzle_result - * Options for drizzle_result_st. - */ -enum drizzle_result_options_t -{ - DRIZZLE_RESULT_NONE= 0, - DRIZZLE_RESULT_ALLOCATED= (1 << 0), // DEPRECATED - DRIZZLE_RESULT_SKIP_COLUMN= (1 << 1), - DRIZZLE_RESULT_BUFFER_COLUMN= (1 << 2), - DRIZZLE_RESULT_BUFFER_ROW= (1 << 3), - DRIZZLE_RESULT_EOF_PACKET= (1 << 4), - DRIZZLE_RESULT_ROW_BREAK= (1 << 5) -}; - -#ifndef __cplusplus -typedef enum drizzle_result_options_t drizzle_result_options_t; -#endif - -/** - * @ingroup drizzle_column - * Options for drizzle_column_st. - */ -enum drizzle_column_options_t -{ - DRIZZLE_COLUMN_ALLOCATED= (1 << 0) // DEPRECATED -}; - -#ifndef __cplusplus -typedef enum drizzle_column_options_t drizzle_column_options_t; -#endif - -/** - * @ingroup drizzle_column - * Types for drizzle_column_st. - */ -enum drizzle_column_type_t -{ - DRIZZLE_COLUMN_TYPE_DECIMAL, - DRIZZLE_COLUMN_TYPE_TINY, - DRIZZLE_COLUMN_TYPE_SHORT, - DRIZZLE_COLUMN_TYPE_LONG, - DRIZZLE_COLUMN_TYPE_FLOAT, - DRIZZLE_COLUMN_TYPE_DOUBLE, - DRIZZLE_COLUMN_TYPE_NULL, - DRIZZLE_COLUMN_TYPE_TIMESTAMP, - DRIZZLE_COLUMN_TYPE_LONGLONG, - DRIZZLE_COLUMN_TYPE_INT24, - DRIZZLE_COLUMN_TYPE_DATE, - DRIZZLE_COLUMN_TYPE_TIME, - DRIZZLE_COLUMN_TYPE_DATETIME, - DRIZZLE_COLUMN_TYPE_YEAR, - DRIZZLE_COLUMN_TYPE_NEWDATE, - DRIZZLE_COLUMN_TYPE_VARCHAR, - DRIZZLE_COLUMN_TYPE_BIT, - DRIZZLE_COLUMN_TYPE_NEWDECIMAL= 246, - DRIZZLE_COLUMN_TYPE_ENUM= 247, - DRIZZLE_COLUMN_TYPE_SET= 248, - DRIZZLE_COLUMN_TYPE_TINY_BLOB= 249, - DRIZZLE_COLUMN_TYPE_MEDIUM_BLOB= 250, - DRIZZLE_COLUMN_TYPE_LONG_BLOB= 251, - DRIZZLE_COLUMN_TYPE_BLOB= 252, - DRIZZLE_COLUMN_TYPE_VAR_STRING= 253, - DRIZZLE_COLUMN_TYPE_STRING= 254, - DRIZZLE_COLUMN_TYPE_GEOMETRY= 255 -}; - -#ifndef __cplusplus -typedef enum drizzle_column_type_t drizzle_column_type_t; -#endif - -/** - * @ingroup drizzle_column - * Types for drizzle_column_st for Drizzle. - */ -enum drizzle_column_type_drizzle_t -{ - DRIZZLE_COLUMN_TYPE_DRIZZLE_TINY, - DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG, - DRIZZLE_COLUMN_TYPE_DRIZZLE_DOUBLE, - DRIZZLE_COLUMN_TYPE_DRIZZLE_NULL, - DRIZZLE_COLUMN_TYPE_DRIZZLE_TIMESTAMP, - DRIZZLE_COLUMN_TYPE_DRIZZLE_LONGLONG, - DRIZZLE_COLUMN_TYPE_DRIZZLE_DATETIME, - DRIZZLE_COLUMN_TYPE_DRIZZLE_DATE, - DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR, - DRIZZLE_COLUMN_TYPE_DRIZZLE_NEWDECIMAL, - DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM, - DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB, - DRIZZLE_COLUMN_TYPE_DRIZZLE_TIME, - DRIZZLE_COLUMN_TYPE_DRIZZLE_BOOLEAN, - DRIZZLE_COLUMN_TYPE_DRIZZLE_UUID, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MICROTIME, - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX=DRIZZLE_COLUMN_TYPE_DRIZZLE_MICROTIME -}; - -#ifndef __cplusplus -typedef enum drizzle_column_type_drizzle_t drizzle_column_type_drizzle_t; -#endif - -/** - * @ingroup drizzle_column - * Flags for drizzle_column_st. - */ -enum drizzle_column_flags_t -{ - DRIZZLE_COLUMN_FLAGS_NONE= 0, - DRIZZLE_COLUMN_FLAGS_NOT_NULL= (1 << 0), - DRIZZLE_COLUMN_FLAGS_PRI_KEY= (1 << 1), - DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY= (1 << 2), - DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY= (1 << 3), - DRIZZLE_COLUMN_FLAGS_BLOB= (1 << 4), - DRIZZLE_COLUMN_FLAGS_UNSIGNED= (1 << 5), - DRIZZLE_COLUMN_FLAGS_ZEROFILL= (1 << 6), - DRIZZLE_COLUMN_FLAGS_BINARY= (1 << 7), - DRIZZLE_COLUMN_FLAGS_ENUM= (1 << 8), - DRIZZLE_COLUMN_FLAGS_AUTO_INCREMENT= (1 << 9), - DRIZZLE_COLUMN_FLAGS_TIMESTAMP= (1 << 10), - DRIZZLE_COLUMN_FLAGS_SET= (1 << 11), - DRIZZLE_COLUMN_FLAGS_NO_DEFAULT_VALUE= (1 << 12), - DRIZZLE_COLUMN_FLAGS_ON_UPDATE_NOW= (1 << 13), - DRIZZLE_COLUMN_FLAGS_PART_KEY= (1 << 14), - DRIZZLE_COLUMN_FLAGS_NUM= (1 << 15), - DRIZZLE_COLUMN_FLAGS_GROUP= (1 << 15), /* NUM & GROUP the same. */ - DRIZZLE_COLUMN_FLAGS_UNIQUE= (1 << 16), - DRIZZLE_COLUMN_FLAGS_BINCMP= (1 << 17), - DRIZZLE_COLUMN_FLAGS_GET_FIXED_FIELDS= (1 << 18), - DRIZZLE_COLUMN_FLAGS_IN_PART_FUNC= (1 << 19), - DRIZZLE_COLUMN_FLAGS_IN_ADD_INDEX= (1 << 20), - DRIZZLE_COLUMN_FLAGS_RENAMED= (1 << 21) -}; - -#ifndef __cplusplus -typedef enum drizzle_column_flags_t drizzle_column_flags_t; -#endif - -/** - * @addtogroup drizzle_types Types - * @ingroup drizzle_client_interface - * @ingroup drizzle_server_interface - * @{ - */ - -/* Types. */ -#ifndef __cplusplus -typedef struct drizzle_st drizzle_st; -typedef struct drizzle_con_tcp_st drizzle_con_tcp_st; -typedef struct drizzle_con_uds_st drizzle_con_uds_st; -typedef struct drizzle_con_st drizzle_con_st; -typedef struct drizzle_query_st drizzle_query_st; -typedef struct drizzle_result_st drizzle_result_st; -typedef struct drizzle_column_st drizzle_column_st; -#else -class drizzle_st; -class drizzle_con_tcp_st; -class drizzle_con_uds_st; -class drizzle_con_st; -class drizzle_query_st; -class drizzle_result_st; -class drizzle_column_st; -#endif - -typedef char drizzle_field_t_type; -typedef drizzle_field_t_type *drizzle_field_t; -typedef drizzle_field_t drizzle_row_t_type; -typedef drizzle_row_t_type *drizzle_row_t; -typedef size_t * drizzle_field_sizes_type; -typedef uint8_t drizzle_charset_t; - -#if defined(__cplusplus) -typedef ::std::vector drizzle_row_list_t; -typedef ::std::vector drizzle_field_sizes_list_t; -#else -typedef void drizzle_row_list_t; -typedef void drizzle_field_sizes_list_t; -#endif - -/* Function types. */ -typedef void (drizzle_context_free_fn)(drizzle_st *drizzle, void *context); -typedef void (drizzle_log_fn)(const char *line, drizzle_verbose_t verbose, void *context); -typedef drizzle_return_t (drizzle_state_fn)(drizzle_con_st *con); -typedef void (drizzle_con_context_free_fn)(drizzle_con_st *con, void *context); -typedef void (drizzle_query_context_free_fn)(drizzle_query_st *query, void *context); -/** - * Custom function to register or deregister interest in file descriptor - * events. See drizzle_set_event_watch_fn(). - * - * @param[in] con Connection that has changed the events it is interested in. - * Use drizzle_con_fd() to get the file descriptor. - * @param[in] events A bit mask of POLLIN | POLLOUT, specifying if the - * connection is waiting for read or write events. - * @param[in] context Application context pointer registered with - * drizzle_set_event_watch_fn(). - * @return DRIZZLE_RETURN_OK if successful. - */ -typedef drizzle_return_t (drizzle_event_watch_fn)(drizzle_con_st *con, - short events, - void *context); - -/** @} */ - -/** - * @addtogroup drizzle_macros Macros - * @ingroup drizzle_client_interface - * @ingroup drizzle_server_interface - * @{ - */ - -/* Protocol unpacking macros. */ -#define drizzle_get_byte2(__buffer) \ - (uint16_t)((__buffer)[0] | \ - ((__buffer)[1] << 8)) -#define drizzle_get_byte3(__buffer) \ - (uint32_t)((__buffer)[0] | \ - ((__buffer)[1] << 8) | \ - ((__buffer)[2] << 16)) -#define drizzle_get_byte4(__buffer) \ - (uint32_t)((__buffer)[0] | \ - ((__buffer)[1] << 8) | \ - ((__buffer)[2] << 16) | \ - ((__buffer)[3] << 24)) -#define drizzle_get_byte8(__buffer) \ - ((uint64_t)(__buffer)[0] | \ - ((uint64_t)(__buffer)[1] << 8) | \ - ((uint64_t)(__buffer)[2] << 16) | \ - ((uint64_t)(__buffer)[3] << 24) | \ - ((uint64_t)(__buffer)[4] << 32) | \ - ((uint64_t)(__buffer)[5] << 40) | \ - ((uint64_t)(__buffer)[6] << 48) | \ - ((uint64_t)(__buffer)[7] << 56)) - -/* Protocol packing macros. */ -#define drizzle_set_byte2(__buffer, __int) do { \ - (__buffer)[0]= (uint8_t)((__int) & 0xFF); \ - (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); } while (0) -#define drizzle_set_byte3(__buffer, __int) do { \ - (__buffer)[0]= (uint8_t)((__int) & 0xFF); \ - (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \ - (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); } while (0) -#define drizzle_set_byte4(__buffer, __int) do { \ - (__buffer)[0]= (uint8_t)((__int) & 0xFF); \ - (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \ - (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \ - (__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); } while (0) -#define drizzle_set_byte8(__buffer, __int) do { \ - (__buffer)[0]= (uint8_t)((__int) & 0xFF); \ - (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \ - (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \ - (__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); \ - (__buffer)[4]= (uint8_t)(((__int) >> 32) & 0xFF); \ - (__buffer)[5]= (uint8_t)(((__int) >> 40) & 0xFF); \ - (__buffer)[6]= (uint8_t)(((__int) >> 48) & 0xFF); \ - (__buffer)[7]= (uint8_t)(((__int) >> 56) & 0xFF); } while (0) - -/* Multi-byte character macros. */ -#define drizzle_mb_char(__c) (((__c) & 0x80) != 0) -#define drizzle_mb_length(__c) \ - ((uint32_t)(__c) <= 0x7f ? 1 : \ - ((uint32_t)(__c) <= 0x7ff ? 2 : \ - ((uint32_t)(__c) <= 0xd7ff ? 3 : \ - ((uint32_t)(__c) <= 0xdfff || (uint32_t)(__c) > 0x10ffff ? 0 : \ - ((uint32_t)(__c) <= 0xffff ? 3 : 4))))) - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/deprecated_enum.h b/utils/mysqlcl_idb/libdrizzle-2.0/deprecated_enum.h deleted file mode 100644 index 5d90877a2..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/deprecated_enum.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2011 Brian Aker (brian@tangent.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @ingroup drizzle_query - * Options for drizzle_query_st. - */ -enum drizzle_query_options_t -{ - DRIZZLE_QUERY_NONE, - DRIZZLE_QUERY_ALLOCATED -}; - -#ifndef __cplusplus -typedef enum drizzle_query_options_t drizzle_query_options_t; -#endif - -/** - * @ingroup drizzle - * Options for drizzle_st. - */ -enum drizzle_options_t -{ - DRIZZLE_NON_BLOCKING, - DRIZZLE_FREE_OBJECTS, - DRIZZLE_ASSERT_DANGLING -}; - -#ifndef __cplusplus -typedef enum drizzle_options_t drizzle_options_t; -#endif - diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/drizzle.h b/utils/mysqlcl_idb/libdrizzle-2.0/drizzle.h deleted file mode 100644 index 96bf17013..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/drizzle.h +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Drizzle Declarations - */ - -#include - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# define NOMINMAX - -# include -# include -# include -# include - -# undef close -# define close _close -typedef unsigned int in_port_t; -//typedef long ssize_t; - -# define snprintf _snprintf - -struct sockaddr_un -{ - short int sun_family; - char sun_path[108]; -}; - -//# define poll WSAPoll -//# define pollfd WSAPOLLFD - -#if defined(__GNUC__) -# include -#else -# if !defined(__cplusplus) -typedef enum { false = 0, true = 1 } _Bool; -typedef _Bool bool; -#endif -#endif - -#else -# if !defined(__cplusplus) -# include -# endif -# include -# include -# include -# include -# include -# include -# include -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle Drizzle Declarations - * @ingroup drizzle_client_interface - * @ingroup drizzle_server_interface - * - * This is the core library structure that other structures (such as - * connections) are created from. - * - * There is no locking within a single drizzle_st structure, so for threaded - * applications you must either ensure isolation in the application or use - * multiple drizzle_st structures (for example, one for each thread). - * @{ - */ - -/** - * Get library version string. - * - * @return Pointer to static buffer in library that holds the version string. - */ -DRIZZLE_API -const char *drizzle_version(void); - -/** - * Get bug report URL. - * - * @return Bug report URL string. - */ -DRIZZLE_API -const char *drizzle_bugreport(void); - -/** - * Get string with the name of the given verbose level. - * - * @param[in] verbose Verbose logging level. - * @return String form of verbose level. - */ -DRIZZLE_API -const char *drizzle_verbose_name(drizzle_verbose_t verbose); - -/** - * Initialize a drizzle structure. Always check the return value even if passing - * in a pre-allocated structure. Some other initialization may have failed. - * - * @param[in] drizzle Caller allocated structure, or NULL to allocate one. - * @return On success, a pointer to the (possibly allocated) structure. On - * failure this will be NULL. - */ -DRIZZLE_API -drizzle_st *drizzle_create(); - -/** - * Clone a drizzle structure. - * - * @param[in] drizzle Caller allocated structure, or NULL to allocate one. - * @param[in] from Drizzle structure to use as a source to clone from. - * @return Same return as drizzle_create(). - */ -DRIZZLE_API -drizzle_st *drizzle_clone(const drizzle_st *from); - -/** - * Free a drizzle structure. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - */ -DRIZZLE_API -void drizzle_free(drizzle_st *drizzle); - -/** - * Return an error string for last error encountered. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @return Pointer to static buffer in library that holds an error string. - */ -DRIZZLE_API -const char *drizzle_error(const drizzle_st *drizzle); - -/** - * Value of errno in the case of a DRIZZLE_RETURN_ERRNO return value. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @return An errno value as defined in your system errno.h file. - */ -DRIZZLE_API -int drizzle_errno(const drizzle_st *drizzle); - -/** - * Get server defined error code for the last result read. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @return An error code given back in the server response. - */ -DRIZZLE_API -uint16_t drizzle_error_code(const drizzle_st *drizzle); - -/** - * Get SQL state code for the last result read. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @return A SQLSTATE code given back in the server response. - */ -DRIZZLE_API -const char *drizzle_sqlstate(const drizzle_st *drizzle); - -/** - * Get application context pointer. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @return Application context that was previously set, or NULL. - */ -DRIZZLE_API -void *drizzle_context(const drizzle_st *drizzle); - -/** - * Set application context pointer. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] context Application context to set. - */ -DRIZZLE_API -void drizzle_set_context(drizzle_st *drizzle, void *context); - -/** - * Set function to call when the drizzle structure is being cleaned up so - * the application can clean up the context pointer. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] function Function to call to clean up drizzle context. - */ -DRIZZLE_API -void drizzle_set_context_free_fn(drizzle_st *drizzle, - drizzle_context_free_fn *function); - -/** - * Get current socket I/O activity timeout value. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @return Timeout in milliseconds to wait for I/O activity. A negative value - * means an infinite timeout. - */ -DRIZZLE_API -int drizzle_timeout(const drizzle_st *drizzle); - -/** - * Set socket I/O activity timeout for connections in a Drizzle structure. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] timeout Milliseconds to wait for I/O activity. A negative value - * means an infinite timeout. - */ -DRIZZLE_API -void drizzle_set_timeout(drizzle_st *drizzle, int timeout); - -/** - * Get current verbosity threshold for logging messages. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @return Current verbosity threshold. - */ -DRIZZLE_API -drizzle_verbose_t drizzle_verbose(const drizzle_st *drizzle); - -/** - * Set verbosity threshold for logging messages. If this is set above - * DRIZZLE_VERBOSE_NEVER and the drizzle_set_log_fn() callback is set to NULL, - * messages are printed to STDOUT. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] verbose Verbosity threshold of what to log. - */ -DRIZZLE_API -void drizzle_set_verbose(drizzle_st *drizzle, drizzle_verbose_t verbose); - -/** - * Set logging function for a drizzle structure. This function is only called - * for log messages that are above the verbosity threshold set with - * drizzle_set_verbose(). - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] function Function to call when there is a logging message. - * @param[in] context Argument to pass into the callback function. - */ -DRIZZLE_API -void drizzle_set_log_fn(drizzle_st *drizzle, drizzle_log_fn *function, - void *context); - -/** - * Set a custom I/O event watcher function for a drizzle structure. Used to - * integrate libdrizzle with a custom event loop. The callback will be invoked - * to register or deregister interest in events for a connection. When the - * events are triggered, drizzle_con_set_revents() should be called to - * indicate which events are ready. The event loop should stop waiting for - * these events, as libdrizzle will call the callback again if it is still - * interested. To resume processing, the libdrizzle function that returned - * DRIZZLE_RETURN_IO_WAIT should be called again. See drizzle_event_watch_fn(). - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] function Function to call when there is an I/O event. - * @param[in] context Argument to pass into the callback function. - */ -DRIZZLE_API -void drizzle_set_event_watch_fn(drizzle_st *drizzle, - drizzle_event_watch_fn *function, - void *context); - -/** - * Initialize a connection structure. Always check the return value even if - * passing in a pre-allocated structure. Some other initialization may have - * failed. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] con Caller allocated structure, or NULL to allocate one. - * @return On success, a pointer to the (possibly allocated) structure. On - * failure this will be NULL. - */ -DRIZZLE_API -drizzle_con_st *drizzle_con_create(drizzle_st *drizzle); - -/** - * Clone a connection structure. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] con Caller allocated structure, or NULL to allocate one. - * @param[in] from Connection structure to use as a source to clone from. - * @return Same return as drizzle_con_create(). - */ -DRIZZLE_API -drizzle_con_st *drizzle_con_clone(drizzle_st *drizzle, drizzle_con_st *con); - -DRIZZLE_API -drizzle_return_t drizzle_set_option(drizzle_st *drizzle, drizzle_options_t arg, bool set); - -/** - * Free a connection structure. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - */ -DRIZZLE_API -void drizzle_con_free(drizzle_con_st *con); - -/** - * Free all connections in a drizzle structure. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - */ -DRIZZLE_API -void drizzle_con_free_all(drizzle_st *drizzle); - -/** - * Wait for I/O on connections. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @return Standard drizzle return value. - */ -DRIZZLE_API -drizzle_return_t drizzle_con_wait(drizzle_st *drizzle); - -/** - * Get next connection that is ready for I/O. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @return Connection that is ready for I/O, or NULL if there are none. - */ -DRIZZLE_API -drizzle_con_st *drizzle_con_ready(drizzle_st *drizzle); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/drizzle_client.h b/utils/mysqlcl_idb/libdrizzle-2.0/drizzle_client.h deleted file mode 100644 index 41f80044a..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/drizzle_client.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Drizzle Declarations for Clients - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup drizzle_client_interface Drizzle Client Interface - */ - -/** - * @addtogroup drizzle_client Drizzle Declarations for Clients - * @ingroup drizzle_client_interface - * @{ - */ - -/** - * Add TCP (IPv4 or IPv6) connection with common arguments. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] con Caller allocated structure, or NULL to allocate one. - * @param[in] host Host to connect to. This may be a hostname to resolve, an - * IPv4 address, or an IPv6 address. This is passed directly to getaddrinfo(). - * @param[in] port Remote port to connect to. - * @param[in] user User to use while establishing the connection. - * @param[in] password Password to use while establishing the connection. - * @param[in] db Initial database to connect to. - * @param[in] options Drizzle connection options to add. - * @return Same return as drizzle_con_create(). - */ -DRIZZLE_API -drizzle_con_st *drizzle_con_add_tcp(drizzle_st *drizzle, - const char *host, in_port_t port, - const char *user, const char *password, - const char *db, - drizzle_con_options_t options); - -/** - * Add unix domain socket connection with common arguments. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] con Caller allocated structure, or NULL to allocate one. - * @param[in] uds Path to unix domain socket to use for connection. - * @param[in] user User to use while establishing the connection. - * @param[in] password Password to use while establishing the connection. - * @param[in] db Initial database to connect to. - * @param[in] options Drizzle connection options to add. - * @return Same return as drizzle_con_create(). - */ -DRIZZLE_API -drizzle_con_st *drizzle_con_add_uds(drizzle_st *drizzle, - const char *uds, const char *user, - const char *password, const char *db, - drizzle_con_options_t options); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/drizzle_local.h b/utils/mysqlcl_idb/libdrizzle-2.0/drizzle_local.h deleted file mode 100644 index c404d81be..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/drizzle_local.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Local Drizzle Declarations - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_local Local Drizzle Declarations - * @ingroup drizzle - * @{ - */ - -/** - * Set the error string. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] function Name of function the error happened in. - * @param[in] format Format and variable argument list of message. - */ -DRIZZLE_LOCAL -void drizzle_set_error(drizzle_st *drizzle, const char *function, - const char *format, ...); - -/** - * Log a message. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] verbose Logging level of the message. - * @param[in] format Format and variable argument list of message. - * @param[in] args Variable argument list that has been initialized. - */ -DRIZZLE_LOCAL -void drizzle_log(drizzle_st *drizzle, drizzle_verbose_t verbose, - const char *format, va_list args); - -/** - * Log a fatal message, see drizzle_log() for argument details. - */ -static inline void drizzle_log_fatal(drizzle_st *drizzle, const char *format, - ...) -{ - va_list args; - - if (drizzle->verbose >= DRIZZLE_VERBOSE_FATAL) - { - va_start(args, format); - drizzle_log(drizzle, DRIZZLE_VERBOSE_FATAL, format, args); - va_end(args); - } -} - -/** - * Log an error message, see drizzle_log() for argument details. - */ -static inline void drizzle_log_error(drizzle_st *drizzle, const char *format, - ...) -{ - va_list args; - - if (drizzle->verbose >= DRIZZLE_VERBOSE_ERROR) - { - va_start(args, format); - drizzle_log(drizzle, DRIZZLE_VERBOSE_ERROR, format, args); - va_end(args); - } -} - -/** - * Log an info message, see drizzle_log() for argument details. - */ -static inline void drizzle_log_info(drizzle_st *drizzle, const char *format, - ...) -{ - va_list args; - - if (drizzle->verbose >= DRIZZLE_VERBOSE_INFO) - { - va_start(args, format); - drizzle_log(drizzle, DRIZZLE_VERBOSE_INFO, format, args); - va_end(args); - } -} - -/** - * Log a debug message, see drizzle_log() for argument details. - */ -static inline void drizzle_log_debug(drizzle_st *drizzle, const char *format, - ...) -{ - va_list args; - - if (drizzle->verbose >= DRIZZLE_VERBOSE_DEBUG) - { - va_start(args, format); - drizzle_log(drizzle, DRIZZLE_VERBOSE_DEBUG, format, args); - va_end(args); - } -} - -/** - * Log a crazy message, see drizzle_log() for argument details. - */ -static inline void drizzle_log_crazy(drizzle_st *drizzle, const char *format, - ...) -{ - va_list args; - - if (drizzle->verbose >= DRIZZLE_VERBOSE_CRAZY) - { - va_start(args, format); - drizzle_log(drizzle, DRIZZLE_VERBOSE_CRAZY, format, args); - va_end(args); - } -} - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/drizzle_server.h b/utils/mysqlcl_idb/libdrizzle-2.0/drizzle_server.h deleted file mode 100644 index 8b2a98c83..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/drizzle_server.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Drizzle Declarations for Servers - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup drizzle_server_interface Drizzle Server Interface - */ - -/** - * @addtogroup drizzle_server Drizzle Declarations for Servers - * @ingroup drizzle_server_interface - * @{ - */ - -/** - * Add TCP (IPv4 or IPv6) connection for listening with common arguments. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] con Caller allocated structure, or NULL to allocate one. - * @param[in] host Host to listen on. This may be a hostname to resolve, an - * IPv4 address, or an IPv6 address. This is passed directly to getaddrinfo(). - * @param[in] port Port to connect to. - * @param[in] backlog Number of backlog connections passed to listen(). - * @param[in] options Drizzle connection options to add. - * @return Same return as drizzle_con_create(). - */ -DRIZZLE_API -drizzle_con_st *drizzle_con_add_tcp_listen(drizzle_st *drizzle, - const char *host, in_port_t port, - int backlog, - drizzle_con_options_t options); - -/** - * Add unix domain socket connection for listening with common arguments. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[in] uds Path to unix domain socket to use for listening. - * @param[in] backlog Number of backlog connections passed to listen(). - * @param[in] options Drizzle connection options to add. - * @return Same return as drizzle_con_create(). - */ -DRIZZLE_API -drizzle_con_st *drizzle_con_add_uds_listen(drizzle_st *drizzle, - const char *uds, int backlog, - drizzle_con_options_t options); - -/** - * Get next connection marked for listening that is ready for I/O. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @return Connection that is ready to accept, or NULL if there are none. - */ -DRIZZLE_API -drizzle_con_st *drizzle_con_ready_listen(drizzle_st *drizzle); - -/** - * Accept a new connection and initialize the connection structure for it. - * - * @param[in] drizzle Drizzle structure previously initialized with - * drizzle_create() or drizzle_clone(). - * @param[out] ret_ptr Standard drizzle return value. - * @return Same return as drizzle_con_create(). - */ -DRIZZLE_API -drizzle_con_st *drizzle_con_accept(drizzle_st *drizzle, - drizzle_return_t *ret_ptr); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/field_client.h b/utils/mysqlcl_idb/libdrizzle-2.0/field_client.h deleted file mode 100644 index c182103c9..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/field_client.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Field Declarations for Clients - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_field_client Field Declarations for Clients - * @ingroup drizzle_client_interface - * - * These functions allow you to access fields in a result set if the result is - * unbuffered. If the result is buffered, you can access the fields through the - * row functions. - * @{ - */ - -/** - * Read field for unbuffered result, possibly in parts. This is especially - * useful for blob streaming, since the client does not need to buffer the - * entire blob. - */ -DRIZZLE_API -drizzle_field_t drizzle_field_read(drizzle_result_st *result, size_t *offset, - size_t *size, size_t *total, - drizzle_return_t *ret_ptr); - -/** - * Buffer one field. - */ -DRIZZLE_API -drizzle_field_t drizzle_field_buffer(drizzle_result_st *result, size_t *total, - drizzle_return_t *ret_ptr); - -/** - * Free a buffered field. - */ -DRIZZLE_API -void drizzle_field_free(drizzle_field_t field); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/field_server.h b/utils/mysqlcl_idb/libdrizzle-2.0/field_server.h deleted file mode 100644 index 494126797..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/field_server.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Field Declarations for Servers - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_field_server Field Declarations for Servers - * @ingroup drizzle_server_interface - * - * These functions allow you to send a field over a connection. - * @{ - */ - -DRIZZLE_API -drizzle_return_t drizzle_field_write(drizzle_result_st *result, - const drizzle_field_t field, size_t size, - size_t total); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/handshake_client.h b/utils/mysqlcl_idb/libdrizzle-2.0/handshake_client.h deleted file mode 100644 index 25eac7461..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/handshake_client.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Handshake Declarations for Clients - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_handshake_client Handshake Declarations for Clients - * @ingroup drizzle_client_interface - * - * These functions are used to send and receive handshake packets for a client. - * These are only used by low-level clients when the DRIZZLE_CON_RAW_PACKET - * option is set, so most applications will never need to use these. - * @{ - */ - -/** - * Read handshake packet from the server in a client. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Standard drizzle return value. - */ -DRIZZLE_API -drizzle_return_t drizzle_handshake_server_read(drizzle_con_st *con); - -/** - * Write client handshake packet to a server. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Standard drizzle return value. - */ -DRIZZLE_API -drizzle_return_t drizzle_handshake_client_write(drizzle_con_st *con); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/handshake_server.h b/utils/mysqlcl_idb/libdrizzle-2.0/handshake_server.h deleted file mode 100644 index 715f4bb56..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/handshake_server.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Handshake Declarations for Servers - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_handshake_server Handshake Declarations for Servers - * @ingroup drizzle_server_interface - * - * These functions are used to send and receive handshake packets in a server. - * @{ - */ - -/** - * Write server handshake packet to a client. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Standard drizzle return value. - */ -DRIZZLE_API -drizzle_return_t drizzle_handshake_server_write(drizzle_con_st *con); - -/** - * Read handshake packet from the client in a server. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Standard drizzle return value. - */ -DRIZZLE_API -drizzle_return_t drizzle_handshake_client_read(drizzle_con_st *con); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/libdrizzle.h b/utils/mysqlcl_idb/libdrizzle-2.0/libdrizzle.h deleted file mode 100644 index d19a85683..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/libdrizzle.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Drizzle Client Library - * Copyright (C) 2011 Olaf van der Spek - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/libdrizzle.hpp b/utils/mysqlcl_idb/libdrizzle-2.0/libdrizzle.hpp deleted file mode 100644 index 36bd2ddf3..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/libdrizzle.hpp +++ /dev/null @@ -1,385 +0,0 @@ -/* Drizzle Client Library - * Copyright (C) 2011 Olaf van der Spek - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace drizzle { - -class bad_query : public std::runtime_error -{ -public: - bad_query(const std::string& v) : std::runtime_error(v) - { - } -}; - -class noncopyable -{ -protected: - noncopyable() - { - } -private: - noncopyable(const noncopyable&); - void operator=(const noncopyable&); -}; - -class drizzle_c : noncopyable -{ -public: - drizzle_c() - { - b_= drizzle_create(); - } - - ~drizzle_c() - { - drizzle_free(b_); - } - - operator drizzle_st*() - { - return b_; - } -private: - drizzle_st *b_; -}; - -class result_c -{ -public: - operator drizzle_result_st*() - { - if (!b_) - b_.reset(new drizzle_result_st, drizzle_result_free); - return b_.get(); - } - - const char* error() - { - return drizzle_result_error(*this); - } - - uint16_t error_code() - { - return drizzle_result_error_code(*this); - } - - uint16_t column_count() - { - return drizzle_result_column_count(*this); - } - - uint64_t row_count() - { - return drizzle_result_row_count(*this); - } - - drizzle_column_st* column_next() - { - return drizzle_column_next(*this); - } - - drizzle_row_t row_next() - { - return drizzle_row_next(*this); - } - - void column_seek(uint16_t i) - { - drizzle_column_seek(*this, i); - } - - void row_seek(uint64_t i) - { - drizzle_row_seek(*this, i); - } - - size_t* row_field_sizes() - { - return drizzle_row_field_sizes(*this); - } -private: - boost::shared_ptr b_; -}; - -class connection_c : noncopyable -{ -public: - explicit connection_c(drizzle_c& drizzle) - { - b_= drizzle_con_create(drizzle); - - if (b_ == NULL) - { - throw "drizzle_con_create() failed"; - } - read_conf_files(); - } - - ~connection_c() - { - drizzle_con_free(b_); - } - - operator drizzle_con_st*() - { - return b_; - } - - const char* error() - { - return drizzle_con_error(b_); - } - - void set_tcp(const char* host, in_port_t port) - { - drizzle_con_set_tcp(b_, host, port); - } - - void set_auth(const char* user, const char* password) - { - drizzle_con_set_auth(b_, user, password); - } - - void set_db(const char* db) - { - drizzle_con_set_db(b_, db); - } - - drizzle_return_t query(result_c& result, const char* str, size_t str_size) - { - drizzle_return_t ret; - - drizzle_query(*this, result, str, str_size, &ret); - - if (!ret) - { - ret = drizzle_result_buffer(result); - } - - return ret; - } - - drizzle_return_t query(result_c& result, const std::string& str) - { - return query(result, str.data(), str.size()); - } - - drizzle_return_t query(result_c& result, const char* str) - { - return query(result, str, strlen(str)); - } - - result_c query(const char* str, size_t str_size) - { - result_c result; - if (query(result, str, str_size)) - { - throw bad_query(error()); - } - - return result; - } - - result_c query(const std::string& str) - { - return query(str.data(), str.size()); - } - - result_c query(const char* str) - { - return query(str, strlen(str)); - } -private: - void read_conf_files(); - - drizzle_con_st *b_; -}; - -class query_c -{ -public: - query_c(connection_c& con, const std::string& in = "") : - con_(con), - in_(in) - { - } - - void operator=(const std::string& v) - { - in_ = v; - out_.clear(); - } - - void operator+=(const std::string& v) - { - in_ += v; - } - - query_c& p_name(const std::string& v) - { - std::vector r(2 * v.size() + 2); - r.resize(drizzle_escape_string(&r.front() + 1, r.size(), v.data(), v.size()) + 2); - r.front() = '`'; - r.back() = '`'; - p_raw(&r.front(), r.size()); - return *this; - } - - query_c& p_raw(const char* v, size_t sz) - { - size_t i = in_.find('?'); - assert(i != std::string::npos); - if (i == std::string::npos) - return *this; - out_.append(in_.substr(0, i)); - in_.erase(0, i + 1); - out_.append(v, sz); - return *this; - } - - query_c& p_raw(const std::string& v) - { - return p_raw(v.data(), v.size()); - } - - query_c& p(const std::string& v) - { - std::vector r(2 * v.size() + 2); - r.resize(drizzle_escape_string(&r.front() + 1, r.size(), v.data(), v.size()) + 2); - r.front() = '\''; - r.back() = '\''; - p_raw(&r.front(), r.size()); - return *this; - } - - query_c& p(long long v) - { - std::stringstream ss; - ss << v; - p_raw(ss.str()); - return *this; - } - - drizzle_return_t execute(result_c& result) - { - return con_.query(result, read()); - } - - result_c execute() - { - return con_.query(read()); - } - - std::string read() const - { - return out_ + in_; - } -private: - connection_c& con_; - std::string in_; - std::string out_; -}; - -template -const char* get_conf(const T& c, const std::string& v) -{ - typename T::const_iterator i = c.find(v); - return i == c.end() ? NULL : i->second.c_str(); -} - -void connection_c::read_conf_files() -{ - using namespace std; - - vector conf_files; -#ifdef WIN32 - { - boost::array d; - GetWindowsDirectoryA(d.data(), d.size()); - conf_files.push_back(string(d.data()) + "/my.cnf"); - conf_files.push_back(string(d.data()) + "/drizzle.cnf"); - conf_files.push_back(string(d.data()) + "/drizzle.conf"); - } -#else - conf_files.push_back("/etc/mysql/my.cnf"); - conf_files.push_back("/etc/drizzle/drizzle.cnf"); - conf_files.push_back("/etc/drizzle/drizzle.conf"); -#endif - if (const char* d = getenv("HOME")) - { - conf_files.push_back(string(d) + "/.my.cnf"); - conf_files.push_back(string(d) + "/.drizzle.conf"); - } - - map conf; - BOOST_FOREACH(string& it, conf_files) - { - ifstream is(it.c_str()); - bool client_section = false; - for (string s; getline(is, s); ) - { - size_t i = s.find('#'); - if (i != string::npos) - s.erase(i); - boost::trim(s); - if (boost::starts_with(s, "[")) - { - client_section = s == "[client]"; - continue; - } - else if (!client_section) - continue; - i = s.find('='); - if (i != string::npos) - conf[boost::trim_copy(s.substr(0, i))] = boost::trim_copy(s.substr(i + 1)); - } - } - if (conf.count("host") || conf.count("port")) - set_tcp(get_conf(conf, "host"), atoi(get_conf(conf, "port"))); - if (conf.count("user") || conf.count("password")) - set_auth(get_conf(conf, "user"), get_conf(conf, "password")); -} - -} diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/limits.h b/utils/mysqlcl_idb/libdrizzle-2.0/limits.h deleted file mode 100644 index 2cfdcd10b..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/limits.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2011 Brian Aker (brian@tangent.org) - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#define DRIZZLE_MAX_BUFFER_SIZE 32768 -#define DRIZZLE_MAX_CATALOG_SIZE 128 -#define DRIZZLE_MAX_COLUMN_NAME_SIZE 2048 -#define DRIZZLE_MAX_DB_SIZE DRIZZLE_MAX_SCHEMA_SIZE -#define DRIZZLE_MAX_DEFAULT_VALUE_SIZE 2048 -#define DRIZZLE_MAX_ERROR_SIZE 2048 -#define DRIZZLE_MAX_INFO_SIZE 2048 -#define DRIZZLE_MAX_PACKET_SIZE UINT32_MAX -#define DRIZZLE_MAX_PASSWORD_SIZE 32 -#define DRIZZLE_MAX_SCHEMA_SIZE 64 -#define DRIZZLE_MAX_SCRAMBLE_SIZE 20 -#define DRIZZLE_MAX_SERVER_EXTRA_SIZE 32 -#define DRIZZLE_MAX_SERVER_VERSION_SIZE 32 -#define DRIZZLE_MAX_SQLSTATE_SIZE 5 -#define DRIZZLE_MAX_TABLE_SIZE 128 -#define DRIZZLE_MAX_USER_SIZE 64 - diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/pack.h b/utils/mysqlcl_idb/libdrizzle-2.0/pack.h deleted file mode 100644 index 90dfe65f2..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/pack.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Packing Declarations - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_pack Packing Declarations - * - * These functions are used internally to pack various parts of the protocol. - * Not all functions are defined in pack.c, they are in the most appropriate - * source file (for example, handshake.c for drizzle_pack_client_handshake). - * @{ - */ - -/** - * Pack length-encoded number. - */ -DRIZZLE_API -uint8_t *drizzle_pack_length(uint64_t number, uint8_t *ptr); - -/** - * Unpack length-encoded number. - */ -DRIZZLE_API -uint64_t drizzle_unpack_length(drizzle_con_st *con, drizzle_return_t *ret_ptr); - -/** - * Pack length-encoded string. - */ -DRIZZLE_API -uint8_t *drizzle_pack_string(char *string, uint8_t *ptr); - -/** - * Unpack length-encoded string. - */ -DRIZZLE_API -drizzle_return_t drizzle_unpack_string(drizzle_con_st *con, char *buffer, - uint64_t max_size); - -/** - * Pack user, scramble, and db. - */ -DRIZZLE_API -uint8_t *drizzle_pack_auth(drizzle_con_st *con, uint8_t *ptr, - drizzle_return_t *ret_ptr); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/query.h b/utils/mysqlcl_idb/libdrizzle-2.0/query.h deleted file mode 100644 index 564a2b1c1..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/query.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Query Declarations - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_query Query Declarations - * - * @ingroup drizzle_client_interface - * These functions are used to issue queries on a connection. Single queries are - * made using the drizzle_query function, or you can queue multiple queries and - * run them concurrently using the other query functions. - * @{ - */ - -/** - * Send query to server. A \ref drizzle_result_st will be created for the - * results. - * - * @param[in] con connection to use to send the query. - * @param[in,out] result pointer to an unused structure that will be used for - * the results, or NULL to allocate a new structure. - * @param[in] query query string to send. - * @param[in] size length of the query string in bytes. - * @param[out] ret_ptr pointer to the result code. - * @return result, a pointer to the newly allocated result structure, or NULL - * if the allocation failed. - */ -DRIZZLE_API -drizzle_result_st *drizzle_query(drizzle_con_st *con, drizzle_result_st *result, - const char *query, size_t size, - drizzle_return_t *ret_ptr); - -/** - * Send query to server, using strlen to get the size of query buffer.. - */ -DRIZZLE_API -drizzle_result_st *drizzle_query_str(drizzle_con_st *con, - drizzle_result_st *result, - const char *query, - drizzle_return_t *ret_ptr); - -/** - * Send query incrementally. - */ -DRIZZLE_API -drizzle_result_st *drizzle_query_inc(drizzle_con_st *con, - drizzle_result_st *result, - const char *query, size_t size, - size_t total, drizzle_return_t *ret_ptr); - -/** - * Add a query to be run concurrently. - */ -DRIZZLE_API -drizzle_query_st *drizzle_query_add(drizzle_st *drizzle, - drizzle_query_st *query, - drizzle_con_st *con, - drizzle_result_st *result, - const char *query_string, size_t size, - drizzle_query_options_t options, - void *context); - -/** - * Initialize a query structure. - */ -DRIZZLE_API -drizzle_query_st *drizzle_query_create(drizzle_st *drizzle, - drizzle_query_st *query); - -/** - * Free a query structure. - */ -DRIZZLE_API -void drizzle_query_free(drizzle_query_st *query); - -/** - * Free a query structure. - */ -DRIZZLE_API -void drizzle_query_free_all(drizzle_st *drizzle); - -/** - * Get connection struct for a query. - */ -DRIZZLE_API -drizzle_con_st *drizzle_query_con(drizzle_query_st *query); - -/** - * Set connection struct for a query. - */ -DRIZZLE_API -void drizzle_query_set_con(drizzle_query_st *query, drizzle_con_st *con); - -/** - * Get result struct for a query. - */ -DRIZZLE_API -drizzle_result_st *drizzle_query_result(drizzle_query_st *query); - -/** - * Set result struct for a query. - */ -DRIZZLE_API -void drizzle_query_set_result(drizzle_query_st *query, - drizzle_result_st *result); - -/** - * Get query string for a query. - */ -DRIZZLE_API -char *drizzle_query_string(drizzle_query_st *query, size_t *size); - -/** - * Set query string for a query. - */ -DRIZZLE_API -void drizzle_query_set_string(drizzle_query_st *query, const char *string, - size_t size); - -/** - * Get options for a query. - */ -DRIZZLE_API -int drizzle_query_options(drizzle_query_st *); - -/** - * Set options for a query. - */ -DRIZZLE_API -void drizzle_query_set_options(drizzle_query_st *, int); - -/** - * Add options for a query. - */ -DRIZZLE_API -void drizzle_query_add_options(drizzle_query_st *, int); - -/** - * Remove options for a query. - */ -DRIZZLE_API -void drizzle_query_remove_options(drizzle_query_st *, int); - -/** - * Get application context for a query. - */ -DRIZZLE_API -void *drizzle_query_context(drizzle_query_st *query); - -/** - * Set application context for a query. - */ -DRIZZLE_API -void drizzle_query_set_context(drizzle_query_st *query, void *context); - -/** - * Set callback function when the context pointer should be freed. - */ -DRIZZLE_API -void drizzle_query_set_context_free_fn(drizzle_query_st *query, - drizzle_query_context_free_fn *function); - -/** - * Run queries concurrently, returning when one is complete. - */ -DRIZZLE_API -drizzle_query_st *drizzle_query_run(drizzle_st *drizzle, - drizzle_return_t *ret_ptr); - -/** - * Run queries until they are all complete. Returns \ref DRIZZLE_RETURN_OK if - * all queries complete, even if some return errors. This returns immediately - * if some other error occurs, leaving some queries unprocessed. You must call - * drizzle_result_error_code() to check if each query succeeded. - */ -DRIZZLE_API -drizzle_return_t drizzle_query_run_all(drizzle_st *drizzle); - -/* - * Escape a string or encode a string in hexadecimal. The return value is the - * size of the output string in to. - */ -DRIZZLE_API -ssize_t drizzle_escape_string(char *to, size_t max_to_size, const char *from, size_t from_size); - -DRIZZLE_API -size_t drizzle_hex_string(char *to, const char *from, size_t from_size); - -DRIZZLE_API -void drizzle_mysql_password_hash(char *to, const char *from, size_t from_size); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/result.h b/utils/mysqlcl_idb/libdrizzle-2.0/result.h deleted file mode 100644 index 5406d35bc..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/result.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Result Declarations - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_result Result Declarations - * @ingroup drizzle_client_interface - * @ingroup drizzle_server_interface - * - * These are core result functions used by both clients and servers. - * @{ - */ - -/** - * Initialize a result structure. - */ -DRIZZLE_API -drizzle_result_st *drizzle_result_create(drizzle_con_st *con); - -drizzle_result_st *drizzle_result_create_with(drizzle_con_st *con, - drizzle_result_st *result); - -/** - * Clone a connection structure. - */ -DRIZZLE_API - drizzle_result_st *drizzle_result_clone(drizzle_con_st *con, - drizzle_result_st *source); - -/** - * Free a result structure. - */ -DRIZZLE_API -void drizzle_result_free(drizzle_result_st *result); - -/** - * Free all result structures. - */ -DRIZZLE_API -void drizzle_result_free_all(drizzle_con_st *con); - -/** - * Get the drizzle_con_st struct that the result belongs to. - */ -DRIZZLE_API -drizzle_con_st *drizzle_result_drizzle_con(drizzle_result_st *result); - -/** - * Get EOF flag for a result. - */ -DRIZZLE_API -bool drizzle_result_eof(drizzle_result_st *result); - -/** - * Get information string for a result. - */ -DRIZZLE_API -const char *drizzle_result_info(drizzle_result_st *result); - -/** - * Get error string for a result. - */ -DRIZZLE_API -const char *drizzle_result_error(drizzle_result_st *result); - -/** - * Get server defined error code for a result. - */ -DRIZZLE_API -uint16_t drizzle_result_error_code(drizzle_result_st *result); - -/** - * Get SQL state code for a result. - */ -DRIZZLE_API -const char *drizzle_result_sqlstate(drizzle_result_st *result); - -/** - * Get the number of warnings encounted during a command. - */ -DRIZZLE_API -uint16_t drizzle_result_warning_count(drizzle_result_st *result); - -/** - * Get inet ID of the last command, if any. - */ -DRIZZLE_API -uint64_t drizzle_result_insert_id(drizzle_result_st *result); - -/** - * Get the number of affected rows during the command. - */ -DRIZZLE_API -uint64_t drizzle_result_affected_rows(drizzle_result_st *result); - -/** - * Get the number of columns in a result set. - */ -DRIZZLE_API -uint16_t drizzle_result_column_count(drizzle_result_st *result); - -/** - * Get the number of rows returned for the command. - */ -DRIZZLE_API -uint64_t drizzle_result_row_count(drizzle_result_st *result); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/result_client.h b/utils/mysqlcl_idb/libdrizzle-2.0/result_client.h deleted file mode 100644 index c083d8956..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/result_client.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Result Declarations for Clients - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_result_client Result Declarations for Clients - * @ingroup drizzle_client_interface - * - * These functions read or buffer the result for a client command. - * @{ - */ - -/** - * Read result packet. - */ -DRIZZLE_API -drizzle_result_st *drizzle_result_read(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr); - -/** - * Buffer all data for a result. - */ -DRIZZLE_API -drizzle_return_t drizzle_result_buffer(drizzle_result_st *result); - -/** - * Get result row packet size. - */ -DRIZZLE_API -size_t drizzle_result_row_size(drizzle_result_st *result); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/result_server.h b/utils/mysqlcl_idb/libdrizzle-2.0/result_server.h deleted file mode 100644 index 3c589fef8..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/result_server.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Result Declarations for Servers - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_result_server Result Declarations for Servers - * @ingroup drizzle_server_interface - * - * These functions allow you to send result packets over a connection. - * @{ - */ - -/** - * Write result packet. - */ -DRIZZLE_API -drizzle_return_t drizzle_result_write(drizzle_con_st *con, - drizzle_result_st *result, bool flush); - -/** - * Set result row packet size. - */ -DRIZZLE_API -void drizzle_result_set_row_size(drizzle_result_st *result, size_t size); - -/** - * Set result row packet size from field and size arrays. - */ -DRIZZLE_API -void drizzle_result_calc_row_size(drizzle_result_st *result, - const drizzle_field_t *field, - const size_t *size); - -/** - * Set information string for a result. - */ -DRIZZLE_API -void drizzle_result_set_eof(drizzle_result_st *result, bool eof); - -/** - * Set information string for a result. - */ -DRIZZLE_API -void drizzle_result_set_info(drizzle_result_st *result, const char *info); - -/** - * Set error string for a result. - */ -DRIZZLE_API -void drizzle_result_set_error(drizzle_result_st *result, const char *error); - -/** - * Set server defined error code for a result. - */ -DRIZZLE_API -void drizzle_result_set_error_code(drizzle_result_st *result, - uint16_t error_code); - -/** - * Set SQL state code for a result. - */ -DRIZZLE_API -void drizzle_result_set_sqlstate(drizzle_result_st *result, - const char *sqlstate); - -/** - * Set the number of warnings encounted during a command. - */ -DRIZZLE_API -void drizzle_result_set_warning_count(drizzle_result_st *result, - uint16_t warning_count); - -/** - * Set inet ID of the last command, if any. - */ -DRIZZLE_API -void drizzle_result_set_insert_id(drizzle_result_st *result, - uint64_t insert_id); - -/** - * Set the number of affected rows during the command. - */ -DRIZZLE_API -void drizzle_result_set_affected_rows(drizzle_result_st *result, - uint64_t affected_rows); - -/** - * Set the number of fields in a result set. - */ -DRIZZLE_API -void drizzle_result_set_column_count(drizzle_result_st *result, - uint16_t column_count); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/return.h b/utils/mysqlcl_idb/libdrizzle-2.0/return.h deleted file mode 100644 index ab1d4f275..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/return.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2011 Brian Aker (brian@tangent.org) - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * Return codes. - */ -enum drizzle_return_t -{ - DRIZZLE_RETURN_OK, - DRIZZLE_RETURN_IO_WAIT, - DRIZZLE_RETURN_PAUSE, - DRIZZLE_RETURN_ROW_BREAK, - DRIZZLE_RETURN_MEMORY, - DRIZZLE_RETURN_ERRNO, - DRIZZLE_RETURN_INTERNAL_ERROR, - DRIZZLE_RETURN_GETADDRINFO, - DRIZZLE_RETURN_NOT_READY, - DRIZZLE_RETURN_BAD_PACKET_NUMBER, - DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET, - DRIZZLE_RETURN_BAD_PACKET, - DRIZZLE_RETURN_PROTOCOL_NOT_SUPPORTED, - DRIZZLE_RETURN_UNEXPECTED_DATA, - DRIZZLE_RETURN_NO_SCRAMBLE, - DRIZZLE_RETURN_AUTH_FAILED, - DRIZZLE_RETURN_NULL_SIZE, - DRIZZLE_RETURN_ERROR_CODE, - DRIZZLE_RETURN_TOO_MANY_COLUMNS, - DRIZZLE_RETURN_ROW_END, - DRIZZLE_RETURN_LOST_CONNECTION, - DRIZZLE_RETURN_COULD_NOT_CONNECT, - DRIZZLE_RETURN_NO_ACTIVE_CONNECTIONS, - DRIZZLE_RETURN_HANDSHAKE_FAILED, - DRIZZLE_RETURN_TIMEOUT, - DRIZZLE_RETURN_INVALID_ARGUMENT, - DRIZZLE_RETURN_MAX /* Always add new codes to the end before this one. */ -}; - -#ifndef __cplusplus -typedef enum drizzle_return_t drizzle_return_t -#endif - - diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/row_client.h b/utils/mysqlcl_idb/libdrizzle-2.0/row_client.h deleted file mode 100644 index 9a5af8f97..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/row_client.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Row Declarations for Clients - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_row_client Row Declarations for Clients - * @ingroup drizzle_client_interface - * - * These functions allow you to access rows in a result set. If the result is - * unbuffered, you can read and buffer rows one at a time. If the rows are - * buffered in the result, the drizzle_row_next() and related functions can be - * used. - * @{ - */ - -/** - * Get next row number for unbuffered results. Use the drizzle_field* functions - * to read individual fields after this function succeeds. - * - * @param[in,out] result pointer to the structure to read from. - * @param[out] ret_ptr Standard libdrizzle return value. May be set to - * DRIZZLE_RESULT_ERROR_CODE if the server return an error, such as a - * deadlock. - * @return the row id if there is a valid row, or 0 if there are no more rows or an error. - */ -DRIZZLE_API -uint64_t drizzle_row_read(drizzle_result_st *result, drizzle_return_t *ret_ptr); - -/** - * Read and buffer one row. The returned row must be freed by the caller with - * drizzle_row_free(). - * - * @param[in,out] result pointer to the result structure to read from. - * @param[out] ret_pointer Standard drizzle return value. - * @return the row that was read, or NULL if there are no more rows. - */ -DRIZZLE_API -drizzle_row_t drizzle_row_buffer(drizzle_result_st *result, - drizzle_return_t *ret_ptr); - -/** - * Free a row that was buffered with drizzle_row_buffer(). - */ -DRIZZLE_API -void drizzle_row_free(drizzle_result_st *result, drizzle_row_t row); - -/** - * Get an array of all field sizes for buffered rows. - */ -DRIZZLE_API -size_t *drizzle_row_field_sizes(drizzle_result_st *result); - -/** - * Get next buffered row from a fully buffered result. - */ -DRIZZLE_API -drizzle_row_t drizzle_row_next(drizzle_result_st *result); - -/** - * Get previous buffered row from a fully buffered result. - */ -DRIZZLE_API -drizzle_row_t drizzle_row_prev(drizzle_result_st *result); - -/** - * Seek to the given buffered row in a fully buffered result. - */ -DRIZZLE_API -void drizzle_row_seek(drizzle_result_st *result, uint64_t row); - -/** - * Get the given buffered row from a fully buffered result. - */ -DRIZZLE_API -drizzle_row_t drizzle_row_index(drizzle_result_st *result, uint64_t row); - -/** - * Get current row number. - */ -DRIZZLE_API -uint64_t drizzle_row_current(drizzle_result_st *result); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/row_server.h b/utils/mysqlcl_idb/libdrizzle-2.0/row_server.h deleted file mode 100644 index 50d3da84c..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/row_server.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Row Declarations for Servers - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_row_server Row Declarations for Servers - * @ingroup drizzle_server_interface - * - * These functions allow you to send row information over a connection. - * @{ - */ - -/** - * Write next row. - */ -DRIZZLE_API -drizzle_return_t drizzle_row_write(drizzle_result_st *result); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/sha1.h b/utils/mysqlcl_idb/libdrizzle-2.0/sha1.h deleted file mode 100644 index 324c9c570..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/sha1.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -/** - * @file - * @brief SHA1 Declarations - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup sha1 SHA-1 in C - * - * Copyright (C) 2010 nobody (this is public domain) - * - * This file is based on public domain code. - * Initial source code is in the public domain, - * so clarified by Steve Reid - * - * @{ - */ - -#define SHA1_BLOCK_LENGTH 64 -#define SHA1_DIGEST_LENGTH 20 -#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1) - -typedef struct { - uint32_t state[5]; - uint64_t count; - uint8_t buffer[SHA1_BLOCK_LENGTH]; -} SHA1_CTX; - -void SHA1Init(SHA1_CTX *); -void SHA1Pad(SHA1_CTX *); -void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH]); -void SHA1Update(SHA1_CTX *, const uint8_t *, size_t); -void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/state.h b/utils/mysqlcl_idb/libdrizzle-2.0/state.h deleted file mode 100644 index e38315a0c..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/state.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief State Machine Declarations - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup drizzle_state State Machine Declarations - * - * These functions are used in the protocol parsing state machine. Not all - * functions are defined in state.c, they are in the most appropriate source - * file (for example, handshake.c for drizzle_state_handshake_server_read). - * @{ - */ - -/** - * Main state loop for connections. - * - * @param[in] con Connection structure previously initialized with - * drizzle_con_create(), drizzle_con_clone(), or related functions. - * @return Standard drizzle return value. - */ -drizzle_return_t drizzle_state_loop(drizzle_con_st *con); - -/* Functions in state.c */ -drizzle_return_t drizzle_state_packet_read(drizzle_con_st *con); - -/* Functions in conn.c */ -drizzle_return_t drizzle_state_addrinfo(drizzle_con_st *con); -drizzle_return_t drizzle_state_connect(drizzle_con_st *con); -drizzle_return_t drizzle_state_connecting(drizzle_con_st *con); -drizzle_return_t drizzle_state_read(drizzle_con_st *con); -drizzle_return_t drizzle_state_write(drizzle_con_st *con); -drizzle_return_t drizzle_state_listen(drizzle_con_st *con); - -/* Functions in handshake.c */ -drizzle_return_t drizzle_state_handshake_server_read(drizzle_con_st *con); -drizzle_return_t drizzle_state_handshake_server_write(drizzle_con_st *con); -drizzle_return_t drizzle_state_handshake_client_read(drizzle_con_st *con); -drizzle_return_t drizzle_state_handshake_client_write(drizzle_con_st *con); -drizzle_return_t drizzle_state_handshake_result_read(drizzle_con_st *con); - -/* Functions in command.c */ -drizzle_return_t drizzle_state_command_read(drizzle_con_st *con); -drizzle_return_t drizzle_state_command_write(drizzle_con_st *con); - -/* Functions in result.c */ -drizzle_return_t drizzle_state_result_read(drizzle_con_st *con); -drizzle_return_t drizzle_state_result_write(drizzle_con_st *con); - -/* Functions in column.c */ -drizzle_return_t drizzle_state_column_read(drizzle_con_st *con); -drizzle_return_t drizzle_state_column_write(drizzle_con_st *con); - -/* Functions in row.c */ -drizzle_return_t drizzle_state_row_read(drizzle_con_st *con); -drizzle_return_t drizzle_state_row_write(drizzle_con_st *con); - -/* Functions in field.c */ -drizzle_return_t drizzle_state_field_read(drizzle_con_st *con); -drizzle_return_t drizzle_state_field_write(drizzle_con_st *con); - -/** @} */ - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/structs.h b/utils/mysqlcl_idb/libdrizzle-2.0/structs.h deleted file mode 100644 index ba7b7767b..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/structs.h +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -/** - * @file - * @brief Struct Definitions - */ - -#include - -#ifndef NI_MAXHOST -# define NI_MAXHOST 1025 -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __cplusplus -struct drizzle_st; -struct drizzle_con_tcp_st; -struct drizzle_con_uds_st; -struct drizzle_con_st; -struct drizzle_query_st; -struct drizzle_result_st; -struct drizzle_column_st; -#else - - -/** - * @ingroup drizzle - */ -class drizzle_st -{ -public: - uint16_t error_code; - struct options_t { - bool is_allocated; - bool is_non_blocking; - bool is_free_objects; - bool is_assert_dangling; - - options_t() : - is_allocated(false), - is_non_blocking(false), - is_free_objects(false), - is_assert_dangling(false) - { } - } options; - drizzle_verbose_t verbose; - uint32_t con_count; - uint32_t pfds_size; - uint32_t query_count; - uint32_t query_new; - uint32_t query_running; - int last_errno; - int timeout; - drizzle_con_st *con_list; - void *context; - drizzle_context_free_fn *context_free_fn; - drizzle_event_watch_fn *event_watch_fn; - void *event_watch_context; - drizzle_log_fn *log_fn; - void *log_context; - struct pollfd *pfds; - drizzle_query_st *query_list; - char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1]; - char last_error[DRIZZLE_MAX_ERROR_SIZE]; - - drizzle_st() : - error_code(0), - options(), - verbose(DRIZZLE_VERBOSE_ERROR), - con_count(0), - pfds_size(0), - query_count(0), - query_new(0), - query_running(0), - last_errno(0), - timeout(-1), - con_list(NULL), - context(NULL), - context_free_fn(NULL), - event_watch_fn(NULL), - event_watch_context(NULL), - log_fn(NULL), - log_context(NULL), - pfds(NULL), - query_list(NULL) - { } -}; - -/** - * @ingroup drizzle_con - */ -class drizzle_con_tcp_st -{ -public: - in_port_t port; - struct addrinfo *addrinfo; - char *host; - char host_buffer[NI_MAXHOST]; -}; - -/** - * @ingroup drizzle_con - */ -class drizzle_con_uds_st -{ -public: - struct addrinfo addrinfo; - struct sockaddr_un sockaddr; -}; - -/** - * @ingroup drizzle_con - */ -class drizzle_con_st -{ -public: - uint8_t packet_number; - uint8_t protocol_version; - uint8_t state_current; - short events; - short revents; - int capabilities; - drizzle_charset_t charset; - drizzle_command_t command; - struct option_t { - bool is_allocated; - - option_t() : - is_allocated(false) - { } - } _options; - int options; - drizzle_con_socket_t socket_type; - drizzle_con_status_t status; - uint32_t max_packet_size; - uint32_t result_count; - uint32_t thread_id; - int backlog; - int fd; - size_t buffer_size; - size_t command_offset; - size_t command_size; - size_t command_total; - size_t packet_size; - struct addrinfo *addrinfo_next; - uint8_t *buffer_ptr; - uint8_t *command_buffer; - uint8_t *command_data; - void *context; - drizzle_con_context_free_fn *context_free_fn; - drizzle_st *drizzle; - drizzle_con_st *next; - drizzle_con_st *prev; - drizzle_query_st *query; - drizzle_result_st *result; - drizzle_result_st *result_list; - uint8_t *scramble; - union - { - drizzle_con_tcp_st tcp; - drizzle_con_uds_st uds; - } socket; - uint8_t buffer[DRIZZLE_MAX_BUFFER_SIZE]; - char schema[DRIZZLE_MAX_DB_SIZE]; - char password[DRIZZLE_MAX_PASSWORD_SIZE]; - uint8_t scramble_buffer[DRIZZLE_MAX_SCRAMBLE_SIZE]; - char server_version[DRIZZLE_MAX_SERVER_VERSION_SIZE]; - char server_extra[DRIZZLE_MAX_SERVER_EXTRA_SIZE]; - drizzle_state_fn *state_stack[DRIZZLE_STATE_STACK_SIZE]; - char user[DRIZZLE_MAX_USER_SIZE]; - - drizzle_con_st() : - packet_number(0), - protocol_version(0), - state_current(0), - events(0), - revents(0), - capabilities(DRIZZLE_CAPABILITIES_NONE), - options(DRIZZLE_CON_NONE), - max_packet_size(0), - result_count(0), - thread_id(0), - backlog(0), - fd(0), - buffer_size(0), - command_offset(0), - command_size(0), - command_total(0), - packet_size(0), - addrinfo_next(NULL), - buffer_ptr(NULL), - command_buffer(NULL), - command_data(NULL), - context(NULL), - context_free_fn(NULL), - drizzle(NULL), - next(NULL), - prev(NULL), - query(NULL), - result(NULL), - result_list(NULL), - scramble(NULL) - { } -}; - -/** - * @ingroup drizzle_query - */ -class drizzle_query_st -{ -private: -public: - drizzle_st *drizzle; - drizzle_query_st *next; - drizzle_query_st *prev; - struct option_t { - bool is_allocated; - - option_t() : - is_allocated(false) - { } - } options; - drizzle_query_state_t state; - drizzle_con_st *con; - drizzle_result_st *result; - const char *string; - size_t size; - void *context; - drizzle_query_context_free_fn *context_free_fn; - - drizzle_query_st() : - drizzle(NULL), - next(NULL), - prev(NULL), - con(NULL), - result(NULL), - string(NULL), - size(0), - context(NULL), - context_free_fn(NULL) - { } -}; - -/** - * @ingroup drizzle_result - */ -class drizzle_result_st -{ -public: - drizzle_con_st *con; - drizzle_result_st *next; - drizzle_result_st *prev; - struct option_t { - bool is_allocated; - - option_t() : - is_allocated(false) - { } - } _options; - int options; - - char info[DRIZZLE_MAX_INFO_SIZE]; - uint16_t error_code; - char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1]; - uint64_t insert_id; - uint16_t warning_count; - uint64_t affected_rows; - - uint16_t column_count; - uint16_t column_current; - drizzle_column_st *column_list; - drizzle_column_st *column; - drizzle_column_st *column_buffer; - - uint64_t row_count; - uint64_t row_current; - - uint16_t field_current; - size_t field_total; - size_t field_offset; - size_t field_size; - drizzle_field_t field; - drizzle_field_t field_buffer; - - uint64_t row_list_size; - drizzle_row_t row; - drizzle_row_list_t *row_list; - size_t *field_sizes; - drizzle_field_sizes_list_t *field_sizes_list; - - drizzle_result_st() : - con(NULL), - next(NULL), - prev(NULL), - options(DRIZZLE_RESULT_NONE), - error_code(0), - insert_id(0), - warning_count(0), - affected_rows(0), - column_count(0), - column_current(0), - column_list(NULL), - column(NULL), - column_buffer(NULL), - row_count(0), - row_current(0), - field_current(0), - field_total(0), - field_offset(0), - field_size(0), - row_list_size(0), - row_list(NULL), - field_sizes(NULL), - field_sizes_list(NULL) - { } -}; - -/** - * @ingroup drizzle_column - */ -class drizzle_column_st -{ -public: - drizzle_result_st *result; - drizzle_column_st *next; - drizzle_column_st *prev; - struct options_t { - bool is_allocated; - - options_t() : - is_allocated(false) - { } - } options; - char catalog[DRIZZLE_MAX_CATALOG_SIZE]; - char schema[DRIZZLE_MAX_DB_SIZE]; - char table[DRIZZLE_MAX_TABLE_SIZE]; - char orig_table[DRIZZLE_MAX_TABLE_SIZE]; - char name[DRIZZLE_MAX_COLUMN_NAME_SIZE]; - char orig_name[DRIZZLE_MAX_COLUMN_NAME_SIZE]; - drizzle_charset_t charset; - uint32_t size; - size_t max_size; - drizzle_column_type_t type; - int flags; - uint8_t decimals; - uint8_t default_value[DRIZZLE_MAX_DEFAULT_VALUE_SIZE]; - size_t default_value_size; - - drizzle_column_st() : - result(NULL), - next(NULL), - prev(NULL), - size(0), - max_size(0), - flags(DRIZZLE_COLUMN_FLAGS_NONE), - decimals(0), - default_value_size(0) - { } -}; -#endif - -#ifdef __cplusplus -} -#endif diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/verbose.h b/utils/mysqlcl_idb/libdrizzle-2.0/verbose.h deleted file mode 100644 index 5829a058c..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/verbose.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2011 Brian Aker (brian@tangent.org) - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - - -/** - * Verbosity levels. - */ -enum drizzle_verbose_t -{ - DRIZZLE_VERBOSE_NEVER, - DRIZZLE_VERBOSE_FATAL, - DRIZZLE_VERBOSE_ERROR, - DRIZZLE_VERBOSE_INFO, - DRIZZLE_VERBOSE_DEBUG, - DRIZZLE_VERBOSE_CRAZY, - DRIZZLE_VERBOSE_MAX -}; - -#ifndef __cplusplus -typedef enum drizzle_verbose_t drizzle_verbose_t; -#endif - diff --git a/utils/mysqlcl_idb/libdrizzle-2.0/visibility.h b/utils/mysqlcl_idb/libdrizzle-2.0/visibility.h deleted file mode 100644 index 493ac2266..000000000 --- a/utils/mysqlcl_idb/libdrizzle-2.0/visibility.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * Implementation drawn from visibility.texi in gnulib. - */ - -#pragma once - -/** - * @file - * @brief Visibility Control Macros - */ - -/** - * - * DRIZZLE_API is used for the public API symbols. It either DLL imports or - * DLL exports (or does nothing for static build). - * - * DRIZZLE_LOCAL is used for non-api symbols. - */ - -#if defined(_WIN32) -# define DRIZZLE_API -# define DRIZZLE_LOCAL -#else -#if defined(BUILDING_LIBDRIZZLE) -# if defined(HAVE_VISIBILITY) -# define DRIZZLE_API __attribute__ ((visibility("default"))) -# define DRIZZLE_LOCAL __attribute__ ((visibility("hidden"))) -# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) -# define DRIZZLE_API __global -# define DRIZZLE_API __hidden -# elif defined(_MSC_VER) -# define DRIZZLE_API extern __declspec(dllexport) -# define DRIZZLE_LOCAL -# endif /* defined(HAVE_VISIBILITY) */ -#else /* defined(BUILDING_LIBDRIZZLE) */ -# if defined(_MSC_VER) -# define DRIZZLE_API extern __declspec(dllimport) -# define DRIZZLE_LOCAL -# else -# define DRIZZLE_API -# define DRIZZLE_LOCAL -# endif /* defined(_MSC_VER) */ -#endif /* defined(BUILDING_LIBDRIZZLE) */ -#endif /* _WIN32 */ diff --git a/utils/mysqlcl_idb/libmysqlcl_idb.vcxproj b/utils/mysqlcl_idb/libmysqlcl_idb.vcxproj deleted file mode 100644 index 451e94c02..000000000 --- a/utils/mysqlcl_idb/libmysqlcl_idb.vcxproj +++ /dev/null @@ -1,235 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - EnterpriseRelease - Win32 - - - EnterpriseRelease - x64 - - - Release - Win32 - - - Release - x64 - - - - {0BBAEACB-3336-4406-ACFB-255669A3B9CF} - libmysqlcl_idb - - - - StaticLibrary - v110 - - - StaticLibrary - v110 - MultiByte - true - - - StaticLibrary - v110 - MultiByte - - - StaticLibrary - v110 - - - StaticLibrary - v110 - MultiByte - true - - - StaticLibrary - v110 - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>11.0.50727.1 - - - $(SolutionDir)..\..\$(PlatformName)\$(ConfigurationName)\ - $(SolutionDir)..\..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)\ - - - $(SolutionDir)..\..\$(Platform)\$(Configuration)\ - $(SolutionDir)..\..\obj\$(ProjectName)\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\$(PlatformName)\$(ConfigurationName)\ - $(SolutionDir)..\..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)\ - - - $(SolutionDir)..\..\$(Platform)\$(Configuration)\ - $(SolutionDir)..\..\obj\$(ProjectName)\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\$(PlatformName)\$(ConfigurationName)\ - $(SolutionDir)..\..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)\ - - - $(SolutionDir)..\..\$(Platform)\$(Configuration)\ - $(SolutionDir)..\..\obj\$(ProjectName)\$(Platform)\$(Configuration)\ - - - - Disabled - $(SolutionDir)..\utils\mysqlcl_idb;$(SolutionDir)..\utils\configcpp;$(SolutionDir)..\utils\winport;$(SolutionDir)..\..\boost_1_54_0;%(AdditionalIncludeDirectories) - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - EditAndContinue - - - - - X64 - - - Disabled - $(SolutionDir)..\utils\mysqlcl_idb;$(SolutionDir)..\utils\configcpp;$(SolutionDir)..\utils\winport;$(SolutionDir)..\..\boost_1_54_0;%(AdditionalIncludeDirectories) - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - ProgramDatabase - - - - - MaxSpeed - true - $(SolutionDir)..\utils\mysqlcl_idb;$(SolutionDir)..\utils\configcpp;$(SolutionDir)..\utils\winport;$(SolutionDir)..\..\boost_1_54_0;%(AdditionalIncludeDirectories) - MultiThreadedDLL - true - Level3 - ProgramDatabase - - - - - X64 - - - MaxSpeed - true - $(SolutionDir)..\utils\mysqlcl_idb;$(SolutionDir)..\utils\configcpp;$(SolutionDir)..\utils\winport;$(SolutionDir)..\..\boost_1_54_0;%(AdditionalIncludeDirectories) - MultiThreadedDLL - true - Level3 - ProgramDatabase - - - - - $(SolutionDir)..\utils\mysqlcl_idb;$(SolutionDir)..\utils\configcpp;$(SolutionDir)..\utils\winport;$(SolutionDir)..\..\boost_1_54_0;%(AdditionalIncludeDirectories) - MultiThreadedDLL - true - - - - - $(SolutionDir)..\utils\mysqlcl_idb;$(SolutionDir)..\utils\configcpp;$(SolutionDir)..\utils\winport;$(SolutionDir)..\..\boost_1_54_0;%(AdditionalIncludeDirectories) - MultiThreadedDLL - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/utils/mysqlcl_idb/libmysqlcl_idb.vcxproj.filters b/utils/mysqlcl_idb/libmysqlcl_idb.vcxproj.filters deleted file mode 100644 index e22e260ef..000000000 --- a/utils/mysqlcl_idb/libmysqlcl_idb.vcxproj.filters +++ /dev/null @@ -1,171 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/utils/mysqlcl_idb/mysqlcl_idb.vpj b/utils/mysqlcl_idb/mysqlcl_idb.vpj deleted file mode 100644 index e0db68404..000000000 --- a/utils/mysqlcl_idb/mysqlcl_idb.vpj +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/utils/mysqlcl_idb/pack.cc b/utils/mysqlcl_idb/pack.cc deleted file mode 100644 index 2f56c9b1b..000000000 --- a/utils/mysqlcl_idb/pack.cc +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @file - * @brief Packing definitions - */ - -#include - -/* - * Private declarations - */ - -/** - * @addtogroup drizzle_pack_private Private Packing Functions - * @ingroup drizzle_pack - * @{ - */ - -/** - * Compute hash from password and scramble. - */ -static drizzle_return_t _pack_scramble_hash(drizzle_con_st *con, - uint8_t *buffer); - -/** @} */ - -/* - * Public definitions - */ - -uint8_t *drizzle_pack_length(uint64_t number, uint8_t *ptr) -{ - if (number < 251) - { - ptr[0]= (uint8_t)number; - ptr++; - } - else if (number < 65536) - { - ptr[0]= 252; - ptr++; - drizzle_set_byte2(ptr, number); - ptr+= 2; - } - else if (number < 16777216) - { - ptr[0]= 253; - ptr++; - drizzle_set_byte3(ptr, number); - ptr+= 3; - } - else - { - ptr[0]= 254; - ptr++; - drizzle_set_byte8(ptr, number); - ptr+= 8; - } - - return ptr; -} - -uint64_t drizzle_unpack_length(drizzle_con_st *con, drizzle_return_t *ret_ptr) -{ - uint64_t length; - uint8_t bytes; - - if (con->buffer_ptr[0] < 251) - { - length= (uint64_t)(con->buffer_ptr[0]); - bytes= 1; - } - else if (con->buffer_ptr[0] == 251) - { - con->buffer_ptr++; - con->buffer_size--; - con->packet_size--; - - *ret_ptr= DRIZZLE_RETURN_NULL_SIZE; - return 0; - } - else if (con->buffer_ptr[0] == 252 && con->buffer_size > 2) - { - length= drizzle_get_byte2(con->buffer_ptr + 1); - bytes= 3; - } - else if (con->buffer_ptr[0] == 253 && con->buffer_size > 3) - { - length= drizzle_get_byte3(con->buffer_ptr + 1); - bytes= 4; - } - else if (con->buffer_size > 8) - { - length= drizzle_get_byte8(con->buffer_ptr + 1); - bytes= 9; - } - else - { - *ret_ptr= DRIZZLE_RETURN_IO_WAIT; - return 0; - } - - con->buffer_ptr+= bytes; - con->buffer_size-= bytes; - con->packet_size-= bytes; - - *ret_ptr= DRIZZLE_RETURN_OK; - return length; -} - -uint8_t *drizzle_pack_string(char *string, uint8_t *ptr) -{ - if (string == NULL) - { - return NULL; - } - - uint64_t size= strlen(string); - - ptr= drizzle_pack_length(size, ptr); - if (size > 0) - { - memcpy(ptr, string, (size_t)size); - ptr+= size; - } - - return ptr; -} - -drizzle_return_t drizzle_unpack_string(drizzle_con_st *con, char *buffer, - uint64_t max_length) -{ - drizzle_return_t ret= DRIZZLE_RETURN_OK; - uint64_t length; - - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - length= drizzle_unpack_length(con, &ret); - if (ret != DRIZZLE_RETURN_OK) - { - if (ret == DRIZZLE_RETURN_NULL_SIZE) - { - drizzle_set_error(con->drizzle, "drizzle_unpack_string", - "unexpected NULL length"); - } - - return ret; - } - - if (length < max_length) - { - if (length > 0) - { - memcpy(buffer, con->buffer_ptr, (size_t)length); - } - - buffer[length]= 0; - } - else - { - memcpy(buffer, con->buffer_ptr, (size_t)(max_length - 1)); - buffer[max_length - 1]= 0; - } - - con->buffer_ptr+= length; - con->buffer_size-= (size_t)length; - con->packet_size-= (size_t)length; - - return DRIZZLE_RETURN_OK; -} - -uint8_t *drizzle_pack_auth(drizzle_con_st *con, uint8_t *ptr, drizzle_return_t *ret_ptr) -{ - if (con == NULL) - { - return NULL; - } - - drizzle_return_t unused; - if (ret_ptr == NULL) - { - ret_ptr= &unused; - } - - if (con->user[0] != 0) - { - memcpy(ptr, con->user, strlen(con->user)); - ptr+= strlen(con->user); - } - - ptr[0]= 0; - ptr++; - - if (con->options & DRIZZLE_CON_RAW_SCRAMBLE && con->scramble != NULL) - { - ptr[0]= DRIZZLE_MAX_SCRAMBLE_SIZE; - ptr++; - - memcpy(ptr, con->scramble, DRIZZLE_MAX_SCRAMBLE_SIZE); - ptr+= DRIZZLE_MAX_SCRAMBLE_SIZE; - } - else if (con->password[0] == 0) - { - ptr[0]= 0; - ptr++; - con->packet_size-= DRIZZLE_MAX_SCRAMBLE_SIZE; - } - else - { - ptr[0]= DRIZZLE_MAX_SCRAMBLE_SIZE; - ptr++; - - if (con->options & DRIZZLE_CON_MYSQL && con->options & DRIZZLE_CON_AUTH_PLUGIN) - { - snprintf((char *)ptr, DRIZZLE_MAX_SCRAMBLE_SIZE, "%s", con->password); - ptr[DRIZZLE_MAX_SCRAMBLE_SIZE-1]= 0; - } - else if (con->options & DRIZZLE_CON_MYSQL) - { - *ret_ptr= _pack_scramble_hash(con, ptr); - if (*ret_ptr != DRIZZLE_RETURN_OK) - { - return ptr; - } - } - else // We assume Drizzle - { - snprintf((char *)ptr, DRIZZLE_MAX_SCRAMBLE_SIZE, "%s", con->password); - ptr[DRIZZLE_MAX_SCRAMBLE_SIZE-1]= 0; - } - - ptr+= DRIZZLE_MAX_SCRAMBLE_SIZE; - } - - if (con->schema[0] != 0) - { - memcpy(ptr, con->schema, strlen(con->schema)); - ptr+= strlen(con->schema); - } - - ptr[0]= 0; - ptr++; - - *ret_ptr= DRIZZLE_RETURN_OK; - - return ptr; -} - -/* - * Private definitions - */ - -static drizzle_return_t _pack_scramble_hash(drizzle_con_st *con, - uint8_t *buffer) -{ - SHA1_CTX ctx; - uint8_t hash_tmp1[SHA1_DIGEST_LENGTH]; - uint8_t hash_tmp2[SHA1_DIGEST_LENGTH]; - - if (SHA1_DIGEST_LENGTH != DRIZZLE_MAX_SCRAMBLE_SIZE) - { - drizzle_set_error(con->drizzle, "_pack_scramble_hash", - "SHA1 hash size mismatch:%u:%u", SHA1_DIGEST_LENGTH, - DRIZZLE_MAX_SCRAMBLE_SIZE); - return DRIZZLE_RETURN_INTERNAL_ERROR; - } - - if (con->scramble == NULL) - { - drizzle_set_error(con->drizzle, "_pack_scramble_hash", - "no scramble buffer"); - return DRIZZLE_RETURN_NO_SCRAMBLE; - } - - /* First hash the password. */ - SHA1Init(&ctx); - SHA1Update(&ctx, (uint8_t *)(con->password), strlen(con->password)); - SHA1Final(hash_tmp1, &ctx); - - /* Second, hash the password hash. */ - SHA1Init(&ctx); - SHA1Update(&ctx, hash_tmp1, SHA1_DIGEST_LENGTH); - SHA1Final(hash_tmp2, &ctx); - - /* Third, hash the scramble and the double password hash. */ - SHA1Init(&ctx); - SHA1Update(&ctx, con->scramble, SHA1_DIGEST_LENGTH); - SHA1Update(&ctx, hash_tmp2, SHA1_DIGEST_LENGTH); - SHA1Final(buffer, &ctx); - - /* Fourth, xor the last hash against the first password hash. */ - for (uint32_t x= 0; x < SHA1_DIGEST_LENGTH; x++) - { - buffer[x]= buffer[x] ^ hash_tmp1[x]; - } - - return DRIZZLE_RETURN_OK; -} diff --git a/utils/mysqlcl_idb/query.cc b/utils/mysqlcl_idb/query.cc deleted file mode 100644 index 3c50ff877..000000000 --- a/utils/mysqlcl_idb/query.cc +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @file - * @brief Query definitions - */ - -#include - -drizzle_result_st *drizzle_query(drizzle_con_st *con, drizzle_result_st *result, - const char *query, size_t size, - drizzle_return_t *ret_ptr) -{ - return drizzle_con_command_write(con, result, DRIZZLE_COMMAND_QUERY, - (uint8_t *)query, size, size, ret_ptr); -} - -drizzle_result_st *drizzle_query_str(drizzle_con_st *con, - drizzle_result_st *result, - const char *query, - drizzle_return_t *ret_ptr) -{ - size_t size= strlen(query); - - return drizzle_con_command_write(con, result, DRIZZLE_COMMAND_QUERY, (uint8_t *)query, size, size, ret_ptr); -} - -drizzle_result_st *drizzle_query_inc(drizzle_con_st *con, - drizzle_result_st *result, - const char *query, size_t size, - size_t total, drizzle_return_t *ret_ptr) -{ - return drizzle_con_command_write(con, result, DRIZZLE_COMMAND_QUERY, (uint8_t *)query, size, total, ret_ptr); -} - -drizzle_query_st *drizzle_query_add(drizzle_st *drizzle, - drizzle_query_st *query, - drizzle_con_st *con, - drizzle_result_st *result, - const char *query_string, size_t size, - drizzle_query_options_t, - void *context) -{ - // @note drizzle_query_st handle the null drizzle case - query= drizzle_query_create(drizzle, query); - if (query == NULL) - { - return NULL; - } - - drizzle_query_set_con(query, con); - drizzle_query_set_result(query, result); - drizzle_query_set_string(query, query_string, size); - drizzle_query_set_context(query, context); - - return query; -} - -drizzle_query_st *drizzle_query_create(drizzle_st *drizzle, drizzle_query_st *query) -{ - if (drizzle == NULL) - { - return NULL; - } - - if (query == NULL) - { - query= new (std::nothrow) drizzle_query_st; - - if (query == NULL) - { - return NULL; - } - query->options.is_allocated= true; - } - else - { - query->prev= NULL; - query->state= DRIZZLE_QUERY_STATE_INIT; - query->con= NULL; - query->result= NULL; - query->string= NULL; - query->size= 0; - query->context= NULL; - query->context_free_fn= NULL; - query->options.is_allocated= false; - } - - query->drizzle= drizzle; - - if (drizzle->query_list) - { - drizzle->query_list->prev= query; - } - query->next= drizzle->query_list; - drizzle->query_list= query; - drizzle->query_count++; - drizzle->query_new++; - - return query; -} - -void drizzle_query_free(drizzle_query_st *query) -{ - if (query == NULL) - { - return; - } - - if (query->context != NULL && query->context_free_fn != NULL) - { - query->context_free_fn(query, query->context); - } - - if (query->drizzle->query_list == query) - { - query->drizzle->query_list= query->next; - } - - if (query->prev) - { - query->prev->next= query->next; - } - - if (query->next) - { - query->next->prev= query->prev; - } - - query->drizzle->query_count--; - - if (query->options.is_allocated) - { - delete query; - } -} - -void drizzle_query_free_all(drizzle_st *drizzle) -{ - while (drizzle->query_list != NULL) - { - drizzle_query_free(drizzle->query_list); - } -} - -drizzle_con_st *drizzle_query_con(drizzle_query_st *query) -{ - if (query == NULL) - { - return NULL; - } - - return query->con; -} - -void drizzle_query_set_con(drizzle_query_st *query, drizzle_con_st *con) -{ - if (query == NULL) - { - return; - } - - query->con= con; -} - -drizzle_result_st *drizzle_query_result(drizzle_query_st *query) -{ - if (query == NULL) - { - return NULL; - } - - return query->result; -} - -void drizzle_query_set_result(drizzle_query_st *query, - drizzle_result_st *result) -{ - if (query == NULL) - { - return; - } - - query->result= result; -} - -char *drizzle_query_string(drizzle_query_st *query, size_t *size) -{ - if (query == NULL) - { - return NULL; - } - - *size= query->size; - return (char *)(query->string); -} - -void drizzle_query_set_string(drizzle_query_st *query, const char *string, - size_t size) -{ - if (query == NULL) - { - return; - } - - query->string= string; - query->size= size; -} - -int drizzle_query_options(drizzle_query_st *) -{ - return 0; -} - -void drizzle_query_set_options(drizzle_query_st *, int) -{ -} - -void drizzle_query_add_options(drizzle_query_st *, int) -{ -} - -void drizzle_query_remove_options(drizzle_query_st *, int) -{ -} - -void *drizzle_query_context(drizzle_query_st *query) -{ - if (query == NULL) - { - return NULL; - } - - return query->context; -} - -void drizzle_query_set_context(drizzle_query_st *query, void *context) -{ - if (query == NULL) - { - return; - } - - query->context= context; -} - -void drizzle_query_set_context_free_fn(drizzle_query_st *query, - drizzle_query_context_free_fn *function) -{ - if (query == NULL) - { - return; - } - - query->context_free_fn= function; -} - -static void drizzle_query_run_state(drizzle_query_st* query, - drizzle_return_t* ret_ptr) -{ - if (query == NULL) - { - return; - } - - switch (query->state) - { - case DRIZZLE_QUERY_STATE_INIT: - query->state= DRIZZLE_QUERY_STATE_QUERY; - - case DRIZZLE_QUERY_STATE_QUERY: - query->result= drizzle_query(query->con, query->result, query->string, - query->size, ret_ptr); - if (*ret_ptr == DRIZZLE_RETURN_IO_WAIT) - { - return; - } - else if (*ret_ptr != DRIZZLE_RETURN_OK) - { - query->state= DRIZZLE_QUERY_STATE_DONE; - return; - } - - query->state= DRIZZLE_QUERY_STATE_RESULT; - - case DRIZZLE_QUERY_STATE_RESULT: - *ret_ptr= drizzle_result_buffer(query->result); - if (*ret_ptr == DRIZZLE_RETURN_IO_WAIT) - { - return; - } - - query->state= DRIZZLE_QUERY_STATE_DONE; - return; - - default: - case DRIZZLE_QUERY_STATE_DONE: - return; - } -} - -drizzle_query_st *drizzle_query_run(drizzle_st *drizzle, - drizzle_return_t *ret_ptr) -{ - drizzle_return_t unused; - if (ret_ptr == NULL) - { - ret_ptr= &unused; - } - - if (drizzle == NULL) - { - *ret_ptr= DRIZZLE_RETURN_INVALID_ARGUMENT; - return NULL; - } - - if (drizzle->query_new == 0 && drizzle->query_running == 0) - { - *ret_ptr= DRIZZLE_RETURN_OK; - return NULL; - } - - drizzle_st::options_t options= drizzle->options; - drizzle->options.is_non_blocking= false; - - /* Check to see if any queries need to be started. */ - if (drizzle->query_new > 0) - { - for (drizzle_query_st *query= drizzle->query_list; query != NULL; query= query->next) - { - if (query->state != DRIZZLE_QUERY_STATE_INIT) - { - continue; - } - - drizzle->query_new--; - drizzle->query_running++; - assert(query->con->query == NULL); - query->con->query= query; - - drizzle_query_run_state(query, ret_ptr); - if (*ret_ptr != DRIZZLE_RETURN_IO_WAIT) - { - assert(query->state == DRIZZLE_QUERY_STATE_DONE); - drizzle->query_running--; - drizzle->options= options; - query->con->query= NULL; - if (*ret_ptr == DRIZZLE_RETURN_ERROR_CODE || *ret_ptr == DRIZZLE_RETURN_OK) - { - return query; - } - return NULL; - } - } - assert(drizzle->query_new == 0); - } - - while (1) - { - drizzle_con_st *con; - - /* Loop through each active connection. */ - while ((con= drizzle_con_ready(drizzle)) != NULL) - { - drizzle_query_st *query= con->query; - drizzle_query_run_state(query, ret_ptr); - if (query->state == DRIZZLE_QUERY_STATE_DONE) - { - drizzle->query_running--; - drizzle->options= options; - con->query= NULL; - return query; - } - assert(*ret_ptr == DRIZZLE_RETURN_IO_WAIT); - } - - if (options.is_non_blocking) - { - *ret_ptr= DRIZZLE_RETURN_IO_WAIT; - return NULL; - } - - *ret_ptr= drizzle_con_wait(drizzle); - if (*ret_ptr != DRIZZLE_RETURN_OK) - { - drizzle->options= options; - return NULL; - } - } -} - -drizzle_return_t drizzle_query_run_all(drizzle_st *drizzle) -{ - if (drizzle == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - while (drizzle->query_new > 0 || drizzle->query_running > 0) - { - drizzle_return_t ret; - - (void)drizzle_query_run(drizzle, &ret); - if (ret != DRIZZLE_RETURN_OK && ret != DRIZZLE_RETURN_ERROR_CODE) - { - return ret; - } - } - - return DRIZZLE_RETURN_OK; -} - -ssize_t drizzle_escape_string(char *to, size_t max_to_size, const char *from, size_t from_size) -{ - ssize_t to_size= 0; - char newchar; - const char *end; - - for (end= from + from_size; from < end; from++) - { - newchar= 0; - /* All multi-byte UTF8 characters have the high bit set for all bytes. */ - if (!(*from & 0x80)) - { - switch (*from) - { - case 0: - newchar= '0'; - break; - case '\n': - newchar= 'n'; - break; - case '\r': - newchar= 'r'; - break; - case '\032': - newchar= 'Z'; - break; - case '\\': - newchar= '\\'; - break; - case '\'': - newchar= '\''; - break; - case '"': - newchar= '"'; - break; - default: - break; - } - } - if (newchar != '\0') - { - if ((size_t)to_size + 2 > max_to_size) - { - return -1; - } - - *to++= '\\'; - *to++= newchar; - to_size++; - } - else - { - if ((size_t)to_size + 1 > max_to_size) - { - return -1; - } - - *to++= *from; - } - to_size++; - } - - *to= 0; - - return to_size; -} - -size_t drizzle_hex_string(char *to, const char *from, size_t from_size) -{ - static const char hex_map[]= "0123456789ABCDEF"; - const char *from_end; - - for (from_end= from + from_size; from != from_end; from++) - { - *to++= hex_map[((unsigned char) *from) >> 4]; - *to++= hex_map[((unsigned char) *from) & 0xF]; - } - - *to= 0; - - return from_size * 2; -} - -void drizzle_mysql_password_hash(char *to, const char *from, size_t from_size) -{ - SHA1_CTX ctx; - uint8_t hash_tmp1[SHA1_DIGEST_LENGTH]; - uint8_t hash_tmp2[SHA1_DIGEST_LENGTH]; - - SHA1Init(&ctx); - SHA1Update(&ctx, (const uint8_t*)from, from_size); - SHA1Final(hash_tmp1, &ctx); - - SHA1Init(&ctx); - SHA1Update(&ctx, hash_tmp1, SHA1_DIGEST_LENGTH); - SHA1Final(hash_tmp2, &ctx); - - (void)drizzle_hex_string(to, (char*)hash_tmp2, SHA1_DIGEST_LENGTH); -} diff --git a/utils/mysqlcl_idb/result.cc b/utils/mysqlcl_idb/result.cc deleted file mode 100644 index 281a3dd5b..000000000 --- a/utils/mysqlcl_idb/result.cc +++ /dev/null @@ -1,803 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @file - * @brief Result definitions - */ - -#include -#include - -/* - * Common definitions - */ - -drizzle_result_st *drizzle_result_create(drizzle_con_st *con) -{ - return drizzle_result_create_with(con, NULL); -} - -drizzle_result_st *drizzle_result_create_with(drizzle_con_st *con, - drizzle_result_st *result) -{ - if (result == NULL) - { - result= new (std::nothrow) drizzle_result_st; - - if (result == NULL) - { - return NULL; - } - - result->row= NULL; - result->field_buffer= NULL; - result->_options.is_allocated= true; - } - else - { - result->prev= NULL; - result->options= 0; - - result->info[0]= '\0'; - result->error_code= 0; - result->sqlstate[0]= '\0'; - result->insert_id= 0; - result->warning_count= 0; - result->affected_rows= 0; - - result->column_count= 0; - result->column_current= 0; - result->column_list= NULL; - result->column= NULL; - result->column_buffer= NULL; - - result->row_count= 0; - result->row_current= 0; - - result->field_current= 0; - result->field_total= 0; - result->field_offset= 0; - result->field_size= 0; - result->field= NULL; - result->field_buffer= NULL; - - result->row_list_size= 0; - result->row= NULL; - result->row_list= NULL; - result->field_sizes= NULL; - result->field_sizes_list= NULL; - - result->_options.is_allocated= false; - } - - result->con= con; - con->result= result; - - if (con->result_list) - con->result_list->prev= result; - result->next= con->result_list; - con->result_list= result; - con->result_count++; - - return result; -} - -drizzle_result_st *drizzle_result_clone(drizzle_con_st *con, - drizzle_result_st *source) -{ - drizzle_result_st *result= drizzle_result_create(con); - if (result == NULL) - { - return NULL; - } - - result->options= source->options; - - drizzle_result_set_info(result, source->info); - result->error_code= source->error_code; - drizzle_result_set_sqlstate(result, source->sqlstate); - result->warning_count= source->warning_count; - result->insert_id= source->insert_id; - result->affected_rows= source->affected_rows; - result->column_count= source->column_count; - result->row_count= source->row_count; - - return result; -} - -void drizzle_result_free(drizzle_result_st *result) -{ - drizzle_column_st *column; - - if (result == NULL) - { - return; - } - - for (column= result->column_list; column != NULL; column= result->column_list) - { - drizzle_column_free(column); - } - - delete[] result->column_buffer; - - if (result->options & DRIZZLE_RESULT_BUFFER_ROW) - { - for (size_t x= 0; x < result->row_count; x++) - { - drizzle_row_free(result, result->row_list->at(x)); - } - - delete result->row_list; - delete result->field_sizes_list; - } - - if (result->con) - { - result->con->result_count--; - if (result->con->result_list == result) - result->con->result_list= result->next; - } - - if (result->prev) - result->prev->next= result->next; - - if (result->next) - result->next->prev= result->prev; - - if (result->_options.is_allocated) - { - delete result; - } -} - -void drizzle_result_free_all(drizzle_con_st *con) -{ - while (con->result_list != NULL) - { - drizzle_result_free(con->result_list); - } -} - -drizzle_con_st *drizzle_result_drizzle_con(drizzle_result_st *result) -{ - if (result == NULL) - { - return NULL; - } - - return result->con; -} - -bool drizzle_result_eof(drizzle_result_st *result) -{ - if (result == NULL) - { - return false; - } - - return (result->options & DRIZZLE_RESULT_EOF_PACKET) ? true : false; -} - -const char *drizzle_result_info(drizzle_result_st *result) -{ - if (result == NULL) - { - return NULL; - } - - return result->info; -} - -const char *drizzle_result_error(drizzle_result_st *result) -{ - if (result == NULL) - { - return NULL; - } - - return result->info; -} - -uint16_t drizzle_result_error_code(drizzle_result_st *result) -{ - if (result == NULL) - { - return 0; - } - - return result->error_code; -} - -const char *drizzle_result_sqlstate(drizzle_result_st *result) -{ - if (result == NULL) - { - return NULL; - } - - return result->sqlstate; -} - -uint16_t drizzle_result_warning_count(drizzle_result_st *result) -{ - if (result == NULL) - { - return 0; - } - - return result->warning_count; -} - -uint64_t drizzle_result_insert_id(drizzle_result_st *result) -{ - if (result == NULL) - { - return 0; - } - - return result->insert_id; -} - -uint64_t drizzle_result_affected_rows(drizzle_result_st *result) -{ - if (result == NULL) - { - return 0; - } - - return result->affected_rows; -} - -uint16_t drizzle_result_column_count(drizzle_result_st *result) -{ - if (result == NULL) - { - return 0; - } - - return result->column_count; -} - -uint64_t drizzle_result_row_count(drizzle_result_st *result) -{ - if (result == NULL) - { - return 0; - } - - return result->row_count; -} - -/* - * Client definitions - */ - -drizzle_result_st *drizzle_result_read(drizzle_con_st *con, - drizzle_result_st *result, - drizzle_return_t *ret_ptr) -{ - drizzle_return_t unused; - if (ret_ptr == NULL) - { - ret_ptr= &unused; - } - - if (con == NULL) - { - *ret_ptr= DRIZZLE_RETURN_INVALID_ARGUMENT; - return NULL; - } - - if (drizzle_state_none(con)) - { - con->result= drizzle_result_create_with(con, result); - if (con->result == NULL) - { - *ret_ptr= DRIZZLE_RETURN_MEMORY; - return NULL; - } - - drizzle_state_push(con, drizzle_state_result_read); - drizzle_state_push(con, drizzle_state_packet_read); - } - - *ret_ptr= drizzle_state_loop(con); - return con->result; -} - -drizzle_return_t drizzle_result_buffer(drizzle_result_st *result) -{ - if (result == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - if (!(result->options & DRIZZLE_RESULT_BUFFER_COLUMN)) - { - drizzle_return_t ret= drizzle_column_buffer(result); - if (ret != DRIZZLE_RETURN_OK) - { - return ret; - } - } - - if (result->column_count == 0) - { - result->options|= DRIZZLE_RESULT_BUFFER_ROW; - return DRIZZLE_RETURN_OK; - } - - while (1) - { - drizzle_return_t ret; - drizzle_row_t row= drizzle_row_buffer(result, &ret); - if (ret != DRIZZLE_RETURN_OK) - { - return ret; - } - - if (row == NULL) - { - break; - } - - if (result->row_list == NULL) - { - result->row_list= new (std::nothrow) drizzle_row_list_t; - - if (result->row_list == NULL) - { - return DRIZZLE_RETURN_MEMORY; - } - } - - - if (result->field_sizes_list == NULL) - { - result->field_sizes_list= new (std::nothrow) drizzle_field_sizes_list_t; - - if (result->field_sizes_list == NULL) - { - } - } - - result->row_list->push_back(row); - result->field_sizes_list->push_back(result->field_sizes); - } - - result->options|= DRIZZLE_RESULT_BUFFER_ROW; - - return DRIZZLE_RETURN_OK; -} - -size_t drizzle_result_row_size(drizzle_result_st *result) -{ - if (result == NULL) - { - return 0; - } - - return result->con->packet_size; -} - -/* - * Server definitions - */ - -drizzle_return_t drizzle_result_write(drizzle_con_st *con, - drizzle_result_st *result, bool flush) -{ - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - if (drizzle_state_none(con)) - { - con->result= result; - - if (flush) - drizzle_state_push(con, drizzle_state_write); - - drizzle_state_push(con, drizzle_state_result_write); - } - - return drizzle_state_loop(con); -} - -void drizzle_result_set_row_size(drizzle_result_st *result, size_t size) -{ - if (result == NULL) - { - return; - } - - result->con->packet_size= size; -} - -void drizzle_result_calc_row_size(drizzle_result_st *result, - const drizzle_field_t *field, - const size_t *size) -{ - if (result == NULL) - { - return; - } - - result->con->packet_size= 0; - - for (uint16_t x= 0; x < result->column_count; x++) - { - if (field[x] == NULL) - { - result->con->packet_size++; - } - else if (size[x] < 251) - { - result->con->packet_size+= (1 + size[x]); - } - else if (size[x] < 65536) - { - result->con->packet_size+= (3 + size[x]); - } - else if (size[x] < 16777216) - { - result->con->packet_size+= (4 + size[x]); - } - else - { - result->con->packet_size+= (9 + size[x]); - } - } -} - -void drizzle_result_set_eof(drizzle_result_st *result, bool is_eof) -{ - if (result == NULL) - { - return; - } - - if (is_eof) - { - result->options|= DRIZZLE_RESULT_EOF_PACKET; - } - else - { - result->options&= ~DRIZZLE_RESULT_EOF_PACKET; - } -} - -void drizzle_result_set_info(drizzle_result_st *result, const char *info) -{ - if (result == NULL) - { - return; - } - - if (info == NULL) - { - result->info[0]= 0; - } - else - { - strncpy(result->info, info, DRIZZLE_MAX_INFO_SIZE); - result->info[DRIZZLE_MAX_INFO_SIZE - 1]= 0; - } -} - -void drizzle_result_set_error(drizzle_result_st *result, const char *error) -{ - if (result == NULL) - { - return; - } - - drizzle_result_set_info(result, error); -} - -void drizzle_result_set_error_code(drizzle_result_st *result, - uint16_t error_code) -{ - if (result == NULL) - { - return; - } - - result->error_code= error_code; -} - -void drizzle_result_set_sqlstate(drizzle_result_st *result, - const char *sqlstate) -{ - if (result == NULL) - { - return; - } - - if (sqlstate == NULL) - { - result->sqlstate[0]= 0; - } - else - { - strncpy(result->sqlstate, sqlstate, DRIZZLE_MAX_SQLSTATE_SIZE + 1); - result->sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE]= 0; - } -} - -void drizzle_result_set_warning_count(drizzle_result_st *result, - uint16_t warning_count) -{ - if (result == NULL) - { - return; - } - - result->warning_count= warning_count; -} - -void drizzle_result_set_insert_id(drizzle_result_st *result, - uint64_t insert_id) -{ - if (result == NULL) - { - return; - } - - result->insert_id= insert_id; -} - -void drizzle_result_set_affected_rows(drizzle_result_st *result, - uint64_t affected_rows) -{ - if (result == NULL) - { - return; - } - - result->affected_rows= affected_rows; -} - -void drizzle_result_set_column_count(drizzle_result_st *result, - uint16_t column_count) -{ - if (result == NULL) - { - return; - } - - result->column_count= column_count; -} - -/* - * Internal state functions. - */ - -drizzle_return_t drizzle_state_result_read(drizzle_con_st *con) -{ - drizzle_return_t ret; - - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - - drizzle_log_debug(con->drizzle, "drizzle_state_result_read"); - - /* Assume the entire result packet will fit in the buffer. */ - if (con->buffer_size < con->packet_size) - { - drizzle_state_push(con, drizzle_state_read); - - return DRIZZLE_RETURN_OK; - } - - if (con->buffer_ptr[0] == 0) - { - con->buffer_ptr++; - /* We can ignore the returns since we've buffered the entire packet. */ - con->result->affected_rows= drizzle_unpack_length(con, &ret); - con->result->insert_id= drizzle_unpack_length(con, &ret); - con->status= (drizzle_con_status_t)drizzle_get_byte2(con->buffer_ptr); - con->result->warning_count= drizzle_get_byte2(con->buffer_ptr + 2); - con->buffer_ptr+= 4; - con->buffer_size-= 5; - con->packet_size-= 5; - if (con->packet_size > 0) - { - /* Skip one byte for message size. */ - con->buffer_ptr+= 1; - con->buffer_size-= 1; - con->packet_size-= 1; - } - ret= DRIZZLE_RETURN_OK; - } - else if (con->buffer_ptr[0] == 254) - { - con->result->options= DRIZZLE_RESULT_EOF_PACKET; - con->result->warning_count= drizzle_get_byte2(con->buffer_ptr + 1); - con->status= (drizzle_con_status_t)drizzle_get_byte2(con->buffer_ptr + 3); - con->buffer_ptr+= 5; - con->buffer_size-= 5; - con->packet_size-= 5; - ret= DRIZZLE_RETURN_OK; - } - else if (con->buffer_ptr[0] == 255) - { - con->result->error_code= drizzle_get_byte2(con->buffer_ptr + 1); - con->drizzle->error_code= con->result->error_code; - /* Byte 3 is always a '#' character, skip it. */ - memcpy(con->result->sqlstate, con->buffer_ptr + 4, - DRIZZLE_MAX_SQLSTATE_SIZE); - con->result->sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE]= 0; - memcpy(con->drizzle->sqlstate, con->result->sqlstate, - DRIZZLE_MAX_SQLSTATE_SIZE + 1); - con->buffer_ptr+= 9; - con->buffer_size-= 9; - con->packet_size-= 9; - ret= DRIZZLE_RETURN_ERROR_CODE; - } - else - { - /* We can ignore the return since we've buffered the entire packet. */ - con->result->column_count= (uint16_t)drizzle_unpack_length(con, &ret); - ret= DRIZZLE_RETURN_OK; - } - - if (con->packet_size > 0) - { - snprintf(con->drizzle->last_error, DRIZZLE_MAX_ERROR_SIZE, "%.*s", - (int32_t)con->packet_size, con->buffer_ptr); - con->drizzle->last_error[DRIZZLE_MAX_ERROR_SIZE-1]= 0; - snprintf(con->result->info, DRIZZLE_MAX_INFO_SIZE, "%.*s", - (int32_t)con->packet_size, con->buffer_ptr); - con->result->info[DRIZZLE_MAX_INFO_SIZE-1]= 0; - con->buffer_ptr+= con->packet_size; - con->buffer_size-= con->packet_size; - con->packet_size= 0; - } - - drizzle_state_pop(con); - - return ret; -} - -drizzle_return_t drizzle_state_result_write(drizzle_con_st *con) -{ - if (con == NULL) - { - return DRIZZLE_RETURN_INVALID_ARGUMENT; - } - - uint8_t *start= con->buffer_ptr + con->buffer_size; - uint8_t *ptr; - drizzle_result_st *result= con->result; - - drizzle_log_debug(con->drizzle, "drizzle_state_result_write"); - - /* Calculate max packet size. */ - con->packet_size= 1 /* OK/Field Count/EOF/Error */ - + 9 /* Affected rows */ - + 9 /* Insert ID */ - + 2 /* Status */ - + 2 /* Warning count */ - + strlen(result->info); /* Info/error message */ - - /* Assume the entire result packet will fit in the buffer. */ - if ((con->packet_size + 4) > DRIZZLE_MAX_BUFFER_SIZE) - { - drizzle_set_error(con->drizzle, "drizzle_state_result_write", "buffer too small:%zu", con->packet_size + 4); - - return DRIZZLE_RETURN_INTERNAL_ERROR; - } - - /* Flush buffer if there is not enough room. */ - if (((size_t)DRIZZLE_MAX_BUFFER_SIZE - (size_t)(start - con->buffer)) < - con->packet_size) - { - drizzle_state_push(con, drizzle_state_write); - - return DRIZZLE_RETURN_OK; - } - - /* Store packet size at the end since it may change. */ - ptr= start; - ptr[3]= con->packet_number; - con->packet_number++; - ptr+= 4; - - if (result->options & DRIZZLE_RESULT_EOF_PACKET) - { - ptr[0]= 254; - ptr++; - - drizzle_set_byte2(ptr, result->warning_count); - ptr+= 2; - - drizzle_set_byte2(ptr, con->status); - ptr+= 2; - } - else if (result->error_code != 0) - { - ptr[0]= 255; - ptr++; - - drizzle_set_byte2(ptr, result->error_code); - ptr+= 2; - - ptr[0]= '#'; - ptr++; - - memcpy(ptr, result->sqlstate, DRIZZLE_MAX_SQLSTATE_SIZE); - ptr+= DRIZZLE_MAX_SQLSTATE_SIZE; - - memcpy(ptr, result->info, strlen(result->info)); - ptr+= strlen(result->info); - } - else if (result->column_count == 0) - { - ptr[0]= 0; - ptr++; - - ptr= drizzle_pack_length(result->affected_rows, ptr); - ptr= drizzle_pack_length(result->insert_id, ptr); - - drizzle_set_byte2(ptr, con->status); - ptr+= 2; - - drizzle_set_byte2(ptr, result->warning_count); - ptr+= 2; - - memcpy(ptr, result->info, strlen(result->info)); - ptr+= strlen(result->info); - } - else - ptr= drizzle_pack_length(result->column_count, ptr); - - con->packet_size= ((size_t)(ptr - start) - 4); - con->buffer_size+= (4 + con->packet_size); - - /* Store packet size now. */ - drizzle_set_byte3(start, con->packet_size); - - drizzle_state_pop(con); - - return DRIZZLE_RETURN_OK; -} diff --git a/utils/mysqlcl_idb/row.cc b/utils/mysqlcl_idb/row.cc deleted file mode 100644 index 5df0ae646..000000000 --- a/utils/mysqlcl_idb/row.cc +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include -using namespace std; - -/** - * @file - * @brief Row definitions - */ - -#include - -/* - * Client definitions - */ - -uint64_t drizzle_row_read(drizzle_result_st *result, drizzle_return_t *ret_ptr) -{ - if ((result->column_current != result->column_count) && (!(result->options & DRIZZLE_RESULT_BUFFER_COLUMN))) - { - drizzle_set_error(result->con->drizzle, "drizzle_row_read", "cannot retrieve rows until all columns are retrieved"); - *ret_ptr= DRIZZLE_RETURN_NOT_READY; - return 0; - } - - if (drizzle_state_none(result->con)) - { - drizzle_state_push(result->con, drizzle_state_row_read); - drizzle_state_push(result->con, drizzle_state_packet_read); - } - - *ret_ptr= drizzle_state_loop(result->con); - - return result->row_current; -} - -drizzle_row_t drizzle_row_buffer(drizzle_result_st *result, - drizzle_return_t *ret_ptr) -{ -//cout<<"drizzle_row_buffer: 0x" << hex << (ptrdiff_t)result << endl; - size_t total; - drizzle_row_t row; - - if (result == NULL) - { - return drizzle_row_t(); - } - - drizzle_return_t unused; - if (ret_ptr == NULL) - { - ret_ptr= &unused; - } - - if (result->row == NULL) - { - if (drizzle_row_read(result, ret_ptr) == 0 || *ret_ptr != DRIZZLE_RETURN_OK) - { - return NULL; - } - - result->row= new (std::nothrow) drizzle_row_t_type[result->column_count *2]; - - if (result->row == NULL) - { - *ret_ptr= DRIZZLE_RETURN_MEMORY; - return drizzle_row_t(); - } - result->field_sizes= reinterpret_cast(result->row + result->column_count); - } - - while (1) - { - drizzle_field_t field= drizzle_field_buffer(result, &total, ret_ptr); - if (*ret_ptr == DRIZZLE_RETURN_ROW_END) - { - break; - } - - if (*ret_ptr != DRIZZLE_RETURN_OK) - { - if (*ret_ptr != DRIZZLE_RETURN_IO_WAIT) - { - delete[] result->row; - result->row= NULL; - result->field_sizes= NULL; - } - - return NULL; - } - - result->row[result->field_current - 1]= field; - result->field_sizes[result->field_current - 1]= total; - } - - *ret_ptr= DRIZZLE_RETURN_OK; - row= result->row; - result->row= NULL; - - return row; -} - -void drizzle_row_free(drizzle_result_st *result, drizzle_row_t row) -{ - uint16_t x; - - for (x= 0; x < result->column_count; x++) - drizzle_field_free(row[x]); - - delete[] row; -} - -size_t *drizzle_row_field_sizes(drizzle_result_st *result) -{ - return result->field_sizes; -} - -drizzle_row_t drizzle_row_next(drizzle_result_st *result) -{ - if (result->row_current == result->row_count) - return NULL; - - result->field_sizes= result->field_sizes_list->at(static_cast(result->row_current)); - result->row_current++; - return result->row_list->at(static_cast(result->row_current) - 1); -} - -drizzle_row_t drizzle_row_prev(drizzle_result_st *result) -{ - if (result->row_current == 0) - return NULL; - - result->row_current--; - result->field_sizes= result->field_sizes_list->at(static_cast(result->row_current)); - return result->row_list->at(static_cast(result->row_current)); -} - -void drizzle_row_seek(drizzle_result_st *result, uint64_t row) -{ - if (row <= result->row_count) - result->row_current= row; -} - -drizzle_row_t drizzle_row_index(drizzle_result_st *result, uint64_t row) -{ - if (row >= result->row_count) - return NULL; - - return (*result->row_list)[static_cast(row)]; -} - -uint64_t drizzle_row_current(drizzle_result_st *result) -{ - return result->row_current; -} - -/* - * Server definitions - */ - -drizzle_return_t drizzle_row_write(drizzle_result_st *result) -{ - if (drizzle_state_none(result->con)) - drizzle_state_push(result->con, drizzle_state_row_write); - - return drizzle_state_loop(result->con); -} - -/* - * Internal state functions. - */ - -drizzle_return_t drizzle_state_row_read(drizzle_con_st *con) -{ - drizzle_log_debug(con->drizzle, "drizzle_state_row_read"); - - if (con->packet_size != 0 && con->buffer_size < con->packet_size && - con->buffer_size < 5) - { - drizzle_state_push(con, drizzle_state_read); - return DRIZZLE_RETURN_OK; - } - - if (con->packet_size == 5 && con->buffer_ptr[0] == 254) - { - /* Got EOF packet, no more rows. */ - con->result->row_current= 0; - con->result->warning_count= drizzle_get_byte2(con->buffer_ptr + 1); - con->status= (drizzle_con_status_t)drizzle_get_byte2(con->buffer_ptr + 3); - con->buffer_ptr+= 5; - con->buffer_size-= 5; - } - else if (con->buffer_ptr[0] == 255) - { - drizzle_state_pop(con); - drizzle_state_push(con, drizzle_state_result_read); - return DRIZZLE_RETURN_OK; - } - else if (con->result->options & DRIZZLE_RESULT_ROW_BREAK) - { - con->result->options&= ~DRIZZLE_RESULT_ROW_BREAK; - } - else - { - con->result->row_count++; - con->result->row_current++; - con->result->field_current= 0; - } - - drizzle_state_pop(con); - - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_row_write(drizzle_con_st *con) -{ - uint8_t *start= con->buffer_ptr + con->buffer_size; - - drizzle_log_debug(con->drizzle, "drizzle_state_row_write"); - - /* Flush buffer if there is not enough room. */ - if (((size_t)DRIZZLE_MAX_BUFFER_SIZE - (size_t)(start - con->buffer)) < 4) - { - drizzle_state_push(con, drizzle_state_write); - return DRIZZLE_RETURN_OK; - } - - drizzle_set_byte3(start, con->packet_size); - start[3]= con->packet_number; - con->packet_number++; - - con->buffer_size+= 4; - - drizzle_state_pop(con); - - return DRIZZLE_RETURN_OK; -} diff --git a/utils/mysqlcl_idb/sha1.cc b/utils/mysqlcl_idb/sha1.cc deleted file mode 100644 index 9cd39ed34..000000000 --- a/utils/mysqlcl_idb/sha1.cc +++ /dev/null @@ -1,179 +0,0 @@ -/** - * @file - * @brief SHA1 Definitions - */ - -/* - * SHA-1 in C - * - * Copyright (C) 2010 nobody (this is public domain) - * - * This file is based on public domain code. - * Initial source code is in the public domain, - * so clarified by Steve Reid - * - * Test Vectors (from FIPS PUB 180-1) - * "abc" - * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D - * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" - * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 - * A million repetitions of "a" - * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F - */ - -#include - -#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) - -/* - * blk0() and blk() perform the initial expand. - * I got the idea of expanding during the round function from SSLeay - */ -#ifndef WORDS_BIGENDIAN -# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ - |(rol(block->l[i],8)&0x00FF00FF)) -#else -# define blk0(i) block->l[i] -#endif -#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ - ^block->l[(i+2)&15]^block->l[i&15],1)) - -/* - * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 - */ -#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); -#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); -#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); -#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); -#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); - -/* - * Hash a single 512-bit block. This is the core of the algorithm. - */ -void -SHA1Transform(uint32_t state[5], const uint8_t buffer[SHA1_BLOCK_LENGTH]) -{ - uint32_t a, b, c, d, e; - typedef union { - uint8_t c[64]; - uint32_t l[16]; - } CHAR64LONG16; - CHAR64LONG16 realBlock; - CHAR64LONG16 *block= &realBlock; - - (void)memcpy(block, buffer, SHA1_BLOCK_LENGTH); - - /* Copy context->state[] to working vars */ - a = state[0]; - b = state[1]; - c = state[2]; - d = state[3]; - e = state[4]; - - /* 4 rounds of 20 operations each. Loop unrolled. */ - R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); - R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); - R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); - R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); - R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); - R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); - R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); - R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); - R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); - R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); - R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); - R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); - R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); - R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); - R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); - R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); - R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); - R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); - R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); - R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); - - /* Add the working vars back into context.state[] */ - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - state[4] += e; - - /* Wipe variables */ - a = b = c = d = e = 0; -} - - -/* - * SHA1Init - Initialize new context - */ -void -SHA1Init(SHA1_CTX *context) -{ - - /* SHA1 initialization constants */ - context->count = 0; - context->state[0] = 0x67452301; - context->state[1] = 0xEFCDAB89; - context->state[2] = 0x98BADCFE; - context->state[3] = 0x10325476; - context->state[4] = 0xC3D2E1F0; -} - - -/* - * Run your data through this. - */ -void -SHA1Update(SHA1_CTX *context, const uint8_t *data, size_t len) -{ - size_t i, j; - - j = (size_t)((context->count >> 3) & 63); - context->count += (len << 3); - if ((j + len) > 63) { - (void)memcpy(&context->buffer[j], data, (i = 64-j)); - SHA1Transform(context->state, context->buffer); - for ( ; i + 63 < len; i += 64) - SHA1Transform(context->state, (uint8_t *)&data[i]); - j = 0; - } else { - i = 0; - } - (void)memcpy(&context->buffer[j], &data[i], len - i); -} - - -/* - * Add padding and return the message digest. - */ -void -SHA1Pad(SHA1_CTX *context) -{ - uint8_t finalcount[8]; - u_int i; - - for (i = 0; i < 8; i++) { - finalcount[i] = (uint8_t)((context->count >> - ((7 - (i & 7)) * 8)) & 255); /* Endian independent */ - } - SHA1Update(context, (uint8_t *)"\200", 1); - while ((context->count & 504) != 448) - SHA1Update(context, (uint8_t *)"\0", 1); - SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ -} - -void -SHA1Final(uint8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context) -{ - u_int i; - - SHA1Pad(context); - if (digest) { - for (i = 0; i < SHA1_DIGEST_LENGTH; i++) { - digest[i] = (uint8_t) - ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); - } - memset(context, 0, sizeof(*context)); - } -} diff --git a/utils/mysqlcl_idb/state.cc b/utils/mysqlcl_idb/state.cc deleted file mode 100644 index 34b476ee2..000000000 --- a/utils/mysqlcl_idb/state.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @file - * @brief State machine definitions - */ - -#include - -drizzle_return_t drizzle_state_loop(drizzle_con_st *con) -{ - while (drizzle_state_none(con) == false) - { - drizzle_return_t ret= con->state_stack[con->state_current - 1](con); - if (ret != DRIZZLE_RETURN_OK) - { - if (ret != DRIZZLE_RETURN_IO_WAIT && ret != DRIZZLE_RETURN_PAUSE && - ret != DRIZZLE_RETURN_ERROR_CODE) - { - drizzle_con_close(con); - } - - return ret; - } - } - - return DRIZZLE_RETURN_OK; -} - -drizzle_return_t drizzle_state_packet_read(drizzle_con_st *con) -{ - drizzle_log_debug(con->drizzle, "drizzle_state_packet_read"); - - if (con->buffer_size < 4) - { - drizzle_state_push(con, drizzle_state_read); - return DRIZZLE_RETURN_OK; - } - - con->packet_size= drizzle_get_byte3(con->buffer_ptr); - - if (con->buffer_size < con->packet_size + 4) - { - drizzle_state_push(con, drizzle_state_read); - return DRIZZLE_RETURN_OK; - } - - if (con->packet_number != con->buffer_ptr[3]) - { - drizzle_set_error(con->drizzle, "drizzle_state_packet_read", - "bad packet number:%u:%u", con->packet_number, - con->buffer_ptr[3]); - return DRIZZLE_RETURN_BAD_PACKET_NUMBER; - } - - drizzle_log_debug(con->drizzle, "packet_size= %zu, packet_number= %u", - con->packet_size, con->packet_number); - - con->packet_number++; - - con->buffer_ptr+= 4; - con->buffer_size-= 4; - - drizzle_state_pop(con); - return DRIZZLE_RETURN_OK; -} diff --git a/utils/mysqlcl_idb/tdriver-works.cpp b/utils/mysqlcl_idb/tdriver-works.cpp deleted file mode 100644 index 67f4b2225..000000000 --- a/utils/mysqlcl_idb/tdriver-works.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Drizzle Client & Protocol Library - * - * Copyright (C) 2008 Eric Day (eday@oddments.org) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -int main(int argc, char *argv[]) -{ - const char* host= NULL; - const char* user= NULL; - const char* password= NULL; - in_port_t port= 0; - - for (int c; (c = getopt(argc, argv, "d:h:mp:u:P:q:v")) != -1; ) - { - switch (c) - { - case 'h': - host= optarg; - break; - - case 'p': - port= static_cast(atoi(optarg)); - break; - - case 'u': - user= optarg; - break; - - case 'P': - password = optarg; - break; - - default: - cout << - "usage:\n" - "\t-h - Host to connect to\n" - "\t-p - Port to connect to\n" - "\t-u - User\n" - "\t-P - Password\n"; - return 1; - } - } -host="127.0.0.1"; -port=13306; -user="rjd"; -password=""; - - drizzle::drizzle_c drizzle; - drizzle_set_verbose((drizzle_st*)drizzle, DRIZZLE_VERBOSE_DEBUG); - drizzle::connection_c* con= new drizzle::connection_c(drizzle); - if (host || port) - con->set_tcp(host, port); - if (user || password) - con->set_auth(user, password); - //con->set_db("information_schema"); - //drizzle::query_c q(*con, "select table_schema, table_name from tables where table_name like ?"); - con->set_db("tpch1"); - drizzle::query_c q(*con, "select n_nationkey from nation"); - //q.p("%"); - try - { - drizzle::result_c result= q.execute(); - cout << q.read() << endl; - while (drizzle_row_t row= result.row_next()) - { - for (int x= 0; x < result.column_count(); x++) - { - if (x) - cout << ", "; - cout << (row[x] ? row[x] : "NULL"); - } - cout << endl; - } - } - catch (const drizzle::bad_query& e) - { - cerr << e.what() << endl; - return 1; - } - return 0; -} diff --git a/utils/mysqlcl_idb/tdriver.cpp b/utils/mysqlcl_idb/tdriver.cpp deleted file mode 100644 index ea5daf42d..000000000 --- a/utils/mysqlcl_idb/tdriver.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include -//#define NDEBUG -#include -using namespace std; - -#include "libdrizzle-2.0/drizzle.h" -#include "libdrizzle-2.0/drizzle_client.h" - -namespace -{ -int doit() -{ - drizzle_st* drzp=0; - drzp = drizzle_create(); - assert(drzp); - - //drizzle_set_verbose(drzp, DRIZZLE_VERBOSE_DEBUG); - - drizzle_con_st* drzcp=0; - drzcp = drizzle_con_add_tcp(drzp, "127.0.0.1", 13306, "rjd", "", "tpch1", DRIZZLE_CON_MYSQL); - - drizzle_return_t drztr; - drztr = drizzle_con_connect(drzcp); - assert(drztr==0); - - //const char* query = "select * from nation"; - const char* query = "select * from region"; - drizzle_return_t* drztrp=0; - drztrp = &drztr; - drizzle_result_st* drzrp=0; - //drzrp=drizzle_result_create(drzcp); - //assert(drzrp); - drzrp = drizzle_query_str(drzcp, drzrp, query, drztrp); - assert(drzrp); - cout << "return_t = " << drztr << endl; - - drztr = drizzle_result_buffer(drzrp); - cout << "return_t = " << drztr << endl; - - drizzle_row_t row; - row = drizzle_row_next(drzrp); - while (row) - { - //cout << "got row: " << row[0] << ',' << row[1] << ',' << row[2] << '.' << row[3] << endl; - cout << "got row: " << row[0] << ',' << row[1] << ',' << row[2] << endl; - //drizzle_row_free(drzrp, row); - row = drizzle_row_next(drzrp); - } - drizzle_result_free(drzrp); - drzrp = 0; - - drizzle_con_close(drzcp); - drizzle_con_free(drzcp); - drzcp = 0; - drizzle_free(drzp); - drzp = 0; - - return 0; -} - -int insertit() -{ - drizzle_st* drzp=0; - drzp = drizzle_create(); - assert(drzp); - - //drizzle_set_verbose(drzp, DRIZZLE_VERBOSE_DEBUG); - - drizzle_con_st* drzcp=0; - drzcp = drizzle_con_add_tcp(drzp, "127.0.0.1", 13306, "rjd", "", "tpch1", DRIZZLE_CON_MYSQL); - - drizzle_return_t drztr; - drztr = drizzle_con_connect(drzcp); - assert(drztr==0); - - //const char* query = "select * from nation"; - const char* query = "insert into foo values (1)"; - drizzle_return_t* drztrp=0; - drztrp = &drztr; - drizzle_result_st* drzrp=0; - //drzrp=drizzle_result_create(drzcp); - //assert(drzrp); - drzrp = drizzle_query_str(drzcp, drzrp, query, drztrp); - assert(drzrp); - cout << "return_t = " << drztr << endl; - - drztr = drizzle_result_buffer(drzrp); - cout << "return_t = " << drztr << endl; - - drizzle_result_free(drzrp); - drzrp = 0; - - drizzle_con_close(drzcp); - drizzle_con_free(drzcp); - drzcp = 0; - drizzle_free(drzp); - drzp = 0; - - return 0; -} - -} - -int main(int argc, char** argv) -{ - doit(); - //doit(); - //doit(); - //doit(); - insertit(); - - return 0; -} - diff --git a/utils/mysqlcl_idb/tdriver1.cpp b/utils/mysqlcl_idb/tdriver1.cpp deleted file mode 100644 index e1a992af4..000000000 --- a/utils/mysqlcl_idb/tdriver1.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include -//#define NDEBUG -#include -using namespace std; - -#include "libdrizzle-2.0/drizzle.h" -#include "libdrizzle-2.0/drizzle_client.h" - -int main(int argc, char** argv) -{ - drizzle_st* drzp=0; - drzp = drizzle_create(); - assert(drzp); - - drizzle_set_verbose(drzp, DRIZZLE_VERBOSE_DEBUG); - - drizzle_con_st* drzcp=0; - drzcp = drizzle_con_create(drzp); - assert(drzcp); - - //drizzle_con_add_tcp(drzp, "127.0.0.1", 13306, "rjd", "", "tpch1", DRIZZLE_CON_MYSQL); - drizzle_con_set_tcp(drzcp, "127.0.0.1", 13306); - drizzle_con_set_auth(drzcp, "rjd", ""); - drizzle_con_set_db(drzcp, "tpch1"); - drizzle_con_add_options(drzcp, DRIZZLE_CON_MYSQL); - - drizzle_con_connect(drzcp); - - drizzle_result_st* drzrp=0; - drzrp = drizzle_result_create(drzcp); - assert(drzrp); - - const char* query = "select n_nationkey from nation"; - drizzle_return_t drztr; - drizzle_return_t* drztrp=0; - drztrp = &drztr; - drzrp = drizzle_query_str(drzcp, drzrp, query, drztrp); - assert(drzrp); - cout << "return_t = " << drztr << endl; - - uint64_t nrows=0; - nrows = drizzle_row_read(drzrp, drztrp); - cout << "return_t = " << drztr << endl; - cout << "rows returned = " << nrows << endl; - - nrows = drizzle_result_row_count(drzrp); - cout << "rows returned = " << nrows << endl; - - drizzle_con_close(drzcp); - - return 0; -} - diff --git a/utils/querystats/CMakeLists.txt b/utils/querystats/CMakeLists.txt index 940749a6b..001211834 100644 --- a/utils/querystats/CMakeLists.txt +++ b/utils/querystats/CMakeLists.txt @@ -8,6 +8,8 @@ set(querystats_LIB_SRCS querystats.cpp) add_library(querystats SHARED ${querystats_LIB_SRCS}) +target_link_libraries(querystats -L${SERVER_SOURCE_ROOT_DIR}/libmysql/ libmysqlclient_r.so) + set_target_properties(querystats PROPERTIES VERSION 1.0.0 SOVERSION 1) install(TARGETS querystats DESTINATION ${ENGINE_LIBDIR} COMPONENT libs) diff --git a/utils/querystats/querystats.cpp b/utils/querystats/querystats.cpp index ef593b3fc..88dab5d26 100644 --- a/utils/querystats/querystats.cpp +++ b/utils/querystats/querystats.cpp @@ -21,6 +21,8 @@ * ***********************************************************************/ +#include +#include #include using namespace std; @@ -37,28 +39,24 @@ using namespace logging; #include "querystats.h" -#include "libdrizzle-2.0/drizzle.h" -#include "libdrizzle-2.0/drizzle_client.h" - namespace querystats { const string SCHEMA = "infinidb_querystats"; -struct IDB_Drizzle +struct IDB_MySQL { - IDB_Drizzle(): drzp(NULL), drzcp(NULL), drzrp(NULL) {} - ~IDB_Drizzle() + IDB_MySQL(): fCon(NULL), fRes(NULL) {} + ~IDB_MySQL() { - // The following API all checks NULL in the implementation. - drizzle_result_free(drzrp); - drizzle_con_close(drzcp); - drizzle_con_free(drzcp); - drizzle_free(drzp); + if (fRes) + mysql_free_result(fRes); + + if (fCon) + mysql_close(fCon); } - drizzle_st* drzp; - drizzle_con_st* drzcp; - drizzle_result_st* drzrp; + MYSQL* fCon; + MYSQL_RES* fRes; }; QueryStats::QueryStats() @@ -206,25 +204,19 @@ void QueryStats::insert() ERR_CROSS_ENGINE_CONFIG); // insert stats to querystats table - IDB_Drizzle drizzle; + IDB_MySQL mysql; - drizzle.drzp = drizzle_create(); - if (drizzle.drzp == 0) + mysql.fCon = mysql_init(NULL); + if (mysql.fCon == NULL) handleMySqlError("fatal error initializing querystats lib", -1); - drizzle.drzcp = drizzle_con_add_tcp(drizzle.drzp, host.c_str(), port, user.c_str(), pwd.c_str(), - SCHEMA.c_str(), DRIZZLE_CON_MYSQL); - if (drizzle.drzcp == 0) - handleMySqlError("fatal error setting up parms in querystats lib", -1); - - drizzle_return_t drzret; - drzret = drizzle_con_connect(drizzle.drzcp); - if (drzret != 0) - handleMySqlError("fatal error connecting to InfiniDB in querystats lib", drzret); + if (mysql_real_connect(mysql.fCon, host.c_str(), user.c_str(), pwd.c_str(), + SCHEMA.c_str(), port, NULL, 0) == NULL) + handleMySqlError("fatal error setting up parms in querystats lib", mysql_errno(mysql.fCon)); // escape quote characters boost::scoped_array query(new char[fQuery.length()*2+1]); - drizzle_escape_string(query.get(), fQuery.length()*2, fQuery.c_str(), fQuery.length()); + mysql_real_escape_string(mysql.fCon, query.get(), fQuery.c_str(), fQuery.length()); ostringstream insert; insert << "insert delayed into querystats values (0, "; @@ -248,14 +240,10 @@ void QueryStats::insert() insert << fBlocksChanged << ", "; insert << fNumFiles << ", "; insert << fFileBytes << ")"; // the last 2 fields are not populated yet - - drizzle.drzrp = drizzle_query_str(drizzle.drzcp, drizzle.drzrp, insert.str().c_str(), &drzret); - if (drzret != 0 || drizzle.drzrp == 0) - handleMySqlError("fatal error executing query in querystats lib", drzret); - drzret = drizzle_result_buffer(drizzle.drzrp); - if (drzret != 0) - handleMySqlError("fatal error reading results from InfiniDB in querystats lib", drzret); + int ret = mysql_query(mysql.fCon, insert.str().c_str()); + if (ret != 0) + handleMySqlError("fatal error executing query in querystats lib", ret); } void QueryStats::handleMySqlError(const char* errStr, unsigned int errCode) @@ -294,19 +282,14 @@ uint32_t QueryStats::userPriority(string _host, const string _user) ERR_CROSS_ENGINE_CONFIG); // get user priority - IDB_Drizzle drizzle; - drizzle.drzp = drizzle_create(); - if (drizzle.drzp == 0) + IDB_MySQL mysql; + mysql.fCon = mysql_init(NULL); + if (mysql.fCon == NULL) handleMySqlError("fatal error initializing querystats lib", -1); - drizzle.drzcp = drizzle_con_add_tcp(drizzle.drzp, host.c_str(), port, user.c_str(), pwd.c_str(), - SCHEMA.c_str(), DRIZZLE_CON_MYSQL); - if (drizzle.drzcp == 0) - handleMySqlError("fatal error setting up parms in querystats lib", -1); - drizzle_return_t drzret; - drzret = drizzle_con_connect(drizzle.drzcp); - if (drzret != 0) - handleMySqlError("fatal error connecting to InfiniDB in querystats lib", drzret); + if (mysql_real_connect(mysql.fCon, host.c_str(), user.c_str(), pwd.c_str(), + SCHEMA.c_str(), port, NULL, 0) == NULL) + handleMySqlError("fatal error connecting to InfiniDB in querystats lib", mysql_errno(mysql.fCon)); // get the part of host string befor ':' if there is. size_t pos = _host.find(':', 0); @@ -324,16 +307,18 @@ uint32_t QueryStats::userPriority(string _host, const string _user) << _user << "') and upper(a.priority) = upper(b.priority)"; - drizzle.drzrp = drizzle_query_str(drizzle.drzcp, drizzle.drzrp, query.str().c_str(), &drzret); - if (drzret != 0 || drizzle.drzrp == 0) - handleMySqlError("fatal error executing query in querystats lib", drzret); - drzret = drizzle_result_buffer(drizzle.drzrp); - if (drzret != 0) - handleMySqlError("fatal error reading results from InfiniDB in querystats lib", drzret); + int ret =mysql_query(mysql.fCon, query.str().c_str()); + if (ret != 0) + handleMySqlError("fatal error executing query in querystats lib", ret); + // Using mysql_store_result here as for mysql_use_result we would need to get every row + // Maybe limit 1 on the query in the future? + mysql.fRes = mysql_store_result(mysql.fCon); + if (mysql.fRes == NULL) + handleMySqlError("fatal error reading results from InfiniDB in querystats lib", mysql_errno(mysql.fCon)); // only fetch one row. if duplicate user name in the table, the first one will be got. - drizzle_row_t row; - row = drizzle_row_next(drizzle.drzrp); + MYSQL_ROW row; + row = mysql_fetch_row(mysql.fRes); if (row) { fPriority = row[0];