diff --git a/.gitignore b/.gitignore index 4494412..0d6fece 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,8 @@ /premake5 /premake5.exe /out -.vscode \ No newline at end of file +.vscode +*.zip +cmake-build-debug +.idea +.vs \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5f7aa16..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: cpp -git: - depth: 1 -addons: - apt: - packages: - - g++-multilib -matrix: - include: - - os: linux - install: - - wget -O premake.tar.gz "https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-linux.tar.gz" - - tar xvzf premake.tar.gz - - "./premake5 --os=linux --file=BuildProjects.lua gmake" - script: - - make -C solutions/linux-gmake - - mkdir -p srcds/garrysmod/lua/bin - - cp out/linux/gmsv_mysqloo_linux64.dll srcds/garrysmod/lua/bin/ - - cp MySQL/lib64/linux/libmysqlclient.so srcds/ - - zip -r release.zip srcds/ README.md - deploy: - provider: releases - api_key: - secure: FNxCgy3Gvuy4ypv6K9M+d9gV5rkDKr4bcUzfeX3JQGLHiE74VI/nbkJYLprVVGr52OtkO8jsq4iL+YCosT8nkP6shJK2cQ68Vnng0Db2Hn1NqflBBg0vJ2IEv/ua1Os7mDOQwhrhTVuxx1timKaIpZQpDbO1FEj8uBsdYhSGX+3HBUctb9B9bluw6NC4rgM/ugSMy6g0JmTZirP5eNxuBffREidyydKIBgn+egKe7Cmh19OzPolIfyTfrvkGB3Mm5Ti7fmmZycPCvCVdhSPq5N7s2FQn1TdOOHN7NaIpeqEjdCTQFM3O/JKYdKvAo0y3FiHLrp2xou2N149ADOlumHATbe9tGQRpBDmnWZMcHQPVcPPCSpXCqT5/CP8UAaP0/RtqenFt4ZA8jFl6TrQJecHU8UdBscnn28Oq8r+C83czE/L/d6RezyjW8ph5IzUEdFQdhkSfOkI1CEqUpCydVh6lXT+Monx9pwGywU3WD3sCKs5DijH34xE4r2M/t41vkojUxSO/P+PUg7GY/ccZtelWFAQgrwZyJECdQWefzYaUfZk1tI6pnjOwtyF5rC2qXMR/W/ZQppRfdfv9oRqx8HOaSKxBqx/iJ2MEZn0v1pa028pc1FQbqVGWBuTdErd+KifH/ffSQdeVLlEkVbJOtWbLWutG1S9jaghAsythqH0= - file: "release.zip" - skip_cleanup: true - on: - tags: true diff --git a/BuildProjects.lua b/BuildProjects.lua deleted file mode 100644 index b55ecdb..0000000 --- a/BuildProjects.lua +++ /dev/null @@ -1,67 +0,0 @@ -function os.winSdkVersion() - local reg_arch = iif( os.is64bit(), "\\Wow6432Node\\", "\\" ) - local sdk_version = os.getWindowsRegistry( "HKLM:SOFTWARE" .. reg_arch .. "Microsoft\\Microsoft SDKs\\Windows\\v10.0\\ProductVersion" ) - if sdk_version ~= nil then return sdk_version end -end - -solution "MySQLOO" - language "C++" - location ( "solutions/" .. os.target() .. "-" .. _ACTION ) - flags { "NoPCH", "NoImportLib"} - targetdir ( "out/" .. os.target() .. "/" ) - includedirs { "MySQLOO/include/", - "GmodLUA/include/", - "Boost/", - "MySQL/include/" } - if os.target() == "macosx" or os.target() == "linux" then - buildoptions{ "-std=c++11 -fPIC" } - linkoptions{ "-fPIC -static-libstdc++" } - end - - configurations { "Release" } - platforms { "x86_64" } - - if os.target() == "windows" then - defines{ "WIN32" } - elseif os.target() == "linux" then - defines{ "LINUX" } - end - - local platform - if os.target() == "windows" then - platform = "win" - elseif os.target() == "macosx" then - platform = "osx" - elseif os.target() == "linux" then - platform = "linux" - else - error "Unsupported platform." - end - - filter "platforms:x86_64" - architecture "x86_64" - libdirs { "MySQL/lib64/" .. os.target() } - targetname( "gmsv_mysqloo_" .. platform .. "64") - filter {"system:windows", "action:vs*"} - systemversion((os.winSdkVersion() or "10.0.16299") .. ".0") - toolset "v141" - - project "MySQLOO" - symbols "On" - editandcontinue "Off" - vectorextensions "SSE" - floatingpoint "Fast" - optimize "On" - - defines{ "GMMODULE", "NDEBUG" } - files{ "MySQLOO/source/**.*", "MySQLOO/include/**.*" } - kind "SharedLib" - targetprefix ("") - targetextension (".dll") - targetdir("out/" .. os.target()) - - if os.target() == "windows" then - links { "libmysql", "ws2_32.lib", "shlwapi.lib" } - elseif os.target() == "macosx" or os.target() == "linux" then - links { "mysqlclient", "pthread", "dl" } - end diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e11fee9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.5) +project(mysqloo) +add_subdirectory(GmodLUA) + +file(GLOB_RECURSE MYSQLOO_SRC "src/*.h" "src/*.cpp") +set(SOURCE_FILES ${MYSQLOO_SRC} src/Main.cpp) +set(CMAKE_BUILD_TYPE RelWithDebInfo) +set (CMAKE_CXX_STANDARD 14) + +add_library(mysqloo SHARED ${SOURCE_FILES}) +target_link_libraries(mysqloo gmod-module-base) + +target_include_directories(mysqloo PRIVATE MySQL/include) + +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + if (WIN32) + find_library(MARIADB_CLIENT_LIB mariadbclient HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib64/windows") + else () + find_library(MARIADB_CLIENT_LIB mariadbclient HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib64/linux") + find_library(CRYPTO_LIB crypto HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib64/linux") + find_library(SSL_LIB ssl HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib64/linux") + endif () +elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) + if (WIN32) + find_library(MARIADB_CLIENT_LIB mariadbclient HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib/windows") + else () + find_library(MARIADB_CLIENT_LIB mariadbclient HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib/linux") + find_library(CRYPTO_LIB crypto HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib/linux") + find_library(SSL_LIB ssl HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib/linux") + endif () +endif () + +if (WIN32) + target_link_libraries(mysqloo ${MARIADB_CLIENT_LIB} crypt32 ws2_32 shlwapi bcrypt secur32) +else () + find_package(Threads REQUIRED) + target_link_libraries(mysqloo ${MARIADB_CLIENT_LIB} ${SSL_LIB} ${CRYPTO_LIB} Threads::Threads ${CMAKE_DL_LIBS}) +endif () + +set_gmod_suffix_prefix(mysqloo) \ No newline at end of file diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 0000000..b6d078a --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,27 @@ +{ + "configurations": [ + { + "name": "x64-RelDebug", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "" + }, + { + "name": "x86-RelDebug", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x86" ], + "variables": [] + } + ] +} \ No newline at end of file diff --git a/GmodLUA/CMakeLists.txt b/GmodLUA/CMakeLists.txt new file mode 100644 index 0000000..9cb5eaa --- /dev/null +++ b/GmodLUA/CMakeLists.txt @@ -0,0 +1,33 @@ +set(SOURCES + GarrysMod/Lua/Interface.h + GarrysMod/Lua/LuaBase.h + GarrysMod/Lua/SourceCompat.h + GarrysMod/Lua/Types.h + GarrysMod/Lua/UserData.h) + +add_library(gmod-module-base INTERFACE) +target_include_directories(gmod-module-base INTERFACE ./) + +function(set_gmod_suffix_prefix library) + SET_TARGET_PROPERTIES(${library} PROPERTIES PREFIX "gmsv_") + + if(APPLE) + if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") + SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_osx.dll") + else() + SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_osx64.dll") + endif() + elseif(UNIX) + if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") + SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_linux.dll") + else() + SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_linux64.dll") + endif() + elseif(WIN32) + if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") + SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_win32.dll") + else() + SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_win64.dll") + endif() + endif() +endfunction() \ No newline at end of file diff --git a/GmodLUA/GarrysMod/Lua/Interface.h b/GmodLUA/GarrysMod/Lua/Interface.h new file mode 100644 index 0000000..bb3b8ca --- /dev/null +++ b/GmodLUA/GarrysMod/Lua/Interface.h @@ -0,0 +1,74 @@ +#ifndef GARRYSMOD_LUA_INTERFACE_H +#define GARRYSMOD_LUA_INTERFACE_H + +#include "LuaBase.h" + +struct lua_State { +#if defined( _WIN32 ) && !defined( _M_X64 ) + // Win32 + unsigned char _ignore_this_common_lua_header_[48 + 22]; +#elif defined( _WIN32 ) && defined( _M_X64 ) + // Win64 + unsigned char _ignore_this_common_lua_header_[92 + 22]; +#elif defined( __linux__ ) && !defined( __x86_64__ ) + // Linux32 + unsigned char _ignore_this_common_lua_header_[48 + 22]; +#elif defined( __linux__ ) && defined( __x86_64__ ) + // Linux64 + unsigned char _ignore_this_common_lua_header_[92 + 22]; +#elif defined ( __APPLE__ ) && !defined( __x86_64__ ) + // macOS32 + unsigned char _ignore_this_common_lua_header_[48 + 22]; +#elif defined ( __APPLE__ ) && defined( __x86_64__ ) + // macOS64 + unsigned char _ignore_this_common_lua_header_[92 + 22]; +#else +#error agh +#endif + + GarrysMod::Lua::ILuaBase *luabase; +}; + +#ifndef GMOD +#ifdef _WIN32 +#define DLL_EXPORT extern "C" __declspec( dllexport ) +#else +#define DLL_EXPORT extern "C" __attribute__((visibility("default"))) +#endif + +#ifdef GMOD_ALLOW_DEPRECATED +// Stop using this and use LUA_FUNCTION! +#define LUA ( state->luabase ) + +#define GMOD_MODULE_OPEN() DLL_EXPORT int gmod13_open( lua_State* state ) +#define GMOD_MODULE_CLOSE() DLL_EXPORT int gmod13_close( lua_State* state ) +#else +#define GMOD_MODULE_OPEN() \ + int gmod13_open__Imp( GarrysMod::Lua::ILuaBase* LUA ); \ + DLL_EXPORT int gmod13_open( lua_State* L ) \ + { \ + return gmod13_open__Imp( L->luabase ); \ + } \ + int gmod13_open__Imp( GarrysMod::Lua::ILuaBase* LUA ) + +#define GMOD_MODULE_CLOSE() \ + int gmod13_close__Imp( GarrysMod::Lua::ILuaBase* LUA ); \ + DLL_EXPORT int gmod13_close( lua_State* L ) \ + { \ + return gmod13_close__Imp( L->luabase ); \ + } \ + int gmod13_close__Imp( GarrysMod::Lua::ILuaBase* LUA ) + +#define LUA_FUNCTION(FUNC) \ + static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ); \ + static int FUNC( lua_State* L ) \ + { \ + GarrysMod::Lua::ILuaBase* LUA = L->luabase; \ + LUA->SetState(L); \ + return FUNC##__Imp( LUA ); \ + } \ + static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ) +#endif +#endif + +#endif diff --git a/GmodLUA/GarrysMod/Lua/LuaBase.h b/GmodLUA/GarrysMod/Lua/LuaBase.h new file mode 100644 index 0000000..0ceab47 --- /dev/null +++ b/GmodLUA/GarrysMod/Lua/LuaBase.h @@ -0,0 +1,313 @@ +#ifndef GARRYSMOD_LUA_LUABASE_H +#define GARRYSMOD_LUA_LUABASE_H + +#include +#include + +#include "Types.h" +#include "UserData.h" +#include "SourceCompat.h" + +struct lua_State; + +namespace GarrysMod +{ + namespace Lua + { + typedef int ( *CFunc )( lua_State* L ); + + // + // Use this to communicate between C and Lua + // + class ILuaBase + { + public: + // You shouldn't need to use this struct + // Instead, use the UserType functions + struct UserData + { + void* data; + unsigned char type; // Change me to a uint32 one day + }; + + protected: + template + struct UserData_Value : UserData + { + T value; + }; + + public: + // Returns the amount of values on the stack + virtual int Top( void ) = 0; + + // Pushes a copy of the value at iStackPos to the top of the stack + virtual void Push( int iStackPos ) = 0; + + // Pops iAmt values from the top of the stack + virtual void Pop( int iAmt = 1 ) = 0; + + // Pushes table[key] on to the stack + // table = value at iStackPos + // key = value at top of the stack + // Pops the key from the stack + virtual void GetTable( int iStackPos ) = 0; + + // Pushes table[key] on to the stack + // table = value at iStackPos + // key = strName + virtual void GetField( int iStackPos, const char* strName ) = 0; + + // Sets table[key] to the value at the top of the stack + // table = value at iStackPos + // key = strName + // Pops the value from the stack + virtual void SetField( int iStackPos, const char* strName ) = 0; + + // Creates a new table and pushes it to the top of the stack + virtual void CreateTable() = 0; + + // Sets table[key] to the value at the top of the stack + // table = value at iStackPos + // key = value 2nd to the top of the stack + // Pops the key and the value from the stack + virtual void SetTable( int iStackPos ) = 0; + + // Sets the metatable for the value at iStackPos to the value at the top of the stack + // Pops the value off of the top of the stack + virtual void SetMetaTable( int iStackPos ) = 0; + + // Pushes the metatable of the value at iStackPos on to the top of the stack + // Upon failure, returns false and does not push anything + virtual bool GetMetaTable( int i ) = 0; + + // Calls a function + // To use it: Push the function on to the stack followed by each argument + // Pops the function and arguments from the stack, leaves iResults values on the stack + // If this function errors, any local C values will not have their destructors called! + virtual void Call( int iArgs, int iResults ) = 0; + + // Similar to Call + // See: lua_pcall( lua_State*, int, int, int ) + virtual int PCall( int iArgs, int iResults, int iErrorFunc ) = 0; + + // Returns true if the values at iA and iB are equal + virtual int Equal( int iA, int iB ) = 0; + + // Returns true if the value at iA and iB are equal + // Does not invoke metamethods + virtual int RawEqual( int iA, int iB ) = 0; + + // Moves the value at the top of the stack in to iStackPos + // Any elements above iStackPos are shifted upwards + virtual void Insert( int iStackPos ) = 0; + + // Removes the value at iStackPos from the stack + // Any elements above iStackPos are shifted downwards + virtual void Remove( int iStackPos ) = 0; + + // Allows you to iterate tables similar to pairs(...) + // See: lua_next( lua_State*, int ); + virtual int Next( int iStackPos ) = 0; + +#ifndef GMOD_ALLOW_DEPRECATED + protected: +#endif + // Deprecated: Use the UserType functions instead of this + virtual void* NewUserdata( unsigned int iSize ) = 0; + + public: + // Throws an error and ceases execution of the function + // If this function is called, any local C values will not have their destructors called! + virtual void ThrowError( const char* strError ) = 0; + + // Checks that the type of the value at iStackPos is iType + // Throws and error and ceases execution of the function otherwise + // If this function errors, any local C values will not have their destructors called! + virtual void CheckType( int iStackPos, int iType ) = 0; + + // Throws a pretty error message about the given argument + // If this function is called, any local C values will not have their destructors called! + virtual void ArgError( int iArgNum, const char* strMessage ) = 0; + + // Pushes table[key] on to the stack + // table = value at iStackPos + // key = value at top of the stack + // Does not invoke metamethods + virtual void RawGet( int iStackPos ) = 0; + + // Sets table[key] to the value at the top of the stack + // table = value at iStackPos + // key = value 2nd to the top of the stack + // Pops the key and the value from the stack + // Does not invoke metamethods + virtual void RawSet( int iStackPos ) = 0; + + // Returns the string at iStackPos. iOutLen is set to the length of the string if it is not NULL + // If the value at iStackPos is a number, it will be converted in to a string + // Returns NULL upon failure + virtual const char* GetString( int iStackPos = -1, unsigned int* iOutLen = NULL ) = 0; + + // Returns the number at iStackPos + // Returns 0 upon failure + virtual double GetNumber( int iStackPos = -1 ) = 0; + + // Returns the boolean at iStackPos + // Returns false upon failure + virtual bool GetBool( int iStackPos = -1 ) = 0; + + // Returns the C-Function at iStackPos + // returns NULL upon failure + virtual CFunc GetCFunction( int iStackPos = -1 ) = 0; + +#ifndef GMOD_ALLOW_DEPRECATED + protected: +#endif + // Deprecated: You should probably be using the UserType functions instead of this + virtual void* GetUserdata( int iStackPos = -1 ) = 0; + + public: + // Pushes a nil value on to the stack + virtual void PushNil() = 0; + + // Pushes the given string on to the stack + // If iLen is 0, strlen will be used to determine the string's length + virtual void PushString( const char* val, unsigned int iLen = 0 ) = 0; + + // Pushes the given double on to the stack + virtual void PushNumber( double val ) = 0; + + // Pushes the given bobolean on to the stack + virtual void PushBool( bool val ) = 0; + + // Pushes the given C-Function on to the stack + virtual void PushCFunction( CFunc val ) = 0; + + // Pushes the given C-Function on to the stack with upvalues + // See: GetUpvalueIndex() + virtual void PushCClosure( CFunc val, int iVars ) = 0; + + +#ifndef GMOD_ALLOW_DEPRECATED + protected: +#endif + // Deprecated: Don't use light userdata in GMod + virtual void PushUserdata( void* ) = 0; + + public: + // Allows for values to be stored by reference for later use + // Make sure you call ReferenceFree when you are done with a reference + virtual int ReferenceCreate() = 0; + virtual void ReferenceFree( int i ) = 0; + virtual void ReferencePush( int i ) = 0; + + // Push a special value onto the top of the stack (see SPECIAL_* enums) + virtual void PushSpecial( int iType ) = 0; + + // Returns true if the value at iStackPos is of type iType + // See: Types.h + virtual bool IsType( int iStackPos, int iType ) = 0; + + // Returns the type of the value at iStackPos + // See: Types.h + virtual int GetType( int iStackPos ) = 0; + + // Returns the name associated with the given type ID + // See: Types.h + // Note: GetTypeName does not work with user-created types + virtual const char* GetTypeName( int iType ) = 0; + +#ifndef GMOD_ALLOW_DEPRECATED + protected: +#endif + // Deprecated: Use CreateMetaTable + virtual void CreateMetaTableType( const char* strName, int iType ) = 0; + + public: + // Like Get* but throws errors and returns if they're not of the expected type + // If these functions error, any local C values will not have their destructors called! + virtual const char* CheckString( int iStackPos = -1 ) = 0; + virtual double CheckNumber( int iStackPos = -1 ) = 0; + + // Returns the length of the object at iStackPos + // Works for: strings, tables, userdata + virtual int ObjLen( int iStackPos = -1 ) = 0; + + // Returns the angle at iStackPos + virtual const QAngle& GetAngle( int iStackPos = -1 ) = 0; + + // Returns the vector at iStackPos + virtual const Vector& GetVector( int iStackPos = -1 ) = 0; + + // Pushes the given angle to the top of the stack + virtual void PushAngle( const QAngle& val ) = 0; + + // Pushes the given vector to the top of the stack + virtual void PushVector( const Vector& val ) = 0; + + // Sets the lua_State to be used by the ILuaBase implementation + // You don't need to use this if you use the LUA_FUNCTION macro + virtual void SetState( lua_State* L ) = 0; + + // Pushes the metatable associated with the given type name + // Returns the type ID to use for this type + // If the type doesn't currently exist, it will be created + virtual int CreateMetaTable( const char* strName ) = 0; + + // Pushes the metatable associated with the given type + virtual bool PushMetaTable( int iType ) = 0; + + // Creates a new UserData of type iType that references the given data + virtual void PushUserType( void* data, int iType ) = 0; + + // Sets the data pointer of the UserType at iStackPos + // You can use this to invalidate a UserType by passing NULL + virtual void SetUserType( int iStackPos, void* data ) = 0; + + // Returns the data of the UserType at iStackPos if it is of the given type + template + T* GetUserType( int iStackPos, int iType ) + { + auto* ud = static_cast( GetUserdata( iStackPos ) ); + + if ( ud == nullptr || ud->data == nullptr || ud->type != iType ) + return nullptr; + + return static_cast( ud->data ); + } + + // Creates a new UserData with your own data embedded within it + template + void PushUserType_Value( const T& val, int iType ) + { + using UserData_T = UserData_Value; + + // The UserData allocated by CLuaInterface is only guaranteed to have a data alignment of 8 + static_assert( std::alignment_of::value <= 8, + "PushUserType_Value given type with unsupported alignment requirement" ); + + // Don't give this function objects that can't be trivially destructed + // You could ignore this limitation if you implement object destruction in `__gc` + static_assert( std::is_trivially_destructible::value, + "PushUserType_Value given type that is not trivially destructible" ); + + auto* ud = static_cast( NewUserdata( sizeof( UserData_T ) ) ); + ud->data = new( &ud->value ) T ( val ); + ud->type = iType; + + // Set the metatable + if ( PushMetaTable( iType ) ) SetMetaTable( -2 ); + } + }; + + // For use with ILuaBase::PushSpecial + enum + { + SPECIAL_GLOB, // Global table + SPECIAL_ENV, // Environment table + SPECIAL_REG, // Registry table + }; + } +} + +#endif diff --git a/GmodLUA/GarrysMod/Lua/SourceCompat.h b/GmodLUA/GarrysMod/Lua/SourceCompat.h new file mode 100644 index 0000000..13ebeec --- /dev/null +++ b/GmodLUA/GarrysMod/Lua/SourceCompat.h @@ -0,0 +1,35 @@ +#ifndef GARRYSMOD_LUA_SOURCECOMPAT_H +#define GARRYSMOD_LUA_SOURCECOMPAT_H + +#ifdef GMOD_USE_SOURCESDK +#include "mathlib/vector.h" +#else + struct Vector + { + Vector() + : x( 0.f ) + , y( 0.f ) + , z( 0.f ) + {} + + Vector( const Vector& src ) + : x( src.x ) + , y( src.y ) + , z( src.z ) + {} + + Vector& operator=( const Vector& src ) + { + x = src.x; + y = src.y; + z = src.z; + return *this; + } + + float x, y, z; + }; + + using QAngle = Vector; +#endif + +#endif diff --git a/GmodLUA/include/GarrysMod/Lua/Types.h b/GmodLUA/GarrysMod/Lua/Types.h similarity index 54% rename from GmodLUA/include/GarrysMod/Lua/Types.h rename to GmodLUA/GarrysMod/Lua/Types.h index f298135..c795bf9 100644 --- a/GmodLUA/include/GarrysMod/Lua/Types.h +++ b/GmodLUA/GarrysMod/Lua/Types.h @@ -1,10 +1,6 @@ #ifndef GARRYSMOD_LUA_TYPES_H #define GARRYSMOD_LUA_TYPES_H -#ifdef ENTITY -#undef ENTITY -#endif - namespace GarrysMod { namespace Lua @@ -14,59 +10,60 @@ namespace GarrysMod enum { #ifdef GMOD_ALLOW_DEPRECATED - // Deprecated: Use NONE instead of INVALID - INVALID = -1, + // Deprecated: Use `None` instead of `Invalid` + Invalid = -1, #endif - // Lua Types - NONE = -1, - NIL, - BOOL, - LIGHTUSERDATA, - NUMBER, - STRING, - TABLE, - FUNCTION, - USERDATA, - THREAD, + // Default Lua Types + None = -1, + Nil, + Bool, + LightUserData, + Number, + String, + Table, + Function, + UserData, + Thread, // GMod Types - ENTITY, - Vector, // GMOD: GO TODO - This was renamed... I'll probably forget to fix it before this ends up public - ANGLE, - PHYSOBJ, - SAVE, - RESTORE, - DAMAGEINFO, - EFFECTDATA, - MOVEDATA, - RECIPIENTFILTER, - USERCMD, - SCRIPTEDVEHICLE, - MATERIAL, - PANEL, - PARTICLE, - PARTICLEEMITTER, - TEXTURE, - USERMSG, - CONVAR, - IMESH, - MATRIX, - SOUND, - PIXELVISHANDLE, - DLIGHT, - VIDEO, - FILE, - LOCOMOTION, - PATH, - NAVAREA, - SOUNDHANDLE, - NAVLADDER, - PARTICLESYSTEM, - PROJECTEDTEXTURE, - PHYSCOLLIDE, + Entity, + Vector, + Angle, + PhysObj, + Save, + Restore, + DamageInfo, + EffectData, + MoveData, + RecipientFilter, + UserCmd, + ScriptedVehicle, + Material, + Panel, + Particle, + ParticleEmitter, + Texture, + UserMsg, + ConVar, + IMesh, + Matrix, + Sound, + PixelVisHandle, + DLight, + Video, + File, + Locomotion, + Path, + NavArea, + SoundHandle, + NavLadder, + ParticleSystem, + ProjectedTexture, + PhysCollide, + SurfaceInfo, - COUNT + Type_Count }; #if ( defined( GMOD ) || defined( GMOD_ALLOW_DEPRECATED ) ) @@ -116,8 +113,8 @@ namespace GarrysMod "particlesystem", "projectedtexture", "physcollide", - - 0 + "surfaceinfo", + nullptr }; #endif } diff --git a/GmodLUA/include/GarrysMod/Lua/UserData.h b/GmodLUA/GarrysMod/Lua/UserData.h similarity index 100% rename from GmodLUA/include/GarrysMod/Lua/UserData.h rename to GmodLUA/GarrysMod/Lua/UserData.h diff --git a/GmodLUA/include/GarrysMod/Lua/Interface.h b/GmodLUA/include/GarrysMod/Lua/Interface.h deleted file mode 100644 index da30d9d..0000000 --- a/GmodLUA/include/GarrysMod/Lua/Interface.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef GARRYSMOD_LUA_INTERFACE_H -#define GARRYSMOD_LUA_INTERFACE_H - -#include "LuaBase.h" - -struct lua_State -{ -#if defined( _WIN32 ) && !defined( _M_X64 ) - // Win32 - unsigned char _ignore_this_common_lua_header_[48 + 22]; -#elif defined( _WIN32 ) && defined( _M_X64 ) - // Win64 - unsigned char _ignore_this_common_lua_header_[92 + 22]; -#elif defined( __linux__ ) && !defined( __x86_64__ ) - // Linux32 - unsigned char _ignore_this_common_lua_header_[48 + 22]; -#elif defined( __linux__ ) && defined( __x86_64__ ) - // Linux64 - unsigned char _ignore_this_common_lua_header_[92 + 22]; -#elif defined ( __APPLE__ ) && !defined( __x86_64__ ) - // macOS32 - unsigned char _ignore_this_common_lua_header_[48 + 22]; -#elif defined ( __APPLE__ ) && defined( __x86_64__ ) - // macOS64 - unsigned char _ignore_this_common_lua_header_[92 + 22]; -#else - #error agh -#endif - - GarrysMod::Lua::ILuaBase* luabase; -}; - -#ifndef GMOD - #ifdef _WIN32 - #define DLL_EXPORT extern "C" __declspec( dllexport ) - #else - #define DLL_EXPORT extern "C" __attribute__((visibility("default"))) - #endif - -#ifdef GMOD_ALLOW_DEPRECATED - // Stop using this and use LUA_FUNCTION! - #define LUA ( state->luabase ) - - #define GMOD_MODULE_OPEN() DLL_EXPORT int gmod13_open( lua_State* state ) - #define GMOD_MODULE_CLOSE() DLL_EXPORT int gmod13_close( lua_State* state ) -#else - #define GMOD_MODULE_OPEN() \ - int gmod13_open__Imp( GarrysMod::Lua::ILuaBase* LUA ); \ - DLL_EXPORT int gmod13_open( lua_State* L ) \ - { \ - return gmod13_open__Imp( L->luabase ); \ - } \ - int gmod13_open__Imp( GarrysMod::Lua::ILuaBase* LUA ) - - #define GMOD_MODULE_CLOSE() \ - int gmod13_close__Imp( GarrysMod::Lua::ILuaBase* LUA ); \ - DLL_EXPORT int gmod13_close( lua_State* L ) \ - { \ - return gmod13_close__Imp( L->luabase ); \ - } \ - int gmod13_close__Imp( GarrysMod::Lua::ILuaBase* LUA ) - - #define LUA_FUNCTION( FUNC ) \ - int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ); \ - int FUNC( lua_State* L ) \ - { \ - GarrysMod::Lua::ILuaBase* LUA = L->luabase; \ - LUA->SetState(L); \ - return FUNC##__Imp( LUA ); \ - } \ - int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ) -#endif - -#endif - -#endif diff --git a/GmodLUA/include/GarrysMod/Lua/LuaBase.h b/GmodLUA/include/GarrysMod/Lua/LuaBase.h deleted file mode 100644 index d5b132c..0000000 --- a/GmodLUA/include/GarrysMod/Lua/LuaBase.h +++ /dev/null @@ -1,277 +0,0 @@ -#ifndef GARRYSMOD_LUA_LUABASE_H -#define GARRYSMOD_LUA_LUABASE_H - -#include - -#include "Types.h" -#include "UserData.h" -#include "SourceCompat.h" - -struct lua_State; - -namespace GarrysMod -{ - namespace Lua - { - typedef int ( *CFunc )( lua_State* L ); - - // - // Use this to communicate between C and Lua - // - class ILuaBase - { - public: - - // You shouldn't need to use this struct - // Instead, use the UserType functions - struct UserData - { - void* data; - unsigned char type; - }; - - // Returns the amount of values on the stack - virtual int Top( void ) = 0; - - // Pushes a copy of the value at iStackPos to the top of the stack - virtual void Push( int iStackPos ) = 0; - - // Pops iAmt values from the top of the stack - virtual void Pop( int iAmt = 1 ) = 0; - - // Pushes table[key] on to the stack - // table = value at iStackPos - // key = value at top of the stack - // Pops the key from the stack - virtual void GetTable( int iStackPos ) = 0; - - // Pushes table[key] on to the stack - // table = value at iStackPos - // key = strName - virtual void GetField( int iStackPos, const char* strName ) = 0; - - // Sets table[key] to the value at the top of the stack - // table = value at iStackPos - // key = strName - // Pops the value from the stack - virtual void SetField( int iStackPos, const char* strName ) = 0; - - // Creates a new table and pushes it to the top of the stack - virtual void CreateTable() = 0; - - // Sets table[key] to the value at the top of the stack - // table = value at iStackPos - // key = value 2nd to the top of the stack - // Pops the key and the value from the stack - virtual void SetTable( int iStackPos ) = 0; - - // Sets the metatable for the value at iStackPos to the value at the top of the stack - // Pops the value off of the top of the stack - virtual void SetMetaTable( int iStackPos ) = 0; - - // Pushes the metatable of the value at iStackPos on to the top of the stack - // Upon failure, returns false and does not push anything - virtual bool GetMetaTable( int i ) = 0; - - // Calls a function - // To use it: Push the function on to the stack followed by each argument - // Pops the function and arguments from the stack, leaves iResults values on the stack - // If this function errors, any local C values will not have their destructors called! - virtual void Call( int iArgs, int iResults ) = 0; - - // Similar to Call - // See: lua_pcall( lua_State*, int, int, int ) - virtual int PCall( int iArgs, int iResults, int iErrorFunc ) = 0; - - // Returns true if the values at iA and iB are equal - virtual int Equal( int iA, int iB ) = 0; - - // Returns true if the value at iA and iB are equal - // Does not invoke metamethods - virtual int RawEqual( int iA, int iB ) = 0; - - // Moves the value at the top of the stack in to iStackPos - // Any elements above iStackPos are shifted upwards - virtual void Insert( int iStackPos ) = 0; - - // Removes the value at iStackPos from the stack - // Any elements above iStackPos are shifted downwards - virtual void Remove( int iStackPos ) = 0; - - // Allows you to iterate tables similar to pairs(...) - // See: lua_next( lua_State*, int ); - virtual int Next( int iStackPos ) = 0; - -#ifndef GMOD_ALLOW_DEPRECATED - private: -#endif - // Deprecated: Use the UserType functions instead of this - virtual void* NewUserdata( unsigned int iSize ) = 0; - - public: - // Throws an error and ceases execution of the function - // If this function is called, any local C values will not have their destructors called! - virtual void ThrowError( const char* strError ) = 0; - - // Checks that the type of the value at iStackPos is iType - // Throws and error and ceases execution of the function otherwise - // If this function errors, any local C values will not have their destructors called! - virtual void CheckType( int iStackPos, int iType ) = 0; - - // Throws a pretty error message about the given argument - // If this function is called, any local C values will not have their destructors called! - virtual void ArgError( int iArgNum, const char* strMessage ) = 0; - - // Pushes table[key] on to the stack - // table = value at iStackPos - // key = value at top of the stack - // Does not invoke metamethods - virtual void RawGet( int iStackPos ) = 0; - - // Sets table[key] to the value at the top of the stack - // table = value at iStackPos - // key = value 2nd to the top of the stack - // Pops the key and the value from the stack - // Does not invoke metamethods - virtual void RawSet( int iStackPos ) = 0; - - // Returns the string at iStackPos. iOutLen is set to the length of the string if it is not NULL - // If the value at iStackPos is a number, it will be converted in to a string - // Returns NULL upon failure - virtual const char* GetString( int iStackPos = -1, unsigned int* iOutLen = NULL ) = 0; - - // Returns the number at iStackPos - // Returns 0 upon failure - virtual double GetNumber( int iStackPos = -1 ) = 0; - - // Returns the boolean at iStackPos - // Returns false upon failure - virtual bool GetBool( int iStackPos = -1 ) = 0; - - // Returns the C-Function at iStackPos - // returns NULL upon failure - virtual CFunc GetCFunction( int iStackPos = -1 ) = 0; - -#ifndef GMOD_ALLOW_DEPRECATED - private: -#endif - // Deprecated: You should probably be using the UserType functions instead of this - virtual void* GetUserdata( int iStackPos = -1 ) = 0; - - public: - // Pushes a nil value on to the stack - virtual void PushNil() = 0; - - // Pushes the given string on to the stack - // If iLen is 0, strlen will be used to determine the string's length - virtual void PushString( const char* val, unsigned int iLen = 0 ) = 0; - - // Pushes the given double on to the stack - virtual void PushNumber( double val ) = 0; - - // Pushes the given bobolean on to the stack - virtual void PushBool( bool val ) = 0; - - // Pushes the given C-Function on to the stack - virtual void PushCFunction( CFunc val ) = 0; - - // Pushes the given C-Function on to the stack with upvalues - // See: GetUpvalueIndex() - virtual void PushCClosure( CFunc val, int iVars ) = 0; - - // Pushes the given pointer on to the stack as light-userdata - virtual void PushUserdata( void* ) = 0; - - // Allows for values to be stored by reference for later use - // Make sure you call ReferenceFree when you are done with a reference - virtual int ReferenceCreate() = 0; - virtual void ReferenceFree( int i ) = 0; - virtual void ReferencePush( int i ) = 0; - - // Push a special value onto the top of the stack (see SPECIAL_* enums) - virtual void PushSpecial( int iType ) = 0; - - // Returns true if the value at iStackPos is of type iType - // See: Types.h - virtual bool IsType( int iStackPos, int iType ) = 0; - - // Returns the type of the value at iStackPos - // See: Types.h - virtual int GetType( int iStackPos ) = 0; - - // Returns the name associated with the given type ID - // See: Types.h - // Note: GetTypeName does not work with user-created types - virtual const char* GetTypeName( int iType ) = 0; - -#ifndef GMOD_ALLOW_DEPRECATED - private: -#endif - // Deprecated: Use CreateMetaTable - virtual void CreateMetaTableType( const char* strName, int iType ) = 0; - - public: - // Like Get* but throws errors and returns if they're not of the expected type - // If these functions error, any local C values will not have their destructors called! - virtual const char* CheckString( int iStackPos = -1 ) = 0; - virtual double CheckNumber( int iStackPos = -1 ) = 0; - - // Returns the length of the object at iStackPos - // Works for: strings, tables, userdata - virtual int ObjLen( int iStackPos = -1 ) = 0; - - // Returns the angle at iStackPos - virtual const QAngle& GetAngle( int iStackPos = -1 ) = 0; - - // Returns the vector at iStackPos - virtual const Vector& GetVector( int iStackPos = -1 ) = 0; - - // Pushes the given angle to the top of the stack - virtual void PushAngle( const QAngle& val ) = 0; - - // Pushes the given vector to the top of the stack - virtual void PushVector( const Vector& val ) = 0; - - // Sets the lua_State to be used by the ILuaBase implementation - // You don't need to use this if you use the LUA_FUNCTION macro - virtual void SetState( lua_State *L ) = 0; - - // Pushes the metatable associated with the given type name - // Returns the type ID to use for this type - // If the type doesn't currently exist, it will be created - virtual int CreateMetaTable( const char* strName ) = 0; - - // Pushes the metatable associated with the given type - virtual bool PushMetaTable( int iType ) = 0; - - // Creates a new UserData of type iType that references the given data - virtual void PushUserType( void* data, int iType ) = 0; - - // Sets the data pointer of the UserType at iStackPos - // You can use this to invalidate a UserType by passing NULL - virtual void SetUserType( int iStackPos, void* data ) = 0; - - // Returns the data of the UserType at iStackPos if it is of the given type - template - T* GetUserType( int iStackPos, int iType ) - { - UserData* ud = (UserData*) GetUserdata( iStackPos ); - - if ( ud == NULL || ud->data == NULL || ud->type != iType ) - return NULL; - - return reinterpret_cast( ud->data ); - } - }; - - // For use with ILuaBase::PushSpecial - enum - { - SPECIAL_GLOB, // Global table - SPECIAL_ENV, // Environment table - SPECIAL_REG, // Registry table - }; - } -} - -#endif diff --git a/GmodLUA/include/GarrysMod/Lua/SourceCompat.h b/GmodLUA/include/GarrysMod/Lua/SourceCompat.h deleted file mode 100644 index 18a294c..0000000 --- a/GmodLUA/include/GarrysMod/Lua/SourceCompat.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef GARRYSMOD_LUA_SOURCECOMPAT_H -#define GARRYSMOD_LUA_SOURCECOMPAT_H - -#ifdef GMOD_USE_SOURCESDK - #include "mathlib/vector.h" -#else - struct Vector - { - Vector() - : x( 0.f ) - , y( 0.f ) - , z( 0.f ) - {} - - float x, y, z; - }; - - struct QAngle - { - QAngle() - : x( 0.f ) - , y( 0.f ) - , z( 0.f ) - {} - - float x, y, z; - }; -#endif - -#endif diff --git a/IntegrationTest/README.md b/IntegrationTest/README.md new file mode 100644 index 0000000..1e52e03 --- /dev/null +++ b/IntegrationTest/README.md @@ -0,0 +1,12 @@ +# MySQLOO Lua Integration Tests + +This folder contains integration tests for MySQLOO. + +## Running + +- Place this folder into the server's addons folder. +- Adjust the database settings in lua/autorun/server/init.lua + - ensure that the database used is **empty** as it will be filled with test data +- run `mysqloo_start_tests` in the server console + +Each of the tests outputs its result to the console and at the end there is an overview of all tests printed. \ No newline at end of file diff --git a/IntegrationTest/lua/autorun/server/init.lua b/IntegrationTest/lua/autorun/server/init.lua new file mode 100644 index 0000000..ed15fb8 --- /dev/null +++ b/IntegrationTest/lua/autorun/server/init.lua @@ -0,0 +1,10 @@ +DatabaseSettings = { + Host = "localhost", + Port = 3306, + Username = "root", + Password = "", + Database = "test" +} + +print("Loading MySQLOO Testing Framework") +include("mysqloo/init.lua") \ No newline at end of file diff --git a/IntegrationTest/lua/mysqloo/init.lua b/IntegrationTest/lua/mysqloo/init.lua new file mode 100644 index 0000000..ad0c60b --- /dev/null +++ b/IntegrationTest/lua/mysqloo/init.lua @@ -0,0 +1,8 @@ +include("testframework.lua") +include("setup.lua") + + +local files = file.Find("mysqloo/tests/*.lua", "LUA") +for _,f in pairs(files) do + include("tests/" .. f) +end \ No newline at end of file diff --git a/IntegrationTest/lua/mysqloo/setup.lua b/IntegrationTest/lua/mysqloo/setup.lua new file mode 100644 index 0000000..e9ff841 --- /dev/null +++ b/IntegrationTest/lua/mysqloo/setup.lua @@ -0,0 +1,18 @@ +require("mysqloo") + +function TestFramework:ConnectToDatabase() + local db = mysqloo.connect(DatabaseSettings.Host, DatabaseSettings.Username, DatabaseSettings.Password, DatabaseSettings.Database, DatabaseSettings.Port) + db:connect() + db:wait() + return db +end + +function TestFramework:RunQuery(db, queryStr) + local query = db:query(queryStr) + query:start() + function query:onError(err) + error(err) + end + query:wait() + return query:getData() +end \ No newline at end of file diff --git a/IntegrationTest/lua/mysqloo/testframework.lua b/IntegrationTest/lua/mysqloo/testframework.lua new file mode 100644 index 0000000..8791602 --- /dev/null +++ b/IntegrationTest/lua/mysqloo/testframework.lua @@ -0,0 +1,167 @@ + + +TestFramework = TestFramework or {} +TestFramework.RegisteredTests = {} + +local TestMT = {} +TestMT.__index = TestMT + +function TestFramework:RegisterTest(name, f) + local tbl = setmetatable({}, {__index = TestMT}) + tbl.TestFunction = f + tbl.Name = name + table.insert(TestFramework.RegisteredTests, tbl) + print("Registered test ", name) +end + +function TestFramework:RunNextTest() + TestFramework.CurrentIndex = (TestFramework.CurrentIndex or 0) + 1 + TestFramework.TestTimeout = CurTime() + 3 + local test = TestFramework.RegisteredTests[TestFramework.CurrentIndex] + TestFramework.CurrentTest = test + if (!test) then + TestFramework:OnCompleted() + else + test:Run() + end +end + +function TestFramework:CheckTimeout() + if (!TestFramework.CurrentTest) then return end + if (CurTime() > TestFramework.TestTimeout) then + TestFramework.CurrentTest:Fail("TIMEOUT") + end +end + +hook.Add("Think", "TestFrameworkTimeoutCheck", function() + TestFramework:CheckTimeout() +end) + +function TestFramework:ReportResult(success) + TestFramework.TestCount = (TestFramework.TestCount or 0) + 1 + if (success) then + TestFramework.SuccessCount = (TestFramework.SuccessCount or 0) + 1 + else + TestFramework.FailureCount = (TestFramework.FailureCount or 0) + 1 + end +end + +function TestFramework:OnCompleted() + print("[MySQLOO] Tests completed") + MsgC(Color(255, 255, 255), "Completed: ", Color(30, 230, 30), TestFramework.SuccessCount, Color(255, 255, 255), " Failures: ", Color(230, 30, 30), TestFramework.FailureCount, "\n") + + for j = 0, 3 do + timer.Simple(j * 0.5, function() + for i = 1, 100 do + collectgarbage("collect") + end + end) + end + timer.Simple(2, function() + for i = 1, 100 do + collectgarbage("collect") + end + local diffBefore = TestFramework.AllocationCount - TestFramework.DeallocationCount + local diffAfter = mysqloo.allocationCount() - mysqloo.deallocationCount() + if (diffAfter > diffBefore) then + MsgC(Color(255, 255, 255), "Found potential memory leak with ", diffAfter - diffBefore, " new allocations that were not freed\n") + else + MsgC(Color(255, 255, 255), "All allocated objects were freed\n") + end + MsgC(Color(255, 255, 255), "Lua Heap Before: ", TestFramework.LuaMemory, " After: ", collectgarbage("count"), "\n") + end) +end + +function TestFramework:Start() + for i = 1, 5 do + collectgarbage("collect") + end + TestFramework.CurrentIndex = 0 + TestFramework.SuccessCount = 0 + TestFramework.FailureCount = 0 + TestFramework.AllocationCount = mysqloo.allocationCount() + TestFramework.DeallocationCount = mysqloo.deallocationCount() + TestFramework.LuaMemory = collectgarbage("count") + TestFramework:RunNextTest() +end + +function TestMT:Fail(reason) + if (self.Completed) then return end + self.Completed = true + MsgC(Color(230, 30, 30), "FAILED\n") + MsgC(Color(230, 30, 30), "Error: ", reason, "\n") + TestFramework:ReportResult(false) + TestFramework:RunNextTest() +end + +function TestMT:Complete() + if (self.Completed) then return end + self.Completed = true + MsgC(Color(30, 230, 30), "PASSED\n") + TestFramework:ReportResult(true) + TestFramework:RunNextTest() +end + +function TestMT:Run() + MsgC("Test: ", self.Name, " ") + self.Completed = false + local status, err = pcall(function() + self.TestFunction(self) + end) + if (!status) then + self:Fail(err) + end +end + +function TestMT:shouldBeNil(a) + if (a != nil) then + self:Fail(tostring(a) .. " was expected to be nil, but was not nil") + error("Assertion failed") + end +end + +function TestMT:shouldBeGreaterThan(a, num) + if (num >= a) then + self:Fail(tostring(a) .. " was expected to be greater than " .. tostring(num)) + error("Assertion failed") + end +end + +function TestMT:shouldNotBeNil(a) + if (a == nil) then + self:Fail(tostring(a) .. " was expected to not be nil, but was nil") + error("Assertion failed") + end +end + +function TestMT:shouldNotBeEqual(a, b) + if (a == b) then + self:Fail(tostring(a) .. " was equal to " .. tostring(b)) + error("Assertion failed") + end +end + +function TestMT:shouldBeEqual(a, b) + if (a != b) then + self:Fail(tostring(a) .. " was not equal to " .. tostring(b)) + error("Assertion failed") + end +end + +function TestMT:shouldHaveLength(tbl, exactLength) + if (#tbl != exactLength) then + self:Fail("Length of " .. tostring(tbl) .. " was not equal to " .. exactLength) + error("Assertion failed") + end +end + +concommand.Add("mysqloo_start_tests", function(ply) + if (IsValid(ply)) then return end + print("Starting MySQLOO Tests") + if (#player.GetBots() == 0) then + RunConsoleCommand("bot") + end + timer.Simple(0.1, function() + TestFramework:Start() + end) +end) \ No newline at end of file diff --git a/IntegrationTest/lua/mysqloo/tests/basic_mysql_test.lua b/IntegrationTest/lua/mysqloo/tests/basic_mysql_test.lua new file mode 100644 index 0000000..7da524b --- /dev/null +++ b/IntegrationTest/lua/mysqloo/tests/basic_mysql_test.lua @@ -0,0 +1,14 @@ +TestFramework:RegisterTest("[Basic] selecting 1 should return 1", function(test) + local db = TestFramework:ConnectToDatabase() + local query = db:query("SELECT 3 as test") + function query:onSuccess(data) + test:shouldHaveLength(data, 1) + test:shouldBeEqual(data[1]["test"], 3) + test:Complete() + end + function query:onError(err) + test:Fail(err) + end + query:start() + query:wait() +end) \ No newline at end of file diff --git a/IntegrationTest/lua/mysqloo/tests/database_tests.lua b/IntegrationTest/lua/mysqloo/tests/database_tests.lua new file mode 100644 index 0000000..38f2930 --- /dev/null +++ b/IntegrationTest/lua/mysqloo/tests/database_tests.lua @@ -0,0 +1,119 @@ +TestFramework:RegisterTest("[Database] should return info correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local serverInfo = db:serverInfo() + local hostInfo = db:hostInfo() + local serverVersion = db:serverVersion() + test:shouldBeGreaterThan(#serverInfo, 0) + test:shouldBeGreaterThan(#hostInfo, 0) + test:shouldBeGreaterThan(serverVersion, 0) + test:Complete() +end) + +TestFramework:RegisterTest("[Database] queue size should return correct size", function(test) + local db = TestFramework:ConnectToDatabase() + test:shouldBeEqual(db:queueSize(), 0) + local query1 = db:query("SELECT SLEEP(0.5)") + local query2 = db:query("SELECT SLEEP(0.5)") + local query3 = db:query("SELECT SLEEP(0.5)") + function query1:onSuccess() + test:shouldBeEqual(db:queueSize(), 1) //1 because the next was already started at this point + end + function query2:onSuccess() + test:shouldBeEqual(db:queueSize(), 0) //0 because the next was already started at this point + test:Complete() + end + function query3:onSuccess() + test:shouldBeEqual(db:queueSize(), 0) + test:Complete() + end + query1:start() + query2:start() + query3:start() + test:shouldBeGreaterThan(db:queueSize(), 1) +end) + +TestFramework:RegisterTest("[Database] should abort all queries correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local query1 = db:query("SELECT SLEEP(0.5)") + local query2 = db:query("SELECT SLEEP(0.5)") + local query3 = db:query("SELECT SLEEP(0.5)") + local abortedCount = 0 + local f = function(q) + abortedCount = abortedCount + 1 + if (abortedCount == 2) then + test:Complete() + end + end + query1.onAborted = f + query2.onAborted = f + query3.onAborted = f + query1:start() + query2:start() + query3:start() + local amountAborted = db:abortAllQueries() + test:shouldBeGreaterThan(amountAborted, 1) //The one already processing might not be aborted +end) + +TestFramework:RegisterTest("[Database] should escape a string correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local escapedStr = db:escape("t'a") + test:shouldBeEqual(escapedStr, "t\\'a") + test:Complete() +end) + +TestFramework:RegisterTest("[Database] should return correct status", function(test) + local db = mysqloo.connect(DatabaseSettings.Host, DatabaseSettings.Username, DatabaseSettings.Password, DatabaseSettings.Database, DatabaseSettings.Port) + test:shouldBeEqual(db:status(), mysqloo.DATABASE_NOT_CONNECTED) + db:connect() + function db:onConnected() + test:shouldBeEqual(db:status(), mysqloo.DATABASE_CONNECTED) + + db:disconnect(true) + test:shouldBeEqual(db:status(), mysqloo.DATABASE_NOT_CONNECTED) + test:Complete() + end +end) + +TestFramework:RegisterTest("[Database] should call onConnected callback correctly", function(test) + local db = mysqloo.connect(DatabaseSettings.Host, DatabaseSettings.Username, DatabaseSettings.Password, DatabaseSettings.Database, DatabaseSettings.Port) + function db:onConnected() + test:Complete() + end + db:connect() +end) + +TestFramework:RegisterTest("[Database] should call onConnectionFailed callback correctly", function(test) + local db = mysqloo.connect(DatabaseSettings.Host, DatabaseSettings.Username, "incorrect_password", DatabaseSettings.Database, DatabaseSettings.Port) + function db:onConnectionFailed(err) + test:shouldBeGreaterThan(#err, 0) + test:Complete() + end + db:connect() +end) + +TestFramework:RegisterTest("[Database] should ping correctly", function(test) + local db = TestFramework:ConnectToDatabase() + test:shouldBeEqual(db:ping(), true) + test:Complete() +end) + +TestFramework:RegisterTest("[Database] allow setting only valid character set", function(test) + local db = TestFramework:ConnectToDatabase() + test:shouldBeEqual(db:setCharacterSet("utf8"), true) + test:shouldBeEqual(db:setCharacterSet("ascii"), true) + test:shouldBeEqual(db:setCharacterSet("invalid_name"), false) + test:Complete() +end) + +TestFramework:RegisterTest("[Database] wait for queries when disconnecting", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:query("SELECT SLEEP(1)") + local wasCalled = false + function qu:onSuccess() + wasCalled = true + end + qu:start() + db:disconnect(true) + test:shouldBeEqual(wasCalled, true) + test:Complete() +end) \ No newline at end of file diff --git a/IntegrationTest/lua/mysqloo/tests/prepared_query_tests.lua b/IntegrationTest/lua/mysqloo/tests/prepared_query_tests.lua new file mode 100644 index 0000000..8871e8e --- /dev/null +++ b/IntegrationTest/lua/mysqloo/tests/prepared_query_tests.lua @@ -0,0 +1,300 @@ +TestFramework:RegisterTest("[Prepared Query] have correct set... functions", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SELECT ? as a, ? as b, ? as c, ? as d, ? as e") + qu:setNumber(1, 5.5) + qu:setString(2, "test") + qu:setBoolean(3, true) + qu:setBoolean(4, false) + qu:setString(5, "b") + qu:setNull(5) + qu:start() + qu:wait() + local data = qu:getData() + test:shouldHaveLength(data, 1) + test:shouldBeEqual(data[1].a, 5.5) + test:shouldBeEqual(data[1].b, "test") + test:shouldBeEqual(data[1].c, 1) + test:shouldBeEqual(data[1].d, 0) + test:shouldBeNil(data[1].e) + test:Complete() +end) + +TestFramework:RegisterTest("[Prepared Query] allow batching parameters correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SELECT ? as a") + qu:setNumber(1, 1) + qu:putNewParameters() + qu:setNumber(1, 2) + qu:putNewParameters() + qu:setNumber(1, 3) + qu:start() + qu:wait() + test:shouldBeEqual(qu:hasMoreResults(), true) + test:shouldBeEqual(qu:getData()[1].a, 1) + qu:getNextResults() + test:shouldBeEqual(qu:hasMoreResults(), true) + test:shouldBeEqual(qu:getData()[1].a, 2) + qu:getNextResults() + test:shouldBeEqual(qu:hasMoreResults(), true) + test:shouldBeEqual(qu:getData()[1].a, 3) + qu:getNextResults() + test:shouldBeEqual(qu:hasMoreResults(), false) + test:Complete() +end) + +TestFramework:RegisterTest("[Prepared Query] clear parameters correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SELECT ? as a, ? as b") + qu:setNumber(1, 1) + qu:setString(2, "test") + qu:clearParameters() + qu:start() + qu:wait() + local data = qu:getData() + test:shouldHaveLength(data, 1) + test:shouldBeNil(data[1].a) + test:shouldBeNil(data[1].b) + test:Complete() +end) + +TestFramework:RegisterTest("[Prepared Query] last insert should return correct values", function(test) + local db = TestFramework:ConnectToDatabase() + TestFramework:RunQuery(db, [[DROP TABLE IF EXISTS last_insert_test]]) + TestFramework:RunQuery(db, [[CREATE TABLE last_insert_test(id INT AUTO_INCREMENT PRIMARY KEY)]]) + + local qu = db:prepare("INSERT INTO last_insert_test VALUES()") + function qu:onSuccess() + test:shouldBeEqual(qu:lastInsert(), 1) + end + qu:start() + local qu2 = db:prepare("INSERT INTO last_insert_test VALUES()") + function qu2:onSuccess() + test:shouldBeEqual(qu2:lastInsert(), 2) + end + qu2:start() + local qu3 = db:prepare("INSERT INTO last_insert_test VALUES()") + function qu3:onSuccess() + test:shouldBeEqual(qu3:lastInsert(), 3) + function qu3:onSuccess() + test:shouldBeEqual(qu3:lastInsert(), 4) + qu3.onSuccess = nil + qu3:start() + qu3:wait() + test:shouldBeEqual(qu3:lastInsert(), 5) + test:Complete() + end + qu3:start() + end + qu3:start() +end) + +TestFramework:RegisterTest("[Prepared Query] affected rows should return correct values", function(test) + local db = TestFramework:ConnectToDatabase() + TestFramework:RunQuery(db, [[DROP TABLE IF EXISTS affected_rows_test]]) + TestFramework:RunQuery(db, [[CREATE TABLE affected_rows_test(id INT AUTO_INCREMENT PRIMARY KEY)]]) + TestFramework:RunQuery(db, "INSERT INTO affected_rows_test VALUES()") + TestFramework:RunQuery(db, "INSERT INTO affected_rows_test VALUES()") + TestFramework:RunQuery(db, "INSERT INTO affected_rows_test VALUES()") + TestFramework:RunQuery(db, "INSERT INTO affected_rows_test VALUES()") + local qu = db:prepare("DELETE FROM affected_rows_test WHERE id = ?") + qu:setNumber(1, 4) + qu:start() + qu:wait() + test:shouldBeEqual(qu:affectedRows(), 1) + qu:start() + local qu2 = db:prepare("DELETE FROM affected_rows_test") + function qu2:onSuccess() + test:shouldBeEqual(qu2:affectedRows(), 3) + function qu2:onSuccess() + test:shouldBeEqual(qu2:affectedRows(), 0) + test:Complete() + end + qu2:start() + end + qu2:start() +end) + +TestFramework:RegisterTest("[Prepared Query] isRunning should return the correct value", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SELECT SLEEP(0.1)") + test:shouldBeEqual(qu:isRunning(), false) + function qu:onSuccess() + test:shouldBeEqual(qu:isRunning(), true) + timer.Simple(0.1, function() + test:shouldBeEqual(qu:isRunning(), false) + test:Complete() + end) + end + qu:start() + test:shouldBeEqual(qu:isRunning(), true) +end) + +TestFramework:RegisterTest("[Prepared Query] should return correct data", function(test) + local db = TestFramework:ConnectToDatabase() + TestFramework:RunQuery(db, [[DROP TABLE IF EXISTS data_test]]) + TestFramework:RunQuery(db, [[CREATE TABLE data_test(id INT PRIMARY KEY, str VARCHAR(10), big BIGINT, bin BLOB, num DOUBLE, bool BIT)]]) + TestFramework:RunQuery(db, [[INSERT INTO data_test VALUES(1, '2', 8589934588, X'470047', 3.3, TRUE)]]) + TestFramework:RunQuery(db, [[INSERT INTO data_test VALUES(2, null, -8589930588, X'00AB', 10.1, FALSE)]]) + + local qu = db:prepare("SELECT * FROM data_test") + function qu:onSuccess(data) + test:shouldBeEqual(data, qu:getData()) //Check that it is cached correctly + test:shouldBeEqual(#data, 2) + local row1 = data[1] + test:shouldBeEqual(row1.id, 1) + test:shouldBeEqual(row1.str, "2") + test:shouldBeEqual(row1.big, 8589934588) + test:shouldBeEqual(row1.bin, string.char(0x47,0x00,0x47)) + test:shouldBeEqual(row1.num, 3.3) + test:shouldBeEqual(row1.bool, 1) + local row2 = data[2] + test:shouldBeEqual(row2.id, 2) + test:shouldBeNil(row2.str) + test:shouldBeEqual(row2.big, -8589930588) + test:shouldBeEqual(row2.bin, string.char(0x00,0xAB)) + test:shouldBeEqual(row2.num, 10.1) + test:shouldBeEqual(row2.bool, 0) + test:Complete() + end + function qu:onError(err) + print(err) + end + qu:start() +end) + +TestFramework:RegisterTest("[Prepared Query] should return correct data if numeric is enabled", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SELECT 1, 2, 4") + qu:setOption(mysqloo.OPTION_NUMERIC_FIELDS) + function qu:onSuccess(data) + test:shouldBeEqual(#data, 1) + local row = data[1] + test:shouldBeEqual(row[1], 1) + test:shouldBeEqual(row[2], 2) + test:shouldBeEqual(row[3], 4) + test:shouldBeNil(row[4]) + test:Complete() + end + qu:start() +end) + +TestFramework:RegisterTest("[Prepared Query] should return correct error", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SEsdg") + function qu:onError(err) + test:shouldBeEqual(qu:error(), err) + test:shouldBeGreaterThan(#qu:error(), 0) + test:Complete() + end + qu:start() +end) + +TestFramework:RegisterTest("[Prepared Query] should return correct error", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SEsdg") + function qu:onError(err) + test:shouldBeEqual(qu:error(), err) + test:shouldBeGreaterThan(#qu:error(), 0) + timer.Simple(0.1, function() + test:shouldBeEqual(qu:error(), err) + test:Complete() + end) + end + qu:start() +end) + +TestFramework:RegisterTest("[Prepared Query] should return correct error if waiting", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SEsdg") + qu:start() + qu:wait() + test:shouldBeGreaterThan(#qu:error(), 0) + test:Complete() +end) + +TestFramework:RegisterTest("[Prepared Query] prevent multiple statements if disabled", function(test) + local db = mysqloo.connect(DatabaseSettings.Host, DatabaseSettings.Username, DatabaseSettings.Password, DatabaseSettings.Database, DatabaseSettings.Port) + db:setMultiStatements(false) + db:connect() + db:wait() + local qu = db:prepare("SELECT 1; SELECT 2;") + function qu:onError() + test:Complete() + end + function qu:onSuccess() + test:Fail("Query should have failed but did not") + end + qu:start() + qu:wait() +end) + +TestFramework:RegisterTest("[Prepared Query] prevent multiple statements even if enabled", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SELECT 1 as a; SELECT 2 as b;") + function qu:onError() + test:Complete() + end + qu:start() +end) + +TestFramework:RegisterTest("[Prepared Query] call onData correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SELECT ? as a UNION ALL SELECT ?") + qu:setNumber(1, 1) + qu:setNumber(2, 2) + local callCount = 0 + local sum = 0 + function qu:onSuccess(data) //onData is called before onSuccess + test:shouldHaveLength(data, 2) + test:shouldBeEqual(callCount, 2) + test:shouldBeEqual(sum, 3) + test:Complete() + end + function qu:onData(row) + callCount = callCount + 1 + sum = sum + row.a + end + qu:start() +end) + +TestFramework:RegisterTest("[Prepared Query] abort query correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:prepare("SELECT SLEEP(1)") //This should block for a bit + qu:start() + local qu2 = db:prepare("SELECT 1") + qu2:start() + function qu2:onAborted() + test:Complete() + end + test:shouldBeEqual(qu2:abort(), true) + test:shouldBeEqual(qu:abort(), false) +end) + +TestFramework:RegisterTest("[Prepared Query] Work with stored procedure correctly", function(test) + local db = TestFramework:ConnectToDatabase() + //db:setMultiStatements(false) + TestFramework:RunQuery(db, "DROP PROCEDURE IF EXISTS test_procedure") + TestFramework:RunQuery(db, [[ + CREATE PROCEDURE test_procedure (IN param INT) + BEGIN + SELECT param as a; + SELECT 999 as b; + END + ]]) + local qu = db:prepare("CALL test_procedure(?)") + qu:setNumber(1, 5) + qu:start() + qu:wait() + test:shouldBeEqual(qu:hasMoreResults(), true) + local first = qu:getData() + test:shouldBeEqual(first[1].a, 5) + qu:getNextResults() + test:shouldBeEqual(qu:hasMoreResults(), true) + local second = qu:getData() + test:shouldBeEqual(second[1].b, 999) + qu:getNextResults() + test:shouldBeEqual(qu:hasMoreResults(), true) //For some reason, stored procedures add extra result sets + qu:getNextResults() + test:shouldBeEqual(qu:hasMoreResults(), false) + test:Complete() +end) \ No newline at end of file diff --git a/IntegrationTest/lua/mysqloo/tests/query_tests.lua b/IntegrationTest/lua/mysqloo/tests/query_tests.lua new file mode 100644 index 0000000..a7fa375 --- /dev/null +++ b/IntegrationTest/lua/mysqloo/tests/query_tests.lua @@ -0,0 +1,253 @@ +TestFramework:RegisterTest("[Query] last insert should return correct values", function(test) + local db = TestFramework:ConnectToDatabase() + TestFramework:RunQuery(db, [[DROP TABLE IF EXISTS last_insert_test]]) + TestFramework:RunQuery(db, [[CREATE TABLE last_insert_test(id INT AUTO_INCREMENT PRIMARY KEY)]]) + + local qu = db:query("INSERT INTO last_insert_test VALUES()") + function qu:onSuccess() + test:shouldBeEqual(qu:lastInsert(), 1) + end + qu:start() + local qu2 = db:query("INSERT INTO last_insert_test VALUES()") + function qu2:onSuccess() + test:shouldBeEqual(qu2:lastInsert(), 2) + end + qu2:start() + local qu3 = db:query("INSERT INTO last_insert_test VALUES()") + function qu3:onSuccess() + test:shouldBeEqual(qu3:lastInsert(), 3) + function qu3:onSuccess() + test:shouldBeEqual(qu3:lastInsert(), 4) + qu3.onSuccess = nil + qu3:start() + qu3:wait() + test:shouldBeEqual(qu3:lastInsert(), 5) + test:Complete() + end + qu3:start() + end + qu3:start() +end) + +TestFramework:RegisterTest("[Query] affected rows should return correct values", function(test) + local db = TestFramework:ConnectToDatabase() + TestFramework:RunQuery(db, [[DROP TABLE IF EXISTS affected_rows_test]]) + TestFramework:RunQuery(db, [[CREATE TABLE affected_rows_test(id INT AUTO_INCREMENT PRIMARY KEY)]]) + TestFramework:RunQuery(db, "INSERT INTO affected_rows_test VALUES()") + TestFramework:RunQuery(db, "INSERT INTO affected_rows_test VALUES()") + TestFramework:RunQuery(db, "INSERT INTO affected_rows_test VALUES()") + TestFramework:RunQuery(db, "INSERT INTO affected_rows_test VALUES()") + local qu = db:query("DELETE FROM affected_rows_test WHERE id = 4") + qu:start() + qu:wait() + test:shouldBeEqual(qu:affectedRows(), 1) + qu:start() + local qu2 = db:query("DELETE FROM affected_rows_test") + function qu2:onSuccess() + test:shouldBeEqual(qu2:affectedRows(), 3) + function qu2:onSuccess() + test:shouldBeEqual(qu2:affectedRows(), 0) + test:Complete() + end + qu2:start() + end + qu2:start() +end) + +TestFramework:RegisterTest("[Query] isRunning should return the correct value", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:query("SELECT SLEEP(0.1)") + test:shouldBeEqual(qu:isRunning(), false) + function qu:onSuccess() + test:shouldBeEqual(qu:isRunning(), true) + timer.Simple(0.1, function() + test:shouldBeEqual(qu:isRunning(), false) + test:Complete() + end) + end + qu:start() + test:shouldBeEqual(qu:isRunning(), true) +end) + +TestFramework:RegisterTest("[Query] should return correct data", function(test) + local db = TestFramework:ConnectToDatabase() + TestFramework:RunQuery(db, [[DROP TABLE IF EXISTS data_test]]) + TestFramework:RunQuery(db, [[CREATE TABLE data_test(id INT PRIMARY KEY, str VARCHAR(10), big BIGINT, bin BLOB, num DOUBLE, bool BIT)]]) + TestFramework:RunQuery(db, [[INSERT INTO data_test VALUES(1, '2', 8589934588, X'470047', 3.3, TRUE)]]) + TestFramework:RunQuery(db, [[INSERT INTO data_test VALUES(2, null, -8589930588, X'00AB', 10.1, FALSE)]]) + + local qu = db:query("SELECT * FROM data_test") + function qu:onSuccess(data) + test:shouldBeEqual(data, qu:getData()) //Check that it is cached correctly + test:shouldBeEqual(#data, 2) + local row1 = data[1] + test:shouldBeEqual(row1.id, 1) + test:shouldBeEqual(row1.str, "2") + test:shouldBeEqual(row1.big, 8589934588) + test:shouldBeEqual(row1.bin, string.char(0x47,0x00,0x47)) + test:shouldBeEqual(row1.num, 3.3) + test:shouldBeEqual(row1.bool, 1) + local row2 = data[2] + test:shouldBeEqual(row2.id, 2) + test:shouldBeNil(row2.str) + test:shouldBeEqual(row2.big, -8589930588) + test:shouldBeEqual(row2.bin, string.char(0x00,0xAB)) + test:shouldBeEqual(row2.num, 10.1) + test:shouldBeEqual(row2.bool, 0) + test:Complete() + end + function qu:onError(err) + print(err) + end + qu:start() +end) + +TestFramework:RegisterTest("[Query] should return correct data if numeric is enabled", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:query("SELECT 1, 2, 4") + qu:setOption(mysqloo.OPTION_NUMERIC_FIELDS) + function qu:onSuccess(data) + test:shouldBeEqual(#data, 1) + local row = data[1] + test:shouldBeEqual(row[1], 1) + test:shouldBeEqual(row[2], 2) + test:shouldBeEqual(row[3], 4) + test:shouldBeNil(row[4]) + test:Complete() + end + qu:start() +end) + +TestFramework:RegisterTest("[Query] should return correct error", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:query("SEsdg") + function qu:onError(err) + test:shouldBeEqual(qu:error(), err) + test:shouldBeGreaterThan(#qu:error(), 0) + test:Complete() + end + qu:start() +end) + +TestFramework:RegisterTest("[Query] should return correct error", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:query("SEsdg") + function qu:onError(err) + test:shouldBeEqual(qu:error(), err) + test:shouldBeGreaterThan(#qu:error(), 0) + timer.Simple(0.1, function() + test:shouldBeEqual(qu:error(), err) + test:Complete() + end) + end + qu:start() +end) + +TestFramework:RegisterTest("[Query] should return correct error if waiting", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:query("SEsdg") + qu:start() + qu:wait() + test:shouldBeGreaterThan(#qu:error(), 0) + test:Complete() +end) + +TestFramework:RegisterTest("[Query] prevent multiple statements if disabled", function(test) + local db = mysqloo.connect(DatabaseSettings.Host, DatabaseSettings.Username, DatabaseSettings.Password, DatabaseSettings.Database, DatabaseSettings.Port) + db:setMultiStatements(false) + db:connect() + db:wait() + local qu = db:query("SELECT 1; SELECT 2;") + function qu:onError() + test:Complete() + end + function qu:onSuccess() + test:Fail("Query should have failed but did not") + end + qu:start() + qu:wait() +end) + +TestFramework:RegisterTest("[Query] work correctly with multi statements and multiple results", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:query("SELECT 1 as a; SELECT 2 as b;") + qu:start() + qu:wait() + local data = qu:getData() + test:shouldBeEqual(#data, 1) + test:shouldBeEqual(data[1].a, 1) + test:shouldBeEqual(qu:hasMoreResults(), true) + + qu:getNextResults() + local newData = qu:getData() + test:shouldNotBeEqual(newData, data) + test:shouldBeEqual(#newData, 1) + test:shouldBeEqual(newData[1].b, 2) + test:shouldBeEqual(qu:hasMoreResults(), true) + qu:getNextResults() + test:shouldBeEqual(qu:hasMoreResults(), false) + test:Complete() +end) + +TestFramework:RegisterTest("[Query] work correctly with multi statements and multiple results with affectedRows/lastInserts", function(test) + local db = TestFramework:ConnectToDatabase() + TestFramework:RunQuery(db, [[DROP TABLE IF EXISTS last_insert_test]]) + TestFramework:RunQuery(db, [[CREATE TABLE last_insert_test(id INT AUTO_INCREMENT PRIMARY KEY)]]) + local qu = db:query("INSERT INTO last_insert_test VALUES(); INSERT INTO last_insert_test VALUES(); INSERT INTO last_insert_test VALUES()") + qu:start() + qu:wait() + test:shouldBeEqual(qu:lastInsert(), 1) + test:shouldBeEqual(qu:hasMoreResults(), true) + qu:getNextResults() + test:shouldBeEqual(qu:lastInsert(), 2) + test:shouldBeEqual(qu:hasMoreResults(), true) + qu:getNextResults() + test:shouldBeEqual(qu:lastInsert(), 3) + test:shouldBeEqual(qu:hasMoreResults(), true) + qu:getNextResults() + test:shouldBeEqual(qu:hasMoreResults(), false) + + local qu2 = db:query("DELETE FROM last_insert_test WHERE id = 1; DELETE FROM last_insert_test") + qu2:start() + qu2:wait() + test:shouldBeEqual(qu2:affectedRows(), 1) + test:shouldBeEqual(qu2:hasMoreResults(), true) + qu2:getNextResults() + test:shouldBeEqual(qu2:affectedRows(), 2) + test:shouldBeEqual(qu2:hasMoreResults(), true) + qu2:getNextResults() + test:shouldBeEqual(qu2:hasMoreResults(), false) + + test:Complete() +end) + +TestFramework:RegisterTest("[Query] call onData correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:query("SELECT 1 as a UNION ALL SELECT 2") + local callCount = 0 + local sum = 0 + function qu:onSuccess(data) //onData is called before onSuccess + test:shouldHaveLength(data, 2) + test:shouldBeEqual(callCount, 2) + test:shouldBeEqual(sum, 3) + test:Complete() + end + function qu:onData(row) + callCount = callCount + 1 + sum = sum + row.a + end + qu:start() +end) + +TestFramework:RegisterTest("[Query] abort query correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local qu = db:query("SELECT SLEEP(1)") //This should block for a bit + qu:start() + local qu2 = db:query("SELECT 1") + qu2:start() + function qu2:onAborted() + test:Complete() + end + test:shouldBeEqual(qu2:abort(), true) + test:shouldBeEqual(qu:abort(), false) +end) \ No newline at end of file diff --git a/IntegrationTest/lua/mysqloo/tests/transaction_test.lua b/IntegrationTest/lua/mysqloo/tests/transaction_test.lua new file mode 100644 index 0000000..6e81465 --- /dev/null +++ b/IntegrationTest/lua/mysqloo/tests/transaction_test.lua @@ -0,0 +1,55 @@ +TestFramework:RegisterTest("[Transaction] should return added queries correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local q1 = db:query("SELECT 1") + local q2 = db:prepare("SELECT ?") + q2:setNumber(2, 2) + local q3 = db:query("SELECT 3") + local transaction = db:createTransaction() + test:shouldHaveLength(transaction:getQueries(), 0) + transaction:addQuery(q1) + transaction:addQuery(q2) + transaction:addQuery(q3) + local queries = transaction:getQueries() + test:shouldHaveLength(transaction:getQueries(), 3) + test:shouldBeEqual(queries[1], q1) + test:shouldBeEqual(queries[2], q2) + test:shouldBeEqual(queries[3], q3) + test:Complete() +end) + +TestFramework:RegisterTest("[Transaction] run transaction with same query correctly", function(test) + local db = TestFramework:ConnectToDatabase() + local transaction = db:createTransaction() + local qu = db:prepare("SELECT ? as a") + qu:setNumber(1, 1) + transaction:addQuery(qu) + qu:setNumber(1, 3) + transaction:addQuery(qu) + function transaction:onSuccess(data) + test:shouldHaveLength(data, 2) + test:shouldBeEqual(data[1][1].a, 1) + test:shouldBeEqual(data[2][1].a, 3) + test:Complete() + end + transaction:start() + transaction:wait() +end) + +TestFramework:RegisterTest("[Transaction] rollback failure correctly", function(test) + local db = TestFramework:ConnectToDatabase() + TestFramework:RunQuery(db, [[DROP TABLE IF EXISTS transaction_test]]) + TestFramework:RunQuery(db, [[CREATE TABLE transaction_test(id INT AUTO_INCREMENT PRIMARY KEY)]]) + local transaction = db:createTransaction() + local qu = db:query("INSERT INTO transaction_test VALUES()") + local qu2 = db:query("gfdgdg") + transaction:addQuery(qu) + transaction:addQuery(qu2) + function transaction:onError() + local qu3 = db:query("SELECT * FROM transaction_test") + qu3:start() + qu3:wait() + test:shouldHaveLength(qu3, 0) + test:Complete() + end + transaction:start() +end) \ No newline at end of file diff --git a/MySQL/include/errmsg.h b/MySQL/include/errmsg.h index 419f03b..7ca3238 100644 --- a/MySQL/include/errmsg.h +++ b/MySQL/include/errmsg.h @@ -1,137 +1,107 @@ -#ifndef ERRMSG_INCLUDED -#define ERRMSG_INCLUDED - -/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2.0, - as published by the Free Software Foundation. - - This program is also distributed with certain software (including - but not limited to OpenSSL) that is licensed under separate terms, - as designated in a particular file or component or in included license - documentation. The authors of MySQL hereby grant you an additional - permission to link the program and your derivative works with the - separately licensed software that they have included with MySQL. - - Without limiting anything contained in the foregoing, this file, - which is part of C Driver for MySQL (Connector/C), is also subject to the - Universal FOSS Exception, version 1.0, a copy of which can be found at - http://oss.oracle.com/licenses/universal-foss-exception. - - This program is distributed in the hope that it will be useful, +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + 2012-2016 SkySQL AB, MariaDB Corporation AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License, version 2.0, for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -/** - @file include/errmsg.h - - Error messages for MySQL clients. - These are constant and use the CR_ prefix. - will contain auto-generated mappings - containing the symbolic name and the number from this file, - and the english error messages in libmysql/errmsg.c. - - Dynamic error messages for the daemon are in share/language/errmsg.sys. - The server equivalent to is . - The server equivalent to is . - - Note that the auth subsystem also uses codes with a CR_ prefix. -*/ - -void init_client_errs(void); -void finish_client_errs(void); -extern const char *client_errors[]; /* Error messages */ - -#define CR_MIN_ERROR 2000 /* For easier client code */ -#define CR_MAX_ERROR 2999 -#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */ - -/* Do not add error numbers before CR_ERROR_FIRST. */ -/* If necessary to add lower numbers, change CR_ERROR_FIRST accordingly. */ -#define CR_ERROR_FIRST 2000 /*Copy first error nr.*/ -#define CR_UNKNOWN_ERROR 2000 -#define CR_SOCKET_CREATE_ERROR 2001 -#define CR_CONNECTION_ERROR 2002 -#define CR_CONN_HOST_ERROR 2003 -#define CR_IPSOCK_ERROR 2004 -#define CR_UNKNOWN_HOST 2005 -#define CR_SERVER_GONE_ERROR 2006 -#define CR_VERSION_ERROR 2007 -#define CR_OUT_OF_MEMORY 2008 -#define CR_WRONG_HOST_INFO 2009 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02111-1301, USA */ + +/* Error messages for mysql clients */ +/* error messages for the demon is in share/language/errmsg.sys */ +#ifndef _errmsg_h_ +#define _errmsg_h_ + +#ifdef __cplusplus +extern "C" { +#endif +void init_client_errs(void); +extern const char *client_errors[]; /* Error messages */ +extern const char *mariadb_client_errors[]; /* Error messages */ +#ifdef __cplusplus +} +#endif + + + +#define CR_MIN_ERROR 2000 /* For easier client code */ +#define CR_MAX_ERROR 2999 +#define CER_MIN_ERROR 5000 +#define CER_MAX_ERROR 5999 +#define CER(X) mariadb_client_errors[(X)-CER_MIN_ERROR] +#define ER(X) client_errors[(X)-CR_MIN_ERROR] +#define CLIENT_ERRMAP 2 /* Errormap used by ma_error() */ + +#define CR_UNKNOWN_ERROR 2000 +#define CR_SOCKET_CREATE_ERROR 2001 +#define CR_CONNECTION_ERROR 2002 +#define CR_CONN_HOST_ERROR 2003 /* never sent to a client, message only */ +#define CR_IPSOCK_ERROR 2004 +#define CR_UNKNOWN_HOST 2005 +#define CR_SERVER_GONE_ERROR 2006 /* disappeared _between_ queries */ +#define CR_VERSION_ERROR 2007 +#define CR_OUT_OF_MEMORY 2008 +#define CR_WRONG_HOST_INFO 2009 #define CR_LOCALHOST_CONNECTION 2010 -#define CR_TCP_CONNECTION 2011 +#define CR_TCP_CONNECTION 2011 #define CR_SERVER_HANDSHAKE_ERR 2012 -#define CR_SERVER_LOST 2013 +#define CR_SERVER_LOST 2013 /* disappeared _during_ a query */ #define CR_COMMANDS_OUT_OF_SYNC 2014 #define CR_NAMEDPIPE_CONNECTION 2015 #define CR_NAMEDPIPEWAIT_ERROR 2016 #define CR_NAMEDPIPEOPEN_ERROR 2017 #define CR_NAMEDPIPESETSTATE_ERROR 2018 -#define CR_CANT_READ_CHARSET 2019 +#define CR_CANT_READ_CHARSET 2019 #define CR_NET_PACKET_TOO_LARGE 2020 -#define CR_EMBEDDED_CONNECTION 2021 -#define CR_PROBE_SLAVE_STATUS 2022 -#define CR_PROBE_SLAVE_HOSTS 2023 -#define CR_PROBE_SLAVE_CONNECT 2024 -#define CR_PROBE_MASTER_CONNECT 2025 #define CR_SSL_CONNECTION_ERROR 2026 -#define CR_MALFORMED_PACKET 2027 -#define CR_WRONG_LICENSE 2028 - -/* new 4.1 error codes */ -#define CR_NULL_POINTER 2029 -#define CR_NO_PREPARE_STMT 2030 -#define CR_PARAMS_NOT_BOUND 2031 -#define CR_DATA_TRUNCATED 2032 -#define CR_NO_PARAMETERS_EXISTS 2033 -#define CR_INVALID_PARAMETER_NO 2034 -#define CR_INVALID_BUFFER_USE 2035 +#define CR_MALFORMED_PACKET 2027 +#define CR_NO_PREPARE_STMT 2030 +#define CR_PARAMS_NOT_BOUND 2031 +#define CR_INVALID_PARAMETER_NO 2034 +#define CR_INVALID_BUFFER_USE 2035 #define CR_UNSUPPORTED_PARAM_TYPE 2036 #define CR_SHARED_MEMORY_CONNECTION 2037 -#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2038 -#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2039 -#define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2040 -#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2041 -#define CR_SHARED_MEMORY_FILE_MAP_ERROR 2042 -#define CR_SHARED_MEMORY_MAP_ERROR 2043 -#define CR_SHARED_MEMORY_EVENT_ERROR 2044 -#define CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR 2045 -#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2046 -#define CR_CONN_UNKNOW_PROTOCOL 2047 -#define CR_INVALID_CONN_HANDLE 2048 -#define CR_UNUSED_1 2049 -#define CR_FETCH_CANCELED 2050 -#define CR_NO_DATA 2051 -#define CR_NO_STMT_METADATA 2052 -#define CR_NO_RESULT_SET 2053 -#define CR_NOT_IMPLEMENTED 2054 -#define CR_SERVER_LOST_EXTENDED 2055 -#define CR_STMT_CLOSED 2056 -#define CR_NEW_STMT_METADATA 2057 -#define CR_ALREADY_CONNECTED 2058 +#define CR_SHARED_MEMORY_CONNECT_ERROR 2038 + +#define CR_CONN_UNKNOWN_PROTOCOL 2047 +#define CR_SECURE_AUTH 2049 +#define CR_NO_DATA 2051 +#define CR_NO_STMT_METADATA 2052 +#define CR_NOT_IMPLEMENTED 2054 +#define CR_SERVER_LOST_EXTENDED 2055 /* never sent to a client, message only */ +#define CR_STMT_CLOSED 2056 +#define CR_NEW_STMT_METADATA 2057 +#define CR_ALREADY_CONNECTED 2058 #define CR_AUTH_PLUGIN_CANNOT_LOAD 2059 #define CR_DUPLICATE_CONNECTION_ATTR 2060 #define CR_AUTH_PLUGIN_ERR 2061 -#define CR_INSECURE_API_ERR 2062 -#define CR_FILE_NAME_TOO_LONG 2063 -#define CR_SSL_FIPS_MODE_ERR 2064 -#define CR_COMPRESSION_NOT_SUPPORTED 2065 -#define CR_ERROR_LAST /*Copy last error nr:*/ 2065 -/* Add error numbers before CR_ERROR_LAST and change it accordingly. */ - -/* Visual Studio requires '__inline' for C code */ -static inline const char *ER_CLIENT(int client_errno) { - if (client_errno >= CR_ERROR_FIRST && client_errno <= CR_ERROR_LAST) - return client_errors[client_errno - CR_ERROR_FIRST]; - return client_errors[CR_UNKNOWN_ERROR]; -} - -#endif /* ERRMSG_INCLUDED */ +/* Always last, if you add new error codes please update the + value for CR_MYSQL_LAST_ERROR */ +#define CR_MYSQL_LAST_ERROR CR_AUTH_PLUGIN_ERR + +/* + * MariaDB Connector/C errors: + */ +#define CR_EVENT_CREATE_FAILED 5000 +#define CR_BIND_ADDR_FAILED 5001 +#define CR_ASYNC_NOT_SUPPORTED 5002 +#define CR_FUNCTION_NOT_SUPPORTED 5003 +#define CR_FILE_NOT_FOUND 5004 +#define CR_FILE_READ 5005 +#define CR_BULK_WITHOUT_PARAMETERS 5006 +#define CR_INVALID_STMT 5007 +#define CR_VERSION_MISMATCH 5008 +/* Always last, if you add new error codes please update the + value for CR_MARIADB_LAST_ERROR */ +#define CR_MARIADB_LAST_ERROR CR_VERSION_MISMATCH +#endif diff --git a/MySQL/include/field_types.h b/MySQL/include/field_types.h deleted file mode 100644 index 9485138..0000000 --- a/MySQL/include/field_types.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2.0, - as published by the Free Software Foundation. - - This program is also distributed with certain software (including - but not limited to OpenSSL) that is licensed under separate terms, - as designated in a particular file or component or in included license - documentation. The authors of MySQL hereby grant you an additional - permission to link the program and your derivative works with the - separately licensed software that they have included with MySQL. - - Without limiting anything contained in the foregoing, this file, - which is part of C Driver for MySQL (Connector/C), is also subject to the - Universal FOSS Exception, version 1.0, a copy of which can be found at - http://oss.oracle.com/licenses/universal-foss-exception. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License, version 2.0, for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -/** - @file field_types.h - - @brief This file contains the field type. - - - @note This file can be imported both from C and C++ code, so the - definitions have to be constructed to support this. -*/ - -#ifndef FIELD_TYPES_INCLUDED -#define FIELD_TYPES_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * Constants exported from this package. - */ - -/** - Column types for MySQL -*/ -enum enum_field_types -#if defined(__cplusplus) && __cplusplus > 201103L - // N2764: Forward enum declarations, added in C++11 - : int -#endif /* __cplusplus */ -{ MYSQL_TYPE_DECIMAL, - MYSQL_TYPE_TINY, - MYSQL_TYPE_SHORT, - MYSQL_TYPE_LONG, - MYSQL_TYPE_FLOAT, - MYSQL_TYPE_DOUBLE, - MYSQL_TYPE_NULL, - MYSQL_TYPE_TIMESTAMP, - MYSQL_TYPE_LONGLONG, - MYSQL_TYPE_INT24, - MYSQL_TYPE_DATE, - MYSQL_TYPE_TIME, - MYSQL_TYPE_DATETIME, - MYSQL_TYPE_YEAR, - MYSQL_TYPE_NEWDATE, /**< Internal to MySQL. Not used in protocol */ - MYSQL_TYPE_VARCHAR, - MYSQL_TYPE_BIT, - MYSQL_TYPE_TIMESTAMP2, - MYSQL_TYPE_DATETIME2, /**< Internal to MySQL. Not used in protocol */ - MYSQL_TYPE_TIME2, /**< Internal to MySQL. Not used in protocol */ - MYSQL_TYPE_TYPED_ARRAY = 244, /** Used for replication only */ - MYSQL_TYPE_JSON = 245, - MYSQL_TYPE_NEWDECIMAL = 246, - MYSQL_TYPE_ENUM = 247, - MYSQL_TYPE_SET = 248, - MYSQL_TYPE_TINY_BLOB = 249, - MYSQL_TYPE_MEDIUM_BLOB = 250, - MYSQL_TYPE_LONG_BLOB = 251, - MYSQL_TYPE_BLOB = 252, - MYSQL_TYPE_VAR_STRING = 253, - MYSQL_TYPE_STRING = 254, - MYSQL_TYPE_GEOMETRY = 255 }; - -#ifdef __cplusplus -} // extern "C" -#else -typedef enum enum_field_types enum_field_types; -#endif /* __cplusplus */ - -#endif /* FIELD_TYPES_INCLUDED */ diff --git a/MySQL/include/ma_io.h b/MySQL/include/ma_io.h new file mode 100644 index 0000000..d39fc06 --- /dev/null +++ b/MySQL/include/ma_io.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2015 MariaDB Corporation AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02111-1301, USA */ + +#ifndef _ma_io_h_ +#define _ma_io_h_ + + +#ifdef HAVE_REMOTEIO +#include +#endif + +enum enum_file_type { + MA_FILE_NONE=0, + MA_FILE_LOCAL=1, + MA_FILE_REMOTE=2 +}; + +typedef struct +{ + enum enum_file_type type; + void *ptr; +} MA_FILE; + +#ifdef HAVE_REMOTEIO +struct st_rio_methods { + MA_FILE *(*mopen)(const char *url, const char *mode); + int (*mclose)(MA_FILE *ptr); + int (*mfeof)(MA_FILE *file); + size_t (*mread)(void *ptr, size_t size, size_t nmemb, MA_FILE *file); + char * (*mgets)(char *ptr, size_t size, MA_FILE *file); +}; +#endif + +/* function prototypes */ +MA_FILE *ma_open(const char *location, const char *mode, MYSQL *mysql); +int ma_close(MA_FILE *file); +int ma_feof(MA_FILE *file); +size_t ma_read(void *ptr, size_t size, size_t nmemb, MA_FILE *file); +char *ma_gets(char *ptr, size_t size, MA_FILE *file); + +#endif diff --git a/MySQL/include/ma_list.h b/MySQL/include/ma_list.h new file mode 100644 index 0000000..ccd2bbd --- /dev/null +++ b/MySQL/include/ma_list.h @@ -0,0 +1,47 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02111-1301, USA */ + +#ifndef _list_h_ +#define _list_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct st_list { + struct st_list *prev,*next; + void *data; +} LIST; + +typedef int (*list_walk_action)(void *,void *); + +extern LIST *list_add(LIST *root,LIST *element); +extern LIST *list_delete(LIST *root,LIST *element); +extern LIST *list_cons(void *data,LIST *root); +extern LIST *list_reverse(LIST *root); +extern void list_free(LIST *root,unsigned int free_data); +extern unsigned int list_length(LIST *list); +extern int list_walk(LIST *list,list_walk_action action,char * argument); + +#define list_rest(a) ((a)->next) +#define list_push(a,b) (a)=list_cons((b),(a)) +#define list_pop(A) do {LIST *old=(A); (A)=list_delete(old,old) ; ma_free((char *) old,MYF(MY_FAE)); } while(0) + +#ifdef __cplusplus +} +#endif +#endif diff --git a/MySQL/include/ma_pvio.h b/MySQL/include/ma_pvio.h new file mode 100644 index 0000000..05a0748 --- /dev/null +++ b/MySQL/include/ma_pvio.h @@ -0,0 +1,139 @@ +#ifndef _ma_pvio_h_ +#define _ma_pvio_h_ +#define cio_defined + +#ifdef HAVE_TLS +#include +#else +#define MARIADB_TLS void +#endif + +/* CONC-492: Allow to buuld plugins outside of MariaDB Connector/C + source tree wnen ma_global.h was not included. */ +#if !defined(_global_h) && !defined(MY_GLOBAL_INCLUDED) +typedef unsigned char uchar; +#endif + +#define PVIO_SET_ERROR if (pvio->set_error) \ + pvio->set_error + +#define PVIO_READ_AHEAD_CACHE_SIZE 16384 +#define PVIO_READ_AHEAD_CACHE_MIN_SIZE 2048 +#define PVIO_EINTR_TRIES 2 + +struct st_ma_pvio_methods; +typedef struct st_ma_pvio_methods PVIO_METHODS; + +#define IS_PVIO_ASYNC(a) \ + ((a)->mysql && (a)->mysql->options.extension && (a)->mysql->options.extension->async_context) + +#define IS_PVIO_ASYNC_ACTIVE(a) \ + (IS_PVIO_ASYNC(a)&& (a)->mysql->options.extension->async_context->active) + +#define IS_MYSQL_ASYNC(a) \ + ((a)->options.extension && (a)->options.extension->async_context) + +#define IS_MYSQL_ASYNC_ACTIVE(a) \ + (IS_MYSQL_ASYNC(a)&& (a)->options.extension->async_context->active) + +enum enum_pvio_timeout { + PVIO_CONNECT_TIMEOUT= 0, + PVIO_READ_TIMEOUT, + PVIO_WRITE_TIMEOUT +}; + +enum enum_pvio_io_event +{ + VIO_IO_EVENT_READ, + VIO_IO_EVENT_WRITE, + VIO_IO_EVENT_CONNECT +}; + +enum enum_pvio_type { + PVIO_TYPE_UNIXSOCKET= 0, + PVIO_TYPE_SOCKET, + PVIO_TYPE_NAMEDPIPE, + PVIO_TYPE_SHAREDMEM, +}; + +enum enum_pvio_operation { + PVIO_READ= 0, + PVIO_WRITE=1 +}; + +#define SHM_DEFAULT_NAME "MYSQL" + +struct st_pvio_callback; + +typedef struct st_pvio_callback { + void (*callback)(MYSQL *mysql, uchar *buffer, size_t size); + struct st_pvio_callback *next; +} PVIO_CALLBACK; + +struct st_ma_pvio { + void *data; + /* read ahead cache */ + uchar *cache; + uchar *cache_pos; + size_t cache_size; + enum enum_pvio_type type; + int timeout[3]; + int ssl_type; /* todo: change to enum (ssl plugins) */ + MARIADB_TLS *ctls; + MYSQL *mysql; + PVIO_METHODS *methods; + void (*set_error)(MYSQL *mysql, unsigned int error_nr, const char *sqlstate, const char *format, ...); + void (*callback)(MARIADB_PVIO *pvio, my_bool is_read, const uchar *buffer, size_t length); +}; + +typedef struct st_ma_pvio_cinfo +{ + const char *host; + const char *unix_socket; + int port; + enum enum_pvio_type type; + MYSQL *mysql; +} MA_PVIO_CINFO; + +struct st_ma_pvio_methods +{ + my_bool (*set_timeout)(MARIADB_PVIO *pvio, enum enum_pvio_timeout type, int timeout); + int (*get_timeout)(MARIADB_PVIO *pvio, enum enum_pvio_timeout type); + ssize_t (*read)(MARIADB_PVIO *pvio, uchar *buffer, size_t length); + ssize_t (*async_read)(MARIADB_PVIO *pvio, uchar *buffer, size_t length); + ssize_t (*write)(MARIADB_PVIO *pvio, const uchar *buffer, size_t length); + ssize_t (*async_write)(MARIADB_PVIO *pvio, const uchar *buffer, size_t length); + int (*wait_io_or_timeout)(MARIADB_PVIO *pvio, my_bool is_read, int timeout); + int (*blocking)(MARIADB_PVIO *pvio, my_bool value, my_bool *old_value); + my_bool (*connect)(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo); + my_bool (*close)(MARIADB_PVIO *pvio); + int (*fast_send)(MARIADB_PVIO *pvio); + int (*keepalive)(MARIADB_PVIO *pvio); + my_bool (*get_handle)(MARIADB_PVIO *pvio, void *handle); + my_bool (*is_blocking)(MARIADB_PVIO *pvio); + my_bool (*is_alive)(MARIADB_PVIO *pvio); + my_bool (*has_data)(MARIADB_PVIO *pvio, ssize_t *data_len); + int(*shutdown)(MARIADB_PVIO *pvio); +}; + +/* Function prototypes */ +MARIADB_PVIO *ma_pvio_init(MA_PVIO_CINFO *cinfo); +void ma_pvio_close(MARIADB_PVIO *pvio); +ssize_t ma_pvio_cache_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length); +ssize_t ma_pvio_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length); +ssize_t ma_pvio_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length); +int ma_pvio_get_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type); +my_bool ma_pvio_set_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type, int timeout); +int ma_pvio_fast_send(MARIADB_PVIO *pvio); +int ma_pvio_keepalive(MARIADB_PVIO *pvio); +my_socket ma_pvio_get_socket(MARIADB_PVIO *pvio); +my_bool ma_pvio_is_blocking(MARIADB_PVIO *pvio); +my_bool ma_pvio_blocking(MARIADB_PVIO *pvio, my_bool block, my_bool *previous_mode); +my_bool ma_pvio_is_blocking(MARIADB_PVIO *pvio); +int ma_pvio_wait_io_or_timeout(MARIADB_PVIO *pvio, my_bool is_read, int timeout); +my_bool ma_pvio_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo); +my_bool ma_pvio_is_alive(MARIADB_PVIO *pvio); +my_bool ma_pvio_get_handle(MARIADB_PVIO *pvio, void *handle); +my_bool ma_pvio_has_data(MARIADB_PVIO *pvio, ssize_t *length); + +#endif /* _ma_pvio_h_ */ diff --git a/MySQL/include/ma_tls.h b/MySQL/include/ma_tls.h new file mode 100644 index 0000000..9ce49e7 --- /dev/null +++ b/MySQL/include/ma_tls.h @@ -0,0 +1,161 @@ +#ifndef _ma_tls_h_ +#define _ma_tls_h_ + +enum enum_pvio_tls_type { + SSL_TYPE_DEFAULT=0, +#ifdef _WIN32 + SSL_TYPE_SCHANNEL, +#endif + SSL_TYPE_OPENSSL, + SSL_TYPE_GNUTLS +}; + +#define PROTOCOL_SSLV3 0 +#define PROTOCOL_TLS_1_0 1 +#define PROTOCOL_TLS_1_1 2 +#define PROTOCOL_TLS_1_2 3 +#define PROTOCOL_TLS_1_3 4 +#define PROTOCOL_UNKNOWN 5 +#define PROTOCOL_MAX PROTOCOL_TLS_1_3 + +#define TLS_VERSION_LENGTH 64 +extern char tls_library_version[TLS_VERSION_LENGTH]; + +typedef struct st_ma_pvio_tls { + void *data; + MARIADB_PVIO *pvio; + void *ssl; +} MARIADB_TLS; + +/* Function prototypes */ + +/* ma_tls_start + initializes the ssl library + Parameter: + errmsg pointer to error message buffer + errmsg_len length of error message buffer + Returns: + 0 success + 1 if an error occurred + Notes: + On success the global variable ma_tls_initialized will be set to 1 +*/ +int ma_tls_start(char *errmsg, size_t errmsg_len); + +/* ma_tls_end + unloads/deinitializes ssl library and unsets global variable + ma_tls_initialized +*/ +void ma_tls_end(void); + +/* ma_tls_init + creates a new SSL structure for a SSL connection and loads + client certificates + + Parameters: + MYSQL a mysql structure + Returns: + void * a pointer to internal SSL structure +*/ +void * ma_tls_init(MYSQL *mysql); + +/* ma_tls_connect + performs SSL handshake + Parameters: + MARIADB_TLS MariaDB SSL container + Returns: + 0 success + 1 error +*/ +my_bool ma_tls_connect(MARIADB_TLS *ctls); + +/* ma_tls_read + reads up to length bytes from socket + Parameters: + ctls MariaDB SSL container + buffer read buffer + length buffer length + Returns: + 0-n bytes read + -1 if an error occurred +*/ +ssize_t ma_tls_read(MARIADB_TLS *ctls, const uchar* buffer, size_t length); + +/* ma_tls_write + write buffer to socket + Parameters: + ctls MariaDB SSL container + buffer write buffer + length buffer length + Returns: + 0-n bytes written + -1 if an error occurred +*/ +ssize_t ma_tls_write(MARIADB_TLS *ctls, const uchar* buffer, size_t length); + +/* ma_tls_close + closes SSL connection and frees SSL structure which was previously + created by ma_tls_init call + Parameters: + MARIADB_TLS MariaDB SSL container + Returns: + 0 success + 1 error +*/ +my_bool ma_tls_close(MARIADB_TLS *ctls); + +/* ma_tls_verify_server_cert + validation check of server certificate + Parameter: + MARIADB_TLS MariaDB SSL container + Returns: + ß success + 1 error +*/ +int ma_tls_verify_server_cert(MARIADB_TLS *ctls); + +/* ma_tls_get_cipher + returns cipher for current ssl connection + Parameter: + MARIADB_TLS MariaDB SSL container + Returns: + cipher in use or + NULL on error +*/ +const char *ma_tls_get_cipher(MARIADB_TLS *ssl); + +/* ma_tls_get_finger_print + returns SHA1 finger print of server certificate + Parameter: + MARIADB_TLS MariaDB SSL container + fp buffer for fingerprint + fp_len buffer length + Returns: + actual size of finger print +*/ +unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, char *fp, unsigned int fp_len); + +/* ma_tls_get_protocol_version + returns protocol version number in use + Parameter: + MARIADB_TLS MariaDB SSL container + Returns: + protocol number +*/ +int ma_tls_get_protocol_version(MARIADB_TLS *ctls); +const char *ma_pvio_tls_get_protocol_version(MARIADB_TLS *ctls); +int ma_pvio_tls_get_protocol_version_id(MARIADB_TLS *ctls); + +/* Function prototypes */ +MARIADB_TLS *ma_pvio_tls_init(MYSQL *mysql); +my_bool ma_pvio_tls_connect(MARIADB_TLS *ctls); +ssize_t ma_pvio_tls_read(MARIADB_TLS *ctls, const uchar *buffer, size_t length); +ssize_t ma_pvio_tls_write(MARIADB_TLS *ctls, const uchar *buffer, size_t length); +my_bool ma_pvio_tls_close(MARIADB_TLS *ctls); +int ma_pvio_tls_verify_server_cert(MARIADB_TLS *ctls); +const char *ma_pvio_tls_cipher(MARIADB_TLS *ctls); +my_bool ma_pvio_tls_check_fp(MARIADB_TLS *ctls, const char *fp, const char *fp_list); +my_bool ma_pvio_start_ssl(MARIADB_PVIO *pvio); +void ma_pvio_tls_end(); + +#endif /* _ma_tls_h_ */ diff --git a/MySQL/include/mariadb_com.h b/MySQL/include/mariadb_com.h new file mode 100644 index 0000000..a1b99a8 --- /dev/null +++ b/MySQL/include/mariadb_com.h @@ -0,0 +1,466 @@ +/************************************************************************************ + Copyright (C) 2000, 2012 MySQL AB & MySQL Finland AB & TCX DataKonsult AB, + Monty Program AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not see + or write to the Free Software Foundation, Inc., + 51 Franklin St., Fifth Floor, Boston, MA 02110, USA + + Part of this code includes code from the PHP project which + is freely available from http://www.php.net +*************************************************************************************/ + +/* +** Common definition between mysql server & client +*/ + +#ifndef _mysql_com_h +#define _mysql_com_h + + +#define NAME_CHAR_LEN 64 +#define NAME_LEN 256 /* Field/table name length */ +#define HOSTNAME_LENGTH 60 +#define SYSTEM_MB_MAX_CHAR_LENGTH 4 +#define USERNAME_CHAR_LENGTH 128 +#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH * SYSTEM_MB_MAX_CHAR_LENGTH) +#define SERVER_VERSION_LENGTH 60 +#define SQLSTATE_LENGTH 5 +#define SCRAMBLE_LENGTH 20 +#define SCRAMBLE_LENGTH_323 8 + +#define LOCAL_HOST "localhost" +#define LOCAL_HOST_NAMEDPIPE "." + +#if defined(_WIN32) && !defined( _CUSTOMCONFIG_) +#define MARIADB_NAMEDPIPE "MySQL" +#define MYSQL_SERVICENAME "MySql" +#endif /* _WIN32 */ + +/* for use in mysql client tools only */ +#define MYSQL_AUTODETECT_CHARSET_NAME "auto" +#define BINCMP_FLAG 131072 + +enum mysql_enum_shutdown_level +{ + SHUTDOWN_DEFAULT = 0, + KILL_QUERY= 254, + KILL_CONNECTION= 255 +}; + +enum enum_server_command +{ + COM_SLEEP = 0, + COM_QUIT, + COM_INIT_DB, + COM_QUERY, + COM_FIELD_LIST, + COM_CREATE_DB, + COM_DROP_DB, + COM_REFRESH, + COM_SHUTDOWN, + COM_STATISTICS, + COM_PROCESS_INFO, + COM_CONNECT, + COM_PROCESS_KILL, + COM_DEBUG, + COM_PING, + COM_TIME = 15, + COM_DELAYED_INSERT, + COM_CHANGE_USER, + COM_BINLOG_DUMP, + COM_TABLE_DUMP, + COM_CONNECT_OUT = 20, + COM_REGISTER_SLAVE, + COM_STMT_PREPARE = 22, + COM_STMT_EXECUTE = 23, + COM_STMT_SEND_LONG_DATA = 24, + COM_STMT_CLOSE = 25, + COM_STMT_RESET = 26, + COM_SET_OPTION = 27, + COM_STMT_FETCH = 28, + COM_DAEMON= 29, + COM_UNSUPPORTED= 30, + COM_RESET_CONNECTION = 31, + COM_STMT_BULK_EXECUTE = 250, + COM_RESERVED_1 = 254, /* former COM_MULTI, now removed */ + COM_END +}; + + +#define NOT_NULL_FLAG 1 /* Field can't be NULL */ +#define PRI_KEY_FLAG 2 /* Field is part of a primary key */ +#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */ +#define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */ +#define BLOB_FLAG 16 /* Field is a blob */ +#define UNSIGNED_FLAG 32 /* Field is unsigned */ +#define ZEROFILL_FLAG 64 /* Field is zerofill */ +#define BINARY_FLAG 128 +/* The following are only sent to new clients */ +#define ENUM_FLAG 256 /* field is an enum */ +#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */ +#define TIMESTAMP_FLAG 1024 /* Field is a timestamp */ +#define SET_FLAG 2048 /* field is a set */ +/* new since 3.23.58 */ +#define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */ +#define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */ +/* end new */ +#define NUM_FLAG 32768 /* Field is num (for clients) */ +#define PART_KEY_FLAG 16384 /* Intern; Part of some key */ +#define GROUP_FLAG 32768 /* Intern: Group field */ +#define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */ + +#define REFRESH_GRANT 1 /* Refresh grant tables */ +#define REFRESH_LOG 2 /* Start on new log file */ +#define REFRESH_TABLES 4 /* close all tables */ +#define REFRESH_HOSTS 8 /* Flush host cache */ +#define REFRESH_STATUS 16 /* Flush status variables */ +#define REFRESH_THREADS 32 /* Flush thread cache */ +#define REFRESH_SLAVE 64 /* Reset master info and restart slave + thread */ +#define REFRESH_MASTER 128 /* Remove all bin logs in the index + and truncate the index */ + +/* The following can't be set with mysql_refresh() */ +#define REFRESH_READ_LOCK 16384 /* Lock tables for read */ +#define REFRESH_FAST 32768 /* Intern flag */ + +#define CLIENT_MYSQL 1 +#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */ +#define CLIENT_LONG_FLAG 4 /* Get all column flags */ +#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */ +#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */ +#define CLIENT_COMPRESS 32 /* Can use compression protocol */ +#define CLIENT_ODBC 64 /* Odbc client */ +#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */ +#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */ +#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */ +#define CLIENT_SSL 2048 /* Switch to SSL after handshake */ +#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */ +#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */ +/* added in 4.x */ +#define CLIENT_PROTOCOL_41 512 +#define CLIENT_RESERVED 16384 +#define CLIENT_SECURE_CONNECTION 32768 +#define CLIENT_MULTI_STATEMENTS (1UL << 16) +#define CLIENT_MULTI_RESULTS (1UL << 17) +#define CLIENT_PS_MULTI_RESULTS (1UL << 18) +#define CLIENT_PLUGIN_AUTH (1UL << 19) +#define CLIENT_CONNECT_ATTRS (1UL << 20) +#define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21) +#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22) +#define CLIENT_SESSION_TRACKING (1UL << 23) +#define CLIENT_PROGRESS (1UL << 29) /* client supports progress indicator */ +#define CLIENT_PROGRESS_OBSOLETE CLIENT_PROGRESS +#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) +#define CLIENT_REMEMBER_OPTIONS (1UL << 31) + +/* MariaDB specific capabilities */ +#define MARIADB_CLIENT_FLAGS 0xFFFFFFFF00000000ULL +#define MARIADB_CLIENT_PROGRESS (1ULL << 32) +#define MARIADB_CLIENT_RESERVED_1 (1ULL << 33) /* Former COM_MULTI, don't use */ +#define MARIADB_CLIENT_STMT_BULK_OPERATIONS (1ULL << 34) +/* support of extended data type/format information, since 10.5.0 */ +#define MARIADB_CLIENT_EXTENDED_METADATA (1ULL << 35) + +#define IS_MARIADB_EXTENDED_SERVER(mysql)\ + (!(mysql->server_capabilities & CLIENT_MYSQL)) + +#define MARIADB_CLIENT_SUPPORTED_FLAGS (MARIADB_CLIENT_PROGRESS |\ + MARIADB_CLIENT_STMT_BULK_OPERATIONS|\ + MARIADB_CLIENT_EXTENDED_METADATA) + +#define CLIENT_SUPPORTED_FLAGS (CLIENT_MYSQL |\ + CLIENT_FOUND_ROWS |\ + CLIENT_LONG_FLAG |\ + CLIENT_CONNECT_WITH_DB |\ + CLIENT_NO_SCHEMA |\ + CLIENT_COMPRESS |\ + CLIENT_ODBC |\ + CLIENT_LOCAL_FILES |\ + CLIENT_IGNORE_SPACE |\ + CLIENT_INTERACTIVE |\ + CLIENT_SSL |\ + CLIENT_IGNORE_SIGPIPE |\ + CLIENT_TRANSACTIONS |\ + CLIENT_PROTOCOL_41 |\ + CLIENT_RESERVED |\ + CLIENT_SECURE_CONNECTION |\ + CLIENT_MULTI_STATEMENTS |\ + CLIENT_MULTI_RESULTS |\ + CLIENT_PROGRESS |\ + CLIENT_SSL_VERIFY_SERVER_CERT |\ + CLIENT_REMEMBER_OPTIONS |\ + CLIENT_PLUGIN_AUTH |\ + CLIENT_SESSION_TRACKING |\ + CLIENT_CONNECT_ATTRS) +#define CLIENT_CAPABILITIES (CLIENT_MYSQL | \ + CLIENT_LONG_FLAG |\ + CLIENT_TRANSACTIONS |\ + CLIENT_SECURE_CONNECTION |\ + CLIENT_MULTI_RESULTS | \ + CLIENT_PS_MULTI_RESULTS |\ + CLIENT_PROTOCOL_41 |\ + CLIENT_PLUGIN_AUTH |\ + CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \ + CLIENT_SESSION_TRACKING |\ + CLIENT_CONNECT_ATTRS) + +#define CLIENT_DEFAULT_FLAGS ((CLIENT_SUPPORTED_FLAGS & ~CLIENT_COMPRESS)\ + & ~CLIENT_SSL) + +#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ +#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ +#define SERVER_MORE_RESULTS_EXIST 8 +#define SERVER_QUERY_NO_GOOD_INDEX_USED 16 +#define SERVER_QUERY_NO_INDEX_USED 32 +#define SERVER_STATUS_CURSOR_EXISTS 64 +#define SERVER_STATUS_LAST_ROW_SENT 128 +#define SERVER_STATUS_DB_DROPPED 256 +#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512 +#define SERVER_STATUS_METADATA_CHANGED 1024 +#define SERVER_QUERY_WAS_SLOW 2048 +#define SERVER_PS_OUT_PARAMS 4096 +#define SERVER_STATUS_IN_TRANS_READONLY 8192 +#define SERVER_SESSION_STATE_CHANGED 16384 +#define SERVER_STATUS_ANSI_QUOTES 32768 + +#define MYSQL_ERRMSG_SIZE 512 +#define NET_READ_TIMEOUT 30 /* Timeout on read */ +#define NET_WRITE_TIMEOUT 60 /* Timeout on write */ +#define NET_WAIT_TIMEOUT (8*60*60) /* Wait for new query */ + +/* for server integration (mysqlbinlog) */ +#define LIST_PROCESS_HOST_LEN 64 +#define MYSQL50_TABLE_NAME_PREFIX "#mysql50#" +#define MYSQL50_TABLE_NAME_PREFIX_LENGTH (sizeof(MYSQL50_TABLE_NAME_PREFIX)-1) +#define SAFE_NAME_LEN (NAME_LEN + MYSQL50_TABLE_NAME_PREFIX_LENGTH) + +struct st_ma_pvio; +typedef struct st_ma_pvio MARIADB_PVIO; + +#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR column */ +#define MAX_BLOB_WIDTH 8192 /* Default width for blob */ + +/* the following defines were added for PHP's mysqli and pdo extensions: + see: CONC-56 +*/ +#define MAX_TINYINT_WIDTH 3 +#define MAX_SMALLINT_WIDTH 5 +#define MAX_MEDIUMINT_WIDTH 8 +#define MAX_INT_WIDTH 10 +#define MAX_BIGINT_WIDTH 20 + +struct st_ma_connection_plugin; + + +typedef struct st_net { + MARIADB_PVIO *pvio; + unsigned char *buff; + unsigned char *buff_end,*write_pos,*read_pos; + my_socket fd; /* For Perl DBI/dbd */ + unsigned long remain_in_buf,length; + unsigned long buf_length, where_b; + unsigned long max_packet, max_packet_size; + unsigned int pkt_nr, compress_pkt_nr; + unsigned int write_timeout, read_timeout, retry_count; + int fcntl; + unsigned int *return_status; + unsigned char reading_or_writing; + char save_char; + char unused_1; + my_bool unused_2; + my_bool compress; + my_bool unused_3; + void *unused_4; + unsigned int last_errno; + unsigned char error; + my_bool unused_5; + my_bool unused_6; + char last_error[MYSQL_ERRMSG_SIZE]; + char sqlstate[SQLSTATE_LENGTH+1]; + struct st_mariadb_net_extension *extension; +} NET; + +#define packet_error ((unsigned int) -1) + +/* used by mysql_set_server_option */ +enum enum_mysql_set_option +{ + MYSQL_OPTION_MULTI_STATEMENTS_ON, + MYSQL_OPTION_MULTI_STATEMENTS_OFF +}; + +enum enum_session_state_type +{ + SESSION_TRACK_SYSTEM_VARIABLES= 0, + SESSION_TRACK_SCHEMA, + SESSION_TRACK_STATE_CHANGE, + /* currently not supported by MariaDB Server */ + SESSION_TRACK_GTIDS, + SESSION_TRACK_TRANSACTION_CHARACTERISTICS, + SESSION_TRACK_TRANSACTION_STATE /* make sure that SESSION_TRACK_END always points + to last element of enum !! */ +}; + +#define SESSION_TRACK_BEGIN 0 +#define SESSION_TRACK_END SESSION_TRACK_TRANSACTION_STATE +#define SESSION_TRACK_TYPES (SESSION_TRACK_END + 1) + +/* SESSION_TRACK_TRANSACTION_TYPE was renamed to SESSION_TRACK_TRANSACTION_STATE + in 3e699a1738cdfb0a2c5b8eabfa8301b8d11cf711. + This is a workaround to prevent breaking of travis and buildbot tests. + TODO: Remove this after server fixes */ +#define SESSION_TRACK_TRANSACTION_TYPE SESSION_TRACK_TRANSACTION_STATE + +enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, + MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG, + MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE, + MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP, + MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24, + MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, + MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, + MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, + MYSQL_TYPE_BIT, + /* + the following types are not used by client, + only for mysqlbinlog!! + */ + MYSQL_TYPE_TIMESTAMP2, + MYSQL_TYPE_DATETIME2, + MYSQL_TYPE_TIME2, + /* --------------------------------------------- */ + MYSQL_TYPE_JSON=245, + MYSQL_TYPE_NEWDECIMAL=246, + MYSQL_TYPE_ENUM=247, + MYSQL_TYPE_SET=248, + MYSQL_TYPE_TINY_BLOB=249, + MYSQL_TYPE_MEDIUM_BLOB=250, + MYSQL_TYPE_LONG_BLOB=251, + MYSQL_TYPE_BLOB=252, + MYSQL_TYPE_VAR_STRING=253, + MYSQL_TYPE_STRING=254, + MYSQL_TYPE_GEOMETRY=255, + MAX_NO_FIELD_TYPES }; + +#define FIELD_TYPE_CHAR FIELD_TYPE_TINY /* For compatibility */ +#define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM /* For compatibility */ +#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL +#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL +#define FIELD_TYPE_TINY MYSQL_TYPE_TINY +#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT +#define FIELD_TYPE_LONG MYSQL_TYPE_LONG +#define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT +#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE +#define FIELD_TYPE_NULL MYSQL_TYPE_NULL +#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP +#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG +#define FIELD_TYPE_INT24 MYSQL_TYPE_INT24 +#define FIELD_TYPE_DATE MYSQL_TYPE_DATE +#define FIELD_TYPE_TIME MYSQL_TYPE_TIME +#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME +#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR +#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE +#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM +#define FIELD_TYPE_SET MYSQL_TYPE_SET +#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB +#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB +#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB +#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB +#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING +#define FIELD_TYPE_STRING MYSQL_TYPE_STRING +#define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY +#define FIELD_TYPE_BIT MYSQL_TYPE_BIT + +extern unsigned long max_allowed_packet; +extern unsigned long net_buffer_length; + +#define net_new_transaction(net) ((net)->pkt_nr=0) + +int ma_net_init(NET *net, MARIADB_PVIO *pvio); +void ma_net_end(NET *net); +void ma_net_clear(NET *net); +int ma_net_flush(NET *net); +int ma_net_write(NET *net,const unsigned char *packet, size_t len); +int ma_net_write_command(NET *net,unsigned char command,const char *packet, + size_t len, my_bool disable_flush); +int ma_net_real_write(NET *net,const char *packet, size_t len); +extern unsigned long ma_net_read(NET *net); + +struct rand_struct { + unsigned long seed1,seed2,max_value; + double max_value_dbl; +}; + + /* The following is for user defined functions */ + +enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT,ROW_RESULT,DECIMAL_RESULT}; + +typedef struct st_udf_args +{ + unsigned int arg_count; /* Number of arguments */ + enum Item_result *arg_type; /* Pointer to item_results */ + char **args; /* Pointer to argument */ + unsigned long *lengths; /* Length of string arguments */ + char *maybe_null; /* Set to 1 for all maybe_null args */ +} UDF_ARGS; + + /* This holds information about the result */ + +typedef struct st_udf_init +{ + my_bool maybe_null; /* 1 if function can return NULL */ + unsigned int decimals; /* for real functions */ + unsigned int max_length; /* For string functions */ + char *ptr; /* free pointer for function data */ + my_bool const_item; /* 0 if result is independent of arguments */ +} UDF_INIT; + +/* Connection types */ +#define MARIADB_CONNECTION_UNIXSOCKET 0 +#define MARIADB_CONNECTION_TCP 1 +#define MARIADB_CONNECTION_NAMEDPIPE 2 +#define MARIADB_CONNECTION_SHAREDMEM 3 + + /* Constants when using compression */ +#define NET_HEADER_SIZE 4 /* standard header size */ +#define COMP_HEADER_SIZE 3 /* compression header extra size */ + + /* Prototypes to password functions */ +#define native_password_plugin_name "mysql_native_password" +#define old_password_plugin_name "mysql_old_password" + +#ifdef __cplusplus +extern "C" { +#endif + +char *ma_scramble_323(char *to,const char *message,const char *password); +void ma_scramble_41(const unsigned char *buffer, const char *scramble, const char *password); +void ma_hash_password(unsigned long *result, const char *password, size_t len); +void ma_make_scrambled_password(char *to,const char *password); + +/* Some other useful functions */ + +void mariadb_load_defaults(const char *conf_file, const char **groups, + int *argc, char ***argv); +my_bool ma_thread_init(void); +void ma_thread_end(void); + +#ifdef __cplusplus +} +#endif + +#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */ + +#endif diff --git a/MySQL/include/mariadb_ctype.h b/MySQL/include/mariadb_ctype.h new file mode 100644 index 0000000..3b218c3 --- /dev/null +++ b/MySQL/include/mariadb_ctype.h @@ -0,0 +1,76 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02111-1301, USA */ + +/* + A better implementation of the UNIX ctype(3) library. + Notes: my_global.h should be included before ctype.h +*/ + +#ifndef _mariadb_ctype_h +#define _mariadb_ctype_h + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CHARSET_DIR "charsets/" +#define MY_CS_NAME_SIZE 32 + +#define MADB_DEFAULT_CHARSET_NAME "latin1" +#define MADB_DEFAULT_COLLATION_NAME "latin1_swedish_ci" +#define MADB_AUTODETECT_CHARSET_NAME "auto" + +/* we use the mysqlnd implementation */ +typedef struct ma_charset_info_st +{ + unsigned int nr; /* so far only 1 byte for charset */ + unsigned int state; + const char *csname; + const char *name; + const char *dir; + unsigned int codepage; + const char *encoding; + unsigned int char_minlen; + unsigned int char_maxlen; + unsigned int (*mb_charlen)(unsigned int c); + unsigned int (*mb_valid)(const char *start, const char *end); +} MARIADB_CHARSET_INFO; + +extern const MARIADB_CHARSET_INFO mariadb_compiled_charsets[]; +extern MARIADB_CHARSET_INFO *ma_default_charset_info; +extern MARIADB_CHARSET_INFO *ma_charset_bin; +extern MARIADB_CHARSET_INFO *ma_charset_latin1; +extern MARIADB_CHARSET_INFO *ma_charset_utf8_general_ci; +extern MARIADB_CHARSET_INFO *ma_charset_utf16le_general_ci; + +MARIADB_CHARSET_INFO *find_compiled_charset(unsigned int cs_number); +MARIADB_CHARSET_INFO *find_compiled_charset_by_name(const char *name); + +size_t mysql_cset_escape_quotes(const MARIADB_CHARSET_INFO *cset, char *newstr, const char *escapestr, size_t escapestr_len); +size_t mysql_cset_escape_slashes(const MARIADB_CHARSET_INFO *cset, char *newstr, const char *escapestr, size_t escapestr_len); +const char* madb_get_os_character_set(void); +#ifdef _WIN32 +int madb_get_windows_cp(const char *charset); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/MySQL/include/mariadb_dyncol.h b/MySQL/include/mariadb_dyncol.h new file mode 100644 index 0000000..216431a --- /dev/null +++ b/MySQL/include/mariadb_dyncol.h @@ -0,0 +1,259 @@ +/* Copyright (c) 2011, Monty Program Ab + Copyright (c) 2011, Oleksandr Byelkin + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY ``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 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. +*/ + +#ifndef ma_dyncol_h +#define ma_dyncol_h + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef LIBMARIADB +#include +#include +#endif +#include + +#ifndef longlong_defined +#if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8 +typedef unsigned long long int ulonglong; /* ulong or unsigned long long */ +typedef long long int longlong; +#else +typedef unsigned long ulonglong; /* ulong or unsigned long long */ +typedef long longlong; +#endif +#define longlong_defined +#endif + + +#ifndef _my_sys_h +typedef struct st_dynamic_string +{ + char *str; + size_t length,max_length,alloc_increment; +} DYNAMIC_STRING; +#endif + +struct st_mysql_lex_string +{ + char *str; + size_t length; +}; +typedef struct st_mysql_lex_string MYSQL_LEX_STRING; +typedef struct st_mysql_lex_string LEX_STRING; +/* + Limits of implementation +*/ +#define MAX_TOTAL_NAME_LENGTH 65535 +#define MAX_NAME_LENGTH (MAX_TOTAL_NAME_LENGTH/4) + +/* NO and OK is the same used just to show semantics */ +#define ER_DYNCOL_NO ER_DYNCOL_OK + +enum enum_dyncol_func_result +{ + ER_DYNCOL_OK= 0, + ER_DYNCOL_YES= 1, /* For functions returning 0/1 */ + ER_DYNCOL_FORMAT= -1, /* Wrong format of the encoded string */ + ER_DYNCOL_LIMIT= -2, /* Some limit reached */ + ER_DYNCOL_RESOURCE= -3, /* Out of resourses */ + ER_DYNCOL_DATA= -4, /* Incorrect input data */ + ER_DYNCOL_UNKNOWN_CHARSET= -5, /* Unknown character set */ + ER_DYNCOL_TRUNCATED= 2 /* OK, but data was truncated */ +}; + +typedef DYNAMIC_STRING DYNAMIC_COLUMN; + +enum enum_dynamic_column_type +{ + DYN_COL_NULL= 0, + DYN_COL_INT, + DYN_COL_UINT, + DYN_COL_DOUBLE, + DYN_COL_STRING, + DYN_COL_DECIMAL, + DYN_COL_DATETIME, + DYN_COL_DATE, + DYN_COL_TIME, + DYN_COL_DYNCOL +}; + +typedef enum enum_dynamic_column_type DYNAMIC_COLUMN_TYPE; + +struct st_dynamic_column_value +{ + DYNAMIC_COLUMN_TYPE type; + union + { + long long long_value; + unsigned long long ulong_value; + double double_value; + struct { + MYSQL_LEX_STRING value; + MARIADB_CHARSET_INFO *charset; + } string; +#ifndef LIBMARIADB + struct { + decimal_digit_t buffer[DECIMAL_BUFF_LENGTH]; + decimal_t value; + } decimal; +#endif + MYSQL_TIME time_value; + } x; +}; + +typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE; + +#ifdef MADYNCOL_DEPRECATED +enum enum_dyncol_func_result +dynamic_column_create(DYNAMIC_COLUMN *str, + uint column_nr, DYNAMIC_COLUMN_VALUE *value); + +enum enum_dyncol_func_result +dynamic_column_create_many(DYNAMIC_COLUMN *str, + uint column_count, + uint *column_numbers, + DYNAMIC_COLUMN_VALUE *values); +enum enum_dyncol_func_result +dynamic_column_update(DYNAMIC_COLUMN *org, uint column_nr, + DYNAMIC_COLUMN_VALUE *value); +enum enum_dyncol_func_result +dynamic_column_update_many(DYNAMIC_COLUMN *str, + uint add_column_count, + uint *column_numbers, + DYNAMIC_COLUMN_VALUE *values); + +enum enum_dyncol_func_result +dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr); + +enum enum_dyncol_func_result +dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint); + +enum enum_dyncol_func_result +dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr, + DYNAMIC_COLUMN_VALUE *store_it_here); +#endif + +/* new functions */ +enum enum_dyncol_func_result +mariadb_dyncol_create_many_num(DYNAMIC_COLUMN *str, + uint column_count, + uint *column_numbers, + DYNAMIC_COLUMN_VALUE *values, + my_bool new_string); +enum enum_dyncol_func_result +mariadb_dyncol_create_many_named(DYNAMIC_COLUMN *str, + uint column_count, + MYSQL_LEX_STRING *column_keys, + DYNAMIC_COLUMN_VALUE *values, + my_bool new_string); + + +enum enum_dyncol_func_result +mariadb_dyncol_update_many_num(DYNAMIC_COLUMN *str, + uint add_column_count, + uint *column_keys, + DYNAMIC_COLUMN_VALUE *values); +enum enum_dyncol_func_result +mariadb_dyncol_update_many_named(DYNAMIC_COLUMN *str, + uint add_column_count, + MYSQL_LEX_STRING *column_keys, + DYNAMIC_COLUMN_VALUE *values); + + +enum enum_dyncol_func_result +mariadb_dyncol_exists_num(DYNAMIC_COLUMN *org, uint column_nr); +enum enum_dyncol_func_result +mariadb_dyncol_exists_named(DYNAMIC_COLUMN *str, MYSQL_LEX_STRING *name); + +/* List of not NULL columns */ +enum enum_dyncol_func_result +mariadb_dyncol_list_num(DYNAMIC_COLUMN *str, uint *count, uint **nums); +enum enum_dyncol_func_result +mariadb_dyncol_list_named(DYNAMIC_COLUMN *str, uint *count, + MYSQL_LEX_STRING **names); + +/* + if the column do not exists it is NULL +*/ +enum enum_dyncol_func_result +mariadb_dyncol_get_num(DYNAMIC_COLUMN *org, uint column_nr, + DYNAMIC_COLUMN_VALUE *store_it_here); +enum enum_dyncol_func_result +mariadb_dyncol_get_named(DYNAMIC_COLUMN *str, MYSQL_LEX_STRING *name, + DYNAMIC_COLUMN_VALUE *store_it_here); + +my_bool mariadb_dyncol_has_names(DYNAMIC_COLUMN *str); + +enum enum_dyncol_func_result +mariadb_dyncol_check(DYNAMIC_COLUMN *str); + +enum enum_dyncol_func_result +mariadb_dyncol_json(DYNAMIC_COLUMN *str, DYNAMIC_STRING *json); + +void mariadb_dyncol_free(DYNAMIC_COLUMN *str); + +#define mariadb_dyncol_init(A) memset((A), 0, sizeof(DYNAMIC_COLUMN)) +#define dynamic_column_initialize(A) mariadb_dyncol_init((A)) +#define dynamic_column_column_free(A) mariadb_dyncol_free((A)) + +/* conversion of values to 3 base types */ +enum enum_dyncol_func_result +mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val, + MARIADB_CHARSET_INFO *cs, char quote); +enum enum_dyncol_func_result +mariadb_dyncol_val_long(longlong *ll, DYNAMIC_COLUMN_VALUE *val); +enum enum_dyncol_func_result +mariadb_dyncol_val_double(double *dbl, DYNAMIC_COLUMN_VALUE *val); + +enum enum_dyncol_func_result +mariadb_dyncol_unpack(DYNAMIC_COLUMN *str, + uint *count, + MYSQL_LEX_STRING **names, DYNAMIC_COLUMN_VALUE **vals); + +int mariadb_dyncol_column_cmp_named(const MYSQL_LEX_STRING *s1, + const MYSQL_LEX_STRING *s2); + +enum enum_dyncol_func_result +mariadb_dyncol_column_count(DYNAMIC_COLUMN *str, uint *column_count); + +#define mariadb_dyncol_value_init(V) \ +do {\ + (V)->type= DYN_COL_NULL;\ +} while(0) + +/* + Prepare value for using as decimal +*/ +void mariadb_dyncol_prepare_decimal(DYNAMIC_COLUMN_VALUE *value); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/MySQL/include/mariadb_rpl.h b/MySQL/include/mariadb_rpl.h new file mode 100644 index 0000000..315543f --- /dev/null +++ b/MySQL/include/mariadb_rpl.h @@ -0,0 +1,305 @@ +/* Copyright (C) 2018 MariaDB Corporation AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02111-1301, USA */ +#ifndef _mariadb_rpl_h_ +#define _mariadb_rpl_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define MARIADB_RPL_VERSION 0x0001 +#define MARIADB_RPL_REQUIRED_VERSION 0x0001 + +/* Protocol flags */ +#define MARIADB_RPL_BINLOG_DUMP_NON_BLOCK 1 +#define MARIADB_RPL_BINLOG_SEND_ANNOTATE_ROWS 2 +#define MARIADB_RPL_IGNORE_HEARTBEAT (1 << 17) + +#define EVENT_HEADER_OFS 20 + +#define FL_GROUP_COMMIT_ID 2 +#define FL_STMT_END 1 + +#define LOG_EVENT_ARTIFICIAL_F 0x20 + + +/* Options */ +enum mariadb_rpl_option { + MARIADB_RPL_FILENAME, /* Filename and length */ + MARIADB_RPL_START, /* Start position */ + MARIADB_RPL_SERVER_ID, /* Server ID */ + MARIADB_RPL_FLAGS, /* Protocol flags */ + MARIADB_RPL_GTID_CALLBACK, /* GTID callback function */ + MARIADB_RPL_GTID_DATA, /* GTID data */ + MARIADB_RPL_BUFFER +}; + +/* Event types: From MariaDB Server sql/log_event.h */ +enum mariadb_rpl_event { + UNKNOWN_EVENT= 0, + START_EVENT_V3= 1, + QUERY_EVENT= 2, + STOP_EVENT= 3, + ROTATE_EVENT= 4, + INTVAR_EVENT= 5, + LOAD_EVENT= 6, + SLAVE_EVENT= 7, + CREATE_FILE_EVENT= 8, + APPEND_BLOCK_EVENT= 9, + EXEC_LOAD_EVENT= 10, + DELETE_FILE_EVENT= 11, + NEW_LOAD_EVENT= 12, + RAND_EVENT= 13, + USER_VAR_EVENT= 14, + FORMAT_DESCRIPTION_EVENT= 15, + XID_EVENT= 16, + BEGIN_LOAD_QUERY_EVENT= 17, + EXECUTE_LOAD_QUERY_EVENT= 18, + TABLE_MAP_EVENT = 19, + + PRE_GA_WRITE_ROWS_EVENT = 20, /* deprecated */ + PRE_GA_UPDATE_ROWS_EVENT = 21, /* deprecated */ + PRE_GA_DELETE_ROWS_EVENT = 22, /* deprecated */ + + WRITE_ROWS_EVENT_V1 = 23, + UPDATE_ROWS_EVENT_V1 = 24, + DELETE_ROWS_EVENT_V1 = 25, + INCIDENT_EVENT= 26, + HEARTBEAT_LOG_EVENT= 27, + IGNORABLE_LOG_EVENT= 28, + ROWS_QUERY_LOG_EVENT= 29, + WRITE_ROWS_EVENT = 30, + UPDATE_ROWS_EVENT = 31, + DELETE_ROWS_EVENT = 32, + GTID_LOG_EVENT= 33, + ANONYMOUS_GTID_LOG_EVENT= 34, + PREVIOUS_GTIDS_LOG_EVENT= 35, + TRANSACTION_CONTEXT_EVENT= 36, + VIEW_CHANGE_EVENT= 37, + XA_PREPARE_LOG_EVENT= 38, + + /* + Add new events here - right above this comment! + Existing events (except ENUM_END_EVENT) should never change their numbers + */ + + /* New MySQL/Sun events are to be added right above this comment */ + MYSQL_EVENTS_END, + + MARIA_EVENTS_BEGIN= 160, + ANNOTATE_ROWS_EVENT= 160, + BINLOG_CHECKPOINT_EVENT= 161, + GTID_EVENT= 162, + GTID_LIST_EVENT= 163, + START_ENCRYPTION_EVENT= 164, + QUERY_COMPRESSED_EVENT = 165, + WRITE_ROWS_COMPRESSED_EVENT_V1 = 166, + UPDATE_ROWS_COMPRESSED_EVENT_V1 = 167, + DELETE_ROWS_COMPRESSED_EVENT_V1 = 168, + WRITE_ROWS_COMPRESSED_EVENT = 169, + UPDATE_ROWS_COMPRESSED_EVENT = 170, + DELETE_ROWS_COMPRESSED_EVENT = 171, + + /* Add new MariaDB events here - right above this comment! */ + + ENUM_END_EVENT /* end marker */ +}; + +typedef struct { + char *str; + size_t length; +} MARIADB_STRING; + +enum mariadb_row_event_type { + WRITE_ROWS= 0, + UPDATE_ROWS= 1, + DELETE_ROWS= 2 +}; + +/* Global transaction id */ +typedef struct st_mariadb_gtid { + unsigned int domain_id; + unsigned int server_id; + unsigned long long sequence_nr; +} MARIADB_GTID; + +/* Generic replication handle */ +typedef struct st_mariadb_rpl { + unsigned int version; + MYSQL *mysql; + char *filename; + uint32_t filename_length; + unsigned char *buffer; + unsigned long buffer_size; + uint32_t server_id; + unsigned long start_position; + uint32_t flags; + uint8_t fd_header_len; /* header len from last format description event */ + uint8_t use_checksum; +} MARIADB_RPL; + +/* Event header */ +struct st_mariadb_rpl_rotate_event { + unsigned long long position; + MARIADB_STRING filename; +}; + +struct st_mariadb_rpl_query_event { + uint32_t thread_id; + uint32_t seconds; + MARIADB_STRING database; + uint32_t errornr; + MARIADB_STRING status; + MARIADB_STRING statement; +}; + +struct st_mariadb_rpl_gtid_list_event { + uint32_t gtid_cnt; + MARIADB_GTID *gtid; +}; + +struct st_mariadb_rpl_format_description_event +{ + uint16_t format; + char *server_version; + uint32_t timestamp; + uint8_t header_len; +}; + +struct st_mariadb_rpl_checkpoint_event { + MARIADB_STRING filename; +}; + +struct st_mariadb_rpl_xid_event { + uint64_t transaction_nr; +}; + +struct st_mariadb_rpl_gtid_event { + uint64_t sequence_nr; + uint32_t domain_id; + uint8_t flags; + uint64_t commit_id; +}; + +struct st_mariadb_rpl_annotate_rows_event { + MARIADB_STRING statement; +}; + +struct st_mariadb_rpl_table_map_event { + unsigned long long table_id; + MARIADB_STRING database; + MARIADB_STRING table; + unsigned int column_count; + MARIADB_STRING column_types; + MARIADB_STRING metadata; + char *null_indicator; +}; + +struct st_mariadb_rpl_rand_event { + unsigned long long first_seed; + unsigned long long second_seed; +}; + +struct st_mariadb_rpl_encryption_event { + char scheme; + unsigned int key_version; + char *nonce; +}; + +struct st_mariadb_rpl_intvar_event { + char type; + unsigned long long value; +}; + +struct st_mariadb_rpl_uservar_event { + MARIADB_STRING name; + uint8_t is_null; + uint8_t type; + uint32_t charset_nr; + MARIADB_STRING value; + uint8_t flags; +}; + +struct st_mariadb_rpl_rows_event { + enum mariadb_row_event_type type; + uint64_t table_id; + uint16_t flags; + uint32_t column_count; + char *column_bitmap; + char *column_update_bitmap; + size_t row_data_size; + void *row_data; +}; + +struct st_mariadb_rpl_heartbeat_event { + uint32_t timestamp; + uint32_t next_position; + uint8_t type; + uint16_t flags; +}; + +typedef struct st_mariadb_rpl_event +{ + /* common header */ + MA_MEM_ROOT memroot; + unsigned int checksum; + char ok; + enum mariadb_rpl_event event_type; + unsigned int timestamp; + unsigned int server_id; + unsigned int event_length; + unsigned int next_event_pos; + unsigned short flags; + /****************/ + union { + struct st_mariadb_rpl_rotate_event rotate; + struct st_mariadb_rpl_query_event query; + struct st_mariadb_rpl_format_description_event format_description; + struct st_mariadb_rpl_gtid_list_event gtid_list; + struct st_mariadb_rpl_checkpoint_event checkpoint; + struct st_mariadb_rpl_xid_event xid; + struct st_mariadb_rpl_gtid_event gtid; + struct st_mariadb_rpl_annotate_rows_event annotate_rows; + struct st_mariadb_rpl_table_map_event table_map; + struct st_mariadb_rpl_rand_event rand; + struct st_mariadb_rpl_encryption_event encryption; + struct st_mariadb_rpl_intvar_event intvar; + struct st_mariadb_rpl_uservar_event uservar; + struct st_mariadb_rpl_rows_event rows; + struct st_mariadb_rpl_heartbeat_event heartbeat; + } event; +} MARIADB_RPL_EVENT; + +#define mariadb_rpl_init(a) mariadb_rpl_init_ex((a), MARIADB_RPL_VERSION) + +/* Function prototypes */ +MARIADB_RPL * STDCALL mariadb_rpl_init_ex(MYSQL *mysql, unsigned int version); + +int mariadb_rpl_optionsv(MARIADB_RPL *rpl, enum mariadb_rpl_option, ...); +int mariadb_rpl_get_optionsv(MARIADB_RPL *rpl, enum mariadb_rpl_option, ...); + +int STDCALL mariadb_rpl_open(MARIADB_RPL *rpl); +void STDCALL mariadb_rpl_close(MARIADB_RPL *rpl); +MARIADB_RPL_EVENT * STDCALL mariadb_rpl_fetch(MARIADB_RPL *rpl, MARIADB_RPL_EVENT *event); +void STDCALL mariadb_free_rpl_event(MARIADB_RPL_EVENT *event); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/MySQL/include/mariadb_stmt.h b/MySQL/include/mariadb_stmt.h new file mode 100644 index 0000000..d07540e --- /dev/null +++ b/MySQL/include/mariadb_stmt.h @@ -0,0 +1,298 @@ +/************************************************************************ + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02111-1301, USA + + Part of this code includes code from PHP's mysqlnd extension + (written by Andrey Hristov, Georg Richter and Ulf Wendel), freely + available from http://www.php.net/software + +*************************************************************************/ + +#define MYSQL_NO_DATA 100 +#define MYSQL_DATA_TRUNCATED 101 +#define MYSQL_DEFAULT_PREFETCH_ROWS (unsigned long) 1 + +/* Bind flags */ +#define MADB_BIND_DUMMY 1 + +#define MARIADB_STMT_BULK_SUPPORTED(stmt)\ + ((stmt)->mysql && \ + (!((stmt)->mysql->server_capabilities & CLIENT_MYSQL) &&\ + ((stmt)->mysql->extension->mariadb_server_capabilities & \ + (MARIADB_CLIENT_STMT_BULK_OPERATIONS >> 32)))) + +#define SET_CLIENT_STMT_ERROR(a, b, c, d) \ +do { \ + (a)->last_errno= (b);\ + strncpy((a)->sqlstate, (c), SQLSTATE_LENGTH);\ + (a)->sqlstate[SQLSTATE_LENGTH]= 0;\ + strncpy((a)->last_error, (d) ? (d) : ER((b)), MYSQL_ERRMSG_SIZE);\ + (a)->last_error[MYSQL_ERRMSG_SIZE - 1]= 0;\ +} while (0) + +#define CLEAR_CLIENT_STMT_ERROR(a) \ +do { \ + (a)->last_errno= 0;\ + strcpy((a)->sqlstate, "00000");\ + (a)->last_error[0]= 0;\ +} while (0) + +#define MYSQL_PS_SKIP_RESULT_W_LEN -1 +#define MYSQL_PS_SKIP_RESULT_STR -2 +#define STMT_ID_LENGTH 4 + + +typedef struct st_mysql_stmt MYSQL_STMT; + +typedef MYSQL_RES* (*mysql_stmt_use_or_store_func)(MYSQL_STMT *); + +enum enum_stmt_attr_type +{ + STMT_ATTR_UPDATE_MAX_LENGTH, + STMT_ATTR_CURSOR_TYPE, + STMT_ATTR_PREFETCH_ROWS, + + /* MariaDB only */ + STMT_ATTR_PREBIND_PARAMS=200, + STMT_ATTR_ARRAY_SIZE, + STMT_ATTR_ROW_SIZE, + STMT_ATTR_STATE, + STMT_ATTR_CB_USER_DATA, + STMT_ATTR_CB_PARAM, + STMT_ATTR_CB_RESULT +}; + +enum enum_cursor_type +{ + CURSOR_TYPE_NO_CURSOR= 0, + CURSOR_TYPE_READ_ONLY= 1, + CURSOR_TYPE_FOR_UPDATE= 2, + CURSOR_TYPE_SCROLLABLE= 4 +}; + +enum enum_indicator_type +{ + STMT_INDICATOR_NTS=-1, + STMT_INDICATOR_NONE=0, + STMT_INDICATOR_NULL=1, + STMT_INDICATOR_DEFAULT=2, + STMT_INDICATOR_IGNORE=3, + STMT_INDICATOR_IGNORE_ROW=4 +}; + +/* + bulk PS flags +*/ +#define STMT_BULK_FLAG_CLIENT_SEND_TYPES 128 +#define STMT_BULK_FLAG_INSERT_ID_REQUEST 64 + +typedef enum mysql_stmt_state +{ + MYSQL_STMT_INITTED = 0, + MYSQL_STMT_PREPARED, + MYSQL_STMT_EXECUTED, + MYSQL_STMT_WAITING_USE_OR_STORE, + MYSQL_STMT_USE_OR_STORE_CALLED, + MYSQL_STMT_USER_FETCHING, /* fetch_row_buff or fetch_row_unbuf */ + MYSQL_STMT_FETCH_DONE +} enum_mysqlnd_stmt_state; + +typedef struct st_mysql_bind +{ + unsigned long *length; /* output length pointer */ + my_bool *is_null; /* Pointer to null indicator */ + void *buffer; /* buffer to get/put data */ + /* set this if you want to track data truncations happened during fetch */ + my_bool *error; + union { + unsigned char *row_ptr; /* for the current data position */ + char *indicator; /* indicator variable */ + } u; + void (*store_param_func)(NET *net, struct st_mysql_bind *param); + void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *, + unsigned char **row); + void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *, + unsigned char **row); + /* output buffer length, must be set when fetching str/binary */ + unsigned long buffer_length; + unsigned long offset; /* offset position for char/binary fetch */ + unsigned long length_value; /* Used if length is 0 */ + unsigned int flags; /* special flags, e.g. for dummy bind */ + unsigned int pack_length; /* Internal length for packed data */ + enum enum_field_types buffer_type; /* buffer type */ + my_bool error_value; /* used if error is 0 */ + my_bool is_unsigned; /* set if integer type is unsigned */ + my_bool long_data_used; /* If used with mysql_send_long_data */ + my_bool is_null_value; /* Used if is_null is 0 */ + void *extension; +} MYSQL_BIND; + +typedef struct st_mysqlnd_upsert_result +{ + unsigned int warning_count; + unsigned int server_status; + unsigned long long affected_rows; + unsigned long long last_insert_id; +} mysql_upsert_status; + +typedef struct st_mysql_cmd_buffer +{ + unsigned char *buffer; + size_t length; +} MYSQL_CMD_BUFFER; + +typedef struct st_mysql_error_info +{ + unsigned int error_no; + char error[MYSQL_ERRMSG_SIZE+1]; + char sqlstate[SQLSTATE_LENGTH + 1]; +} mysql_error_info; + + +struct st_mysqlnd_stmt_methods +{ + my_bool (*prepare)(const MYSQL_STMT * stmt, const char * const query, size_t query_len); + my_bool (*execute)(const MYSQL_STMT * stmt); + MYSQL_RES * (*use_result)(const MYSQL_STMT * stmt); + MYSQL_RES * (*store_result)(const MYSQL_STMT * stmt); + MYSQL_RES * (*get_result)(const MYSQL_STMT * stmt); + my_bool (*free_result)(const MYSQL_STMT * stmt); + my_bool (*seek_data)(const MYSQL_STMT * stmt, unsigned long long row); + my_bool (*reset)(const MYSQL_STMT * stmt); + my_bool (*close)(const MYSQL_STMT * stmt); /* private */ + my_bool (*dtor)(const MYSQL_STMT * stmt); /* use this for mysqlnd_stmt_close */ + + my_bool (*fetch)(const MYSQL_STMT * stmt, my_bool * const fetched_anything); + + my_bool (*bind_param)(const MYSQL_STMT * stmt, const MYSQL_BIND bind); + my_bool (*refresh_bind_param)(const MYSQL_STMT * stmt); + my_bool (*bind_result)(const MYSQL_STMT * stmt, const MYSQL_BIND *bind); + my_bool (*send_long_data)(const MYSQL_STMT * stmt, unsigned int param_num, + const char * const data, size_t length); + MYSQL_RES *(*get_parameter_metadata)(const MYSQL_STMT * stmt); + MYSQL_RES *(*get_result_metadata)(const MYSQL_STMT * stmt); + unsigned long long (*get_last_insert_id)(const MYSQL_STMT * stmt); + unsigned long long (*get_affected_rows)(const MYSQL_STMT * stmt); + unsigned long long (*get_num_rows)(const MYSQL_STMT * stmt); + + unsigned int (*get_param_count)(const MYSQL_STMT * stmt); + unsigned int (*get_field_count)(const MYSQL_STMT * stmt); + unsigned int (*get_warning_count)(const MYSQL_STMT * stmt); + + unsigned int (*get_error_no)(const MYSQL_STMT * stmt); + const char * (*get_error_str)(const MYSQL_STMT * stmt); + const char * (*get_sqlstate)(const MYSQL_STMT * stmt); + + my_bool (*get_attribute)(const MYSQL_STMT * stmt, enum enum_stmt_attr_type attr_type, const void * value); + my_bool (*set_attribute)(const MYSQL_STMT * stmt, enum enum_stmt_attr_type attr_type, const void * value); + void (*set_error)(MYSQL_STMT *stmt, unsigned int error_nr, const char *sqlstate, const char *format, ...); +}; + +typedef int (*mysql_stmt_fetch_row_func)(MYSQL_STMT *stmt, unsigned char **row); +typedef void (*ps_result_callback)(void *data, unsigned int column, unsigned char **row); +typedef my_bool *(*ps_param_callback)(void *data, MYSQL_BIND *bind, unsigned int row_nr); + +struct st_mysql_stmt +{ + MA_MEM_ROOT mem_root; + MYSQL *mysql; + unsigned long stmt_id; + unsigned long flags;/* cursor is set here */ + enum_mysqlnd_stmt_state state; + MYSQL_FIELD *fields; + unsigned int field_count; + unsigned int param_count; + unsigned char send_types_to_server; + MYSQL_BIND *params; + MYSQL_BIND *bind; + MYSQL_DATA result; /* we don't use mysqlnd's result set logic */ + MYSQL_ROWS *result_cursor; + my_bool bind_result_done; + my_bool bind_param_done; + + mysql_upsert_status upsert_status; + + unsigned int last_errno; + char last_error[MYSQL_ERRMSG_SIZE+1]; + char sqlstate[SQLSTATE_LENGTH + 1]; + + my_bool update_max_length; + unsigned long prefetch_rows; + LIST list; + + my_bool cursor_exists; + + void *extension; + mysql_stmt_fetch_row_func fetch_row_func; + unsigned int execute_count;/* count how many times the stmt was executed */ + mysql_stmt_use_or_store_func default_rset_handler; + struct st_mysqlnd_stmt_methods *m; + unsigned int array_size; + size_t row_size; + unsigned int prebind_params; + void *user_data; + ps_result_callback result_callback; + ps_param_callback param_callback; +}; + +typedef void (*ps_field_fetch_func)(MYSQL_BIND *r_param, const MYSQL_FIELD * field, unsigned char **row); +typedef struct st_mysql_perm_bind { + ps_field_fetch_func func; + /* should be signed int */ + int pack_len; + unsigned long max_len; +} MYSQL_PS_CONVERSION; + +extern MYSQL_PS_CONVERSION mysql_ps_fetch_functions[MYSQL_TYPE_GEOMETRY + 1]; +unsigned long ma_net_safe_read(MYSQL *mysql); +void mysql_init_ps_subsystem(void); +unsigned long net_field_length(unsigned char **packet); +int ma_simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, + size_t length, my_bool skipp_check, void *opt_arg); +/* + * function prototypes + */ +MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql); +int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, unsigned long length); +int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt); +int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt); +int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg, unsigned int column, unsigned long offset); +int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt); +unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt); +my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, const void *attr); +my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, void *attr); +my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd); +my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd); +my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt); +my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt); +my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt); +my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, unsigned int param_number, const char *data, unsigned long length); +MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt); +MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt); +unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt); +const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt); +const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt); +MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET offset); +MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt); +void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, unsigned long long offset); +unsigned long long STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt); +unsigned long long STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt); +unsigned long long STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt); +unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt); +int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt); +my_bool STDCALL mysql_stmt_more_results(MYSQL_STMT *stmt); +int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt, const char *stmt_str, size_t length); +MYSQL_FIELD * STDCALL mariadb_stmt_fetch_fields(MYSQL_STMT *stmt); diff --git a/MySQL/include/mariadb_version.h b/MySQL/include/mariadb_version.h new file mode 100644 index 0000000..47ea413 --- /dev/null +++ b/MySQL/include/mariadb_version.h @@ -0,0 +1,44 @@ +/* Copyright Abandoned 1996, 1999, 2001 MySQL AB + This file is public domain and comes with NO WARRANTY of any kind */ + +/* Version numbers for protocol & mysqld */ + +#ifndef _mariadb_version_h_ +#define _mariadb_version_h_ + +#ifdef _CUSTOMCONFIG_ +#include +#else +#define PROTOCOL_VERSION 10 +#define MARIADB_CLIENT_VERSION_STR "10.5.5" +#define MARIADB_BASE_VERSION "mariadb-10.5" +#define MARIADB_VERSION_ID 100505 +#define MARIADB_PORT 3306 +#define MARIADB_UNIX_ADDR "/tmp/mysql.sock" +#ifndef MYSQL_UNIX_ADDR +#define MYSQL_UNIX_ADDR MARIADB_UNIX_ADDR +#endif +#ifndef MYSQL_PORT +#define MYSQL_PORT MARIADB_PORT +#endif + +#define MYSQL_CONFIG_NAME "my" +#define MYSQL_VERSION_ID 100505 +#define MYSQL_SERVER_VERSION "10.5.5-MariaDB" + +#define MARIADB_PACKAGE_VERSION "3.1.12" +#define MARIADB_PACKAGE_VERSION_ID 30112 +#define MARIADB_SYSTEM_TYPE "Windows" +#define MARIADB_MACHINE_TYPE "AMD64" +#define MARIADB_PLUGINDIR "C:/Program Files/mariadb-connector-c/lib/mariadb/plugin" + +/* mysqld compile time options */ +#ifndef MYSQL_CHARSET +#define MYSQL_CHARSET "" +#endif +#endif + +/* Source information */ +#define CC_SOURCE_REVISION "7d304d26c787a3f0430624db977b615aba56e4bb" + +#endif /* _mariadb_version_h_ */ diff --git a/MySQL/include/my_command.h b/MySQL/include/my_command.h deleted file mode 100644 index 13b8993..0000000 --- a/MySQL/include/my_command.h +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License, version 2.0, -as published by the Free Software Foundation. - -This program is also distributed with certain software (including -but not limited to OpenSSL) that is licensed under separate terms, -as designated in a particular file or component or in included license -documentation. The authors of MySQL hereby grant you an additional -permission to link the program and your derivative works with the -separately licensed software that they have included with MySQL. - -Without limiting anything contained in the foregoing, this file, -which is part of C Driver for MySQL (Connector/C), is also subject to the -Universal FOSS Exception, version 1.0, a copy of which can be found at -http://oss.oracle.com/licenses/universal-foss-exception. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License, version 2.0, for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#ifndef _mysql_command_h -#define _mysql_command_h - -/** - @file include/my_command.h -*/ - -/** - @enum enum_server_command - - @brief A list of all MySQL protocol commands. - - These are the top level commands the server can receive - while it listens for a new command in ::dispatch_command - - @par Warning - Add new commands to the end of this list, otherwise old - servers won't be able to handle them as 'unsupported'. -*/ -enum enum_server_command { - /** - Currently refused by the server. See ::dispatch_command. - Also used internally to mark the start of a session. - */ - COM_SLEEP, - COM_QUIT, /**< See @ref page_protocol_com_quit */ - COM_INIT_DB, /**< See @ref page_protocol_com_init_db */ - COM_QUERY, /**< See @ref page_protocol_com_query */ - COM_FIELD_LIST, /**< Deprecated. See @ref page_protocol_com_field_list */ - COM_CREATE_DB, /**< Currently refused by the server. See ::dispatch_command */ - COM_DROP_DB, /**< Currently refused by the server. See ::dispatch_command */ - COM_REFRESH, /**< Deprecated. See @ref page_protocol_com_refresh */ - COM_DEPRECATED_1, /**< Deprecated, used to be COM_SHUTDOWN */ - COM_STATISTICS, /**< See @ref page_protocol_com_statistics */ - COM_PROCESS_INFO, /**< Deprecated. See @ref page_protocol_com_process_info */ - COM_CONNECT, /**< Currently refused by the server. */ - COM_PROCESS_KILL, /**< Deprecated. See @ref page_protocol_com_process_kill */ - COM_DEBUG, /**< See @ref page_protocol_com_debug */ - COM_PING, /**< See @ref page_protocol_com_ping */ - COM_TIME, /**< Currently refused by the server. */ - COM_DELAYED_INSERT, /**< Functionality removed. */ - COM_CHANGE_USER, /**< See @ref page_protocol_com_change_user */ - COM_BINLOG_DUMP, /**< See @ref page_protocol_com_binlog_dump */ - COM_TABLE_DUMP, - COM_CONNECT_OUT, - COM_REGISTER_SLAVE, - COM_STMT_PREPARE, /**< See @ref page_protocol_com_stmt_prepare */ - COM_STMT_EXECUTE, /**< See @ref page_protocol_com_stmt_execute */ - /** See @ref page_protocol_com_stmt_send_long_data */ - COM_STMT_SEND_LONG_DATA, - COM_STMT_CLOSE, /**< See @ref page_protocol_com_stmt_close */ - COM_STMT_RESET, /**< See @ref page_protocol_com_stmt_reset */ - COM_SET_OPTION, /**< See @ref page_protocol_com_set_option */ - COM_STMT_FETCH, /**< See @ref page_protocol_com_stmt_fetch */ - /** - Currently refused by the server. See ::dispatch_command. - Also used internally to mark the session as a "daemon", - i.e. non-client THD. Currently the scheduler and the GTID - code does use this state. - These threads won't be killed by `KILL` - - @sa Event_scheduler::start, ::init_thd, ::kill_one_thread, - ::Find_thd_with_id - */ - COM_DAEMON, - COM_BINLOG_DUMP_GTID, - COM_RESET_CONNECTION, /**< See @ref page_protocol_com_reset_connection */ - COM_CLONE, - /* don't forget to update const char *command_name[] in sql_parse.cc */ - - /* Must be last */ - COM_END /**< Not a real command. Refused. */ -}; - -#endif /* _mysql_command_h */ diff --git a/MySQL/include/my_list.h b/MySQL/include/my_list.h deleted file mode 100644 index a19e414..0000000 --- a/MySQL/include/my_list.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2.0, - as published by the Free Software Foundation. - - This program is also distributed with certain software (including - but not limited to OpenSSL) that is licensed under separate terms, - as designated in a particular file or component or in included license - documentation. The authors of MySQL hereby grant you an additional - permission to link the program and your derivative works with the - separately licensed software that they have included with MySQL. - - Without limiting anything contained in the foregoing, this file, - which is part of C Driver for MySQL (Connector/C), is also subject to the - Universal FOSS Exception, version 1.0, a copy of which can be found at - http://oss.oracle.com/licenses/universal-foss-exception. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License, version 2.0, for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#ifndef _list_h_ -#define _list_h_ - -/** - @file include/my_list.h -*/ - -/* - NOTE: This file should really include mysql/service_mysql_alloc.h - (due to the my_free() call in list_pop), but that is not acceptable - in client code, so it has been kept out. -*/ - -typedef struct LIST { -#if defined(__cplusplus) && __cplusplus >= 201103L - struct LIST *prev{nullptr}, *next{nullptr}; - void *data{nullptr}; -#else - struct LIST *prev, *next; - void *data; -#endif -} LIST; - -typedef int (*list_walk_action)(void *, void *); - -extern LIST *list_add(LIST *root, LIST *element); -extern LIST *list_delete(LIST *root, LIST *element); -extern LIST *list_cons(void *data, LIST *root); -extern LIST *list_reverse(LIST *root); -extern void list_free(LIST *root, unsigned int free_data); -extern unsigned int list_length(LIST *); -extern int list_walk(LIST *, list_walk_action action, unsigned char *argument); - -#define list_rest(a) ((a)->next) -#define list_push(a, b) (a) = list_cons((b), (a)) -#define list_pop(A) \ - { \ - LIST *old = (A); \ - (A) = list_delete(old, old); \ - my_free(old); \ - } - -#endif diff --git a/MySQL/include/mysql.h b/MySQL/include/mysql.h index 561960c..34f0985 100644 --- a/MySQL/include/mysql.h +++ b/MySQL/include/mysql.h @@ -1,791 +1,891 @@ -/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2.0, - as published by the Free Software Foundation. - - This program is also distributed with certain software (including - but not limited to OpenSSL) that is licensed under separate terms, - as designated in a particular file or component or in included license - documentation. The authors of MySQL hereby grant you an additional - permission to link the program and your derivative works with the - separately licensed software that they have included with MySQL. - - Without limiting anything contained in the foregoing, this file, - which is part of C Driver for MySQL (Connector/C), is also subject to the - Universal FOSS Exception, version 1.0, a copy of which can be found at - http://oss.oracle.com/licenses/universal-foss-exception. - - This program is distributed in the hope that it will be useful, +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + 2012 by MontyProgram AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License, version 2.0, for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -/** - @file include/mysql.h - This file defines the client API to MySQL and also the ABI of the - dynamically linked libmysqlclient. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02111-1301, USA */ - The ABI should never be changed in a released product of MySQL, - thus you need to take great care when changing the file. In case - the file is changed so the ABI is broken, you must also update - the SHARED_LIB_MAJOR_VERSION in cmake/mysql_version.cmake -*/ +/* defines for the libmariadb library */ #ifndef _mysql_h #define _mysql_h -#ifndef MYSQL_ABI_CHECK -#include -#include -#include +#ifdef __cplusplus +extern "C" { #endif -// Small extra definitions to avoid pulling in my_inttypes.h in client code. -// IWYU pragma: no_include "my_inttypes.h" -#if defined(_WIN32) -typedef unsigned __int64 my_ulonglong; -#else -typedef unsigned long long my_ulonglong; -#endif /* _WIN32 */ - -#ifndef my_socket_defined -#define my_socket_defined -#ifdef _WIN32 -#include -#ifdef WIN32_LEAN_AND_MEAN -#include +#ifndef LIBMARIADB +#define LIBMARIADB #endif -#define my_socket SOCKET -#else -typedef int my_socket; -#endif /* _WIN32 */ -#endif /* my_socket_defined */ +#ifndef MYSQL_CLIENT +#define MYSQL_CLIENT +#endif + +#include + +#if !defined (_global_h) && !defined (MY_GLOBAL_INCLUDED) /* If not standard header */ +#include +typedef char my_bool; +typedef unsigned long long my_ulonglong; -// Small extra definition to avoid pulling in my_compiler.h in client code. -// IWYU pragma: no_include "my_compiler.h" -#ifndef MY_COMPILER_INCLUDED #if !defined(_WIN32) #define STDCALL #else #define STDCALL __stdcall #endif -#endif /* MY_COMPILER_INCLUDED */ - -#include "field_types.h" -#include "my_list.h" -#include "mysql_com.h" - -/* Include declarations of plug-in API */ -#include "mysql/client_plugin.h" // IWYU pragma: keep -/* - The client should be able to know which version it is compiled against, - even if mysql.h doesn't use this information directly. -*/ -#include "mysql_version.h" // IWYU pragma: keep - -// MYSQL_TIME is part of our public API. -#include "mysql_time.h" // IWYU pragma: keep - -// The error messages are part of our public API. -#include "errmsg.h" // IWYU pragma: keep - -#ifdef __cplusplus -extern "C" { +#ifndef my_socket_defined +#define my_socket_defined +#if defined(_WIN64) +#define my_socket unsigned long long +#elif defined(_WIN32) +#define my_socket unsigned int +#else +typedef int my_socket; +#endif +#endif +#endif +#include "mariadb_com.h" +#include "mariadb_version.h" +#include "ma_list.h" +#include "mariadb_ctype.h" + + +typedef struct st_ma_const_string +{ + const char *str; + size_t length; +} MARIADB_CONST_STRING; + + +#ifndef ST_MA_USED_MEM_DEFINED +#define ST_MA_USED_MEM_DEFINED + typedef struct st_ma_used_mem { /* struct for once_alloc */ + struct st_ma_used_mem *next; /* Next block in use */ + size_t left; /* memory left in block */ + size_t size; /* Size of block */ + } MA_USED_MEM; + + typedef struct st_ma_mem_root { + MA_USED_MEM *free; + MA_USED_MEM *used; + MA_USED_MEM *pre_alloc; + size_t min_malloc; + size_t block_size; + unsigned int block_num; + unsigned int first_block_usage; + void (*error_handler)(void); + } MA_MEM_ROOT; #endif extern unsigned int mysql_port; extern char *mysql_unix_port; +extern unsigned int mariadb_deinitialize_ssl; + +#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG) +#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG) +#define IS_BLOB(n) ((n) & BLOB_FLAG) +#define IS_NUM(t) (((t) <= MYSQL_TYPE_INT24 && (t) != MYSQL_TYPE_TIMESTAMP) || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL) +#define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG) +#define INTERNAL_NUM_FIELD(f) (((f)->type <= MYSQL_TYPE_INT24 && ((f)->type != MYSQL_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == MYSQL_TYPE_YEAR || (f)->type == MYSQL_TYPE_NEWDECIMAL || (f)->type == MYSQL_TYPE_DECIMAL) + + typedef struct st_mysql_field { + char *name; /* Name of column */ + char *org_name; /* Name of original column (added after 3.23.58) */ + char *table; /* Table of column if column was a field */ + char *org_table; /* Name of original table (added after 3.23.58 */ + char *db; /* table schema (added after 3.23.58) */ + char *catalog; /* table catalog (added after 3.23.58) */ + char *def; /* Default value (set by mysql_list_fields) */ + unsigned long length; /* Width of column */ + unsigned long max_length; /* Max width of selected set */ + /* added after 3.23.58 */ + unsigned int name_length; + unsigned int org_name_length; + unsigned int table_length; + unsigned int org_table_length; + unsigned int db_length; + unsigned int catalog_length; + unsigned int def_length; + /***********************/ + unsigned int flags; /* Div flags */ + unsigned int decimals; /* Number of decimals in field */ + unsigned int charsetnr; /* char set number (added in 4.1) */ + enum enum_field_types type; /* Type of field. Se mysql_com.h for types */ + void *extension; /* added in 4.1 */ + } MYSQL_FIELD; + + typedef char **MYSQL_ROW; /* return data as array of strings */ + typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */ + +#define SET_CLIENT_ERROR(a, b, c, d) \ + do { \ + (a)->net.last_errno= (b);\ + strncpy((a)->net.sqlstate, (c), SQLSTATE_LENGTH);\ + (a)->net.sqlstate[SQLSTATE_LENGTH]= 0;\ + strncpy((a)->net.last_error, (d) ? (d) : ER((b)), MYSQL_ERRMSG_SIZE - 1);\ + (a)->net.last_error[MYSQL_ERRMSG_SIZE - 1]= 0;\ + } while(0) + +/* For mysql_async.c */ +#define set_mariadb_error(A,B,C) SET_CLIENT_ERROR((A),(B),(C),0) +extern const char *SQLSTATE_UNKNOWN; +#define unknown_sqlstate SQLSTATE_UNKNOWN + +#define CLEAR_CLIENT_ERROR(a) \ + do { \ + (a)->net.last_errno= 0;\ + strcpy((a)->net.sqlstate, "00000");\ + (a)->net.last_error[0]= '\0';\ + if ((a)->net.extension)\ + (a)->net.extension->extended_errno= 0;\ + } while (0) + +#define MYSQL_COUNT_ERROR (~(unsigned long long) 0) + + + typedef struct st_mysql_rows { + struct st_mysql_rows *next; /* list of rows */ + MYSQL_ROW data; + unsigned long length; + } MYSQL_ROWS; + + typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ + + typedef struct st_mysql_data { + MYSQL_ROWS *data; + void *embedded_info; + MA_MEM_ROOT alloc; + unsigned long long rows; + unsigned int fields; + void *extension; + } MYSQL_DATA; + + enum mysql_option + { + MYSQL_OPT_CONNECT_TIMEOUT, + MYSQL_OPT_COMPRESS, + MYSQL_OPT_NAMED_PIPE, + MYSQL_INIT_COMMAND, + MYSQL_READ_DEFAULT_FILE, + MYSQL_READ_DEFAULT_GROUP, + MYSQL_SET_CHARSET_DIR, + MYSQL_SET_CHARSET_NAME, + MYSQL_OPT_LOCAL_INFILE, + MYSQL_OPT_PROTOCOL, + MYSQL_SHARED_MEMORY_BASE_NAME, + MYSQL_OPT_READ_TIMEOUT, + MYSQL_OPT_WRITE_TIMEOUT, + MYSQL_OPT_USE_RESULT, + MYSQL_OPT_USE_REMOTE_CONNECTION, + MYSQL_OPT_USE_EMBEDDED_CONNECTION, + MYSQL_OPT_GUESS_CONNECTION, + MYSQL_SET_CLIENT_IP, + MYSQL_SECURE_AUTH, + MYSQL_REPORT_DATA_TRUNCATION, + MYSQL_OPT_RECONNECT, + MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + MYSQL_PLUGIN_DIR, + MYSQL_DEFAULT_AUTH, + MYSQL_OPT_BIND, + MYSQL_OPT_SSL_KEY, + MYSQL_OPT_SSL_CERT, + MYSQL_OPT_SSL_CA, + MYSQL_OPT_SSL_CAPATH, + MYSQL_OPT_SSL_CIPHER, + MYSQL_OPT_SSL_CRL, + MYSQL_OPT_SSL_CRLPATH, + /* Connection attribute options */ + MYSQL_OPT_CONNECT_ATTR_RESET, + MYSQL_OPT_CONNECT_ATTR_ADD, + MYSQL_OPT_CONNECT_ATTR_DELETE, + MYSQL_SERVER_PUBLIC_KEY, + MYSQL_ENABLE_CLEARTEXT_PLUGIN, + MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, + MYSQL_OPT_SSL_ENFORCE, + MYSQL_OPT_MAX_ALLOWED_PACKET, + MYSQL_OPT_NET_BUFFER_LENGTH, + MYSQL_OPT_TLS_VERSION, + + /* MariaDB specific */ + MYSQL_PROGRESS_CALLBACK=5999, + MYSQL_OPT_NONBLOCK, + /* MariaDB Connector/C specific */ + MYSQL_DATABASE_DRIVER=7000, + MARIADB_OPT_SSL_FP, /* deprecated, use MARIADB_OPT_TLS_PEER_FP instead */ + MARIADB_OPT_SSL_FP_LIST, /* deprecated, use MARIADB_OPT_TLS_PEER_FP_LIST instead */ + MARIADB_OPT_TLS_PASSPHRASE, /* passphrase for encrypted certificates */ + MARIADB_OPT_TLS_CIPHER_STRENGTH, + MARIADB_OPT_TLS_VERSION, + MARIADB_OPT_TLS_PEER_FP, /* single finger print for server certificate verification */ + MARIADB_OPT_TLS_PEER_FP_LIST, /* finger print white list for server certificate verification */ + MARIADB_OPT_CONNECTION_READ_ONLY, + MYSQL_OPT_CONNECT_ATTRS, /* for mysql_get_optionv */ + MARIADB_OPT_USERDATA, + MARIADB_OPT_CONNECTION_HANDLER, + MARIADB_OPT_PORT, + MARIADB_OPT_UNIXSOCKET, + MARIADB_OPT_PASSWORD, + MARIADB_OPT_HOST, + MARIADB_OPT_USER, + MARIADB_OPT_SCHEMA, + MARIADB_OPT_DEBUG, + MARIADB_OPT_FOUND_ROWS, + MARIADB_OPT_MULTI_RESULTS, + MARIADB_OPT_MULTI_STATEMENTS, + MARIADB_OPT_INTERACTIVE, + MARIADB_OPT_PROXY_HEADER, + MARIADB_OPT_IO_WAIT + }; + + enum mariadb_value { + MARIADB_CHARSET_ID, + MARIADB_CHARSET_NAME, + MARIADB_CLIENT_ERRORS, + MARIADB_CLIENT_VERSION, + MARIADB_CLIENT_VERSION_ID, + MARIADB_CONNECTION_ASYNC_TIMEOUT, + MARIADB_CONNECTION_ASYNC_TIMEOUT_MS, + MARIADB_CONNECTION_MARIADB_CHARSET_INFO, + MARIADB_CONNECTION_ERROR, + MARIADB_CONNECTION_ERROR_ID, + MARIADB_CONNECTION_HOST, + MARIADB_CONNECTION_INFO, + MARIADB_CONNECTION_PORT, + MARIADB_CONNECTION_PROTOCOL_VERSION_ID, + MARIADB_CONNECTION_PVIO_TYPE, + MARIADB_CONNECTION_SCHEMA, + MARIADB_CONNECTION_SERVER_TYPE, + MARIADB_CONNECTION_SERVER_VERSION, + MARIADB_CONNECTION_SERVER_VERSION_ID, + MARIADB_CONNECTION_SOCKET, + MARIADB_CONNECTION_SQLSTATE, + MARIADB_CONNECTION_SSL_CIPHER, + MARIADB_TLS_LIBRARY, + MARIADB_CONNECTION_TLS_VERSION, + MARIADB_CONNECTION_TLS_VERSION_ID, + MARIADB_CONNECTION_TYPE, + MARIADB_CONNECTION_UNIX_SOCKET, + MARIADB_CONNECTION_USER, + MARIADB_MAX_ALLOWED_PACKET, + MARIADB_NET_BUFFER_LENGTH, + MARIADB_CONNECTION_SERVER_STATUS, + MARIADB_CONNECTION_SERVER_CAPABILITIES, + MARIADB_CONNECTION_EXTENDED_SERVER_CAPABILITIES, + MARIADB_CONNECTION_CLIENT_CAPABILITIES + }; + + enum mysql_status { MYSQL_STATUS_READY, + MYSQL_STATUS_GET_RESULT, + MYSQL_STATUS_USE_RESULT, + MYSQL_STATUS_QUERY_SENT, + MYSQL_STATUS_SENDING_LOAD_DATA, + MYSQL_STATUS_FETCHING_DATA, + MYSQL_STATUS_NEXT_RESULT_PENDING, + MYSQL_STATUS_QUIT_SENT, /* object is "destroyed" at this stage */ + MYSQL_STATUS_STMT_RESULT + }; + + enum mysql_protocol_type + { + MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET, + MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY + }; -#define CLIENT_NET_RETRY_COUNT 1 /* Retry count */ -#define CLIENT_NET_READ_TIMEOUT 365 * 24 * 3600 /* Timeout on read */ -#define CLIENT_NET_WRITE_TIMEOUT 365 * 24 * 3600 /* Timeout on write */ - -#define IS_PRI_KEY(n) ((n)&PRI_KEY_FLAG) -#define IS_NOT_NULL(n) ((n)&NOT_NULL_FLAG) -#define IS_BLOB(n) ((n)&BLOB_FLAG) -/** - Returns true if the value is a number which does not need quotes for - the sql_lex.cc parser to parse correctly. -*/ -#define IS_NUM(t) \ - (((t) <= MYSQL_TYPE_INT24 && (t) != MYSQL_TYPE_TIMESTAMP) || \ - (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL) -#define IS_LONGDATA(t) ((t) >= MYSQL_TYPE_TINY_BLOB && (t) <= MYSQL_TYPE_STRING) - -typedef struct MYSQL_FIELD { - char *name; /* Name of column */ - char *org_name; /* Original column name, if an alias */ - char *table; /* Table of column if column was a field */ - char *org_table; /* Org table name, if table was an alias */ - char *db; /* Database for table */ - char *catalog; /* Catalog for table */ - char *def; /* Default value (set by mysql_list_fields) */ - unsigned long length; /* Width of column (create length) */ - unsigned long max_length; /* Max width for selected set */ - unsigned int name_length; - unsigned int org_name_length; - unsigned int table_length; - unsigned int org_table_length; - unsigned int db_length; - unsigned int catalog_length; - unsigned int def_length; - unsigned int flags; /* Div flags */ - unsigned int decimals; /* Number of decimals in field */ - unsigned int charsetnr; /* Character set */ - enum enum_field_types type; /* Type of field. See mysql_com.h for types */ - void *extension; -} MYSQL_FIELD; - -typedef char **MYSQL_ROW; /* return data as array of strings */ -typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */ - -#define MYSQL_COUNT_ERROR (~(my_ulonglong)0) - -/* backward compatibility define - to be removed eventually */ -#define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED - -typedef struct MYSQL_ROWS { - struct MYSQL_ROWS *next; /* list of rows */ - MYSQL_ROW data; - unsigned long length; -} MYSQL_ROWS; - -typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ - -struct MEM_ROOT; - -typedef struct MYSQL_DATA { - MYSQL_ROWS *data; - struct MEM_ROOT *alloc; - my_ulonglong rows; - unsigned int fields; -} MYSQL_DATA; - -enum mysql_option { - MYSQL_OPT_CONNECT_TIMEOUT, - MYSQL_OPT_COMPRESS, - MYSQL_OPT_NAMED_PIPE, - MYSQL_INIT_COMMAND, - MYSQL_READ_DEFAULT_FILE, - MYSQL_READ_DEFAULT_GROUP, - MYSQL_SET_CHARSET_DIR, - MYSQL_SET_CHARSET_NAME, - MYSQL_OPT_LOCAL_INFILE, - MYSQL_OPT_PROTOCOL, - MYSQL_SHARED_MEMORY_BASE_NAME, - MYSQL_OPT_READ_TIMEOUT, - MYSQL_OPT_WRITE_TIMEOUT, - MYSQL_OPT_USE_RESULT, - MYSQL_REPORT_DATA_TRUNCATION, - MYSQL_OPT_RECONNECT, - MYSQL_PLUGIN_DIR, - MYSQL_DEFAULT_AUTH, - MYSQL_OPT_BIND, - MYSQL_OPT_SSL_KEY, - MYSQL_OPT_SSL_CERT, - MYSQL_OPT_SSL_CA, - MYSQL_OPT_SSL_CAPATH, - MYSQL_OPT_SSL_CIPHER, - MYSQL_OPT_SSL_CRL, - MYSQL_OPT_SSL_CRLPATH, - MYSQL_OPT_CONNECT_ATTR_RESET, - MYSQL_OPT_CONNECT_ATTR_ADD, - MYSQL_OPT_CONNECT_ATTR_DELETE, - MYSQL_SERVER_PUBLIC_KEY, - MYSQL_ENABLE_CLEARTEXT_PLUGIN, - MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, - MYSQL_OPT_MAX_ALLOWED_PACKET, - MYSQL_OPT_NET_BUFFER_LENGTH, - MYSQL_OPT_TLS_VERSION, - MYSQL_OPT_SSL_MODE, - MYSQL_OPT_GET_SERVER_PUBLIC_KEY, - MYSQL_OPT_RETRY_COUNT, - MYSQL_OPT_OPTIONAL_RESULTSET_METADATA, - MYSQL_OPT_SSL_FIPS_MODE, - MYSQL_OPT_TLS_CIPHERSUITES +struct st_mysql_options { + unsigned int connect_timeout, read_timeout, write_timeout; + unsigned int port, protocol; + unsigned long client_flag; + char *host,*user,*password,*unix_socket,*db; + struct st_dynamic_array *init_command; + char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name; + char *ssl_key; /* PEM key file */ + char *ssl_cert; /* PEM cert file */ + char *ssl_ca; /* PEM CA file */ + char *ssl_capath; /* PEM directory of CA-s? */ + char *ssl_cipher; + char *shared_memory_base_name; + unsigned long max_allowed_packet; + my_bool use_ssl; /* if to use SSL or not */ + my_bool compress,named_pipe; + my_bool reconnect, unused_1, unused_2, unused_3; + enum mysql_option methods_to_use; + char *bind_address; + my_bool secure_auth; + my_bool report_data_truncation; + /* function pointers for local infile support */ + int (*local_infile_init)(void **, const char *, void *); + int (*local_infile_read)(void *, char *, unsigned int); + void (*local_infile_end)(void *); + int (*local_infile_error)(void *, char *, unsigned int); + void *local_infile_userdata; + struct st_mysql_options_extension *extension; }; -/** - @todo remove the "extension", move st_mysql_options completely - out of mysql.h -*/ -struct st_mysql_options_extention; + typedef struct st_mysql { + NET net; /* Communication parameters */ + void *unused_0; + char *host,*user,*passwd,*unix_socket,*server_version,*host_info; + char *info,*db; + const struct ma_charset_info_st *charset; /* character set */ + MYSQL_FIELD *fields; + MA_MEM_ROOT field_alloc; + unsigned long long affected_rows; + unsigned long long insert_id; /* id if insert on table with NEXTNR */ + unsigned long long extra_info; /* Used by mysqlshow */ + unsigned long thread_id; /* Id for connection in server */ + unsigned long packet_length; + unsigned int port; + unsigned long client_flag; + unsigned long server_capabilities; + unsigned int protocol_version; + unsigned int field_count; + unsigned int server_status; + unsigned int server_language; + unsigned int warning_count; /* warning count, added in 4.1 protocol */ + struct st_mysql_options options; + enum mysql_status status; + my_bool free_me; /* If free in mysql_close */ + my_bool unused_1; + char scramble_buff[20+ 1]; + /* madded after 3.23.58 */ + my_bool unused_2; + void *unused_3, *unused_4, *unused_5, *unused_6; + LIST *stmts; + const struct st_mariadb_methods *methods; + void *thd; + my_bool *unbuffered_fetch_owner; + char *info_buffer; + struct st_mariadb_extension *extension; +} MYSQL; -struct st_mysql_options { - unsigned int connect_timeout, read_timeout, write_timeout; - unsigned int port, protocol; - unsigned long client_flag; - char *host, *user, *password, *unix_socket, *db; - struct Init_commands_array *init_commands; - char *my_cnf_file, *my_cnf_group, *charset_dir, *charset_name; - char *ssl_key; /* PEM key file */ - char *ssl_cert; /* PEM cert file */ - char *ssl_ca; /* PEM CA file */ - char *ssl_capath; /* PEM directory of CA-s? */ - char *ssl_cipher; /* cipher to use */ - char *shared_memory_base_name; - unsigned long max_allowed_packet; - bool compress, named_pipe; - /** - The local address to bind when connecting to remote server. - */ - char *bind_address; - /* 0 - never report, 1 - always report (default) */ - bool report_data_truncation; - - /* function pointers for local infile support */ - int (*local_infile_init)(void **, const char *, void *); - int (*local_infile_read)(void *, char *, unsigned int); - void (*local_infile_end)(void *); - int (*local_infile_error)(void *, char *, unsigned int); - void *local_infile_userdata; - struct st_mysql_options_extention *extension; -}; +typedef struct st_mysql_res { + unsigned long long row_count; + unsigned int field_count, current_field; + MYSQL_FIELD *fields; + MYSQL_DATA *data; + MYSQL_ROWS *data_cursor; + MA_MEM_ROOT field_alloc; + MYSQL_ROW row; /* If unbuffered read */ + MYSQL_ROW current_row; /* buffer to current row */ + unsigned long *lengths; /* column lengths of current row */ + MYSQL *handle; /* for unbuffered reads */ + my_bool eof; /* Used my mysql_fetch_row */ + my_bool is_ps; +} MYSQL_RES; -enum mysql_status { - MYSQL_STATUS_READY, - MYSQL_STATUS_GET_RESULT, - MYSQL_STATUS_USE_RESULT, - MYSQL_STATUS_STATEMENT_GET_RESULT -}; +typedef struct +{ + unsigned long *p_max_allowed_packet; + unsigned long *p_net_buffer_length; + void *extension; +} MYSQL_PARAMETERS; -enum mysql_protocol_type { - MYSQL_PROTOCOL_DEFAULT, - MYSQL_PROTOCOL_TCP, - MYSQL_PROTOCOL_SOCKET, - MYSQL_PROTOCOL_PIPE, - MYSQL_PROTOCOL_MEMORY -}; -enum mysql_ssl_mode { - SSL_MODE_DISABLED = 1, - SSL_MODE_PREFERRED, - SSL_MODE_REQUIRED, - SSL_MODE_VERIFY_CA, - SSL_MODE_VERIFY_IDENTITY +enum mariadb_field_attr_t +{ + MARIADB_FIELD_ATTR_DATA_TYPE_NAME= 0, + MARIADB_FIELD_ATTR_FORMAT_NAME= 1 }; -enum mysql_ssl_fips_mode { - SSL_FIPS_MODE_OFF = 0, - SSL_FIPS_MODE_ON = 1, - SSL_FIPS_MODE_STRICT +#define MARIADB_FIELD_ATTR_LAST MARIADB_FIELD_ATTR_FORMAT_NAME + + +int STDCALL mariadb_field_attr(MARIADB_CONST_STRING *attr, + const MYSQL_FIELD *field, + enum mariadb_field_attr_t type); + +#ifndef _mysql_time_h_ +enum enum_mysql_timestamp_type +{ + MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, + MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2 }; -typedef struct character_set { - unsigned int number; /* character set number */ - unsigned int state; /* character set state */ - const char *csname; /* collation name */ - const char *name; /* character set name */ - const char *comment; /* comment */ - const char *dir; /* character set directory */ - unsigned int mbminlen; /* min. length for multibyte strings */ - unsigned int mbmaxlen; /* max. length for multibyte strings */ +typedef struct st_mysql_time +{ + unsigned int year, month, day, hour, minute, second; + unsigned long second_part; + my_bool neg; + enum enum_mysql_timestamp_type time_type; +} MYSQL_TIME; +#define AUTO_SEC_PART_DIGITS 39 +#endif + +#define SEC_PART_DIGITS 6 +#define MARIADB_INVALID_SOCKET -1 + +/* Asynchronous API constants */ +#define MYSQL_WAIT_READ 1 +#define MYSQL_WAIT_WRITE 2 +#define MYSQL_WAIT_EXCEPT 4 +#define MYSQL_WAIT_TIMEOUT 8 + +typedef struct character_set +{ + unsigned int number; /* character set number */ + unsigned int state; /* character set state */ + const char *csname; /* character set name */ + const char *name; /* collation name */ + const char *comment; /* comment */ + const char *dir; /* character set directory */ + unsigned int mbminlen; /* min. length for multibyte strings */ + unsigned int mbmaxlen; /* max. length for multibyte strings */ } MY_CHARSET_INFO; -struct MYSQL_METHODS; -struct MYSQL_STMT; - -typedef struct MYSQL { - NET net; /* Communication parameters */ - unsigned char *connector_fd; /* ConnectorFd for SSL */ - char *host, *user, *passwd, *unix_socket, *server_version, *host_info; - char *info, *db; - struct CHARSET_INFO *charset; - MYSQL_FIELD *fields; - struct MEM_ROOT *field_alloc; - my_ulonglong affected_rows; - my_ulonglong insert_id; /* id if insert on table with NEXTNR */ - my_ulonglong extra_info; /* Not used */ - unsigned long thread_id; /* Id for connection in server */ - unsigned long packet_length; - unsigned int port; - unsigned long client_flag, server_capabilities; - unsigned int protocol_version; - unsigned int field_count; - unsigned int server_status; - unsigned int server_language; - unsigned int warning_count; - struct st_mysql_options options; - enum mysql_status status; - enum enum_resultset_metadata resultset_metadata; - bool free_me; /* If free in mysql_close */ - bool reconnect; /* set to 1 if automatic reconnect */ - - /* session-wide random string */ - char scramble[SCRAMBLE_LENGTH + 1]; - - LIST *stmts; /* list of all statements */ - const struct MYSQL_METHODS *methods; - void *thd; - /* - Points to boolean flag in MYSQL_RES or MYSQL_STMT. We set this flag - from mysql_stmt_close if close had to cancel result set of this object. - */ - bool *unbuffered_fetch_owner; - void *extension; -} MYSQL; +/* Local infile support functions */ +#define LOCAL_INFILE_ERROR_LEN 512 -typedef struct MYSQL_RES { - my_ulonglong row_count; - MYSQL_FIELD *fields; - struct MYSQL_DATA *data; - MYSQL_ROWS *data_cursor; - unsigned long *lengths; /* column lengths of current row */ - MYSQL *handle; /* for unbuffered reads */ - const struct MYSQL_METHODS *methods; - MYSQL_ROW row; /* If unbuffered read */ - MYSQL_ROW current_row; /* buffer to current row */ - struct MEM_ROOT *field_alloc; - unsigned int field_count, current_field; - bool eof; /* Used by mysql_fetch_row */ - /* mysql_stmt_close() had to cancel this result */ - bool unbuffered_fetch_cancelled; - enum enum_resultset_metadata metadata; - void *extension; -} MYSQL_RES; +#include "mariadb_stmt.h" + +#ifndef MYSQL_CLIENT_PLUGIN_HEADER +#define MYSQL_CLIENT_PLUGIN_HEADER \ + int type; \ + unsigned int interface_version; \ + const char *name; \ + const char *author; \ + const char *desc; \ + unsigned int version[3]; \ + const char *license; \ + void *mysql_api; \ + int (*init)(char *, size_t, int, va_list); \ + int (*deinit)(void); \ + int (*options)(const char *option, const void *); +struct st_mysql_client_plugin +{ + MYSQL_CLIENT_PLUGIN_HEADER +}; -/** - Flag to indicate that COM_BINLOG_DUMP_GTID should - be used rather than COM_BINLOG_DUMP in the @sa mysql_binlog_open(). -*/ -#define MYSQL_RPL_GTID (1 << 16) -/** - Skip HEARBEAT events in the @sa mysql_binlog_fetch(). -*/ -#define MYSQL_RPL_SKIP_HEARTBEAT (1 << 17) - -/** - Struct for information about a replication stream. - - @sa mysql_binlog_open() - @sa mysql_binlog_fetch() - @sa mysql_binlog_close() -*/ -typedef struct MYSQL_RPL { - size_t file_name_length; /** Length of the 'file_name' or 0 */ - const char *file_name; /** Filename of the binary log to read */ - my_ulonglong start_position; /** Position in the binary log to */ - /* start reading from */ - unsigned int server_id; /** Server ID to use when identifying */ - /* with the master */ - unsigned int flags; /** Flags, e.g. MYSQL_RPL_GTID */ - - /** Size of gtid set data */ - size_t gtid_set_encoded_size; - /** Callback function which is called */ - /* from @sa mysql_binlog_open() to */ - /* fill command packet gtid set */ - void (*fix_gtid_set)(struct MYSQL_RPL *rpl, unsigned char *packet_gtid_set); - void *gtid_set_arg; /** GTID set data or an argument for */ - /* fix_gtid_set() callback function */ - - unsigned long size; /** Size of the packet returned by */ - /* mysql_binlog_fetch() */ - const unsigned char *buffer; /** Pointer to returned data */ -} MYSQL_RPL; - -/* - Set up and bring down the server; to ensure that applications will - work when linked against either the standard client library or the - embedded server library, these functions should be called. -*/ -int STDCALL mysql_server_init(int argc, char **argv, char **groups); -void STDCALL mysql_server_end(void); +struct st_mysql_client_plugin * +mysql_load_plugin(struct st_mysql *mysql, const char *name, int type, + int argc, ...); +struct st_mysql_client_plugin * STDCALL +mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type, + int argc, va_list args); +struct st_mysql_client_plugin * STDCALL +mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type); +struct st_mysql_client_plugin * STDCALL +mysql_client_register_plugin(struct st_mysql *mysql, + struct st_mysql_client_plugin *plugin); +#endif -/* - mysql_server_init/end need to be called when using libmysqld or - libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so - you don't need to call it explicitely; but you need to call - mysql_server_end() to free memory). The names are a bit misleading - (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general - names which suit well whether you're using libmysqld or libmysqlclient. We - intend to promote these aliases over the mysql_server* ones. -*/ -#define mysql_library_init mysql_server_init -#define mysql_library_end mysql_server_end -/* - Set up and bring down a thread; these function should be called - for each thread in an application which opens at least one MySQL - connection. All uses of the connection(s) should be between these - function calls. -*/ -bool STDCALL mysql_thread_init(void); -void STDCALL mysql_thread_end(void); +void STDCALL mysql_set_local_infile_handler(MYSQL *mysql, + int (*local_infile_init)(void **, const char *, void *), + int (*local_infile_read)(void *, char *, unsigned int), + void (*local_infile_end)(void *), + int (*local_infile_error)(void *, char*, unsigned int), + void *); -/* - Functions to get information from the MYSQL and MYSQL_RES structures - Should definitely be used if one uses shared libraries. -*/ +void mysql_set_local_infile_default(MYSQL *mysql); + +void my_set_error(MYSQL *mysql, unsigned int error_nr, + const char *sqlstate, const char *format, ...); +/* Functions to get information from the MYSQL and MYSQL_RES structures */ +/* Should definitely be used if one uses shared libraries */ my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res); unsigned int STDCALL mysql_num_fields(MYSQL_RES *res); -bool STDCALL mysql_eof(MYSQL_RES *res); +my_bool STDCALL mysql_eof(MYSQL_RES *res); MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res, - unsigned int fieldnr); -MYSQL_FIELD *STDCALL mysql_fetch_fields(MYSQL_RES *res); -MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res); -MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res); -enum enum_resultset_metadata STDCALL mysql_result_metadata(MYSQL_RES *result); + unsigned int fieldnr); +MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res); +MYSQL_ROWS * STDCALL mysql_row_tell(MYSQL_RES *res); +unsigned int STDCALL mysql_field_tell(MYSQL_RES *res); unsigned int STDCALL mysql_field_count(MYSQL *mysql); +my_bool STDCALL mysql_more_results(MYSQL *mysql); +int STDCALL mysql_next_result(MYSQL *mysql); my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql); +my_bool STDCALL mysql_autocommit(MYSQL *mysql, my_bool mode); +my_bool STDCALL mysql_commit(MYSQL *mysql); +my_bool STDCALL mysql_rollback(MYSQL *mysql); my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql); unsigned int STDCALL mysql_errno(MYSQL *mysql); -const char *STDCALL mysql_error(MYSQL *mysql); -const char *STDCALL mysql_sqlstate(MYSQL *mysql); -unsigned int STDCALL mysql_warning_count(MYSQL *mysql); -const char *STDCALL mysql_info(MYSQL *mysql); +const char * STDCALL mysql_error(MYSQL *mysql); +const char * STDCALL mysql_info(MYSQL *mysql); unsigned long STDCALL mysql_thread_id(MYSQL *mysql); -const char *STDCALL mysql_character_set_name(MYSQL *mysql); +const char * STDCALL mysql_character_set_name(MYSQL *mysql); +void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *cs); int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname); -MYSQL *STDCALL mysql_init(MYSQL *mysql); -bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, - const char *ca, const char *capath, - const char *cipher); -const char *STDCALL mysql_get_ssl_cipher(MYSQL *mysql); -bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, - const char *passwd, const char *db); -MYSQL *STDCALL mysql_real_connect(MYSQL *mysql, const char *host, - const char *user, const char *passwd, - const char *db, unsigned int port, - const char *unix_socket, - unsigned long clientflag); -int STDCALL mysql_select_db(MYSQL *mysql, const char *db); -int STDCALL mysql_query(MYSQL *mysql, const char *q); -int STDCALL mysql_send_query(MYSQL *mysql, const char *q, unsigned long length); -int STDCALL mysql_real_query(MYSQL *mysql, const char *q, unsigned long length); -MYSQL_RES *STDCALL mysql_store_result(MYSQL *mysql); -MYSQL_RES *STDCALL mysql_use_result(MYSQL *mysql); - -enum net_async_status STDCALL mysql_real_connect_nonblocking( - MYSQL *mysql, const char *host, const char *user, const char *passwd, - const char *db, unsigned int port, const char *unix_socket, - unsigned long clientflag); -enum net_async_status STDCALL mysql_send_query_nonblocking( - MYSQL *mysql, const char *query, unsigned long length); -enum net_async_status STDCALL mysql_real_query_nonblocking( - MYSQL *mysql, const char *query, unsigned long length); -enum net_async_status STDCALL -mysql_store_result_nonblocking(MYSQL *mysql, MYSQL_RES **result); -enum net_async_status STDCALL mysql_next_result_nonblocking(MYSQL *mysql); -enum net_async_status STDCALL mysql_select_db_nonblocking(MYSQL *mysql, - const char *db, - bool *error); -void STDCALL mysql_get_character_set_info(MYSQL *mysql, - MY_CHARSET_INFO *charset); - -int STDCALL mysql_session_track_get_first(MYSQL *mysql, - enum enum_session_state_type type, - const char **data, size_t *length); -int STDCALL mysql_session_track_get_next(MYSQL *mysql, - enum enum_session_state_type type, - const char **data, size_t *length); -/* local infile support */ - -#define LOCAL_INFILE_ERROR_LEN 512 - -void mysql_set_local_infile_handler( - MYSQL *mysql, int (*local_infile_init)(void **, const char *, void *), - int (*local_infile_read)(void *, char *, unsigned int), - void (*local_infile_end)(void *), - int (*local_infile_error)(void *, char *, unsigned int), void *); - -void mysql_set_local_infile_default(MYSQL *mysql); -int STDCALL mysql_shutdown(MYSQL *mysql, - enum mysql_enum_shutdown_level shutdown_level); -int STDCALL mysql_dump_debug_info(MYSQL *mysql); -int STDCALL mysql_refresh(MYSQL *mysql, unsigned int refresh_options); -int STDCALL mysql_kill(MYSQL *mysql, unsigned long pid); -int STDCALL mysql_set_server_option(MYSQL *mysql, +my_bool mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *arg, ...); +my_bool STDCALL mariadb_get_info(MYSQL *mysql, enum mariadb_value value, void *arg); +MYSQL * STDCALL mysql_init(MYSQL *mysql); +int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, + const char *cert, const char *ca, + const char *capath, const char *cipher); +const char * STDCALL mysql_get_ssl_cipher(MYSQL *mysql); +my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, + const char *passwd, const char *db); +MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, + const char *user, + const char *passwd, + const char *db, + unsigned int port, + const char *unix_socket, + unsigned long clientflag); +void STDCALL mysql_close(MYSQL *sock); +int STDCALL mysql_select_db(MYSQL *mysql, const char *db); +int STDCALL mysql_query(MYSQL *mysql, const char *q); +int STDCALL mysql_send_query(MYSQL *mysql, const char *q, + unsigned long length); +my_bool STDCALL mysql_read_query_result(MYSQL *mysql); +int STDCALL mysql_real_query(MYSQL *mysql, const char *q, + unsigned long length); +int STDCALL mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level); +int STDCALL mysql_dump_debug_info(MYSQL *mysql); +int STDCALL mysql_refresh(MYSQL *mysql, + unsigned int refresh_options); +int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid); +int STDCALL mysql_ping(MYSQL *mysql); +char * STDCALL mysql_stat(MYSQL *mysql); +char * STDCALL mysql_get_server_info(MYSQL *mysql); +unsigned long STDCALL mysql_get_server_version(MYSQL *mysql); +char * STDCALL mysql_get_host_info(MYSQL *mysql); +unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql); +MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild); +MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild); +MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table, + const char *wild); +MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql); +MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql); +MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql); +int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, + const void *arg); +int STDCALL mysql_options4(MYSQL *mysql,enum mysql_option option, + const void *arg1, const void *arg2); +void STDCALL mysql_free_result(MYSQL_RES *result); +void STDCALL mysql_data_seek(MYSQL_RES *result, + unsigned long long offset); +MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET); +MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result, + MYSQL_FIELD_OFFSET offset); +MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); +unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result); +MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result); +unsigned long STDCALL mysql_escape_string(char *to,const char *from, + unsigned long from_length); +unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql, + char *to,const char *from, + unsigned long length); +unsigned int STDCALL mysql_thread_safe(void); +unsigned int STDCALL mysql_warning_count(MYSQL *mysql); +const char * STDCALL mysql_sqlstate(MYSQL *mysql); +int STDCALL mysql_server_init(int argc, char **argv, char **groups); +void STDCALL mysql_server_end(void); +void STDCALL mysql_thread_end(void); +my_bool STDCALL mysql_thread_init(void); +int STDCALL mysql_set_server_option(MYSQL *mysql, enum enum_mysql_set_option option); -int STDCALL mysql_ping(MYSQL *mysql); -const char *STDCALL mysql_stat(MYSQL *mysql); -const char *STDCALL mysql_get_server_info(MYSQL *mysql); -const char *STDCALL mysql_get_client_info(void); +const char * STDCALL mysql_get_client_info(void); unsigned long STDCALL mysql_get_client_version(void); -const char *STDCALL mysql_get_host_info(MYSQL *mysql); -unsigned long STDCALL mysql_get_server_version(MYSQL *mysql); -unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql); -MYSQL_RES *STDCALL mysql_list_dbs(MYSQL *mysql, const char *wild); -MYSQL_RES *STDCALL mysql_list_tables(MYSQL *mysql, const char *wild); -MYSQL_RES *STDCALL mysql_list_processes(MYSQL *mysql); -int STDCALL mysql_options(MYSQL *mysql, enum mysql_option option, - const void *arg); -int STDCALL mysql_options4(MYSQL *mysql, enum mysql_option option, - const void *arg1, const void *arg2); -int STDCALL mysql_get_option(MYSQL *mysql, enum mysql_option option, - const void *arg); -void STDCALL mysql_free_result(MYSQL_RES *result); -enum net_async_status STDCALL mysql_free_result_nonblocking(MYSQL_RES *result); -void STDCALL mysql_data_seek(MYSQL_RES *result, my_ulonglong offset); -MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, - MYSQL_ROW_OFFSET offset); -MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result, - MYSQL_FIELD_OFFSET offset); -MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); -enum net_async_status STDCALL mysql_fetch_row_nonblocking(MYSQL_RES *res, - MYSQL_ROW *row); - -unsigned long *STDCALL mysql_fetch_lengths(MYSQL_RES *result); -MYSQL_FIELD *STDCALL mysql_fetch_field(MYSQL_RES *result); -MYSQL_RES *STDCALL mysql_list_fields(MYSQL *mysql, const char *table, - const char *wild); -unsigned long STDCALL mysql_escape_string(char *to, const char *from, - unsigned long from_length); -unsigned long STDCALL mysql_hex_string(char *to, const char *from, - unsigned long from_length); -unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql, char *to, - const char *from, - unsigned long length); -unsigned long STDCALL mysql_real_escape_string_quote(MYSQL *mysql, char *to, - const char *from, - unsigned long length, - char quote); +my_bool STDCALL mariadb_connection(MYSQL *mysql); +const char * STDCALL mysql_get_server_name(MYSQL *mysql); +MARIADB_CHARSET_INFO * STDCALL mariadb_get_charset_by_name(const char *csname); +MARIADB_CHARSET_INFO * STDCALL mariadb_get_charset_by_nr(unsigned int csnr); +size_t STDCALL mariadb_convert_string(const char *from, size_t *from_len, MARIADB_CHARSET_INFO *from_cs, + char *to, size_t *to_len, MARIADB_CHARSET_INFO *to_cs, int *errorcode); +int mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...); +int mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...); +int STDCALL mysql_get_option(MYSQL *mysql, enum mysql_option option, void *arg); +unsigned long STDCALL mysql_hex_string(char *to, const char *from, unsigned long len); +my_socket STDCALL mysql_get_socket(MYSQL *mysql); +unsigned int STDCALL mysql_get_timeout_value(const MYSQL *mysql); +unsigned int STDCALL mysql_get_timeout_value_ms(const MYSQL *mysql); +my_bool STDCALL mariadb_reconnect(MYSQL *mysql); +int STDCALL mariadb_cancel(MYSQL *mysql); void STDCALL mysql_debug(const char *debug); -void STDCALL myodbc_remove_escape(MYSQL *mysql, char *name); -unsigned int STDCALL mysql_thread_safe(void); -bool STDCALL mysql_read_query_result(MYSQL *mysql); +unsigned long STDCALL mysql_net_read_packet(MYSQL *mysql); +unsigned long STDCALL mysql_net_field_length(unsigned char **packet); +my_bool STDCALL mysql_embedded(void); +MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void); + +/* Async API */ +int STDCALL mysql_close_start(MYSQL *sock); +int STDCALL mysql_close_cont(MYSQL *sock, int status); +int STDCALL mysql_commit_start(my_bool *ret, MYSQL * mysql); +int STDCALL mysql_commit_cont(my_bool *ret, MYSQL * mysql, int status); +int STDCALL mysql_dump_debug_info_cont(int *ret, MYSQL *mysql, int ready_status); +int STDCALL mysql_dump_debug_info_start(int *ret, MYSQL *mysql); +int STDCALL mysql_rollback_start(my_bool *ret, MYSQL * mysql); +int STDCALL mysql_rollback_cont(my_bool *ret, MYSQL * mysql, int status); +int STDCALL mysql_autocommit_start(my_bool *ret, MYSQL * mysql, + my_bool auto_mode); +int STDCALL mysql_list_fields_cont(MYSQL_RES **ret, MYSQL *mysql, int ready_status); +int STDCALL mysql_list_fields_start(MYSQL_RES **ret, MYSQL *mysql, const char *table, + const char *wild); +int STDCALL mysql_autocommit_cont(my_bool *ret, MYSQL * mysql, int status); +int STDCALL mysql_next_result_start(int *ret, MYSQL *mysql); +int STDCALL mysql_next_result_cont(int *ret, MYSQL *mysql, int status); +int STDCALL mysql_select_db_start(int *ret, MYSQL *mysql, const char *db); +int STDCALL mysql_select_db_cont(int *ret, MYSQL *mysql, int ready_status); +int STDCALL mysql_stmt_warning_count(MYSQL_STMT *stmt); +int STDCALL mysql_stmt_next_result_start(int *ret, MYSQL_STMT *stmt); +int STDCALL mysql_stmt_next_result_cont(int *ret, MYSQL_STMT *stmt, int status); + +int STDCALL mysql_set_character_set_start(int *ret, MYSQL *mysql, + const char *csname); +int STDCALL mysql_set_character_set_cont(int *ret, MYSQL *mysql, + int status); +int STDCALL mysql_change_user_start(my_bool *ret, MYSQL *mysql, + const char *user, + const char *passwd, + const char *db); +int STDCALL mysql_change_user_cont(my_bool *ret, MYSQL *mysql, + int status); +int STDCALL mysql_real_connect_start(MYSQL **ret, MYSQL *mysql, + const char *host, + const char *user, + const char *passwd, + const char *db, + unsigned int port, + const char *unix_socket, + unsigned long clientflag); +int STDCALL mysql_real_connect_cont(MYSQL **ret, MYSQL *mysql, + int status); +int STDCALL mysql_query_start(int *ret, MYSQL *mysql, + const char *q); +int STDCALL mysql_query_cont(int *ret, MYSQL *mysql, + int status); +int STDCALL mysql_send_query_start(int *ret, MYSQL *mysql, + const char *q, + unsigned long length); +int STDCALL mysql_send_query_cont(int *ret, MYSQL *mysql, int status); +int STDCALL mysql_real_query_start(int *ret, MYSQL *mysql, + const char *q, + unsigned long length); +int STDCALL mysql_real_query_cont(int *ret, MYSQL *mysql, + int status); +int STDCALL mysql_store_result_start(MYSQL_RES **ret, MYSQL *mysql); +int STDCALL mysql_store_result_cont(MYSQL_RES **ret, MYSQL *mysql, + int status); +int STDCALL mysql_shutdown_start(int *ret, MYSQL *mysql, + enum mysql_enum_shutdown_level + shutdown_level); +int STDCALL mysql_shutdown_cont(int *ret, MYSQL *mysql, + int status); +int STDCALL mysql_refresh_start(int *ret, MYSQL *mysql, + unsigned int refresh_options); +int STDCALL mysql_refresh_cont(int *ret, MYSQL *mysql, int status); +int STDCALL mysql_kill_start(int *ret, MYSQL *mysql, + unsigned long pid); +int STDCALL mysql_kill_cont(int *ret, MYSQL *mysql, int status); +int STDCALL mysql_set_server_option_start(int *ret, MYSQL *mysql, + enum enum_mysql_set_option + option); +int STDCALL mysql_set_server_option_cont(int *ret, MYSQL *mysql, + int status); +int STDCALL mysql_ping_start(int *ret, MYSQL *mysql); +int STDCALL mysql_ping_cont(int *ret, MYSQL *mysql, int status); +int STDCALL mysql_stat_start(const char **ret, MYSQL *mysql); +int STDCALL mysql_stat_cont(const char **ret, MYSQL *mysql, + int status); +int STDCALL mysql_free_result_start(MYSQL_RES *result); +int STDCALL mysql_free_result_cont(MYSQL_RES *result, int status); +int STDCALL mysql_fetch_row_start(MYSQL_ROW *ret, + MYSQL_RES *result); +int STDCALL mysql_fetch_row_cont(MYSQL_ROW *ret, MYSQL_RES *result, + int status); +int STDCALL mysql_read_query_result_start(my_bool *ret, + MYSQL *mysql); +int STDCALL mysql_read_query_result_cont(my_bool *ret, + MYSQL *mysql, int status); +int STDCALL mysql_reset_connection_start(int *ret, MYSQL *mysql); +int STDCALL mysql_reset_connection_cont(int *ret, MYSQL *mysql, int status); +int STDCALL mysql_session_track_get_next(MYSQL *mysql, enum enum_session_state_type type, const char **data, size_t *length); +int STDCALL mysql_session_track_get_first(MYSQL *mysql, enum enum_session_state_type type, const char **data, size_t *length); +int STDCALL mysql_stmt_prepare_start(int *ret, MYSQL_STMT *stmt,const char *query, unsigned long length); +int STDCALL mysql_stmt_prepare_cont(int *ret, MYSQL_STMT *stmt, int status); +int STDCALL mysql_stmt_execute_start(int *ret, MYSQL_STMT *stmt); +int STDCALL mysql_stmt_execute_cont(int *ret, MYSQL_STMT *stmt, int status); +int STDCALL mysql_stmt_fetch_start(int *ret, MYSQL_STMT *stmt); +int STDCALL mysql_stmt_fetch_cont(int *ret, MYSQL_STMT *stmt, int status); +int STDCALL mysql_stmt_store_result_start(int *ret, MYSQL_STMT *stmt); +int STDCALL mysql_stmt_store_result_cont(int *ret, MYSQL_STMT *stmt,int status); +int STDCALL mysql_stmt_close_start(my_bool *ret, MYSQL_STMT *stmt); +int STDCALL mysql_stmt_close_cont(my_bool *ret, MYSQL_STMT * stmt, int status); +int STDCALL mysql_stmt_reset_start(my_bool *ret, MYSQL_STMT * stmt); +int STDCALL mysql_stmt_reset_cont(my_bool *ret, MYSQL_STMT *stmt, int status); +int STDCALL mysql_stmt_free_result_start(my_bool *ret, MYSQL_STMT *stmt); +int STDCALL mysql_stmt_free_result_cont(my_bool *ret, MYSQL_STMT *stmt, + int status); +int STDCALL mysql_stmt_send_long_data_start(my_bool *ret, MYSQL_STMT *stmt, + unsigned int param_number, + const char *data, + unsigned long len); +int STDCALL mysql_stmt_send_long_data_cont(my_bool *ret, MYSQL_STMT *stmt, + int status); int STDCALL mysql_reset_connection(MYSQL *mysql); -int STDCALL mysql_binlog_open(MYSQL *mysql, MYSQL_RPL *rpl); -int STDCALL mysql_binlog_fetch(MYSQL *mysql, MYSQL_RPL *rpl); -void STDCALL mysql_binlog_close(MYSQL *mysql, MYSQL_RPL *rpl); - -/* - The following definitions are added for the enhanced - client-server protocol -*/ - -/* statement state */ -enum enum_mysql_stmt_state { - MYSQL_STMT_INIT_DONE = 1, - MYSQL_STMT_PREPARE_DONE, - MYSQL_STMT_EXECUTE_DONE, - MYSQL_STMT_FETCH_DONE +/* API function calls (used by dynamic plugins) */ +struct st_mariadb_api { + unsigned long long (STDCALL *mysql_num_rows)(MYSQL_RES *res); + unsigned int (STDCALL *mysql_num_fields)(MYSQL_RES *res); + my_bool (STDCALL *mysql_eof)(MYSQL_RES *res); + MYSQL_FIELD *(STDCALL *mysql_fetch_field_direct)(MYSQL_RES *res, unsigned int fieldnr); + MYSQL_FIELD * (STDCALL *mysql_fetch_fields)(MYSQL_RES *res); + MYSQL_ROWS * (STDCALL *mysql_row_tell)(MYSQL_RES *res); + unsigned int (STDCALL *mysql_field_tell)(MYSQL_RES *res); + unsigned int (STDCALL *mysql_field_count)(MYSQL *mysql); + my_bool (STDCALL *mysql_more_results)(MYSQL *mysql); + int (STDCALL *mysql_next_result)(MYSQL *mysql); + unsigned long long (STDCALL *mysql_affected_rows)(MYSQL *mysql); + my_bool (STDCALL *mysql_autocommit)(MYSQL *mysql, my_bool mode); + my_bool (STDCALL *mysql_commit)(MYSQL *mysql); + my_bool (STDCALL *mysql_rollback)(MYSQL *mysql); + unsigned long long (STDCALL *mysql_insert_id)(MYSQL *mysql); + unsigned int (STDCALL *mysql_errno)(MYSQL *mysql); + const char * (STDCALL *mysql_error)(MYSQL *mysql); + const char * (STDCALL *mysql_info)(MYSQL *mysql); + unsigned long (STDCALL *mysql_thread_id)(MYSQL *mysql); + const char * (STDCALL *mysql_character_set_name)(MYSQL *mysql); + void (STDCALL *mysql_get_character_set_info)(MYSQL *mysql, MY_CHARSET_INFO *cs); + int (STDCALL *mysql_set_character_set)(MYSQL *mysql, const char *csname); + my_bool (*mariadb_get_infov)(MYSQL *mysql, enum mariadb_value value, void *arg, ...); + my_bool (STDCALL *mariadb_get_info)(MYSQL *mysql, enum mariadb_value value, void *arg); + MYSQL * (STDCALL *mysql_init)(MYSQL *mysql); + int (STDCALL *mysql_ssl_set)(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher); + const char * (STDCALL *mysql_get_ssl_cipher)(MYSQL *mysql); + my_bool (STDCALL *mysql_change_user)(MYSQL *mysql, const char *user, const char *passwd, const char *db); + MYSQL * (STDCALL *mysql_real_connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); + void (STDCALL *mysql_close)(MYSQL *sock); + int (STDCALL *mysql_select_db)(MYSQL *mysql, const char *db); + int (STDCALL *mysql_query)(MYSQL *mysql, const char *q); + int (STDCALL *mysql_send_query)(MYSQL *mysql, const char *q, unsigned long length); + my_bool (STDCALL *mysql_read_query_result)(MYSQL *mysql); + int (STDCALL *mysql_real_query)(MYSQL *mysql, const char *q, unsigned long length); + int (STDCALL *mysql_shutdown)(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level); + int (STDCALL *mysql_dump_debug_info)(MYSQL *mysql); + int (STDCALL *mysql_refresh)(MYSQL *mysql, unsigned int refresh_options); + int (STDCALL *mysql_kill)(MYSQL *mysql,unsigned long pid); + int (STDCALL *mysql_ping)(MYSQL *mysql); + char * (STDCALL *mysql_stat)(MYSQL *mysql); + char * (STDCALL *mysql_get_server_info)(MYSQL *mysql); + unsigned long (STDCALL *mysql_get_server_version)(MYSQL *mysql); + char * (STDCALL *mysql_get_host_info)(MYSQL *mysql); + unsigned int (STDCALL *mysql_get_proto_info)(MYSQL *mysql); + MYSQL_RES * (STDCALL *mysql_list_dbs)(MYSQL *mysql,const char *wild); + MYSQL_RES * (STDCALL *mysql_list_tables)(MYSQL *mysql,const char *wild); + MYSQL_RES * (STDCALL *mysql_list_fields)(MYSQL *mysql, const char *table, const char *wild); + MYSQL_RES * (STDCALL *mysql_list_processes)(MYSQL *mysql); + MYSQL_RES * (STDCALL *mysql_store_result)(MYSQL *mysql); + MYSQL_RES * (STDCALL *mysql_use_result)(MYSQL *mysql); + int (STDCALL *mysql_options)(MYSQL *mysql,enum mysql_option option, const void *arg); + void (STDCALL *mysql_free_result)(MYSQL_RES *result); + void (STDCALL *mysql_data_seek)(MYSQL_RES *result, unsigned long long offset); + MYSQL_ROW_OFFSET (STDCALL *mysql_row_seek)(MYSQL_RES *result, MYSQL_ROW_OFFSET); + MYSQL_FIELD_OFFSET (STDCALL *mysql_field_seek)(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset); + MYSQL_ROW (STDCALL *mysql_fetch_row)(MYSQL_RES *result); + unsigned long * (STDCALL *mysql_fetch_lengths)(MYSQL_RES *result); + MYSQL_FIELD * (STDCALL *mysql_fetch_field)(MYSQL_RES *result); + unsigned long (STDCALL *mysql_escape_string)(char *to,const char *from, unsigned long from_length); + unsigned long (STDCALL *mysql_real_escape_string)(MYSQL *mysql, char *to,const char *from, unsigned long length); + unsigned int (STDCALL *mysql_thread_safe)(void); + unsigned int (STDCALL *mysql_warning_count)(MYSQL *mysql); + const char * (STDCALL *mysql_sqlstate)(MYSQL *mysql); + int (STDCALL *mysql_server_init)(int argc, char **argv, char **groups); + void (STDCALL *mysql_server_end)(void); + void (STDCALL *mysql_thread_end)(void); + my_bool (STDCALL *mysql_thread_init)(void); + int (STDCALL *mysql_set_server_option)(MYSQL *mysql, enum enum_mysql_set_option option); + const char * (STDCALL *mysql_get_client_info)(void); + unsigned long (STDCALL *mysql_get_client_version)(void); + my_bool (STDCALL *mariadb_connection)(MYSQL *mysql); + const char * (STDCALL *mysql_get_server_name)(MYSQL *mysql); + MARIADB_CHARSET_INFO * (STDCALL *mariadb_get_charset_by_name)(const char *csname); + MARIADB_CHARSET_INFO * (STDCALL *mariadb_get_charset_by_nr)(unsigned int csnr); + size_t (STDCALL *mariadb_convert_string)(const char *from, size_t *from_len, MARIADB_CHARSET_INFO *from_cs, char *to, size_t *to_len, MARIADB_CHARSET_INFO *to_cs, int *errorcode); + int (*mysql_optionsv)(MYSQL *mysql,enum mysql_option option, ...); + int (*mysql_get_optionv)(MYSQL *mysql, enum mysql_option option, void *arg, ...); + int (STDCALL *mysql_get_option)(MYSQL *mysql, enum mysql_option option, void *arg); + unsigned long (STDCALL *mysql_hex_string)(char *to, const char *from, unsigned long len); + my_socket (STDCALL *mysql_get_socket)(MYSQL *mysql); + unsigned int (STDCALL *mysql_get_timeout_value)(const MYSQL *mysql); + unsigned int (STDCALL *mysql_get_timeout_value_ms)(const MYSQL *mysql); + my_bool (STDCALL *mariadb_reconnect)(MYSQL *mysql); + MYSQL_STMT * (STDCALL *mysql_stmt_init)(MYSQL *mysql); + int (STDCALL *mysql_stmt_prepare)(MYSQL_STMT *stmt, const char *query, unsigned long length); + int (STDCALL *mysql_stmt_execute)(MYSQL_STMT *stmt); + int (STDCALL *mysql_stmt_fetch)(MYSQL_STMT *stmt); + int (STDCALL *mysql_stmt_fetch_column)(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg, unsigned int column, unsigned long offset); + int (STDCALL *mysql_stmt_store_result)(MYSQL_STMT *stmt); + unsigned long (STDCALL *mysql_stmt_param_count)(MYSQL_STMT * stmt); + my_bool (STDCALL *mysql_stmt_attr_set)(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, const void *attr); + my_bool (STDCALL *mysql_stmt_attr_get)(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, void *attr); + my_bool (STDCALL *mysql_stmt_bind_param)(MYSQL_STMT * stmt, MYSQL_BIND * bnd); + my_bool (STDCALL *mysql_stmt_bind_result)(MYSQL_STMT * stmt, MYSQL_BIND * bnd); + my_bool (STDCALL *mysql_stmt_close)(MYSQL_STMT * stmt); + my_bool (STDCALL *mysql_stmt_reset)(MYSQL_STMT * stmt); + my_bool (STDCALL *mysql_stmt_free_result)(MYSQL_STMT *stmt); + my_bool (STDCALL *mysql_stmt_send_long_data)(MYSQL_STMT *stmt, unsigned int param_number, const char *data, unsigned long length); + MYSQL_RES *(STDCALL *mysql_stmt_result_metadata)(MYSQL_STMT *stmt); + MYSQL_RES *(STDCALL *mysql_stmt_param_metadata)(MYSQL_STMT *stmt); + unsigned int (STDCALL *mysql_stmt_errno)(MYSQL_STMT * stmt); + const char *(STDCALL *mysql_stmt_error)(MYSQL_STMT * stmt); + const char *(STDCALL *mysql_stmt_sqlstate)(MYSQL_STMT * stmt); + MYSQL_ROW_OFFSET (STDCALL *mysql_stmt_row_seek)(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET offset); + MYSQL_ROW_OFFSET (STDCALL *mysql_stmt_row_tell)(MYSQL_STMT *stmt); + void (STDCALL *mysql_stmt_data_seek)(MYSQL_STMT *stmt, unsigned long long offset); + unsigned long long (STDCALL *mysql_stmt_num_rows)(MYSQL_STMT *stmt); + unsigned long long (STDCALL *mysql_stmt_affected_rows)(MYSQL_STMT *stmt); + unsigned long long (STDCALL *mysql_stmt_insert_id)(MYSQL_STMT *stmt); + unsigned int (STDCALL *mysql_stmt_field_count)(MYSQL_STMT *stmt); + int (STDCALL *mysql_stmt_next_result)(MYSQL_STMT *stmt); + my_bool (STDCALL *mysql_stmt_more_results)(MYSQL_STMT *stmt); + int (STDCALL *mariadb_stmt_execute_direct)(MYSQL_STMT *stmt, const char *stmtstr, size_t length); + int (STDCALL *mysql_reset_connection)(MYSQL *mysql); }; - -/* - This structure is used to define bind information, and - internally by the client library. - Public members with their descriptions are listed below - (conventionally `On input' refers to the binds given to - mysql_stmt_bind_param, `On output' refers to the binds given - to mysql_stmt_bind_result): - - buffer_type - One of the MYSQL_* types, used to describe - the host language type of buffer. - On output: if column type is different from - buffer_type, column value is automatically converted - to buffer_type before it is stored in the buffer. - buffer - On input: points to the buffer with input data. - On output: points to the buffer capable to store - output data. - The type of memory pointed by buffer must correspond - to buffer_type. See the correspondence table in - the comment to mysql_stmt_bind_param. - - The two above members are mandatory for any kind of bind. - - buffer_length - the length of the buffer. You don't have to set - it for any fixed length buffer: float, double, - int, etc. It must be set however for variable-length - types, such as BLOBs or STRINGs. - - length - On input: in case when lengths of input values - are different for each execute, you can set this to - point at a variable containining value length. This - way the value length can be different in each execute. - If length is not NULL, buffer_length is not used. - Note, length can even point at buffer_length if - you keep bind structures around while fetching: - this way you can change buffer_length before - each execution, everything will work ok. - On output: if length is set, mysql_stmt_fetch will - write column length into it. - - is_null - On input: points to a boolean variable that should - be set to TRUE for NULL values. - This member is useful only if your data may be - NULL in some but not all cases. - If your data is never NULL, is_null should be set to 0. - If your data is always NULL, set buffer_type - to MYSQL_TYPE_NULL, and is_null will not be used. - - is_unsigned - On input: used to signify that values provided for one - of numeric types are unsigned. - On output describes signedness of the output buffer. - If, taking into account is_unsigned flag, column data - is out of range of the output buffer, data for this column - is regarded truncated. Note that this has no correspondence - to the sign of result set column, if you need to find it out - use mysql_stmt_result_metadata. - error - where to write a truncation error if it is present. - possible error value is: - 0 no truncation - 1 value is out of range or buffer is too small - - Please note that MYSQL_BIND also has internals members. -*/ - -typedef struct MYSQL_BIND { - unsigned long *length; /* output length pointer */ - bool *is_null; /* Pointer to null indicator */ - void *buffer; /* buffer to get/put data */ - /* set this if you want to track data truncations happened during fetch */ - bool *error; - unsigned char *row_ptr; /* for the current data position */ - void (*store_param_func)(NET *net, struct MYSQL_BIND *param); - void (*fetch_result)(struct MYSQL_BIND *, MYSQL_FIELD *, unsigned char **row); - void (*skip_result)(struct MYSQL_BIND *, MYSQL_FIELD *, unsigned char **row); - /* output buffer length, must be set when fetching str/binary */ - unsigned long buffer_length; - unsigned long offset; /* offset position for char/binary fetch */ - unsigned long length_value; /* Used if length is 0 */ - unsigned int param_number; /* For null count and error messages */ - unsigned int pack_length; /* Internal length for packed data */ - enum enum_field_types buffer_type; /* buffer type */ - bool error_value; /* used if error is 0 */ - bool is_unsigned; /* set if integer type is unsigned */ - bool long_data_used; /* If used with mysql_send_long_data */ - bool is_null_value; /* Used if is_null is 0 */ - void *extension; -} MYSQL_BIND; - -struct MYSQL_STMT_EXT; - -/* statement handler */ -typedef struct MYSQL_STMT { - struct MEM_ROOT *mem_root; /* root allocations */ - LIST list; /* list to keep track of all stmts */ - MYSQL *mysql; /* connection handle */ - MYSQL_BIND *params; /* input parameters */ - MYSQL_BIND *bind; /* output parameters */ - MYSQL_FIELD *fields; /* result set metadata */ - MYSQL_DATA result; /* cached result set */ - MYSQL_ROWS *data_cursor; /* current row in cached result */ - /* - mysql_stmt_fetch() calls this function to fetch one row (it's different - for buffered, unbuffered and cursor fetch). - */ - int (*read_row_func)(struct MYSQL_STMT *stmt, unsigned char **row); - /* copy of mysql->affected_rows after statement execution */ - my_ulonglong affected_rows; - my_ulonglong insert_id; /* copy of mysql->insert_id */ - unsigned long stmt_id; /* Id for prepared statement */ - unsigned long flags; /* i.e. type of cursor to open */ - unsigned long prefetch_rows; /* number of rows per one COM_FETCH */ - /* - Copied from mysql->server_status after execute/fetch to know - server-side cursor status for this statement. - */ - unsigned int server_status; - unsigned int last_errno; /* error code */ - unsigned int param_count; /* input parameter count */ - unsigned int field_count; /* number of columns in result set */ - enum enum_mysql_stmt_state state; /* statement state */ - char last_error[MYSQL_ERRMSG_SIZE]; /* error message */ - char sqlstate[SQLSTATE_LENGTH + 1]; - /* Types of input parameters should be sent to server */ - bool send_types_to_server; - bool bind_param_done; /* input buffers were supplied */ - unsigned char bind_result_done; /* output buffers were supplied */ - /* mysql_stmt_close() had to cancel this result */ - bool unbuffered_fetch_cancelled; - /* - Is set to true if we need to calculate field->max_length for - metadata fields when doing mysql_stmt_store_result. - */ - bool update_max_length; - struct MYSQL_STMT_EXT *extension; -} MYSQL_STMT; - -enum enum_stmt_attr_type { - /* - When doing mysql_stmt_store_result calculate max_length attribute - of statement metadata. This is to be consistent with the old API, - where this was done automatically. - In the new API we do that only by request because it slows down - mysql_stmt_store_result sufficiently. - */ - STMT_ATTR_UPDATE_MAX_LENGTH, - /* - unsigned long with combination of cursor flags (read only, for update, - etc) - */ - STMT_ATTR_CURSOR_TYPE, - /* - Amount of rows to retrieve from server per one fetch if using cursors. - Accepts unsigned long attribute in the range 1 - ulong_max - */ - STMT_ATTR_PREFETCH_ROWS + +/* these methods can be overwritten by db plugins */ +struct st_mariadb_methods { + MYSQL *(*db_connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd, + const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); + void (*db_close)(MYSQL *mysql); + int (*db_command)(MYSQL *mysql,enum enum_server_command command, const char *arg, + size_t length, my_bool skipp_check, void *opt_arg); + void (*db_skip_result)(MYSQL *mysql); + int (*db_read_query_result)(MYSQL *mysql); + MYSQL_DATA *(*db_read_rows)(MYSQL *mysql,MYSQL_FIELD *fields, unsigned int field_count); + int (*db_read_one_row)(MYSQL *mysql,unsigned int fields,MYSQL_ROW row, unsigned long *lengths); + /* prepared statements */ + my_bool (*db_supported_buffer_type)(enum enum_field_types type); + my_bool (*db_read_prepare_response)(MYSQL_STMT *stmt); + int (*db_read_stmt_result)(MYSQL *mysql); + my_bool (*db_stmt_get_result_metadata)(MYSQL_STMT *stmt); + my_bool (*db_stmt_get_param_metadata)(MYSQL_STMT *stmt); + int (*db_stmt_read_all_rows)(MYSQL_STMT *stmt); + int (*db_stmt_fetch)(MYSQL_STMT *stmt, unsigned char **row); + int (*db_stmt_fetch_to_bind)(MYSQL_STMT *stmt, unsigned char *row); + void (*db_stmt_flush_unbuffered)(MYSQL_STMT *stmt); + void (*set_error)(MYSQL *mysql, unsigned int error_nr, const char *sqlstate, const char *format, ...); + void (*invalidate_stmts)(MYSQL *mysql, const char *function_name); + struct st_mariadb_api *api; }; -MYSQL_STMT *STDCALL mysql_stmt_init(MYSQL *mysql); -int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, - unsigned long length); -int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt); -int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt); -int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg, - unsigned int column, unsigned long offset); -int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt); -unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT *stmt); -bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt, - enum enum_stmt_attr_type attr_type, - const void *attr); -bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt, - enum enum_stmt_attr_type attr_type, - void *attr); -bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bnd); -bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bnd); -bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt); -bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt); -bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt); -bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, - unsigned int param_number, - const char *data, unsigned long length); -MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt); -MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt); -unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT *stmt); -const char *STDCALL mysql_stmt_error(MYSQL_STMT *stmt); -const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT *stmt); -MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, - MYSQL_ROW_OFFSET offset); -MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt); -void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset); -my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt); -my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt); -my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt); -unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt); - -bool STDCALL mysql_commit(MYSQL *mysql); -bool STDCALL mysql_rollback(MYSQL *mysql); -bool STDCALL mysql_autocommit(MYSQL *mysql, bool auto_mode); -bool STDCALL mysql_more_results(MYSQL *mysql); -int STDCALL mysql_next_result(MYSQL *mysql); -int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt); -void STDCALL mysql_close(MYSQL *sock); - -/* Public key reset */ -void STDCALL mysql_reset_server_public_key(void); - -/* status return codes */ -#define MYSQL_NO_DATA 100 -#define MYSQL_DATA_TRUNCATED 101 +/* synonyms/aliases functions */ +#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) +#define mysql_library_init mysql_server_init +#define mysql_library_end mysql_server_end -#define mysql_reload(mysql) mysql_refresh((mysql), REFRESH_GRANT) +/* new api functions */ #define HAVE_MYSQL_REAL_CONNECT -#ifdef __cplusplus + +#ifdef __cplusplus } #endif -#endif /* _mysql_h */ +#endif diff --git a/MySQL/include/mysql/client_plugin.h b/MySQL/include/mysql/client_plugin.h index 96e481b..72939d2 100644 --- a/MySQL/include/mysql/client_plugin.h +++ b/MySQL/include/mysql/client_plugin.h @@ -1,36 +1,29 @@ -#ifndef MYSQL_CLIENT_PLUGIN_INCLUDED -/* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2.0, - as published by the Free Software Foundation. - - This program is also distributed with certain software (including - but not limited to OpenSSL) that is licensed under separate terms, - as designated in a particular file or component or in included license - documentation. The authors of MySQL hereby grant you an additional - permission to link the program and your derivative works with the - separately licensed software that they have included with MySQL. - - Without limiting anything contained in the foregoing, this file, - which is part of C Driver for MySQL (Connector/C), is also subject to the - Universal FOSS Exception, version 1.0, a copy of which can be found at - http://oss.oracle.com/licenses/universal-foss-exception. - - This program is distributed in the hope that it will be useful, +/* Copyright (C) 2010 - 2012 Sergei Golubchik and Monty Program Ab + 2014 MariaDB Corporation AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License, version 2.0, for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not see + or write to the Free Software Foundation, Inc., + 51 Franklin St., Fifth Floor, Boston, MA 02110, USA */ /** - @file include/mysql/client_plugin.h - MySQL Client Plugin API. + @file + + MySQL Client Plugin API + This file defines the API for plugins that work on the client side */ +#ifndef MYSQL_CLIENT_PLUGIN_INCLUDED #define MYSQL_CLIENT_PLUGIN_INCLUDED #ifndef MYSQL_ABI_CHECK @@ -38,95 +31,146 @@ #include #endif -/* - On Windows, exports from DLL need to be declared. - Also, plugin needs to be declared as extern "C" because MSVC - unlike other compilers, uses C++ mangling for variables not only - for functions. -*/ -#undef MYSQL_PLUGIN_EXPORT - -#if defined(_MSC_VER) -#if defined(MYSQL_DYNAMIC_PLUGIN) -#ifdef __cplusplus -#define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport) -#else -#define MYSQL_PLUGIN_EXPORT __declspec(dllexport) -#endif -#else /* MYSQL_DYNAMIC_PLUGIN */ -#ifdef __cplusplus -#define MYSQL_PLUGIN_EXPORT extern "C" -#else -#define MYSQL_PLUGIN_EXPORT -#endif -#endif /*MYSQL_DYNAMIC_PLUGIN */ -#else /*_MSC_VER */ -#define MYSQL_PLUGIN_EXPORT +#ifndef PLUGINDIR +#define PLUGINDIR "lib/plugin" #endif -#ifdef __cplusplus -extern "C" { -#endif +#define plugin_declarations_sym "_mysql_client_plugin_declaration_" /* known plugin types */ -#define MYSQL_CLIENT_reserved1 0 -#define MYSQL_CLIENT_reserved2 1 -#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN 2 -#define MYSQL_CLIENT_TRACE_PLUGIN 3 +#define MYSQL_CLIENT_PLUGIN_RESERVED 0 +#define MYSQL_CLIENT_PLUGIN_RESERVED2 1 +#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN 2 /* authentication */ + +#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0100 +#define MYSQL_CLIENT_MAX_PLUGINS 3 -#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0101 -#define MYSQL_CLIENT_TRACE_PLUGIN_INTERFACE_VERSION 0x0100 +/* Connector/C specific plugin types */ +#define MARIADB_CLIENT_REMOTEIO_PLUGIN 100 /* communication IO */ +#define MARIADB_CLIENT_PVIO_PLUGIN 101 +#define MARIADB_CLIENT_TRACE_PLUGIN 102 +#define MARIADB_CLIENT_CONNECTION_PLUGIN 103 -#define MYSQL_CLIENT_MAX_PLUGINS 4 +#define MARIADB_CLIENT_REMOTEIO_PLUGIN_INTERFACE_VERSION 0x0100 +#define MARIADB_CLIENT_PVIO_PLUGIN_INTERFACE_VERSION 0x0100 +#define MARIADB_CLIENT_TRACE_PLUGIN_INTERFACE_VERSION 0x0100 +#define MARIADB_CLIENT_CONNECTION_PLUGIN_INTERFACE_VERSION 0x0100 -#define mysql_declare_client_plugin(X) \ - MYSQL_PLUGIN_EXPORT st_mysql_client_plugin_##X \ - _mysql_client_plugin_declaration_ = { \ - MYSQL_CLIENT_##X##_PLUGIN, \ - MYSQL_CLIENT_##X##_PLUGIN_INTERFACE_VERSION, -#define mysql_end_client_plugin } +#define MARIADB_CLIENT_MAX_PLUGINS 4 + +#define mysql_declare_client_plugin(X) \ + struct st_mysql_client_plugin_ ## X \ + _mysql_client_plugin_declaration_ = { \ + MYSQL_CLIENT_ ## X ## _PLUGIN, \ + MYSQL_CLIENT_ ## X ## _PLUGIN_INTERFACE_VERSION, +#define mysql_end_client_plugin } /* generic plugin header structure */ -#define MYSQL_CLIENT_PLUGIN_HEADER \ - int type; \ - unsigned int interface_version; \ - const char *name; \ - const char *author; \ - const char *desc; \ - unsigned int version[3]; \ - const char *license; \ - void *mysql_api; \ - int (*init)(char *, size_t, int, va_list); \ - int (*deinit)(void); \ +#ifndef MYSQL_CLIENT_PLUGIN_HEADER +#define MYSQL_CLIENT_PLUGIN_HEADER \ + int type; \ + unsigned int interface_version; \ + const char *name; \ + const char *author; \ + const char *desc; \ + unsigned int version[3]; \ + const char *license; \ + void *mysql_api; \ + int (*init)(char *, size_t, int, va_list); \ + int (*deinit)(void); \ int (*options)(const char *option, const void *); - -struct st_mysql_client_plugin { +struct st_mysql_client_plugin +{ MYSQL_CLIENT_PLUGIN_HEADER }; +#endif + +struct st_mysql; -struct MYSQL; +/********* connection handler plugin specific declarations **********/ + +typedef struct st_ma_connection_plugin +{ + MYSQL_CLIENT_PLUGIN_HEADER + /* functions */ + MYSQL *(*connect)(MYSQL *mysql, const char *host, + const char *user, const char *passwd, + const char *db, unsigned int port, + const char *unix_socket, unsigned long clientflag); + void (*close)(MYSQL *mysql); + int (*set_optionsv)(MYSQL *mysql, unsigned int option, ...); + int (*set_connection)(MYSQL *mysql,enum enum_server_command command, + const char *arg, + size_t length, my_bool skipp_check, void *opt_arg); + my_bool (*reconnect)(MYSQL *mysql); + int (*reset)(MYSQL *mysql); +} MARIADB_CONNECTION_PLUGIN; + +#define MARIADB_DB_DRIVER(a) ((a)->ext_db) + +/******************* Communication IO plugin *****************/ +#include + +typedef struct st_mariadb_client_plugin_PVIO +{ + MYSQL_CLIENT_PLUGIN_HEADER + struct st_ma_pvio_methods *methods; +} MARIADB_PVIO_PLUGIN; /******** authentication plugin specific declarations *********/ -#include "plugin_auth_common.h" +#include -struct auth_plugin_t { +struct st_mysql_client_plugin_AUTHENTICATION +{ MYSQL_CLIENT_PLUGIN_HEADER - int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct MYSQL *mysql); - enum net_async_status (*authenticate_user_nonblocking)(MYSQL_PLUGIN_VIO *vio, - struct MYSQL *mysql, - int *result); + int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql); }; -// Needed for the mysql_declare_client_plugin() macro. Do not use elsewhere. -typedef struct auth_plugin_t st_mysql_client_plugin_AUTHENTICATION; +/******** trace plugin *******/ +struct st_mysql_client_plugin_TRACE +{ + MYSQL_CLIENT_PLUGIN_HEADER +}; + +/** + type of the mysql_authentication_dialog_ask function + + @param mysql mysql + @param type type of the input + 1 - ordinary string input + 2 - password string + @param prompt prompt + @param buf a buffer to store the use input + @param buf_len the length of the buffer + + @retval a pointer to the user input string. + It may be equal to 'buf' or to 'mysql->password'. + In all other cases it is assumed to be an allocated + string, and the "dialog" plugin will free() it. +*/ +typedef char *(*mysql_authentication_dialog_ask_t)(struct st_mysql *mysql, + int type, const char *prompt, char *buf, int buf_len); + +/********************** remote IO plugin **********************/ +#ifdef HAVE_REMOTEIO +#include + +/* Remote IO plugin */ +typedef struct st_mysql_client_plugin_REMOTEIO +{ + MYSQL_CLIENT_PLUGIN_HEADER + struct st_rio_methods *methods; +} MARIADB_REMOTEIO_PLUGIN; +#endif /******** using plugins ************/ /** loads a plugin and initializes it - @param mysql MYSQL structure. + @param mysql MYSQL structure. only MYSQL_PLUGIN_DIR option value is used, + and last_errno/last_error, for error reporting @param name a name of the plugin to load @param type type of plugin that should be loaded, -1 to disable type check @param argc number of arguments to pass to the plugin initialization @@ -136,9 +180,9 @@ typedef struct auth_plugin_t st_mysql_client_plugin_AUTHENTICATION; @retval a pointer to the loaded plugin, or NULL in case of a failure */ -struct st_mysql_client_plugin *mysql_load_plugin(struct MYSQL *mysql, - const char *name, int type, - int argc, ...); +struct st_mysql_client_plugin * +mysql_load_plugin(struct st_mysql *mysql, const char *name, int type, + int argc, ...); /** loads a plugin and initializes it, taking va_list as an argument @@ -146,7 +190,8 @@ struct st_mysql_client_plugin *mysql_load_plugin(struct MYSQL *mysql, This is the same as mysql_load_plugin, but take va_list instead of a list of arguments. - @param mysql MYSQL structure. + @param mysql MYSQL structure. only MYSQL_PLUGIN_DIR option value is used, + and last_errno/last_error, for error reporting @param name a name of the plugin to load @param type type of plugin that should be loaded, -1 to disable type check @param argc number of arguments to pass to the plugin initialization @@ -156,23 +201,23 @@ struct st_mysql_client_plugin *mysql_load_plugin(struct MYSQL *mysql, @retval a pointer to the loaded plugin, or NULL in case of a failure */ -struct st_mysql_client_plugin *mysql_load_plugin_v(struct MYSQL *mysql, - const char *name, int type, - int argc, va_list args); +struct st_mysql_client_plugin * STDCALL +mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type, + int argc, va_list args); /** finds an already loaded plugin by name, or loads it, if necessary - @param mysql MYSQL structure. + @param mysql MYSQL structure. only MYSQL_PLUGIN_DIR option value is used, + and last_errno/last_error, for error reporting @param name a name of the plugin to load @param type type of plugin that should be loaded @retval a pointer to the plugin, or NULL in case of a failure */ -struct st_mysql_client_plugin *mysql_client_find_plugin(struct MYSQL *mysql, - const char *name, - int type); +struct st_mysql_client_plugin * STDCALL +mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type); /** adds a plugin structure to the list of loaded plugins @@ -188,26 +233,12 @@ struct st_mysql_client_plugin *mysql_client_find_plugin(struct MYSQL *mysql, @retval a pointer to the plugin, or NULL in case of a failure */ -struct st_mysql_client_plugin *mysql_client_register_plugin( - struct MYSQL *mysql, struct st_mysql_client_plugin *plugin); - -/** - set plugin options +struct st_mysql_client_plugin * STDCALL +mysql_client_register_plugin(struct st_mysql *mysql, + struct st_mysql_client_plugin *plugin); - Can be used to set extra options and affect behavior for a plugin. - This function may be called multiple times to set several options +extern struct st_mysql_client_plugin *mysql_client_builtins[]; - @param plugin an st_mysql_client_plugin structure - @param option a string which specifies the option to set - @param value value for the option. - - @retval 0 on success, 1 in case of failure -**/ -int mysql_plugin_options(struct st_mysql_client_plugin *plugin, - const char *option, const void *value); - -#ifdef __cplusplus -} #endif -#endif + diff --git a/MySQL/include/mysql/plugin_auth.h b/MySQL/include/mysql/plugin_auth.h new file mode 100644 index 0000000..2be64a6 --- /dev/null +++ b/MySQL/include/mysql/plugin_auth.h @@ -0,0 +1,107 @@ +#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED +/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02111-1301, USA */ + +/** + @file + + This file defines constants and data structures that are the same for + both client- and server-side authentication plugins. +*/ +#define MYSQL_PLUGIN_AUTH_COMMON_INCLUDED + +/** the max allowed length for a user name */ +#define MYSQL_USERNAME_LENGTH 512 + +/** + return values of the plugin authenticate_user() method. +*/ + +/** + Authentication failed. Additionally, all other CR_xxx values + (libmariadb error code) can be used too. + + The client plugin may set the error code and the error message directly + in the MYSQL structure and return CR_ERROR. If a CR_xxx specific error + code was returned, an error message in the MYSQL structure will be + overwritten. If CR_ERROR is returned without setting the error in MYSQL, + CR_UNKNOWN_ERROR will be user. +*/ +#define CR_ERROR 0 +/** + Authentication (client part) was successful. It does not mean that the + authentication as a whole was successful, usually it only means + that the client was able to send the user name and the password to the + server. If CR_OK is returned, the libmariadb reads the next packet expecting + it to be one of OK, ERROR, or CHANGE_PLUGIN packets. +*/ +#define CR_OK -1 +/** + Authentication was successful. + It means that the client has done its part successfully and also that + a plugin has read the last packet (one of OK, ERROR, CHANGE_PLUGIN). + In this case, libmariadb will not read a packet from the server, + but it will use the data at mysql->net.read_pos. + + A plugin may return this value if the number of roundtrips in the + authentication protocol is not known in advance, and the client plugin + needs to read one packet more to determine if the authentication is finished + or not. +*/ +#define CR_OK_HANDSHAKE_COMPLETE -2 + +typedef struct st_plugin_vio_info +{ + enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET, + MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol; + int socket; /**< it's set, if the protocol is SOCKET or TCP */ +#ifdef _WIN32 + HANDLE handle; /**< it's set, if the protocol is PIPE or MEMORY */ +#endif +} MYSQL_PLUGIN_VIO_INFO; + +/** + Provides plugin access to communication channel +*/ +typedef struct st_plugin_vio +{ + /** + Plugin provides a pointer reference and this function sets it to the + contents of any incoming packet. Returns the packet length, or -1 if + the plugin should terminate. + */ + int (*read_packet)(struct st_plugin_vio *vio, + unsigned char **buf); + + /** + Plugin provides a buffer with data and the length and this + function sends it as a packet. Returns 0 on success, 1 on failure. + */ + int (*write_packet)(struct st_plugin_vio *vio, + const unsigned char *packet, + int packet_len); + + /** + Fills in a st_plugin_vio_info structure, providing the information + about the connection. + */ + void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info); + +} MYSQL_PLUGIN_VIO; + +#endif + diff --git a/MySQL/include/mysql/plugin_auth_common.h b/MySQL/include/mysql/plugin_auth_common.h index 8447005..ee4b8b9 100644 --- a/MySQL/include/mysql/plugin_auth_common.h +++ b/MySQL/include/mysql/plugin_auth_common.h @@ -1,33 +1,24 @@ -#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED -/* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2.0, - as published by the Free Software Foundation. - - This program is also distributed with certain software (including - but not limited to OpenSSL) that is licensed under separate terms, - as designated in a particular file or component or in included license - documentation. The authors of MySQL hereby grant you an additional - permission to link the program and your derivative works with the - separately licensed software that they have included with MySQL. - - Without limiting anything contained in the foregoing, this file, - which is part of C Driver for MySQL (Connector/C), is also subject to the - Universal FOSS Exception, version 1.0, a copy of which can be found at - http://oss.oracle.com/licenses/universal-foss-exception. - - This program is distributed in the hope that it will be useful, +/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License, version 2.0, for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02111-1301, USA */ - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED /** - @file include/mysql/plugin_auth_common.h + @file This file defines constants and data structures that are the same for both client- and server-side authentication plugins. @@ -35,36 +26,15 @@ #define MYSQL_PLUGIN_AUTH_COMMON_INCLUDED /** the max allowed length for a user name */ -#define MYSQL_USERNAME_LENGTH 96 +#define MYSQL_USERNAME_LENGTH 512 /** return values of the plugin authenticate_user() method. */ -/** - Authentication failed, plugin internal error. - An error occurred in the authentication plugin itself. - These errors are reported in table performance_schema.host_cache, - column COUNT_AUTH_PLUGIN_ERRORS. -*/ -#define CR_AUTH_PLUGIN_ERROR 3 -/** - Authentication failed, client server handshake. - An error occurred during the client server handshake. - These errors are reported in table performance_schema.host_cache, - column COUNT_HANDSHAKE_ERRORS. -*/ -#define CR_AUTH_HANDSHAKE 2 -/** - Authentication failed, user credentials. - For example, wrong passwords. - These errors are reported in table performance_schema.host_cache, - column COUNT_AUTHENTICATION_ERRORS. -*/ -#define CR_AUTH_USER_CREDENTIALS 1 /** Authentication failed. Additionally, all other CR_xxx values - (libmysql error code) can be used too. + (libmariadb error code) can be used too. The client plugin may set the error code and the error message directly in the MYSQL structure and return CR_ERROR. If a CR_xxx specific error @@ -77,7 +47,7 @@ Authentication (client part) was successful. It does not mean that the authentication as a whole was successful, usually it only means that the client was able to send the user name and the password to the - server. If CR_OK is returned, the libmysql reads the next packet expecting + server. If CR_OK is returned, the libmariadb reads the next packet expecting it to be one of OK, ERROR, or CHANGE_PLUGIN packets. */ #define CR_OK -1 @@ -85,7 +55,7 @@ Authentication was successful. It means that the client has done its part successfully and also that a plugin has read the last packet (one of OK, ERROR, CHANGE_PLUGIN). - In this case, libmysql will not read a packet from the server, + In this case, libmariadb will not read a packet from the server, but it will use the data at mysql->net.read_pos. A plugin may return this value if the number of roundtrips in the @@ -95,88 +65,46 @@ */ #define CR_OK_HANDSHAKE_COMPLETE -2 -/** -Flag to be passed back to server from authentication plugins via -authenticated_as when proxy mapping should be done by the server. -*/ -#define PROXY_FLAG 0 - -/* - We need HANDLE definition if on Windows. Define WIN32_LEAN_AND_MEAN (if - not already done) to minimize amount of imported declarations. -*/ -#ifdef _WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include +typedef struct st_plugin_vio_info +{ + enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET, + MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol; +#ifndef _WIN32 + int socket; /**< it's set, if the protocol is SOCKET or TCP */ +#else + SOCKET socket; /**< it's set, if the protocol is SOCKET or TCP */ + HANDLE handle; /**< it's set, if the protocol is PIPE or MEMORY */ #endif - -struct MYSQL_PLUGIN_VIO_INFO { - enum { - MYSQL_VIO_INVALID, - MYSQL_VIO_TCP, - MYSQL_VIO_SOCKET, - MYSQL_VIO_PIPE, - MYSQL_VIO_MEMORY - } protocol; - int socket; /**< it's set, if the protocol is SOCKET or TCP */ -#ifdef _WIN32 - HANDLE handle; /**< it's set, if the protocol is PIPE or MEMORY */ -#endif -}; - -/* state of an asynchronous operation */ -enum net_async_status { - NET_ASYNC_COMPLETE = 0, - NET_ASYNC_NOT_READY, - NET_ASYNC_ERROR, - NET_ASYNC_COMPLETE_NO_MORE_RESULTS -}; +} MYSQL_PLUGIN_VIO_INFO; /** Provides plugin access to communication channel */ -typedef struct MYSQL_PLUGIN_VIO { +typedef struct st_plugin_vio +{ /** Plugin provides a pointer reference and this function sets it to the contents of any incoming packet. Returns the packet length, or -1 if the plugin should terminate. */ - int (*read_packet)(struct MYSQL_PLUGIN_VIO *vio, unsigned char **buf); - + int (*read_packet)(struct st_plugin_vio *vio, + unsigned char **buf); + /** Plugin provides a buffer with data and the length and this function sends it as a packet. Returns 0 on success, 1 on failure. */ - int (*write_packet)(struct MYSQL_PLUGIN_VIO *vio, const unsigned char *packet, + int (*write_packet)(struct st_plugin_vio *vio, + const unsigned char *packet, int packet_len); /** - Fills in a MYSQL_PLUGIN_VIO_INFO structure, providing the information + Fills in a st_plugin_vio_info structure, providing the information about the connection. */ - void (*info)(struct MYSQL_PLUGIN_VIO *vio, - struct MYSQL_PLUGIN_VIO_INFO *info); - - /** - Non blocking version of read_packet. This function points buf to starting - position of incoming packet. When this function returns NET_ASYNC_NOT_READY - plugin should call this function again until all incoming packets are read. - If return code is NET_ASYNC_COMPLETE, plugin can do further processing of - read packets. - */ - enum net_async_status (*read_packet_nonblocking)(struct MYSQL_PLUGIN_VIO *vio, - unsigned char **buf, - int *result); - /** - Non blocking version of write_packet. Sends data available in pkt of length - pkt_len to server in asynchrnous way. - */ - enum net_async_status (*write_packet_nonblocking)( - struct MYSQL_PLUGIN_VIO *vio, const unsigned char *pkt, int pkt_len, - int *result); + void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info); } MYSQL_PLUGIN_VIO; #endif + diff --git a/MySQL/include/mysql/udf_registration_types.h b/MySQL/include/mysql/udf_registration_types.h deleted file mode 100644 index 874b2ff..0000000 --- a/MySQL/include/mysql/udf_registration_types.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License, version 2.0, -as published by the Free Software Foundation. - -This program is also distributed with certain software (including -but not limited to OpenSSL) that is licensed under separate terms, -as designated in a particular file or component or in included license -documentation. The authors of MySQL hereby grant you an additional -permission to link the program and your derivative works with the -separately licensed software that they have included with MySQL. - -Without limiting anything contained in the foregoing, this file, -which is part of C Driver for MySQL (Connector/C), is also subject to the -Universal FOSS Exception, version 1.0, a copy of which can be found at -http://oss.oracle.com/licenses/universal-foss-exception. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License, version 2.0, for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#ifndef UDF_REGISTRATION_TYPES_H -#define UDF_REGISTRATION_TYPES_H - -#ifndef MYSQL_ABI_CHECK -#include -#endif - -/** -Type of the user defined function return slot and arguments -*/ -enum Item_result { - INVALID_RESULT = -1, /** not valid for UDFs */ - STRING_RESULT = 0, /** char * */ - REAL_RESULT, /** double */ - INT_RESULT, /** long long */ - ROW_RESULT, /** not valid for UDFs */ - DECIMAL_RESULT /** char *, to be converted to/from a decimal */ -}; - -typedef struct UDF_ARGS { - unsigned int arg_count; /**< Number of arguments */ - enum Item_result *arg_type; /**< Pointer to item_results */ - char **args; /**< Pointer to argument */ - unsigned long *lengths; /**< Length of string arguments */ - char *maybe_null; /**< Set to 1 for all maybe_null args */ - char **attributes; /**< Pointer to attribute name */ - unsigned long *attribute_lengths; /**< Length of attribute arguments */ - void *extension; -} UDF_ARGS; - -/** -Information about the result of a user defined function - -@todo add a notion for determinism of the UDF. - -@sa Item_udf_func::update_used_tables() -*/ -typedef struct UDF_INIT { - bool maybe_null; /** 1 if function can return NULL */ - unsigned int decimals; /** for real functions */ - unsigned long max_length; /** For string functions */ - char *ptr; /** free pointer for function data */ - bool const_item; /** 1 if function always returns the same value */ - void *extension; -} UDF_INIT; - -enum Item_udftype { UDFTYPE_FUNCTION = 1, UDFTYPE_AGGREGATE }; - -typedef void (*Udf_func_clear)(UDF_INIT *, unsigned char *, unsigned char *); -typedef void (*Udf_func_add)(UDF_INIT *, UDF_ARGS *, unsigned char *, - unsigned char *); -typedef void (*Udf_func_deinit)(UDF_INIT *); -typedef bool (*Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *); -typedef void (*Udf_func_any)(void); -typedef double (*Udf_func_double)(UDF_INIT *, UDF_ARGS *, unsigned char *, - unsigned char *); -typedef long long (*Udf_func_longlong)(UDF_INIT *, UDF_ARGS *, unsigned char *, - unsigned char *); -typedef char *(*Udf_func_string)(UDF_INIT *, UDF_ARGS *, char *, - unsigned long *, unsigned char *, - unsigned char *); - -#endif /* UDF_REGISTRATION_TYPES_H */ diff --git a/MySQL/include/mysql_com.h b/MySQL/include/mysql_com.h deleted file mode 100644 index 38a3b58..0000000 --- a/MySQL/include/mysql_com.h +++ /dev/null @@ -1,1089 +0,0 @@ -/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2.0, - as published by the Free Software Foundation. - - This program is also distributed with certain software (including - but not limited to OpenSSL) that is licensed under separate terms, - as designated in a particular file or component or in included license - documentation. The authors of MySQL hereby grant you an additional - permission to link the program and your derivative works with the - separately licensed software that they have included with MySQL. - - Without limiting anything contained in the foregoing, this file, - which is part of C Driver for MySQL (Connector/C), is also subject to the - Universal FOSS Exception, version 1.0, a copy of which can be found at - http://oss.oracle.com/licenses/universal-foss-exception. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License, version 2.0, for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -/** - @file include/mysql_com.h - Common definition between mysql server & client. -*/ - -#ifndef _mysql_com_h -#define _mysql_com_h - -#ifndef MYSQL_ABI_CHECK -#include -#endif - -#include "my_command.h" - -/* - We need a definition for my_socket. On the client, already provides - it, but on the server side, we need to get it from a header. -*/ -#ifndef my_socket_defined -#include "my_io.h" -#endif - -#ifndef MYSQL_ABI_CHECK -#include -#endif - -#define SYSTEM_CHARSET_MBMAXLEN 3 -#define FILENAME_CHARSET_MBMAXLEN 5 -#define NAME_CHAR_LEN 64 /**< Field/table name length */ -#define PARTITION_EXPR_CHAR_LEN \ - 2048 /**< Maximum expression length in chars \ - */ -#define USERNAME_CHAR_LENGTH 32 -#define USERNAME_CHAR_LENGTH_STR "32" -#ifndef NAME_LEN -#define NAME_LEN (NAME_CHAR_LEN * SYSTEM_CHARSET_MBMAXLEN) -#endif -#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH * SYSTEM_CHARSET_MBMAXLEN) -#define CONNECT_STRING_MAXLEN 1024 - -#define MYSQL_AUTODETECT_CHARSET_NAME "auto" - -#define SERVER_VERSION_LENGTH 60 -#define SQLSTATE_LENGTH 5 - -/** - Maximum length of comments - - pre 5.6: 60 characters -*/ -#define TABLE_COMMENT_INLINE_MAXLEN 180 -#define TABLE_COMMENT_MAXLEN 2048 -#define COLUMN_COMMENT_MAXLEN 1024 -#define INDEX_COMMENT_MAXLEN 1024 -#define TABLE_PARTITION_COMMENT_MAXLEN 1024 -#define TABLESPACE_COMMENT_MAXLEN 2048 - -/** - Maximum length of protocol packet. - @ref page_protocol_basic_ok_packet length limit also restricted to this value - as any length greater than this value will have first byte of - @ref page_protocol_basic_ok_packet to be 254 thus does not - provide a means to identify if this is @ref page_protocol_basic_ok_packet or - @ref page_protocol_basic_eof_packet. -*/ -#define MAX_PACKET_LENGTH (256L * 256L * 256L - 1) - -#define LOCAL_HOST "localhost" -#define LOCAL_HOST_NAMEDPIPE "." - -#if defined(_WIN32) -#define MYSQL_NAMEDPIPE "MySQL" -#define MYSQL_SERVICENAME "MySQL" -#endif /* _WIN32 */ - -/** The length of the header part for each generated column in the .frm file.*/ -#define FRM_GCOL_HEADER_SIZE 4 -/** - Maximum length of the expression statement defined for generated columns. -*/ -#define GENERATED_COLUMN_EXPRESSION_MAXLEN 65535 - FRM_GCOL_HEADER_SIZE -/** - Length of random string sent by server on handshake; this is also length of - obfuscated password, received from client -*/ -#define SCRAMBLE_LENGTH 20 -#define AUTH_PLUGIN_DATA_PART_1_LENGTH 8 -/** length of password stored in the db: new passwords are preceeded with '*'*/ -#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH * 2 + 1) - -/** - @defgroup group_cs_column_definition_flags Column Definition Flags - @ingroup group_cs - - @brief Values for the flags bitmask used by ::Send_field:flags - - Currently need to fit into 32 bits. - - Each bit represents an optional feature of the protocol. - - Both the client and the server are sending these. - - The intersection of the two determines what optional parts of the - protocol will be used. -*/ - -/** - @addtogroup group_cs_column_definition_flags - @{ -*/ - -#define NOT_NULL_FLAG 1 /**< Field can't be NULL */ -#define PRI_KEY_FLAG 2 /**< Field is part of a primary key */ -#define UNIQUE_KEY_FLAG 4 /**< Field is part of a unique key */ -#define MULTIPLE_KEY_FLAG 8 /**< Field is part of a key */ -#define BLOB_FLAG 16 /**< Field is a blob */ -#define UNSIGNED_FLAG 32 /**< Field is unsigned */ -#define ZEROFILL_FLAG 64 /**< Field is zerofill */ -#define BINARY_FLAG 128 /**< Field is binary */ - -/* The following are only sent to new clients */ -#define ENUM_FLAG 256 /**< field is an enum */ -#define AUTO_INCREMENT_FLAG 512 /**< field is a autoincrement field */ -#define TIMESTAMP_FLAG 1024 /**< Field is a timestamp */ -#define SET_FLAG 2048 /**< field is a set */ -#define NO_DEFAULT_VALUE_FLAG 4096 /**< Field doesn't have default value */ -#define ON_UPDATE_NOW_FLAG 8192 /**< Field is set to NOW on UPDATE */ -#define NUM_FLAG 32768 /**< Field is num (for clients) */ -#define PART_KEY_FLAG 16384 /**< Intern; Part of some key */ -#define GROUP_FLAG 32768 /**< Intern: Group field */ -#define UNIQUE_FLAG 65536 /**< Intern: Used by sql_yacc */ -#define BINCMP_FLAG 131072 /**< Intern: Used by sql_yacc */ -#define GET_FIXED_FIELDS_FLAG \ - (1 << 18) /**< Used to get fields in item tree \ - */ -#define FIELD_IN_PART_FUNC_FLAG (1 << 19) /**< Field part of partition func */ -/** - Intern: Field in TABLE object for new version of altered table, - which participates in a newly added index. -*/ -#define FIELD_IN_ADD_INDEX (1 << 20) -#define FIELD_IS_RENAMED (1 << 21) /**< Intern: Field is being renamed */ -#define FIELD_FLAGS_STORAGE_MEDIA 22 /**< Field storage media, bit 22-23 */ -#define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA) -#define FIELD_FLAGS_COLUMN_FORMAT 24 /**< Field column format, bit 24-25 */ -#define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT) -#define FIELD_IS_DROPPED (1 << 26) /**< Intern: Field is being dropped */ -#define EXPLICIT_NULL_FLAG \ - (1 << 27) /**< Field is explicitly specified as \ - NULL by the user */ -#define FIELD_IS_MARKED \ - (1 << 28) /**< Intern: field is marked, \ - general purpose */ - -/** Field will not be loaded in secondary engine. */ -#define NOT_SECONDARY_FLAG (1 << 29) - -/** @}*/ - -/** - @defgroup group_cs_com_refresh_flags COM_REFRESH Flags - @ingroup group_cs - - @brief Values for the `sub_command` in ::COM_REFRESH - - Currently the protocol carries only 8 bits of these flags. - - The rest (8-end) are used only internally in the server. -*/ - -/** - @addtogroup group_cs_com_refresh_flags - @{ -*/ - -#define REFRESH_GRANT 1 /**< Refresh grant tables, FLUSH PRIVILEGES */ -#define REFRESH_LOG 2 /**< Start on new log file, FLUSH LOGS */ -#define REFRESH_TABLES 4 /**< close all tables, FLUSH TABLES */ -#define REFRESH_HOSTS 8 /**< Flush host cache, FLUSH HOSTS */ -#define REFRESH_STATUS 16 /**< Flush status variables, FLUSH STATUS */ -#define REFRESH_THREADS 32 /**< Flush thread cache */ -#define REFRESH_SLAVE \ - 64 /**< Reset master info and restart slave \ - thread, RESET SLAVE */ -#define REFRESH_MASTER \ - 128 /**< Remove all bin logs in the index \ - and truncate the index, RESET MASTER */ -#define REFRESH_ERROR_LOG 256 /**< Rotate only the erorr log */ -#define REFRESH_ENGINE_LOG 512 /**< Flush all storage engine logs */ -#define REFRESH_BINARY_LOG 1024 /**< Flush the binary log */ -#define REFRESH_RELAY_LOG 2048 /**< Flush the relay log */ -#define REFRESH_GENERAL_LOG 4096 /**< Flush the general log */ -#define REFRESH_SLOW_LOG 8192 /**< Flush the slow query log */ -#define REFRESH_READ_LOCK 16384 /**< Lock tables for read. */ -/** - Wait for an impending flush before closing the tables. - - @sa REFRESH_READ_LOCK, handle_reload_request, close_cached_tables -*/ -#define REFRESH_FAST 32768 -#define REFRESH_USER_RESOURCES 0x80000L /** FLISH RESOUCES. @sa ::reset_mqh */ -#define REFRESH_FOR_EXPORT 0x100000L /** FLUSH TABLES ... FOR EXPORT */ -#define REFRESH_OPTIMIZER_COSTS 0x200000L /** FLUSH OPTIMIZER_COSTS */ -#define REFRESH_PERSIST 0x400000L /** RESET PERSIST */ - -/** @}*/ - -/** - @defgroup group_cs_capabilities_flags Capabilities Flags - @ingroup group_cs - - @brief Values for the capabilities flag bitmask used by the MySQL protocol - - Currently need to fit into 32 bits. - - Each bit represents an optional feature of the protocol. - - Both the client and the server are sending these. - - The intersection of the two determines whast optional parts of the - protocol will be used. -*/ - -/** - @addtogroup group_cs_capabilities_flags - @{ -*/ - -/** - Use the improved version of Old Password Authentication. - - Not used. - - @note Assumed to be set since 4.1.1. -*/ -#define CLIENT_LONG_PASSWORD 1 -/** - Send found rows instead of affected rows in @ref - page_protocol_basic_eof_packet -*/ -#define CLIENT_FOUND_ROWS 2 -/** - @brief Get all column flags - - Longer flags in Protocol::ColumnDefinition320. - - @todo Reference Protocol::ColumnDefinition320 - - Server - ------ - - Supports longer flags. - - Client - ------ - - Expects longer flags. -*/ -#define CLIENT_LONG_FLAG 4 -/** - Database (schema) name can be specified on connect in Handshake Response - Packet. - - @todo Reference Handshake Response Packet. - - Server - ------ - - Supports schema-name in Handshake Response Packet. - - Client - ------ - - Handshake Response Packet contains a schema-name. - - @sa send_client_reply_packet() -*/ -#define CLIENT_CONNECT_WITH_DB 8 -#define CLIENT_NO_SCHEMA 16 /**< Don't allow database.table.column */ -/** - Compression protocol supported. - - @todo Reference Compression - - Server - ------ - - Supports compression. - - Client - ------ - - Switches to Compression compressed protocol after successful authentication. -*/ -#define CLIENT_COMPRESS 32 -/** - Special handling of ODBC behavior. - - @note No special behavior since 3.22. -*/ -#define CLIENT_ODBC 64 -/** - Can use LOAD DATA LOCAL. - - Server - ------ - - Enables the LOCAL INFILE request of LOAD DATA|XML. - - Client - ------ - - Will handle LOCAL INFILE request. -*/ -#define CLIENT_LOCAL_FILES 128 -/** - Ignore spaces before '(' - - Server - ------ - - Parser can ignore spaces before '('. - - Client - ------ - - Let the parser ignore spaces before '('. -*/ -#define CLIENT_IGNORE_SPACE 256 -/** - New 4.1 protocol - - @todo Reference the new 4.1 protocol - - Server - ------ - - Supports the 4.1 protocol. - - Client - ------ - - Uses the 4.1 protocol. - - @note this value was CLIENT_CHANGE_USER in 3.22, unused in 4.0 -*/ -#define CLIENT_PROTOCOL_41 512 -/** - This is an interactive client - - Use @ref System_variables::net_wait_timeout - versus @ref System_variables::net_interactive_timeout. - - Server - ------ - - Supports interactive and noninteractive clients. - - Client - ------ - - Client is interactive. - - @sa mysql_real_connect() -*/ -#define CLIENT_INTERACTIVE 1024 -/** - Use SSL encryption for the session - - @todo Reference SSL - - Server - ------ - - Supports SSL - - Client - ------ - - Switch to SSL after sending the capability-flags. -*/ -#define CLIENT_SSL 2048 -/** - Client only flag. Not used. - - Client - ------ - - Do not issue SIGPIPE if network failures occur (libmysqlclient only). - - @sa mysql_real_connect() -*/ -#define CLIENT_IGNORE_SIGPIPE 4096 -/** - Client knows about transactions - - Server - ------ - - Can send status flags in @ref page_protocol_basic_ok_packet / - @ref page_protocol_basic_eof_packet. - - Client - ------ - - Expects status flags in @ref page_protocol_basic_ok_packet / - @ref page_protocol_basic_eof_packet. - - @note This flag is optional in 3.23, but always set by the server since 4.0. - @sa send_server_handshake_packet(), parse_client_handshake_packet(), - net_send_ok(), net_send_eof() -*/ -#define CLIENT_TRANSACTIONS 8192 -#define CLIENT_RESERVED 16384 /**< DEPRECATED: Old flag for 4.1 protocol */ -#define CLIENT_RESERVED2 \ - 32768 /**< DEPRECATED: Old flag for 4.1 authentication \ - CLIENT_SECURE_CONNECTION */ -/** - Enable/disable multi-stmt support - - Also sets @ref CLIENT_MULTI_RESULTS. Currently not checked anywhere. - - Server - ------ - - Can handle multiple statements per COM_QUERY and COM_STMT_PREPARE. - - Client - ------- - - May send multiple statements per COM_QUERY and COM_STMT_PREPARE. - - @note Was named ::CLIENT_MULTI_QUERIES in 4.1.0, renamed later. - - Requires - -------- - - ::CLIENT_PROTOCOL_41 - - @todo Reference COM_QUERY and COM_STMT_PREPARE -*/ -#define CLIENT_MULTI_STATEMENTS (1UL << 16) -/** - Enable/disable multi-results - - Server - ------ - - Can send multiple resultsets for COM_QUERY. - Error if the server needs to send them and client - does not support them. - - Client - ------- - - Can handle multiple resultsets for COM_QUERY. - - Requires - -------- - - ::CLIENT_PROTOCOL_41 - - @sa mysql_execute_command(), sp_head::MULTI_RESULTS -*/ -#define CLIENT_MULTI_RESULTS (1UL << 17) -/** - Multi-results and OUT parameters in PS-protocol. - - Server - ------ - - Can send multiple resultsets for COM_STMT_EXECUTE. - - Client - ------ - - Can handle multiple resultsets for COM_STMT_EXECUTE. - - Requires - -------- - - ::CLIENT_PROTOCOL_41 - - @todo Reference COM_STMT_EXECUTE and PS-protocol - - @sa Protocol_binary::send_out_parameters -*/ -#define CLIENT_PS_MULTI_RESULTS (1UL << 18) - -/** - Client supports plugin authentication - - Server - ------ - - Sends extra data in Initial Handshake Packet and supports the pluggable - authentication protocol. - - Client - ------ - - Supports authentication plugins. - - Requires - -------- - - ::CLIENT_PROTOCOL_41 - - @todo Reference plugin authentication, Initial Handshake Packet, - Authentication plugins - - @sa send_change_user_packet(), send_client_reply_packet(), run_plugin_auth(), - parse_com_change_user_packet(), parse_client_handshake_packet() -*/ -#define CLIENT_PLUGIN_AUTH (1UL << 19) -/** - Client supports connection attributes - - Server - ------ - - Permits connection attributes in Protocol::HandshakeResponse41. - - Client - ------ - - Sends connection attributes in Protocol::HandshakeResponse41. - - @todo Reference Protocol::HandshakeResponse41 - - @sa send_client_connect_attrs(), read_client_connect_attrs() -*/ -#define CLIENT_CONNECT_ATTRS (1UL << 20) - -/** - Enable authentication response packet to be larger than 255 bytes. - - When the ability to change default plugin require that the initial password - field in the Protocol::HandshakeResponse41 paclet can be of arbitrary size. - However, the 4.1 client-server protocol limits the length of the - auth-data-field sent from client to server to 255 bytes. - The solution is to change the type of the field to a true length encoded - string and indicate the protocol change - with this client capability flag. - - Server - ------ - - Understands length-encoded integer for auth response data in - Protocol::HandshakeResponse41. - - Client - ------ - - Length of auth response data in Protocol::HandshakeResponse41 - is a length-encoded integer. - - @todo Reference Protocol::HandshakeResponse41 - - @note The flag was introduced in 5.6.6, but had the wrong value. - - @sa send_client_reply_packet(), parse_client_handshake_packet(), - get_56_lenc_string(), get_41_lenc_string() -*/ -#define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21) - -/** - Don't close the connection for a user account with expired password. - - Server - ------ - - Announces support for expired password extension. - - Client - ------ - - Can handle expired passwords. - - @todo Reference expired password - - @sa MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, disconnect_on_expired_password - ACL_USER::password_expired, check_password_lifetime(), acl_authenticate() -*/ -#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22) - -/** - Capable of handling server state change information. Its a hint to the - server to include the state change information in - @ref page_protocol_basic_ok_packet. - - Server - ------ - Can set ::SERVER_SESSION_STATE_CHANGED in the ::SERVER_STATUS_flags_enum - and send @ref sect_protocol_basic_ok_packet_sessinfo in a - @ref page_protocol_basic_ok_packet. - - Client - ------ - - Expects the server to send @ref sect_protocol_basic_ok_packet_sessinfo in - a @ref page_protocol_basic_ok_packet. - - @sa enum_session_state_type, read_ok_ex(), net_send_ok(), Session_tracker, - State_tracker -*/ -#define CLIENT_SESSION_TRACK (1UL << 23) -/** - Client no longer needs @ref page_protocol_basic_eof_packet and will - use @ref page_protocol_basic_ok_packet instead. - @sa net_send_ok() - - Server - ------ - - Can send OK after a Text Resultset. - - Client - ------ - - Expects an @ref page_protocol_basic_ok_packet (instead of - @ref page_protocol_basic_eof_packet) after the resultset rows of a - Text Resultset. - - Background - ---------- - - To support ::CLIENT_SESSION_TRACK, additional information must be sent after - all successful commands. Although the @ref page_protocol_basic_ok_packet is - extensible, the @ref page_protocol_basic_eof_packet is not due to the overlap - of its bytes with the content of the Text Resultset Row. - - Therefore, the @ref page_protocol_basic_eof_packet in the - Text Resultset is replaced with an @ref page_protocol_basic_ok_packet. - @ref page_protocol_basic_eof_packet is deprecated as of MySQL 5.7.5. - - @todo Reference Text Resultset - - @sa cli_safe_read_with_ok(), read_ok_ex(), net_send_ok(), net_send_eof() -*/ -#define CLIENT_DEPRECATE_EOF (1UL << 24) - -/** - Verify server certificate. - - Client only flag. - - @deprecated in favor of --ssl-mode. -*/ -#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) - -/** - The client can handle optional metadata information in the resultset. -*/ -#define CLIENT_OPTIONAL_RESULTSET_METADATA (1UL << 25) - -/** - Don't reset the options after an unsuccessful connect - - Client only flag. - - Typically passed via ::mysql_real_connect() 's client_flag parameter. - - @sa mysql_real_connect() -*/ -#define CLIENT_REMEMBER_OPTIONS (1UL << 31) -/** @}*/ - -/** a compatibility alias for CLIENT_COMPRESS */ -#define CAN_CLIENT_COMPRESS CLIENT_COMPRESS - -/** Gather all possible capabilites (flags) supported by the server */ -#define CLIENT_ALL_FLAGS \ - (CLIENT_LONG_PASSWORD | CLIENT_FOUND_ROWS | CLIENT_LONG_FLAG | \ - CLIENT_CONNECT_WITH_DB | CLIENT_NO_SCHEMA | CLIENT_COMPRESS | CLIENT_ODBC | \ - CLIENT_LOCAL_FILES | CLIENT_IGNORE_SPACE | CLIENT_PROTOCOL_41 | \ - CLIENT_INTERACTIVE | CLIENT_SSL | CLIENT_IGNORE_SIGPIPE | \ - CLIENT_TRANSACTIONS | CLIENT_RESERVED | CLIENT_RESERVED2 | \ - CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS | CLIENT_PS_MULTI_RESULTS | \ - CLIENT_SSL_VERIFY_SERVER_CERT | CLIENT_REMEMBER_OPTIONS | \ - CLIENT_PLUGIN_AUTH | CLIENT_CONNECT_ATTRS | \ - CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \ - CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS | CLIENT_SESSION_TRACK | \ - CLIENT_DEPRECATE_EOF | CLIENT_OPTIONAL_RESULTSET_METADATA) - -/** - Switch off from ::CLIENT_ALL_FLAGS the flags that are optional and - depending on build flags. - If any of the optional flags is supported by the build it will be switched - on before sending to the client during the connection handshake. -*/ -#define CLIENT_BASIC_FLAGS \ - (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) & ~CLIENT_COMPRESS) & \ - ~CLIENT_SSL_VERIFY_SERVER_CERT) - -/** The status flags are a bit-field */ -enum SERVER_STATUS_flags_enum { - /** - Is raised when a multi-statement transaction - has been started, either explicitly, by means - of BEGIN or COMMIT AND CHAIN, or - implicitly, by the first transactional - statement, when autocommit=off. - */ - SERVER_STATUS_IN_TRANS = 1, - SERVER_STATUS_AUTOCOMMIT = 2, /**< Server in auto_commit mode */ - SERVER_MORE_RESULTS_EXISTS = 8, /**< Multi query - next query exists */ - SERVER_QUERY_NO_GOOD_INDEX_USED = 16, - SERVER_QUERY_NO_INDEX_USED = 32, - /** - The server was able to fulfill the clients request and opened a - read-only non-scrollable cursor for a query. This flag comes - in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. - Used by Binary Protocol Resultset to signal that COM_STMT_FETCH - must be used to fetch the row-data. - @todo Refify "Binary Protocol Resultset" and "COM_STMT_FETCH". - */ - SERVER_STATUS_CURSOR_EXISTS = 64, - /** - This flag is sent when a read-only cursor is exhausted, in reply to - COM_STMT_FETCH command. - */ - SERVER_STATUS_LAST_ROW_SENT = 128, - SERVER_STATUS_DB_DROPPED = 256, /**< A database was dropped */ - SERVER_STATUS_NO_BACKSLASH_ESCAPES = 512, - /** - Sent to the client if after a prepared statement reprepare - we discovered that the new statement returns a different - number of result set columns. - */ - SERVER_STATUS_METADATA_CHANGED = 1024, - SERVER_QUERY_WAS_SLOW = 2048, - /** - To mark ResultSet containing output parameter values. - */ - SERVER_PS_OUT_PARAMS = 4096, - - /** - Set at the same time as SERVER_STATUS_IN_TRANS if the started - multi-statement transaction is a read-only transaction. Cleared - when the transaction commits or aborts. Since this flag is sent - to clients in OK and EOF packets, the flag indicates the - transaction status at the end of command execution. - */ - SERVER_STATUS_IN_TRANS_READONLY = 8192, - - /** - This status flag, when on, implies that one of the state information has - changed on the server because of the execution of the last statement. - */ - SERVER_SESSION_STATE_CHANGED = (1UL << 14) -}; - -/** - Server status flags that must be cleared when starting - execution of a new SQL statement. - Flags from this set are only added to the - current server status by the execution engine, but - never removed -- the execution engine expects them - to disappear automagically by the next command. -*/ -#define SERVER_STATUS_CLEAR_SET \ - (SERVER_QUERY_NO_GOOD_INDEX_USED | SERVER_QUERY_NO_INDEX_USED | \ - SERVER_MORE_RESULTS_EXISTS | SERVER_STATUS_METADATA_CHANGED | \ - SERVER_QUERY_WAS_SLOW | SERVER_STATUS_DB_DROPPED | \ - SERVER_STATUS_CURSOR_EXISTS | SERVER_STATUS_LAST_ROW_SENT | \ - SERVER_SESSION_STATE_CHANGED) - -/** Max length of a error message. Should be kept in sync with ::ERRMSGSIZE. */ -#define MYSQL_ERRMSG_SIZE 512 -#define NET_READ_TIMEOUT 30 /**< Timeout on read */ -#define NET_WRITE_TIMEOUT 60 /**< Timeout on write */ -#define NET_WAIT_TIMEOUT 8 * 60 * 60 /**< Wait for new query */ - -/** - Flag used by the parser. Kill only the query and not the connection. - - @sa SQLCOM_KILL, sql_kill(), LEX::type -*/ -#define ONLY_KILL_QUERY 1 - -#ifndef MYSQL_VIO -struct Vio; -#define MYSQL_VIO struct Vio * -#endif - -#define MAX_TINYINT_WIDTH 3 /**< Max width for a TINY w.o. sign */ -#define MAX_SMALLINT_WIDTH 5 /**< Max width for a SHORT w.o. sign */ -#define MAX_MEDIUMINT_WIDTH 8 /**< Max width for a INT24 w.o. sign */ -#define MAX_INT_WIDTH 10 /**< Max width for a LONG w.o. sign */ -#define MAX_BIGINT_WIDTH 20 /**< Max width for a LONGLONG */ -#define MAX_CHAR_WIDTH 255 /**< Max length for a CHAR colum */ -#define MAX_BLOB_WIDTH 16777216 /**< Default width for blob */ - -typedef struct NET { - MYSQL_VIO vio; - unsigned char *buff, *buff_end, *write_pos, *read_pos; - my_socket fd; /* For Perl DBI/dbd */ - /** - Set if we are doing several queries in one - command ( as in LOAD TABLE ... FROM MASTER ), - and do not want to confuse the client with OK at the wrong time - */ - unsigned long remain_in_buf, length, buf_length, where_b; - unsigned long max_packet, max_packet_size; - unsigned int pkt_nr, compress_pkt_nr; - unsigned int write_timeout, read_timeout, retry_count; - int fcntl; - unsigned int *return_status; - unsigned char reading_or_writing; - unsigned char save_char; - bool compress; - unsigned int last_errno; - unsigned char error; - /** Client library error message buffer. Actually belongs to struct MYSQL. */ - char last_error[MYSQL_ERRMSG_SIZE]; - /** Client library sqlstate buffer. Set along with the error message. */ - char sqlstate[SQLSTATE_LENGTH + 1]; - /** - Extension pointer, for the caller private use. - Any program linking with the networking library can use this pointer, - which is handy when private connection specific data needs to be - maintained. - The mysqld server process uses this pointer internally, - to maintain the server internal instrumentation for the connection. - */ - void *extension; -} NET; - -#define packet_error (~(unsigned long)0) - -/** - @addtogroup group_cs_backward_compatibility Backward compatibility - @ingroup group_cs - @{ -*/ -#define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS -#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL -#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL -#define FIELD_TYPE_TINY MYSQL_TYPE_TINY -#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT -#define FIELD_TYPE_LONG MYSQL_TYPE_LONG -#define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT -#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE -#define FIELD_TYPE_NULL MYSQL_TYPE_NULL -#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP -#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG -#define FIELD_TYPE_INT24 MYSQL_TYPE_INT24 -#define FIELD_TYPE_DATE MYSQL_TYPE_DATE -#define FIELD_TYPE_TIME MYSQL_TYPE_TIME -#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME -#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR -#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE -#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM -#define FIELD_TYPE_SET MYSQL_TYPE_SET -#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB -#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB -#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB -#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB -#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING -#define FIELD_TYPE_STRING MYSQL_TYPE_STRING -#define FIELD_TYPE_CHAR MYSQL_TYPE_TINY -#define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM -#define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY -#define FIELD_TYPE_BIT MYSQL_TYPE_BIT -/** @}*/ - -/** - @addtogroup group_cs_shutdown_kill_constants Shutdown/kill enums and constants - @ingroup group_cs - - @sa THD::is_killable - @{ -*/ -#define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0) -#define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1) -#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2) -#define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3) - -/** - We want levels to be in growing order of hardness (because we use number - comparisons). - - @note ::SHUTDOWN_DEFAULT does not respect the growing property, but it's ok. -*/ -enum mysql_enum_shutdown_level { - SHUTDOWN_DEFAULT = 0, - /** Wait for existing connections to finish */ - SHUTDOWN_WAIT_CONNECTIONS = MYSQL_SHUTDOWN_KILLABLE_CONNECT, - /** Wait for existing transactons to finish */ - SHUTDOWN_WAIT_TRANSACTIONS = MYSQL_SHUTDOWN_KILLABLE_TRANS, - /** Wait for existing updates to finish (=> no partial MyISAM update) */ - SHUTDOWN_WAIT_UPDATES = MYSQL_SHUTDOWN_KILLABLE_UPDATE, - /** Flush InnoDB buffers and other storage engines' buffers*/ - SHUTDOWN_WAIT_ALL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1), - /** Don't flush InnoDB buffers, flush other storage engines' buffers*/ - SHUTDOWN_WAIT_CRITICAL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1, - /** Query level of the KILL command */ - KILL_QUERY = 254, - /** Connection level of the KILL command */ - KILL_CONNECTION = 255 -}; -/** @}*/ - -enum enum_resultset_metadata { - /** No metadata will be sent. */ - RESULTSET_METADATA_NONE = 0, - /** The server will send all metadata. */ - RESULTSET_METADATA_FULL = 1 -}; - -enum enum_cursor_type { - CURSOR_TYPE_NO_CURSOR = 0, - CURSOR_TYPE_READ_ONLY = 1, - CURSOR_TYPE_FOR_UPDATE = 2, - CURSOR_TYPE_SCROLLABLE = 4 -}; - -/** options for ::mysql_options() */ -enum enum_mysql_set_option { - MYSQL_OPTION_MULTI_STATEMENTS_ON, - MYSQL_OPTION_MULTI_STATEMENTS_OFF -}; - -/** - Type of state change information that the server can include in the Ok - packet. - - @note - - session_state_type shouldn't go past 255 (i.e. 1-byte boundary). - - Modify the definition of ::SESSION_TRACK_END when a new member is added. -*/ -enum enum_session_state_type { - SESSION_TRACK_SYSTEM_VARIABLES, /**< Session system variables */ - SESSION_TRACK_SCHEMA, /**< Current schema */ - SESSION_TRACK_STATE_CHANGE, /**< track session state changes */ - SESSION_TRACK_GTIDS, /**< See also: session_track_gtids */ - SESSION_TRACK_TRANSACTION_CHARACTERISTICS, /**< Transaction chistics */ - SESSION_TRACK_TRANSACTION_STATE /**< Transaction state */ -}; - -/** start of ::enum_session_state_type */ -#define SESSION_TRACK_BEGIN SESSION_TRACK_SYSTEM_VARIABLES - -/** End of ::enum_session_state_type */ -#define SESSION_TRACK_END SESSION_TRACK_TRANSACTION_STATE - -/** is T a valid session state type */ -#define IS_SESSION_STATE_TYPE(T) \ - (((int)(T) >= SESSION_TRACK_BEGIN) && ((T) <= SESSION_TRACK_END)) - -#define net_new_transaction(net) ((net)->pkt_nr = 0) - -bool my_net_init(struct NET *net, MYSQL_VIO vio); -void my_net_local_init(struct NET *net); -void net_end(struct NET *net); -void net_clear(struct NET *net, bool check_buffer); -void net_claim_memory_ownership(struct NET *net); -bool net_realloc(struct NET *net, size_t length); -bool net_flush(struct NET *net); -bool my_net_write(struct NET *net, const unsigned char *packet, size_t len); -bool net_write_command(struct NET *net, unsigned char command, - const unsigned char *header, size_t head_len, - const unsigned char *packet, size_t len); -bool net_write_packet(struct NET *net, const unsigned char *packet, - size_t length); -unsigned long my_net_read(struct NET *net); -void my_net_set_write_timeout(struct NET *net, unsigned int timeout); -void my_net_set_read_timeout(struct NET *net, unsigned int timeout); -void my_net_set_retry_count(struct NET *net, unsigned int retry_count); - -struct rand_struct { - unsigned long seed1, seed2, max_value; - double max_value_dbl; -}; - -/* Include the types here so existing UDFs can keep compiling */ -#include - -/** - @addtogroup group_cs_compresson_constants Constants when using compression - @ingroup group_cs - @{ -*/ -#define NET_HEADER_SIZE 4 /**< standard header size */ -#define COMP_HEADER_SIZE 3 /**< compression header extra size */ -/** @}*/ - -/* Prototypes to password functions */ - -/* - These functions are used for authentication by client and server and - implemented in sql/password.c -*/ - -void randominit(struct rand_struct *, unsigned long seed1, unsigned long seed2); -double my_rnd(struct rand_struct *); -void create_random_string(char *to, unsigned int length, - struct rand_struct *rand_st); - -void hash_password(unsigned long *to, const char *password, - unsigned int password_len); -void make_scrambled_password_323(char *to, const char *password); -void scramble_323(char *to, const char *message, const char *password); -bool check_scramble_323(const unsigned char *reply, const char *message, - unsigned long *salt); -void get_salt_from_password_323(unsigned long *res, const char *password); -void make_password_from_salt_323(char *to, const unsigned long *salt); - -void make_scrambled_password(char *to, const char *password); -void scramble(char *to, const char *message, const char *password); -bool check_scramble(const unsigned char *reply, const char *message, - const unsigned char *hash_stage2); -void get_salt_from_password(unsigned char *res, const char *password); -void make_password_from_salt(char *to, const unsigned char *hash_stage2); -char *octet2hex(char *to, const char *str, unsigned int len); - -/* end of password.c */ - -bool generate_sha256_scramble(unsigned char *dst, size_t dst_size, - const char *src, size_t src_size, const char *rnd, - size_t rnd_size); - -// extern "C" since it is an (undocumented) part of the libmysql ABI. -#ifdef __cplusplus -extern "C" { -#endif -char *get_tty_password(const char *opt_message); -#ifdef __cplusplus -} -#endif - -const char *mysql_errno_to_sqlstate(unsigned int mysql_errno); - -/* Some other useful functions */ - -// Need to be extern "C" for the time being, due to memcached. -#ifdef __cplusplus -extern "C" { -#endif -bool my_thread_init(void); -void my_thread_end(void); -#ifdef __cplusplus -} -#endif - -#ifdef STDCALL -unsigned long STDCALL net_field_length(unsigned char **packet); -unsigned long STDCALL net_field_length_checked(unsigned char **packet, - unsigned long max_length); -#endif -unsigned long long net_field_length_ll(unsigned char **packet); -unsigned char *net_store_length(unsigned char *pkg, unsigned long long length); -unsigned int net_length_size(unsigned long long num); -unsigned int net_field_length_size(const unsigned char *pos); - -#define NULL_LENGTH ((unsigned long)~0) /**< For ::net_store_length() */ -#define MYSQL_STMT_HEADER 4 -#define MYSQL_LONG_DATA_HEADER 6 - -#define NOT_FIXED_DEC 31 -#endif diff --git a/MySQL/include/mysql_time.h b/MySQL/include/mysql_time.h deleted file mode 100644 index fee0733..0000000 --- a/MySQL/include/mysql_time.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2.0, - as published by the Free Software Foundation. - - This program is also distributed with certain software (including - but not limited to OpenSSL) that is licensed under separate terms, - as designated in a particular file or component or in included license - documentation. The authors of MySQL hereby grant you an additional - permission to link the program and your derivative works with the - separately licensed software that they have included with MySQL. - - Without limiting anything contained in the foregoing, this file, - which is part of C Driver for MySQL (Connector/C), is also subject to the - Universal FOSS Exception, version 1.0, a copy of which can be found at - http://oss.oracle.com/licenses/universal-foss-exception. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License, version 2.0, for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#ifndef _mysql_time_h_ -#define _mysql_time_h_ - -/** - @file include/mysql_time.h - Time declarations shared between the server and client API: - you should not add anything to this header unless it's used - (and hence should be visible) in mysql.h. - If you're looking for a place to add new time-related declaration, - it's most likely my_time.h. See also "C API Handling of Date - and Time Values" chapter in documentation. -*/ - -// Do not not pull in the server header "my_inttypes.h" from client code. -// IWYU pragma: no_include "my_inttypes.h" - -enum enum_mysql_timestamp_type { - MYSQL_TIMESTAMP_NONE = -2, - MYSQL_TIMESTAMP_ERROR = -1, - MYSQL_TIMESTAMP_DATE = 0, - MYSQL_TIMESTAMP_DATETIME = 1, - MYSQL_TIMESTAMP_TIME = 2 -}; - -/* - Structure which is used to represent datetime values inside MySQL. - - We assume that values in this structure are normalized, i.e. year <= 9999, - month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions - in server such as my_system_gmt_sec() or make_time() family of functions - rely on this (actually now usage of make_*() family relies on a bit weaker - restriction). Also functions that produce MYSQL_TIME as result ensure this. - There is one exception to this rule though if this structure holds time - value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold - bigger values. -*/ -typedef struct MYSQL_TIME { - unsigned int year, month, day, hour, minute, second; - unsigned long second_part; /**< microseconds */ - bool neg; - enum enum_mysql_timestamp_type time_type; -} MYSQL_TIME; - -#endif /* _mysql_time_h_ */ diff --git a/MySQL/include/mysql_version.h b/MySQL/include/mysql_version.h deleted file mode 100644 index af39acc..0000000 --- a/MySQL/include/mysql_version.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright Abandoned 1996,1999 TCX DataKonsult AB & Monty Program KB - & Detron HB, 1996, 1999-2004, 2007 MySQL AB. - This file is public domain and comes with NO WARRANTY of any kind -*/ - -/* Version numbers for protocol & mysqld */ - -#ifndef _mysql_version_h -#define _mysql_version_h - -#define PROTOCOL_VERSION 10 -#define MYSQL_SERVER_VERSION "8.0.17" -#define MYSQL_BASE_VERSION "mysqld-8.0" -#define MYSQL_SERVER_SUFFIX_DEF "" -#define MYSQL_VERSION_ID 80017 -#define MYSQL_PORT 3306 -#define MYSQL_ADMIN_PORT 33062 -#define MYSQL_PORT_DEFAULT 0 -#define MYSQL_UNIX_ADDR "/tmp/mysql.sock" -#define MYSQL_CONFIG_NAME "my" -#define MYSQL_PERSIST_CONFIG_NAME "mysqld-auto" -#define MYSQL_COMPILATION_COMMENT "MySQL Community - GPL" -#define MYSQL_COMPILATION_COMMENT_SERVER "MySQL Community Server - GPL" -#define LIBMYSQL_VERSION "8.0.17" -#define LIBMYSQL_VERSION_ID 80017 -#define SYS_SCHEMA_VERSION "2.1.0" - -#ifndef LICENSE -#define LICENSE GPL -#endif /* LICENSE */ - -#endif /* _mysql_version_h */ diff --git a/MySQL/include/mysqld_error.h b/MySQL/include/mysqld_error.h index 4f28068..6a42ffc 100644 --- a/MySQL/include/mysqld_error.h +++ b/MySQL/include/mysqld_error.h @@ -1,36 +1,11 @@ -/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. +/* Autogenerated file, please don't edit + branch: 10.2 + revision id: 01a4eb8f761eb669fe2ae5139c73a7434b141a8f + */ - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2.0, - as published by the Free Software Foundation. - - This program is also distributed with certain software (including - but not limited to OpenSSL) that is licensed under separate terms, - as designated in a particular file or component or in included license - documentation. The authors of MySQL hereby grant you an additional - permission to link the program and your derivative works with the - separately licensed software that they have included with MySQL. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License, version 2.0, for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* Autogenerated file, please don't edit */ - -#ifndef MYSQLD_ERROR_INCLUDED -#define MYSQLD_ERROR_INCLUDED - -static const int errmsg_section_start[] = { 1000, 3000, 3500, 10000 }; -static const int errmsg_section_size[] = { 888, 227, 417, 3485 }; - -static const int total_error_count = 5017; - -//#define OBSOLETE_ER_HASHCHK 1000 -//#define OBSOLETE_ER_NISAMCHK 1001 +#define ER_ERROR_FIRST 1000 +#define ER_HASHCHK 1000 +#define ER_NISAMCHK 1001 #define ER_NO 1002 #define ER_YES 1003 #define ER_CANT_CREATE_FILE 1004 @@ -38,27 +13,27 @@ static const int total_error_count = 5017; #define ER_CANT_CREATE_DB 1006 #define ER_DB_CREATE_EXISTS 1007 #define ER_DB_DROP_EXISTS 1008 -//#define OBSOLETE_ER_DB_DROP_DELETE 1009 +#define ER_DB_DROP_DELETE 1009 #define ER_DB_DROP_RMDIR 1010 -//#define OBSOLETE_ER_CANT_DELETE_FILE 1011 +#define ER_CANT_DELETE_FILE 1011 #define ER_CANT_FIND_SYSTEM_REC 1012 #define ER_CANT_GET_STAT 1013 -//#define OBSOLETE_ER_CANT_GET_WD 1014 +#define ER_CANT_GET_WD 1014 #define ER_CANT_LOCK 1015 #define ER_CANT_OPEN_FILE 1016 #define ER_FILE_NOT_FOUND 1017 #define ER_CANT_READ_DIR 1018 -//#define OBSOLETE_ER_CANT_SET_WD 1019 +#define ER_CANT_SET_WD 1019 #define ER_CHECKREAD 1020 -//#define OBSOLETE_ER_DISK_FULL 1021 +#define ER_DISK_FULL 1021 #define ER_DUP_KEY 1022 -//#define OBSOLETE_ER_ERROR_ON_CLOSE 1023 +#define ER_ERROR_ON_CLOSE 1023 #define ER_ERROR_ON_READ 1024 #define ER_ERROR_ON_RENAME 1025 #define ER_ERROR_ON_WRITE 1026 #define ER_FILE_USED 1027 #define ER_FILSORT_ABORT 1028 -//#define OBSOLETE_ER_FORM_NOT_FOUND 1029 +#define ER_FORM_NOT_FOUND 1029 #define ER_GET_ERRNO 1030 #define ER_ILLEGAL_HA 1031 #define ER_KEY_NOT_FOUND 1032 @@ -68,7 +43,7 @@ static const int total_error_count = 5017; #define ER_OPEN_AS_READONLY 1036 #define ER_OUTOFMEMORY 1037 #define ER_OUT_OF_SORTMEMORY 1038 -//#define OBSOLETE_ER_UNEXPECTED_EOF 1039 +#define ER_UNEXPECTED_EOF 1039 #define ER_CON_COUNT_ERROR 1040 #define ER_OUT_OF_RESOURCES 1041 #define ER_BAD_HOST_ERROR 1042 @@ -105,9 +80,9 @@ static const int total_error_count = 5017; #define ER_BLOB_USED_AS_KEY 1073 #define ER_TOO_BIG_FIELDLENGTH 1074 #define ER_WRONG_AUTO_KEY 1075 -#define ER_READY 1076 -//#define OBSOLETE_ER_NORMAL_SHUTDOWN 1077 -//#define OBSOLETE_ER_GOT_SIGNAL 1078 +#define ER_UNUSED_9 1076 +#define ER_NORMAL_SHUTDOWN 1077 +#define ER_GOT_SIGNAL 1078 #define ER_SHUTDOWN_COMPLETE 1079 #define ER_FORCING_CLOSE 1080 #define ER_IPSOCK_ERROR 1081 @@ -149,7 +124,7 @@ static const int total_error_count = 5017; #define ER_TOO_MANY_FIELDS 1117 #define ER_TOO_BIG_ROWSIZE 1118 #define ER_STACK_OVERRUN 1119 -#define ER_WRONG_OUTER_JOIN_UNUSED 1120 +#define ER_WRONG_OUTER_JOIN 1120 #define ER_NULL_COLUMN_IN_INDEX 1121 #define ER_CANT_FIND_UDF 1122 #define ER_CANT_INITIALIZE_UDF 1123 @@ -179,8 +154,8 @@ static const int total_error_count = 5017; #define ER_NONEXISTING_TABLE_GRANT 1147 #define ER_NOT_ALLOWED_COMMAND 1148 #define ER_SYNTAX_ERROR 1149 -//#define OBSOLETE_ER_UNUSED1 1150 -//#define OBSOLETE_ER_UNUSED2 1151 +#define ER_DELAYED_CANT_CHANGE_LOCK 1150 +#define ER_TOO_MANY_DELAYED_THREADS 1151 #define ER_ABORTING_CONNECTION 1152 #define ER_NET_PACKET_TOO_LARGE 1153 #define ER_NET_READ_ERROR_FROM_PIPE 1154 @@ -194,7 +169,7 @@ static const int total_error_count = 5017; #define ER_TOO_LONG_STRING 1162 #define ER_TABLE_CANT_HANDLE_BLOB 1163 #define ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164 -//#define OBSOLETE_ER_UNUSED3 1165 +#define ER_DELAYED_INSERT_TABLE_LOCKED 1165 #define ER_WRONG_COLUMN_NAME 1166 #define ER_WRONG_KEY_COLUMN 1167 #define ER_WRONG_MRG_TABLE 1168 @@ -203,20 +178,20 @@ static const int total_error_count = 5017; #define ER_PRIMARY_CANT_HAVE_NULL 1171 #define ER_TOO_MANY_ROWS 1172 #define ER_REQUIRES_PRIMARY_KEY 1173 -//#define OBSOLETE_ER_NO_RAID_COMPILED 1174 +#define ER_NO_RAID_COMPILED 1174 #define ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175 -#define ER_KEY_DOES_NOT_EXITS 1176 +#define ER_KEY_DOES_NOT_EXISTS 1176 #define ER_CHECK_NO_SUCH_TABLE 1177 #define ER_CHECK_NOT_IMPLEMENTED 1178 #define ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179 #define ER_ERROR_DURING_COMMIT 1180 #define ER_ERROR_DURING_ROLLBACK 1181 #define ER_ERROR_DURING_FLUSH_LOGS 1182 -//#define OBSOLETE_ER_ERROR_DURING_CHECKPOINT 1183 +#define ER_ERROR_DURING_CHECKPOINT 1183 #define ER_NEW_ABORTING_CONNECTION 1184 -//#define OBSOLETE_ER_DUMP_NOT_IMPLEMENTED 1185 -//#define OBSOLETE_ER_FLUSH_MASTER_BINLOG_CLOSED 1186 -//#define OBSOLETE_ER_INDEX_REBUILD 1187 +#define ER_UNUSED_10 1185 +#define ER_FLUSH_MASTER_BINLOG_CLOSED 1186 +#define ER_INDEX_REBUILD 1187 #define ER_MASTER 1188 #define ER_MASTER_NET_READ 1189 #define ER_MASTER_NET_WRITE 1190 @@ -227,7 +202,7 @@ static const int total_error_count = 5017; #define ER_CRASHED_ON_REPAIR 1195 #define ER_WARNING_NOT_COMPLETE_ROLLBACK 1196 #define ER_TRANS_CACHE_FULL 1197 -//#define OBSOLETE_ER_SLAVE_MUST_STOP 1198 +#define ER_SLAVE_MUST_STOP 1198 #define ER_SLAVE_NOT_RUNNING 1199 #define ER_BAD_SLAVE 1200 #define ER_MASTER_INFO 1201 @@ -237,18 +212,18 @@ static const int total_error_count = 5017; #define ER_LOCK_WAIT_TIMEOUT 1205 #define ER_LOCK_TABLE_FULL 1206 #define ER_READ_ONLY_TRANSACTION 1207 -//#define OBSOLETE_ER_DROP_DB_WITH_READ_LOCK 1208 -//#define OBSOLETE_ER_CREATE_DB_WITH_READ_LOCK 1209 +#define ER_DROP_DB_WITH_READ_LOCK 1208 +#define ER_CREATE_DB_WITH_READ_LOCK 1209 #define ER_WRONG_ARGUMENTS 1210 #define ER_NO_PERMISSION_TO_CREATE_USER 1211 -//#define OBSOLETE_ER_UNION_TABLES_IN_DIFFERENT_DIR 1212 +#define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212 #define ER_LOCK_DEADLOCK 1213 #define ER_TABLE_CANT_HANDLE_FT 1214 #define ER_CANNOT_ADD_FOREIGN 1215 #define ER_NO_REFERENCED_ROW 1216 #define ER_ROW_IS_REFERENCED 1217 #define ER_CONNECT_TO_MASTER 1218 -//#define OBSOLETE_ER_QUERY_ON_MASTER 1219 +#define ER_QUERY_ON_MASTER 1219 #define ER_ERROR_WHEN_EXECUTING_COMMAND 1220 #define ER_WRONG_USAGE 1221 #define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1222 @@ -274,7 +249,7 @@ static const int total_error_count = 5017; #define ER_SUBQUERY_NO_1_ROW 1242 #define ER_UNKNOWN_STMT_HANDLER 1243 #define ER_CORRUPT_HELP_DB 1244 -//#define OBSOLETE_ER_CYCLIC_REFERENCE 1245 +#define ER_CYCLIC_REFERENCE 1245 #define ER_AUTO_CONVERT 1246 #define ER_ILLEGAL_REFERENCE 1247 #define ER_DERIVED_MUST_HAVE_ALIAS 1248 @@ -283,8 +258,8 @@ static const int total_error_count = 5017; #define ER_NOT_SUPPORTED_AUTH_MODE 1251 #define ER_SPATIAL_CANT_HAVE_NULL 1252 #define ER_COLLATION_CHARSET_MISMATCH 1253 -//#define OBSOLETE_ER_SLAVE_WAS_RUNNING 1254 -//#define OBSOLETE_ER_SLAVE_WAS_NOT_RUNNING 1255 +#define ER_SLAVE_WAS_RUNNING 1254 +#define ER_SLAVE_WAS_NOT_RUNNING 1255 #define ER_TOO_BIG_FOR_UNCOMPRESS 1256 #define ER_ZLIB_Z_MEM_ERROR 1257 #define ER_ZLIB_Z_BUF_ERROR 1258 @@ -297,21 +272,21 @@ static const int total_error_count = 5017; #define WARN_DATA_TRUNCATED 1265 #define ER_WARN_USING_OTHER_HANDLER 1266 #define ER_CANT_AGGREGATE_2COLLATIONS 1267 -//#define OBSOLETE_ER_DROP_USER 1268 +#define ER_DROP_USER 1268 #define ER_REVOKE_GRANTS 1269 #define ER_CANT_AGGREGATE_3COLLATIONS 1270 #define ER_CANT_AGGREGATE_NCOLLATIONS 1271 #define ER_VARIABLE_IS_NOT_STRUCT 1272 #define ER_UNKNOWN_COLLATION 1273 #define ER_SLAVE_IGNORED_SSL_PARAMS 1274 -//#define OBSOLETE_ER_SERVER_IS_IN_SECURE_AUTH_MODE 1275 +#define ER_SERVER_IS_IN_SECURE_AUTH_MODE 1275 #define ER_WARN_FIELD_RESOLVED 1276 #define ER_BAD_SLAVE_UNTIL_COND 1277 #define ER_MISSING_SKIP_SLAVE 1278 #define ER_UNTIL_COND_IGNORED 1279 #define ER_WRONG_NAME_FOR_INDEX 1280 #define ER_WRONG_NAME_FOR_CATALOG 1281 -//#define OBSOLETE_ER_WARN_QC_RESIZE 1282 +#define ER_WARN_QC_RESIZE 1282 #define ER_BAD_FT_COLUMN 1283 #define ER_UNKNOWN_KEY_CACHE 1284 #define ER_WARN_HOSTNAME_WONT_WORK 1285 @@ -322,7 +297,7 @@ static const int total_error_count = 5017; #define ER_OPTION_PREVENTS_STATEMENT 1290 #define ER_DUPLICATED_VALUE_IN_TYPE 1291 #define ER_TRUNCATED_WRONG_VALUE 1292 -//#define OBSOLETE_ER_TOO_MUCH_AUTO_TIMESTAMP_COLS 1293 +#define ER_TOO_MUCH_AUTO_TIMESTAMP_COLS 1293 #define ER_INVALID_ON_UPDATE 1294 #define ER_UNSUPPORTED_PS 1295 #define ER_GET_ERRMSG 1296 @@ -375,10 +350,10 @@ static const int total_error_count = 5017; #define ER_FPARSER_ERROR_IN_PARAMETER 1343 #define ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER 1344 #define ER_VIEW_NO_EXPLAIN 1345 -//#define OBSOLETE_ER_FRM_UNKNOWN_TYPE 1346 +#define ER_FRM_UNKNOWN_TYPE 1346 #define ER_WRONG_OBJECT 1347 #define ER_NONUPDATEABLE_COLUMN 1348 -//#define OBSOLETE_ER_VIEW_SELECT_DERIVED_UNUSED 1349 +#define ER_VIEW_SELECT_DERIVED 1349 #define ER_VIEW_SELECT_CLAUSE 1350 #define ER_VIEW_SELECT_VARIABLE 1351 #define ER_VIEW_SELECT_TMPTABLE 1352 @@ -387,7 +362,7 @@ static const int total_error_count = 5017; #define ER_WARN_VIEW_WITHOUT_KEY 1355 #define ER_VIEW_INVALID 1356 #define ER_SP_NO_DROP_SP 1357 -//#define OBSOLETE_ER_SP_GOTO_IN_HNDLR 1358 +#define ER_SP_GOTO_IN_HNDLR 1358 #define ER_TRG_ALREADY_EXISTS 1359 #define ER_TRG_DOES_NOT_EXIST 1360 #define ER_TRG_ON_VIEW_OR_TEMP_TABLE 1361 @@ -401,7 +376,7 @@ static const int total_error_count = 5017; #define ER_VIEW_CHECK_FAILED 1369 #define ER_PROCACCESS_DENIED_ERROR 1370 #define ER_RELAY_LOG_FAIL 1371 -//#define OBSOLETE_ER_PASSWD_LENGTH 1372 +#define ER_PASSWD_LENGTH 1372 #define ER_UNKNOWN_TARGET_BINLOG 1373 #define ER_IO_ERR_LOG_INDEX_READ 1374 #define ER_BINLOG_PURGE_PROHIBITED 1375 @@ -412,13 +387,13 @@ static const int total_error_count = 5017; #define ER_RELAY_LOG_INIT 1380 #define ER_NO_BINARY_LOGGING 1381 #define ER_RESERVED_SYNTAX 1382 -//#define OBSOLETE_ER_WSAS_FAILED 1383 -//#define OBSOLETE_ER_DIFF_GROUPS_PROC 1384 -//#define OBSOLETE_ER_NO_GROUP_FOR_PROC 1385 -//#define OBSOLETE_ER_ORDER_WITH_PROC 1386 -//#define OBSOLETE_ER_LOGGING_PROHIBIT_CHANGING_OF 1387 -//#define OBSOLETE_ER_NO_FILE_MAPPING 1388 -//#define OBSOLETE_ER_WRONG_MAGIC 1389 +#define ER_WSAS_FAILED 1383 +#define ER_DIFF_GROUPS_PROC 1384 +#define ER_NO_GROUP_FOR_PROC 1385 +#define ER_ORDER_WITH_PROC 1386 +#define ER_LOGGING_PROHIBIT_CHANGING_OF 1387 +#define ER_NO_FILE_MAPPING 1388 +#define ER_WRONG_MAGIC 1389 #define ER_PS_MANY_PARAM 1390 #define ER_KEY_PART_0 1391 #define ER_VIEW_CHECKSUM 1392 @@ -446,10 +421,10 @@ static const int total_error_count = 5017; #define ER_SP_NOT_VAR_ARG 1414 #define ER_SP_NO_RETSET 1415 #define ER_CANT_CREATE_GEOMETRY_OBJECT 1416 -//#define OBSOLETE_ER_FAILED_ROUTINE_BREAK_BINLOG 1417 +#define ER_FAILED_ROUTINE_BREAK_BINLOG 1417 #define ER_BINLOG_UNSAFE_ROUTINE 1418 #define ER_BINLOG_CREATE_ROUTINE_NEED_SUPER 1419 -//#define OBSOLETE_ER_EXEC_STMT_WITH_OPEN_CURSOR 1420 +#define ER_EXEC_STMT_WITH_OPEN_CURSOR 1420 #define ER_STMT_HAS_NO_OPEN_CURSOR 1421 #define ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG 1422 #define ER_NO_DEFAULT_FOR_VIEW_FIELD 1423 @@ -463,7 +438,7 @@ static const int total_error_count = 5017; #define ER_FOREIGN_DATA_SOURCE_DOESNT_EXIST 1431 #define ER_FOREIGN_DATA_STRING_INVALID_CANT_CREATE 1432 #define ER_FOREIGN_DATA_STRING_INVALID 1433 -//#define OBSOLETE_ER_CANT_CREATE_FEDERATED_TABLE 1434 +#define ER_CANT_CREATE_FEDERATED_TABLE 1434 #define ER_TRG_IN_WRONG_SCHEMA 1435 #define ER_STACK_OVERRUN_NEED_MORE 1436 #define ER_TOO_LONG_BODY 1437 @@ -475,7 +450,7 @@ static const int total_error_count = 5017; #define ER_VIEW_PREVENT_UPDATE 1443 #define ER_PS_NO_RECURSION 1444 #define ER_SP_CANT_SET_AUTOCOMMIT 1445 -//#define OBSOLETE_ER_MALFORMED_DEFINER 1446 +#define ER_MALFORMED_DEFINER 1446 #define ER_VIEW_FRM_NO_USER 1447 #define ER_VIEW_OTHER_USER 1448 #define ER_NO_SUCH_USER 1449 @@ -486,7 +461,7 @@ static const int total_error_count = 5017; #define ER_TRG_NO_DEFINER 1454 #define ER_OLD_FILE_FORMAT 1455 #define ER_SP_RECURSION_LIMIT 1456 -//#define OBSOLETE_ER_SP_PROC_TABLE_CORRUPT 1457 +#define ER_SP_PROC_TABLE_CORRUPT 1457 #define ER_SP_WRONG_NAME 1458 #define ER_TABLE_NEEDS_UPGRADE 1459 #define ER_SP_NO_AGGREGATE 1460 @@ -511,14 +486,14 @@ static const int total_error_count = 5017; #define ER_PARTITION_REQUIRES_VALUES_ERROR 1479 #define ER_PARTITION_WRONG_VALUES_ERROR 1480 #define ER_PARTITION_MAXVALUE_ERROR 1481 -//#define OBSOLETE_ER_PARTITION_SUBPARTITION_ERROR 1482 -//#define OBSOLETE_ER_PARTITION_SUBPART_MIX_ERROR 1483 +#define ER_PARTITION_SUBPARTITION_ERROR 1482 +#define ER_PARTITION_SUBPART_MIX_ERROR 1483 #define ER_PARTITION_WRONG_NO_PART_ERROR 1484 #define ER_PARTITION_WRONG_NO_SUBPART_ERROR 1485 #define ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR 1486 -//#define OBSOLETE_ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR 1487 +#define ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR 1487 #define ER_FIELD_NOT_FOUND_PART_ERROR 1488 -//#define OBSOLETE_ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR 1489 +#define ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR 1489 #define ER_INCONSISTENT_PARTITION_INFO_ERROR 1490 #define ER_PARTITION_FUNC_NOT_ALLOWED_ERROR 1491 #define ER_PARTITIONS_MUST_BE_DEFINED_ERROR 1492 @@ -551,7 +526,7 @@ static const int total_error_count = 5017; #define ER_CONSECUTIVE_REORG_PARTITIONS 1519 #define ER_REORG_OUTSIDE_RANGE 1520 #define ER_PARTITION_FUNCTION_FAILURE 1521 -//#define OBSOLETE_ER_PART_STATE_ERROR 1522 +#define ER_PART_STATE_ERROR 1522 #define ER_LIMITED_PART_RANGE 1523 #define ER_PLUGIN_IS_NOT_LOADED 1524 #define ER_WRONG_VALUE 1525 @@ -564,49 +539,49 @@ static const int total_error_count = 5017; #define ER_SIZE_OVERFLOW_ERROR 1532 #define ER_ALTER_FILEGROUP_FAILED 1533 #define ER_BINLOG_ROW_LOGGING_FAILED 1534 -//#define OBSOLETE_ER_BINLOG_ROW_WRONG_TABLE_DEF 1535 -//#define OBSOLETE_ER_BINLOG_ROW_RBR_TO_SBR 1536 +#define ER_BINLOG_ROW_WRONG_TABLE_DEF 1535 +#define ER_BINLOG_ROW_RBR_TO_SBR 1536 #define ER_EVENT_ALREADY_EXISTS 1537 -//#define OBSOLETE_ER_EVENT_STORE_FAILED 1538 +#define ER_EVENT_STORE_FAILED 1538 #define ER_EVENT_DOES_NOT_EXIST 1539 -//#define OBSOLETE_ER_EVENT_CANT_ALTER 1540 -//#define OBSOLETE_ER_EVENT_DROP_FAILED 1541 +#define ER_EVENT_CANT_ALTER 1540 +#define ER_EVENT_DROP_FAILED 1541 #define ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG 1542 #define ER_EVENT_ENDS_BEFORE_STARTS 1543 #define ER_EVENT_EXEC_TIME_IN_THE_PAST 1544 -//#define OBSOLETE_ER_EVENT_OPEN_TABLE_FAILED 1545 -//#define OBSOLETE_ER_EVENT_NEITHER_M_EXPR_NOR_M_AT 1546 -//#define OBSOLETE_ER_COL_COUNT_DOESNT_MATCH_CORRUPTED 1547 -//#define OBSOLETE_ER_CANNOT_LOAD_FROM_TABLE 1548 -//#define OBSOLETE_ER_EVENT_CANNOT_DELETE 1549 -//#define OBSOLETE_ER_EVENT_COMPILE_ERROR 1550 +#define ER_EVENT_OPEN_TABLE_FAILED 1545 +#define ER_EVENT_NEITHER_M_EXPR_NOR_M_AT 1546 +#define ER_UNUSED_2 1547 +#define ER_UNUSED_3 1548 +#define ER_EVENT_CANNOT_DELETE 1549 +#define ER_EVENT_COMPILE_ERROR 1550 #define ER_EVENT_SAME_NAME 1551 -//#define OBSOLETE_ER_EVENT_DATA_TOO_LONG 1552 +#define ER_EVENT_DATA_TOO_LONG 1552 #define ER_DROP_INDEX_FK 1553 #define ER_WARN_DEPRECATED_SYNTAX_WITH_VER 1554 -//#define OBSOLETE_ER_CANT_WRITE_LOCK_LOG_TABLE 1555 +#define ER_CANT_WRITE_LOCK_LOG_TABLE 1555 #define ER_CANT_LOCK_LOG_TABLE 1556 -#define ER_FOREIGN_DUPLICATE_KEY_OLD_UNUSED 1557 +#define ER_UNUSED_4 1557 #define ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE 1558 -//#define OBSOLETE_ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR 1559 +#define ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR 1559 #define ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT 1560 -//#define OBSOLETE_ER_NDB_CANT_SWITCH_BINLOG_FORMAT 1561 +#define ER_UNUSED_13 1561 #define ER_PARTITION_NO_TEMPORARY 1562 #define ER_PARTITION_CONST_DOMAIN_ERROR 1563 #define ER_PARTITION_FUNCTION_IS_NOT_ALLOWED 1564 -//#define OBSOLETE_ER_DDL_LOG_ERROR_UNUSED 1565 +#define ER_DDL_LOG_ERROR 1565 #define ER_NULL_IN_VALUES_LESS_THAN 1566 #define ER_WRONG_PARTITION_NAME 1567 #define ER_CANT_CHANGE_TX_CHARACTERISTICS 1568 #define ER_DUP_ENTRY_AUTOINCREMENT_CASE 1569 -//#define OBSOLETE_ER_EVENT_MODIFY_QUEUE_ERROR 1570 +#define ER_EVENT_MODIFY_QUEUE_ERROR 1570 #define ER_EVENT_SET_VAR_ERROR 1571 #define ER_PARTITION_MERGE_ERROR 1572 -//#define OBSOLETE_ER_CANT_ACTIVATE_LOG 1573 -//#define OBSOLETE_ER_RBR_NOT_AVAILABLE 1574 +#define ER_CANT_ACTIVATE_LOG 1573 +#define ER_RBR_NOT_AVAILABLE 1574 #define ER_BASE64_DECODE_ERROR 1575 #define ER_EVENT_RECURSION_FORBIDDEN 1576 -//#define OBSOLETE_ER_EVENTS_DB_ERROR 1577 +#define ER_EVENTS_DB_ERROR 1577 #define ER_ONLY_INTEGERS_ALLOWED 1578 #define ER_UNSUPORTED_LOG_ENGINE 1579 #define ER_BAD_LOG_STATEMENT 1580 @@ -619,42 +594,42 @@ static const int total_error_count = 5017; #define ER_BINLOG_PURGE_EMFILE 1587 #define ER_EVENT_CANNOT_CREATE_IN_THE_PAST 1588 #define ER_EVENT_CANNOT_ALTER_IN_THE_PAST 1589 -//#define OBSOLETE_ER_SLAVE_INCIDENT 1590 +#define ER_SLAVE_INCIDENT 1590 #define ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT 1591 #define ER_BINLOG_UNSAFE_STATEMENT 1592 -#define ER_BINLOG_FATAL_ERROR 1593 -//#define OBSOLETE_ER_SLAVE_RELAY_LOG_READ_FAILURE 1594 -//#define OBSOLETE_ER_SLAVE_RELAY_LOG_WRITE_FAILURE 1595 -//#define OBSOLETE_ER_SLAVE_CREATE_EVENT_FAILURE 1596 -//#define OBSOLETE_ER_SLAVE_MASTER_COM_FAILURE 1597 +#define ER_SLAVE_FATAL_ERROR 1593 +#define ER_SLAVE_RELAY_LOG_READ_FAILURE 1594 +#define ER_SLAVE_RELAY_LOG_WRITE_FAILURE 1595 +#define ER_SLAVE_CREATE_EVENT_FAILURE 1596 +#define ER_SLAVE_MASTER_COM_FAILURE 1597 #define ER_BINLOG_LOGGING_IMPOSSIBLE 1598 #define ER_VIEW_NO_CREATION_CTX 1599 #define ER_VIEW_INVALID_CREATION_CTX 1600 -//#define OBSOLETE_ER_SR_INVALID_CREATION_CTX 1601 +#define ER_SR_INVALID_CREATION_CTX 1601 #define ER_TRG_CORRUPTED_FILE 1602 #define ER_TRG_NO_CREATION_CTX 1603 #define ER_TRG_INVALID_CREATION_CTX 1604 #define ER_EVENT_INVALID_CREATION_CTX 1605 #define ER_TRG_CANT_OPEN_TABLE 1606 -//#define OBSOLETE_ER_CANT_CREATE_SROUTINE 1607 -//#define OBSOLETE_ER_NEVER_USED 1608 +#define ER_CANT_CREATE_SROUTINE 1607 +#define ER_UNUSED_11 1608 #define ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT 1609 #define ER_SLAVE_CORRUPT_EVENT 1610 -//#define OBSOLETE_ER_LOAD_DATA_INVALID_COLUMN_UNUSED 1611 +#define ER_LOAD_DATA_INVALID_COLUMN 1611 #define ER_LOG_PURGE_NO_FILE 1612 #define ER_XA_RBTIMEOUT 1613 #define ER_XA_RBDEADLOCK 1614 #define ER_NEED_REPREPARE 1615 -//#define OBSOLETE_ER_DELAYED_NOT_SUPPORTED 1616 +#define ER_DELAYED_NOT_SUPPORTED 1616 #define WARN_NO_MASTER_INFO 1617 #define WARN_OPTION_IGNORED 1618 #define ER_PLUGIN_DELETE_BUILTIN 1619 #define WARN_PLUGIN_BUSY 1620 #define ER_VARIABLE_IS_READONLY 1621 #define ER_WARN_ENGINE_TRANSACTION_ROLLBACK 1622 -//#define OBSOLETE_ER_SLAVE_HEARTBEAT_FAILURE 1623 +#define ER_SLAVE_HEARTBEAT_FAILURE 1623 #define ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE 1624 -#define ER_NDB_REPLICATION_SCHEMA_ERROR 1625 +#define ER_UNUSED_14 1625 #define ER_CONFLICT_FN_PARSE_ERROR 1626 #define ER_EXCEPTIONS_WRITE_ERROR 1627 #define ER_TOO_LONG_TABLE_COMMENT 1628 @@ -680,7 +655,7 @@ static const int total_error_count = 5017; #define ER_COND_ITEM_TOO_LONG 1648 #define ER_UNKNOWN_LOCALE 1649 #define ER_SLAVE_IGNORE_SERVER_IDS 1650 -//#define OBSOLETE_ER_QUERY_CACHE_DISABLED 1651 +#define ER_QUERY_CACHE_DISABLED 1651 #define ER_SAME_NAME_PARTITION_FIELD 1652 #define ER_PARTITION_COLUMN_LIST_ERROR 1653 #define ER_WRONG_TYPE_COLUMN_VALUE_ERROR 1654 @@ -698,7 +673,7 @@ static const int total_error_count = 5017; #define ER_BINLOG_ROW_INJECTION_AND_STMT_MODE 1666 #define ER_BINLOG_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE 1667 #define ER_BINLOG_UNSAFE_LIMIT 1668 -//#define OBSOLETE_ER_UNUSED4 1669 +#define ER_BINLOG_UNSAFE_INSERT_DELAYED 1669 #define ER_BINLOG_UNSAFE_SYSTEM_TABLE 1670 #define ER_BINLOG_UNSAFE_AUTOINC_COLUMNS 1671 #define ER_BINLOG_UNSAFE_UDF 1672 @@ -706,7 +681,7 @@ static const int total_error_count = 5017; #define ER_BINLOG_UNSAFE_SYSTEM_FUNCTION 1674 #define ER_BINLOG_UNSAFE_NONTRANS_AFTER_TRANS 1675 #define ER_MESSAGE_AND_STATEMENT 1676 -//#define OBSOLETE_ER_SLAVE_CONVERSION_FAILED 1677 +#define ER_SLAVE_CONVERSION_FAILED 1677 #define ER_SLAVE_CANT_CREATE_CONVERSION 1678 #define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT 1679 #define ER_PATH_LENGTH 1680 @@ -729,7 +704,7 @@ static const int total_error_count = 5017; #define ER_VALUES_IS_NOT_INT_TYPE_ERROR 1697 #define ER_ACCESS_DENIED_NO_PASSWORD_ERROR 1698 #define ER_SET_PASSWORD_AUTH_PLUGIN 1699 -//#define OBSOLETE_ER_GRANT_PLUGIN_USER_EXISTS 1700 +#define ER_GRANT_PLUGIN_USER_EXISTS 1700 #define ER_TRUNCATE_ILLEGAL_FK 1701 #define ER_PLUGIN_IS_PERMANENT 1702 #define ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MIN 1703 @@ -749,13 +724,13 @@ static const int total_error_count = 5017; #define ER_BINLOG_UNSAFE_CREATE_IGNORE_SELECT 1717 #define ER_BINLOG_UNSAFE_CREATE_REPLACE_SELECT 1718 #define ER_BINLOG_UNSAFE_UPDATE_IGNORE 1719 -#define ER_PLUGIN_NO_UNINSTALL 1720 -#define ER_PLUGIN_NO_INSTALL 1721 +#define ER_UNUSED_15 1720 +#define ER_UNUSED_16 1721 #define ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT 1722 #define ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC 1723 #define ER_BINLOG_UNSAFE_INSERT_TWO_KEYS 1724 #define ER_TABLE_IN_FK_CHECK 1725 -#define ER_UNSUPPORTED_ENGINE 1726 +#define ER_UNUSED_1 1726 #define ER_BINLOG_UNSAFE_AUTOINC_NOT_FIRST 1727 #define ER_CANNOT_LOAD_FROM_TABLE_V2 1728 #define ER_MASTER_DELAY_VALUE_OUT_OF_RANGE 1729 @@ -770,15 +745,15 @@ static const int total_error_count = 5017; #define ER_BINLOG_CACHE_SIZE_GREATER_THAN_MAX 1738 #define ER_WARN_INDEX_NOT_APPLICABLE 1739 #define ER_PARTITION_EXCHANGE_FOREIGN_KEY 1740 -//#define OBSOLETE_ER_NO_SUCH_KEY_VALUE 1741 -#define ER_RPL_INFO_DATA_TOO_LONG 1742 -//#define OBSOLETE_ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE 1743 -//#define OBSOLETE_ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE 1744 +#define ER_NO_SUCH_KEY_VALUE 1741 +#define ER_VALUE_TOO_LONG 1742 +#define ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE 1743 +#define ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE 1744 #define ER_BINLOG_STMT_CACHE_SIZE_GREATER_THAN_MAX 1745 #define ER_CANT_UPDATE_TABLE_IN_CREATE_TABLE_SELECT 1746 #define ER_PARTITION_CLAUSE_ON_NONPARTITIONED 1747 #define ER_ROW_DOES_NOT_MATCH_GIVEN_PARTITION_SET 1748 -//#define OBSOLETE_ER_NO_SUCH_PARTITION__UNUSED 1749 +#define ER_UNUSED_5 1749 #define ER_CHANGE_RPL_INFO_REPOSITORY_FAILURE 1750 #define ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_CREATED_TEMP_TABLE 1751 #define ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_DROPPED_TEMP_TABLE 1752 @@ -796,27 +771,27 @@ static const int total_error_count = 5017; #define ER_TABLE_HAS_NO_FT 1764 #define ER_VARIABLE_NOT_SETTABLE_IN_SF_OR_TRIGGER 1765 #define ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION 1766 -//#define OBSOLETE_ER_GTID_NEXT_IS_NOT_IN_GTID_NEXT_LIST 1767 -//#define OBSOLETE_ER_CANT_CHANGE_GTID_NEXT_IN_TRANSACTION 1768 +#define ER_GTID_NEXT_IS_NOT_IN_GTID_NEXT_LIST 1767 +#define ER_CANT_CHANGE_GTID_NEXT_IN_TRANSACTION_WHEN_GTID_NEXT_LIST_IS_NULL 1768 #define ER_SET_STATEMENT_CANNOT_INVOKE_FUNCTION 1769 #define ER_GTID_NEXT_CANT_BE_AUTOMATIC_IF_GTID_NEXT_LIST_IS_NON_NULL 1770 -//#define OBSOLETE_ER_SKIPPING_LOGGED_TRANSACTION 1771 +#define ER_SKIPPING_LOGGED_TRANSACTION 1771 #define ER_MALFORMED_GTID_SET_SPECIFICATION 1772 #define ER_MALFORMED_GTID_SET_ENCODING 1773 #define ER_MALFORMED_GTID_SPECIFICATION 1774 #define ER_GNO_EXHAUSTED 1775 #define ER_BAD_SLAVE_AUTO_POSITION 1776 -#define ER_AUTO_POSITION_REQUIRES_GTID_MODE_NOT_OFF 1777 +#define ER_AUTO_POSITION_REQUIRES_GTID_MODE_ON 1777 #define ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET 1778 -#define ER_GTID_MODE_ON_REQUIRES_ENFORCE_GTID_CONSISTENCY_ON 1779 -//#define OBSOLETE_ER_GTID_MODE_REQUIRES_BINLOG 1780 +#define ER_GTID_MODE_2_OR_3_REQUIRES_ENFORCE_GTID_CONSISTENCY_ON 1779 +#define ER_GTID_MODE_REQUIRES_BINLOG 1780 #define ER_CANT_SET_GTID_NEXT_TO_GTID_WHEN_GTID_MODE_IS_OFF 1781 #define ER_CANT_SET_GTID_NEXT_TO_ANONYMOUS_WHEN_GTID_MODE_IS_ON 1782 #define ER_CANT_SET_GTID_NEXT_LIST_TO_NON_NULL_WHEN_GTID_MODE_IS_OFF 1783 -//#define OBSOLETE_ER_FOUND_GTID_EVENT_WHEN_GTID_MODE_IS_OFF__UNUSED 1784 +#define ER_FOUND_GTID_EVENT_WHEN_GTID_MODE_IS_OFF 1784 #define ER_GTID_UNSAFE_NON_TRANSACTIONAL_TABLE 1785 #define ER_GTID_UNSAFE_CREATE_SELECT 1786 -//#define OBSOLETE_ER_GTID_UNSAFE_CREATE_DROP_TEMP_TABLE_IN_TRANSACTION 1787 +#define ER_GTID_UNSAFE_CREATE_DROP_TEMPORARY_TABLE_IN_TRANSACTION 1787 #define ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME 1788 #define ER_MASTER_HAS_PURGED_REQUIRED_GTIDS 1789 #define ER_CANT_SET_GTID_NEXT_WHEN_OWNING_GTID 1790 @@ -855,7 +830,7 @@ static const int total_error_count = 5017; #define ER_FK_FAIL_ADD_SYSTEM 1823 #define ER_FK_CANNOT_OPEN_PARENT 1824 #define ER_FK_INCORRECT_OPTION 1825 -#define ER_FK_DUP_NAME 1826 +#define ER_DUP_CONSTRAINT_NAME 1826 #define ER_PASSWORD_FORMAT 1827 #define ER_FK_COLUMN_CANNOT_DROP 1828 #define ER_FK_COLUMN_CANNOT_DROP_CHILD 1829 @@ -863,12 +838,12 @@ static const int total_error_count = 5017; #define ER_DUP_INDEX 1831 #define ER_FK_COLUMN_CANNOT_CHANGE 1832 #define ER_FK_COLUMN_CANNOT_CHANGE_CHILD 1833 -//#define OBSOLETE_ER_UNUSED5 1834 +#define ER_FK_CANNOT_DELETE_PARENT 1834 #define ER_MALFORMED_PACKET 1835 #define ER_READ_ONLY_MODE 1836 -#define ER_GTID_NEXT_TYPE_UNDEFINED_GTID 1837 +#define ER_GTID_NEXT_TYPE_UNDEFINED_GROUP 1837 #define ER_VARIABLE_NOT_SETTABLE_IN_SP 1838 -//#define OBSOLETE_ER_CANT_SET_GTID_PURGED_WHEN_GTID_MODE_IS_OFF 1839 +#define ER_CANT_SET_GTID_PURGED_WHEN_GTID_MODE_IS_OFF 1839 #define ER_CANT_SET_GTID_PURGED_WHEN_GTID_EXECUTED_IS_NOT_EMPTY 1840 #define ER_CANT_SET_GTID_PURGED_WHEN_OWNED_GTIDS_IS_NOT_EMPTY 1841 #define ER_GTID_PURGED_WAS_CHANGED 1842 @@ -881,7 +856,7 @@ static const int total_error_count = 5017; #define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FK_RENAME 1849 #define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_COLUMN_TYPE 1850 #define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FK_CHECK 1851 -//#define OBSOLETE_ER_UNUSED6 1852 +#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_IGNORE 1852 #define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOPK 1853 #define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_AUTOINC 1854 #define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_HIDDEN_FTS 1855 @@ -894,7 +869,7 @@ static const int total_error_count = 5017; #define ER_MUST_CHANGE_PASSWORD_LOGIN 1862 #define ER_ROW_IN_WRONG_PARTITION 1863 #define ER_MTS_EVENT_BIGGER_PENDING_JOBS_SIZE_MAX 1864 -//#define OBSOLETE_ER_INNODB_NO_FT_USES_PARSER 1865 +#define ER_INNODB_NO_FT_USES_PARSER 1865 #define ER_BINLOG_LOGICAL_CORRUPTION 1866 #define ER_WARN_PURGE_LOG_IN_USE 1867 #define ER_WARN_PURGE_LOG_IS_ACTIVE 1868 @@ -909,17 +884,107 @@ static const int total_error_count = 5017; #define ER_TABLE_CORRUPT 1877 #define ER_TEMP_FILE_WRITE_FAILURE 1878 #define ER_INNODB_FT_AUX_NOT_HEX_ID 1879 -#define ER_OLD_TEMPORALS_UPGRADED 1880 -#define ER_INNODB_FORCED_RECOVERY 1881 -#define ER_AES_INVALID_IV 1882 -#define ER_PLUGIN_CANNOT_BE_UNINSTALLED 1883 -#define ER_GTID_UNSAFE_BINLOG_SPLITTABLE_STATEMENT_AND_ASSIGNED_GTID 1884 -#define ER_SLAVE_HAS_MORE_GTIDS_THAN_MASTER 1885 -#define ER_MISSING_KEY 1886 -#define WARN_NAMED_PIPE_ACCESS_EVERYONE 1887 +#define ER_LAST_MYSQL_ERROR_MESSAGE 1880 +#define ER_ERROR_LAST_SECTION_1 1880 + +/* New section */ + +#define ER_ERROR_FIRST_SECTION_2 1900 +#define ER_UNUSED_18 1900 +#define ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED 1901 +#define ER_UNUSED_19 1902 +#define ER_PRIMARY_KEY_BASED_ON_GENERATED_COLUMN 1903 +#define ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN 1904 +#define ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN 1905 +#define ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN 1906 +#define ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN 1907 +#define ER_UNUSED_20 1908 +#define ER_UNUSED_21 1909 +#define ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS 1910 +#define ER_UNKNOWN_OPTION 1911 +#define ER_BAD_OPTION_VALUE 1912 +#define ER_UNUSED_6 1913 +#define ER_UNUSED_7 1914 +#define ER_UNUSED_8 1915 +#define ER_DATA_OVERFLOW 1916 +#define ER_DATA_TRUNCATED 1917 +#define ER_BAD_DATA 1918 +#define ER_DYN_COL_WRONG_FORMAT 1919 +#define ER_DYN_COL_IMPLEMENTATION_LIMIT 1920 +#define ER_DYN_COL_DATA 1921 +#define ER_DYN_COL_WRONG_CHARSET 1922 +#define ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES 1923 +#define ER_QUERY_CACHE_IS_DISABLED 1924 +#define ER_QUERY_CACHE_IS_GLOBALY_DISABLED 1925 +#define ER_VIEW_ORDERBY_IGNORED 1926 +#define ER_CONNECTION_KILLED 1927 +#define ER_UNUSED_12 1928 +#define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SKIP_REPLICATION 1929 +#define ER_STORED_FUNCTION_PREVENTS_SWITCH_SKIP_REPLICATION 1930 +#define ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT 1931 +#define ER_NO_SUCH_TABLE_IN_ENGINE 1932 +#define ER_TARGET_NOT_EXPLAINABLE 1933 +#define ER_CONNECTION_ALREADY_EXISTS 1934 +#define ER_MASTER_LOG_PREFIX 1935 +#define ER_CANT_START_STOP_SLAVE 1936 +#define ER_SLAVE_STARTED 1937 +#define ER_SLAVE_STOPPED 1938 +#define ER_SQL_DISCOVER_ERROR 1939 +#define ER_FAILED_GTID_STATE_INIT 1940 +#define ER_INCORRECT_GTID_STATE 1941 +#define ER_CANNOT_UPDATE_GTID_STATE 1942 +#define ER_DUPLICATE_GTID_DOMAIN 1943 +#define ER_GTID_OPEN_TABLE_FAILED 1944 +#define ER_GTID_POSITION_NOT_FOUND_IN_BINLOG 1945 +#define ER_CANNOT_LOAD_SLAVE_GTID_STATE 1946 +#define ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG 1947 +#define ER_MASTER_GTID_POS_MISSING_DOMAIN 1948 +#define ER_UNTIL_REQUIRES_USING_GTID 1949 +#define ER_GTID_STRICT_OUT_OF_ORDER 1950 +#define ER_GTID_START_FROM_BINLOG_HOLE 1951 +#define ER_SLAVE_UNEXPECTED_MASTER_SWITCH 1952 +#define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO 1953 +#define ER_STORED_FUNCTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO 1954 +#define ER_GTID_POSITION_NOT_FOUND_IN_BINLOG2 1955 +#define ER_BINLOG_MUST_BE_EMPTY 1956 +#define ER_NO_SUCH_QUERY 1957 +#define ER_BAD_BASE64_DATA 1958 +#define ER_INVALID_ROLE 1959 +#define ER_INVALID_CURRENT_USER 1960 +#define ER_CANNOT_GRANT_ROLE 1961 +#define ER_CANNOT_REVOKE_ROLE 1962 +#define ER_CHANGE_SLAVE_PARALLEL_THREADS_ACTIVE 1963 +#define ER_PRIOR_COMMIT_FAILED 1964 +#define ER_IT_IS_A_VIEW 1965 +#define ER_SLAVE_SKIP_NOT_IN_GTID 1966 +#define ER_TABLE_DEFINITION_TOO_BIG 1967 +#define ER_PLUGIN_INSTALLED 1968 +#define ER_STATEMENT_TIMEOUT 1969 +#define ER_SUBQUERIES_NOT_SUPPORTED 1970 +#define ER_SET_STATEMENT_NOT_SUPPORTED 1971 +#define ER_UNUSED_17 1972 +#define ER_USER_CREATE_EXISTS 1973 +#define ER_USER_DROP_EXISTS 1974 +#define ER_ROLE_CREATE_EXISTS 1975 +#define ER_ROLE_DROP_EXISTS 1976 +#define ER_CANNOT_CONVERT_CHARACTER 1977 +#define ER_INVALID_DEFAULT_VALUE_FOR_FIELD 1978 +#define ER_KILL_QUERY_DENIED_ERROR 1979 +#define ER_NO_EIS_FOR_FIELD 1980 +#define ER_WARN_AGGFUNC_DEPENDENCE 1981 +#define ER_ERROR_LAST_SECTION_2 1981 + +/* New section */ + +#define ER_ERROR_FIRST_SECTION_3 2000 +#define ER_ERROR_LAST_SECTION_3 2000 + +/* New section */ + +#define ER_ERROR_FIRST_SECTION_4 3000 #define ER_FILE_CORRUPT 3000 #define ER_ERROR_ON_MASTER 3001 -//#define OBSOLETE_ER_INCONSISTENT_ERROR 3002 +#define ER_INCONSISTENT_ERROR 3002 #define ER_STORAGE_ENGINE_NOT_LOADED 3003 #define ER_GET_STACKED_DA_WITHOUT_ACTIVE_HANDLER 3004 #define ER_WARN_LEGACY_SYNTAX_CONVERTED 3005 @@ -928,7 +993,7 @@ static const int total_error_count = 5017; #define ER_FK_DEPTH_EXCEEDED 3008 #define ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE_V2 3009 #define ER_WARN_TRIGGER_DOESNT_HAVE_CREATED 3010 -#define ER_REFERENCED_TRG_DOES_NOT_EXIST 3011 +#define ER_REFERENCED_TRG_DOES_NOT_EXIST_MYSQL 3011 #define ER_EXPLAIN_NOT_SUPPORTED 3012 #define ER_INVALID_FIELD_SIZE 3013 #define ER_MISSING_HA_CREATE_OPTION 3014 @@ -944,7 +1009,7 @@ static const int total_error_count = 5017; #define ER_QUERY_TIMEOUT 3024 #define ER_NON_RO_SELECT_DISABLE_TIMER 3025 #define ER_DUP_LIST_ENTRY 3026 -//#define OBSOLETE_ER_SQL_MODE_NO_EFFECT 3027 +#define ER_SQL_MODE_NO_EFFECT 3027 #define ER_AGGREGATE_ORDER_FOR_UNION 3028 #define ER_AGGREGATE_ORDER_NON_AGG_QUERY 3029 #define ER_SLAVE_WORKER_STOPPED_PREVIOUS_THD_ERROR 3030 @@ -978,4074 +1043,84 @@ static const int total_error_count = 5017; #define ER_USER_LOCK_DEADLOCK 3058 #define ER_REPLACE_INACCESSIBLE_ROWS 3059 #define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_GIS 3060 -#define ER_ILLEGAL_USER_VAR 3061 -#define ER_GTID_MODE_OFF 3062 -//#define OBSOLETE_ER_UNSUPPORTED_BY_REPLICATION_THREAD 3063 -#define ER_INCORRECT_TYPE 3064 -#define ER_FIELD_IN_ORDER_NOT_SELECT 3065 -#define ER_AGGREGATE_IN_ORDER_NOT_SELECT 3066 -#define ER_INVALID_RPL_WILD_TABLE_FILTER_PATTERN 3067 -#define ER_NET_OK_PACKET_TOO_LARGE 3068 -#define ER_INVALID_JSON_DATA 3069 -#define ER_INVALID_GEOJSON_MISSING_MEMBER 3070 -#define ER_INVALID_GEOJSON_WRONG_TYPE 3071 -#define ER_INVALID_GEOJSON_UNSPECIFIED 3072 -#define ER_DIMENSION_UNSUPPORTED 3073 -#define ER_SLAVE_CHANNEL_DOES_NOT_EXIST 3074 -//#define OBSOLETE_ER_SLAVE_MULTIPLE_CHANNELS_HOST_PORT 3075 -#define ER_SLAVE_CHANNEL_NAME_INVALID_OR_TOO_LONG 3076 -#define ER_SLAVE_NEW_CHANNEL_WRONG_REPOSITORY 3077 -//#define OBSOLETE_ER_SLAVE_CHANNEL_DELETE 3078 -#define ER_SLAVE_MULTIPLE_CHANNELS_CMD 3079 -#define ER_SLAVE_MAX_CHANNELS_EXCEEDED 3080 -#define ER_SLAVE_CHANNEL_MUST_STOP 3081 -#define ER_SLAVE_CHANNEL_NOT_RUNNING 3082 -#define ER_SLAVE_CHANNEL_WAS_RUNNING 3083 -#define ER_SLAVE_CHANNEL_WAS_NOT_RUNNING 3084 -#define ER_SLAVE_CHANNEL_SQL_THREAD_MUST_STOP 3085 -#define ER_SLAVE_CHANNEL_SQL_SKIP_COUNTER 3086 -#define ER_WRONG_FIELD_WITH_GROUP_V2 3087 -#define ER_MIX_OF_GROUP_FUNC_AND_FIELDS_V2 3088 -#define ER_WARN_DEPRECATED_SYSVAR_UPDATE 3089 -#define ER_WARN_DEPRECATED_SQLMODE 3090 -#define ER_CANNOT_LOG_PARTIAL_DROP_DATABASE_WITH_GTID 3091 -#define ER_GROUP_REPLICATION_CONFIGURATION 3092 -#define ER_GROUP_REPLICATION_RUNNING 3093 -#define ER_GROUP_REPLICATION_APPLIER_INIT_ERROR 3094 -#define ER_GROUP_REPLICATION_STOP_APPLIER_THREAD_TIMEOUT 3095 -#define ER_GROUP_REPLICATION_COMMUNICATION_LAYER_SESSION_ERROR 3096 -#define ER_GROUP_REPLICATION_COMMUNICATION_LAYER_JOIN_ERROR 3097 -#define ER_BEFORE_DML_VALIDATION_ERROR 3098 -#define ER_PREVENTS_VARIABLE_WITHOUT_RBR 3099 -#define ER_RUN_HOOK_ERROR 3100 -#define ER_TRANSACTION_ROLLBACK_DURING_COMMIT 3101 -#define ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED 3102 -#define ER_UNSUPPORTED_ALTER_INPLACE_ON_VIRTUAL_COLUMN 3103 -#define ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN 3104 -#define ER_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN 3105 -#define ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN 3106 -#define ER_GENERATED_COLUMN_NON_PRIOR 3107 -#define ER_DEPENDENT_BY_GENERATED_COLUMN 3108 -#define ER_GENERATED_COLUMN_REF_AUTO_INC 3109 -#define ER_FEATURE_NOT_AVAILABLE 3110 -#define ER_CANT_SET_GTID_MODE 3111 -#define ER_CANT_USE_AUTO_POSITION_WITH_GTID_MODE_OFF 3112 -//#define OBSOLETE_ER_CANT_REPLICATE_ANONYMOUS_WITH_AUTO_POSITION 3113 -//#define OBSOLETE_ER_CANT_REPLICATE_ANONYMOUS_WITH_GTID_MODE_ON 3114 -//#define OBSOLETE_ER_CANT_REPLICATE_GTID_WITH_GTID_MODE_OFF 3115 -#define ER_CANT_ENFORCE_GTID_CONSISTENCY_WITH_ONGOING_GTID_VIOLATING_TX 3116 -#define ER_ENFORCE_GTID_CONSISTENCY_WARN_WITH_ONGOING_GTID_VIOLATING_TX 3117 -#define ER_ACCOUNT_HAS_BEEN_LOCKED 3118 -#define ER_WRONG_TABLESPACE_NAME 3119 -#define ER_TABLESPACE_IS_NOT_EMPTY 3120 -#define ER_WRONG_FILE_NAME 3121 -#define ER_BOOST_GEOMETRY_INCONSISTENT_TURNS_EXCEPTION 3122 -#define ER_WARN_OPTIMIZER_HINT_SYNTAX_ERROR 3123 -#define ER_WARN_BAD_MAX_EXECUTION_TIME 3124 -#define ER_WARN_UNSUPPORTED_MAX_EXECUTION_TIME 3125 -#define ER_WARN_CONFLICTING_HINT 3126 -#define ER_WARN_UNKNOWN_QB_NAME 3127 -#define ER_UNRESOLVED_HINT_NAME 3128 -#define ER_WARN_ON_MODIFYING_GTID_EXECUTED_TABLE 3129 -#define ER_PLUGGABLE_PROTOCOL_COMMAND_NOT_SUPPORTED 3130 -#define ER_LOCKING_SERVICE_WRONG_NAME 3131 -#define ER_LOCKING_SERVICE_DEADLOCK 3132 -#define ER_LOCKING_SERVICE_TIMEOUT 3133 -#define ER_GIS_MAX_POINTS_IN_GEOMETRY_OVERFLOWED 3134 -#define ER_SQL_MODE_MERGED 3135 -#define ER_VTOKEN_PLUGIN_TOKEN_MISMATCH 3136 -#define ER_VTOKEN_PLUGIN_TOKEN_NOT_FOUND 3137 -#define ER_CANT_SET_VARIABLE_WHEN_OWNING_GTID 3138 -#define ER_SLAVE_CHANNEL_OPERATION_NOT_ALLOWED 3139 -#define ER_INVALID_JSON_TEXT 3140 -#define ER_INVALID_JSON_TEXT_IN_PARAM 3141 -#define ER_INVALID_JSON_BINARY_DATA 3142 -#define ER_INVALID_JSON_PATH 3143 -#define ER_INVALID_JSON_CHARSET 3144 -#define ER_INVALID_JSON_CHARSET_IN_FUNCTION 3145 -#define ER_INVALID_TYPE_FOR_JSON 3146 -#define ER_INVALID_CAST_TO_JSON 3147 -#define ER_INVALID_JSON_PATH_CHARSET 3148 -#define ER_INVALID_JSON_PATH_WILDCARD 3149 -#define ER_JSON_VALUE_TOO_BIG 3150 -#define ER_JSON_KEY_TOO_BIG 3151 -#define ER_JSON_USED_AS_KEY 3152 -#define ER_JSON_VACUOUS_PATH 3153 -#define ER_JSON_BAD_ONE_OR_ALL_ARG 3154 -#define ER_NUMERIC_JSON_VALUE_OUT_OF_RANGE 3155 -#define ER_INVALID_JSON_VALUE_FOR_CAST 3156 -#define ER_JSON_DOCUMENT_TOO_DEEP 3157 -#define ER_JSON_DOCUMENT_NULL_KEY 3158 -#define ER_SECURE_TRANSPORT_REQUIRED 3159 -#define ER_NO_SECURE_TRANSPORTS_CONFIGURED 3160 -#define ER_DISABLED_STORAGE_ENGINE 3161 -#define ER_USER_DOES_NOT_EXIST 3162 -#define ER_USER_ALREADY_EXISTS 3163 -#define ER_AUDIT_API_ABORT 3164 -#define ER_INVALID_JSON_PATH_ARRAY_CELL 3165 -#define ER_BUFPOOL_RESIZE_INPROGRESS 3166 -#define ER_FEATURE_DISABLED_SEE_DOC 3167 -#define ER_SERVER_ISNT_AVAILABLE 3168 -#define ER_SESSION_WAS_KILLED 3169 -#define ER_CAPACITY_EXCEEDED 3170 -#define ER_CAPACITY_EXCEEDED_IN_RANGE_OPTIMIZER 3171 -//#define OBSOLETE_ER_TABLE_NEEDS_UPG_PART 3172 -#define ER_CANT_WAIT_FOR_EXECUTED_GTID_SET_WHILE_OWNING_A_GTID 3173 -#define ER_CANNOT_ADD_FOREIGN_BASE_COL_VIRTUAL 3174 -#define ER_CANNOT_CREATE_VIRTUAL_INDEX_CONSTRAINT 3175 -#define ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE 3176 -#define ER_LOCK_REFUSED_BY_ENGINE 3177 -#define ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN 3178 -#define ER_MASTER_KEY_ROTATION_NOT_SUPPORTED_BY_SE 3179 -//#define OBSOLETE_ER_MASTER_KEY_ROTATION_ERROR_BY_SE 3180 -#define ER_MASTER_KEY_ROTATION_BINLOG_FAILED 3181 -#define ER_MASTER_KEY_ROTATION_SE_UNAVAILABLE 3182 -#define ER_TABLESPACE_CANNOT_ENCRYPT 3183 -#define ER_INVALID_ENCRYPTION_OPTION 3184 -#define ER_CANNOT_FIND_KEY_IN_KEYRING 3185 -#define ER_CAPACITY_EXCEEDED_IN_PARSER 3186 -#define ER_UNSUPPORTED_ALTER_ENCRYPTION_INPLACE 3187 -#define ER_KEYRING_UDF_KEYRING_SERVICE_ERROR 3188 -#define ER_USER_COLUMN_OLD_LENGTH 3189 -#define ER_CANT_RESET_MASTER 3190 -#define ER_GROUP_REPLICATION_MAX_GROUP_SIZE 3191 -#define ER_CANNOT_ADD_FOREIGN_BASE_COL_STORED 3192 -#define ER_TABLE_REFERENCED 3193 -//#define OBSOLETE_ER_PARTITION_ENGINE_DEPRECATED_FOR_TABLE 3194 -//#define OBSOLETE_ER_WARN_USING_GEOMFROMWKB_TO_SET_SRID_ZERO 3195 -//#define OBSOLETE_ER_WARN_USING_GEOMFROMWKB_TO_SET_SRID 3196 -#define ER_XA_RETRY 3197 -#define ER_KEYRING_AWS_UDF_AWS_KMS_ERROR 3198 -#define ER_BINLOG_UNSAFE_XA 3199 -#define ER_UDF_ERROR 3200 -#define ER_KEYRING_MIGRATION_FAILURE 3201 -#define ER_KEYRING_ACCESS_DENIED_ERROR 3202 -#define ER_KEYRING_MIGRATION_STATUS 3203 -//#define OBSOLETE_ER_PLUGIN_FAILED_TO_OPEN_TABLES 3204 -//#define OBSOLETE_ER_PLUGIN_FAILED_TO_OPEN_TABLE 3205 -//#define OBSOLETE_ER_AUDIT_LOG_NO_KEYRING_PLUGIN_INSTALLED 3206 -//#define OBSOLETE_ER_AUDIT_LOG_ENCRYPTION_PASSWORD_HAS_NOT_BEEN_SET 3207 -//#define OBSOLETE_ER_AUDIT_LOG_COULD_NOT_CREATE_AES_KEY 3208 -//#define OBSOLETE_ER_AUDIT_LOG_ENCRYPTION_PASSWORD_CANNOT_BE_FETCHED 3209 -//#define OBSOLETE_ER_AUDIT_LOG_JSON_FILTERING_NOT_ENABLED 3210 -//#define OBSOLETE_ER_AUDIT_LOG_UDF_INSUFFICIENT_PRIVILEGE 3211 -//#define OBSOLETE_ER_AUDIT_LOG_SUPER_PRIVILEGE_REQUIRED 3212 -//#define OBSOLETE_ER_COULD_NOT_REINITIALIZE_AUDIT_LOG_FILTERS 3213 -//#define OBSOLETE_ER_AUDIT_LOG_UDF_INVALID_ARGUMENT_TYPE 3214 -//#define OBSOLETE_ER_AUDIT_LOG_UDF_INVALID_ARGUMENT_COUNT 3215 -//#define OBSOLETE_ER_AUDIT_LOG_HAS_NOT_BEEN_INSTALLED 3216 -//#define OBSOLETE_ER_AUDIT_LOG_UDF_READ_INVALID_MAX_ARRAY_LENGTH_ARG_TYPE 3217 -#define ER_AUDIT_LOG_UDF_READ_INVALID_MAX_ARRAY_LENGTH_ARG_VALUE 3218 -//#define OBSOLETE_ER_AUDIT_LOG_JSON_FILTER_PARSING_ERROR 3219 -//#define OBSOLETE_ER_AUDIT_LOG_JSON_FILTER_NAME_CANNOT_BE_EMPTY 3220 -//#define OBSOLETE_ER_AUDIT_LOG_JSON_USER_NAME_CANNOT_BE_EMPTY 3221 -//#define OBSOLETE_ER_AUDIT_LOG_JSON_FILTER_DOES_NOT_EXISTS 3222 -//#define OBSOLETE_ER_AUDIT_LOG_USER_FIRST_CHARACTER_MUST_BE_ALPHANUMERIC 3223 -//#define OBSOLETE_ER_AUDIT_LOG_USER_NAME_INVALID_CHARACTER 3224 -//#define OBSOLETE_ER_AUDIT_LOG_HOST_NAME_INVALID_CHARACTER 3225 -#define OBSOLETE_WARN_DEPRECATED_MAXDB_SQL_MODE_FOR_TIMESTAMP 3226 -#define ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE 3500 -#define ER_ACL_OPERATION_FAILED 3501 -#define ER_UNSUPPORTED_INDEX_ALGORITHM 3502 -#define ER_NO_SUCH_DB 3503 -#define ER_TOO_BIG_ENUM 3504 -#define ER_TOO_LONG_SET_ENUM_VALUE 3505 -#define ER_INVALID_DD_OBJECT 3506 -#define ER_UPDATING_DD_TABLE 3507 -#define ER_INVALID_DD_OBJECT_ID 3508 -#define ER_INVALID_DD_OBJECT_NAME 3509 -#define ER_TABLESPACE_MISSING_WITH_NAME 3510 -#define ER_TOO_LONG_ROUTINE_COMMENT 3511 -#define ER_SP_LOAD_FAILED 3512 -#define ER_INVALID_BITWISE_OPERANDS_SIZE 3513 -#define ER_INVALID_BITWISE_AGGREGATE_OPERANDS_SIZE 3514 -#define ER_WARN_UNSUPPORTED_HINT 3515 -#define ER_UNEXPECTED_GEOMETRY_TYPE 3516 -#define ER_SRS_PARSE_ERROR 3517 -#define ER_SRS_PROJ_PARAMETER_MISSING 3518 -#define ER_WARN_SRS_NOT_FOUND 3519 -#define ER_SRS_NOT_CARTESIAN 3520 -#define ER_SRS_NOT_CARTESIAN_UNDEFINED 3521 -#define ER_PK_INDEX_CANT_BE_INVISIBLE 3522 -#define ER_UNKNOWN_AUTHID 3523 -#define ER_FAILED_ROLE_GRANT 3524 -#define ER_OPEN_ROLE_TABLES 3525 -#define ER_FAILED_DEFAULT_ROLES 3526 -#define ER_COMPONENTS_NO_SCHEME 3527 -#define ER_COMPONENTS_NO_SCHEME_SERVICE 3528 -#define ER_COMPONENTS_CANT_LOAD 3529 -#define ER_ROLE_NOT_GRANTED 3530 -#define ER_FAILED_REVOKE_ROLE 3531 -#define ER_RENAME_ROLE 3532 -#define ER_COMPONENTS_CANT_ACQUIRE_SERVICE_IMPLEMENTATION 3533 -#define ER_COMPONENTS_CANT_SATISFY_DEPENDENCY 3534 -#define ER_COMPONENTS_LOAD_CANT_REGISTER_SERVICE_IMPLEMENTATION 3535 -#define ER_COMPONENTS_LOAD_CANT_INITIALIZE 3536 -#define ER_COMPONENTS_UNLOAD_NOT_LOADED 3537 -#define ER_COMPONENTS_UNLOAD_CANT_DEINITIALIZE 3538 -#define ER_COMPONENTS_CANT_RELEASE_SERVICE 3539 -#define ER_COMPONENTS_UNLOAD_CANT_UNREGISTER_SERVICE 3540 -#define ER_COMPONENTS_CANT_UNLOAD 3541 -#define ER_WARN_UNLOAD_THE_NOT_PERSISTED 3542 -#define ER_COMPONENT_TABLE_INCORRECT 3543 -#define ER_COMPONENT_MANIPULATE_ROW_FAILED 3544 -#define ER_COMPONENTS_UNLOAD_DUPLICATE_IN_GROUP 3545 -#define ER_CANT_SET_GTID_PURGED_DUE_SETS_CONSTRAINTS 3546 -#define ER_CANNOT_LOCK_USER_MANAGEMENT_CACHES 3547 -#define ER_SRS_NOT_FOUND 3548 -#define ER_VARIABLE_NOT_PERSISTED 3549 -#define ER_IS_QUERY_INVALID_CLAUSE 3550 -#define ER_UNABLE_TO_STORE_STATISTICS 3551 -#define ER_NO_SYSTEM_SCHEMA_ACCESS 3552 -#define ER_NO_SYSTEM_TABLESPACE_ACCESS 3553 -#define ER_NO_SYSTEM_TABLE_ACCESS 3554 -#define ER_NO_SYSTEM_TABLE_ACCESS_FOR_DICTIONARY_TABLE 3555 -#define ER_NO_SYSTEM_TABLE_ACCESS_FOR_SYSTEM_TABLE 3556 -#define ER_NO_SYSTEM_TABLE_ACCESS_FOR_TABLE 3557 -#define ER_INVALID_OPTION_KEY 3558 -#define ER_INVALID_OPTION_VALUE 3559 -#define ER_INVALID_OPTION_KEY_VALUE_PAIR 3560 -#define ER_INVALID_OPTION_START_CHARACTER 3561 -#define ER_INVALID_OPTION_END_CHARACTER 3562 -#define ER_INVALID_OPTION_CHARACTERS 3563 -#define ER_DUPLICATE_OPTION_KEY 3564 -#define ER_WARN_SRS_NOT_FOUND_AXIS_ORDER 3565 -#define ER_NO_ACCESS_TO_NATIVE_FCT 3566 -#define ER_RESET_MASTER_TO_VALUE_OUT_OF_RANGE 3567 -#define ER_UNRESOLVED_TABLE_LOCK 3568 -#define ER_DUPLICATE_TABLE_LOCK 3569 -#define ER_BINLOG_UNSAFE_SKIP_LOCKED 3570 -#define ER_BINLOG_UNSAFE_NOWAIT 3571 -#define ER_LOCK_NOWAIT 3572 -#define ER_CTE_RECURSIVE_REQUIRES_UNION 3573 -#define ER_CTE_RECURSIVE_REQUIRES_NONRECURSIVE_FIRST 3574 -#define ER_CTE_RECURSIVE_FORBIDS_AGGREGATION 3575 -#define ER_CTE_RECURSIVE_FORBIDDEN_JOIN_ORDER 3576 -#define ER_CTE_RECURSIVE_REQUIRES_SINGLE_REFERENCE 3577 -#define ER_SWITCH_TMP_ENGINE 3578 -#define ER_WINDOW_NO_SUCH_WINDOW 3579 -#define ER_WINDOW_CIRCULARITY_IN_WINDOW_GRAPH 3580 -#define ER_WINDOW_NO_CHILD_PARTITIONING 3581 -#define ER_WINDOW_NO_INHERIT_FRAME 3582 -#define ER_WINDOW_NO_REDEFINE_ORDER_BY 3583 -#define ER_WINDOW_FRAME_START_ILLEGAL 3584 -#define ER_WINDOW_FRAME_END_ILLEGAL 3585 -#define ER_WINDOW_FRAME_ILLEGAL 3586 -#define ER_WINDOW_RANGE_FRAME_ORDER_TYPE 3587 -#define ER_WINDOW_RANGE_FRAME_TEMPORAL_TYPE 3588 -#define ER_WINDOW_RANGE_FRAME_NUMERIC_TYPE 3589 -#define ER_WINDOW_RANGE_BOUND_NOT_CONSTANT 3590 -#define ER_WINDOW_DUPLICATE_NAME 3591 -#define ER_WINDOW_ILLEGAL_ORDER_BY 3592 -#define ER_WINDOW_INVALID_WINDOW_FUNC_USE 3593 -#define ER_WINDOW_INVALID_WINDOW_FUNC_ALIAS_USE 3594 -#define ER_WINDOW_NESTED_WINDOW_FUNC_USE_IN_WINDOW_SPEC 3595 -#define ER_WINDOW_ROWS_INTERVAL_USE 3596 -#define ER_WINDOW_NO_GROUP_ORDER_UNUSED 3597 -#define ER_WINDOW_EXPLAIN_JSON 3598 -#define ER_WINDOW_FUNCTION_IGNORES_FRAME 3599 -#define ER_WL9236_NOW_UNUSED 3600 -#define ER_INVALID_NO_OF_ARGS 3601 -#define ER_FIELD_IN_GROUPING_NOT_GROUP_BY 3602 -#define ER_TOO_LONG_TABLESPACE_COMMENT 3603 -#define ER_ENGINE_CANT_DROP_TABLE 3604 -#define ER_ENGINE_CANT_DROP_MISSING_TABLE 3605 -#define ER_TABLESPACE_DUP_FILENAME 3606 -#define ER_DB_DROP_RMDIR2 3607 -#define ER_IMP_NO_FILES_MATCHED 3608 -#define ER_IMP_SCHEMA_DOES_NOT_EXIST 3609 -#define ER_IMP_TABLE_ALREADY_EXISTS 3610 -#define ER_IMP_INCOMPATIBLE_MYSQLD_VERSION 3611 -#define ER_IMP_INCOMPATIBLE_DD_VERSION 3612 -#define ER_IMP_INCOMPATIBLE_SDI_VERSION 3613 -#define ER_WARN_INVALID_HINT 3614 -#define ER_VAR_DOES_NOT_EXIST 3615 -#define ER_LONGITUDE_OUT_OF_RANGE 3616 -#define ER_LATITUDE_OUT_OF_RANGE 3617 -#define ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS 3618 -#define ER_ILLEGAL_PRIVILEGE_LEVEL 3619 -#define ER_NO_SYSTEM_VIEW_ACCESS 3620 -#define ER_COMPONENT_FILTER_FLABBERGASTED 3621 -#define ER_PART_EXPR_TOO_LONG 3622 -#define ER_UDF_DROP_DYNAMICALLY_REGISTERED 3623 -#define ER_UNABLE_TO_STORE_COLUMN_STATISTICS 3624 -#define ER_UNABLE_TO_UPDATE_COLUMN_STATISTICS 3625 -#define ER_UNABLE_TO_DROP_COLUMN_STATISTICS 3626 -#define ER_UNABLE_TO_BUILD_HISTOGRAM 3627 -#define ER_MANDATORY_ROLE 3628 -#define ER_MISSING_TABLESPACE_FILE 3629 -#define ER_PERSIST_ONLY_ACCESS_DENIED_ERROR 3630 -#define ER_CMD_NEED_SUPER 3631 -#define ER_PATH_IN_DATADIR 3632 -#define ER_CLONE_DDL_IN_PROGRESS 3633 -#define ER_CLONE_TOO_MANY_CONCURRENT_CLONES 3634 -#define ER_APPLIER_LOG_EVENT_VALIDATION_ERROR 3635 -#define ER_CTE_MAX_RECURSION_DEPTH 3636 -#define ER_NOT_HINT_UPDATABLE_VARIABLE 3637 -#define ER_CREDENTIALS_CONTRADICT_TO_HISTORY 3638 -#define ER_WARNING_PASSWORD_HISTORY_CLAUSES_VOID 3639 -#define ER_CLIENT_DOES_NOT_SUPPORT 3640 -#define ER_I_S_SKIPPED_TABLESPACE 3641 -#define ER_TABLESPACE_ENGINE_MISMATCH 3642 -#define ER_WRONG_SRID_FOR_COLUMN 3643 -#define ER_CANNOT_ALTER_SRID_DUE_TO_INDEX 3644 -#define ER_WARN_BINLOG_PARTIAL_UPDATES_DISABLED 3645 -#define ER_WARN_BINLOG_V1_ROW_EVENTS_DISABLED 3646 -#define ER_WARN_BINLOG_PARTIAL_UPDATES_SUGGESTS_PARTIAL_IMAGES 3647 -#define ER_COULD_NOT_APPLY_JSON_DIFF 3648 -#define ER_CORRUPTED_JSON_DIFF 3649 -#define ER_RESOURCE_GROUP_EXISTS 3650 -#define ER_RESOURCE_GROUP_NOT_EXISTS 3651 -#define ER_INVALID_VCPU_ID 3652 -#define ER_INVALID_VCPU_RANGE 3653 -#define ER_INVALID_THREAD_PRIORITY 3654 -#define ER_DISALLOWED_OPERATION 3655 -#define ER_RESOURCE_GROUP_BUSY 3656 -#define ER_RESOURCE_GROUP_DISABLED 3657 -#define ER_FEATURE_UNSUPPORTED 3658 -#define ER_ATTRIBUTE_IGNORED 3659 -#define ER_INVALID_THREAD_ID 3660 -#define ER_RESOURCE_GROUP_BIND_FAILED 3661 -#define ER_INVALID_USE_OF_FORCE_OPTION 3662 -#define ER_GROUP_REPLICATION_COMMAND_FAILURE 3663 -#define ER_SDI_OPERATION_FAILED 3664 -#define ER_MISSING_JSON_TABLE_VALUE 3665 -#define ER_WRONG_JSON_TABLE_VALUE 3666 -#define ER_TF_MUST_HAVE_ALIAS 3667 -#define ER_TF_FORBIDDEN_JOIN_TYPE 3668 -#define ER_JT_VALUE_OUT_OF_RANGE 3669 -#define ER_JT_MAX_NESTED_PATH 3670 -#define ER_PASSWORD_EXPIRATION_NOT_SUPPORTED_BY_AUTH_METHOD 3671 -#define ER_INVALID_GEOJSON_CRS_NOT_TOP_LEVEL 3672 -#define ER_BAD_NULL_ERROR_NOT_IGNORED 3673 -#define WARN_USELESS_SPATIAL_INDEX 3674 -#define ER_DISK_FULL_NOWAIT 3675 -#define ER_PARSE_ERROR_IN_DIGEST_FN 3676 -#define ER_UNDISCLOSED_PARSE_ERROR_IN_DIGEST_FN 3677 -#define ER_SCHEMA_DIR_EXISTS 3678 -#define ER_SCHEMA_DIR_MISSING 3679 -#define ER_SCHEMA_DIR_CREATE_FAILED 3680 -#define ER_SCHEMA_DIR_UNKNOWN 3681 -#define ER_ONLY_IMPLEMENTED_FOR_SRID_0_AND_4326 3682 -#define ER_BINLOG_EXPIRE_LOG_DAYS_AND_SECS_USED_TOGETHER 3683 -#define ER_REGEXP_BUFFER_OVERFLOW 3684 -#define ER_REGEXP_ILLEGAL_ARGUMENT 3685 -#define ER_REGEXP_INDEX_OUTOFBOUNDS_ERROR 3686 -#define ER_REGEXP_INTERNAL_ERROR 3687 -#define ER_REGEXP_RULE_SYNTAX 3688 -#define ER_REGEXP_BAD_ESCAPE_SEQUENCE 3689 -#define ER_REGEXP_UNIMPLEMENTED 3690 -#define ER_REGEXP_MISMATCHED_PAREN 3691 -#define ER_REGEXP_BAD_INTERVAL 3692 -#define ER_REGEXP_MAX_LT_MIN 3693 -#define ER_REGEXP_INVALID_BACK_REF 3694 -#define ER_REGEXP_LOOK_BEHIND_LIMIT 3695 -#define ER_REGEXP_MISSING_CLOSE_BRACKET 3696 -#define ER_REGEXP_INVALID_RANGE 3697 -#define ER_REGEXP_STACK_OVERFLOW 3698 -#define ER_REGEXP_TIME_OUT 3699 -#define ER_REGEXP_PATTERN_TOO_BIG 3700 -#define ER_CANT_SET_ERROR_LOG_SERVICE 3701 -#define ER_EMPTY_PIPELINE_FOR_ERROR_LOG_SERVICE 3702 -#define ER_COMPONENT_FILTER_DIAGNOSTICS 3703 -#define ER_NOT_IMPLEMENTED_FOR_CARTESIAN_SRS 3704 -#define ER_NOT_IMPLEMENTED_FOR_PROJECTED_SRS 3705 -#define ER_NONPOSITIVE_RADIUS 3706 -#define ER_RESTART_SERVER_FAILED 3707 -#define ER_SRS_MISSING_MANDATORY_ATTRIBUTE 3708 -#define ER_SRS_MULTIPLE_ATTRIBUTE_DEFINITIONS 3709 -#define ER_SRS_NAME_CANT_BE_EMPTY_OR_WHITESPACE 3710 -#define ER_SRS_ORGANIZATION_CANT_BE_EMPTY_OR_WHITESPACE 3711 -#define ER_SRS_ID_ALREADY_EXISTS 3712 -#define ER_WARN_SRS_ID_ALREADY_EXISTS 3713 -#define ER_CANT_MODIFY_SRID_0 3714 -#define ER_WARN_RESERVED_SRID_RANGE 3715 -#define ER_CANT_MODIFY_SRS_USED_BY_COLUMN 3716 -#define ER_SRS_INVALID_CHARACTER_IN_ATTRIBUTE 3717 -#define ER_SRS_ATTRIBUTE_STRING_TOO_LONG 3718 -#define ER_DEPRECATED_UTF8_ALIAS 3719 -#define ER_DEPRECATED_NATIONAL 3720 -#define ER_INVALID_DEFAULT_UTF8MB4_COLLATION 3721 -#define ER_UNABLE_TO_COLLECT_LOG_STATUS 3722 -#define ER_RESERVED_TABLESPACE_NAME 3723 -#define ER_UNABLE_TO_SET_OPTION 3724 -#define ER_SLAVE_POSSIBLY_DIVERGED_AFTER_DDL 3725 -#define ER_SRS_NOT_GEOGRAPHIC 3726 -#define ER_POLYGON_TOO_LARGE 3727 -#define ER_SPATIAL_UNIQUE_INDEX 3728 -#define ER_INDEX_TYPE_NOT_SUPPORTED_FOR_SPATIAL_INDEX 3729 -#define ER_FK_CANNOT_DROP_PARENT 3730 -#define ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE 3731 -#define ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE 3732 -#define ER_FK_CANNOT_USE_VIRTUAL_COLUMN 3733 -#define ER_FK_NO_COLUMN_PARENT 3734 -#define ER_CANT_SET_ERROR_SUPPRESSION_LIST 3735 -#define ER_SRS_GEOGCS_INVALID_AXES 3736 -#define ER_SRS_INVALID_SEMI_MAJOR_AXIS 3737 -#define ER_SRS_INVALID_INVERSE_FLATTENING 3738 -#define ER_SRS_INVALID_ANGULAR_UNIT 3739 -#define ER_SRS_INVALID_PRIME_MERIDIAN 3740 -#define ER_TRANSFORM_SOURCE_SRS_NOT_SUPPORTED 3741 -#define ER_TRANSFORM_TARGET_SRS_NOT_SUPPORTED 3742 -#define ER_TRANSFORM_SOURCE_SRS_MISSING_TOWGS84 3743 -#define ER_TRANSFORM_TARGET_SRS_MISSING_TOWGS84 3744 -#define ER_TEMP_TABLE_PREVENTS_SWITCH_SESSION_BINLOG_FORMAT 3745 -#define ER_TEMP_TABLE_PREVENTS_SWITCH_GLOBAL_BINLOG_FORMAT 3746 -#define ER_RUNNING_APPLIER_PREVENTS_SWITCH_GLOBAL_BINLOG_FORMAT 3747 -#define ER_CLIENT_GTID_UNSAFE_CREATE_DROP_TEMP_TABLE_IN_TRX_IN_SBR 3748 -//#define OBSOLETE_ER_XA_CANT_CREATE_MDL_BACKUP 3749 -#define ER_TABLE_WITHOUT_PK 3750 -#define ER_WARN_DATA_TRUNCATED_FUNCTIONAL_INDEX 3751 -#define ER_WARN_DATA_OUT_OF_RANGE_FUNCTIONAL_INDEX 3752 -#define ER_FUNCTIONAL_INDEX_ON_JSON_OR_GEOMETRY_FUNCTION 3753 -#define ER_FUNCTIONAL_INDEX_REF_AUTO_INCREMENT 3754 -#define ER_CANNOT_DROP_COLUMN_FUNCTIONAL_INDEX 3755 -#define ER_FUNCTIONAL_INDEX_PRIMARY_KEY 3756 -#define ER_FUNCTIONAL_INDEX_ON_LOB 3757 -#define ER_FUNCTIONAL_INDEX_FUNCTION_IS_NOT_ALLOWED 3758 -#define ER_FULLTEXT_FUNCTIONAL_INDEX 3759 -#define ER_SPATIAL_FUNCTIONAL_INDEX 3760 -#define ER_WRONG_KEY_COLUMN_FUNCTIONAL_INDEX 3761 -#define ER_FUNCTIONAL_INDEX_ON_FIELD 3762 -#define ER_GENERATED_COLUMN_NAMED_FUNCTION_IS_NOT_ALLOWED 3763 -#define ER_GENERATED_COLUMN_ROW_VALUE 3764 -#define ER_GENERATED_COLUMN_VARIABLES 3765 -#define ER_DEPENDENT_BY_DEFAULT_GENERATED_VALUE 3766 -#define ER_DEFAULT_VAL_GENERATED_NON_PRIOR 3767 -#define ER_DEFAULT_VAL_GENERATED_REF_AUTO_INC 3768 -#define ER_DEFAULT_VAL_GENERATED_FUNCTION_IS_NOT_ALLOWED 3769 -#define ER_DEFAULT_VAL_GENERATED_NAMED_FUNCTION_IS_NOT_ALLOWED 3770 -#define ER_DEFAULT_VAL_GENERATED_ROW_VALUE 3771 -#define ER_DEFAULT_VAL_GENERATED_VARIABLES 3772 -#define ER_DEFAULT_AS_VAL_GENERATED 3773 -#define ER_UNSUPPORTED_ACTION_ON_DEFAULT_VAL_GENERATED 3774 -#define ER_GTID_UNSAFE_ALTER_ADD_COL_WITH_DEFAULT_EXPRESSION 3775 -#define ER_FK_CANNOT_CHANGE_ENGINE 3776 -#define ER_WARN_DEPRECATED_USER_SET_EXPR 3777 -#define ER_WARN_DEPRECATED_UTF8MB3_COLLATION 3778 -#define ER_WARN_DEPRECATED_NESTED_COMMENT_SYNTAX 3779 -#define ER_FK_INCOMPATIBLE_COLUMNS 3780 -#define ER_GR_HOLD_WAIT_TIMEOUT 3781 -#define ER_GR_HOLD_KILLED 3782 -#define ER_GR_HOLD_MEMBER_STATUS_ERROR 3783 -#define ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY 3784 -#define ER_RPL_ENCRYPTION_KEY_NOT_FOUND 3785 -#define ER_RPL_ENCRYPTION_KEYRING_INVALID_KEY 3786 -#define ER_RPL_ENCRYPTION_HEADER_ERROR 3787 -#define ER_RPL_ENCRYPTION_FAILED_TO_ROTATE_LOGS 3788 -#define ER_RPL_ENCRYPTION_KEY_EXISTS_UNEXPECTED 3789 -#define ER_RPL_ENCRYPTION_FAILED_TO_GENERATE_KEY 3790 -#define ER_RPL_ENCRYPTION_FAILED_TO_STORE_KEY 3791 -#define ER_RPL_ENCRYPTION_FAILED_TO_REMOVE_KEY 3792 -#define ER_RPL_ENCRYPTION_UNABLE_TO_CHANGE_OPTION 3793 -#define ER_RPL_ENCRYPTION_MASTER_KEY_RECOVERY_FAILED 3794 -#define ER_SLOW_LOG_MODE_IGNORED_WHEN_NOT_LOGGING_TO_FILE 3795 -#define ER_GRP_TRX_CONSISTENCY_NOT_ALLOWED 3796 -#define ER_GRP_TRX_CONSISTENCY_BEFORE 3797 -#define ER_GRP_TRX_CONSISTENCY_AFTER_ON_TRX_BEGIN 3798 -#define ER_GRP_TRX_CONSISTENCY_BEGIN_NOT_ALLOWED 3799 -#define ER_FUNCTIONAL_INDEX_ROW_VALUE_IS_NOT_ALLOWED 3800 -#define ER_RPL_ENCRYPTION_FAILED_TO_ENCRYPT 3801 -#define ER_PAGE_TRACKING_NOT_STARTED 3802 -#define ER_PAGE_TRACKING_RANGE_NOT_TRACKED 3803 -#define ER_PAGE_TRACKING_CANNOT_PURGE 3804 -#define ER_RPL_ENCRYPTION_CANNOT_ROTATE_BINLOG_MASTER_KEY 3805 -#define ER_BINLOG_MASTER_KEY_RECOVERY_OUT_OF_COMBINATION 3806 -#define ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY 3807 -#define ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_ROTATE_LOGS 3808 -#define ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG 3809 -#define ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS 3810 -#define ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_AUX_KEY 3811 -#define ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT 3812 -#define ER_COLUMN_CHECK_CONSTRAINT_REFERENCES_OTHER_COLUMN 3813 -#define ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED 3814 -#define ER_CHECK_CONSTRAINT_FUNCTION_IS_NOT_ALLOWED 3815 -#define ER_CHECK_CONSTRAINT_VARIABLES 3816 -#define ER_CHECK_CONSTRAINT_ROW_VALUE 3817 -#define ER_CHECK_CONSTRAINT_REFERS_AUTO_INCREMENT_COLUMN 3818 -#define ER_CHECK_CONSTRAINT_VIOLATED 3819 -#define ER_CHECK_CONSTRAINT_REFERS_UNKNOWN_COLUMN 3820 -#define ER_CHECK_CONSTRAINT_NOT_FOUND 3821 -#define ER_CHECK_CONSTRAINT_DUP_NAME 3822 -#define ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN 3823 -#define WARN_UNENCRYPTED_TABLE_IN_ENCRYPTED_DB 3824 -#define ER_INVALID_ENCRYPTION_REQUEST 3825 -#define ER_CANNOT_SET_TABLE_ENCRYPTION 3826 -#define ER_CANNOT_SET_DATABASE_ENCRYPTION 3827 -#define ER_CANNOT_SET_TABLESPACE_ENCRYPTION 3828 -#define ER_TABLESPACE_CANNOT_BE_ENCRYPTED 3829 -#define ER_TABLESPACE_CANNOT_BE_DECRYPTED 3830 -#define ER_TABLESPACE_TYPE_UNKNOWN 3831 -#define ER_TARGET_TABLESPACE_UNENCRYPTED 3832 -#define ER_CANNOT_USE_ENCRYPTION_CLAUSE 3833 -#define ER_INVALID_MULTIPLE_CLAUSES 3834 -#define ER_UNSUPPORTED_USE_OF_GRANT_AS 3835 -#define ER_UKNOWN_AUTH_ID_OR_ACCESS_DENIED_FOR_GRANT_AS 3836 -#define ER_DEPENDENT_BY_FUNCTIONAL_INDEX 3837 -#define ER_PLUGIN_NOT_EARLY 3838 -#define ER_INNODB_REDO_LOG_ARCHIVE_START_SUBDIR_PATH 3839 -#define ER_INNODB_REDO_LOG_ARCHIVE_START_TIMEOUT 3840 -#define ER_INNODB_REDO_LOG_ARCHIVE_DIRS_INVALID 3841 -#define ER_INNODB_REDO_LOG_ARCHIVE_LABEL_NOT_FOUND 3842 -#define ER_INNODB_REDO_LOG_ARCHIVE_DIR_EMPTY 3843 -#define ER_INNODB_REDO_LOG_ARCHIVE_NO_SUCH_DIR 3844 -#define ER_INNODB_REDO_LOG_ARCHIVE_DIR_CLASH 3845 -#define ER_INNODB_REDO_LOG_ARCHIVE_DIR_PERMISSIONS 3846 -#define ER_INNODB_REDO_LOG_ARCHIVE_FILE_CREATE 3847 -#define ER_INNODB_REDO_LOG_ARCHIVE_ACTIVE 3848 -#define ER_INNODB_REDO_LOG_ARCHIVE_INACTIVE 3849 -#define ER_INNODB_REDO_LOG_ARCHIVE_FAILED 3850 -#define ER_INNODB_REDO_LOG_ARCHIVE_SESSION 3851 -#define ER_STD_REGEX_ERROR 3852 -#define ER_INVALID_JSON_TYPE 3853 -#define ER_CANNOT_CONVERT_STRING 3854 -#define ER_DEPENDENT_BY_PARTITION_FUNC 3855 -#define ER_WARN_DEPRECATED_FLOAT_AUTO_INCREMENT 3856 -#define ER_RPL_CANT_STOP_SLAVE_WHILE_LOCKED_BACKUP 3857 -#define ER_WARN_DEPRECATED_FLOAT_DIGITS 3858 -#define ER_WARN_DEPRECATED_FLOAT_UNSIGNED 3859 -#define ER_WARN_DEPRECATED_INTEGER_DISPLAY_WIDTH 3860 -#define ER_WARN_DEPRECATED_ZEROFILL 3861 -#define ER_CLONE_DONOR 3862 -#define ER_CLONE_PROTOCOL 3863 -#define ER_CLONE_DONOR_VERSION 3864 -#define ER_CLONE_OS 3865 -#define ER_CLONE_PLATFORM 3866 -#define ER_CLONE_CHARSET 3867 -#define ER_CLONE_CONFIG 3868 -#define ER_CLONE_SYS_CONFIG 3869 -#define ER_CLONE_PLUGIN_MATCH 3870 -#define ER_CLONE_LOOPBACK 3871 -#define ER_CLONE_ENCRYPTION 3872 -#define ER_CLONE_DISK_SPACE 3873 -#define ER_CLONE_IN_PROGRESS 3874 -#define ER_CLONE_DISALLOWED 3875 -#define ER_CANNOT_GRANT_ROLES_TO_ANONYMOUS_USER 3876 -#define ER_SECONDARY_ENGINE_PLUGIN 3877 -#define ER_SECOND_PASSWORD_CANNOT_BE_EMPTY 3878 -#define ER_DB_ACCESS_DENIED 3879 -#define ER_DA_AUTH_ID_WITH_SYSTEM_USER_PRIV_IN_MANDATORY_ROLES 3880 -#define ER_DA_RPL_GTID_TABLE_CANNOT_OPEN 3881 -#define ER_GEOMETRY_IN_UNKNOWN_LENGTH_UNIT 3882 -#define ER_DA_PLUGIN_INSTALL_ERROR 3883 -#define ER_NO_SESSION_TEMP 3884 -#define ER_DA_UNKNOWN_ERROR_NUMBER 3885 -#define ER_COLUMN_CHANGE_SIZE 3886 -#define ER_REGEXP_INVALID_CAPTURE_GROUP_NAME 3887 -#define ER_DA_SSL_LIBRARY_ERROR 3888 -#define ER_SECONDARY_ENGINE 3889 -#define ER_SECONDARY_ENGINE_DDL 3890 -#define ER_INCORRECT_CURRENT_PASSWORD 3891 -#define ER_MISSING_CURRENT_PASSWORD 3892 -#define ER_CURRENT_PASSWORD_NOT_REQUIRED 3893 -#define ER_PASSWORD_CANNOT_BE_RETAINED_ON_PLUGIN_CHANGE 3894 -#define ER_CURRENT_PASSWORD_CANNOT_BE_RETAINED 3895 -#define ER_PARTIAL_REVOKES_EXIST 3896 -#define ER_CANNOT_GRANT_SYSTEM_PRIV_TO_MANDATORY_ROLE 3897 -#define ER_XA_REPLICATION_FILTERS 3898 -#define ER_UNSUPPORTED_SQL_MODE 3899 -#define ER_REGEXP_INVALID_FLAG 3900 -#define ER_PARTIAL_REVOKE_AND_DB_GRANT_BOTH_EXISTS 3901 -#define ER_UNIT_NOT_FOUND 3902 -#define ER_INVALID_JSON_VALUE_FOR_FUNC_INDEX 3903 -#define ER_JSON_VALUE_OUT_OF_RANGE_FOR_FUNC_INDEX 3904 -#define ER_EXCEEDED_MV_KEYS_NUM 3905 -#define ER_EXCEEDED_MV_KEYS_SPACE 3906 -#define ER_FUNCTIONAL_INDEX_DATA_IS_TOO_LONG 3907 -#define ER_WRONG_MVI_VALUE 3908 -#define ER_WARN_FUNC_INDEX_NOT_APPLICABLE 3909 -#define ER_GRP_RPL_UDF_ERROR 3910 -#define ER_UPDATE_GTID_PURGED_WITH_GR 3911 -#define ER_GROUPING_ON_TIMESTAMP_IN_DST 3912 -#define ER_TABLE_NAME_CAUSES_TOO_LONG_PATH 3913 -#define ER_AUDIT_LOG_INSUFFICIENT_PRIVILEGE 3914 -//#define OBSOLETE_ER_AUDIT_LOG_PASSWORD_HAS_BEEN_COPIED 3915 -#define ER_DA_GRP_RPL_STARTED_AUTO_REJOIN 3916 -#define ER_PARSER_TRACE 10000 -#define ER_BOOTSTRAP_CANT_THREAD 10001 -#define ER_TRIGGER_INVALID_VALUE 10002 -#define ER_OPT_WRONG_TREE 10003 -#define ER_DD_FAILSAFE 10004 -#define ER_DD_NO_WRITES_NO_REPOPULATION 10005 -#define ER_DD_VERSION_FOUND 10006 -#define ER_DD_VERSION_INSTALLED 10007 -#define ER_DD_VERSION_UNSUPPORTED 10008 -//#define OBSOLETE_ER_LOG_SYSLOG_FACILITY_FAIL 10009 -#define ER_LOG_SYSLOG_CANNOT_OPEN 10010 -#define ER_LOG_SLOW_CANNOT_OPEN 10011 -#define ER_LOG_GENERAL_CANNOT_OPEN 10012 -#define ER_LOG_CANNOT_WRITE 10013 -#define ER_RPL_ZOMBIE_ENCOUNTERED 10014 -#define ER_RPL_GTID_TABLE_CANNOT_OPEN 10015 -#define ER_SYSTEM_SCHEMA_NOT_FOUND 10016 -#define ER_DD_INIT_UPGRADE_FAILED 10017 -#define ER_VIEW_UNKNOWN_CHARSET_OR_COLLATION 10018 -#define ER_DD_VIEW_CANT_ALLOC_CHARSET 10019 -#define ER_DD_INIT_FAILED 10020 -#define ER_DD_UPDATING_PLUGIN_MD_FAILED 10021 -#define ER_DD_POPULATING_TABLES_FAILED 10022 -#define ER_DD_VIEW_CANT_CREATE 10023 -#define ER_DD_METADATA_NOT_FOUND 10024 -#define ER_DD_CACHE_NOT_EMPTY_AT_SHUTDOWN 10025 -#define ER_DD_OBJECT_REMAINS 10026 -#define ER_DD_OBJECT_REMAINS_IN_RELEASER 10027 -#define ER_DD_OBJECT_RELEASER_REMAINS 10028 -#define ER_DD_CANT_GET_OBJECT_KEY 10029 -#define ER_DD_CANT_CREATE_OBJECT_KEY 10030 -#define ER_CANT_CREATE_HANDLE_MGR_THREAD 10031 -#define ER_RPL_REPO_HAS_GAPS 10032 -#define ER_INVALID_VALUE_FOR_ENFORCE_GTID_CONSISTENCY 10033 -#define ER_CHANGED_ENFORCE_GTID_CONSISTENCY 10034 -#define ER_CHANGED_GTID_MODE 10035 -#define ER_DISABLED_STORAGE_ENGINE_AS_DEFAULT 10036 -#define ER_DEBUG_SYNC_HIT 10037 -#define ER_DEBUG_SYNC_EXECUTED 10038 -#define ER_DEBUG_SYNC_THREAD_MAX 10039 -#define ER_DEBUG_SYNC_OOM 10040 -#define ER_CANT_INIT_TC_LOG 10041 -#define ER_EVENT_CANT_INIT_QUEUE 10042 -#define ER_EVENT_PURGING_QUEUE 10043 -#define ER_EVENT_LAST_EXECUTION 10044 -#define ER_EVENT_MESSAGE_STACK 10045 -#define ER_EVENT_EXECUTION_FAILED 10046 -#define ER_CANT_INIT_SCHEDULER_THREAD 10047 -#define ER_SCHEDULER_STOPPED 10048 -#define ER_CANT_CREATE_SCHEDULER_THREAD 10049 -#define ER_SCHEDULER_WAITING 10050 -#define ER_SCHEDULER_STARTED 10051 -#define ER_SCHEDULER_STOPPING_FAILED_TO_GET_EVENT 10052 -#define ER_SCHEDULER_STOPPING_FAILED_TO_CREATE_WORKER 10053 -#define ER_SCHEDULER_KILLING 10054 -#define ER_UNABLE_TO_RESOLVE_IP 10055 -#define ER_UNABLE_TO_RESOLVE_HOSTNAME 10056 -#define ER_HOSTNAME_RESEMBLES_IPV4 10057 -#define ER_HOSTNAME_DOESNT_RESOLVE_TO 10058 -#define ER_ADDRESSES_FOR_HOSTNAME_HEADER 10059 -#define ER_ADDRESSES_FOR_HOSTNAME_LIST_ITEM 10060 -#define ER_TRG_WITHOUT_DEFINER 10061 -#define ER_TRG_NO_CLIENT_CHARSET 10062 -#define ER_PARSING_VIEW 10063 -#define ER_COMPONENTS_INFRASTRUCTURE_BOOTSTRAP 10064 -#define ER_COMPONENTS_INFRASTRUCTURE_SHUTDOWN 10065 -#define ER_COMPONENTS_PERSIST_LOADER_BOOTSTRAP 10066 -#define ER_DEPART_WITH_GRACE 10067 -#define ER_CA_SELF_SIGNED 10068 -#define ER_SSL_LIBRARY_ERROR 10069 -#define ER_NO_THD_NO_UUID 10070 -#define ER_UUID_SALT 10071 -#define ER_UUID_IS 10072 -#define ER_UUID_INVALID 10073 -#define ER_UUID_SCRUB 10074 -#define ER_CREATING_NEW_UUID 10075 -#define ER_CANT_CREATE_UUID 10076 -#define ER_UNKNOWN_UNSUPPORTED_STORAGE_ENGINE 10077 -#define ER_SECURE_AUTH_VALUE_UNSUPPORTED 10078 -#define ER_INVALID_INSTRUMENT 10079 -#define ER_INNODB_MANDATORY 10080 -//#define OBSOLETE_ER_INNODB_CANNOT_BE_IGNORED 10081 -//#define OBSOLETE_ER_OLD_PASSWORDS_NO_MIDDLE_GROUND 10082 -#define ER_VERBOSE_REQUIRES_HELP 10083 -#define ER_POINTLESS_WITHOUT_SLOWLOG 10084 -#define ER_WASTEFUL_NET_BUFFER_SIZE 10085 -#define ER_DEPRECATED_TIMESTAMP_IMPLICIT_DEFAULTS 10086 -#define ER_FT_BOOL_SYNTAX_INVALID 10087 -#define ER_CREDENTIALLESS_AUTO_USER_BAD 10088 -#define ER_CONNECTION_HANDLING_OOM 10089 -#define ER_THREAD_HANDLING_OOM 10090 -#define ER_CANT_CREATE_TEST_FILE 10091 -#define ER_CANT_CREATE_PID_FILE 10092 -#define ER_CANT_REMOVE_PID_FILE 10093 -#define ER_CANT_CREATE_SHUTDOWN_THREAD 10094 -#define ER_SEC_FILE_PRIV_CANT_ACCESS_DIR 10095 -#define ER_SEC_FILE_PRIV_IGNORED 10096 -#define ER_SEC_FILE_PRIV_EMPTY 10097 -#define ER_SEC_FILE_PRIV_NULL 10098 -#define ER_SEC_FILE_PRIV_DIRECTORY_INSECURE 10099 -#define ER_SEC_FILE_PRIV_CANT_STAT 10100 -#define ER_SEC_FILE_PRIV_DIRECTORY_PERMISSIONS 10101 -#define ER_SEC_FILE_PRIV_ARGUMENT_TOO_LONG 10102 -#define ER_CANT_CREATE_NAMED_PIPES_THREAD 10103 -#define ER_CANT_CREATE_TCPIP_THREAD 10104 -#define ER_CANT_CREATE_SHM_THREAD 10105 -#define ER_CANT_CREATE_INTERRUPT_THREAD 10106 -#define ER_WRITABLE_CONFIG_REMOVED 10107 -#define ER_CORE_VALUES 10108 -#define ER_WRONG_DATETIME_SPEC 10109 -#define ER_RPL_BINLOG_FILTERS_OOM 10110 -#define ER_KEYCACHE_OOM 10111 -#define ER_CONFIRMING_THE_FUTURE 10112 -#define ER_BACK_IN_TIME 10113 -#define ER_FUTURE_DATE 10114 -#define ER_UNSUPPORTED_DATE 10115 -#define ER_STARTING_AS 10116 -#define ER_SHUTTING_DOWN_SLAVE_THREADS 10117 -#define ER_DISCONNECTING_REMAINING_CLIENTS 10118 -#define ER_ABORTING 10119 -#define ER_BINLOG_END 10120 -#define ER_CALL_ME_LOCALHOST 10121 -#define ER_USER_REQUIRES_ROOT 10122 -#define ER_REALLY_RUN_AS_ROOT 10123 -#define ER_USER_WHAT_USER 10124 -#define ER_TRANSPORTS_WHAT_TRANSPORTS 10125 -#define ER_FAIL_SETGID 10126 -#define ER_FAIL_SETUID 10127 -#define ER_FAIL_SETREGID 10128 -#define ER_FAIL_SETREUID 10129 -#define ER_FAIL_CHROOT 10130 -#define ER_WIN_LISTEN_BUT_HOW 10131 -#define ER_NOT_RIGHT_NOW 10132 -#define ER_FIXING_CLIENT_CHARSET 10133 -#define ER_OOM 10134 -#define ER_FAILED_TO_LOCK_MEM 10135 -#define ER_MYINIT_FAILED 10136 -#define ER_BEG_INITFILE 10137 -#define ER_END_INITFILE 10138 -#define ER_CHANGED_MAX_OPEN_FILES 10139 -#define ER_CANT_INCREASE_MAX_OPEN_FILES 10140 -#define ER_CHANGED_MAX_CONNECTIONS 10141 -#define ER_CHANGED_TABLE_OPEN_CACHE 10142 -#define ER_THE_USER_ABIDES 10143 -#define ER_RPL_CANT_ADD_DO_TABLE 10144 -#define ER_RPL_CANT_ADD_IGNORE_TABLE 10145 -#define ER_TRACK_VARIABLES_BOGUS 10146 -#define ER_EXCESS_ARGUMENTS 10147 -#define ER_VERBOSE_HINT 10148 -#define ER_CANT_READ_ERRMSGS 10149 -#define ER_CANT_INIT_DBS 10150 -#define ER_LOG_OUTPUT_CONTRADICTORY 10151 -#define ER_NO_CSV_NO_LOG_TABLES 10152 -#define ER_RPL_REWRITEDB_MISSING_ARROW 10153 -#define ER_RPL_REWRITEDB_EMPTY_FROM 10154 -#define ER_RPL_REWRITEDB_EMPTY_TO 10155 -#define ER_LOG_FILES_GIVEN_LOG_OUTPUT_IS_TABLE 10156 -#define ER_LOG_FILE_INVALID 10157 -#define ER_LOWER_CASE_TABLE_NAMES_CS_DD_ON_CI_FS_UNSUPPORTED 10158 -#define ER_LOWER_CASE_TABLE_NAMES_USING_2 10159 -#define ER_LOWER_CASE_TABLE_NAMES_USING_0 10160 -#define ER_NEED_LOG_BIN 10161 -#define ER_NEED_FILE_INSTEAD_OF_DIR 10162 -#define ER_LOG_BIN_BETTER_WITH_NAME 10163 -#define ER_BINLOG_NEEDS_SERVERID 10164 -#define ER_RPL_CANT_MAKE_PATHS 10165 -#define ER_CANT_INITIALIZE_GTID 10166 -#define ER_CANT_INITIALIZE_EARLY_PLUGINS 10167 -#define ER_CANT_INITIALIZE_BUILTIN_PLUGINS 10168 -#define ER_CANT_INITIALIZE_DYNAMIC_PLUGINS 10169 -#define ER_PERFSCHEMA_INIT_FAILED 10170 -#define ER_STACKSIZE_UNEXPECTED 10171 -//#define OBSOLETE_ER_CANT_SET_DATADIR 10172 -#define ER_CANT_STAT_DATADIR 10173 -#define ER_CANT_CHOWN_DATADIR 10174 -#define ER_CANT_SET_UP_PERSISTED_VALUES 10175 -#define ER_CANT_SAVE_GTIDS 10176 -#define ER_AUTH_CANT_SET_DEFAULT_PLUGIN 10177 -#define ER_CANT_JOIN_SHUTDOWN_THREAD 10178 -#define ER_CANT_HASH_DO_AND_IGNORE_RULES 10179 -#define ER_CANT_OPEN_CA 10180 -#define ER_CANT_ACCESS_CAPATH 10181 -#define ER_SSL_TRYING_DATADIR_DEFAULTS 10182 -#define ER_AUTO_OPTIONS_FAILED 10183 -#define ER_CANT_INIT_TIMER 10184 -#define ER_SERVERID_TOO_LARGE 10185 -#define ER_DEFAULT_SE_UNAVAILABLE 10186 -#define ER_CANT_OPEN_ERROR_LOG 10187 -#define ER_INVALID_ERROR_LOG_NAME 10188 -#define ER_RPL_INFINITY_DENIED 10189 -#define ER_RPL_INFINITY_IGNORED 10190 -//#define OBSOLETE_ER_NDB_TABLES_NOT_READY 10191 -#define ER_TABLE_CHECK_INTACT 10192 -#define ER_DD_TABLESPACE_NOT_FOUND 10193 -#define ER_DD_TRG_CONNECTION_COLLATION_MISSING 10194 -#define ER_DD_TRG_DB_COLLATION_MISSING 10195 -#define ER_DD_TRG_DEFINER_OOM 10196 -#define ER_DD_TRG_FILE_UNREADABLE 10197 -#define ER_TRG_CANT_PARSE 10198 -#define ER_DD_TRG_CANT_ADD 10199 -#define ER_DD_CANT_RESOLVE_VIEW 10200 -#define ER_DD_VIEW_WITHOUT_DEFINER 10201 -#define ER_PLUGIN_INIT_FAILED 10202 -#define ER_RPL_TRX_DELEGATES_INIT_FAILED 10203 -#define ER_RPL_BINLOG_STORAGE_DELEGATES_INIT_FAILED 10204 -#define ER_RPL_BINLOG_TRANSMIT_DELEGATES_INIT_FAILED 10205 -#define ER_RPL_BINLOG_RELAY_DELEGATES_INIT_FAILED 10206 -#define ER_RPL_PLUGIN_FUNCTION_FAILED 10207 -#define ER_SQL_HA_READ_FAILED 10208 -#define ER_SR_BOGUS_VALUE 10209 -#define ER_SR_INVALID_CONTEXT 10210 -#define ER_READING_TABLE_FAILED 10211 -#define ER_DES_FILE_WRONG_KEY 10212 -#define ER_CANT_SET_PERSISTED 10213 -#define ER_JSON_PARSE_ERROR 10214 -#define ER_CONFIG_OPTION_WITHOUT_GROUP 10215 -#define ER_VALGRIND_DO_QUICK_LEAK_CHECK 10216 -#define ER_VALGRIND_COUNT_LEAKS 10217 -#define ER_LOAD_DATA_INFILE_FAILED_IN_UNEXPECTED_WAY 10218 -#define ER_UNKNOWN_ERROR_NUMBER 10219 -#define ER_UDF_CANT_ALLOC_FOR_STRUCTURES 10220 -#define ER_UDF_CANT_ALLOC_FOR_FUNCTION 10221 -#define ER_UDF_INVALID_ROW_IN_FUNCTION_TABLE 10222 -#define ER_UDF_CANT_OPEN_FUNCTION_TABLE 10223 -#define ER_XA_RECOVER_FOUND_TRX_IN_SE 10224 -#define ER_XA_RECOVER_FOUND_XA_TRX 10225 -#define ER_XA_IGNORING_XID 10226 -#define ER_XA_COMMITTING_XID 10227 -#define ER_XA_ROLLING_BACK_XID 10228 -#define ER_XA_STARTING_RECOVERY 10229 -#define ER_XA_NO_MULTI_2PC_HEURISTIC_RECOVER 10230 -#define ER_XA_RECOVER_EXPLANATION 10231 -#define ER_XA_RECOVERY_DONE 10232 -#define ER_TRX_GTID_COLLECT_REJECT 10233 -#define ER_SQL_AUTHOR_DEFAULT_ROLES_FAIL 10234 -#define ER_SQL_USER_TABLE_CREATE_WARNING 10235 -#define ER_SQL_USER_TABLE_ALTER_WARNING 10236 -#define ER_ROW_IN_WRONG_PARTITION_PLEASE_REPAIR 10237 -#define ER_MYISAM_CRASHED_ERROR_IN_THREAD 10238 -#define ER_MYISAM_CRASHED_ERROR_IN 10239 -#define ER_TOO_MANY_STORAGE_ENGINES 10240 -#define ER_SE_TYPECODE_CONFLICT 10241 -#define ER_TRX_WRITE_SET_OOM 10242 -#define ER_HANDLERTON_OOM 10243 -#define ER_CONN_SHM_LISTENER 10244 -#define ER_CONN_SHM_CANT_CREATE_SERVICE 10245 -#define ER_CONN_SHM_CANT_CREATE_CONNECTION 10246 -#define ER_CONN_PIP_CANT_CREATE_EVENT 10247 -#define ER_CONN_PIP_CANT_CREATE_PIPE 10248 -#define ER_CONN_PER_THREAD_NO_THREAD 10249 -#define ER_CONN_TCP_NO_SOCKET 10250 -#define ER_CONN_TCP_CREATED 10251 -#define ER_CONN_TCP_ADDRESS 10252 -#define ER_CONN_TCP_IPV6_AVAILABLE 10253 -#define ER_CONN_TCP_IPV6_UNAVAILABLE 10254 -#define ER_CONN_TCP_ERROR_WITH_STRERROR 10255 -#define ER_CONN_TCP_CANT_RESOLVE_HOSTNAME 10256 -#define ER_CONN_TCP_IS_THERE_ANOTHER_USING_PORT 10257 -#define ER_CONN_UNIX_IS_THERE_ANOTHER_USING_SOCKET 10258 -#define ER_CONN_UNIX_PID_CLAIMED_SOCKET_FILE 10259 -#define ER_CONN_TCP_CANT_RESET_V6ONLY 10260 -#define ER_CONN_TCP_BIND_RETRY 10261 -#define ER_CONN_TCP_BIND_FAIL 10262 -#define ER_CONN_TCP_IP_NOT_LOGGED 10263 -#define ER_CONN_TCP_RESOLVE_INFO 10264 -#define ER_CONN_TCP_START_FAIL 10265 -#define ER_CONN_TCP_LISTEN_FAIL 10266 -#define ER_CONN_UNIX_PATH_TOO_LONG 10267 -#define ER_CONN_UNIX_LOCK_FILE_FAIL 10268 -#define ER_CONN_UNIX_NO_FD 10269 -#define ER_CONN_UNIX_NO_BIND_NO_START 10270 -#define ER_CONN_UNIX_LISTEN_FAILED 10271 -#define ER_CONN_UNIX_LOCK_FILE_GIVING_UP 10272 -#define ER_CONN_UNIX_LOCK_FILE_CANT_CREATE 10273 -#define ER_CONN_UNIX_LOCK_FILE_CANT_OPEN 10274 -#define ER_CONN_UNIX_LOCK_FILE_CANT_READ 10275 -#define ER_CONN_UNIX_LOCK_FILE_EMPTY 10276 -#define ER_CONN_UNIX_LOCK_FILE_PIDLESS 10277 -#define ER_CONN_UNIX_LOCK_FILE_CANT_WRITE 10278 -#define ER_CONN_UNIX_LOCK_FILE_CANT_DELETE 10279 -#define ER_CONN_UNIX_LOCK_FILE_CANT_SYNC 10280 -#define ER_CONN_UNIX_LOCK_FILE_CANT_CLOSE 10281 -#define ER_CONN_SOCKET_SELECT_FAILED 10282 -#define ER_CONN_SOCKET_ACCEPT_FAILED 10283 -#define ER_AUTH_RSA_CANT_FIND 10284 -#define ER_AUTH_RSA_CANT_PARSE 10285 -#define ER_AUTH_RSA_CANT_READ 10286 -#define ER_AUTH_RSA_FILES_NOT_FOUND 10287 -#define ER_CONN_ATTR_TRUNCATED 10288 -#define ER_X509_CIPHERS_MISMATCH 10289 -#define ER_X509_ISSUER_MISMATCH 10290 -#define ER_X509_SUBJECT_MISMATCH 10291 -#define ER_AUTH_CANT_ACTIVATE_ROLE 10292 -#define ER_X509_NEEDS_RSA_PRIVKEY 10293 -#define ER_X509_CANT_WRITE_KEY 10294 -#define ER_X509_CANT_CHMOD_KEY 10295 -#define ER_X509_CANT_READ_CA_KEY 10296 -#define ER_X509_CANT_READ_CA_CERT 10297 -#define ER_X509_CANT_CREATE_CERT 10298 -#define ER_X509_CANT_WRITE_CERT 10299 -#define ER_AUTH_CANT_CREATE_RSA_PAIR 10300 -#define ER_AUTH_CANT_WRITE_PRIVKEY 10301 -#define ER_AUTH_CANT_WRITE_PUBKEY 10302 -#define ER_AUTH_SSL_CONF_PREVENTS_CERT_GENERATION 10303 -#define ER_AUTH_USING_EXISTING_CERTS 10304 -#define ER_AUTH_CERTS_SAVED_TO_DATADIR 10305 -#define ER_AUTH_CERT_GENERATION_DISABLED 10306 -#define ER_AUTH_RSA_CONF_PREVENTS_KEY_GENERATION 10307 -#define ER_AUTH_KEY_GENERATION_SKIPPED_PAIR_PRESENT 10308 -#define ER_AUTH_KEYS_SAVED_TO_DATADIR 10309 -#define ER_AUTH_KEY_GENERATION_DISABLED 10310 -#define ER_AUTHCACHE_PROXIES_PRIV_SKIPPED_NEEDS_RESOLVE 10311 -#define ER_AUTHCACHE_PLUGIN_MISSING 10312 -#define ER_AUTHCACHE_PLUGIN_CONFIG 10313 -//#define OBSOLETE_ER_AUTHCACHE_ROLE_TABLES_DODGY 10314 -#define ER_AUTHCACHE_USER_SKIPPED_NEEDS_RESOLVE 10315 -#define ER_AUTHCACHE_USER_TABLE_DODGY 10316 -#define ER_AUTHCACHE_USER_IGNORED_DEPRECATED_PASSWORD 10317 -#define ER_AUTHCACHE_USER_IGNORED_NEEDS_PLUGIN 10318 -#define ER_AUTHCACHE_USER_IGNORED_INVALID_PASSWORD 10319 -#define ER_AUTHCACHE_EXPIRED_PASSWORD_UNSUPPORTED 10320 -#define ER_NO_SUPER_WITHOUT_USER_PLUGIN 10321 -#define ER_AUTHCACHE_DB_IGNORED_EMPTY_NAME 10322 -#define ER_AUTHCACHE_DB_SKIPPED_NEEDS_RESOLVE 10323 -#define ER_AUTHCACHE_DB_ENTRY_LOWERCASED_REVOKE_WILL_FAIL 10324 -#define ER_AUTHCACHE_TABLE_PROXIES_PRIV_MISSING 10325 -#define ER_AUTHCACHE_CANT_OPEN_AND_LOCK_PRIVILEGE_TABLES 10326 -#define ER_AUTHCACHE_CANT_INIT_GRANT_SUBSYSTEM 10327 -#define ER_AUTHCACHE_PROCS_PRIV_SKIPPED_NEEDS_RESOLVE 10328 -#define ER_AUTHCACHE_PROCS_PRIV_ENTRY_IGNORED_BAD_ROUTINE_TYPE 10329 -#define ER_AUTHCACHE_TABLES_PRIV_SKIPPED_NEEDS_RESOLVE 10330 -#define ER_USER_NOT_IN_EXTRA_USERS_BINLOG_POSSIBLY_INCOMPLETE 10331 -#define ER_DD_SCHEMA_NOT_FOUND 10332 -#define ER_DD_TABLE_NOT_FOUND 10333 -#define ER_DD_SE_INIT_FAILED 10334 -#define ER_DD_ABORTING_PARTIAL_UPGRADE 10335 -#define ER_DD_FRM_EXISTS_FOR_TABLE 10336 -#define ER_DD_CREATED_FOR_UPGRADE 10337 -#define ER_ERRMSG_CANT_FIND_FILE 10338 -#define ER_ERRMSG_LOADING_55_STYLE 10339 -#define ER_ERRMSG_MISSING_IN_FILE 10340 -#define ER_ERRMSG_OOM 10341 -#define ER_ERRMSG_CANT_READ 10342 -#define ER_TABLE_INCOMPATIBLE_DECIMAL_FIELD 10343 -#define ER_TABLE_INCOMPATIBLE_YEAR_FIELD 10344 -#define ER_INVALID_CHARSET_AND_DEFAULT_IS_MB 10345 -#define ER_TABLE_WRONG_KEY_DEFINITION 10346 -#define ER_CANT_OPEN_FRM_FILE 10347 -#define ER_CANT_READ_FRM_FILE 10348 -#define ER_TABLE_CREATED_WITH_DIFFERENT_VERSION 10349 -#define ER_VIEW_UNPARSABLE 10350 -#define ER_FILE_TYPE_UNKNOWN 10351 -#define ER_INVALID_INFO_IN_FRM 10352 -#define ER_CANT_OPEN_AND_LOCK_PRIVILEGE_TABLES 10353 -#define ER_AUDIT_PLUGIN_DOES_NOT_SUPPORT_AUDIT_AUTH_EVENTS 10354 -#define ER_AUDIT_PLUGIN_HAS_INVALID_DATA 10355 -#define ER_TZ_OOM_INITIALIZING_TIME_ZONES 10356 -#define ER_TZ_CANT_OPEN_AND_LOCK_TIME_ZONE_TABLE 10357 -#define ER_TZ_OOM_LOADING_LEAP_SECOND_TABLE 10358 -#define ER_TZ_TOO_MANY_LEAPS_IN_LEAP_SECOND_TABLE 10359 -#define ER_TZ_ERROR_LOADING_LEAP_SECOND_TABLE 10360 -#define ER_TZ_UNKNOWN_OR_ILLEGAL_DEFAULT_TIME_ZONE 10361 -#define ER_TZ_CANT_FIND_DESCRIPTION_FOR_TIME_ZONE 10362 -#define ER_TZ_CANT_FIND_DESCRIPTION_FOR_TIME_ZONE_ID 10363 -#define ER_TZ_TRANSITION_TYPE_TABLE_TYPE_TOO_LARGE 10364 -#define ER_TZ_TRANSITION_TYPE_TABLE_ABBREVIATIONS_EXCEED_SPACE 10365 -#define ER_TZ_TRANSITION_TYPE_TABLE_LOAD_ERROR 10366 -#define ER_TZ_TRANSITION_TABLE_TOO_MANY_TRANSITIONS 10367 -#define ER_TZ_TRANSITION_TABLE_BAD_TRANSITION_TYPE 10368 -#define ER_TZ_TRANSITION_TABLE_LOAD_ERROR 10369 -#define ER_TZ_NO_TRANSITION_TYPES_IN_TIME_ZONE 10370 -#define ER_TZ_OOM_LOADING_TIME_ZONE_DESCRIPTION 10371 -#define ER_TZ_CANT_BUILD_MKTIME_MAP 10372 -#define ER_TZ_OOM_WHILE_LOADING_TIME_ZONE 10373 -#define ER_TZ_OOM_WHILE_SETTING_TIME_ZONE 10374 -#define ER_SLAVE_SQL_THREAD_STOPPED_UNTIL_CONDITION_BAD 10375 -#define ER_SLAVE_SQL_THREAD_STOPPED_UNTIL_POSITION_REACHED 10376 -#define ER_SLAVE_SQL_THREAD_STOPPED_BEFORE_GTIDS_ALREADY_APPLIED 10377 -#define ER_SLAVE_SQL_THREAD_STOPPED_BEFORE_GTIDS_REACHED 10378 -#define ER_SLAVE_SQL_THREAD_STOPPED_AFTER_GTIDS_REACHED 10379 -#define ER_SLAVE_SQL_THREAD_STOPPED_GAP_TRX_PROCESSED 10380 -#define ER_GROUP_REPLICATION_PLUGIN_NOT_INSTALLED 10381 -#define ER_GTID_ALREADY_ADDED_BY_USER 10382 -#define ER_FAILED_TO_DELETE_FROM_GTID_EXECUTED_TABLE 10383 -#define ER_FAILED_TO_COMPRESS_GTID_EXECUTED_TABLE 10384 -#define ER_FAILED_TO_COMPRESS_GTID_EXECUTED_TABLE_OOM 10385 -#define ER_FAILED_TO_INIT_THREAD_ATTR_FOR_GTID_TABLE_COMPRESSION 10386 -#define ER_FAILED_TO_CREATE_GTID_TABLE_COMPRESSION_THREAD 10387 -#define ER_FAILED_TO_JOIN_GTID_TABLE_COMPRESSION_THREAD 10388 -#define ER_NPIPE_FAILED_TO_INIT_SECURITY_DESCRIPTOR 10389 -#define ER_NPIPE_FAILED_TO_SET_SECURITY_DESCRIPTOR 10390 -#define ER_NPIPE_PIPE_ALREADY_IN_USE 10391 -//#define OBSOLETE_ER_NDB_SLAVE_SAW_EPOCH_LOWER_THAN_PREVIOUS_ON_START 10392 -//#define OBSOLETE_ER_NDB_SLAVE_SAW_EPOCH_LOWER_THAN_PREVIOUS 10393 -//#define OBSOLETE_ER_NDB_SLAVE_SAW_ALREADY_COMMITTED_EPOCH 10394 -//#define OBSOLETE_ER_NDB_SLAVE_PREVIOUS_EPOCH_NOT_COMMITTED 10395 -//#define OBSOLETE_ER_NDB_SLAVE_MISSING_DATA_FOR_TIMESTAMP_COLUMN 10396 -//#define OBSOLETE_ER_NDB_SLAVE_LOGGING_EXCEPTIONS_TO 10397 -//#define OBSOLETE_ER_NDB_SLAVE_LOW_EPOCH_RESOLUTION 10398 -//#define OBSOLETE_ER_NDB_INFO_FOUND_UNEXPECTED_FIELD_TYPE 10399 -//#define OBSOLETE_ER_NDB_INFO_FAILED_TO_CREATE_NDBINFO 10400 -//#define OBSOLETE_ER_NDB_INFO_FAILED_TO_INIT_NDBINFO 10401 -//#define OBSOLETE_ER_NDB_CLUSTER_WRONG_NUMBER_OF_FUNCTION_ARGUMENTS 10402 -//#define OBSOLETE_ER_NDB_CLUSTER_SCHEMA_INFO 10403 -//#define OBSOLETE_ER_NDB_CLUSTER_GENERIC_MESSAGE 10404 -#define ER_RPL_CANT_OPEN_INFO_TABLE 10405 -#define ER_RPL_CANT_SCAN_INFO_TABLE 10406 -#define ER_RPL_CORRUPTED_INFO_TABLE 10407 -#define ER_RPL_CORRUPTED_KEYS_IN_INFO_TABLE 10408 -#define ER_RPL_WORKER_ID_IS 10409 -#define ER_RPL_INCONSISTENT_TIMESTAMPS_IN_TRX 10410 -#define ER_RPL_INCONSISTENT_SEQUENCE_NO_IN_TRX 10411 -#define ER_RPL_CHANNELS_REQUIRE_TABLES_AS_INFO_REPOSITORIES 10412 -#define ER_RPL_CHANNELS_REQUIRE_NON_ZERO_SERVER_ID 10413 -#define ER_RPL_REPO_SHOULD_BE_TABLE 10414 -#define ER_RPL_ERROR_CREATING_MASTER_INFO 10415 -#define ER_RPL_ERROR_CHANGING_MASTER_INFO_REPO_TYPE 10416 -#define ER_RPL_CHANGING_RELAY_LOG_INFO_REPO_TYPE_FAILED_DUE_TO_GAPS 10417 -#define ER_RPL_ERROR_CREATING_RELAY_LOG_INFO 10418 -#define ER_RPL_ERROR_CHANGING_RELAY_LOG_INFO_REPO_TYPE 10419 -#define ER_RPL_FAILED_TO_DELETE_FROM_SLAVE_WORKERS_INFO_REPOSITORY 10420 -#define ER_RPL_FAILED_TO_RESET_STATE_IN_SLAVE_INFO_REPOSITORY 10421 -#define ER_RPL_ERROR_CHECKING_REPOSITORY 10422 -#define ER_RPL_SLAVE_GENERIC_MESSAGE 10423 -#define ER_RPL_SLAVE_COULD_NOT_CREATE_CHANNEL_LIST 10424 -#define ER_RPL_MULTISOURCE_REQUIRES_TABLE_TYPE_REPOSITORIES 10425 -#define ER_RPL_SLAVE_FAILED_TO_INIT_A_MASTER_INFO_STRUCTURE 10426 -#define ER_RPL_SLAVE_FAILED_TO_INIT_MASTER_INFO_STRUCTURE 10427 -#define ER_RPL_SLAVE_FAILED_TO_CREATE_CHANNEL_FROM_MASTER_INFO 10428 -#define ER_RPL_FAILED_TO_CREATE_NEW_INFO_FILE 10429 -#define ER_RPL_FAILED_TO_CREATE_CACHE_FOR_INFO_FILE 10430 -#define ER_RPL_FAILED_TO_OPEN_INFO_FILE 10431 -#define ER_RPL_GTID_MEMORY_FINALLY_AVAILABLE 10432 -#define ER_SERVER_COST_UNKNOWN_COST_CONSTANT 10433 -#define ER_SERVER_COST_INVALID_COST_CONSTANT 10434 -#define ER_ENGINE_COST_UNKNOWN_COST_CONSTANT 10435 -#define ER_ENGINE_COST_UNKNOWN_STORAGE_ENGINE 10436 -#define ER_ENGINE_COST_INVALID_DEVICE_TYPE_FOR_SE 10437 -#define ER_ENGINE_COST_INVALID_CONST_CONSTANT_FOR_SE_AND_DEVICE 10438 -#define ER_SERVER_COST_FAILED_TO_READ 10439 -#define ER_ENGINE_COST_FAILED_TO_READ 10440 -#define ER_FAILED_TO_OPEN_COST_CONSTANT_TABLES 10441 -#define ER_RPL_UNSUPPORTED_UNIGNORABLE_EVENT_IN_STREAM 10442 -#define ER_RPL_GTID_LOG_EVENT_IN_STREAM 10443 -#define ER_RPL_UNEXPECTED_BEGIN_IN_STREAM 10444 -#define ER_RPL_UNEXPECTED_COMMIT_ROLLBACK_OR_XID_LOG_EVENT_IN_STREAM 10445 -#define ER_RPL_UNEXPECTED_XA_ROLLBACK_IN_STREAM 10446 -#define ER_EVENT_EXECUTION_FAILED_CANT_AUTHENTICATE_USER 10447 -#define ER_EVENT_EXECUTION_FAILED_USER_LOST_EVEN_PRIVILEGE 10448 -#define ER_EVENT_ERROR_DURING_COMPILATION 10449 -#define ER_EVENT_DROPPING 10450 -//#define OBSOLETE_ER_NDB_SCHEMA_GENERIC_MESSAGE 10451 -#define ER_RPL_INCOMPATIBLE_DECIMAL_IN_RBR 10452 -#define ER_INIT_ROOT_WITHOUT_PASSWORD 10453 -#define ER_INIT_GENERATING_TEMP_PASSWORD_FOR_ROOT 10454 -#define ER_INIT_CANT_OPEN_BOOTSTRAP_FILE 10455 -#define ER_INIT_BOOTSTRAP_COMPLETE 10456 -#define ER_INIT_DATADIR_NOT_EMPTY_WONT_INITIALIZE 10457 -#define ER_INIT_DATADIR_EXISTS_WONT_INITIALIZE 10458 -#define ER_INIT_DATADIR_EXISTS_AND_PATH_TOO_LONG_WONT_INITIALIZE 10459 -#define ER_INIT_DATADIR_EXISTS_AND_NOT_WRITABLE_WONT_INITIALIZE 10460 -#define ER_INIT_CREATING_DD 10461 -#define ER_RPL_BINLOG_STARTING_DUMP 10462 -#define ER_RPL_BINLOG_MASTER_SENDS_HEARTBEAT 10463 -#define ER_RPL_BINLOG_SKIPPING_REMAINING_HEARTBEAT_INFO 10464 -#define ER_RPL_BINLOG_MASTER_USES_CHECKSUM_AND_SLAVE_CANT 10465 -//#define OBSOLETE_ER_NDB_QUERY_FAILED 10466 -#define ER_KILLING_THREAD 10467 -#define ER_DETACHING_SESSION_LEFT_BY_PLUGIN 10468 -#define ER_CANT_DETACH_SESSION_LEFT_BY_PLUGIN 10469 -#define ER_DETACHED_SESSIONS_LEFT_BY_PLUGIN 10470 -#define ER_FAILED_TO_DECREMENT_NUMBER_OF_THREADS 10471 -#define ER_PLUGIN_DID_NOT_DEINITIALIZE_THREADS 10472 -#define ER_KILLED_THREADS_OF_PLUGIN 10473 -//#define OBSOLETE_ER_NDB_SLAVE_MAX_REPLICATED_EPOCH_UNKNOWN 10474 -//#define OBSOLETE_ER_NDB_SLAVE_MAX_REPLICATED_EPOCH_SET_TO 10475 -//#define OBSOLETE_ER_NDB_NODE_ID_AND_MANAGEMENT_SERVER_INFO 10476 -//#define OBSOLETE_ER_NDB_DISCONNECT_INFO 10477 -//#define OBSOLETE_ER_NDB_COLUMN_DEFAULTS_DIFFER 10478 -//#define OBSOLETE_ER_NDB_COLUMN_SHOULD_NOT_HAVE_NATIVE_DEFAULT 10479 -//#define OBSOLETE_ER_NDB_FIELD_INFO 10480 -//#define OBSOLETE_ER_NDB_COLUMN_INFO 10481 -//#define OBSOLETE_ER_NDB_OOM_IN_FIX_UNIQUE_INDEX_ATTR_ORDER 10482 -//#define OBSOLETE_ER_NDB_SLAVE_MALFORMED_EVENT_RECEIVED_ON_TABLE 10483 -//#define OBSOLETE_ER_NDB_SLAVE_CONFLICT_FUNCTION_REQUIRES_ROLE 10484 -//#define OBSOLETE_ER_NDB_SLAVE_CONFLICT_TRANSACTION_IDS 10485 -//#define OBSOLETE_ER_NDB_SLAVE_BINLOG_MISSING_INFO_FOR_CONFLICT_DETECTION 10486 -//#define OBSOLETE_ER_NDB_ERROR_IN_READAUTOINCREMENTVALUE 10487 -//#define OBSOLETE_ER_NDB_FOUND_UNCOMMITTED_AUTOCOMMIT 10488 -//#define OBSOLETE_ER_NDB_SLAVE_TOO_MANY_RETRIES 10489 -//#define OBSOLETE_ER_NDB_SLAVE_ERROR_IN_UPDATE_CREATE_INFO 10490 -//#define OBSOLETE_ER_NDB_SLAVE_CANT_ALLOCATE_TABLE_SHARE 10491 -//#define OBSOLETE_ER_NDB_BINLOG_ERROR_INFO_FROM_DA 10492 -//#define OBSOLETE_ER_NDB_BINLOG_CREATE_TABLE_EVENT 10493 -//#define OBSOLETE_ER_NDB_BINLOG_FAILED_CREATE_TABLE_EVENT_OPERATIONS 10494 -//#define OBSOLETE_ER_NDB_BINLOG_RENAME_EVENT 10495 -//#define OBSOLETE_ER_NDB_BINLOG_FAILED_CREATE_DURING_RENAME 10496 -//#define OBSOLETE_ER_NDB_UNEXPECTED_RENAME_TYPE 10497 -//#define OBSOLETE_ER_NDB_ERROR_IN_GET_AUTO_INCREMENT 10498 -//#define OBSOLETE_ER_NDB_CREATING_SHARE_IN_OPEN 10499 -//#define OBSOLETE_ER_NDB_TABLE_OPENED_READ_ONLY 10500 -//#define OBSOLETE_ER_NDB_INITIALIZE_GIVEN_CLUSTER_PLUGIN_DISABLED 10501 -//#define OBSOLETE_ER_NDB_BINLOG_FORMAT_CHANGED_FROM_STMT_TO_MIXED 10502 -//#define OBSOLETE_ER_NDB_TRAILING_SHARE_RELEASED_BY_CLOSE_CACHED_TABLES 10503 -//#define OBSOLETE_ER_NDB_SHARE_ALREADY_EXISTS 10504 -//#define OBSOLETE_ER_NDB_HANDLE_TRAILING_SHARE_INFO 10505 -//#define OBSOLETE_ER_NDB_CLUSTER_GET_SHARE_INFO 10506 -//#define OBSOLETE_ER_NDB_CLUSTER_REAL_FREE_SHARE_INFO 10507 -//#define OBSOLETE_ER_NDB_CLUSTER_REAL_FREE_SHARE_DROP_FAILED 10508 -//#define OBSOLETE_ER_NDB_CLUSTER_FREE_SHARE_INFO 10509 -//#define OBSOLETE_ER_NDB_CLUSTER_MARK_SHARE_DROPPED_INFO 10510 -//#define OBSOLETE_ER_NDB_CLUSTER_MARK_SHARE_DROPPED_DESTROYING_SHARE 10511 -//#define OBSOLETE_ER_NDB_CLUSTER_OOM_THD_NDB 10512 -//#define OBSOLETE_ER_NDB_BINLOG_NDB_TABLES_INITIALLY_READ_ONLY 10513 -//#define OBSOLETE_ER_NDB_UTIL_THREAD_OOM 10514 -//#define OBSOLETE_ER_NDB_ILLEGAL_VALUE_FOR_NDB_RECV_THREAD_CPU_MASK 10515 -//#define OBSOLETE_ER_NDB_TOO_MANY_CPUS_IN_NDB_RECV_THREAD_CPU_MASK 10516 -#define ER_DBUG_CHECK_SHARES_OPEN 10517 -#define ER_DBUG_CHECK_SHARES_INFO 10518 -#define ER_DBUG_CHECK_SHARES_DROPPED 10519 -#define ER_INVALID_OR_OLD_TABLE_OR_DB_NAME 10520 -#define ER_TC_RECOVERING_AFTER_CRASH_USING 10521 -#define ER_TC_CANT_AUTO_RECOVER_WITH_TC_HEURISTIC_RECOVER 10522 -#define ER_TC_BAD_MAGIC_IN_TC_LOG 10523 -#define ER_TC_NEED_N_SE_SUPPORTING_2PC_FOR_RECOVERY 10524 -#define ER_TC_RECOVERY_FAILED_THESE_ARE_YOUR_OPTIONS 10525 -#define ER_TC_HEURISTIC_RECOVERY_MODE 10526 -#define ER_TC_HEURISTIC_RECOVERY_FAILED 10527 -#define ER_TC_RESTART_WITHOUT_TC_HEURISTIC_RECOVER 10528 -#define ER_RPL_SLAVE_FAILED_TO_CREATE_OR_RECOVER_INFO_REPOSITORIES 10529 -#define ER_RPL_SLAVE_AUTO_POSITION_IS_1_AND_GTID_MODE_IS_OFF 10530 -#define ER_RPL_SLAVE_CANT_START_SLAVE_FOR_CHANNEL 10531 -#define ER_RPL_SLAVE_CANT_STOP_SLAVE_FOR_CHANNEL 10532 -#define ER_RPL_RECOVERY_NO_ROTATE_EVENT_FROM_MASTER 10533 -#define ER_RPL_RECOVERY_ERROR_READ_RELAY_LOG 10534 -//#define OBSOLETE_ER_RPL_RECOVERY_ERROR_FREEING_IO_CACHE 10535 -#define ER_RPL_RECOVERY_SKIPPED_GROUP_REPLICATION_CHANNEL 10536 -#define ER_RPL_RECOVERY_ERROR 10537 -#define ER_RPL_RECOVERY_IO_ERROR_READING_RELAY_LOG_INDEX 10538 -#define ER_RPL_RECOVERY_FILE_MASTER_POS_INFO 10539 -#define ER_RPL_RECOVERY_REPLICATE_SAME_SERVER_ID_REQUIRES_POSITION 10540 -#define ER_RPL_MTS_RECOVERY_STARTING_COORDINATOR 10541 -#define ER_RPL_MTS_RECOVERY_FAILED_TO_START_COORDINATOR 10542 -#define ER_RPL_MTS_AUTOMATIC_RECOVERY_FAILED 10543 -#define ER_RPL_MTS_RECOVERY_CANT_OPEN_RELAY_LOG 10544 -#define ER_RPL_MTS_RECOVERY_SUCCESSFUL 10545 -#define ER_RPL_SERVER_ID_MISSING 10546 -#define ER_RPL_CANT_CREATE_SLAVE_THREAD 10547 -#define ER_RPL_SLAVE_IO_THREAD_WAS_KILLED 10548 -#define ER_RPL_SLAVE_MASTER_UUID_HAS_CHANGED 10549 -#define ER_RPL_SLAVE_USES_CHECKSUM_AND_MASTER_PRE_50 10550 -#define ER_RPL_SLAVE_SECONDS_BEHIND_MASTER_DUBIOUS 10551 -#define ER_RPL_SLAVE_CANT_FLUSH_MASTER_INFO_FILE 10552 -#define ER_RPL_SLAVE_REPORT_HOST_TOO_LONG 10553 -#define ER_RPL_SLAVE_REPORT_USER_TOO_LONG 10554 -#define ER_RPL_SLAVE_REPORT_PASSWORD_TOO_LONG 10555 -#define ER_RPL_SLAVE_ERROR_RETRYING 10556 -#define ER_RPL_SLAVE_ERROR_READING_FROM_SERVER 10557 -#define ER_RPL_SLAVE_DUMP_THREAD_KILLED_BY_MASTER 10558 -#define ER_RPL_MTS_STATISTICS 10559 -#define ER_RPL_MTS_RECOVERY_COMPLETE 10560 -#define ER_RPL_SLAVE_CANT_INIT_RELAY_LOG_POSITION 10561 -#define ER_RPL_SLAVE_CONNECTED_TO_MASTER_REPLICATION_STARTED 10562 -#define ER_RPL_SLAVE_IO_THREAD_KILLED 10563 -#define ER_RPL_SLAVE_IO_THREAD_CANT_REGISTER_ON_MASTER 10564 -#define ER_RPL_SLAVE_FORCING_TO_RECONNECT_IO_THREAD 10565 -#define ER_RPL_SLAVE_ERROR_REQUESTING_BINLOG_DUMP 10566 -#define ER_RPL_LOG_ENTRY_EXCEEDS_SLAVE_MAX_ALLOWED_PACKET 10567 -#define ER_RPL_SLAVE_STOPPING_AS_MASTER_OOM 10568 -#define ER_RPL_SLAVE_IO_THREAD_ABORTED_WAITING_FOR_RELAY_LOG_SPACE 10569 -#define ER_RPL_SLAVE_IO_THREAD_EXITING 10570 -#define ER_RPL_SLAVE_CANT_INITIALIZE_SLAVE_WORKER 10571 -#define ER_RPL_MTS_GROUP_RECOVERY_RELAY_LOG_INFO_FOR_WORKER 10572 -#define ER_RPL_ERROR_LOOKING_FOR_LOG 10573 -#define ER_RPL_MTS_GROUP_RECOVERY_RELAY_LOG_INFO 10574 -#define ER_RPL_CANT_FIND_FOLLOWUP_FILE 10575 -#define ER_RPL_MTS_CHECKPOINT_PERIOD_DIFFERS_FROM_CNT 10576 -#define ER_RPL_SLAVE_WORKER_THREAD_CREATION_FAILED 10577 -#define ER_RPL_SLAVE_WORKER_THREAD_CREATION_FAILED_WITH_ERRNO 10578 -#define ER_RPL_SLAVE_FAILED_TO_INIT_PARTITIONS_HASH 10579 -//#define OBSOLETE_ER_RPL_SLAVE_NDB_TABLES_NOT_AVAILABLE 10580 -#define ER_RPL_SLAVE_SQL_THREAD_STARTING 10581 -#define ER_RPL_SLAVE_SKIP_COUNTER_EXECUTED 10582 -#define ER_RPL_SLAVE_ADDITIONAL_ERROR_INFO_FROM_DA 10583 -#define ER_RPL_SLAVE_ERROR_INFO_FROM_DA 10584 -#define ER_RPL_SLAVE_ERROR_LOADING_USER_DEFINED_LIBRARY 10585 -#define ER_RPL_SLAVE_ERROR_RUNNING_QUERY 10586 -#define ER_RPL_SLAVE_SQL_THREAD_EXITING 10587 -#define ER_RPL_SLAVE_READ_INVALID_EVENT_FROM_MASTER 10588 -#define ER_RPL_SLAVE_QUEUE_EVENT_FAILED_INVALID_CONFIGURATION 10589 -#define ER_RPL_SLAVE_IO_THREAD_DETECTED_UNEXPECTED_EVENT_SEQUENCE 10590 -#define ER_RPL_SLAVE_CANT_USE_CHARSET 10591 -#define ER_RPL_SLAVE_CONNECTED_TO_MASTER_REPLICATION_RESUMED 10592 -#define ER_RPL_SLAVE_NEXT_LOG_IS_ACTIVE 10593 -#define ER_RPL_SLAVE_NEXT_LOG_IS_INACTIVE 10594 -#define ER_RPL_SLAVE_SQL_THREAD_IO_ERROR_READING_EVENT 10595 -#define ER_RPL_SLAVE_ERROR_READING_RELAY_LOG_EVENTS 10596 -#define ER_SLAVE_CHANGE_MASTER_TO_EXECUTED 10597 -#define ER_RPL_SLAVE_NEW_MASTER_INFO_NEEDS_REPOS_TYPE_OTHER_THAN_FILE 10598 -#define ER_RPL_FAILED_TO_STAT_LOG_IN_INDEX 10599 -#define ER_RPL_LOG_NOT_FOUND_WHILE_COUNTING_RELAY_LOG_SPACE 10600 -#define ER_SLAVE_CANT_USE_TEMPDIR 10601 -#define ER_RPL_RELAY_LOG_NEEDS_FILE_NOT_DIRECTORY 10602 -#define ER_RPL_RELAY_LOG_INDEX_NEEDS_FILE_NOT_DIRECTORY 10603 -#define ER_RPL_PLEASE_USE_OPTION_RELAY_LOG 10604 -#define ER_RPL_OPEN_INDEX_FILE_FAILED 10605 -#define ER_RPL_CANT_INITIALIZE_GTID_SETS_IN_RLI_INIT_INFO 10606 -#define ER_RPL_CANT_OPEN_LOG_IN_RLI_INIT_INFO 10607 -#define ER_RPL_ERROR_WRITING_RELAY_LOG_CONFIGURATION 10608 -//#define OBSOLETE_ER_NDB_OOM_GET_NDB_BLOBS_VALUE 10609 -//#define OBSOLETE_ER_NDB_THREAD_TIMED_OUT 10610 -//#define OBSOLETE_ER_NDB_TABLE_IS_NOT_DISTRIBUTED 10611 -//#define OBSOLETE_ER_NDB_CREATING_TABLE 10612 -//#define OBSOLETE_ER_NDB_FLUSHING_TABLE_INFO 10613 -//#define OBSOLETE_ER_NDB_CLEANING_STRAY_TABLES 10614 -//#define OBSOLETE_ER_NDB_DISCOVERED_MISSING_DB 10615 -//#define OBSOLETE_ER_NDB_DISCOVERED_REMAINING_DB 10616 -//#define OBSOLETE_ER_NDB_CLUSTER_FIND_ALL_DBS_RETRY 10617 -//#define OBSOLETE_ER_NDB_CLUSTER_FIND_ALL_DBS_FAIL 10618 -//#define OBSOLETE_ER_NDB_SKIPPING_SETUP_TABLE 10619 -//#define OBSOLETE_ER_NDB_FAILED_TO_SET_UP_TABLE 10620 -//#define OBSOLETE_ER_NDB_MISSING_FRM_DISCOVERING 10621 -//#define OBSOLETE_ER_NDB_MISMATCH_IN_FRM_DISCOVERING 10622 -//#define OBSOLETE_ER_NDB_BINLOG_CLEANING_UP_SETUP_LEFTOVERS 10623 -//#define OBSOLETE_ER_NDB_WAITING_INFO 10624 -//#define OBSOLETE_ER_NDB_WAITING_INFO_WITH_MAP 10625 -//#define OBSOLETE_ER_NDB_TIMEOUT_WHILE_DISTRIBUTING 10626 -//#define OBSOLETE_ER_NDB_NOT_WAITING_FOR_DISTRIBUTING 10627 -//#define OBSOLETE_ER_NDB_DISTRIBUTED_INFO 10628 -//#define OBSOLETE_ER_NDB_DISTRIBUTION_COMPLETE 10629 -//#define OBSOLETE_ER_NDB_SCHEMA_DISTRIBUTION_FAILED 10630 -//#define OBSOLETE_ER_NDB_SCHEMA_DISTRIBUTION_REPORTS_SUBSCRIBE 10631 -//#define OBSOLETE_ER_NDB_SCHEMA_DISTRIBUTION_REPORTS_UNSUBSCRIBE 10632 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_DISCOVER_TABLE_FROM_SCHEMA_EVENT 10633 -//#define OBSOLETE_ER_NDB_BINLOG_SIGNALLING_UNKNOWN_VALUE 10634 -//#define OBSOLETE_ER_NDB_BINLOG_REPLY_TO 10635 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_RELEASE_SLOCK 10636 -//#define OBSOLETE_ER_NDB_CANT_FIND_TABLE 10637 -//#define OBSOLETE_ER_NDB_DISCARDING_EVENT_NO_OBJ 10638 -//#define OBSOLETE_ER_NDB_DISCARDING_EVENT_ID_VERSION_MISMATCH 10639 -//#define OBSOLETE_ER_NDB_CLEAR_SLOCK_INFO 10640 -//#define OBSOLETE_ER_NDB_BINLOG_SKIPPING_LOCAL_TABLE 10641 -//#define OBSOLETE_ER_NDB_BINLOG_ONLINE_ALTER_RENAME 10642 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_REOPEN_SHADOW_TABLE 10643 -//#define OBSOLETE_ER_NDB_BINLOG_ONLINE_ALTER_RENAME_COMPLETE 10644 -//#define OBSOLETE_ER_NDB_BINLOG_SKIPPING_DROP_OF_LOCAL_TABLE 10645 -//#define OBSOLETE_ER_NDB_BINLOG_SKIPPING_RENAME_OF_LOCAL_TABLE 10646 -//#define OBSOLETE_ER_NDB_BINLOG_SKIPPING_DROP_OF_TABLES 10647 -//#define OBSOLETE_ER_NDB_BINLOG_GOT_DIST_PRIV_EVENT_FLUSHING_PRIVILEGES 10648 -//#define OBSOLETE_ER_NDB_BINLOG_GOT_SCHEMA_EVENT 10649 -//#define OBSOLETE_ER_NDB_BINLOG_SKIPPING_OLD_SCHEMA_OPERATION 10650 -//#define OBSOLETE_ER_NDB_CLUSTER_FAILURE 10651 -//#define OBSOLETE_ER_NDB_TABLES_INITIALLY_READ_ONLY_ON_RECONNECT 10652 -//#define OBSOLETE_ER_NDB_IGNORING_UNKNOWN_EVENT 10653 -//#define OBSOLETE_ER_NDB_BINLOG_OPENING_INDEX 10654 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_LOCK_NDB_BINLOG_INDEX 10655 -//#define OBSOLETE_ER_NDB_BINLOG_INJECTING_RANDOM_WRITE_FAILURE 10656 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_WRITE_TO_NDB_BINLOG_INDEX 10657 -//#define OBSOLETE_ER_NDB_BINLOG_WRITING_TO_NDB_BINLOG_INDEX 10658 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_COMMIT_TO_NDB_BINLOG_INDEX 10659 -//#define OBSOLETE_ER_NDB_BINLOG_WRITE_INDEX_FAILED_AFTER_KILL 10660 -//#define OBSOLETE_ER_NDB_BINLOG_USING_SERVER_ID_0_SLAVES_WILL_NOT 10661 -//#define OBSOLETE_ER_NDB_SERVER_ID_RESERVED_OR_TOO_LARGE 10662 -//#define OBSOLETE_ER_NDB_BINLOG_REQUIRES_V2_ROW_EVENTS 10663 -//#define OBSOLETE_ER_NDB_BINLOG_STATUS_FORCING_FULL_USE_WRITE 10664 -//#define OBSOLETE_ER_NDB_BINLOG_GENERIC_MESSAGE 10665 -//#define OBSOLETE_ER_NDB_CONFLICT_GENERIC_MESSAGE 10666 -//#define OBSOLETE_ER_NDB_TRANS_DEPENDENCY_TRACKER_ERROR 10667 -//#define OBSOLETE_ER_NDB_CONFLICT_FN_PARSE_ERROR 10668 -//#define OBSOLETE_ER_NDB_CONFLICT_FN_SETUP_ERROR 10669 -//#define OBSOLETE_ER_NDB_BINLOG_FAILED_TO_GET_TABLE 10670 -//#define OBSOLETE_ER_NDB_BINLOG_NOT_LOGGING 10671 -//#define OBSOLETE_ER_NDB_BINLOG_CREATE_TABLE_EVENT_FAILED 10672 -//#define OBSOLETE_ER_NDB_BINLOG_CREATE_TABLE_EVENT_INFO 10673 -//#define OBSOLETE_ER_NDB_BINLOG_DISCOVER_TABLE_EVENT_INFO 10674 -//#define OBSOLETE_ER_NDB_BINLOG_BLOB_REQUIRES_PK 10675 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_CREATE_EVENT_IN_DB 10676 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_CREATE_EVENT_IN_DB_AND_CANT_DROP 10677 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_CREATE_EVENT_IN_DB_DROPPED 10678 -//#define OBSOLETE_ER_NDB_BINLOG_DISCOVER_REUSING_OLD_EVENT_OPS 10679 -//#define OBSOLETE_ER_NDB_BINLOG_CREATING_NDBEVENTOPERATION_FAILED 10680 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_CREATE_BLOB 10681 -//#define OBSOLETE_ER_NDB_BINLOG_NDBEVENT_EXECUTE_FAILED 10682 -//#define OBSOLETE_ER_NDB_CREATE_EVENT_OPS_LOGGING_INFO 10683 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_DROP_EVENT_FROM_DB 10684 -//#define OBSOLETE_ER_NDB_TIMED_OUT_IN_DROP_TABLE 10685 -//#define OBSOLETE_ER_NDB_BINLOG_UNHANDLED_ERROR_FOR_TABLE 10686 -//#define OBSOLETE_ER_NDB_BINLOG_CLUSTER_FAILURE 10687 -//#define OBSOLETE_ER_NDB_BINLOG_UNKNOWN_NON_DATA_EVENT 10688 -//#define OBSOLETE_ER_NDB_BINLOG_INJECTOR_DISCARDING_ROW_EVENT_METADATA 10689 -//#define OBSOLETE_ER_NDB_REMAINING_OPEN_TABLES 10690 -//#define OBSOLETE_ER_NDB_REMAINING_OPEN_TABLE_INFO 10691 -//#define OBSOLETE_ER_NDB_COULD_NOT_GET_APPLY_STATUS_SHARE 10692 -//#define OBSOLETE_ER_NDB_BINLOG_SERVER_SHUTDOWN_DURING_NDB_CLUSTER_START 10693 -//#define OBSOLETE_ER_NDB_BINLOG_CLUSTER_RESTARTED_RESET_MASTER_SUGGESTED 10694 -//#define OBSOLETE_ER_NDB_BINLOG_CLUSTER_HAS_RECONNECTED 10695 -//#define OBSOLETE_ER_NDB_BINLOG_STARTING_LOG_AT_EPOCH 10696 -//#define OBSOLETE_ER_NDB_BINLOG_NDB_TABLES_WRITABLE 10697 -//#define OBSOLETE_ER_NDB_BINLOG_SHUTDOWN_DETECTED 10698 -//#define OBSOLETE_ER_NDB_BINLOG_LOST_SCHEMA_CONNECTION_WAITING 10699 -//#define OBSOLETE_ER_NDB_BINLOG_LOST_SCHEMA_CONNECTION_CONTINUING 10700 -//#define OBSOLETE_ER_NDB_BINLOG_ERROR_HANDLING_SCHEMA_EVENT 10701 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_INJECT_APPLY_STATUS_WRITE_ROW 10702 -//#define OBSOLETE_ER_NDB_BINLOG_ERROR_DURING_GCI_ROLLBACK 10703 -//#define OBSOLETE_ER_NDB_BINLOG_ERROR_DURING_GCI_COMMIT 10704 -//#define OBSOLETE_ER_NDB_BINLOG_LATEST_TRX_IN_EPOCH_NOT_IN_BINLOG 10705 -//#define OBSOLETE_ER_NDB_BINLOG_RELEASING_EXTRA_SHARE_REFERENCES 10706 -//#define OBSOLETE_ER_NDB_BINLOG_REMAINING_OPEN_TABLES 10707 -//#define OBSOLETE_ER_NDB_BINLOG_REMAINING_OPEN_TABLE_INFO 10708 -#define ER_TREE_CORRUPT_PARENT_SHOULD_POINT_AT_PARENT 10709 -#define ER_TREE_CORRUPT_ROOT_SHOULD_BE_BLACK 10710 -#define ER_TREE_CORRUPT_2_CONSECUTIVE_REDS 10711 -#define ER_TREE_CORRUPT_RIGHT_IS_LEFT 10712 -#define ER_TREE_CORRUPT_INCORRECT_BLACK_COUNT 10713 -#define ER_WRONG_COUNT_FOR_ORIGIN 10714 -#define ER_WRONG_COUNT_FOR_KEY 10715 -#define ER_WRONG_COUNT_OF_ELEMENTS 10716 -#define ER_RPL_ERROR_READING_SLAVE_WORKER_CONFIGURATION 10717 -#define ER_RPL_ERROR_WRITING_SLAVE_WORKER_CONFIGURATION 10718 -#define ER_RPL_FAILED_TO_OPEN_RELAY_LOG 10719 -#define ER_RPL_WORKER_CANT_READ_RELAY_LOG 10720 -#define ER_RPL_WORKER_CANT_FIND_NEXT_RELAY_LOG 10721 -#define ER_RPL_MTS_SLAVE_COORDINATOR_HAS_WAITED 10722 -#define ER_BINLOG_FAILED_TO_WRITE_DROP_FOR_TEMP_TABLES 10723 -#define ER_BINLOG_OOM_WRITING_DELETE_WHILE_OPENING_HEAP_TABLE 10724 -#define ER_FAILED_TO_REPAIR_TABLE 10725 -#define ER_FAILED_TO_REMOVE_TEMP_TABLE 10726 -#define ER_SYSTEM_TABLE_NOT_TRANSACTIONAL 10727 -#define ER_RPL_ERROR_WRITING_MASTER_CONFIGURATION 10728 -#define ER_RPL_ERROR_READING_MASTER_CONFIGURATION 10729 -#define ER_RPL_SSL_INFO_IN_MASTER_INFO_IGNORED 10730 -#define ER_PLUGIN_FAILED_DEINITIALIZATION 10731 -#define ER_PLUGIN_HAS_NONZERO_REFCOUNT_AFTER_DEINITIALIZATION 10732 -#define ER_PLUGIN_SHUTTING_DOWN_PLUGIN 10733 -#define ER_PLUGIN_REGISTRATION_FAILED 10734 -#define ER_PLUGIN_CANT_OPEN_PLUGIN_TABLE 10735 -#define ER_PLUGIN_CANT_LOAD 10736 -#define ER_PLUGIN_LOAD_PARAMETER_TOO_LONG 10737 -#define ER_PLUGIN_FORCING_SHUTDOWN 10738 -#define ER_PLUGIN_HAS_NONZERO_REFCOUNT_AFTER_SHUTDOWN 10739 -#define ER_PLUGIN_UNKNOWN_VARIABLE_TYPE 10740 -#define ER_PLUGIN_VARIABLE_SET_READ_ONLY 10741 -#define ER_PLUGIN_VARIABLE_MISSING_NAME 10742 -#define ER_PLUGIN_VARIABLE_NOT_ALLOCATED_THREAD_LOCAL 10743 -#define ER_PLUGIN_OOM 10744 -#define ER_PLUGIN_BAD_OPTIONS 10745 -#define ER_PLUGIN_PARSING_OPTIONS_FAILED 10746 -#define ER_PLUGIN_DISABLED 10747 -#define ER_PLUGIN_HAS_CONFLICTING_SYSTEM_VARIABLES 10748 -#define ER_PLUGIN_CANT_SET_PERSISTENT_OPTIONS 10749 -#define ER_MY_NET_WRITE_FAILED_FALLING_BACK_ON_STDERR 10750 -#define ER_RETRYING_REPAIR_WITHOUT_QUICK 10751 -#define ER_RETRYING_REPAIR_WITH_KEYCACHE 10752 -#define ER_FOUND_ROWS_WHILE_REPAIRING 10753 -#define ER_ERROR_DURING_OPTIMIZE_TABLE 10754 -#define ER_ERROR_ENABLING_KEYS 10755 -#define ER_CHECKING_TABLE 10756 -#define ER_RECOVERING_TABLE 10757 -#define ER_CANT_CREATE_TABLE_SHARE_FROM_FRM 10758 -#define ER_CANT_LOCK_TABLE 10759 -#define ER_CANT_ALLOC_TABLE_OBJECT 10760 -#define ER_CANT_CREATE_HANDLER_OBJECT_FOR_TABLE 10761 -#define ER_CANT_SET_HANDLER_REFERENCE_FOR_TABLE 10762 -#define ER_CANT_LOCK_TABLESPACE 10763 -#define ER_CANT_UPGRADE_GENERATED_COLUMNS_TO_DD 10764 -#define ER_DD_ERROR_CREATING_ENTRY 10765 -#define ER_DD_CANT_FETCH_TABLE_DATA 10766 -#define ER_DD_CANT_FIX_SE_DATA 10767 -#define ER_DD_CANT_CREATE_SP 10768 -#define ER_CANT_OPEN_DB_OPT_USING_DEFAULT_CHARSET 10769 -#define ER_CANT_CREATE_CACHE_FOR_DB_OPT 10770 -#define ER_CANT_IDENTIFY_CHARSET_USING_DEFAULT 10771 -#define ER_DB_OPT_NOT_FOUND_USING_DEFAULT_CHARSET 10772 -#define ER_EVENT_CANT_GET_TIMEZONE_FROM_FIELD 10773 -#define ER_EVENT_CANT_FIND_TIMEZONE 10774 -#define ER_EVENT_CANT_GET_CHARSET 10775 -#define ER_EVENT_CANT_GET_COLLATION 10776 -#define ER_EVENT_CANT_OPEN_TABLE_MYSQL_EVENT 10777 -#define ER_CANT_PARSE_STORED_ROUTINE_BODY 10778 -#define ER_CANT_OPEN_TABLE_MYSQL_PROC 10779 -#define ER_CANT_READ_TABLE_MYSQL_PROC 10780 -#define ER_FILE_EXISTS_DURING_UPGRADE 10781 -#define ER_CANT_OPEN_DATADIR_AFTER_UPGRADE_FAILURE 10782 -#define ER_CANT_SET_PATH_FOR 10783 -#define ER_CANT_OPEN_DIR 10784 -//#define OBSOLETE_ER_NDB_CLUSTER_CONNECTION_POOL_NODEIDS 10785 -//#define OBSOLETE_ER_NDB_CANT_PARSE_NDB_CLUSTER_CONNECTION_POOL_NODEIDS 10786 -//#define OBSOLETE_ER_NDB_INVALID_CLUSTER_CONNECTION_POOL_NODEIDS 10787 -//#define OBSOLETE_ER_NDB_DUPLICATE_CLUSTER_CONNECTION_POOL_NODEIDS 10788 -//#define OBSOLETE_ER_NDB_POOL_SIZE_CLUSTER_CONNECTION_POOL_NODEIDS 10789 -//#define OBSOLETE_ER_NDB_NODEID_NOT_FIRST_CONNECTION_POOL_NODEIDS 10790 -//#define OBSOLETE_ER_NDB_USING_NODEID 10791 -//#define OBSOLETE_ER_NDB_CANT_ALLOC_GLOBAL_NDB_CLUSTER_CONNECTION 10792 -//#define OBSOLETE_ER_NDB_CANT_ALLOC_GLOBAL_NDB_OBJECT 10793 -//#define OBSOLETE_ER_NDB_USING_NODEID_LIST 10794 -//#define OBSOLETE_ER_NDB_CANT_ALLOC_NDB_CLUSTER_CONNECTION 10795 -//#define OBSOLETE_ER_NDB_STARTING_CONNECT_THREAD 10796 -//#define OBSOLETE_ER_NDB_NODE_INFO 10797 -//#define OBSOLETE_ER_NDB_CANT_START_CONNECT_THREAD 10798 -//#define OBSOLETE_ER_NDB_GENERIC_ERROR 10799 -//#define OBSOLETE_ER_NDB_CPU_MASK_TOO_SHORT 10800 -#define ER_EVENT_ERROR_CREATING_QUERY_TO_WRITE_TO_BINLOG 10801 -#define ER_EVENT_SCHEDULER_ERROR_LOADING_FROM_DB 10802 -#define ER_EVENT_SCHEDULER_ERROR_GETTING_EVENT_OBJECT 10803 -#define ER_EVENT_SCHEDULER_GOT_BAD_DATA_FROM_TABLE 10804 -#define ER_EVENT_CANT_GET_LOCK_FOR_DROPPING_EVENT 10805 -#define ER_EVENT_UNABLE_TO_DROP_EVENT 10806 -//#define OBSOLETE_ER_BINLOG_ATTACHING_THREAD_MEMORY_FINALLY_AVAILABLE 10807 -#define ER_BINLOG_CANT_RESIZE_CACHE 10808 -#define ER_BINLOG_FILE_BEING_READ_NOT_PURGED 10809 -#define ER_BINLOG_IO_ERROR_READING_HEADER 10810 -//#define OBSOLETE_ER_BINLOG_CANT_OPEN_LOG 10811 -//#define OBSOLETE_ER_BINLOG_CANT_CREATE_CACHE_FOR_LOG 10812 -#define ER_BINLOG_FILE_EXTENSION_NUMBER_EXHAUSTED 10813 -#define ER_BINLOG_FILE_NAME_TOO_LONG 10814 -#define ER_BINLOG_FILE_EXTENSION_NUMBER_RUNNING_LOW 10815 -#define ER_BINLOG_CANT_OPEN_FOR_LOGGING 10816 -#define ER_BINLOG_FAILED_TO_SYNC_INDEX_FILE 10817 -#define ER_BINLOG_ERROR_READING_GTIDS_FROM_RELAY_LOG 10818 -#define ER_BINLOG_EVENTS_READ_FROM_RELAY_LOG_INFO 10819 -#define ER_BINLOG_ERROR_READING_GTIDS_FROM_BINARY_LOG 10820 -#define ER_BINLOG_EVENTS_READ_FROM_BINLOG_INFO 10821 -#define ER_BINLOG_CANT_GENERATE_NEW_FILE_NAME 10822 -#define ER_BINLOG_FAILED_TO_SYNC_INDEX_FILE_IN_OPEN 10823 -#define ER_BINLOG_CANT_USE_FOR_LOGGING 10824 -#define ER_BINLOG_FAILED_TO_CLOSE_INDEX_FILE_WHILE_REBUILDING 10825 -#define ER_BINLOG_FAILED_TO_DELETE_INDEX_FILE_WHILE_REBUILDING 10826 -#define ER_BINLOG_FAILED_TO_RENAME_INDEX_FILE_WHILE_REBUILDING 10827 -#define ER_BINLOG_FAILED_TO_OPEN_INDEX_FILE_AFTER_REBUILDING 10828 -#define ER_BINLOG_CANT_APPEND_LOG_TO_TMP_INDEX 10829 -#define ER_BINLOG_CANT_LOCATE_OLD_BINLOG_OR_RELAY_LOG_FILES 10830 -#define ER_BINLOG_CANT_DELETE_FILE 10831 -#define ER_BINLOG_CANT_SET_TMP_INDEX_NAME 10832 -#define ER_BINLOG_FAILED_TO_OPEN_TEMPORARY_INDEX_FILE 10833 -//#define OBSOLETE_ER_BINLOG_ERROR_GETTING_NEXT_LOG_FROM_INDEX 10834 -#define ER_BINLOG_CANT_OPEN_TMP_INDEX 10835 -#define ER_BINLOG_CANT_COPY_INDEX_TO_TMP 10836 -#define ER_BINLOG_CANT_CLOSE_TMP_INDEX 10837 -#define ER_BINLOG_CANT_MOVE_TMP_TO_INDEX 10838 -#define ER_BINLOG_PURGE_LOGS_CALLED_WITH_FILE_NOT_IN_INDEX 10839 -#define ER_BINLOG_PURGE_LOGS_CANT_SYNC_INDEX_FILE 10840 -#define ER_BINLOG_PURGE_LOGS_CANT_COPY_TO_REGISTER_FILE 10841 -#define ER_BINLOG_PURGE_LOGS_CANT_FLUSH_REGISTER_FILE 10842 -#define ER_BINLOG_PURGE_LOGS_CANT_UPDATE_INDEX_FILE 10843 -#define ER_BINLOG_PURGE_LOGS_FAILED_TO_PURGE_LOG 10844 -#define ER_BINLOG_FAILED_TO_SET_PURGE_INDEX_FILE_NAME 10845 -#define ER_BINLOG_FAILED_TO_OPEN_REGISTER_FILE 10846 -#define ER_BINLOG_FAILED_TO_REINIT_REGISTER_FILE 10847 -#define ER_BINLOG_FAILED_TO_READ_REGISTER_FILE 10848 -#define ER_CANT_STAT_FILE 10849 -#define ER_BINLOG_CANT_DELETE_LOG_FILE_DOES_INDEX_MATCH_FILES 10850 -#define ER_BINLOG_CANT_DELETE_FILE_AND_READ_BINLOG_INDEX 10851 -#define ER_BINLOG_FAILED_TO_DELETE_LOG_FILE 10852 -#define ER_BINLOG_LOGGING_INCIDENT_TO_STOP_SLAVES 10853 -#define ER_BINLOG_CANT_FIND_LOG_IN_INDEX 10854 -#define ER_BINLOG_RECOVERING_AFTER_CRASH_USING 10855 -#define ER_BINLOG_CANT_OPEN_CRASHED_BINLOG 10856 -#define ER_BINLOG_CANT_TRIM_CRASHED_BINLOG 10857 -#define ER_BINLOG_CRASHED_BINLOG_TRIMMED 10858 -#define ER_BINLOG_CANT_CLEAR_IN_USE_FLAG_FOR_CRASHED_BINLOG 10859 -#define ER_BINLOG_FAILED_TO_RUN_AFTER_SYNC_HOOK 10860 -#define ER_TURNING_LOGGING_OFF_FOR_THE_DURATION 10861 -#define ER_BINLOG_FAILED_TO_RUN_AFTER_FLUSH_HOOK 10862 -#define ER_BINLOG_CRASH_RECOVERY_FAILED 10863 -#define ER_BINLOG_WARNING_SUPPRESSED 10864 -#define ER_NDB_LOG_ENTRY 10865 -#define ER_NDB_LOG_ENTRY_WITH_PREFIX 10866 -//#define OBSOLETE_ER_NDB_BINLOG_CANT_CREATE_PURGE_THD 10867 -#define ER_INNODB_UNKNOWN_COLLATION 10868 -#define ER_INNODB_INVALID_LOG_GROUP_HOME_DIR 10869 -#define ER_INNODB_INVALID_INNODB_UNDO_DIRECTORY 10870 -#define ER_INNODB_ILLEGAL_COLON_IN_POOL 10871 -#define ER_INNODB_INVALID_PAGE_SIZE 10872 -#define ER_INNODB_DIRTY_WATER_MARK_NOT_LOW 10873 -#define ER_INNODB_IO_CAPACITY_EXCEEDS_MAX 10874 -#define ER_INNODB_FILES_SAME 10875 -#define ER_INNODB_UNREGISTERED_TRX_ACTIVE 10876 -#define ER_INNODB_CLOSING_CONNECTION_ROLLS_BACK 10877 -#define ER_INNODB_TRX_XLATION_TABLE_OOM 10878 -#define ER_INNODB_CANT_FIND_INDEX_IN_INNODB_DD 10879 -#define ER_INNODB_INDEX_COLUMN_INFO_UNLIKE_MYSQLS 10880 -#define ER_INNODB_CANT_OPEN_TABLE 10881 -#define ER_INNODB_CANT_BUILD_INDEX_XLATION_TABLE_FOR 10882 -#define ER_INNODB_PK_NOT_IN_MYSQL 10883 -#define ER_INNODB_PK_ONLY_IN_MYSQL 10884 -#define ER_INNODB_CLUSTERED_INDEX_PRIVATE 10885 -#define ER_INNODB_PARTITION_TABLE_LOWERCASED 10886 -#define ER_ERRMSG_REPLACEMENT_DODGY 10887 -#define ER_ERRMSG_REPLACEMENTS_FAILED 10888 -#define ER_NPIPE_CANT_CREATE 10889 -#define ER_PARTITION_MOVE_CREATED_DUPLICATE_ROW_PLEASE_FIX 10890 -#define ER_AUDIT_CANT_ABORT_COMMAND 10891 -#define ER_AUDIT_CANT_ABORT_EVENT 10892 -#define ER_AUDIT_WARNING 10893 -//#define OBSOLETE_ER_NDB_NUMBER_OF_CHANNELS 10894 -//#define OBSOLETE_ER_NDB_SLAVE_PARALLEL_WORKERS 10895 -//#define OBSOLETE_ER_NDB_DISTRIBUTING_ERR 10896 -#define ER_RPL_SLAVE_INSECURE_CHANGE_MASTER 10897 -//#define OBSOLETE_ER_RPL_SLAVE_FLUSH_RELAY_LOGS_NOT_ALLOWED 10898 -#define ER_RPL_SLAVE_INCORRECT_CHANNEL 10899 -#define ER_FAILED_TO_FIND_DL_ENTRY 10900 -#define ER_FAILED_TO_OPEN_SHARED_LIBRARY 10901 -#define ER_THREAD_PRIORITY_IGNORED 10902 -#define ER_BINLOG_CACHE_SIZE_TOO_LARGE 10903 -#define ER_BINLOG_STMT_CACHE_SIZE_TOO_LARGE 10904 -#define ER_FAILED_TO_GENERATE_UNIQUE_LOGFILE 10905 -#define ER_FAILED_TO_READ_FILE 10906 -#define ER_FAILED_TO_WRITE_TO_FILE 10907 -#define ER_BINLOG_UNSAFE_MESSAGE_AND_STATEMENT 10908 -#define ER_FORCE_CLOSE_THREAD 10909 -#define ER_SERVER_SHUTDOWN_COMPLETE 10910 -#define ER_RPL_CANT_HAVE_SAME_BASENAME 10911 -#define ER_RPL_GTID_MODE_REQUIRES_ENFORCE_GTID_CONSISTENCY_ON 10912 -#define ER_WARN_NO_SERVERID_SPECIFIED 10913 -#define ER_ABORTING_USER_CONNECTION 10914 -#define ER_SQL_MODE_MERGED_WITH_STRICT_MODE 10915 -#define ER_GTID_PURGED_WAS_UPDATED 10916 -#define ER_GTID_EXECUTED_WAS_UPDATED 10917 -#define ER_DEPRECATE_MSG_WITH_REPLACEMENT 10918 -#define ER_TRG_CREATION_CTX_NOT_SET 10919 -#define ER_FILE_HAS_OLD_FORMAT 10920 -#define ER_VIEW_CREATION_CTX_NOT_SET 10921 -//#define OBSOLETE_ER_TABLE_NAME_CAUSES_TOO_LONG_PATH 10922 -#define ER_TABLE_UPGRADE_REQUIRED 10923 -#define ER_GET_ERRNO_FROM_STORAGE_ENGINE 10924 -#define ER_ACCESS_DENIED_ERROR_WITHOUT_PASSWORD 10925 -#define ER_ACCESS_DENIED_ERROR_WITH_PASSWORD 10926 -#define ER_ACCESS_DENIED_FOR_USER_ACCOUNT_LOCKED 10927 -#define ER_MUST_CHANGE_EXPIRED_PASSWORD 10928 -#define ER_SYSTEM_TABLES_NOT_SUPPORTED_BY_STORAGE_ENGINE 10929 -#define ER_FILESORT_TERMINATED 10930 -#define ER_SERVER_STARTUP_MSG 10931 -#define ER_FAILED_TO_FIND_LOCALE_NAME 10932 -#define ER_FAILED_TO_FIND_COLLATION_NAME 10933 -#define ER_SERVER_OUT_OF_RESOURCES 10934 -#define ER_SERVER_OUTOFMEMORY 10935 -#define ER_INVALID_COLLATION_FOR_CHARSET 10936 -#define ER_CANT_START_ERROR_LOG_SERVICE 10937 -#define ER_CREATING_NEW_UUID_FIRST_START 10938 -#define ER_FAILED_TO_GET_ABSOLUTE_PATH 10939 -#define ER_PERFSCHEMA_COMPONENTS_INFRASTRUCTURE_BOOTSTRAP 10940 -#define ER_PERFSCHEMA_COMPONENTS_INFRASTRUCTURE_SHUTDOWN 10941 -#define ER_DUP_FD_OPEN_FAILED 10942 -#define ER_SYSTEM_VIEW_INIT_FAILED 10943 -#define ER_RESOURCE_GROUP_POST_INIT_FAILED 10944 -#define ER_RESOURCE_GROUP_SUBSYSTEM_INIT_FAILED 10945 -#define ER_FAILED_START_MYSQLD_DAEMON 10946 -#define ER_CANNOT_CHANGE_TO_ROOT_DIR 10947 -#define ER_PERSISTENT_PRIVILEGES_BOOTSTRAP 10948 -#define ER_BASEDIR_SET_TO 10949 -#define ER_RPL_FILTER_ADD_WILD_DO_TABLE_FAILED 10950 -#define ER_RPL_FILTER_ADD_WILD_IGNORE_TABLE_FAILED 10951 -#define ER_PRIVILEGE_SYSTEM_INIT_FAILED 10952 -#define ER_CANNOT_SET_LOG_ERROR_SERVICES 10953 -#define ER_PERFSCHEMA_TABLES_INIT_FAILED 10954 -#define ER_TX_EXTRACTION_ALGORITHM_FOR_BINLOG_TX_DEPEDENCY_TRACKING 10955 -#define ER_INVALID_REPLICATION_TIMESTAMPS 10956 -#define ER_RPL_TIMESTAMPS_RETURNED_TO_NORMAL 10957 -#define ER_BINLOG_FILE_OPEN_FAILED 10958 -#define ER_BINLOG_EVENT_WRITE_TO_STMT_CACHE_FAILED 10959 -#define ER_SLAVE_RELAY_LOG_TRUNCATE_INFO 10960 -#define ER_SLAVE_RELAY_LOG_PURGE_FAILED 10961 -#define ER_RPL_SLAVE_FILTER_CREATE_FAILED 10962 -#define ER_RPL_SLAVE_GLOBAL_FILTERS_COPY_FAILED 10963 -#define ER_RPL_SLAVE_RESET_FILTER_OPTIONS 10964 -#define ER_MISSING_GRANT_SYSTEM_TABLE 10965 -#define ER_MISSING_ACL_SYSTEM_TABLE 10966 -#define ER_ANONYMOUS_AUTH_ID_NOT_ALLOWED_IN_MANDATORY_ROLES 10967 -#define ER_UNKNOWN_AUTH_ID_IN_MANDATORY_ROLE 10968 -#define ER_WRITE_ROW_TO_PARTITION_FAILED 10969 -#define ER_RESOURCE_GROUP_METADATA_UPDATE_SKIPPED 10970 -#define ER_FAILED_TO_PERSIST_RESOURCE_GROUP_METADATA 10971 -#define ER_FAILED_TO_DESERIALIZE_RESOURCE_GROUP 10972 -#define ER_FAILED_TO_UPDATE_RESOURCE_GROUP 10973 -#define ER_RESOURCE_GROUP_VALIDATION_FAILED 10974 -#define ER_FAILED_TO_ALLOCATE_MEMORY_FOR_RESOURCE_GROUP 10975 -#define ER_FAILED_TO_ALLOCATE_MEMORY_FOR_RESOURCE_GROUP_HASH 10976 -#define ER_FAILED_TO_ADD_RESOURCE_GROUP_TO_MAP 10977 -#define ER_RESOURCE_GROUP_IS_DISABLED 10978 -#define ER_FAILED_TO_APPLY_RESOURCE_GROUP_CONTROLLER 10979 -#define ER_FAILED_TO_ACQUIRE_LOCK_ON_RESOURCE_GROUP 10980 -#define ER_PFS_NOTIFICATION_FUNCTION_REGISTER_FAILED 10981 -#define ER_RES_GRP_SET_THR_AFFINITY_FAILED 10982 -#define ER_RES_GRP_SET_THR_AFFINITY_TO_CPUS_FAILED 10983 -#define ER_RES_GRP_THD_UNBIND_FROM_CPU_FAILED 10984 -#define ER_RES_GRP_SET_THREAD_PRIORITY_FAILED 10985 -#define ER_RES_GRP_FAILED_TO_DETERMINE_NICE_CAPABILITY 10986 -#define ER_RES_GRP_FAILED_TO_GET_THREAD_HANDLE 10987 -#define ER_RES_GRP_GET_THREAD_PRIO_NOT_SUPPORTED 10988 -#define ER_RES_GRP_FAILED_DETERMINE_CPU_COUNT 10989 -#define ER_RES_GRP_FEATURE_NOT_AVAILABLE 10990 -#define ER_RES_GRP_INVALID_THREAD_PRIORITY 10991 -#define ER_RES_GRP_SOLARIS_PROCESSOR_BIND_TO_CPUID_FAILED 10992 -#define ER_RES_GRP_SOLARIS_PROCESSOR_BIND_TO_THREAD_FAILED 10993 -#define ER_RES_GRP_SOLARIS_PROCESSOR_AFFINITY_FAILED 10994 -#define ER_DD_UPGRADE_RENAME_IDX_STATS_FILE_FAILED 10995 -#define ER_DD_UPGRADE_DD_OPEN_FAILED 10996 -#define ER_DD_UPGRADE_FAILED_TO_FETCH_TABLESPACES 10997 -#define ER_DD_UPGRADE_FAILED_TO_ACQUIRE_TABLESPACE 10998 -#define ER_DD_UPGRADE_FAILED_TO_RESOLVE_TABLESPACE_ENGINE 10999 -#define ER_FAILED_TO_CREATE_SDI_FOR_TABLESPACE 11000 -#define ER_FAILED_TO_STORE_SDI_FOR_TABLESPACE 11001 -#define ER_DD_UPGRADE_FAILED_TO_FETCH_TABLES 11002 -#define ER_DD_UPGRADE_DD_POPULATED 11003 -#define ER_DD_UPGRADE_INFO_FILE_OPEN_FAILED 11004 -#define ER_DD_UPGRADE_INFO_FILE_CLOSE_FAILED 11005 -#define ER_DD_UPGRADE_TABLESPACE_MIGRATION_FAILED 11006 -#define ER_DD_UPGRADE_FAILED_TO_CREATE_TABLE_STATS 11007 -#define ER_DD_UPGRADE_TABLE_STATS_MIGRATE_COMPLETED 11008 -#define ER_DD_UPGRADE_FAILED_TO_CREATE_INDEX_STATS 11009 -#define ER_DD_UPGRADE_INDEX_STATS_MIGRATE_COMPLETED 11010 -#define ER_DD_UPGRADE_FAILED_FIND_VALID_DATA_DIR 11011 -#define ER_DD_UPGRADE_START 11012 -#define ER_DD_UPGRADE_FAILED_INIT_DD_SE 11013 -#define ER_DD_UPGRADE_FOUND_PARTIALLY_UPGRADED_DD_ABORT 11014 -#define ER_DD_UPGRADE_FOUND_PARTIALLY_UPGRADED_DD_CONTINUE 11015 -#define ER_DD_UPGRADE_SE_LOGS_FAILED 11016 -#define ER_DD_UPGRADE_SDI_INFO_UPDATE_FAILED 11017 -#define ER_SKIP_UPDATING_METADATA_IN_SE_RO_MODE 11018 -#define ER_CREATED_SYSTEM_WITH_VERSION 11019 -#define ER_UNKNOWN_ERROR_DETECTED_IN_SE 11020 -#define ER_READ_LOG_EVENT_FAILED 11021 -#define ER_ROW_DATA_TOO_BIG_TO_WRITE_IN_BINLOG 11022 -#define ER_FAILED_TO_CONSTRUCT_DROP_EVENT_QUERY 11023 -#define ER_FAILED_TO_BINLOG_DROP_EVENT 11024 -#define ER_FAILED_TO_START_SLAVE_THREAD 11025 -#define ER_RPL_IO_THREAD_KILLED 11026 -#define ER_SLAVE_RECONNECT_FAILED 11027 -#define ER_SLAVE_KILLED_AFTER_RECONNECT 11028 -#define ER_SLAVE_NOT_STARTED_ON_SOME_CHANNELS 11029 -#define ER_FAILED_TO_ADD_RPL_FILTER 11030 -#define ER_PER_CHANNEL_RPL_FILTER_CONF_FOR_GRP_RPL 11031 -#define ER_RPL_FILTERS_NOT_ATTACHED_TO_CHANNEL 11032 -#define ER_FAILED_TO_BUILD_DO_AND_IGNORE_TABLE_HASHES 11033 -#define ER_CLONE_PLUGIN_NOT_LOADED_TRACE 11034 -#define ER_CLONE_HANDLER_EXIST_TRACE 11035 -#define ER_CLONE_CREATE_HANDLER_FAIL_TRACE 11036 -#define ER_CYCLE_TIMER_IS_NOT_AVAILABLE 11037 -#define ER_NANOSECOND_TIMER_IS_NOT_AVAILABLE 11038 -#define ER_MICROSECOND_TIMER_IS_NOT_AVAILABLE 11039 -#define ER_PFS_MALLOC_ARRAY_OVERFLOW 11040 -#define ER_PFS_MALLOC_ARRAY_OOM 11041 -#define ER_INNODB_FAILED_TO_FIND_IDX_WITH_KEY_NO 11042 -#define ER_INNODB_FAILED_TO_FIND_IDX 11043 -#define ER_INNODB_FAILED_TO_FIND_IDX_FROM_DICT_CACHE 11044 -#define ER_INNODB_ACTIVE_INDEX_CHANGE_FAILED 11045 -#define ER_INNODB_DIFF_IN_REF_LEN 11046 -#define ER_WRONG_TYPE_FOR_COLUMN_PREFIX_IDX_FLD 11047 -#define ER_INNODB_CANNOT_CREATE_TABLE 11048 -#define ER_INNODB_INTERNAL_INDEX 11049 -#define ER_INNODB_IDX_CNT_MORE_THAN_DEFINED_IN_MYSQL 11050 -#define ER_INNODB_IDX_CNT_FEWER_THAN_DEFINED_IN_MYSQL 11051 -#define ER_INNODB_IDX_COLUMN_CNT_DIFF 11052 -#define ER_INNODB_USE_MONITOR_GROUP_NAME 11053 -#define ER_INNODB_MONITOR_DEFAULT_VALUE_NOT_DEFINED 11054 -#define ER_INNODB_MONITOR_IS_ENABLED 11055 -#define ER_INNODB_INVALID_MONITOR_COUNTER_NAME 11056 -#define ER_WIN_LOAD_LIBRARY_FAILED 11057 -#define ER_PARTITION_HANDLER_ADMIN_MSG 11058 -#define ER_RPL_RLI_INIT_INFO_MSG 11059 -#define ER_DD_UPGRADE_TABLE_INTACT_ERROR 11060 -#define ER_SERVER_INIT_COMPILED_IN_COMMANDS 11061 -#define ER_MYISAM_CHECK_METHOD_ERROR 11062 -#define ER_MYISAM_CRASHED_ERROR 11063 -#define ER_WAITPID_FAILED 11064 -#define ER_FAILED_TO_FIND_MYSQLD_STATUS 11065 -#define ER_INNODB_ERROR_LOGGER_MSG 11066 -#define ER_INNODB_ERROR_LOGGER_FATAL_MSG 11067 -#define ER_DEPRECATED_SYNTAX_WITH_REPLACEMENT 11068 -#define ER_DEPRECATED_SYNTAX_NO_REPLACEMENT 11069 -#define ER_DEPRECATE_MSG_NO_REPLACEMENT 11070 -#define ER_LOG_PRINTF_MSG 11071 -#define ER_BINLOG_LOGGING_NOT_POSSIBLE 11072 -#define ER_FAILED_TO_SET_PERSISTED_OPTIONS 11073 -#define ER_COMPONENTS_FAILED_TO_ACQUIRE_SERVICE_IMPLEMENTATION 11074 -#define ER_RES_GRP_INVALID_VCPU_RANGE 11075 -#define ER_RES_GRP_INVALID_VCPU_ID 11076 -#define ER_ERROR_DURING_FLUSH_LOG_COMMIT_PHASE 11077 -#define ER_DROP_DATABASE_FAILED_RMDIR_MANUALLY 11078 -#define ER_EXPIRE_LOGS_DAYS_IGNORED 11079 -#define ER_BINLOG_MALFORMED_OR_OLD_RELAY_LOG 11080 -#define ER_DD_UPGRADE_VIEW_COLUMN_NAME_TOO_LONG 11081 -#define ER_TABLE_NEEDS_DUMP_UPGRADE 11082 -#define ER_DD_UPGRADE_FAILED_TO_UPDATE_VER_NO_IN_TABLESPACE 11083 -#define ER_KEYRING_MIGRATION_FAILED 11084 -#define ER_KEYRING_MIGRATION_SUCCESSFUL 11085 -#define ER_RESTART_RECEIVED_INFO 11086 -#define ER_LCTN_CHANGED 11087 -#define ER_DD_INITIALIZE 11088 -#define ER_DD_RESTART 11089 -#define ER_DD_UPGRADE 11090 -#define ER_DD_UPGRADE_OFF 11091 -#define ER_DD_UPGRADE_VERSION_NOT_SUPPORTED 11092 -#define ER_DD_UPGRADE_SCHEMA_UNAVAILABLE 11093 -#define ER_DD_MINOR_DOWNGRADE 11094 -#define ER_DD_MINOR_DOWNGRADE_VERSION_NOT_SUPPORTED 11095 -#define ER_DD_NO_VERSION_FOUND 11096 -#define ER_THREAD_POOL_NOT_SUPPORTED_ON_PLATFORM 11097 -#define ER_THREAD_POOL_SIZE_TOO_LOW 11098 -#define ER_THREAD_POOL_SIZE_TOO_HIGH 11099 -#define ER_THREAD_POOL_ALGORITHM_INVALID 11100 -#define ER_THREAD_POOL_INVALID_STALL_LIMIT 11101 -#define ER_THREAD_POOL_INVALID_PRIO_KICKUP_TIMER 11102 -#define ER_THREAD_POOL_MAX_UNUSED_THREADS_INVALID 11103 -#define ER_THREAD_POOL_CON_HANDLER_INIT_FAILED 11104 -#define ER_THREAD_POOL_INIT_FAILED 11105 -#define ER_THREAD_POOL_PLUGIN_STARTED 11106 -#define ER_THREAD_POOL_CANNOT_SET_THREAD_SPECIFIC_DATA 11107 -#define ER_THREAD_POOL_FAILED_TO_CREATE_CONNECT_HANDLER_THD 11108 -#define ER_THREAD_POOL_FAILED_TO_CREATE_THD_AND_AUTH_CONN 11109 -#define ER_THREAD_POOL_FAILED_PROCESS_CONNECT_EVENT 11110 -#define ER_THREAD_POOL_FAILED_TO_CREATE_POOL 11111 -#define ER_THREAD_POOL_RATE_LIMITED_ERROR_MSGS 11112 -#define ER_TRHEAD_POOL_LOW_LEVEL_INIT_FAILED 11113 -#define ER_THREAD_POOL_LOW_LEVEL_REARM_FAILED 11114 -#define ER_THREAD_POOL_BUFFER_TOO_SMALL 11115 -#define ER_MECAB_NOT_SUPPORTED 11116 -#define ER_MECAB_NOT_VERIFIED 11117 -#define ER_MECAB_CREATING_MODEL 11118 -#define ER_MECAB_FAILED_TO_CREATE_MODEL 11119 -#define ER_MECAB_FAILED_TO_CREATE_TRIGGER 11120 -#define ER_MECAB_UNSUPPORTED_CHARSET 11121 -#define ER_MECAB_CHARSET_LOADED 11122 -#define ER_MECAB_PARSE_FAILED 11123 -#define ER_MECAB_OOM_WHILE_PARSING_TEXT 11124 -#define ER_MECAB_CREATE_LATTICE_FAILED 11125 -#define ER_SEMISYNC_TRACE_ENTER_FUNC 11126 -#define ER_SEMISYNC_TRACE_EXIT_WITH_INT_EXIT_CODE 11127 -#define ER_SEMISYNC_TRACE_EXIT_WITH_BOOL_EXIT_CODE 11128 -#define ER_SEMISYNC_TRACE_EXIT 11129 -#define ER_SEMISYNC_RPL_INIT_FOR_TRX 11130 -#define ER_SEMISYNC_FAILED_TO_ALLOCATE_TRX_NODE 11131 -#define ER_SEMISYNC_BINLOG_WRITE_OUT_OF_ORDER 11132 -#define ER_SEMISYNC_INSERT_LOG_INFO_IN_ENTRY 11133 -#define ER_SEMISYNC_PROBE_LOG_INFO_IN_ENTRY 11134 -#define ER_SEMISYNC_CLEARED_ALL_ACTIVE_TRANSACTION_NODES 11135 -#define ER_SEMISYNC_CLEARED_ACTIVE_TRANSACTION_TILL_POS 11136 -#define ER_SEMISYNC_REPLY_MAGIC_NO_ERROR 11137 -#define ER_SEMISYNC_REPLY_PKT_LENGTH_TOO_SMALL 11138 -#define ER_SEMISYNC_REPLY_BINLOG_FILE_TOO_LARGE 11139 -#define ER_SEMISYNC_SERVER_REPLY 11140 -#define ER_SEMISYNC_FUNCTION_CALLED_TWICE 11141 -#define ER_SEMISYNC_RPL_ENABLED_ON_MASTER 11142 -#define ER_SEMISYNC_MASTER_OOM 11143 -#define ER_SEMISYNC_DISABLED_ON_MASTER 11144 -#define ER_SEMISYNC_FORCED_SHUTDOWN 11145 -#define ER_SEMISYNC_MASTER_GOT_REPLY_AT_POS 11146 -#define ER_SEMISYNC_MASTER_SIGNAL_ALL_WAITING_THREADS 11147 -#define ER_SEMISYNC_MASTER_TRX_WAIT_POS 11148 -#define ER_SEMISYNC_BINLOG_REPLY_IS_AHEAD 11149 -#define ER_SEMISYNC_MOVE_BACK_WAIT_POS 11150 -#define ER_SEMISYNC_INIT_WAIT_POS 11151 -#define ER_SEMISYNC_WAIT_TIME_FOR_BINLOG_SENT 11152 -#define ER_SEMISYNC_WAIT_FOR_BINLOG_TIMEDOUT 11153 -#define ER_SEMISYNC_WAIT_TIME_ASSESSMENT_FOR_COMMIT_TRX_FAILED 11154 -#define ER_SEMISYNC_RPL_SWITCHED_OFF 11155 -#define ER_SEMISYNC_RPL_SWITCHED_ON 11156 -#define ER_SEMISYNC_NO_SPACE_IN_THE_PKT 11157 -#define ER_SEMISYNC_SYNC_HEADER_UPDATE_INFO 11158 -#define ER_SEMISYNC_FAILED_TO_INSERT_TRX_NODE 11159 -#define ER_SEMISYNC_TRX_SKIPPED_AT_POS 11160 -#define ER_SEMISYNC_MASTER_FAILED_ON_NET_FLUSH 11161 -#define ER_SEMISYNC_RECEIVED_ACK_IS_SMALLER 11162 -#define ER_SEMISYNC_ADD_ACK_TO_SLOT 11163 -#define ER_SEMISYNC_UPDATE_EXISTING_SLAVE_ACK 11164 -#define ER_SEMISYNC_FAILED_TO_START_ACK_RECEIVER_THD 11165 -#define ER_SEMISYNC_STARTING_ACK_RECEIVER_THD 11166 -#define ER_SEMISYNC_FAILED_TO_WAIT_ON_DUMP_SOCKET 11167 -#define ER_SEMISYNC_STOPPING_ACK_RECEIVER_THREAD 11168 -#define ER_SEMISYNC_FAILED_REGISTER_SLAVE_TO_RECEIVER 11169 -#define ER_SEMISYNC_START_BINLOG_DUMP_TO_SLAVE 11170 -#define ER_SEMISYNC_STOP_BINLOG_DUMP_TO_SLAVE 11171 -#define ER_SEMISYNC_UNREGISTER_TRX_OBSERVER_FAILED 11172 -#define ER_SEMISYNC_UNREGISTER_BINLOG_STORAGE_OBSERVER_FAILED 11173 -#define ER_SEMISYNC_UNREGISTER_BINLOG_TRANSMIT_OBSERVER_FAILED 11174 -#define ER_SEMISYNC_UNREGISTERED_REPLICATOR 11175 -#define ER_SEMISYNC_SOCKET_FD_TOO_LARGE 11176 -#define ER_SEMISYNC_SLAVE_REPLY 11177 -#define ER_SEMISYNC_MISSING_MAGIC_NO_FOR_SEMISYNC_PKT 11178 -#define ER_SEMISYNC_SLAVE_START 11179 -#define ER_SEMISYNC_SLAVE_REPLY_WITH_BINLOG_INFO 11180 -#define ER_SEMISYNC_SLAVE_NET_FLUSH_REPLY_FAILED 11181 -#define ER_SEMISYNC_SLAVE_SEND_REPLY_FAILED 11182 -#define ER_SEMISYNC_EXECUTION_FAILED_ON_MASTER 11183 -#define ER_SEMISYNC_NOT_SUPPORTED_BY_MASTER 11184 -#define ER_SEMISYNC_SLAVE_SET_FAILED 11185 -#define ER_SEMISYNC_FAILED_TO_STOP_ACK_RECEIVER_THD 11186 -#define ER_FIREWALL_FAILED_TO_READ_FIREWALL_TABLES 11187 -#define ER_FIREWALL_FAILED_TO_REG_DYNAMIC_PRIVILEGES 11188 -#define ER_FIREWALL_RECORDING_STMT_WAS_TRUNCATED 11189 -#define ER_FIREWALL_RECORDING_STMT_WITHOUT_TEXT 11190 -#define ER_FIREWALL_SUSPICIOUS_STMT 11191 -#define ER_FIREWALL_ACCESS_DENIED 11192 -#define ER_FIREWALL_SKIPPED_UNKNOWN_USER_MODE 11193 -#define ER_FIREWALL_RELOADING_CACHE 11194 -#define ER_FIREWALL_RESET_FOR_USER 11195 -#define ER_FIREWALL_STATUS_FLUSHED 11196 -#define ER_KEYRING_LOGGER_ERROR_MSG 11197 -#define ER_AUDIT_LOG_FILTER_IS_NOT_INSTALLED 11198 -#define ER_AUDIT_LOG_SWITCHING_TO_INCLUDE_LIST 11199 -#define ER_AUDIT_LOG_CANNOT_SET_LOG_POLICY_WITH_OTHER_POLICIES 11200 -#define ER_AUDIT_LOG_ONLY_INCLUDE_LIST_USED 11201 -#define ER_AUDIT_LOG_INDEX_MAP_CANNOT_ACCESS_DIR 11202 -#define ER_AUDIT_LOG_WRITER_RENAME_FILE_FAILED 11203 -#define ER_AUDIT_LOG_WRITER_DEST_FILE_ALREADY_EXISTS 11204 -#define ER_AUDIT_LOG_WRITER_RENAME_FILE_FAILED_REMOVE_FILE_MANUALLY 11205 -#define ER_AUDIT_LOG_WRITER_INCOMPLETE_FILE_RENAMED 11206 -#define ER_AUDIT_LOG_WRITER_FAILED_TO_WRITE_TO_FILE 11207 -#define ER_AUDIT_LOG_EC_WRITER_FAILED_TO_INIT_ENCRYPTION 11208 -#define ER_AUDIT_LOG_EC_WRITER_FAILED_TO_INIT_COMPRESSION 11209 -#define ER_AUDIT_LOG_EC_WRITER_FAILED_TO_CREATE_FILE 11210 -#define ER_AUDIT_LOG_RENAME_LOG_FILE_BEFORE_FLUSH 11211 -#define ER_AUDIT_LOG_FILTER_RESULT_MSG 11212 -#define ER_AUDIT_LOG_JSON_READER_FAILED_TO_PARSE 11213 -#define ER_AUDIT_LOG_JSON_READER_BUF_TOO_SMALL 11214 -#define ER_AUDIT_LOG_JSON_READER_FAILED_TO_OPEN_FILE 11215 -#define ER_AUDIT_LOG_JSON_READER_FILE_PARSING_ERROR 11216 -#define ER_AUDIT_LOG_FILTER_INVALID_COLUMN_COUNT 11217 -#define ER_AUDIT_LOG_FILTER_INVALID_COLUMN_DEFINITION 11218 -#define ER_AUDIT_LOG_FILTER_FAILED_TO_STORE_TABLE_FLDS 11219 -#define ER_AUDIT_LOG_FILTER_FAILED_TO_UPDATE_TABLE 11220 -#define ER_AUDIT_LOG_FILTER_FAILED_TO_INSERT_INTO_TABLE 11221 -#define ER_AUDIT_LOG_FILTER_FAILED_TO_DELETE_FROM_TABLE 11222 -#define ER_AUDIT_LOG_FILTER_FAILED_TO_INIT_TABLE_FOR_READ 11223 -#define ER_AUDIT_LOG_FILTER_FAILED_TO_READ_TABLE 11224 -#define ER_AUDIT_LOG_FILTER_FAILED_TO_CLOSE_TABLE_AFTER_READING 11225 -#define ER_AUDIT_LOG_FILTER_USER_AND_HOST_CANNOT_BE_EMPTY 11226 -#define ER_AUDIT_LOG_FILTER_FLD_FILTERNAME_CANNOT_BE_EMPTY 11227 -#define ER_VALIDATE_PWD_DICT_FILE_NOT_SPECIFIED 11228 -#define ER_VALIDATE_PWD_DICT_FILE_NOT_LOADED 11229 -#define ER_VALIDATE_PWD_DICT_FILE_TOO_BIG 11230 -#define ER_VALIDATE_PWD_FAILED_TO_READ_DICT_FILE 11231 -#define ER_VALIDATE_PWD_FAILED_TO_GET_FLD_FROM_SECURITY_CTX 11232 -#define ER_VALIDATE_PWD_FAILED_TO_GET_SECURITY_CTX 11233 -#define ER_VALIDATE_PWD_LENGTH_CHANGED 11234 -#define ER_REWRITER_QUERY_ERROR_MSG 11235 -#define ER_REWRITER_QUERY_FAILED 11236 -#define ER_XPLUGIN_STARTUP_FAILED 11237 -//#define OBSOLETE_ER_XPLUGIN_SERVER_EXITING 11238 -//#define OBSOLETE_ER_XPLUGIN_SERVER_EXITED 11239 -#define ER_XPLUGIN_USING_SSL_CONF_FROM_SERVER 11240 -#define ER_XPLUGIN_USING_SSL_CONF_FROM_MYSQLX 11241 -#define ER_XPLUGIN_FAILED_TO_USE_SSL_CONF 11242 -#define ER_XPLUGIN_USING_SSL_FOR_TLS_CONNECTION 11243 -#define ER_XPLUGIN_REFERENCE_TO_SECURE_CONN_WITH_XPLUGIN 11244 -#define ER_XPLUGIN_ERROR_MSG 11245 -#define ER_SHA_PWD_FAILED_TO_PARSE_AUTH_STRING 11246 -#define ER_SHA_PWD_FAILED_TO_GENERATE_MULTI_ROUND_HASH 11247 -#define ER_SHA_PWD_AUTH_REQUIRES_RSA_OR_SSL 11248 -#define ER_SHA_PWD_RSA_KEY_TOO_LONG 11249 -#define ER_PLUGIN_COMMON_FAILED_TO_OPEN_FILTER_TABLES 11250 -#define ER_PLUGIN_COMMON_FAILED_TO_OPEN_TABLE 11251 -#define ER_AUTH_LDAP_ERROR_LOGGER_ERROR_MSG 11252 -#define ER_CONN_CONTROL_ERROR_MSG 11253 -#define ER_GRP_RPL_ERROR_MSG 11254 -#define ER_SHA_PWD_SALT_FOR_USER_CORRUPT 11255 -#define ER_SYS_VAR_COMPONENT_OOM 11256 -#define ER_SYS_VAR_COMPONENT_VARIABLE_SET_READ_ONLY 11257 -#define ER_SYS_VAR_COMPONENT_UNKNOWN_VARIABLE_TYPE 11258 -#define ER_SYS_VAR_COMPONENT_FAILED_TO_PARSE_VARIABLE_OPTIONS 11259 -#define ER_SYS_VAR_COMPONENT_FAILED_TO_MAKE_VARIABLE_PERSISTENT 11260 -#define ER_COMPONENT_FILTER_CONFUSED 11261 -#define ER_STOP_SLAVE_IO_THREAD_DISK_SPACE 11262 -#define ER_LOG_FILE_CANNOT_OPEN 11263 -//#define OBSOLETE_ER_UNABLE_TO_COLLECT_LOG_STATUS 11264 -//#define OBSOLETE_ER_DEPRECATED_UTF8_ALIAS 11265 -//#define OBSOLETE_ER_DEPRECATED_NATIONAL 11266 -//#define OBSOLETE_ER_SLAVE_POSSIBLY_DIVERGED_AFTER_DDL 11267 -#define ER_PERSIST_OPTION_STATUS 11268 -#define ER_NOT_IMPLEMENTED_GET_TABLESPACE_STATISTICS 11269 -//#define OBSOLETE_ER_UNABLE_TO_SET_OPTION 11270 -//#define OBSOLETE_ER_RESERVED_TABLESPACE_NAME 11271 -#define ER_SSL_FIPS_MODE_ERROR 11272 -#define ER_CONN_INIT_CONNECT_IGNORED 11273 -//#define OBSOLETE_ER_UNSUPPORTED_SQL_MODE 11274 -#define ER_REWRITER_OOM 11275 -#define ER_REWRITER_TABLE_MALFORMED_ERROR 11276 -#define ER_REWRITER_LOAD_FAILED 11277 -#define ER_REWRITER_READ_FAILED 11278 -#define ER_CONN_CONTROL_EVENT_COORDINATOR_INIT_FAILED 11279 -#define ER_CONN_CONTROL_STAT_CONN_DELAY_TRIGGERED_UPDATE_FAILED 11280 -#define ER_CONN_CONTROL_STAT_CONN_DELAY_TRIGGERED_RESET_FAILED 11281 -#define ER_CONN_CONTROL_INVALID_CONN_DELAY_TYPE 11282 -#define ER_CONN_CONTROL_DELAY_ACTION_INIT_FAILED 11283 -#define ER_CONN_CONTROL_FAILED_TO_SET_CONN_DELAY 11284 -#define ER_CONN_CONTROL_FAILED_TO_UPDATE_CONN_DELAY_HASH 11285 -#define ER_XPLUGIN_FORCE_STOP_CLIENT 11286 -#define ER_XPLUGIN_MAX_AUTH_ATTEMPTS_REACHED 11287 -#define ER_XPLUGIN_BUFFER_PAGE_ALLOC_FAILED 11288 -#define ER_XPLUGIN_DETECTED_HANGING_CLIENTS 11289 -#define ER_XPLUGIN_FAILED_TO_ACCEPT_CLIENT 11290 -#define ER_XPLUGIN_FAILED_TO_SCHEDULE_CLIENT 11291 -#define ER_XPLUGIN_FAILED_TO_PREPARE_IO_INTERFACES 11292 -#define ER_XPLUGIN_SRV_SESSION_INIT_THREAD_FAILED 11293 -#define ER_XPLUGIN_UNABLE_TO_USE_USER_SESSION_ACCOUNT 11294 -#define ER_XPLUGIN_REFERENCE_TO_USER_ACCOUNT_DOC_SECTION 11295 -#define ER_XPLUGIN_UNEXPECTED_EXCEPTION_DISPATCHING_CMD 11296 -#define ER_XPLUGIN_EXCEPTION_IN_TASK_SCHEDULER 11297 -#define ER_XPLUGIN_TASK_SCHEDULING_FAILED 11298 -#define ER_XPLUGIN_EXCEPTION_IN_EVENT_LOOP 11299 -#define ER_XPLUGIN_LISTENER_SETUP_FAILED 11300 -#define ER_XPLUING_NET_STARTUP_FAILED 11301 -#define ER_XPLUGIN_FAILED_AT_SSL_CONF 11302 -//#define OBSOLETE_ER_XPLUGIN_CLIENT_SSL_HANDSHAKE_FAILED 11303 -//#define OBSOLETE_ER_XPLUGIN_SSL_HANDSHAKE_WITH_SERVER_FAILED 11304 -#define ER_XPLUGIN_FAILED_TO_CREATE_SESSION_FOR_CONN 11305 -#define ER_XPLUGIN_FAILED_TO_INITIALIZE_SESSION 11306 -#define ER_XPLUGIN_MESSAGE_TOO_LONG 11307 -#define ER_XPLUGIN_UNINITIALIZED_MESSAGE 11308 -#define ER_XPLUGIN_FAILED_TO_SET_MIN_NUMBER_OF_WORKERS 11309 -#define ER_XPLUGIN_UNABLE_TO_ACCEPT_CONNECTION 11310 -#define ER_XPLUGIN_ALL_IO_INTERFACES_DISABLED 11311 -//#define OBSOLETE_ER_XPLUGIN_INVALID_MSG_DURING_CLIENT_INIT 11312 -//#define OBSOLETE_ER_XPLUGIN_CLOSING_CLIENTS_ON_SHUTDOWN 11313 -#define ER_XPLUGIN_ERROR_READING_SOCKET 11314 -#define ER_XPLUGIN_PEER_DISCONNECTED_WHILE_READING_MSG_BODY 11315 -#define ER_XPLUGIN_READ_FAILED_CLOSING_CONNECTION 11316 -//#define OBSOLETE_ER_XPLUGIN_INVALID_AUTH_METHOD 11317 -//#define OBSOLETE_ER_XPLUGIN_UNEXPECTED_MSG_DURING_AUTHENTICATION 11318 -//#define OBSOLETE_ER_XPLUGIN_ERROR_WRITING_TO_CLIENT 11319 -//#define OBSOLETE_ER_XPLUGIN_SCHEDULER_STARTED 11320 -//#define OBSOLETE_ER_XPLUGIN_SCHEDULER_STOPPED 11321 -#define ER_XPLUGIN_LISTENER_SYS_VARIABLE_ERROR 11322 -#define ER_XPLUGIN_LISTENER_STATUS_MSG 11323 -#define ER_XPLUGIN_RETRYING_BIND_ON_PORT 11324 -//#define OBSOLETE_ER_XPLUGIN_SHUTDOWN_TRIGGERED 11325 -//#define OBSOLETE_ER_XPLUGIN_USER_ACCOUNT_WITH_ALL_PERMISSIONS 11326 -#define ER_XPLUGIN_EXISTING_USER_ACCOUNT_WITH_INCOMPLETE_GRANTS 11327 -//#define OBSOLETE_ER_XPLUGIN_SERVER_STARTS_HANDLING_CONNECTIONS 11328 -//#define OBSOLETE_ER_XPLUGIN_SERVER_STOPPED_HANDLING_CONNECTIONS 11329 -//#define OBSOLETE_ER_XPLUGIN_FAILED_TO_INTERRUPT_SESSION 11330 -//#define OBSOLETE_ER_XPLUGIN_CLIENT_RELEASE_TRIGGERED 11331 -#define ER_XPLUGIN_IPv6_AVAILABLE 11332 -//#define OBSOLETE_ER_XPLUGIN_UNIX_SOCKET_NOT_CONFIGURED 11333 -#define ER_XPLUGIN_CLIENT_KILL_MSG 11334 -#define ER_XPLUGIN_FAILED_TO_GET_SECURITY_CTX 11335 -//#define OBSOLETE_ER_XPLUGIN_FAILED_TO_SWITCH_SECURITY_CTX_TO_ROOT 11336 -#define ER_XPLUGIN_FAILED_TO_CLOSE_SQL_SESSION 11337 -#define ER_XPLUGIN_FAILED_TO_EXECUTE_ADMIN_CMD 11338 -#define ER_XPLUGIN_EMPTY_ADMIN_CMD 11339 -#define ER_XPLUGIN_FAILED_TO_GET_SYS_VAR 11340 -#define ER_XPLUGIN_FAILED_TO_GET_CREATION_STMT 11341 -#define ER_XPLUGIN_FAILED_TO_GET_ENGINE_INFO 11342 -//#define OBSOLETE_ER_XPLUGIN_FAIL_TO_GET_RESULT_DATA 11343 -//#define OBSOLETE_ER_XPLUGIN_CAPABILITY_EXPIRED_PASSWORD 11344 -#define ER_XPLUGIN_FAILED_TO_SET_SO_REUSEADDR_FLAG 11345 -#define ER_XPLUGIN_FAILED_TO_OPEN_INTERNAL_SESSION 11346 -#define ER_XPLUGIN_FAILED_TO_SWITCH_CONTEXT 11347 -#define ER_XPLUGIN_FAILED_TO_UNREGISTER_UDF 11348 -//#define OBSOLETE_ER_XPLUGIN_GET_PEER_ADDRESS_FAILED 11349 -//#define OBSOLETE_ER_XPLUGIN_CAPABILITY_CLIENT_INTERACTIVE_FAILED 11350 -#define ER_XPLUGIN_FAILED_TO_RESET_IPV6_V6ONLY_FLAG 11351 -#define ER_KEYRING_INVALID_KEY_TYPE 11352 -#define ER_KEYRING_INVALID_KEY_LENGTH 11353 -#define ER_KEYRING_FAILED_TO_CREATE_KEYRING_DIR 11354 -#define ER_KEYRING_FILE_INIT_FAILED 11355 -#define ER_KEYRING_INTERNAL_EXCEPTION_FAILED_FILE_INIT 11356 -#define ER_KEYRING_FAILED_TO_GENERATE_KEY 11357 -#define ER_KEYRING_CHECK_KEY_FAILED_DUE_TO_INVALID_KEY 11358 -#define ER_KEYRING_CHECK_KEY_FAILED_DUE_TO_EMPTY_KEY_ID 11359 -#define ER_KEYRING_OPERATION_FAILED_DUE_TO_INTERNAL_ERROR 11360 -#define ER_KEYRING_INCORRECT_FILE 11361 -#define ER_KEYRING_FOUND_MALFORMED_BACKUP_FILE 11362 -#define ER_KEYRING_FAILED_TO_RESTORE_FROM_BACKUP_FILE 11363 -#define ER_KEYRING_FAILED_TO_FLUSH_KEYRING_TO_FILE 11364 -#define ER_KEYRING_FAILED_TO_GET_FILE_STAT 11365 -#define ER_KEYRING_FAILED_TO_REMOVE_FILE 11366 -#define ER_KEYRING_FAILED_TO_TRUNCATE_FILE 11367 -#define ER_KEYRING_UNKNOWN_ERROR 11368 -#define ER_KEYRING_FAILED_TO_SET_KEYRING_FILE_DATA 11369 -#define ER_KEYRING_FILE_IO_ERROR 11370 -#define ER_KEYRING_FAILED_TO_LOAD_KEYRING_CONTENT 11371 -#define ER_KEYRING_FAILED_TO_FLUSH_KEYS_TO_KEYRING 11372 -#define ER_KEYRING_FAILED_TO_FLUSH_KEYS_TO_KEYRING_BACKUP 11373 -#define ER_KEYRING_KEY_FETCH_FAILED_DUE_TO_EMPTY_KEY_ID 11374 -#define ER_KEYRING_FAILED_TO_REMOVE_KEY_DUE_TO_EMPTY_ID 11375 -#define ER_KEYRING_OKV_INCORRECT_KEY_VAULT_CONFIGURED 11376 -#define ER_KEYRING_OKV_INIT_FAILED_DUE_TO_INCORRECT_CONF 11377 -#define ER_KEYRING_OKV_INIT_FAILED_DUE_TO_INTERNAL_ERROR 11378 -#define ER_KEYRING_OKV_INVALID_KEY_TYPE 11379 -#define ER_KEYRING_OKV_INVALID_KEY_LENGTH_FOR_CIPHER 11380 -#define ER_KEYRING_OKV_FAILED_TO_GENERATE_KEY_DUE_TO_INTERNAL_ERROR 11381 -#define ER_KEYRING_OKV_FAILED_TO_FIND_SERVER_ENTRY 11382 -#define ER_KEYRING_OKV_FAILED_TO_FIND_STANDBY_SERVER_ENTRY 11383 -#define ER_KEYRING_OKV_FAILED_TO_PARSE_CONF_FILE 11384 -#define ER_KEYRING_OKV_FAILED_TO_LOAD_KEY_UID 11385 -#define ER_KEYRING_OKV_FAILED_TO_INIT_SSL_LAYER 11386 -#define ER_KEYRING_OKV_FAILED_TO_INIT_CLIENT 11387 -#define ER_KEYRING_OKV_CONNECTION_TO_SERVER_FAILED 11388 -#define ER_KEYRING_OKV_FAILED_TO_REMOVE_KEY 11389 -#define ER_KEYRING_OKV_FAILED_TO_ADD_ATTRIBUTE 11390 -#define ER_KEYRING_OKV_FAILED_TO_GENERATE_KEY 11391 -#define ER_KEYRING_OKV_FAILED_TO_STORE_KEY 11392 -#define ER_KEYRING_OKV_FAILED_TO_ACTIVATE_KEYS 11393 -#define ER_KEYRING_OKV_FAILED_TO_FETCH_KEY 11394 -#define ER_KEYRING_OKV_FAILED_TO_STORE_OR_GENERATE_KEY 11395 -#define ER_KEYRING_OKV_FAILED_TO_RETRIEVE_KEY_SIGNATURE 11396 -#define ER_KEYRING_OKV_FAILED_TO_RETRIEVE_KEY 11397 -#define ER_KEYRING_OKV_FAILED_TO_LOAD_SSL_TRUST_STORE 11398 -#define ER_KEYRING_OKV_FAILED_TO_SET_CERTIFICATE_FILE 11399 -#define ER_KEYRING_OKV_FAILED_TO_SET_KEY_FILE 11400 -#define ER_KEYRING_OKV_KEY_MISMATCH 11401 -#define ER_KEYRING_ENCRYPTED_FILE_INCORRECT_KEYRING_FILE 11402 -#define ER_KEYRING_ENCRYPTED_FILE_DECRYPTION_FAILED 11403 -#define ER_KEYRING_ENCRYPTED_FILE_FOUND_MALFORMED_BACKUP_FILE 11404 -#define ER_KEYRING_ENCRYPTED_FILE_FAILED_TO_RESTORE_KEYRING 11405 -#define ER_KEYRING_ENCRYPTED_FILE_FAILED_TO_FLUSH_KEYRING 11406 -#define ER_KEYRING_ENCRYPTED_FILE_ENCRYPTION_FAILED 11407 -#define ER_KEYRING_ENCRYPTED_FILE_INVALID_KEYRING_DIR 11408 -#define ER_KEYRING_ENCRYPTED_FILE_FAILED_TO_CREATE_KEYRING_DIR 11409 -#define ER_KEYRING_ENCRYPTED_FILE_PASSWORD_IS_INVALID 11410 -#define ER_KEYRING_ENCRYPTED_FILE_PASSWORD_IS_TOO_LONG 11411 -#define ER_KEYRING_ENCRYPTED_FILE_INIT_FAILURE 11412 -#define ER_KEYRING_ENCRYPTED_FILE_INIT_FAILED_DUE_TO_INTERNAL_ERROR 11413 -#define ER_KEYRING_ENCRYPTED_FILE_GEN_KEY_FAILED_DUE_TO_INTERNAL_ERROR 11414 -#define ER_KEYRING_AWS_FAILED_TO_SET_CMK_ID 11415 -#define ER_KEYRING_AWS_FAILED_TO_SET_REGION 11416 -#define ER_KEYRING_AWS_FAILED_TO_OPEN_CONF_FILE 11417 -#define ER_KEYRING_AWS_FAILED_TO_ACCESS_KEY_ID_FROM_CONF_FILE 11418 -#define ER_KEYRING_AWS_FAILED_TO_ACCESS_KEY_FROM_CONF_FILE 11419 -#define ER_KEYRING_AWS_INVALID_CONF_FILE_PATH 11420 -#define ER_KEYRING_AWS_INVALID_DATA_FILE_PATH 11421 -#define ER_KEYRING_AWS_FAILED_TO_ACCESS_OR_CREATE_KEYRING_DIR 11422 -#define ER_KEYRING_AWS_FAILED_TO_ACCESS_OR_CREATE_KEYRING_DATA_FILE 11423 -#define ER_KEYRING_AWS_FAILED_TO_INIT_DUE_TO_INTERNAL_ERROR 11424 -#define ER_KEYRING_AWS_FAILED_TO_ACCESS_DATA_FILE 11425 -#define ER_KEYRING_AWS_CMK_ID_NOT_SET 11426 -#define ER_KEYRING_AWS_FAILED_TO_GET_KMS_CREDENTIAL_FROM_CONF_FILE 11427 -#define ER_KEYRING_AWS_INIT_FAILURE 11428 -#define ER_KEYRING_AWS_FAILED_TO_INIT_DUE_TO_PLUGIN_INTERNAL_ERROR 11429 -#define ER_KEYRING_AWS_INVALID_KEY_LENGTH_FOR_CIPHER 11430 -#define ER_KEYRING_AWS_FAILED_TO_GENERATE_KEY_DUE_TO_INTERNAL_ERROR 11431 -#define ER_KEYRING_AWS_INCORRECT_FILE 11432 -#define ER_KEYRING_AWS_FOUND_MALFORMED_BACKUP_FILE 11433 -#define ER_KEYRING_AWS_FAILED_TO_RESTORE_FROM_BACKUP_FILE 11434 -#define ER_KEYRING_AWS_FAILED_TO_FLUSH_KEYRING_TO_FILE 11435 -#define ER_KEYRING_AWS_INCORRECT_REGION 11436 -#define ER_KEYRING_AWS_FAILED_TO_CONNECT_KMS 11437 -#define ER_KEYRING_AWS_FAILED_TO_GENERATE_NEW_KEY 11438 -#define ER_KEYRING_AWS_FAILED_TO_ENCRYPT_KEY 11439 -#define ER_KEYRING_AWS_FAILED_TO_RE_ENCRYPT_KEY 11440 -#define ER_KEYRING_AWS_FAILED_TO_DECRYPT_KEY 11441 -#define ER_KEYRING_AWS_FAILED_TO_ROTATE_CMK 11442 -#define ER_GRP_RPL_GTID_ALREADY_USED 11443 -#define ER_GRP_RPL_APPLIER_THD_KILLED 11444 -#define ER_GRP_RPL_EVENT_HANDLING_ERROR 11445 -#define ER_GRP_RPL_ERROR_GTID_EXECUTION_INFO 11446 -#define ER_GRP_RPL_CERTIFICATE_SIZE_ERROR 11447 -#define ER_GRP_RPL_CREATE_APPLIER_CACHE_ERROR 11448 -#define ER_GRP_RPL_UNBLOCK_WAITING_THD 11449 -#define ER_GRP_RPL_APPLIER_PIPELINE_NOT_DISPOSED 11450 -#define ER_GRP_RPL_APPLIER_THD_EXECUTION_ABORTED 11451 -#define ER_GRP_RPL_APPLIER_EXECUTION_FATAL_ERROR 11452 -#define ER_GRP_RPL_ERROR_STOPPING_CHANNELS 11453 -#define ER_GRP_RPL_ERROR_SENDING_SINGLE_PRIMARY_MSSG 11454 -#define ER_GRP_RPL_UPDATE_TRANS_SNAPSHOT_VER_ERROR 11455 -#define ER_GRP_RPL_SIDNO_FETCH_ERROR 11456 -#define ER_GRP_RPL_BROADCAST_COMMIT_TRANS_MSSG_FAILED 11457 -#define ER_GRP_RPL_GROUP_NAME_PARSE_ERROR 11458 -#define ER_GRP_RPL_ADD_GRPSID_TO_GRPGTIDSID_MAP_ERROR 11459 -#define ER_GRP_RPL_UPDATE_GRPGTID_EXECUTED_ERROR 11460 -#define ER_GRP_RPL_DONOR_TRANS_INFO_ERROR 11461 -#define ER_GRP_RPL_SERVER_CONN_ERROR 11462 -#define ER_GRP_RPL_ERROR_FETCHING_GTID_EXECUTED_SET 11463 -#define ER_GRP_RPL_ADD_GTID_TO_GRPGTID_EXECUTED_ERROR 11464 -#define ER_GRP_RPL_ERROR_FETCHING_GTID_SET 11465 -#define ER_GRP_RPL_ADD_RETRIEVED_SET_TO_GRP_GTID_EXECUTED_ERROR 11466 -#define ER_GRP_RPL_CERTIFICATION_INITIALIZATION_FAILURE 11467 -#define ER_GRP_RPL_UPDATE_LAST_CONFLICT_FREE_TRANS_ERROR 11468 -#define ER_GRP_RPL_UPDATE_TRANS_SNAPSHOT_REF_VER_ERROR 11469 -#define ER_GRP_RPL_FETCH_TRANS_SIDNO_ERROR 11470 -#define ER_GRP_RPL_ERROR_VERIFYING_SIDNO 11471 -#define ER_GRP_RPL_CANT_GENERATE_GTID 11472 -#define ER_GRP_RPL_INVALID_GTID_SET 11473 -#define ER_GRP_RPL_UPDATE_GTID_SET_ERROR 11474 -#define ER_GRP_RPL_RECEIVED_SET_MISSING_GTIDS 11475 -#define ER_GRP_RPL_SKIP_COMPUTATION_TRANS_COMMITTED 11476 -#define ER_GRP_RPL_NULL_PACKET 11477 -#define ER_GRP_RPL_CANT_READ_GTID 11478 -#define ER_GRP_RPL_PROCESS_GTID_SET_ERROR 11479 -#define ER_GRP_RPL_PROCESS_INTERSECTION_GTID_SET_ERROR 11480 -#define ER_GRP_RPL_SET_STABLE_TRANS_ERROR 11481 -#define ER_GRP_RPL_CANT_READ_GRP_GTID_EXTRACTED 11482 -#define ER_GRP_RPL_CANT_READ_WRITE_SET_ITEM 11483 -#define ER_GRP_RPL_INIT_CERTIFICATION_INFO_FAILURE 11484 -#define ER_GRP_RPL_CONFLICT_DETECTION_DISABLED 11485 -#define ER_GRP_RPL_MSG_DISCARDED 11486 -#define ER_GRP_RPL_MISSING_GRP_RPL_APPLIER 11487 -#define ER_GRP_RPL_CERTIFIER_MSSG_PROCESS_ERROR 11488 -#define ER_GRP_RPL_SRV_NOT_ONLINE 11489 -#define ER_GRP_RPL_SRV_ONLINE 11490 -#define ER_GRP_RPL_DISABLE_SRV_READ_MODE_RESTRICTED 11491 -#define ER_GRP_RPL_MEM_ONLINE 11492 -#define ER_GRP_RPL_MEM_UNREACHABLE 11493 -#define ER_GRP_RPL_MEM_REACHABLE 11494 -#define ER_GRP_RPL_SRV_BLOCKED 11495 -#define ER_GRP_RPL_SRV_BLOCKED_FOR_SECS 11496 -#define ER_GRP_RPL_CHANGE_GRP_MEM_NOT_PROCESSED 11497 -#define ER_GRP_RPL_MEMBER_CONTACT_RESTORED 11498 -#define ER_GRP_RPL_MEMBER_REMOVED 11499 -#define ER_GRP_RPL_PRIMARY_MEMBER_LEFT_GRP 11500 -#define ER_GRP_RPL_MEMBER_ADDED 11501 -#define ER_GRP_RPL_MEMBER_EXIT_PLUGIN_ERROR 11502 -#define ER_GRP_RPL_MEMBER_CHANGE 11503 -#define ER_GRP_RPL_MEMBER_LEFT_GRP 11504 -#define ER_GRP_RPL_MEMBER_EXPELLED 11505 -#define ER_GRP_RPL_SESSION_OPEN_FAILED 11506 -#define ER_GRP_RPL_NEW_PRIMARY_ELECTED 11507 -#define ER_GRP_RPL_DISABLE_READ_ONLY_FAILED 11508 -#define ER_GRP_RPL_ENABLE_READ_ONLY_FAILED 11509 -#define ER_GRP_RPL_SRV_PRIMARY_MEM 11510 -#define ER_GRP_RPL_SRV_SECONDARY_MEM 11511 -#define ER_GRP_RPL_NO_SUITABLE_PRIMARY_MEM 11512 -#define ER_GRP_RPL_SUPER_READ_ONLY_ACTIVATE_ERROR 11513 -#define ER_GRP_RPL_EXCEEDS_AUTO_INC_VALUE 11514 -#define ER_GRP_RPL_DATA_NOT_PROVIDED_BY_MEM 11515 -#define ER_GRP_RPL_MEMBER_ALREADY_EXISTS 11516 -#define ER_GRP_RPL_GRP_CHANGE_INFO_EXTRACT_ERROR 11517 -#define ER_GRP_RPL_GTID_EXECUTED_EXTRACT_ERROR 11518 -#define ER_GRP_RPL_GTID_SET_EXTRACT_ERROR 11519 -#define ER_GRP_RPL_START_FAILED 11520 -#define ER_GRP_RPL_MEMBER_VER_INCOMPATIBLE 11521 -#define ER_GRP_RPL_TRANS_NOT_PRESENT_IN_GRP 11522 -#define ER_GRP_RPL_TRANS_GREATER_THAN_GRP 11523 -#define ER_GRP_RPL_MEMBER_VERSION_LOWER_THAN_GRP 11524 -#define ER_GRP_RPL_LOCAL_GTID_SETS_PROCESS_ERROR 11525 -#define ER_GRP_RPL_MEMBER_TRANS_GREATER_THAN_GRP 11526 -#define ER_GRP_RPL_BLOCK_SIZE_DIFF_FROM_GRP 11527 -#define ER_GRP_RPL_TRANS_WRITE_SET_EXTRACT_DIFF_FROM_GRP 11528 -#define ER_GRP_RPL_MEMBER_CFG_INCOMPATIBLE_WITH_GRP_CFG 11529 -#define ER_GRP_RPL_MEMBER_STOP_RPL_CHANNELS_ERROR 11530 -#define ER_GRP_RPL_PURGE_APPLIER_LOGS 11531 -#define ER_GRP_RPL_RESET_APPLIER_MODULE_LOGS_ERROR 11532 -#define ER_GRP_RPL_APPLIER_THD_SETUP_ERROR 11533 -#define ER_GRP_RPL_APPLIER_THD_START_ERROR 11534 -#define ER_GRP_RPL_APPLIER_THD_STOP_ERROR 11535 -#define ER_GRP_RPL_FETCH_TRANS_DATA_FAILED 11536 -#define ER_GRP_RPL_SLAVE_IO_THD_PRIMARY_UNKNOWN 11537 -#define ER_GRP_RPL_SALVE_IO_THD_ON_SECONDARY_MEMBER 11538 -#define ER_GRP_RPL_SLAVE_SQL_THD_PRIMARY_UNKNOWN 11539 -#define ER_GRP_RPL_SLAVE_SQL_THD_ON_SECONDARY_MEMBER 11540 -#define ER_GRP_RPL_NEEDS_INNODB_TABLE 11541 -#define ER_GRP_RPL_PRIMARY_KEY_NOT_DEFINED 11542 -#define ER_GRP_RPL_FK_WITH_CASCADE_UNSUPPORTED 11543 -#define ER_GRP_RPL_AUTO_INC_RESET 11544 -#define ER_GRP_RPL_AUTO_INC_OFFSET_RESET 11545 -#define ER_GRP_RPL_AUTO_INC_SET 11546 -#define ER_GRP_RPL_AUTO_INC_OFFSET_SET 11547 -#define ER_GRP_RPL_FETCH_TRANS_CONTEXT_FAILED 11548 -#define ER_GRP_RPL_FETCH_FORMAT_DESC_LOG_EVENT_FAILED 11549 -#define ER_GRP_RPL_FETCH_TRANS_CONTEXT_LOG_EVENT_FAILED 11550 -#define ER_GRP_RPL_FETCH_SNAPSHOT_VERSION_FAILED 11551 -#define ER_GRP_RPL_FETCH_GTID_LOG_EVENT_FAILED 11552 -#define ER_GRP_RPL_UPDATE_SERV_CERTIFICATE_FAILED 11553 -#define ER_GRP_RPL_ADD_GTID_INFO_WITH_LOCAL_GTID_FAILED 11554 -#define ER_GRP_RPL_ADD_GTID_INFO_WITHOUT_LOCAL_GTID_FAILED 11555 -#define ER_GRP_RPL_NOTIFY_CERTIFICATION_OUTCOME_FAILED 11556 -#define ER_GRP_RPL_ADD_GTID_INFO_WITH_REMOTE_GTID_FAILED 11557 -#define ER_GRP_RPL_ADD_GTID_INFO_WITHOUT_REMOTE_GTID_FAILED 11558 -#define ER_GRP_RPL_FETCH_VIEW_CHANGE_LOG_EVENT_FAILED 11559 -#define ER_GRP_RPL_CONTACT_WITH_SRV_FAILED 11560 -#define ER_GRP_RPL_SRV_WAIT_TIME_OUT 11561 -#define ER_GRP_RPL_FETCH_LOG_EVENT_FAILED 11562 -#define ER_GRP_RPL_START_GRP_RPL_FAILED 11563 -#define ER_GRP_RPL_CONN_INTERNAL_PLUGIN_FAIL 11564 -#define ER_GRP_RPL_SUPER_READ_ON 11565 -#define ER_GRP_RPL_SUPER_READ_OFF 11566 -#define ER_GRP_RPL_KILLED_SESSION_ID 11567 -#define ER_GRP_RPL_KILLED_FAILED_ID 11568 -#define ER_GRP_RPL_INTERNAL_QUERY 11569 -#define ER_GRP_RPL_COPY_FROM_EMPTY_STRING 11570 -#define ER_GRP_RPL_QUERY_FAIL 11571 -#define ER_GRP_RPL_CREATE_SESSION_UNABLE 11572 -#define ER_GRP_RPL_MEMBER_NOT_FOUND 11573 -#define ER_GRP_RPL_MAXIMUM_CONNECTION_RETRIES_REACHED 11574 -#define ER_GRP_RPL_ALL_DONORS_LEFT_ABORT_RECOVERY 11575 -#define ER_GRP_RPL_ESTABLISH_RECOVERY_WITH_DONOR 11576 -#define ER_GRP_RPL_ESTABLISH_RECOVERY_WITH_ANOTHER_DONOR 11577 -#define ER_GRP_RPL_NO_VALID_DONOR 11578 -#define ER_GRP_RPL_CONFIG_RECOVERY 11579 -#define ER_GRP_RPL_ESTABLISHING_CONN_GRP_REC_DONOR 11580 -#define ER_GRP_RPL_CREATE_GRP_RPL_REC_CHANNEL 11581 -#define ER_GRP_RPL_DONOR_SERVER_CONN 11582 -#define ER_GRP_RPL_CHECK_STATUS_TABLE 11583 -#define ER_GRP_RPL_STARTING_GRP_REC 11584 -#define ER_GRP_RPL_DONOR_CONN_TERMINATION 11585 -#define ER_GRP_RPL_STOPPING_GRP_REC 11586 -#define ER_GRP_RPL_PURGE_REC 11587 -#define ER_GRP_RPL_UNABLE_TO_KILL_CONN_REC_DONOR_APPLIER 11588 -#define ER_GRP_RPL_UNABLE_TO_KILL_CONN_REC_DONOR_FAILOVER 11589 -#define ER_GRP_RPL_FAILED_TO_NOTIFY_GRP_MEMBERSHIP_EVENT 11590 -#define ER_GRP_RPL_FAILED_TO_BROADCAST_GRP_MEMBERSHIP_NOTIFICATION 11591 -#define ER_GRP_RPL_FAILED_TO_BROADCAST_MEMBER_STATUS_NOTIFICATION 11592 -#define ER_GRP_RPL_OOM_FAILED_TO_GENERATE_IDENTIFICATION_HASH 11593 -#define ER_GRP_RPL_WRITE_IDENT_HASH_BASE64_ENCODING_FAILED 11594 -#define ER_GRP_RPL_INVALID_BINLOG_FORMAT 11595 -#define ER_GRP_RPL_BINLOG_CHECKSUM_SET 11596 -#define ER_GRP_RPL_TRANS_WRITE_SET_EXTRACTION_NOT_SET 11597 -#define ER_GRP_RPL_UNSUPPORTED_TRANS_ISOLATION 11598 -#define ER_GRP_RPL_CANNOT_EXECUTE_TRANS_WHILE_STOPPING 11599 -#define ER_GRP_RPL_CANNOT_EXECUTE_TRANS_WHILE_RECOVERING 11600 -#define ER_GRP_RPL_CANNOT_EXECUTE_TRANS_IN_ERROR_STATE 11601 -#define ER_GRP_RPL_CANNOT_EXECUTE_TRANS_IN_OFFLINE_MODE 11602 -#define ER_GRP_RPL_MULTIPLE_CACHE_TYPE_NOT_SUPPORTED_FOR_SESSION 11603 -#define ER_GRP_RPL_FAILED_TO_REINIT_BINLOG_CACHE_FOR_READ 11604 -#define ER_GRP_RPL_FAILED_TO_CREATE_TRANS_CONTEXT 11605 -#define ER_GRP_RPL_FAILED_TO_EXTRACT_TRANS_WRITE_SET 11606 -#define ER_GRP_RPL_FAILED_TO_GATHER_TRANS_WRITE_SET 11607 -#define ER_GRP_RPL_TRANS_SIZE_EXCEEDS_LIMIT 11608 -//#define OBSOLETE_ER_GRP_RPL_REINIT_OF_INTERNAL_CACHE_FOR_READ_FAILED 11609 -//#define OBSOLETE_ER_GRP_RPL_APPENDING_DATA_TO_INTERNAL_CACHE_FAILED 11610 -#define ER_GRP_RPL_WRITE_TO_TRANSACTION_MESSAGE_FAILED 11611 -#define ER_GRP_RPL_FAILED_TO_REGISTER_TRANS_OUTCOME_NOTIFICTION 11612 -#define ER_GRP_RPL_MSG_TOO_LONG_BROADCASTING_TRANS_FAILED 11613 -#define ER_GRP_RPL_BROADCASTING_TRANS_TO_GRP_FAILED 11614 -#define ER_GRP_RPL_ERROR_WHILE_WAITING_FOR_CONFLICT_DETECTION 11615 -//#define OBSOLETE_ER_GRP_RPL_REINIT_OF_INTERNAL_CACHE_FOR_WRITE_FAILED 11616 -//#define OBSOLETE_ER_GRP_RPL_FAILED_TO_CREATE_COMMIT_CACHE 11617 -//#define OBSOLETE_ER_GRP_RPL_REINIT_OF_COMMIT_CACHE_FOR_WRITE_FAILED 11618 -#define ER_GRP_RPL_PREV_REC_SESSION_RUNNING 11619 -#define ER_GRP_RPL_FATAL_REC_PROCESS 11620 -#define ER_GRP_RPL_WHILE_STOPPING_REP_CHANNEL 11621 -#define ER_GRP_RPL_UNABLE_TO_EVALUATE_APPLIER_STATUS 11622 -#define ER_GRP_RPL_ONLY_ONE_SERVER_ALIVE 11623 -#define ER_GRP_RPL_CERTIFICATION_REC_PROCESS 11624 -#define ER_GRP_RPL_UNABLE_TO_ENSURE_EXECUTION_REC 11625 -#define ER_GRP_RPL_WHILE_SENDING_MSG_REC 11626 -#define ER_GRP_RPL_READ_UNABLE_FOR_SUPER_READ_ONLY 11627 -#define ER_GRP_RPL_READ_UNABLE_FOR_READ_ONLY_SUPER_READ_ONLY 11628 -#define ER_GRP_RPL_UNABLE_TO_RESET_SERVER_READ_MODE 11629 -#define ER_GRP_RPL_UNABLE_TO_CERTIFY_PLUGIN_TRANS 11630 -#define ER_GRP_RPL_UNBLOCK_CERTIFIED_TRANS 11631 -#define ER_GRP_RPL_SERVER_WORKING_AS_SECONDARY 11632 -#define ER_GRP_RPL_FAILED_TO_START_WITH_INVALID_SERVER_ID 11633 -#define ER_GRP_RPL_FORCE_MEMBERS_MUST_BE_EMPTY 11634 -#define ER_GRP_RPL_PLUGIN_STRUCT_INIT_NOT_POSSIBLE_ON_SERVER_START 11635 -#define ER_GRP_RPL_FAILED_TO_ENABLE_SUPER_READ_ONLY_MODE 11636 -#define ER_GRP_RPL_FAILED_TO_INIT_COMMUNICATION_ENGINE 11637 -#define ER_GRP_RPL_FAILED_TO_START_ON_SECONDARY_WITH_ASYNC_CHANNELS 11638 -#define ER_GRP_RPL_FAILED_TO_START_COMMUNICATION_ENGINE 11639 -#define ER_GRP_RPL_TIMEOUT_ON_VIEW_AFTER_JOINING_GRP 11640 -#define ER_GRP_RPL_FAILED_TO_CALL_GRP_COMMUNICATION_INTERFACE 11641 -#define ER_GRP_RPL_MEMBER_SERVER_UUID_IS_INCOMPATIBLE_WITH_GRP 11642 -#define ER_GRP_RPL_MEMBER_CONF_INFO 11643 -#define ER_GRP_RPL_FAILED_TO_CONFIRM_IF_SERVER_LEFT_GRP 11644 -#define ER_GRP_RPL_SERVER_IS_ALREADY_LEAVING 11645 -#define ER_GRP_RPL_SERVER_ALREADY_LEFT 11646 -#define ER_GRP_RPL_WAITING_FOR_VIEW_UPDATE 11647 -#define ER_GRP_RPL_TIMEOUT_RECEIVING_VIEW_CHANGE_ON_SHUTDOWN 11648 -#define ER_GRP_RPL_REQUESTING_NON_MEMBER_SERVER_TO_LEAVE 11649 -#define ER_GRP_RPL_IS_STOPPING 11650 -#define ER_GRP_RPL_IS_STOPPED 11651 -#define ER_GRP_RPL_FAILED_TO_ENABLE_READ_ONLY_MODE_ON_SHUTDOWN 11652 -#define ER_GRP_RPL_RECOVERY_MODULE_TERMINATION_TIMED_OUT_ON_SHUTDOWN 11653 -#define ER_GRP_RPL_APPLIER_TERMINATION_TIMED_OUT_ON_SHUTDOWN 11654 -#define ER_GRP_RPL_FAILED_TO_SHUTDOWN_REGISTRY_MODULE 11655 -#define ER_GRP_RPL_FAILED_TO_INIT_HANDLER 11656 -#define ER_GRP_RPL_FAILED_TO_REGISTER_SERVER_STATE_OBSERVER 11657 -#define ER_GRP_RPL_FAILED_TO_REGISTER_TRANS_STATE_OBSERVER 11658 -#define ER_GRP_RPL_FAILED_TO_REGISTER_BINLOG_STATE_OBSERVER 11659 -#define ER_GRP_RPL_FAILED_TO_START_ON_BOOT 11660 -#define ER_GRP_RPL_FAILED_TO_STOP_ON_PLUGIN_UNINSTALL 11661 -#define ER_GRP_RPL_FAILED_TO_UNREGISTER_SERVER_STATE_OBSERVER 11662 -#define ER_GRP_RPL_FAILED_TO_UNREGISTER_TRANS_STATE_OBSERVER 11663 -#define ER_GRP_RPL_FAILED_TO_UNREGISTER_BINLOG_STATE_OBSERVER 11664 -#define ER_GRP_RPL_ALL_OBSERVERS_UNREGISTERED 11665 -#define ER_GRP_RPL_FAILED_TO_PARSE_THE_GRP_NAME 11666 -#define ER_GRP_RPL_FAILED_TO_GENERATE_SIDNO_FOR_GRP 11667 -#define ER_GRP_RPL_APPLIER_NOT_STARTED_DUE_TO_RUNNING_PREV_SHUTDOWN 11668 -#define ER_GRP_RPL_FAILED_TO_INIT_APPLIER_MODULE 11669 -#define ER_GRP_RPL_APPLIER_INITIALIZED 11670 -#define ER_GRP_RPL_COMMUNICATION_SSL_CONF_INFO 11671 -#define ER_GRP_RPL_ABORTS_AS_SSL_NOT_SUPPORTED_BY_MYSQLD 11672 -#define ER_GRP_RPL_SSL_DISABLED 11673 -#define ER_GRP_RPL_UNABLE_TO_INIT_COMMUNICATION_ENGINE 11674 -#define ER_GRP_RPL_BINLOG_DISABLED 11675 -#define ER_GRP_RPL_GTID_MODE_OFF 11676 -#define ER_GRP_RPL_LOG_SLAVE_UPDATES_NOT_SET 11677 -#define ER_GRP_RPL_INVALID_TRANS_WRITE_SET_EXTRACTION_VALUE 11678 -#define ER_GRP_RPL_RELAY_LOG_INFO_REPO_MUST_BE_TABLE 11679 -#define ER_GRP_RPL_MASTER_INFO_REPO_MUST_BE_TABLE 11680 -#define ER_GRP_RPL_INCORRECT_TYPE_SET_FOR_PARALLEL_APPLIER 11681 -#define ER_GRP_RPL_SLAVE_PRESERVE_COMMIT_ORDER_NOT_SET 11682 -#define ER_GRP_RPL_SINGLE_PRIM_MODE_NOT_ALLOWED_WITH_UPDATE_EVERYWHERE 11683 -#define ER_GRP_RPL_MODULE_TERMINATE_ERROR 11684 -#define ER_GRP_RPL_GRP_NAME_OPTION_MANDATORY 11685 -#define ER_GRP_RPL_GRP_NAME_IS_TOO_LONG 11686 -#define ER_GRP_RPL_GRP_NAME_IS_NOT_VALID_UUID 11687 -#define ER_GRP_RPL_FLOW_CTRL_MIN_QUOTA_GREATER_THAN_MAX_QUOTA 11688 -#define ER_GRP_RPL_FLOW_CTRL_MIN_RECOVERY_QUOTA_GREATER_THAN_MAX_QUOTA 11689 -#define ER_GRP_RPL_FLOW_CTRL_MAX_QUOTA_SMALLER_THAN_MIN_QUOTAS 11690 -#define ER_GRP_RPL_INVALID_SSL_RECOVERY_STRING 11691 -#define ER_GRP_RPL_SUPPORTS_ONLY_ONE_FORCE_MEMBERS_SET 11692 -#define ER_GRP_RPL_FORCE_MEMBERS_SET_UPDATE_NOT_ALLOWED 11693 -#define ER_GRP_RPL_GRP_COMMUNICATION_INIT_WITH_CONF 11694 -#define ER_GRP_RPL_UNKNOWN_GRP_RPL_APPLIER_PIPELINE_REQUESTED 11695 -#define ER_GRP_RPL_FAILED_TO_BOOTSTRAP_EVENT_HANDLING_INFRASTRUCTURE 11696 -#define ER_GRP_RPL_APPLIER_HANDLER_NOT_INITIALIZED 11697 -#define ER_GRP_RPL_APPLIER_HANDLER_IS_IN_USE 11698 -#define ER_GRP_RPL_APPLIER_HANDLER_ROLE_IS_IN_USE 11699 -#define ER_GRP_RPL_FAILED_TO_INIT_APPLIER_HANDLER 11700 -#define ER_GRP_RPL_SQL_SERVICE_FAILED_TO_INIT_SESSION_THREAD 11701 -#define ER_GRP_RPL_SQL_SERVICE_COMM_SESSION_NOT_INITIALIZED 11702 -#define ER_GRP_RPL_SQL_SERVICE_SERVER_SESSION_KILLED 11703 -#define ER_GRP_RPL_SQL_SERVICE_FAILED_TO_RUN_SQL_QUERY 11704 -#define ER_GRP_RPL_SQL_SERVICE_SERVER_INTERNAL_FAILURE 11705 -#define ER_GRP_RPL_SQL_SERVICE_RETRIES_EXCEEDED_ON_SESSION_STATE 11706 -#define ER_GRP_RPL_SQL_SERVICE_FAILED_TO_FETCH_SECURITY_CTX 11707 -#define ER_GRP_RPL_SQL_SERVICE_SERVER_ACCESS_DENIED_FOR_USER 11708 -#define ER_GRP_RPL_SQL_SERVICE_MAX_CONN_ERROR_FROM_SERVER 11709 -#define ER_GRP_RPL_SQL_SERVICE_SERVER_ERROR_ON_CONN 11710 -#define ER_GRP_RPL_UNREACHABLE_MAJORITY_TIMEOUT_FOR_MEMBER 11711 -#define ER_GRP_RPL_SERVER_SET_TO_READ_ONLY_DUE_TO_ERRORS 11712 -#define ER_GRP_RPL_GMS_LISTENER_FAILED_TO_LOG_NOTIFICATION 11713 -#define ER_GRP_RPL_GRP_COMMUNICATION_ENG_INIT_FAILED 11714 -#define ER_GRP_RPL_SET_GRP_COMMUNICATION_ENG_LOGGER_FAILED 11715 -#define ER_GRP_RPL_DEBUG_OPTIONS 11716 -#define ER_GRP_RPL_INVALID_DEBUG_OPTIONS 11717 -#define ER_GRP_RPL_EXIT_GRP_GCS_ERROR 11718 -#define ER_GRP_RPL_GRP_MEMBER_OFFLINE 11719 -#define ER_GRP_RPL_GCS_INTERFACE_ERROR 11720 -#define ER_GRP_RPL_FORCE_MEMBER_VALUE_SET_ERROR 11721 -#define ER_GRP_RPL_FORCE_MEMBER_VALUE_SET 11722 -#define ER_GRP_RPL_FORCE_MEMBER_VALUE_TIME_OUT 11723 -#define ER_GRP_RPL_BROADCAST_COMMIT_MSSG_TOO_BIG 11724 -#define ER_GRP_RPL_SEND_STATS_ERROR 11725 -#define ER_GRP_RPL_MEMBER_STATS_INFO 11726 -#define ER_GRP_RPL_FLOW_CONTROL_STATS 11727 -#define ER_GRP_RPL_UNABLE_TO_CONVERT_PACKET_TO_EVENT 11728 -#define ER_GRP_RPL_PIPELINE_CREATE_FAILED 11729 -#define ER_GRP_RPL_PIPELINE_REINIT_FAILED_WRITE 11730 -#define ER_GRP_RPL_UNABLE_TO_CONVERT_EVENT_TO_PACKET 11731 -#define ER_GRP_RPL_PIPELINE_FLUSH_FAIL 11732 -#define ER_GRP_RPL_PIPELINE_REINIT_FAILED_READ 11733 -#define ER_GRP_RPL_STOP_REP_CHANNEL 11734 -#define ER_GRP_RPL_GCS_GR_ERROR_MSG 11735 -#define ER_GRP_RPL_SLAVE_IO_THREAD_UNBLOCKED 11736 -#define ER_GRP_RPL_SLAVE_IO_THREAD_ERROR_OUT 11737 -#define ER_GRP_RPL_SLAVE_APPLIER_THREAD_UNBLOCKED 11738 -#define ER_GRP_RPL_SLAVE_APPLIER_THREAD_ERROR_OUT 11739 -#define ER_LDAP_AUTH_FAILED_TO_CREATE_OR_GET_CONNECTION 11740 -#define ER_LDAP_AUTH_DEINIT_FAILED 11741 -#define ER_LDAP_AUTH_SKIPPING_USER_GROUP_SEARCH 11742 -#define ER_LDAP_AUTH_POOL_DISABLE_MAX_SIZE_ZERO 11743 -#define ER_LDAP_AUTH_FAILED_TO_CREATE_LDAP_OBJECT_CREATOR 11744 -#define ER_LDAP_AUTH_FAILED_TO_CREATE_LDAP_OBJECT 11745 -#define ER_LDAP_AUTH_TLS_CONF 11746 -#define ER_LDAP_AUTH_TLS_CONNECTION 11747 -#define ER_LDAP_AUTH_CONN_POOL_NOT_CREATED 11748 -#define ER_LDAP_AUTH_CONN_POOL_INITIALIZING 11749 -#define ER_LDAP_AUTH_CONN_POOL_DEINITIALIZING 11750 -#define ER_LDAP_AUTH_ZERO_MAX_POOL_SIZE_UNCHANGED 11751 -#define ER_LDAP_AUTH_POOL_REINITIALIZING 11752 -#define ER_LDAP_AUTH_FAILED_TO_WRITE_PACKET 11753 -#define ER_LDAP_AUTH_SETTING_USERNAME 11754 -#define ER_LDAP_AUTH_USER_AUTH_DATA 11755 -#define ER_LDAP_AUTH_INFO_FOR_USER 11756 -#define ER_LDAP_AUTH_USER_GROUP_SEARCH_INFO 11757 -#define ER_LDAP_AUTH_GRP_SEARCH_SPECIAL_HDL 11758 -#define ER_LDAP_AUTH_GRP_IS_FULL_DN 11759 -#define ER_LDAP_AUTH_USER_NOT_FOUND_IN_ANY_GRP 11760 -#define ER_LDAP_AUTH_USER_FOUND_IN_MANY_GRPS 11761 -#define ER_LDAP_AUTH_USER_HAS_MULTIPLE_GRP_NAMES 11762 -#define ER_LDAP_AUTH_SEARCHED_USER_GRP_NAME 11763 -#define ER_LDAP_AUTH_OBJECT_CREATE_TIMESTAMP 11764 -#define ER_LDAP_AUTH_CERTIFICATE_NAME 11765 -#define ER_LDAP_AUTH_FAILED_TO_POOL_DEINIT 11766 -#define ER_LDAP_AUTH_FAILED_TO_INITIALIZE_POOL_IN_RECONSTRUCTING 11767 -#define ER_LDAP_AUTH_FAILED_TO_INITIALIZE_POOL_IN_INIT_STATE 11768 -#define ER_LDAP_AUTH_FAILED_TO_INITIALIZE_POOL_IN_DEINIT_STATE 11769 -#define ER_LDAP_AUTH_FAILED_TO_DEINITIALIZE_POOL_IN_RECONSTRUCT_STATE 11770 -#define ER_LDAP_AUTH_FAILED_TO_DEINITIALIZE_NOT_READY_POOL 11771 -#define ER_LDAP_AUTH_FAILED_TO_GET_CONNECTION_AS_PLUGIN_NOT_READY 11772 -#define ER_LDAP_AUTH_CONNECTION_POOL_INIT_FAILED 11773 -#define ER_LDAP_AUTH_MAX_ALLOWED_CONNECTION_LIMIT_HIT 11774 -#define ER_LDAP_AUTH_MAX_POOL_SIZE_SET_FAILED 11775 -#define ER_LDAP_AUTH_PLUGIN_FAILED_TO_READ_PACKET 11776 -#define ER_LDAP_AUTH_CREATING_LDAP_CONNECTION 11777 -#define ER_LDAP_AUTH_GETTING_CONNECTION_FROM_POOL 11778 -#define ER_LDAP_AUTH_RETURNING_CONNECTION_TO_POOL 11779 -#define ER_LDAP_AUTH_SEARCH_USER_GROUP_ATTR_NOT_FOUND 11780 -#define ER_LDAP_AUTH_LDAP_INFO_NULL 11781 -#define ER_LDAP_AUTH_FREEING_CONNECTION 11782 -#define ER_LDAP_AUTH_CONNECTION_PUSHED_TO_POOL 11783 -#define ER_LDAP_AUTH_CONNECTION_CREATOR_ENTER 11784 -#define ER_LDAP_AUTH_STARTING_TLS 11785 -#define ER_LDAP_AUTH_CONNECTION_GET_LDAP_INFO_NULL 11786 -#define ER_LDAP_AUTH_DELETING_CONNECTION_KEY 11787 -#define ER_LDAP_AUTH_POOLED_CONNECTION_KEY 11788 -#define ER_LDAP_AUTH_CREATE_CONNECTION_KEY 11789 -#define ER_LDAP_AUTH_COMMUNICATION_HOST_INFO 11790 -#define ER_LDAP_AUTH_METHOD_TO_CLIENT 11791 -#define ER_LDAP_AUTH_SASL_REQUEST_FROM_CLIENT 11792 -#define ER_LDAP_AUTH_SASL_PROCESS_SASL 11793 -#define ER_LDAP_AUTH_SASL_BIND_SUCCESS_INFO 11794 -#define ER_LDAP_AUTH_STARTED_FOR_USER 11795 -#define ER_LDAP_AUTH_DISTINGUISHED_NAME 11796 -#define ER_LDAP_AUTH_INIT_FAILED 11797 -#define ER_LDAP_AUTH_OR_GROUP_RETRIEVAL_FAILED 11798 -#define ER_LDAP_AUTH_USER_GROUP_SEARCH_FAILED 11799 -#define ER_LDAP_AUTH_USER_BIND_FAILED 11800 -#define ER_LDAP_AUTH_POOL_GET_FAILED_TO_CREATE_CONNECTION 11801 -#define ER_LDAP_AUTH_FAILED_TO_CREATE_LDAP_CONNECTION 11802 -#define ER_LDAP_AUTH_FAILED_TO_ESTABLISH_TLS_CONNECTION 11803 -#define ER_LDAP_AUTH_FAILED_TO_SEARCH_DN 11804 -#define ER_LDAP_AUTH_CONNECTION_POOL_REINIT_ENTER 11805 -#define ER_SYSTEMD_NOTIFY_PATH_TOO_LONG 11806 -#define ER_SYSTEMD_NOTIFY_CONNECT_FAILED 11807 -#define ER_SYSTEMD_NOTIFY_WRITE_FAILED 11808 -#define ER_FOUND_MISSING_GTIDS 11809 -#define ER_PID_FILE_PRIV_DIRECTORY_INSECURE 11810 -#define ER_CANT_CHECK_PID_PATH 11811 -#define ER_VALIDATE_PWD_STATUS_VAR_REGISTRATION_FAILED 11812 -#define ER_VALIDATE_PWD_STATUS_VAR_UNREGISTRATION_FAILED 11813 -#define ER_VALIDATE_PWD_DICT_FILE_OPEN_FAILED 11814 -#define ER_VALIDATE_PWD_COULD_BE_NULL 11815 -#define ER_VALIDATE_PWD_STRING_CONV_TO_LOWERCASE_FAILED 11816 -#define ER_VALIDATE_PWD_STRING_CONV_TO_BUFFER_FAILED 11817 -#define ER_VALIDATE_PWD_STRING_HANDLER_MEM_ALLOCATION_FAILED 11818 -#define ER_VALIDATE_PWD_STRONG_POLICY_DICT_FILE_UNSPECIFIED 11819 -#define ER_VALIDATE_PWD_CONVERT_TO_BUFFER_FAILED 11820 -#define ER_VALIDATE_PWD_VARIABLE_REGISTRATION_FAILED 11821 -#define ER_VALIDATE_PWD_VARIABLE_UNREGISTRATION_FAILED 11822 -#define ER_KEYRING_MIGRATION_EXTRA_OPTIONS 11823 -//#define OBSOLETE_ER_INVALID_DEFAULT_UTF8MB4_COLLATION 11824 -#define ER_IB_MSG_0 11825 -#define ER_IB_MSG_1 11826 -#define ER_IB_MSG_2 11827 -#define ER_IB_MSG_3 11828 -#define ER_IB_MSG_4 11829 -#define ER_IB_MSG_5 11830 -#define ER_IB_MSG_6 11831 -#define ER_IB_MSG_7 11832 -#define ER_IB_MSG_8 11833 -#define ER_IB_MSG_9 11834 -#define ER_IB_MSG_10 11835 -#define ER_IB_MSG_11 11836 -#define ER_IB_MSG_12 11837 -#define ER_IB_MSG_13 11838 -#define ER_IB_MSG_14 11839 -#define ER_IB_MSG_15 11840 -#define ER_IB_MSG_16 11841 -#define ER_IB_MSG_17 11842 -#define ER_IB_MSG_18 11843 -#define ER_IB_MSG_19 11844 -#define ER_IB_MSG_20 11845 -#define ER_IB_MSG_21 11846 -#define ER_IB_MSG_22 11847 -#define ER_IB_MSG_23 11848 -#define ER_IB_MSG_24 11849 -#define ER_IB_MSG_25 11850 -#define ER_IB_MSG_26 11851 -#define ER_IB_MSG_27 11852 -#define ER_IB_MSG_28 11853 -#define ER_IB_MSG_29 11854 -#define ER_IB_MSG_30 11855 -#define ER_IB_MSG_31 11856 -#define ER_IB_MSG_32 11857 -#define ER_IB_MSG_33 11858 -#define ER_IB_MSG_34 11859 -#define ER_IB_MSG_35 11860 -#define ER_IB_MSG_36 11861 -#define ER_IB_MSG_37 11862 -#define ER_IB_MSG_38 11863 -#define ER_IB_MSG_39 11864 -#define ER_IB_MSG_40 11865 -#define ER_IB_MSG_41 11866 -#define ER_IB_MSG_42 11867 -#define ER_IB_MSG_43 11868 -#define ER_IB_MSG_44 11869 -#define ER_IB_MSG_45 11870 -#define ER_IB_MSG_46 11871 -#define ER_IB_MSG_47 11872 -#define ER_IB_MSG_48 11873 -#define ER_IB_MSG_49 11874 -#define ER_IB_MSG_50 11875 -#define ER_IB_MSG_51 11876 -#define ER_IB_MSG_52 11877 -#define ER_IB_MSG_53 11878 -#define ER_IB_MSG_54 11879 -#define ER_IB_MSG_55 11880 -#define ER_IB_MSG_56 11881 -#define ER_IB_MSG_57 11882 -#define ER_IB_MSG_58 11883 -#define ER_IB_MSG_59 11884 -#define ER_IB_MSG_60 11885 -#define ER_IB_MSG_61 11886 -#define ER_IB_MSG_62 11887 -#define ER_IB_MSG_63 11888 -#define ER_IB_MSG_64 11889 -#define ER_IB_MSG_65 11890 -#define ER_IB_MSG_66 11891 -#define ER_IB_MSG_67 11892 -#define ER_IB_MSG_68 11893 -#define ER_IB_MSG_69 11894 -#define ER_IB_MSG_70 11895 -#define ER_IB_MSG_71 11896 -#define ER_IB_MSG_72 11897 -#define ER_IB_MSG_73 11898 -#define ER_IB_MSG_74 11899 -#define ER_IB_MSG_75 11900 -#define ER_IB_MSG_76 11901 -#define ER_IB_MSG_77 11902 -#define ER_IB_MSG_78 11903 -#define ER_IB_MSG_79 11904 -#define ER_IB_MSG_80 11905 -#define ER_IB_MSG_81 11906 -#define ER_IB_MSG_82 11907 -#define ER_IB_MSG_83 11908 -#define ER_IB_MSG_84 11909 -#define ER_IB_MSG_85 11910 -#define ER_IB_MSG_86 11911 -//#define OBSOLETE_ER_IB_MSG_87 11912 -//#define OBSOLETE_ER_IB_MSG_88 11913 -//#define OBSOLETE_ER_IB_MSG_89 11914 -//#define OBSOLETE_ER_IB_MSG_90 11915 -//#define OBSOLETE_ER_IB_MSG_91 11916 -//#define OBSOLETE_ER_IB_MSG_92 11917 -//#define OBSOLETE_ER_IB_MSG_93 11918 -//#define OBSOLETE_ER_IB_MSG_94 11919 -#define ER_IB_MSG_95 11920 -#define ER_IB_MSG_96 11921 -#define ER_IB_MSG_97 11922 -#define ER_IB_MSG_98 11923 -#define ER_IB_MSG_99 11924 -#define ER_IB_MSG_100 11925 -#define ER_IB_MSG_101 11926 -#define ER_IB_MSG_102 11927 -#define ER_IB_MSG_103 11928 -#define ER_IB_MSG_104 11929 -#define ER_IB_MSG_105 11930 -#define ER_IB_MSG_106 11931 -#define ER_IB_MSG_107 11932 -#define ER_IB_MSG_108 11933 -#define ER_IB_MSG_109 11934 -#define ER_IB_MSG_110 11935 -#define ER_IB_MSG_111 11936 -#define ER_IB_MSG_112 11937 -//#define OBSOLETE_ER_IB_MSG_113 11938 -//#define OBSOLETE_ER_IB_MSG_114 11939 -//#define OBSOLETE_ER_IB_MSG_115 11940 -//#define OBSOLETE_ER_IB_MSG_116 11941 -//#define OBSOLETE_ER_IB_MSG_117 11942 -//#define OBSOLETE_ER_IB_MSG_118 11943 -#define ER_IB_MSG_119 11944 -#define ER_IB_MSG_120 11945 -#define ER_IB_MSG_121 11946 -#define ER_IB_MSG_122 11947 -#define ER_IB_MSG_123 11948 -#define ER_IB_MSG_124 11949 -#define ER_IB_MSG_125 11950 -#define ER_IB_MSG_126 11951 -#define ER_IB_MSG_127 11952 -#define ER_IB_MSG_128 11953 -#define ER_IB_MSG_129 11954 -#define ER_IB_MSG_130 11955 -#define ER_IB_MSG_131 11956 -#define ER_IB_MSG_132 11957 -#define ER_IB_MSG_133 11958 -#define ER_IB_MSG_134 11959 -#define ER_IB_MSG_135 11960 -#define ER_IB_MSG_136 11961 -#define ER_IB_MSG_137 11962 -#define ER_IB_MSG_138 11963 -#define ER_IB_MSG_139 11964 -#define ER_IB_MSG_140 11965 -#define ER_IB_MSG_141 11966 -#define ER_IB_MSG_142 11967 -#define ER_IB_MSG_143 11968 -#define ER_IB_MSG_144 11969 -#define ER_IB_MSG_145 11970 -#define ER_IB_MSG_146 11971 -#define ER_IB_MSG_147 11972 -#define ER_IB_MSG_148 11973 -#define ER_IB_CLONE_INTERNAL 11974 -#define ER_IB_CLONE_TIMEOUT 11975 -#define ER_IB_CLONE_STATUS_FILE 11976 -#define ER_IB_CLONE_SQL 11977 -#define ER_IB_CLONE_VALIDATE 11978 -#define ER_IB_CLONE_PUNCH_HOLE 11979 -#define ER_IB_CLONE_GTID_PERSIST 11980 -#define ER_IB_MSG_156 11981 -#define ER_IB_MSG_157 11982 -#define ER_IB_MSG_158 11983 -#define ER_IB_MSG_159 11984 -#define ER_IB_MSG_160 11985 -#define ER_IB_MSG_161 11986 -#define ER_IB_MSG_162 11987 -#define ER_IB_MSG_163 11988 -#define ER_IB_MSG_164 11989 -#define ER_IB_MSG_165 11990 -#define ER_IB_MSG_166 11991 -#define ER_IB_MSG_167 11992 -#define ER_IB_MSG_168 11993 -#define ER_IB_MSG_169 11994 -#define ER_IB_MSG_170 11995 -#define ER_IB_MSG_171 11996 -#define ER_IB_MSG_172 11997 -#define ER_IB_MSG_173 11998 -#define ER_IB_MSG_174 11999 -#define ER_IB_MSG_175 12000 -#define ER_IB_MSG_176 12001 -#define ER_IB_MSG_177 12002 -#define ER_IB_MSG_178 12003 -#define ER_IB_MSG_179 12004 -#define ER_IB_MSG_180 12005 -#define ER_IB_MSG_181 12006 -#define ER_IB_MSG_182 12007 -#define ER_IB_MSG_183 12008 -#define ER_IB_MSG_184 12009 -#define ER_IB_MSG_185 12010 -#define ER_IB_MSG_186 12011 -#define ER_IB_MSG_187 12012 -#define ER_IB_MSG_188 12013 -#define ER_IB_MSG_189 12014 -#define ER_IB_MSG_190 12015 -#define ER_IB_MSG_191 12016 -#define ER_IB_MSG_192 12017 -#define ER_IB_MSG_193 12018 -#define ER_IB_MSG_194 12019 -#define ER_IB_MSG_195 12020 -#define ER_IB_MSG_196 12021 -#define ER_IB_MSG_197 12022 -#define ER_IB_MSG_198 12023 -#define ER_IB_MSG_199 12024 -#define ER_IB_MSG_200 12025 -#define ER_IB_MSG_201 12026 -#define ER_IB_MSG_202 12027 -#define ER_IB_MSG_203 12028 -#define ER_IB_MSG_204 12029 -#define ER_IB_MSG_205 12030 -#define ER_IB_MSG_206 12031 -#define ER_IB_MSG_207 12032 -#define ER_IB_MSG_208 12033 -#define ER_IB_MSG_209 12034 -#define ER_IB_MSG_210 12035 -#define ER_IB_MSG_211 12036 -#define ER_IB_MSG_212 12037 -#define ER_IB_MSG_213 12038 -#define ER_IB_MSG_214 12039 -#define ER_IB_MSG_215 12040 -#define ER_IB_MSG_216 12041 -#define ER_IB_MSG_217 12042 -#define ER_IB_MSG_218 12043 -#define ER_IB_MSG_219 12044 -#define ER_IB_MSG_220 12045 -#define ER_IB_MSG_221 12046 -#define ER_IB_MSG_222 12047 -#define ER_IB_MSG_223 12048 -#define ER_IB_MSG_224 12049 -#define ER_IB_MSG_225 12050 -#define ER_IB_MSG_226 12051 -#define ER_IB_MSG_227 12052 -#define ER_IB_MSG_228 12053 -#define ER_IB_MSG_229 12054 -#define ER_IB_MSG_230 12055 -#define ER_IB_MSG_231 12056 -#define ER_IB_MSG_232 12057 -#define ER_IB_MSG_233 12058 -#define ER_IB_MSG_234 12059 -#define ER_IB_MSG_235 12060 -#define ER_IB_MSG_236 12061 -#define ER_IB_MSG_237 12062 -#define ER_IB_MSG_238 12063 -#define ER_IB_MSG_239 12064 -#define ER_IB_MSG_240 12065 -#define ER_IB_MSG_241 12066 -#define ER_IB_MSG_242 12067 -#define ER_IB_MSG_243 12068 -#define ER_IB_MSG_244 12069 -#define ER_IB_MSG_245 12070 -#define ER_IB_MSG_246 12071 -#define ER_IB_MSG_247 12072 -#define ER_IB_MSG_248 12073 -#define ER_IB_MSG_249 12074 -#define ER_IB_MSG_250 12075 -#define ER_IB_MSG_251 12076 -#define ER_IB_MSG_252 12077 -#define ER_IB_MSG_253 12078 -#define ER_IB_MSG_254 12079 -#define ER_IB_MSG_255 12080 -#define ER_IB_MSG_256 12081 -#define ER_IB_MSG_257 12082 -#define ER_IB_MSG_258 12083 -#define ER_IB_MSG_259 12084 -#define ER_IB_MSG_260 12085 -#define ER_IB_MSG_261 12086 -#define ER_IB_MSG_262 12087 -#define ER_IB_MSG_263 12088 -#define ER_IB_MSG_264 12089 -#define ER_IB_MSG_265 12090 -#define ER_IB_MSG_266 12091 -#define ER_IB_MSG_267 12092 -#define ER_IB_MSG_268 12093 -#define ER_IB_MSG_269 12094 -#define ER_IB_MSG_270 12095 -#define ER_IB_MSG_271 12096 -#define ER_IB_MSG_272 12097 -#define ER_IB_MSG_273 12098 -#define ER_IB_MSG_274 12099 -#define ER_IB_MSG_275 12100 -#define ER_IB_MSG_276 12101 -#define ER_IB_MSG_277 12102 -#define ER_IB_MSG_278 12103 -#define ER_IB_MSG_279 12104 -#define ER_IB_MSG_280 12105 -#define ER_IB_MSG_281 12106 -#define ER_IB_MSG_282 12107 -#define ER_IB_MSG_283 12108 -#define ER_IB_MSG_284 12109 -#define ER_IB_MSG_285 12110 -#define ER_IB_MSG_286 12111 -#define ER_IB_MSG_287 12112 -#define ER_IB_MSG_288 12113 -#define ER_IB_MSG_289 12114 -#define ER_IB_MSG_290 12115 -#define ER_IB_MSG_291 12116 -#define ER_IB_MSG_292 12117 -#define ER_IB_MSG_293 12118 -#define ER_IB_MSG_294 12119 -#define ER_IB_MSG_295 12120 -#define ER_IB_MSG_296 12121 -#define ER_IB_MSG_297 12122 -#define ER_IB_MSG_298 12123 -#define ER_IB_MSG_299 12124 -#define ER_IB_MSG_300 12125 -#define ER_IB_MSG_301 12126 -#define ER_IB_MSG_UNEXPECTED_FILE_EXISTS 12127 -#define ER_IB_MSG_303 12128 -#define ER_IB_MSG_304 12129 -#define ER_IB_MSG_305 12130 -#define ER_IB_MSG_306 12131 -#define ER_IB_MSG_307 12132 -#define ER_IB_MSG_308 12133 -#define ER_IB_MSG_309 12134 -#define ER_IB_MSG_310 12135 -#define ER_IB_MSG_311 12136 -#define ER_IB_MSG_312 12137 -#define ER_IB_MSG_313 12138 -#define ER_IB_MSG_314 12139 -#define ER_IB_MSG_315 12140 -#define ER_IB_MSG_316 12141 -#define ER_IB_MSG_317 12142 -#define ER_IB_MSG_318 12143 -#define ER_IB_MSG_319 12144 -#define ER_IB_MSG_320 12145 -#define ER_IB_MSG_321 12146 -#define ER_IB_MSG_322 12147 -#define ER_IB_MSG_323 12148 -#define ER_IB_MSG_324 12149 -#define ER_IB_MSG_325 12150 -#define ER_IB_MSG_326 12151 -#define ER_IB_MSG_327 12152 -#define ER_IB_MSG_328 12153 -#define ER_IB_MSG_329 12154 -#define ER_IB_MSG_330 12155 -#define ER_IB_MSG_331 12156 -#define ER_IB_MSG_332 12157 -#define ER_IB_MSG_333 12158 -#define ER_IB_MSG_334 12159 -#define ER_IB_MSG_335 12160 -#define ER_IB_MSG_336 12161 -#define ER_IB_MSG_337 12162 -#define ER_IB_MSG_338 12163 -#define ER_IB_MSG_339 12164 -#define ER_IB_MSG_340 12165 -#define ER_IB_MSG_341 12166 -#define ER_IB_MSG_342 12167 -#define ER_IB_MSG_343 12168 -#define ER_IB_MSG_344 12169 -#define ER_IB_MSG_345 12170 -#define ER_IB_MSG_346 12171 -#define ER_IB_MSG_347 12172 -#define ER_IB_MSG_348 12173 -#define ER_IB_MSG_349 12174 -#define ER_IB_MSG_350 12175 -//#define OBSOLETE_ER_IB_MSG_351 12176 -#define ER_IB_MSG_352 12177 -#define ER_IB_MSG_353 12178 -#define ER_IB_MSG_354 12179 -#define ER_IB_MSG_355 12180 -#define ER_IB_MSG_356 12181 -#define ER_IB_MSG_357 12182 -#define ER_IB_MSG_358 12183 -#define ER_IB_MSG_359 12184 -#define ER_IB_MSG_360 12185 -#define ER_IB_MSG_361 12186 -#define ER_IB_MSG_362 12187 -//#define OBSOLETE_ER_IB_MSG_363 12188 -#define ER_IB_MSG_364 12189 -#define ER_IB_MSG_365 12190 -#define ER_IB_MSG_366 12191 -#define ER_IB_MSG_367 12192 -#define ER_IB_MSG_368 12193 -#define ER_IB_MSG_369 12194 -#define ER_IB_MSG_370 12195 -#define ER_IB_MSG_371 12196 -#define ER_IB_MSG_372 12197 -#define ER_IB_MSG_373 12198 -#define ER_IB_MSG_374 12199 -#define ER_IB_MSG_375 12200 -#define ER_IB_MSG_376 12201 -#define ER_IB_MSG_377 12202 -#define ER_IB_MSG_378 12203 -#define ER_IB_MSG_379 12204 -#define ER_IB_MSG_380 12205 -#define ER_IB_MSG_381 12206 -#define ER_IB_MSG_382 12207 -#define ER_IB_MSG_383 12208 -#define ER_IB_MSG_384 12209 -#define ER_IB_MSG_385 12210 -#define ER_IB_MSG_386 12211 -#define ER_IB_MSG_387 12212 -#define ER_IB_MSG_388 12213 -#define ER_IB_MSG_389 12214 -#define ER_IB_MSG_390 12215 -#define ER_IB_MSG_391 12216 -#define ER_IB_MSG_392 12217 -#define ER_IB_MSG_393 12218 -#define ER_IB_MSG_394 12219 -#define ER_IB_MSG_395 12220 -#define ER_IB_MSG_396 12221 -#define ER_IB_MSG_397 12222 -#define ER_IB_MSG_398 12223 -#define ER_IB_MSG_399 12224 -//#define OBSOLETE_ER_IB_MSG_400 12225 -#define ER_IB_MSG_401 12226 -#define ER_IB_MSG_402 12227 -#define ER_IB_MSG_403 12228 -#define ER_IB_MSG_404 12229 -#define ER_IB_MSG_405 12230 -#define ER_IB_MSG_406 12231 -#define ER_IB_MSG_407 12232 -#define ER_IB_MSG_408 12233 -#define ER_IB_MSG_409 12234 -#define ER_IB_MSG_410 12235 -#define ER_IB_MSG_411 12236 -#define ER_IB_MSG_412 12237 -#define ER_IB_MSG_413 12238 -#define ER_IB_MSG_414 12239 -#define ER_IB_MSG_415 12240 -#define ER_IB_MSG_416 12241 -#define ER_IB_MSG_417 12242 -#define ER_IB_MSG_418 12243 -#define ER_IB_MSG_419 12244 -#define ER_IB_MSG_420 12245 -#define ER_IB_MSG_421 12246 -#define ER_IB_MSG_422 12247 -#define ER_IB_MSG_423 12248 -#define ER_IB_MSG_424 12249 -#define ER_IB_MSG_425 12250 -#define ER_IB_MSG_426 12251 -#define ER_IB_MSG_427 12252 -#define ER_IB_MSG_428 12253 -#define ER_IB_MSG_429 12254 -#define ER_IB_MSG_430 12255 -#define ER_IB_MSG_431 12256 -#define ER_IB_MSG_432 12257 -#define ER_IB_MSG_433 12258 -#define ER_IB_MSG_434 12259 -#define ER_IB_MSG_435 12260 -#define ER_IB_MSG_436 12261 -#define ER_IB_MSG_437 12262 -#define ER_IB_MSG_438 12263 -#define ER_IB_MSG_439 12264 -#define ER_IB_MSG_440 12265 -#define ER_IB_MSG_441 12266 -#define ER_IB_MSG_442 12267 -#define ER_IB_MSG_443 12268 -#define ER_IB_MSG_444 12269 -#define ER_IB_MSG_445 12270 -#define ER_IB_MSG_446 12271 -#define ER_IB_MSG_447 12272 -#define ER_IB_MSG_448 12273 -#define ER_IB_MSG_449 12274 -#define ER_IB_MSG_450 12275 -#define ER_IB_MSG_451 12276 -#define ER_IB_MSG_452 12277 -#define ER_IB_MSG_453 12278 -#define ER_IB_MSG_454 12279 -#define ER_IB_MSG_455 12280 -#define ER_IB_MSG_456 12281 -#define ER_IB_MSG_457 12282 -#define ER_IB_MSG_458 12283 -#define ER_IB_MSG_459 12284 -#define ER_IB_MSG_460 12285 -#define ER_IB_MSG_461 12286 -#define ER_IB_MSG_462 12287 -#define ER_IB_MSG_463 12288 -#define ER_IB_MSG_464 12289 -#define ER_IB_MSG_465 12290 -#define ER_IB_MSG_466 12291 -#define ER_IB_MSG_467 12292 -#define ER_IB_MSG_468 12293 -#define ER_IB_MSG_469 12294 -#define ER_IB_MSG_470 12295 -#define ER_IB_MSG_471 12296 -#define ER_IB_MSG_472 12297 -#define ER_IB_MSG_473 12298 -#define ER_IB_MSG_474 12299 -#define ER_IB_MSG_475 12300 -#define ER_IB_MSG_476 12301 -#define ER_IB_MSG_477 12302 -#define ER_IB_MSG_478 12303 -#define ER_IB_MSG_479 12304 -#define ER_IB_MSG_480 12305 -#define ER_IB_MSG_481 12306 -#define ER_IB_MSG_482 12307 -#define ER_IB_MSG_483 12308 -#define ER_IB_MSG_484 12309 -#define ER_IB_MSG_485 12310 -#define ER_IB_MSG_486 12311 -#define ER_IB_MSG_487 12312 -#define ER_IB_MSG_488 12313 -#define ER_IB_MSG_489 12314 -#define ER_IB_MSG_490 12315 -#define ER_IB_MSG_491 12316 -#define ER_IB_MSG_492 12317 -#define ER_IB_MSG_493 12318 -#define ER_IB_MSG_494 12319 -#define ER_IB_MSG_495 12320 -#define ER_IB_MSG_496 12321 -#define ER_IB_MSG_497 12322 -#define ER_IB_MSG_498 12323 -#define ER_IB_MSG_499 12324 -#define ER_IB_MSG_500 12325 -#define ER_IB_MSG_501 12326 -#define ER_IB_MSG_502 12327 -#define ER_IB_MSG_503 12328 -#define ER_IB_MSG_504 12329 -#define ER_IB_MSG_505 12330 -#define ER_IB_MSG_506 12331 -#define ER_IB_MSG_507 12332 -#define ER_IB_MSG_508 12333 -#define ER_IB_MSG_509 12334 -#define ER_IB_MSG_510 12335 -#define ER_IB_MSG_511 12336 -#define ER_IB_MSG_512 12337 -#define ER_IB_MSG_513 12338 -#define ER_IB_MSG_514 12339 -#define ER_IB_MSG_515 12340 -#define ER_IB_MSG_516 12341 -#define ER_IB_MSG_517 12342 -#define ER_IB_MSG_518 12343 -#define ER_IB_MSG_519 12344 -#define ER_IB_MSG_520 12345 -#define ER_IB_MSG_521 12346 -#define ER_IB_MSG_522 12347 -#define ER_IB_MSG_523 12348 -#define ER_IB_MSG_524 12349 -#define ER_IB_MSG_525 12350 -#define ER_IB_MSG_526 12351 -#define ER_IB_MSG_527 12352 -#define ER_IB_MSG_528 12353 -#define ER_IB_MSG_529 12354 -#define ER_IB_MSG_530 12355 -#define ER_IB_MSG_531 12356 -#define ER_IB_MSG_532 12357 -#define ER_IB_MSG_533 12358 -#define ER_IB_MSG_534 12359 -#define ER_IB_MSG_535 12360 -#define ER_IB_MSG_536 12361 -#define ER_IB_MSG_537 12362 -#define ER_IB_MSG_538 12363 -#define ER_IB_MSG_539 12364 -#define ER_IB_MSG_540 12365 -#define ER_IB_MSG_541 12366 -#define ER_IB_MSG_542 12367 -#define ER_IB_MSG_543 12368 -#define ER_IB_MSG_544 12369 -#define ER_IB_MSG_545 12370 -#define ER_IB_MSG_546 12371 -#define ER_IB_MSG_547 12372 -#define ER_IB_MSG_548 12373 -#define ER_IB_MSG_549 12374 -#define ER_IB_MSG_550 12375 -#define ER_IB_MSG_551 12376 -#define ER_IB_MSG_552 12377 -#define ER_IB_MSG_553 12378 -#define ER_IB_MSG_554 12379 -#define ER_IB_MSG_555 12380 -#define ER_IB_MSG_556 12381 -#define ER_IB_MSG_557 12382 -#define ER_IB_MSG_558 12383 -#define ER_IB_MSG_559 12384 -#define ER_IB_MSG_560 12385 -#define ER_IB_MSG_561 12386 -#define ER_IB_MSG_562 12387 -#define ER_IB_MSG_563 12388 -#define ER_IB_MSG_564 12389 -#define ER_IB_MSG_565 12390 -#define ER_IB_MSG_566 12391 -#define ER_IB_MSG_567 12392 -#define ER_IB_MSG_568 12393 -#define ER_IB_MSG_569 12394 -#define ER_IB_MSG_570 12395 -#define ER_IB_MSG_571 12396 -#define ER_IB_MSG_572 12397 -#define ER_IB_MSG_573 12398 -#define ER_IB_MSG_574 12399 -//#define OBSOLETE_ER_IB_MSG_575 12400 -//#define OBSOLETE_ER_IB_MSG_576 12401 -//#define OBSOLETE_ER_IB_MSG_577 12402 -#define ER_IB_MSG_578 12403 -#define ER_IB_MSG_579 12404 -#define ER_IB_MSG_580 12405 -#define ER_IB_MSG_581 12406 -#define ER_IB_MSG_582 12407 -#define ER_IB_MSG_583 12408 -#define ER_IB_MSG_584 12409 -#define ER_IB_MSG_585 12410 -#define ER_IB_MSG_586 12411 -#define ER_IB_MSG_587 12412 -#define ER_IB_MSG_588 12413 -#define ER_IB_MSG_589 12414 -#define ER_IB_MSG_590 12415 -#define ER_IB_MSG_591 12416 -#define ER_IB_MSG_592 12417 -#define ER_IB_MSG_593 12418 -#define ER_IB_MSG_594 12419 -#define ER_IB_MSG_595 12420 -#define ER_IB_MSG_596 12421 -#define ER_IB_MSG_597 12422 -#define ER_IB_MSG_598 12423 -#define ER_IB_MSG_599 12424 -#define ER_IB_MSG_600 12425 -#define ER_IB_MSG_601 12426 -#define ER_IB_MSG_602 12427 -#define ER_IB_MSG_603 12428 -#define ER_IB_MSG_604 12429 -#define ER_IB_MSG_605 12430 -#define ER_IB_MSG_606 12431 -#define ER_IB_MSG_607 12432 -#define ER_IB_MSG_608 12433 -#define ER_IB_MSG_609 12434 -#define ER_IB_MSG_610 12435 -#define ER_IB_MSG_611 12436 -#define ER_IB_MSG_612 12437 -#define ER_IB_MSG_613 12438 -#define ER_IB_MSG_614 12439 -#define ER_IB_MSG_615 12440 -#define ER_IB_MSG_616 12441 -#define ER_IB_MSG_617 12442 -#define ER_IB_MSG_618 12443 -#define ER_IB_MSG_619 12444 -#define ER_IB_MSG_620 12445 -#define ER_IB_MSG_621 12446 -#define ER_IB_MSG_622 12447 -#define ER_IB_MSG_623 12448 -#define ER_IB_MSG_624 12449 -#define ER_IB_MSG_625 12450 -#define ER_IB_MSG_626 12451 -#define ER_IB_MSG_627 12452 -#define ER_IB_MSG_628 12453 -#define ER_IB_MSG_629 12454 -#define ER_IB_MSG_630 12455 -#define ER_IB_MSG_631 12456 -#define ER_IB_MSG_632 12457 -#define ER_IB_MSG_633 12458 -#define ER_IB_MSG_634 12459 -#define ER_IB_MSG_635 12460 -#define ER_IB_MSG_636 12461 -#define ER_IB_MSG_637 12462 -#define ER_IB_MSG_638 12463 -#define ER_IB_MSG_639 12464 -#define ER_IB_MSG_640 12465 -#define ER_IB_MSG_641 12466 -#define ER_IB_MSG_642 12467 -#define ER_IB_MSG_643 12468 -#define ER_IB_MSG_644 12469 -#define ER_IB_MSG_645 12470 -#define ER_IB_MSG_646 12471 -#define ER_IB_MSG_647 12472 -#define ER_IB_MSG_648 12473 -#define ER_IB_MSG_649 12474 -#define ER_IB_MSG_650 12475 -#define ER_IB_MSG_651 12476 -#define ER_IB_MSG_652 12477 -#define ER_IB_MSG_DDL_LOG_DELETE_BY_ID_OK 12478 -#define ER_IB_MSG_654 12479 -#define ER_IB_MSG_655 12480 -#define ER_IB_MSG_656 12481 -#define ER_IB_MSG_657 12482 -#define ER_IB_MSG_658 12483 -#define ER_IB_MSG_659 12484 -#define ER_IB_MSG_660 12485 -#define ER_IB_MSG_661 12486 -#define ER_IB_MSG_662 12487 -#define ER_IB_MSG_663 12488 -//#define OBSOLETE_ER_IB_MSG_664 12489 -//#define OBSOLETE_ER_IB_MSG_665 12490 -//#define OBSOLETE_ER_IB_MSG_666 12491 -//#define OBSOLETE_ER_IB_MSG_667 12492 -//#define OBSOLETE_ER_IB_MSG_668 12493 -//#define OBSOLETE_ER_IB_MSG_669 12494 -//#define OBSOLETE_ER_IB_MSG_670 12495 -//#define OBSOLETE_ER_IB_MSG_671 12496 -//#define OBSOLETE_ER_IB_MSG_672 12497 -//#define OBSOLETE_ER_IB_MSG_673 12498 -//#define OBSOLETE_ER_IB_MSG_674 12499 -//#define OBSOLETE_ER_IB_MSG_675 12500 -//#define OBSOLETE_ER_IB_MSG_676 12501 -//#define OBSOLETE_ER_IB_MSG_677 12502 -//#define OBSOLETE_ER_IB_MSG_678 12503 -//#define OBSOLETE_ER_IB_MSG_679 12504 -//#define OBSOLETE_ER_IB_MSG_680 12505 -//#define OBSOLETE_ER_IB_MSG_681 12506 -//#define OBSOLETE_ER_IB_MSG_682 12507 -//#define OBSOLETE_ER_IB_MSG_683 12508 -//#define OBSOLETE_ER_IB_MSG_684 12509 -//#define OBSOLETE_ER_IB_MSG_685 12510 -//#define OBSOLETE_ER_IB_MSG_686 12511 -//#define OBSOLETE_ER_IB_MSG_687 12512 -//#define OBSOLETE_ER_IB_MSG_688 12513 -//#define OBSOLETE_ER_IB_MSG_689 12514 -//#define OBSOLETE_ER_IB_MSG_690 12515 -//#define OBSOLETE_ER_IB_MSG_691 12516 -//#define OBSOLETE_ER_IB_MSG_692 12517 -//#define OBSOLETE_ER_IB_MSG_693 12518 -#define ER_IB_MSG_694 12519 -#define ER_IB_MSG_695 12520 -#define ER_IB_MSG_696 12521 -#define ER_IB_MSG_697 12522 -#define ER_IB_MSG_698 12523 -#define ER_IB_MSG_699 12524 -#define ER_IB_MSG_700 12525 -#define ER_IB_MSG_701 12526 -//#define OBSOLETE_ER_IB_MSG_702 12527 -//#define OBSOLETE_ER_IB_MSG_703 12528 -#define ER_IB_MSG_704 12529 -#define ER_IB_MSG_705 12530 -#define ER_IB_MSG_706 12531 -#define ER_IB_MSG_707 12532 -#define ER_IB_MSG_708 12533 -#define ER_IB_MSG_709 12534 -#define ER_IB_MSG_710 12535 -#define ER_IB_MSG_711 12536 -#define ER_IB_MSG_712 12537 -#define ER_IB_MSG_713 12538 -#define ER_IB_MSG_714 12539 -#define ER_IB_MSG_715 12540 -#define ER_IB_MSG_716 12541 -#define ER_IB_MSG_717 12542 -#define ER_IB_MSG_718 12543 -#define ER_IB_MSG_719 12544 -#define ER_IB_MSG_720 12545 -#define ER_IB_MSG_721 12546 -#define ER_IB_MSG_722 12547 -#define ER_IB_MSG_723 12548 -#define ER_IB_MSG_724 12549 -#define ER_IB_MSG_725 12550 -#define ER_IB_MSG_726 12551 -#define ER_IB_MSG_727 12552 -#define ER_IB_MSG_728 12553 -#define ER_IB_MSG_729 12554 -#define ER_IB_MSG_730 12555 -#define ER_IB_MSG_731 12556 -#define ER_IB_MSG_732 12557 -#define ER_IB_MSG_733 12558 -#define ER_IB_MSG_734 12559 -#define ER_IB_MSG_735 12560 -#define ER_IB_MSG_736 12561 -#define ER_IB_MSG_737 12562 -#define ER_IB_MSG_738 12563 -#define ER_IB_MSG_739 12564 -#define ER_IB_MSG_740 12565 -#define ER_IB_MSG_741 12566 -#define ER_IB_MSG_742 12567 -#define ER_IB_MSG_743 12568 -#define ER_IB_MSG_744 12569 -#define ER_IB_MSG_745 12570 -#define ER_IB_MSG_746 12571 -#define ER_IB_MSG_747 12572 -#define ER_IB_MSG_748 12573 -#define ER_IB_MSG_749 12574 -#define ER_IB_MSG_750 12575 -#define ER_IB_MSG_751 12576 -#define ER_IB_MSG_752 12577 -#define ER_IB_MSG_753 12578 -#define ER_IB_MSG_754 12579 -#define ER_IB_MSG_755 12580 -#define ER_IB_MSG_756 12581 -#define ER_IB_MSG_757 12582 -#define ER_IB_MSG_758 12583 -#define ER_IB_MSG_759 12584 -#define ER_IB_MSG_760 12585 -#define ER_IB_MSG_761 12586 -#define ER_IB_MSG_762 12587 -#define ER_IB_MSG_763 12588 -#define ER_IB_MSG_764 12589 -#define ER_IB_MSG_765 12590 -#define ER_IB_MSG_766 12591 -#define ER_IB_MSG_767 12592 -#define ER_IB_MSG_768 12593 -#define ER_IB_MSG_769 12594 -#define ER_IB_MSG_770 12595 -#define ER_IB_MSG_771 12596 -#define ER_IB_MSG_772 12597 -#define ER_IB_MSG_773 12598 -#define ER_IB_MSG_774 12599 -#define ER_IB_MSG_775 12600 -#define ER_IB_MSG_776 12601 -#define ER_IB_MSG_777 12602 -#define ER_IB_MSG_778 12603 -#define ER_IB_MSG_779 12604 -#define ER_IB_MSG_780 12605 -#define ER_IB_MSG_781 12606 -#define ER_IB_MSG_782 12607 -#define ER_IB_MSG_783 12608 -#define ER_IB_MSG_784 12609 -#define ER_IB_MSG_785 12610 -#define ER_IB_MSG_786 12611 -#define ER_IB_MSG_787 12612 -#define ER_IB_MSG_788 12613 -#define ER_IB_MSG_789 12614 -#define ER_IB_MSG_790 12615 -#define ER_IB_MSG_791 12616 -#define ER_IB_MSG_792 12617 -#define ER_IB_MSG_793 12618 -#define ER_IB_MSG_794 12619 -#define ER_IB_MSG_795 12620 -#define ER_IB_MSG_796 12621 -#define ER_IB_MSG_797 12622 -#define ER_IB_MSG_798 12623 -#define ER_IB_MSG_799 12624 -#define ER_IB_MSG_800 12625 -#define ER_IB_MSG_801 12626 -#define ER_IB_MSG_802 12627 -#define ER_IB_MSG_803 12628 -#define ER_IB_MSG_804 12629 -#define ER_IB_MSG_805 12630 -#define ER_IB_MSG_806 12631 -#define ER_IB_MSG_807 12632 -#define ER_IB_MSG_808 12633 -#define ER_IB_MSG_809 12634 -#define ER_IB_MSG_810 12635 -#define ER_IB_MSG_811 12636 -#define ER_IB_MSG_812 12637 -#define ER_IB_MSG_813 12638 -#define ER_IB_MSG_814 12639 -#define ER_IB_MSG_815 12640 -#define ER_IB_MSG_816 12641 -#define ER_IB_MSG_817 12642 -#define ER_IB_MSG_818 12643 -#define ER_IB_MSG_819 12644 -#define ER_IB_MSG_820 12645 -#define ER_IB_MSG_821 12646 -#define ER_IB_MSG_822 12647 -#define ER_IB_MSG_823 12648 -#define ER_IB_MSG_824 12649 -#define ER_IB_MSG_825 12650 -#define ER_IB_MSG_826 12651 -#define ER_IB_MSG_827 12652 -#define ER_IB_MSG_828 12653 -#define ER_IB_MSG_829 12654 -#define ER_IB_MSG_830 12655 -#define ER_IB_MSG_831 12656 -#define ER_IB_MSG_832 12657 -#define ER_IB_MSG_833 12658 -#define ER_IB_MSG_834 12659 -#define ER_IB_MSG_835 12660 -#define ER_IB_MSG_836 12661 -#define ER_IB_MSG_837 12662 -#define ER_IB_MSG_838 12663 -#define ER_IB_MSG_839 12664 -#define ER_IB_MSG_840 12665 -#define ER_IB_MSG_841 12666 -#define ER_IB_MSG_842 12667 -#define ER_IB_MSG_843 12668 -#define ER_IB_MSG_844 12669 -#define ER_IB_MSG_845 12670 -#define ER_IB_MSG_846 12671 -#define ER_IB_MSG_847 12672 -#define ER_IB_MSG_848 12673 -#define ER_IB_MSG_849 12674 -#define ER_IB_MSG_850 12675 -#define ER_IB_MSG_851 12676 -#define ER_IB_MSG_852 12677 -#define ER_IB_MSG_853 12678 -#define ER_IB_MSG_854 12679 -#define ER_IB_MSG_855 12680 -#define ER_IB_MSG_856 12681 -#define ER_IB_MSG_857 12682 -#define ER_IB_MSG_858 12683 -#define ER_IB_MSG_859 12684 -#define ER_IB_MSG_860 12685 -#define ER_IB_MSG_861 12686 -#define ER_IB_MSG_862 12687 -#define ER_IB_MSG_863 12688 -#define ER_IB_MSG_864 12689 -#define ER_IB_MSG_865 12690 -#define ER_IB_MSG_866 12691 -#define ER_IB_MSG_867 12692 -#define ER_IB_MSG_868 12693 -#define ER_IB_MSG_869 12694 -#define ER_IB_MSG_870 12695 -#define ER_IB_MSG_871 12696 -#define ER_IB_MSG_872 12697 -#define ER_IB_MSG_873 12698 -#define ER_IB_MSG_874 12699 -#define ER_IB_MSG_875 12700 -#define ER_IB_MSG_876 12701 -#define ER_IB_MSG_877 12702 -#define ER_IB_MSG_878 12703 -#define ER_IB_MSG_879 12704 -#define ER_IB_MSG_880 12705 -#define ER_IB_MSG_881 12706 -#define ER_IB_MSG_882 12707 -#define ER_IB_MSG_883 12708 -#define ER_IB_MSG_884 12709 -#define ER_IB_MSG_885 12710 -#define ER_IB_MSG_886 12711 -#define ER_IB_MSG_887 12712 -#define ER_IB_MSG_888 12713 -#define ER_IB_MSG_889 12714 -#define ER_IB_MSG_890 12715 -#define ER_IB_MSG_891 12716 -#define ER_IB_MSG_892 12717 -#define ER_IB_MSG_893 12718 -#define ER_IB_MSG_894 12719 -#define ER_IB_MSG_895 12720 -#define ER_IB_MSG_896 12721 -#define ER_IB_MSG_897 12722 -#define ER_IB_MSG_898 12723 -#define ER_IB_MSG_899 12724 -#define ER_IB_MSG_900 12725 -#define ER_IB_MSG_901 12726 -#define ER_IB_MSG_902 12727 -#define ER_IB_MSG_903 12728 -#define ER_IB_MSG_904 12729 -#define ER_IB_MSG_905 12730 -#define ER_IB_MSG_906 12731 -#define ER_IB_MSG_907 12732 -#define ER_IB_MSG_908 12733 -#define ER_IB_MSG_909 12734 -#define ER_IB_MSG_910 12735 -#define ER_IB_MSG_911 12736 -#define ER_IB_MSG_912 12737 -#define ER_IB_MSG_913 12738 -#define ER_IB_MSG_914 12739 -#define ER_IB_MSG_915 12740 -#define ER_IB_MSG_916 12741 -#define ER_IB_MSG_917 12742 -#define ER_IB_MSG_918 12743 -#define ER_IB_MSG_919 12744 -#define ER_IB_MSG_920 12745 -#define ER_IB_MSG_921 12746 -#define ER_IB_MSG_922 12747 -#define ER_IB_MSG_923 12748 -#define ER_IB_MSG_924 12749 -#define ER_IB_MSG_925 12750 -#define ER_IB_MSG_926 12751 -#define ER_IB_MSG_927 12752 -#define ER_IB_MSG_928 12753 -#define ER_IB_MSG_929 12754 -#define ER_IB_MSG_930 12755 -#define ER_IB_MSG_931 12756 -#define ER_IB_MSG_932 12757 -#define ER_IB_MSG_933 12758 -#define ER_IB_MSG_934 12759 -#define ER_IB_MSG_935 12760 -#define ER_IB_MSG_936 12761 -#define ER_IB_MSG_937 12762 -#define ER_IB_MSG_938 12763 -#define ER_IB_MSG_939 12764 -#define ER_IB_MSG_940 12765 -#define ER_IB_MSG_941 12766 -#define ER_IB_MSG_942 12767 -#define ER_IB_MSG_943 12768 -#define ER_IB_MSG_944 12769 -#define ER_IB_MSG_945 12770 -#define ER_IB_MSG_946 12771 -#define ER_IB_MSG_947 12772 -#define ER_IB_MSG_948 12773 -#define ER_IB_MSG_949 12774 -#define ER_IB_MSG_950 12775 -#define ER_IB_MSG_951 12776 -#define ER_IB_MSG_952 12777 -#define ER_IB_MSG_953 12778 -#define ER_IB_MSG_954 12779 -#define ER_IB_MSG_955 12780 -#define ER_IB_MSG_956 12781 -#define ER_IB_MSG_957 12782 -#define ER_IB_MSG_958 12783 -#define ER_IB_MSG_959 12784 -#define ER_IB_MSG_960 12785 -#define ER_IB_MSG_961 12786 -#define ER_IB_MSG_962 12787 -#define ER_IB_MSG_963 12788 -#define ER_IB_MSG_964 12789 -#define ER_IB_MSG_965 12790 -#define ER_IB_MSG_966 12791 -#define ER_IB_MSG_967 12792 -#define ER_IB_MSG_968 12793 -#define ER_IB_MSG_969 12794 -#define ER_IB_MSG_970 12795 -#define ER_IB_MSG_971 12796 -#define ER_IB_MSG_972 12797 -#define ER_IB_MSG_973 12798 -#define ER_IB_MSG_974 12799 -#define ER_IB_MSG_975 12800 -#define ER_IB_MSG_976 12801 -#define ER_IB_MSG_977 12802 -#define ER_IB_MSG_978 12803 -#define ER_IB_MSG_979 12804 -#define ER_IB_MSG_980 12805 -#define ER_IB_MSG_981 12806 -#define ER_IB_MSG_982 12807 -#define ER_IB_MSG_983 12808 -#define ER_IB_MSG_984 12809 -#define ER_IB_MSG_985 12810 -#define ER_IB_MSG_986 12811 -#define ER_IB_MSG_987 12812 -#define ER_IB_MSG_988 12813 -#define ER_IB_MSG_989 12814 -#define ER_IB_MSG_990 12815 -#define ER_IB_MSG_991 12816 -#define ER_IB_MSG_992 12817 -#define ER_IB_MSG_993 12818 -#define ER_IB_MSG_994 12819 -#define ER_IB_MSG_995 12820 -#define ER_IB_MSG_996 12821 -#define ER_IB_MSG_997 12822 -#define ER_IB_MSG_998 12823 -#define ER_IB_MSG_999 12824 -#define ER_IB_MSG_1000 12825 -#define ER_IB_MSG_1001 12826 -#define ER_IB_MSG_1002 12827 -#define ER_IB_MSG_1003 12828 -#define ER_IB_MSG_1004 12829 -#define ER_IB_MSG_1005 12830 -#define ER_IB_MSG_1006 12831 -#define ER_IB_MSG_1007 12832 -#define ER_IB_MSG_1008 12833 -#define ER_IB_MSG_1009 12834 -#define ER_IB_MSG_1010 12835 -#define ER_IB_MSG_1011 12836 -#define ER_IB_MSG_1012 12837 -#define ER_IB_MSG_1013 12838 -#define ER_IB_MSG_1014 12839 -#define ER_IB_MSG_1015 12840 -#define ER_IB_MSG_1016 12841 -#define ER_IB_MSG_1017 12842 -#define ER_IB_MSG_1018 12843 -#define ER_IB_MSG_1019 12844 -#define ER_IB_MSG_1020 12845 -#define ER_IB_MSG_1021 12846 -#define ER_IB_MSG_1022 12847 -#define ER_IB_MSG_1023 12848 -#define ER_IB_MSG_1024 12849 -#define ER_IB_MSG_1025 12850 -#define ER_IB_MSG_1026 12851 -#define ER_IB_MSG_1027 12852 -#define ER_IB_MSG_1028 12853 -#define ER_IB_MSG_1029 12854 -#define ER_IB_MSG_1030 12855 -#define ER_IB_MSG_1031 12856 -#define ER_IB_MSG_1032 12857 -#define ER_IB_MSG_1033 12858 -#define ER_IB_MSG_1034 12859 -#define ER_IB_MSG_1035 12860 -#define ER_IB_MSG_1036 12861 -#define ER_IB_MSG_1037 12862 -#define ER_IB_MSG_1038 12863 -#define ER_IB_MSG_1039 12864 -#define ER_IB_MSG_1040 12865 -#define ER_IB_MSG_1041 12866 -#define ER_IB_MSG_1042 12867 -#define ER_IB_MSG_1043 12868 -#define ER_IB_MSG_1044 12869 -#define ER_IB_MSG_1045 12870 -#define ER_IB_MSG_1046 12871 -#define ER_IB_MSG_1047 12872 -#define ER_IB_MSG_1048 12873 -#define ER_IB_MSG_1049 12874 -//#define OBSOLETE_ER_IB_MSG_1050 12875 -#define ER_IB_MSG_1051 12876 -#define ER_IB_MSG_1052 12877 -#define ER_IB_MSG_1053 12878 -#define ER_IB_MSG_1054 12879 -#define ER_IB_MSG_1055 12880 -#define ER_IB_MSG_1056 12881 -#define ER_IB_MSG_1057 12882 -#define ER_IB_MSG_1058 12883 -#define ER_IB_MSG_1059 12884 -#define ER_IB_MSG_1060 12885 -#define ER_IB_MSG_1061 12886 -#define ER_IB_MSG_1062 12887 -#define ER_IB_MSG_1063 12888 -#define ER_IB_MSG_1064 12889 -#define ER_IB_MSG_1065 12890 -#define ER_IB_MSG_1066 12891 -#define ER_IB_MSG_1067 12892 -#define ER_IB_MSG_1068 12893 -#define ER_IB_MSG_1069 12894 -#define ER_IB_MSG_1070 12895 -#define ER_IB_MSG_1071 12896 -#define ER_IB_MSG_1072 12897 -#define ER_IB_MSG_1073 12898 -#define ER_IB_MSG_1074 12899 -#define ER_IB_MSG_1075 12900 -#define ER_IB_MSG_1076 12901 -#define ER_IB_MSG_1077 12902 -#define ER_IB_MSG_1078 12903 -#define ER_IB_MSG_1079 12904 -#define ER_IB_MSG_1080 12905 -#define ER_IB_MSG_1081 12906 -#define ER_IB_MSG_1082 12907 -#define ER_IB_MSG_1083 12908 -#define ER_IB_MSG_1084 12909 -#define ER_IB_MSG_1085 12910 -#define ER_IB_MSG_1086 12911 -#define ER_IB_MSG_1087 12912 -#define ER_IB_MSG_1088 12913 -#define ER_IB_MSG_1089 12914 -#define ER_IB_MSG_1090 12915 -#define ER_IB_MSG_1091 12916 -#define ER_IB_MSG_1092 12917 -#define ER_IB_MSG_1093 12918 -#define ER_IB_MSG_1094 12919 -#define ER_IB_MSG_1095 12920 -#define ER_IB_MSG_1096 12921 -#define ER_IB_MSG_1097 12922 -#define ER_IB_MSG_1098 12923 -#define ER_IB_MSG_1099 12924 -#define ER_IB_MSG_1100 12925 -#define ER_IB_MSG_1101 12926 -#define ER_IB_MSG_1102 12927 -#define ER_IB_MSG_1103 12928 -#define ER_IB_MSG_1104 12929 -#define ER_IB_MSG_1105 12930 -#define ER_IB_MSG_1106 12931 -#define ER_IB_MSG_1107 12932 -#define ER_IB_MSG_1108 12933 -#define ER_IB_MSG_1109 12934 -#define ER_IB_MSG_1110 12935 -#define ER_IB_MSG_1111 12936 -#define ER_IB_MSG_1112 12937 -#define ER_IB_MSG_1113 12938 -#define ER_IB_MSG_1114 12939 -#define ER_IB_MSG_1115 12940 -#define ER_IB_MSG_1116 12941 -#define ER_IB_MSG_1117 12942 -#define ER_IB_MSG_1118 12943 -#define ER_IB_MSG_1119 12944 -#define ER_IB_MSG_1120 12945 -#define ER_IB_MSG_1121 12946 -#define ER_IB_MSG_1122 12947 -#define ER_IB_MSG_1123 12948 -#define ER_IB_MSG_1124 12949 -#define ER_IB_MSG_1125 12950 -#define ER_IB_MSG_1126 12951 -#define ER_IB_MSG_1127 12952 -#define ER_IB_MSG_1128 12953 -#define ER_IB_MSG_1129 12954 -#define ER_IB_MSG_1130 12955 -#define ER_IB_MSG_1131 12956 -#define ER_IB_MSG_1132 12957 -#define ER_IB_MSG_1133 12958 -#define ER_IB_MSG_1134 12959 -#define ER_IB_MSG_1135 12960 -#define ER_IB_MSG_1136 12961 -#define ER_IB_MSG_1137 12962 -#define ER_IB_MSG_1138 12963 -#define ER_IB_MSG_1139 12964 -#define ER_IB_MSG_1140 12965 -#define ER_IB_MSG_1141 12966 -#define ER_IB_MSG_1142 12967 -#define ER_IB_MSG_1143 12968 -#define ER_IB_MSG_1144 12969 -#define ER_IB_MSG_1145 12970 -#define ER_IB_MSG_1146 12971 -#define ER_IB_MSG_1147 12972 -#define ER_IB_MSG_1148 12973 -#define ER_IB_MSG_1149 12974 -#define ER_IB_MSG_1150 12975 -#define ER_IB_MSG_1151 12976 -#define ER_IB_MSG_1152 12977 -#define ER_IB_MSG_1153 12978 -#define ER_IB_MSG_1154 12979 -#define ER_IB_MSG_1155 12980 -#define ER_IB_MSG_1156 12981 -#define ER_IB_MSG_1157 12982 -#define ER_IB_MSG_1158 12983 -#define ER_IB_MSG_1159 12984 -#define ER_IB_MSG_1160 12985 -#define ER_IB_MSG_1161 12986 -#define ER_IB_MSG_1162 12987 -#define ER_IB_MSG_1163 12988 -#define ER_IB_MSG_1164 12989 -#define ER_IB_MSG_1165 12990 -#define ER_IB_MSG_1166 12991 -#define ER_IB_MSG_1167 12992 -#define ER_IB_MSG_1168 12993 -#define ER_IB_MSG_1169 12994 -#define ER_IB_MSG_1170 12995 -#define ER_IB_MSG_1171 12996 -#define ER_IB_MSG_1172 12997 -#define ER_IB_MSG_1173 12998 -#define ER_IB_MSG_1174 12999 -#define ER_IB_MSG_1175 13000 -#define ER_IB_MSG_1176 13001 -#define ER_IB_MSG_1177 13002 -#define ER_IB_MSG_1178 13003 -#define ER_IB_MSG_1179 13004 -#define ER_IB_MSG_1180 13005 -#define ER_IB_MSG_1181 13006 -#define ER_IB_MSG_1182 13007 -#define ER_IB_MSG_1183 13008 -#define ER_IB_MSG_1184 13009 -#define ER_IB_MSG_1185 13010 -#define ER_IB_MSG_1186 13011 -#define ER_IB_MSG_1187 13012 -#define ER_IB_MSG_1188 13013 -#define ER_IB_MSG_1189 13014 -#define ER_IB_MSG_1190 13015 -#define ER_IB_MSG_1191 13016 -#define ER_IB_MSG_1192 13017 -#define ER_IB_MSG_1193 13018 -#define ER_IB_MSG_1194 13019 -#define ER_IB_MSG_1195 13020 -#define ER_IB_MSG_1196 13021 -#define ER_IB_MSG_1197 13022 -#define ER_IB_MSG_1198 13023 -#define ER_IB_MSG_1199 13024 -#define ER_IB_MSG_1200 13025 -#define ER_IB_MSG_1201 13026 -#define ER_IB_MSG_1202 13027 -#define ER_IB_MSG_1203 13028 -#define ER_IB_MSG_1204 13029 -#define ER_IB_MSG_1205 13030 -#define ER_IB_MSG_1206 13031 -#define ER_IB_MSG_1207 13032 -#define ER_IB_MSG_1208 13033 -#define ER_IB_MSG_1209 13034 -#define ER_IB_MSG_1210 13035 -#define ER_IB_MSG_1211 13036 -#define ER_IB_MSG_1212 13037 -#define ER_IB_MSG_1213 13038 -#define ER_IB_MSG_1214 13039 -#define ER_IB_MSG_1215 13040 -#define ER_IB_MSG_1216 13041 -#define ER_IB_MSG_1217 13042 -#define ER_IB_MSG_1218 13043 -#define ER_IB_MSG_1219 13044 -#define ER_IB_MSG_1220 13045 -#define ER_IB_MSG_1221 13046 -#define ER_IB_MSG_1222 13047 -#define ER_IB_MSG_1223 13048 -#define ER_IB_MSG_1224 13049 -#define ER_IB_MSG_1225 13050 -#define ER_IB_MSG_1226 13051 -#define ER_IB_MSG_1227 13052 -#define ER_IB_MSG_1228 13053 -#define ER_IB_MSG_1229 13054 -//#define OBSOLETE_ER_IB_MSG_1230 13055 -#define ER_IB_MSG_1231 13056 -#define ER_IB_MSG_1232 13057 -#define ER_IB_MSG_1233 13058 -#define ER_IB_MSG_1234 13059 -#define ER_IB_MSG_1235 13060 -#define ER_IB_MSG_1236 13061 -#define ER_IB_MSG_1237 13062 -#define ER_IB_MSG_1238 13063 -#define ER_IB_MSG_1239 13064 -#define ER_IB_MSG_1240 13065 -#define ER_IB_MSG_1241 13066 -#define ER_IB_MSG_1242 13067 -#define ER_IB_MSG_1243 13068 -#define ER_IB_MSG_1244 13069 -#define ER_IB_MSG_1245 13070 -#define ER_IB_MSG_1246 13071 -#define ER_IB_MSG_1247 13072 -#define ER_IB_MSG_1248 13073 -#define ER_IB_MSG_1249 13074 -#define ER_IB_MSG_1250 13075 -#define ER_IB_MSG_1251 13076 -#define ER_IB_MSG_1252 13077 -#define ER_IB_MSG_1253 13078 -//#define OBSOLETE_ER_IB_MSG_1254 13079 -#define ER_IB_MSG_1255 13080 -#define ER_IB_MSG_1256 13081 -#define ER_IB_MSG_1257 13082 -#define ER_IB_MSG_1258 13083 -#define ER_IB_MSG_1259 13084 -#define ER_IB_MSG_1260 13085 -#define ER_IB_MSG_1261 13086 -#define ER_IB_MSG_1262 13087 -#define ER_IB_MSG_1263 13088 -#define ER_IB_MSG_1264 13089 -#define ER_IB_MSG_1265 13090 -#define ER_IB_MSG_1266 13091 -#define ER_IB_MSG_1267 13092 -#define ER_IB_MSG_1268 13093 -#define ER_IB_MSG_1269 13094 -#define ER_IB_MSG_1270 13095 -#define ER_RPL_SLAVE_SQL_THREAD_STOP_CMD_EXEC_TIMEOUT 13096 -#define ER_RPL_SLAVE_IO_THREAD_STOP_CMD_EXEC_TIMEOUT 13097 -#define ER_RPL_GTID_UNSAFE_STMT_ON_NON_TRANS_TABLE 13098 -#define ER_RPL_GTID_UNSAFE_STMT_CREATE_SELECT 13099 -//#define OBSOLETE_ER_RPL_GTID_UNSAFE_STMT_ON_TEMPORARY_TABLE 13100 -#define ER_BINLOG_ROW_VALUE_OPTION_IGNORED 13101 -#define ER_BINLOG_USE_V1_ROW_EVENTS_IGNORED 13102 -#define ER_BINLOG_ROW_VALUE_OPTION_USED_ONLY_FOR_AFTER_IMAGES 13103 -#define ER_CONNECTION_ABORTED 13104 -#define ER_NORMAL_SERVER_SHUTDOWN 13105 -#define ER_KEYRING_MIGRATE_FAILED 13106 -#define ER_GRP_RPL_LOWER_CASE_TABLE_NAMES_DIFF_FROM_GRP 13107 -#define ER_OOM_SAVE_GTIDS 13108 -#define ER_LCTN_NOT_FOUND 13109 -//#define OBSOLETE_ER_REGEXP_INVALID_CAPTURE_GROUP_NAME 13110 -#define ER_COMPONENT_FILTER_WRONG_VALUE 13111 -#define ER_XPLUGIN_FAILED_TO_STOP_SERVICES 13112 -#define ER_INCONSISTENT_ERROR 13113 -#define ER_SERVER_MASTER_FATAL_ERROR_READING_BINLOG 13114 -#define ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE 13115 -#define ER_SLAVE_CREATE_EVENT_FAILURE 13116 -#define ER_SLAVE_FATAL_ERROR 13117 -#define ER_SLAVE_HEARTBEAT_FAILURE 13118 -#define ER_SLAVE_INCIDENT 13119 -#define ER_SLAVE_MASTER_COM_FAILURE 13120 -#define ER_SLAVE_RELAY_LOG_READ_FAILURE 13121 -#define ER_SLAVE_RELAY_LOG_WRITE_FAILURE 13122 -#define ER_SERVER_SLAVE_MI_INIT_REPOSITORY 13123 -#define ER_SERVER_SLAVE_RLI_INIT_REPOSITORY 13124 -#define ER_SERVER_NET_PACKET_TOO_LARGE 13125 -#define ER_SERVER_NO_SYSTEM_TABLE_ACCESS 13126 -#define ER_SERVER_UNKNOWN_ERROR 13127 -#define ER_SERVER_UNKNOWN_SYSTEM_VARIABLE 13128 -#define ER_SERVER_NO_SESSION_TO_SEND_TO 13129 -#define ER_SERVER_NEW_ABORTING_CONNECTION 13130 -#define ER_SERVER_OUT_OF_SORTMEMORY 13131 -#define ER_SERVER_RECORD_FILE_FULL 13132 -#define ER_SERVER_DISK_FULL_NOWAIT 13133 -#define ER_SERVER_HANDLER_ERROR 13134 -#define ER_SERVER_NOT_FORM_FILE 13135 -#define ER_SERVER_CANT_OPEN_FILE 13136 -#define ER_SERVER_FILE_NOT_FOUND 13137 -#define ER_SERVER_FILE_USED 13138 -#define ER_SERVER_CANNOT_LOAD_FROM_TABLE_V2 13139 -#define ER_ERROR_INFO_FROM_DA 13140 -#define ER_SERVER_TABLE_CHECK_FAILED 13141 -#define ER_SERVER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE_V2 13142 -#define ER_SERVER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2 13143 -#define ER_SERVER_ACL_TABLE_ERROR 13144 -#define ER_SERVER_SLAVE_INIT_QUERY_FAILED 13145 -#define ER_SERVER_SLAVE_CONVERSION_FAILED 13146 -#define ER_SERVER_SLAVE_IGNORED_TABLE 13147 -#define ER_CANT_REPLICATE_ANONYMOUS_WITH_AUTO_POSITION 13148 -#define ER_CANT_REPLICATE_ANONYMOUS_WITH_GTID_MODE_ON 13149 -#define ER_CANT_REPLICATE_GTID_WITH_GTID_MODE_OFF 13150 -#define ER_SERVER_TEST_MESSAGE 13151 -#define ER_AUDIT_LOG_JSON_FILTER_PARSING_ERROR 13152 -#define ER_AUDIT_LOG_JSON_FILTERING_NOT_ENABLED 13153 -#define ER_PLUGIN_FAILED_TO_OPEN_TABLES 13154 -#define ER_PLUGIN_FAILED_TO_OPEN_TABLE 13155 -#define ER_AUDIT_LOG_JSON_FILTER_NAME_CANNOT_BE_EMPTY 13156 -#define ER_AUDIT_LOG_USER_NAME_INVALID_CHARACTER 13157 -#define ER_AUDIT_LOG_UDF_INSUFFICIENT_PRIVILEGE 13158 -#define ER_AUDIT_LOG_NO_KEYRING_PLUGIN_INSTALLED 13159 -#define ER_AUDIT_LOG_HOST_NAME_INVALID_CHARACTER 13160 -#define ER_AUDIT_LOG_ENCRYPTION_PASSWORD_HAS_NOT_BEEN_SET 13161 -#define ER_AUDIT_LOG_COULD_NOT_CREATE_AES_KEY 13162 -#define ER_AUDIT_LOG_ENCRYPTION_PASSWORD_CANNOT_BE_FETCHED 13163 -#define ER_COULD_NOT_REINITIALIZE_AUDIT_LOG_FILTERS 13164 -#define ER_AUDIT_LOG_JSON_USER_NAME_CANNOT_BE_EMPTY 13165 -#define ER_AUDIT_LOG_USER_FIRST_CHARACTER_MUST_BE_ALPHANUMERIC 13166 -#define ER_AUDIT_LOG_JSON_FILTER_DOES_NOT_EXIST 13167 -#define ER_IB_MSG_1271 13168 -#define ER_STARTING_INIT 13169 -#define ER_ENDING_INIT 13170 -#define ER_IB_MSG_1272 13171 -#define ER_SERVER_SHUTDOWN_INFO 13172 -#define ER_GRP_RPL_PLUGIN_ABORT 13173 -//#define OBSOLETE_ER_REGEXP_INVALID_FLAG 13174 -//#define OBSOLETE_ER_XA_REPLICATION_FILTERS 13175 -//#define OBSOLETE_ER_UPDATE_GTID_PURGED_WITH_GR 13176 -#define ER_AUDIT_LOG_TABLE_DEFINITION_NOT_UPDATED 13177 -#define ER_DD_INITIALIZE_SQL_ERROR 13178 -#define ER_NO_PATH_FOR_SHARED_LIBRARY 13179 -#define ER_UDF_ALREADY_EXISTS 13180 -#define ER_SET_EVENT_FAILED 13181 -#define ER_FAILED_TO_ALLOCATE_SSL_BIO 13182 -#define ER_IB_MSG_1273 13183 -#define ER_PID_FILEPATH_LOCATIONS_INACCESSIBLE 13184 -#define ER_UNKNOWN_VARIABLE_IN_PERSISTED_CONFIG_FILE 13185 -#define ER_FAILED_TO_HANDLE_DEFAULTS_FILE 13186 -#define ER_DUPLICATE_SYS_VAR 13187 -#define ER_FAILED_TO_INIT_SYS_VAR 13188 -#define ER_SYS_VAR_NOT_FOUND 13189 -#define ER_IB_MSG_1274 13190 -#define ER_IB_MSG_1275 13191 -//#define OBSOLETE_ER_TARGET_TS_UNENCRYPTED 13192 -#define ER_IB_MSG_WAIT_FOR_ENCRYPT_THREAD 13193 -#define ER_IB_MSG_1277 13194 -#define ER_IB_MSG_NO_ENCRYPT_PROGRESS_FOUND 13195 -#define ER_IB_MSG_RESUME_OP_FOR_SPACE 13196 -#define ER_IB_MSG_1280 13197 -#define ER_IB_MSG_1281 13198 -#define ER_IB_MSG_1282 13199 -#define ER_IB_MSG_1283 13200 -#define ER_IB_MSG_1284 13201 -#define ER_CANT_SET_ERROR_SUPPRESSION_LIST_FROM_COMMAND_LINE 13202 -#define ER_INVALID_VALUE_OF_BIND_ADDRESSES 13203 -#define ER_RELAY_LOG_SPACE_LIMIT_DISABLED 13204 -#define ER_GRP_RPL_ERROR_GTID_SET_EXTRACTION 13205 -#define ER_GRP_RPL_MISSING_GRP_RPL_ACTION_COORDINATOR 13206 -#define ER_GRP_RPL_JOIN_WHEN_GROUP_ACTION_RUNNING 13207 -#define ER_GRP_RPL_JOINER_EXIT_WHEN_GROUP_ACTION_RUNNING 13208 -#define ER_GRP_RPL_CHANNEL_THREAD_WHEN_GROUP_ACTION_RUNNING 13209 -#define ER_GRP_RPL_APPOINTED_PRIMARY_NOT_PRESENT 13210 -#define ER_GRP_RPL_ERROR_ON_MESSAGE_SENDING 13211 -#define ER_GRP_RPL_CONFIGURATION_ACTION_ERROR 13212 -#define ER_GRP_RPL_CONFIGURATION_ACTION_LOCAL_TERMINATION 13213 -#define ER_GRP_RPL_CONFIGURATION_ACTION_START 13214 -#define ER_GRP_RPL_CONFIGURATION_ACTION_END 13215 -#define ER_GRP_RPL_CONFIGURATION_ACTION_KILLED_ERROR 13216 -#define ER_GRP_RPL_PRIMARY_ELECTION_PROCESS_ERROR 13217 -#define ER_GRP_RPL_PRIMARY_ELECTION_STOP_ERROR 13218 -#define ER_GRP_RPL_NO_STAGE_SERVICE 13219 -#define ER_GRP_RPL_UDF_REGISTER_ERROR 13220 -#define ER_GRP_RPL_UDF_UNREGISTER_ERROR 13221 -#define ER_GRP_RPL_UDF_REGISTER_SERVICE_ERROR 13222 -#define ER_GRP_RPL_SERVER_UDF_ERROR 13223 -//#define OBSOLETE_ER_CURRENT_PASSWORD_NOT_REQUIRED 13224 -//#define OBSOLETE_ER_INCORRECT_CURRENT_PASSWORD 13225 -//#define OBSOLETE_ER_MISSING_CURRENT_PASSWORD 13226 -#define ER_SERVER_WRONG_VALUE_FOR_VAR 13227 -#define ER_COULD_NOT_CREATE_WINDOWS_REGISTRY_KEY 13228 -#define ER_SERVER_GTID_UNSAFE_CREATE_DROP_TEMP_TABLE_IN_TRX_IN_SBR 13229 -//#define OBSOLETE_ER_SECONDARY_ENGINE 13230 -//#define OBSOLETE_ER_SECONDARY_ENGINE_DDL 13231 -//#define OBSOLETE_ER_NO_SESSION_TEMP 13232 -#define ER_XPLUGIN_FAILED_TO_SWITCH_SECURITY_CTX 13233 -#define ER_RPL_GTID_UNSAFE_ALTER_ADD_COL_WITH_DEFAULT_EXPRESSION 13234 -#define ER_UPGRADE_PARSE_ERROR 13235 -#define ER_DATA_DIRECTORY_UNUSABLE 13236 -#define ER_LDAP_AUTH_USER_GROUP_SEARCH_ROOT_BIND 13237 -#define ER_PLUGIN_INSTALL_ERROR 13238 -#define ER_PLUGIN_UNINSTALL_ERROR 13239 -#define ER_SHARED_TABLESPACE_USED_BY_PARTITIONED_TABLE 13240 -#define ER_UNKNOWN_TABLESPACE_TYPE 13241 -#define ER_WARN_DEPRECATED_UTF8_ALIAS_OPTION 13242 -#define ER_WARN_DEPRECATED_UTF8MB3_CHARSET_OPTION 13243 -#define ER_WARN_DEPRECATED_UTF8MB3_COLLATION_OPTION 13244 -#define ER_SSL_MEMORY_INSTRUMENTATION_INIT_FAILED 13245 -#define ER_IB_MSG_MADV_DONTDUMP_UNSUPPORTED 13246 -#define ER_IB_MSG_MADVISE_FAILED 13247 -//#define OBSOLETE_ER_COLUMN_CHANGE_SIZE 13248 -#define ER_WARN_REMOVED_SQL_MODE 13249 -#define ER_IB_MSG_FAILED_TO_ALLOCATE_WAIT 13250 -#define ER_IB_MSG_NUM_POOLS 13251 -#define ER_IB_MSG_USING_UNDO_SPACE 13252 -#define ER_IB_MSG_FAIL_TO_SAVE_SPACE_STATE 13253 -#define ER_IB_MSG_MAX_UNDO_SPACES_REACHED 13254 -#define ER_IB_MSG_ERROR_OPENING_NEW_UNDO_SPACE 13255 -#define ER_IB_MSG_FAILED_SDI_Z_BUF_ERROR 13256 -#define ER_IB_MSG_FAILED_SDI_Z_MEM_ERROR 13257 -#define ER_IB_MSG_SDI_Z_STREAM_ERROR 13258 -#define ER_IB_MSG_SDI_Z_UNKNOWN_ERROR 13259 -#define ER_IB_MSG_FOUND_WRONG_UNDO_SPACE 13260 -#define ER_IB_MSG_NOT_END_WITH_IBU 13261 -#define ER_IB_MSG_UNDO_TRUNC_EMPTY_FILE 13262 -#define ER_IB_MSG_UNDO_TRUNC_BEFOR_DD_UPDATE 13263 -#define ER_IB_MSG_UNDO_TRUNC_BEFORE_UNDO_LOGGING 13264 -#define ER_IB_MSG_UNDO_TRUNK_BEFORE_RSEG 13265 -#define ER_IB_MSG_FAILED_TO_FINISH_TRUNCATE 13266 -#define ER_IB_MSG_DEPRECATED_INNODB_UNDO_TABLESPACES 13267 -#define ER_IB_MSG_DIR_DOES_NOT_EXIST 13268 -#define ER_IB_MSG_LOCK_FREE_HASH_USAGE_STATS 13269 -#define ER_CLONE_DONOR_TRACE 13270 -#define ER_CLONE_PROTOCOL_TRACE 13271 -#define ER_CLONE_CLIENT_TRACE 13272 -#define ER_CLONE_SERVER_TRACE 13273 -#define ER_THREAD_POOL_PFS_TABLES_INIT_FAILED 13274 -#define ER_THREAD_POOL_PFS_TABLES_ADD_FAILED 13275 -#define ER_CANT_SET_DATA_DIR 13276 -#define ER_INNODB_INVALID_INNODB_UNDO_DIRECTORY_LOCATION 13277 -#define ER_SERVER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY 13278 -#define ER_SERVER_RPL_ENCRYPTION_KEY_NOT_FOUND 13279 -#define ER_SERVER_RPL_ENCRYPTION_KEYRING_INVALID_KEY 13280 -#define ER_SERVER_RPL_ENCRYPTION_HEADER_ERROR 13281 -#define ER_SERVER_RPL_ENCRYPTION_FAILED_TO_ROTATE_LOGS 13282 -#define ER_SERVER_RPL_ENCRYPTION_KEY_EXISTS_UNEXPECTED 13283 -#define ER_SERVER_RPL_ENCRYPTION_FAILED_TO_GENERATE_KEY 13284 -#define ER_SERVER_RPL_ENCRYPTION_FAILED_TO_STORE_KEY 13285 -#define ER_SERVER_RPL_ENCRYPTION_FAILED_TO_REMOVE_KEY 13286 -#define ER_SERVER_RPL_ENCRYPTION_MASTER_KEY_RECOVERY_FAILED 13287 -#define ER_SERVER_RPL_ENCRYPTION_UNABLE_TO_INITIALIZE 13288 -#define ER_SERVER_RPL_ENCRYPTION_UNABLE_TO_ROTATE_MASTER_KEY_AT_STARTUP 13289 -#define ER_SERVER_RPL_ENCRYPTION_IGNORE_ROTATE_MASTER_KEY_AT_STARTUP 13290 -#define ER_INVALID_ADMIN_ADDRESS 13291 -#define ER_SERVER_STARTUP_ADMIN_INTERFACE 13292 -#define ER_CANT_CREATE_ADMIN_THREAD 13293 -#define ER_WARNING_RETAIN_CURRENT_PASSWORD_CLAUSE_VOID 13294 -#define ER_WARNING_DISCARD_OLD_PASSWORD_CLAUSE_VOID 13295 -//#define OBSOLETE_ER_SECOND_PASSWORD_CANNOT_BE_EMPTY 13296 -//#define OBSOLETE_ER_PASSWORD_CANNOT_BE_RETAINED_ON_PLUGIN_CHANGE 13297 -//#define OBSOLETE_ER_CURRENT_PASSWORD_CANNOT_BE_RETAINED 13298 -#define ER_WARNING_AUTHCACHE_INVALID_USER_ATTRIBUTES 13299 -#define ER_MYSQL_NATIVE_PASSWORD_SECOND_PASSWORD_USED_INFORMATION 13300 -#define ER_SHA256_PASSWORD_SECOND_PASSWORD_USED_INFORMATION 13301 -#define ER_CACHING_SHA2_PASSWORD_SECOND_PASSWORD_USED_INFORMATION 13302 -#define ER_GRP_RPL_SEND_TRX_PREPARED_MESSAGE_FAILED 13303 -#define ER_GRP_RPL_RELEASE_COMMIT_AFTER_GROUP_PREPARE_FAILED 13304 -#define ER_GRP_RPL_TRX_ALREADY_EXISTS_ON_TCM_ON_AFTER_CERTIFICATION 13305 -#define ER_GRP_RPL_FAILED_TO_INSERT_TRX_ON_TCM_ON_AFTER_CERTIFICATION 13306 -#define ER_GRP_RPL_REGISTER_TRX_TO_WAIT_FOR_GROUP_PREPARE_FAILED 13307 -#define ER_GRP_RPL_TRX_WAIT_FOR_GROUP_PREPARE_FAILED 13308 -#define ER_GRP_RPL_TRX_DOES_NOT_EXIST_ON_TCM_ON_HANDLE_REMOTE_PREPARE 13309 -#define ER_GRP_RPL_RELEASE_BEGIN_TRX_AFTER_DEPENDENCIES_COMMIT_FAILED 13310 -#define ER_GRP_RPL_REGISTER_TRX_TO_WAIT_FOR_DEPENDENCIES_FAILED 13311 -#define ER_GRP_RPL_WAIT_FOR_DEPENDENCIES_FAILED 13312 -#define ER_GRP_RPL_REGISTER_TRX_TO_WAIT_FOR_SYNC_BEFORE_EXECUTION_FAILED 13313 -#define ER_GRP_RPL_SEND_TRX_SYNC_BEFORE_EXECUTION_FAILED 13314 -#define ER_GRP_RPL_TRX_WAIT_FOR_SYNC_BEFORE_EXECUTION_FAILED 13315 -#define ER_GRP_RPL_RELEASE_BEGIN_TRX_AFTER_WAIT_FOR_SYNC_BEFORE_EXEC 13316 -#define ER_GRP_RPL_TRX_WAIT_FOR_GROUP_GTID_EXECUTED 13317 -//#define OBSOLETE_ER_UNIT_NOT_FOUND 13318 -//#define OBSOLETE_ER_GEOMETRY_IN_UNKNOWN_LENGTH_UNIT 13319 -#define ER_WARN_PROPERTY_STRING_PARSE_FAILED 13320 -#define ER_INVALID_PROPERTY_KEY 13321 -#define ER_GRP_RPL_GTID_SET_EXTRACT_ERROR_DURING_RECOVERY 13322 -#define ER_SERVER_RPL_ENCRYPTION_FAILED_TO_ENCRYPT 13323 -#define ER_CANNOT_GET_SERVER_VERSION_FROM_TABLESPACE_HEADER 13324 -#define ER_CANNOT_SET_SERVER_VERSION_IN_TABLESPACE_HEADER 13325 -#define ER_SERVER_UPGRADE_VERSION_NOT_SUPPORTED 13326 -#define ER_SERVER_UPGRADE_FROM_VERSION 13327 -#define ER_GRP_RPL_ERROR_ON_CERT_DB_INSTALL 13328 -#define ER_GRP_RPL_FORCE_MEMBERS_WHEN_LEAVING 13329 -#define ER_TRG_WRONG_ORDER 13330 -//#define OBSOLETE_ER_SECONDARY_ENGINE_PLUGIN 13331 -#define ER_LDAP_AUTH_GRP_SEARCH_NOT_SPECIAL_HDL 13332 -#define ER_LDAP_AUTH_GRP_USER_OBJECT_HAS_GROUP_INFO 13333 -#define ER_LDAP_AUTH_GRP_INFO_FOUND_IN_MANY_OBJECTS 13334 -#define ER_LDAP_AUTH_GRP_INCORRECT_ATTRIBUTE 13335 -#define ER_LDAP_AUTH_GRP_NULL_ATTRIBUTE_VALUE 13336 -#define ER_LDAP_AUTH_GRP_DN_PARSING_FAILED 13337 -#define ER_LDAP_AUTH_GRP_OBJECT_HAS_USER_INFO 13338 -#define ER_LDAP_AUTH_LDAPS 13339 -#define ER_LDAP_MAPPING_GET_USER_PROXY 13340 -#define ER_LDAP_MAPPING_USER_DONT_BELONG_GROUP 13341 -#define ER_LDAP_MAPPING_INFO 13342 -#define ER_LDAP_MAPPING_EMPTY_MAPPING 13343 -#define ER_LDAP_MAPPING_PROCESS_MAPPING 13344 -#define ER_LDAP_MAPPING_CHECK_DELIMI_QUOTE 13345 -#define ER_LDAP_MAPPING_PROCESS_DELIMITER 13346 -#define ER_LDAP_MAPPING_PROCESS_DELIMITER_EQUAL_NOT_FOUND 13347 -#define ER_LDAP_MAPPING_PROCESS_DELIMITER_TRY_COMMA 13348 -#define ER_LDAP_MAPPING_PROCESS_DELIMITER_COMMA_NOT_FOUND 13349 -#define ER_LDAP_MAPPING_NO_SEPEARATOR_END_OF_GROUP 13350 -#define ER_LDAP_MAPPING_GETTING_NEXT_MAPPING 13351 -#define ER_LDAP_MAPPING_PARSING_CURRENT_STATE 13352 -#define ER_LDAP_MAPPING_PARSING_MAPPING_INFO 13353 -#define ER_LDAP_MAPPING_PARSING_ERROR 13354 -#define ER_LDAP_MAPPING_TRIMMING_SPACES 13355 -#define ER_LDAP_MAPPING_IS_QUOTE 13356 -#define ER_LDAP_MAPPING_NON_DESIRED_STATE 13357 -#define ER_INVALID_NAMED_PIPE_FULL_ACCESS_GROUP 13358 -#define ER_PREPARE_FOR_SECONDARY_ENGINE 13359 -#define ER_SERVER_WARN_DEPRECATED 13360 -#define ER_AUTH_ID_WITH_SYSTEM_USER_PRIV_IN_MANDATORY_ROLES 13361 -#define ER_SERVER_BINLOG_MASTER_KEY_RECOVERY_OUT_OF_COMBINATION 13362 -#define ER_SERVER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_AUX_KEY 13363 -//#define OBSOLETE_ER_CANNOT_GRANT_SYSTEM_PRIV_TO_MANDATORY_ROLE 13364 -//#define OBSOLETE_ER_PARTIAL_REVOKE_AND_DB_GRANT_BOTH_EXISTS 13365 -//#define OBSOLETE_ER_DB_ACCESS_DENIED 13366 -//#define OBSOLETE_ER_PARTIAL_REVOKES_EXIST 13367 -#define ER_TURNING_ON_PARTIAL_REVOKES 13368 -#define ER_WARN_PARTIAL_REVOKE_AND_DB_GRANT 13369 -#define ER_WARN_INCORRECT_PRIVILEGE_FOR_DB_RESTRICTIONS 13370 -#define ER_WARN_INVALID_DB_RESTRICTIONS 13371 -#define ER_GRP_RPL_INVALID_COMMUNICATION_PROTOCOL 13372 -#define ER_GRP_RPL_STARTED_AUTO_REJOIN 13373 -#define ER_GRP_RPL_TIMEOUT_RECEIVED_VC_ON_REJOIN 13374 -#define ER_GRP_RPL_FINISHED_AUTO_REJOIN 13375 -#define ER_GRP_RPL_DEFAULT_TABLE_ENCRYPTION_DIFF_FROM_GRP 13376 -#define ER_SERVER_UPGRADE_OFF 13377 -#define ER_SERVER_UPGRADE_SKIP 13378 -#define ER_SERVER_UPGRADE_PENDING 13379 -#define ER_SERVER_UPGRADE_FAILED 13380 -#define ER_SERVER_UPGRADE_STATUS 13381 -#define ER_SERVER_UPGRADE_REPAIR_REQUIRED 13382 -#define ER_SERVER_UPGRADE_REPAIR_STATUS 13383 -#define ER_SERVER_UPGRADE_INFO_FILE 13384 -#define ER_SERVER_UPGRADE_SYS_SCHEMA 13385 -#define ER_SERVER_UPGRADE_MYSQL_TABLES 13386 -#define ER_SERVER_UPGRADE_SYSTEM_TABLES 13387 -#define ER_SERVER_UPGRADE_EMPTY_SYS 13388 -#define ER_SERVER_UPGRADE_NO_SYS_VERSION 13389 -#define ER_SERVER_UPGRADE_SYS_VERSION_EMPTY 13390 -#define ER_SERVER_UPGRADE_SYS_SCHEMA_OUTDATED 13391 -#define ER_SERVER_UPGRADE_SYS_SCHEMA_UP_TO_DATE 13392 -#define ER_SERVER_UPGRADE_SYS_SCHEMA_OBJECT_COUNT 13393 -#define ER_SERVER_UPGRADE_CHECKING_DB 13394 -#define ER_IB_MSG_DDL_LOG_DELETE_BY_ID_TMCT 13395 -#define ER_IB_MSG_POST_RECOVER_DDL_LOG_RECOVER 13396 -#define ER_IB_MSG_POST_RECOVER_POST_TS_ENCRYPT 13397 -#define ER_IB_MSG_DDL_LOG_FAIL_POST_DDL 13398 -#define ER_SERVER_BINLOG_UNSAFE_SYSTEM_FUNCTION 13399 -#define ER_SERVER_UPGRADE_HELP_TABLE_STATUS 13400 -#define ER_GRP_RPL_SRV_GTID_WAIT_ERROR 13401 -#define ER_GRP_DELAYED_VCLE_LOGGING 13402 -//#define OBSOLETE_ER_CANNOT_GRANT_ROLES_TO_ANONYMOUS_USER 13403 -#define ER_BINLOG_UNABLE_TO_ROTATE_GTID_TABLE_READONLY 13404 -#define ER_NETWORK_NAMESPACES_NOT_SUPPORTED 13405 -#define ER_UNKNOWN_NETWORK_NAMESPACE 13406 -#define ER_NETWORK_NAMESPACE_NOT_ALLOWED_FOR_WILDCARD_ADDRESS 13407 -#define ER_SETNS_FAILED 13408 -#define ER_WILDCARD_NOT_ALLOWED_FOR_MULTIADDRESS_BIND 13409 -#define ER_NETWORK_NAMESPACE_FILE_PATH_TOO_LONG 13410 -#define ER_IB_MSG_TOO_LONG_PATH 13411 -#define ER_IB_RECV_FIRST_REC_GROUP_INVALID 13412 -#define ER_DD_UPGRADE_COMPLETED 13413 -#define ER_SSL_SERVER_CERT_VERIFY_FAILED 13414 -#define ER_PERSIST_OPTION_USER_TRUNCATED 13415 -#define ER_PERSIST_OPTION_HOST_TRUNCATED 13416 -#define ER_NET_WAIT_ERROR 13417 -#define ER_IB_MSG_1285 13418 -#define ER_IB_MSG_CLOCK_MONOTONIC_UNSUPPORTED 13419 -#define ER_IB_MSG_CLOCK_GETTIME_FAILED 13420 -#define ER_PLUGIN_NOT_EARLY_DUP 13421 -#define ER_PLUGIN_NO_INSTALL_DUP 13422 -#define ER_WARN_DEPRECATED_SQL_CALC_FOUND_ROWS 13423 -#define ER_WARN_DEPRECATED_FOUND_ROWS 13424 -#define ER_BINLOG_UNSAFE_DEFAULT_EXPRESSION_IN_SUBSTATEMENT 13425 -#define ER_GRP_RPL_MEMBER_VER_READ_COMPATIBLE 13426 -#define ER_LOCK_ORDER_INIT_FAILED 13427 -#define ER_AUDIT_LOG_KEYRING_ID_TIMESTAMP_VALUE_IS_INVALID 13428 -#define ER_AUDIT_LOG_FILE_NAME_TIMESTAMP_VALUE_IS_MISSING_OR_INVALID 13429 -#define ER_AUDIT_LOG_FILE_NAME_DOES_NOT_HAVE_REQUIRED_FORMAT 13430 -#define ER_AUDIT_LOG_FILE_NAME_KEYRING_ID_VALUE_IS_MISSING 13431 -#define ER_AUDIT_LOG_FILE_HAS_BEEN_SUCCESSFULLY_PROCESSED 13432 -#define ER_AUDIT_LOG_COULD_NOT_OPEN_FILE_FOR_READING 13433 -#define ER_AUDIT_LOG_INVALID_FILE_CONTENT 13434 -#define ER_AUDIT_LOG_CANNOT_READ_PASSWORD 13435 -#define ER_AUDIT_LOG_CANNOT_STORE_PASSWORD 13436 -#define ER_AUDIT_LOG_CANNOT_REMOVE_PASSWORD 13437 -#define ER_AUDIT_LOG_PASSWORD_HAS_BEEN_COPIED 13438 -//#define OBSOLETE_ER_AUDIT_LOG_INSUFFICIENT_PRIVILEGE 13439 -//#define OBSOLETE_ER_WRONG_MVI_VALUE 13440 -//#define OBSOLETE_ER_WARN_FUNC_INDEX_NOT_APPLICABLE 13441 -//#define OBSOLETE_ER_EXCEEDED_MV_KEYS_NUM 13442 -//#define OBSOLETE_ER_EXCEEDED_MV_KEYS_SPACE 13443 -//#define OBSOLETE_ER_FUNCTIONAL_INDEX_DATA_IS_TOO_LONG 13444 -//#define OBSOLETE_ER_INVALID_JSON_VALUE_FOR_FUNC_INDEX 13445 -//#define OBSOLETE_ER_JSON_VALUE_OUT_OF_RANGE_FOR_FUNC_INDEX 13446 -#define ER_LDAP_EMPTY_USERDN_PASSWORD 13447 -//#define OBSOLETE_ER_GROUPING_ON_TIMESTAMP_IN_DST 13448 -#define ER_ACL_WRONG_OR_MISSING_ACL_TABLES_LOG 13449 -#define ER_LOCK_ORDER_FAILED_WRITE_FILE 13450 -#define ER_LOCK_ORDER_FAILED_READ_FILE 13451 -#define ER_LOCK_ORDER_MESSAGE 13452 -#define ER_LOCK_ORDER_DEPENDENCIES_SYNTAX 13453 -#define ER_LOCK_ORDER_SCANNER_SYNTAX 13454 -#define ER_DATA_DIRECTORY_UNUSABLE_DELETABLE 13455 -#define ER_IB_MSG_BTREE_LEVEL_LIMIT_EXCEEDED 13456 -#define ER_IB_CLONE_START_STOP 13457 -#define ER_IB_CLONE_OPERATION 13458 -#define ER_IB_CLONE_RESTART 13459 -#define ER_IB_CLONE_USER_DATA 13460 -#define ER_IB_CLONE_NON_INNODB_TABLE 13461 -#define ER_CLONE_SHUTDOWN_TRACE 13462 -#define ER_GRP_RPL_GTID_PURGED_EXTRACT_ERROR 13463 -#define ER_GRP_RPL_CLONE_PROCESS_PREPARE_ERROR 13464 -#define ER_GRP_RPL_CLONE_PROCESS_EXEC_ERROR 13465 -#define ER_GRP_RPL_RECOVERY_EVAL_ERROR 13466 -#define ER_GRP_RPL_NO_POSSIBLE_RECOVERY 13467 -#define ER_GRP_RPL_CANT_KILL_THREAD 13468 -#define ER_GRP_RPL_RECOVERY_STRAT_CLONE_THRESHOLD 13469 -#define ER_GRP_RPL_RECOVERY_STRAT_CLONE_PURGED 13470 -#define ER_GRP_RPL_RECOVERY_STRAT_CHOICE 13471 -#define ER_GRP_RPL_RECOVERY_STRAT_FALLBACK 13472 -#define ER_GRP_RPL_RECOVERY_STRAT_NO_FALLBACK 13473 -#define ER_GRP_RPL_SLAVE_THREAD_ERROR_ON_CLONE 13474 -#define ER_UNKNOWN_TABLE_IN_UPGRADE 13475 -#define ER_IDENT_CAUSES_TOO_LONG_PATH_IN_UPGRADE 13476 -#define ER_XA_CANT_CREATE_MDL_BACKUP 13477 -#define ER_AUDIT_LOG_SUPER_PRIVILEGE_REQUIRED 13478 -#define ER_AUDIT_LOG_UDF_INVALID_ARGUMENT_TYPE 13479 -#define ER_AUDIT_LOG_UDF_INVALID_ARGUMENT_COUNT 13480 -#define ER_AUDIT_LOG_HAS_NOT_BEEN_INSTALLED 13481 -#define ER_AUDIT_LOG_UDF_READ_INVALID_MAX_ARRAY_LENGTH_ARG_TYPE 13482 -#define ER_LOG_CANNOT_WRITE_EXTENDED 13483 -#define ER_UPGRADE_WITH_PARTITIONED_TABLES_REJECTED 13484 -static const int obsolete_error_count = 454; +#define ER_ERROR_LAST_SECTION_4 3060 + +/* New section */ -#endif +#define ER_ERROR_FIRST_SECTION_5 4000 +#define ER_COMMULTI_BADCONTEXT 4000 +#define ER_BAD_COMMAND_IN_MULTI 4001 +#define ER_WITH_COL_WRONG_LIST 4002 +#define ER_TOO_MANY_DEFINITIONS_IN_WITH_CLAUSE 4003 +#define ER_DUP_QUERY_NAME 4004 +#define ER_RECURSIVE_WITHOUT_ANCHORS 4005 +#define ER_UNACCEPTABLE_MUTUAL_RECURSION 4006 +#define ER_REF_TO_RECURSIVE_WITH_TABLE_IN_DERIVED 4007 +#define ER_NOT_STANDARD_COMPLIANT_RECURSIVE 4008 +#define ER_WRONG_WINDOW_SPEC_NAME 4009 +#define ER_DUP_WINDOW_NAME 4010 +#define ER_PARTITION_LIST_IN_REFERENCING_WINDOW_SPEC 4011 +#define ER_ORDER_LIST_IN_REFERENCING_WINDOW_SPEC 4012 +#define ER_WINDOW_FRAME_IN_REFERENCED_WINDOW_SPEC 4013 +#define ER_BAD_COMBINATION_OF_WINDOW_FRAME_BOUND_SPECS 4014 +#define ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION 4015 +#define ER_WINDOW_FUNCTION_IN_WINDOW_SPEC 4016 +#define ER_NOT_ALLOWED_WINDOW_FRAME 4017 +#define ER_NO_ORDER_LIST_IN_WINDOW_SPEC 4018 +#define ER_RANGE_FRAME_NEEDS_SIMPLE_ORDERBY 4019 +#define ER_WRONG_TYPE_FOR_ROWS_FRAME 4020 +#define ER_WRONG_TYPE_FOR_RANGE_FRAME 4021 +#define ER_FRAME_EXCLUSION_NOT_SUPPORTED 4022 +#define ER_WINDOW_FUNCTION_DONT_HAVE_FRAME 4023 +#define ER_INVALID_NTILE_ARGUMENT 4024 +#define ER_CONSTRAINT_FAILED 4025 +#define ER_EXPRESSION_IS_TOO_BIG 4026 +#define ER_ERROR_EVALUATING_EXPRESSION 4027 +#define ER_CALCULATING_DEFAULT_VALUE 4028 +#define ER_EXPRESSION_REFERS_TO_UNINIT_FIELD 4029 +#define ER_PARTITION_DEFAULT_ERROR 4030 +#define ER_REFERENCED_TRG_DOES_NOT_EXIST 4031 +#define ER_INVALID_DEFAULT_PARAM 4032 +#define ER_BINLOG_NON_SUPPORTED_BULK 4033 +#define ER_BINLOG_UNCOMPRESS_ERROR 4034 +#define ER_JSON_BAD_CHR 4035 +#define ER_JSON_NOT_JSON_CHR 4036 +#define ER_JSON_EOS 4037 +#define ER_JSON_SYNTAX 4038 +#define ER_JSON_ESCAPING 4039 +#define ER_JSON_DEPTH 4040 +#define ER_JSON_PATH_EOS 4041 +#define ER_JSON_PATH_SYNTAX 4042 +#define ER_JSON_PATH_DEPTH 4043 +#define ER_JSON_PATH_NO_WILDCARD 4044 +#define ER_JSON_PATH_ARRAY 4045 +#define ER_JSON_ONE_OR_ALL 4046 +#define ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE 4047 +#define ER_GEOJSON_INCORRECT 4048 +#define ER_GEOJSON_TOO_FEW_POINTS 4049 +#define ER_GEOJSON_NOT_CLOSED 4050 +#define ER_JSON_PATH_EMPTY 4051 +#define ER_SLAVE_SAME_ID 4052 +#define ER_FLASHBACK_NOT_SUPPORTED 4053 +#define ER_KEYS_OUT_OF_ORDER 4054 +#define ER_OVERLAPPING_KEYS 4055 +#define ER_REQUIRE_ROW_BINLOG_FORMAT 4056 +#define ER_ISOLATION_MODE_NOT_SUPPORTED 4057 +#define ER_ON_DUPLICATE_DISABLED 4058 +#define ER_UPDATES_WITH_CONSISTENT_SNAPSHOT 4059 +#define ER_ROLLBACK_ONLY 4060 +#define ER_ROLLBACK_TO_SAVEPOINT 4061 +#define ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT 4062 +#define ER_UNSUPPORTED_COLLATION 4063 +#define ER_METADATA_INCONSISTENCY 4064 +#define ER_KEY_CREATE_DURING_ALTER 4065 +#define ER_SK_POPULATE_DURING_ALTER 4066 +#define ER_CF_DIFFERENT 4067 +#define ER_RDB_STATUS_GENERAL 4068 +#define ER_RDB_STATUS_MSG 4069 +#define ER_NET_OK_PACKET_TOO_LARGE 4070 +#define ER_RDB_TTL_UNSUPPORTED 4071 +#define ER_RDB_TTL_COL_FORMAT 4072 +#define ER_RDB_TTL_DURATION_FORMAT 4073 +#define ER_PER_INDEX_CF_DEPRECATED 4074 +#define ER_ERROR_LAST 4074 diff --git a/MySQL/include/mysqlx_ername.h b/MySQL/include/mysqlx_ername.h deleted file mode 100644 index 8db2358..0000000 --- a/MySQL/include/mysqlx_ername.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2.0, - * as published by the Free Software Foundation. - * - * This program is also distributed with certain software (including - * but not limited to OpenSSL) that is licensed under separate terms, - * as designated in a particular file or component or in included license - * documentation. The authors of MySQL hereby grant you an additional - * permission to link the program and your derivative works with the - * separately licensed software that they have included with MySQL. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License, version 2.0, for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Autogenerated file, please don't edit */ - -#include "mysqlx_error.h" - - {"ER_X_BAD_MESSAGE", ER_X_BAD_MESSAGE, "", NULL, NULL, 0 }, - {"ER_X_CAPABILITIES_PREPARE_FAILED", ER_X_CAPABILITIES_PREPARE_FAILED, "", NULL, NULL, 0 }, - {"ER_X_CAPABILITY_NOT_FOUND", ER_X_CAPABILITY_NOT_FOUND, "", NULL, NULL, 0 }, - {"ER_X_INVALID_PROTOCOL_DATA", ER_X_INVALID_PROTOCOL_DATA, "", NULL, NULL, 0 }, - {"ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_VALUE_LENGTH", ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_VALUE_LENGTH, "", NULL, NULL, 0 }, - {"ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_KEY_LENGTH", ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_KEY_LENGTH, "", NULL, NULL, 0 }, - {"ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_EMPTY_KEY", ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_EMPTY_KEY, "", NULL, NULL, 0 }, - {"ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_LENGTH", ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_LENGTH, "", NULL, NULL, 0 }, - {"ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_TYPE", ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_TYPE, "", NULL, NULL, 0 }, - {"ER_X_CAPABILITY_SET_NOT_ALLOWED", ER_X_CAPABILITY_SET_NOT_ALLOWED, "", NULL, NULL, 0 }, - {"ER_X_DUPLICATED_CAPABILITIES", ER_X_DUPLICATED_CAPABILITIES, "", NULL, NULL, 0 }, - {"ER_X_SERVICE_ERROR", ER_X_SERVICE_ERROR, "", NULL, NULL, 0 }, - {"ER_X_SESSION", ER_X_SESSION, "", NULL, NULL, 0 }, - {"ER_X_INVALID_ARGUMENT", ER_X_INVALID_ARGUMENT, "", NULL, NULL, 0 }, - {"ER_X_MISSING_ARGUMENT", ER_X_MISSING_ARGUMENT, "", NULL, NULL, 0 }, - {"ER_X_BAD_INSERT_DATA", ER_X_BAD_INSERT_DATA, "", NULL, NULL, 0 }, - {"ER_X_CMD_NUM_ARGUMENTS", ER_X_CMD_NUM_ARGUMENTS, "", NULL, NULL, 0 }, - {"ER_X_CMD_ARGUMENT_TYPE", ER_X_CMD_ARGUMENT_TYPE, "", NULL, NULL, 0 }, - {"ER_X_CMD_ARGUMENT_VALUE", ER_X_CMD_ARGUMENT_VALUE, "", NULL, NULL, 0 }, - {"ER_X_BAD_UPSERT_DATA", ER_X_BAD_UPSERT_DATA, "", NULL, NULL, 0 }, - {"ER_X_BAD_UPDATE_DATA", ER_X_BAD_UPDATE_DATA, "", NULL, NULL, 0 }, - {"ER_X_BAD_TYPE_OF_UPDATE", ER_X_BAD_TYPE_OF_UPDATE, "", NULL, NULL, 0 }, - {"ER_X_BAD_COLUMN_TO_UPDATE", ER_X_BAD_COLUMN_TO_UPDATE, "", NULL, NULL, 0 }, - {"ER_X_BAD_MEMBER_TO_UPDATE", ER_X_BAD_MEMBER_TO_UPDATE, "", NULL, NULL, 0 }, - {"ER_X_BAD_STATEMENT_ID", ER_X_BAD_STATEMENT_ID, "", NULL, NULL, 0 }, - {"ER_X_BAD_CURSOR_ID", ER_X_BAD_CURSOR_ID, "", NULL, NULL, 0 }, - {"ER_X_BAD_SCHEMA", ER_X_BAD_SCHEMA, "", NULL, NULL, 0 }, - {"ER_X_BAD_TABLE", ER_X_BAD_TABLE, "", NULL, NULL, 0 }, - {"ER_X_BAD_PROJECTION", ER_X_BAD_PROJECTION, "", NULL, NULL, 0 }, - {"ER_X_DOC_ID_MISSING", ER_X_DOC_ID_MISSING, "", NULL, NULL, 0 }, - {"ER_X_DOC_ID_DUPLICATE", ER_X_DOC_ID_DUPLICATE, "", NULL, NULL, 0 }, - {"ER_X_DOC_REQUIRED_FIELD_MISSING", ER_X_DOC_REQUIRED_FIELD_MISSING, "", NULL, NULL, 0 }, - {"ER_X_PROJ_BAD_KEY_NAME", ER_X_PROJ_BAD_KEY_NAME, "", NULL, NULL, 0 }, - {"ER_X_BAD_DOC_PATH", ER_X_BAD_DOC_PATH, "", NULL, NULL, 0 }, - {"ER_X_CURSOR_EXISTS", ER_X_CURSOR_EXISTS, "", NULL, NULL, 0 }, - {"ER_X_CURSOR_REACHED_EOF", ER_X_CURSOR_REACHED_EOF, "", NULL, NULL, 0 }, - {"ER_X_PREPARED_STATMENT_CAN_HAVE_ONE_CURSOR", ER_X_PREPARED_STATMENT_CAN_HAVE_ONE_CURSOR, "", NULL, NULL, 0 }, - {"ER_X_PREPARED_EXECUTE_ARGUMENT_NOT_SUPPORTED", ER_X_PREPARED_EXECUTE_ARGUMENT_NOT_SUPPORTED, "", NULL, NULL, 0 }, - {"ER_X_PREPARED_EXECUTE_ARGUMENT_CONSISTENCY", ER_X_PREPARED_EXECUTE_ARGUMENT_CONSISTENCY, "", NULL, NULL, 0 }, - {"ER_X_EXPR_BAD_OPERATOR", ER_X_EXPR_BAD_OPERATOR, "", NULL, NULL, 0 }, - {"ER_X_EXPR_BAD_NUM_ARGS", ER_X_EXPR_BAD_NUM_ARGS, "", NULL, NULL, 0 }, - {"ER_X_EXPR_MISSING_ARG", ER_X_EXPR_MISSING_ARG, "", NULL, NULL, 0 }, - {"ER_X_EXPR_BAD_TYPE_VALUE", ER_X_EXPR_BAD_TYPE_VALUE, "", NULL, NULL, 0 }, - {"ER_X_EXPR_BAD_VALUE", ER_X_EXPR_BAD_VALUE, "", NULL, NULL, 0 }, - {"ER_X_INVALID_COLLECTION", ER_X_INVALID_COLLECTION, "", NULL, NULL, 0 }, - {"ER_X_INVALID_ADMIN_COMMAND", ER_X_INVALID_ADMIN_COMMAND, "", NULL, NULL, 0 }, - {"ER_X_EXPECT_NOT_OPEN", ER_X_EXPECT_NOT_OPEN, "", NULL, NULL, 0 }, - {"ER_X_EXPECT_NO_ERROR_FAILED", ER_X_EXPECT_NO_ERROR_FAILED, "", NULL, NULL, 0 }, - {"ER_X_EXPECT_BAD_CONDITION", ER_X_EXPECT_BAD_CONDITION, "", NULL, NULL, 0 }, - {"ER_X_EXPECT_BAD_CONDITION_VALUE", ER_X_EXPECT_BAD_CONDITION_VALUE, "", NULL, NULL, 0 }, - {"ER_X_INVALID_NAMESPACE", ER_X_INVALID_NAMESPACE, "", NULL, NULL, 0 }, - {"ER_X_BAD_NOTICE", ER_X_BAD_NOTICE, "", NULL, NULL, 0 }, - {"ER_X_CANNOT_DISABLE_NOTICE", ER_X_CANNOT_DISABLE_NOTICE, "", NULL, NULL, 0 }, - {"ER_X_BAD_CONFIGURATION", ER_X_BAD_CONFIGURATION, "", NULL, NULL, 0 }, - {"ER_X_MYSQLX_ACCOUNT_MISSING_PERMISSIONS", ER_X_MYSQLX_ACCOUNT_MISSING_PERMISSIONS, "", NULL, NULL, 0 }, - {"ER_X_EXPECT_FIELD_EXISTS_FAILED", ER_X_EXPECT_FIELD_EXISTS_FAILED, "", NULL, NULL, 0 }, - {"ER_X_BAD_LOCKING", ER_X_BAD_LOCKING, "", NULL, NULL, 0 }, - diff --git a/MySQL/include/mysqlx_error.h b/MySQL/include/mysqlx_error.h deleted file mode 100644 index cbd1f7b..0000000 --- a/MySQL/include/mysqlx_error.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2.0, - as published by the Free Software Foundation. - - This program is also distributed with certain software (including - but not limited to OpenSSL) that is licensed under separate terms, - as designated in a particular file or component or in included license - documentation. The authors of MySQL hereby grant you an additional - permission to link the program and your derivative works with the - separately licensed software that they have included with MySQL. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License, version 2.0, for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - - -#ifndef _MYSQLX_ERROR_H_ -#define _MYSQLX_ERROR_H_ - -#define ER_X_BAD_MESSAGE 5000 -#define ER_X_CAPABILITIES_PREPARE_FAILED 5001 -#define ER_X_CAPABILITY_NOT_FOUND 5002 -#define ER_X_INVALID_PROTOCOL_DATA 5003 -#define ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_VALUE_LENGTH 5004 -#define ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_KEY_LENGTH 5005 -#define ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_EMPTY_KEY 5006 -#define ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_LENGTH 5007 -#define ER_X_BAD_CONNECTION_SESSION_ATTRIBUTE_TYPE 5008 -#define ER_X_CAPABILITY_SET_NOT_ALLOWED 5009 -#define ER_X_DUPLICATED_CAPABILITIES 5010 - -#define ER_X_SERVICE_ERROR 5010 -#define ER_X_SESSION 5011 -#define ER_X_INVALID_ARGUMENT 5012 -#define ER_X_MISSING_ARGUMENT 5013 -#define ER_X_BAD_INSERT_DATA 5014 -#define ER_X_CMD_NUM_ARGUMENTS 5015 -#define ER_X_CMD_ARGUMENT_TYPE 5016 -#define ER_X_CMD_ARGUMENT_VALUE 5017 -#define ER_X_BAD_UPSERT_DATA 5018 -#define ER_X_BAD_UPDATE_DATA 5050 -#define ER_X_BAD_TYPE_OF_UPDATE 5051 -#define ER_X_BAD_COLUMN_TO_UPDATE 5052 -#define ER_X_BAD_MEMBER_TO_UPDATE 5053 -#define ER_X_BAD_STATEMENT_ID 5110 -#define ER_X_BAD_CURSOR_ID 5111 -#define ER_X_BAD_SCHEMA 5112 -#define ER_X_BAD_TABLE 5113 -#define ER_X_BAD_PROJECTION 5114 -#define ER_X_DOC_ID_MISSING 5115 -#define ER_X_DOC_ID_DUPLICATE 5116 -#define ER_X_DOC_REQUIRED_FIELD_MISSING 5117 -#define ER_X_PROJ_BAD_KEY_NAME 5120 -#define ER_X_BAD_DOC_PATH 5121 -#define ER_X_CURSOR_EXISTS 5122 -#define ER_X_CURSOR_REACHED_EOF 5123 -#define ER_X_PREPARED_STATMENT_CAN_HAVE_ONE_CURSOR 5131 -#define ER_X_PREPARED_EXECUTE_ARGUMENT_NOT_SUPPORTED 5133 -#define ER_X_PREPARED_EXECUTE_ARGUMENT_CONSISTENCY 5134 -#define ER_X_EXPR_BAD_OPERATOR 5150 -#define ER_X_EXPR_BAD_NUM_ARGS 5151 -#define ER_X_EXPR_MISSING_ARG 5152 -#define ER_X_EXPR_BAD_TYPE_VALUE 5153 -#define ER_X_EXPR_BAD_VALUE 5154 -#define ER_X_INVALID_COLLECTION 5156 -#define ER_X_INVALID_ADMIN_COMMAND 5157 -#define ER_X_EXPECT_NOT_OPEN 5158 -#define ER_X_EXPECT_NO_ERROR_FAILED 5159 -#define ER_X_EXPECT_BAD_CONDITION 5160 -#define ER_X_EXPECT_BAD_CONDITION_VALUE 5161 -#define ER_X_INVALID_NAMESPACE 5162 -#define ER_X_BAD_NOTICE 5163 -#define ER_X_CANNOT_DISABLE_NOTICE 5164 -#define ER_X_BAD_CONFIGURATION 5165 -#define ER_X_MYSQLX_ACCOUNT_MISSING_PERMISSIONS 5167 -#define ER_X_EXPECT_FIELD_EXISTS_FAILED 5168 -#define ER_X_BAD_LOCKING 5169 - -#endif // _MYSQLX_ERROR_H_ diff --git a/MySQL/include/mysqlx_version.h b/MySQL/include/mysqlx_version.h deleted file mode 100644 index 773b2cd..0000000 --- a/MySQL/include/mysqlx_version.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2.0, - * as published by the Free Software Foundation. - * - * This program is also distributed with certain software (including - * but not limited to OpenSSL) that is licensed under separate terms, - * as designated in a particular file or component or in included license - * documentation. The authors of MySQL hereby grant you an additional - * permission to link the program and your derivative works with the - * separately licensed software that they have included with MySQL. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License, version 2.0, for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Version numbers for X Plugin */ - -#ifndef _MYSQLX_VERSION_H_ -#define _MYSQLX_VERSION_H_ - -#define MYSQLX_PLUGIN_VERSION_MAJOR 1 -#define MYSQLX_PLUGIN_VERSION_MINOR 0 -#define MYSQLX_PLUGIN_VERSION_PATCH 2 - -#define MYSQLX_PLUGIN_NAME "mysqlx" -#define MYSQLX_STATUS_VARIABLE_PREFIX(NAME) "Mysqlx_" NAME -#define MYSQLX_SYSTEM_VARIABLE_PREFIX(NAME) "mysqlx_" NAME - -#define MYSQLX_TCP_PORT 33060U -#define MYSQLX_UNIX_ADDR "/tmp/mysqlx.sock" - -#define MYSQLX_PLUGIN_VERSION ( (MYSQLX_PLUGIN_VERSION_MAJOR << 8) | MYSQLX_PLUGIN_VERSION_MINOR ) -#define MYSQLX_PLUGIN_VERSION_STRING "1.0.2" - -#endif // _MYSQLX_VERSION_H_ diff --git a/MySQL/include/openssl/applink.c b/MySQL/include/openssl/applink.c deleted file mode 100644 index 2831b39..0000000 --- a/MySQL/include/openssl/applink.c +++ /dev/null @@ -1,129 +0,0 @@ -#define APPLINK_STDIN 1 -#define APPLINK_STDOUT 2 -#define APPLINK_STDERR 3 -#define APPLINK_FPRINTF 4 -#define APPLINK_FGETS 5 -#define APPLINK_FREAD 6 -#define APPLINK_FWRITE 7 -#define APPLINK_FSETMOD 8 -#define APPLINK_FEOF 9 -#define APPLINK_FCLOSE 10 /* should not be used */ - -#define APPLINK_FOPEN 11 /* solely for completeness */ -#define APPLINK_FSEEK 12 -#define APPLINK_FTELL 13 -#define APPLINK_FFLUSH 14 -#define APPLINK_FERROR 15 -#define APPLINK_CLEARERR 16 -#define APPLINK_FILENO 17 /* to be used with below */ - -#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */ -#define APPLINK_READ 19 -#define APPLINK_WRITE 20 -#define APPLINK_LSEEK 21 -#define APPLINK_CLOSE 22 -#define APPLINK_MAX 22 /* always same as last macro */ - -#ifndef APPMACROS_ONLY -# include -# include -# include - -static void *app_stdin(void) -{ - return stdin; -} - -static void *app_stdout(void) -{ - return stdout; -} - -static void *app_stderr(void) -{ - return stderr; -} - -static int app_feof(FILE *fp) -{ - return feof(fp); -} - -static int app_ferror(FILE *fp) -{ - return ferror(fp); -} - -static void app_clearerr(FILE *fp) -{ - clearerr(fp); -} - -static int app_fileno(FILE *fp) -{ - return _fileno(fp); -} - -static int app_fsetmod(FILE *fp, char mod) -{ - return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT); -} - -#ifdef __cplusplus -extern "C" { -#endif - -__declspec(dllexport) -void ** -# if defined(__BORLANDC__) -/* - * __stdcall appears to be the only way to get the name - * decoration right with Borland C. Otherwise it works - * purely incidentally, as we pass no parameters. - */ - __stdcall -# else - __cdecl -# endif -OPENSSL_Applink(void) -{ - static int once = 1; - static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] = - { (void *)APPLINK_MAX }; - - if (once) { - OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin; - OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout; - OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr; - OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf; - OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets; - OPENSSL_ApplinkTable[APPLINK_FREAD] = fread; - OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite; - OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod; - OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof; - OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose; - - OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen; - OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek; - OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell; - OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush; - OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror; - OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr; - OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno; - - OPENSSL_ApplinkTable[APPLINK_OPEN] = _open; - OPENSSL_ApplinkTable[APPLINK_READ] = _read; - OPENSSL_ApplinkTable[APPLINK_WRITE] = _write; - OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek; - OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close; - - once = 0; - } - - return OPENSSL_ApplinkTable; -} - -#ifdef __cplusplus -} -#endif -#endif diff --git a/MySQL/lib/linux/libcrypto.a b/MySQL/lib/linux/libcrypto.a new file mode 100644 index 0000000..1c022dc Binary files /dev/null and b/MySQL/lib/linux/libcrypto.a differ diff --git a/MySQL/lib/linux/libmariadbclient.a b/MySQL/lib/linux/libmariadbclient.a new file mode 100644 index 0000000..6de7d2c Binary files /dev/null and b/MySQL/lib/linux/libmariadbclient.a differ diff --git a/MySQL/lib/linux/libssl.a b/MySQL/lib/linux/libssl.a new file mode 100644 index 0000000..882cfaa Binary files /dev/null and b/MySQL/lib/linux/libssl.a differ diff --git a/MySQL/lib/windows/mariadbclient.lib b/MySQL/lib/windows/mariadbclient.lib new file mode 100644 index 0000000..0547572 Binary files /dev/null and b/MySQL/lib/windows/mariadbclient.lib differ diff --git a/MySQL/lib64/linux/libcrypto.a b/MySQL/lib64/linux/libcrypto.a new file mode 100644 index 0000000..12715c1 Binary files /dev/null and b/MySQL/lib64/linux/libcrypto.a differ diff --git a/MySQL/lib64/linux/libmariadbclient.a b/MySQL/lib64/linux/libmariadbclient.a new file mode 100644 index 0000000..031c7c5 Binary files /dev/null and b/MySQL/lib64/linux/libmariadbclient.a differ diff --git a/MySQL/lib64/linux/libmysqlclient.so b/MySQL/lib64/linux/libmysqlclient.so deleted file mode 100644 index feb683b..0000000 Binary files a/MySQL/lib64/linux/libmysqlclient.so and /dev/null differ diff --git a/MySQL/lib64/linux/libssl.a b/MySQL/lib64/linux/libssl.a new file mode 100644 index 0000000..cf927b9 Binary files /dev/null and b/MySQL/lib64/linux/libssl.a differ diff --git a/MySQL/lib64/windows/libeay32.dll b/MySQL/lib64/windows/libeay32.dll deleted file mode 100644 index 171615f..0000000 Binary files a/MySQL/lib64/windows/libeay32.dll and /dev/null differ diff --git a/MySQL/lib64/windows/libmysql.dll b/MySQL/lib64/windows/libmysql.dll deleted file mode 100644 index d7308d3..0000000 Binary files a/MySQL/lib64/windows/libmysql.dll and /dev/null differ diff --git a/MySQL/lib64/windows/libmysql.lib b/MySQL/lib64/windows/libmysql.lib deleted file mode 100644 index 8ea615d..0000000 Binary files a/MySQL/lib64/windows/libmysql.lib and /dev/null differ diff --git a/MySQL/lib64/windows/mariadbclient.lib b/MySQL/lib64/windows/mariadbclient.lib new file mode 100644 index 0000000..2c5776a Binary files /dev/null and b/MySQL/lib64/windows/mariadbclient.lib differ diff --git a/MySQL/lib64/windows/ssleay32.dll b/MySQL/lib64/windows/ssleay32.dll deleted file mode 100644 index 717ac1d..0000000 Binary files a/MySQL/lib64/windows/ssleay32.dll and /dev/null differ diff --git a/MySQLOO/include/BlockingQueue.h b/MySQLOO/include/BlockingQueue.h deleted file mode 100644 index fe60d45..0000000 --- a/MySQLOO/include/BlockingQueue.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef BLOCKING_QUEUE_ -#define BLOCKING_QUEUE_ -#include -#include -#include -#include - -template -class BlockingQueue { -public: - BlockingQueue() { } - - void put(T elem) { - std::lock_guard lock(mutex); - backingQueue.push_back(elem); - waitObj.notify_all(); - } - - bool empty() { - return size() == 0; - } - - bool swapToFrontIf(std::function func) { - std::lock_guard lock(mutex); - auto pos = std::find_if(backingQueue.begin(), backingQueue.end(), func); - if (pos != backingQueue.begin() && pos != backingQueue.end()) { - std::iter_swap(pos, backingQueue.begin()); - return true; - } - return false; - } - - bool removeIf(std::function func) { - std::lock_guard lock(mutex); - auto pos = std::find_if(backingQueue.begin(), backingQueue.end(), func); - if (pos != backingQueue.begin() && pos != backingQueue.end()) { - backingQueue.erase(pos); - return true; - } - return false; - } - - void remove(T elem) { - std::lock_guard lock(mutex); - backingQueue.erase(std::remove(backingQueue.begin(), backingQueue.end(), elem)); - } - - size_t size() { - std::lock_guard lock(mutex); - return backingQueue.size(); - } - - T take() { - std::unique_lock lock(mutex); - while (size() == 0) waitObj.wait(lock); - auto front = backingQueue.front(); - backingQueue.pop_front(); - return front; - } - - std::deque clear() { - std::lock_guard lock(mutex); - std::deque returnQueue = backingQueue; - backingQueue.clear(); - return returnQueue; - } -private: - std::deque backingQueue; - std::recursive_mutex mutex; - std::condition_variable_any waitObj; -}; -#endif diff --git a/MySQLOO/include/Database.h b/MySQLOO/include/Database.h deleted file mode 100644 index d9ed0e3..0000000 --- a/MySQLOO/include/Database.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef DATABASE_ -#define DATABASE_ - -#include "MySQLHeader.h" -#include -#include -#include -#include -#include -#include -#include -#include "GarrysMod/Lua/Interface.h" -#include "BlockingQueue.h" -#include "LuaObjectBase.h" -#include "Query.h" -#include "IQuery.h" - -class SSLSettings { -public: - bool customSSLSettings = false; - std::string key = ""; - std::string cert = ""; - std::string ca = ""; - std::string capath = ""; - std::string cipher = ""; - void applySSLSettings(MYSQL* m_sql); -}; - -class DatabaseThread; -class ConnectThread; -enum DatabaseStatus { - DATABASE_CONNECTED = 0, - DATABASE_CONNECTING = 1, - DATABASE_NOT_CONNECTED = 2, - DATABASE_CONNECTION_FAILED = 3 -}; - -class Database : public LuaObjectBase { - friend class IQuery; -public: - enum { - INTEGER = 0, - BIT, - FLOATING_POINT, - STRING, - }; - Database(GarrysMod::Lua::ILuaBase* LUA, std::string host, std::string username, std::string pw, std::string database, unsigned int port, std::string unixSocket); - ~Database(void); - void cacheStatement(MYSQL_STMT* stmt); - void freeStatement(MYSQL_STMT* stmt); - void enqueueQuery(IQuery* query, std::shared_ptr data); - void think(GarrysMod::Lua::ILuaBase*); - void setAutoReconnect(bool autoReconnect); - bool getAutoReconnect(); - bool shouldCachePreparedStatements() { - return cachePreparedStatements; - } -private: - void shutdown(); - void freeCachedStatements(); - void freeUnusedStatements(); - void run(); - void connectRun(); - static int query(lua_State* state); - static int prepare(lua_State* state); - static int createTransaction(lua_State* state); - static int escape(lua_State* state); - static int setCharacterSet(lua_State* state); - static int connect(lua_State* state); - static int wait(lua_State* state); - static int abortAllQueries(lua_State* state); - static int status(lua_State* state); - static int serverVersion(lua_State* state); - static int serverInfo(lua_State* state); - static int hostInfo(lua_State* state); - static int queueSize(lua_State* state); - static int setAutoReconnect(lua_State* state); - static int setMultiStatements(lua_State* state); - static int ping(lua_State* state); - static int setCachePreparedStatements(lua_State* state); - static int disconnect(lua_State* state); - static int setSSLSettings(lua_State* state); - BlockingQueue, std::shared_ptr>> finishedQueries; - BlockingQueue, std::shared_ptr>> queryQueue; - BlockingQueue cachedStatements; - BlockingQueue freedStatements; - MYSQL* m_sql = nullptr; - std::thread m_thread; - std::mutex m_connectMutex; //Mutex used during connection - std::mutex m_queryMutex; //Mutex that is locked while query thread operates on m_sql object - std::condition_variable m_connectWakeupVariable; - unsigned int m_serverVersion = 0; - std::string m_serverInfo = ""; - std::string m_hostInfo = ""; - bool shouldAutoReconnect = true; - bool useMultiStatements = true; - bool dbCallbackRan = false; - bool startedConnecting = false; - bool disconnected = false; - std::atomic m_success{ true }; - std::atomic m_connectionDone{ false }; - std::atomic cachePreparedStatements{ true }; - std::atomic m_status{ DATABASE_NOT_CONNECTED }; - std::string m_connection_err; - std::condition_variable m_queryWakupVariable; - std::string database = ""; - std::string host = ""; - std::string username = ""; - std::string pw = ""; - std::string socket = ""; - unsigned int port; - SSLSettings customSSLSettings { }; -}; -#endif \ No newline at end of file diff --git a/MySQLOO/include/IQuery.h b/MySQLOO/include/IQuery.h deleted file mode 100644 index c3b6cd0..0000000 --- a/MySQLOO/include/IQuery.h +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef IQUERY_ -#define IQUERY_ -#include "MySQLHeader.h" -#include "LuaObjectBase.h" -#include -#include -#include -#include -#include -#include "ResultData.h" -class DataRow; -class Database; - -enum QueryStatus { - QUERY_NOT_RUNNING = 0, - QUERY_RUNNING = 1, - QUERY_COMPLETE = 3, //Query is complete right before callback is run - QUERY_ABORTED = 4, - QUERY_WAITING = 5, -}; -enum QueryResultStatus { - QUERY_NONE = 0, - QUERY_ERROR, - QUERY_SUCCESS -}; -enum { - OPTION_NUMERIC_FIELDS = 1, - OPTION_NAMED_FIELDS = 2, - OPTION_INTERPRET_DATA = 4, - OPTION_CACHE = 8, -}; - -class IQueryData; -class MySQLException : public std::runtime_error { -public: - MySQLException(int errorCode, const char* message) : runtime_error(message) { - this->m_errorCode = errorCode; - } - int getErrorCode() const { return m_errorCode; } -private: - int m_errorCode = 0; -}; - -class IQuery : public LuaObjectBase { - friend class Database; -public: - IQuery(Database* dbase, GarrysMod::Lua::ILuaBase* LUA); - virtual ~IQuery(); - virtual void doCallback(GarrysMod::Lua::ILuaBase* LUA, std::shared_ptr queryData) = 0; - virtual void onDestroyed(GarrysMod::Lua::ILuaBase* LUA) {}; - virtual std::shared_ptr buildQueryData(GarrysMod::Lua::ILuaBase* LUA) = 0; - void addQueryData(GarrysMod::Lua::ILuaBase* LUA, std::shared_ptr data, bool shouldRefCallbacks = true); - void onQueryDataFinished(GarrysMod::Lua::ILuaBase* LUA, std::shared_ptr data); - void setCallbackData(std::shared_ptr data) { - callbackQueryData = data; - } -protected: - //methods - QueryResultStatus getResultStatus(); - virtual bool executeStatement(MYSQL* m_sql, std::shared_ptr data) = 0; - virtual void think(GarrysMod::Lua::ILuaBase* LUA) {}; - static int start(lua_State* state); - static int isRunning(lua_State* state); - static int setOption(lua_State* state); - static int error(lua_State* state); - static int abort(lua_State* state); - static int wait(lua_State* state); - bool hasCallbackData() { - return callbackQueryData.get() != nullptr; - } - //Wrapper functions for c api that throw exceptions - void mysqlQuery(MYSQL* sql, std::string &query); - void mysqlAutocommit(MYSQL* sql, bool auto_mode); - MYSQL_RES* mysqlStoreResults(MYSQL* sql); - bool mysqlNextResult(MYSQL* sql); - //fields - Database* m_database = nullptr; - std::condition_variable m_waitWakeupVariable; - std::mutex m_waitMutex; - int m_options = 0; - std::vector> runningQueryData; - std::shared_ptr callbackQueryData; - bool hasBeenStarted = false; -}; - -class IQueryData { - friend class IQuery; -public: - std::string getError() { - return m_errorText; - } - - void setError(std::string err) { - m_errorText = err; - } - - bool isFinished() { - return finished; - } - - void setFinished(bool isFinished) { - finished = isFinished; - } - - QueryStatus getStatus() { - return m_status; - } - - void setStatus(QueryStatus status) { - this->m_status = status; - } - - QueryResultStatus getResultStatus() { - return m_resultStatus; - } - - void setResultStatus(QueryResultStatus status) { - m_resultStatus = status; - } - - int getErrorReference() { - return m_errorReference; - } - - int getSuccessReference() { - return m_successReference; - } - - int getOnDataReference() { - return m_onDataReference; - } - - int getAbortReference() { - return m_abortReference; - } - - bool isFirstData() { - return m_wasFirstData; - } -protected: - std::string m_errorText = ""; - std::atomic finished{ false }; - std::atomic m_status{ QUERY_NOT_RUNNING }; - std::atomic m_resultStatus{ QUERY_NONE }; - int m_successReference = 0; - int m_errorReference = 0; - int m_abortReference = 0; - int m_onDataReference = 0; - bool m_wasFirstData = false; -}; -#endif \ No newline at end of file diff --git a/MySQLOO/include/LuaObjectBase.h b/MySQLOO/include/LuaObjectBase.h deleted file mode 100644 index 55d12ca..0000000 --- a/MySQLOO/include/LuaObjectBase.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef LUA_OBJECT_BASE_ -#define LUA_OBJECT_BASE_ -#include "GarrysMod/Lua/Interface.h" -#include "GarrysMod/Lua/Types.h" -#include -#include -#include -#include -#include -#include -#include -#include - -extern int TYPE_DATABASE; -extern int TYPE_QUERY; - -class LuaObjectBase : public std::enable_shared_from_this { -public: - LuaObjectBase(GarrysMod::Lua::ILuaBase* LUA, bool shouldthink, unsigned char type); - LuaObjectBase(GarrysMod::Lua::ILuaBase* LUA, unsigned char type); - virtual ~LuaObjectBase(); - virtual void think(GarrysMod::Lua::ILuaBase* LUA) = 0; - void registerFunction(GarrysMod::Lua::ILuaBase* LUA, std::string name, GarrysMod::Lua::CFunc func); - static int gcDeleteWrapper(lua_State* state); - static int toStringWrapper(lua_State* state); - static int createMetatables(GarrysMod::Lua::ILuaBase* LUA); - static int doThink(lua_State* state); - static LuaObjectBase* unpackSelf(GarrysMod::Lua::ILuaBase* LUA, int type = -1, bool shouldReference = false); - static LuaObjectBase* unpackLuaObject(GarrysMod::Lua::ILuaBase* LUA, int index, int type, bool shouldReference); - int pushTableReference(GarrysMod::Lua::ILuaBase* LUA); - bool hasCallback(GarrysMod::Lua::ILuaBase* LUA, const char* functionName); - int getCallbackReference(GarrysMod::Lua::ILuaBase* LUA, const char* functionName); - void runFunction(GarrysMod::Lua::ILuaBase* LUA, int funcRef, const char* sig = 0, ...); - void runCallback(GarrysMod::Lua::ILuaBase* LUA, const char* functionName, const char* sig = 0, ...); - static std::deque> luaObjects; - static std::deque> luaThinkObjects; - static std::deque> luaRemovalObjects; - virtual void onDestroyed(GarrysMod::Lua::ILuaBase* LUA) {}; - std::shared_ptr getSharedPointerInstance(); - void unreference(GarrysMod::Lua::ILuaBase* LUA); -protected: - void runFunctionVarList(GarrysMod::Lua::ILuaBase* LUA, int funcRef, const char* sig, va_list list); - bool scheduledForRemoval = false; - bool shouldthink = false; - int m_tableReference = 0; - int m_userdataReference = 0; - bool canbedestroyed = true; - const char* classname = "LuaObject"; - int type = -1; - static void referenceTable(GarrysMod::Lua::ILuaBase* LUA, LuaObjectBase* object, int index); -private: - std::map m_callbackFunctions; - static int tableMetaTable; -}; -#endif diff --git a/MySQLOO/include/PingQuery.h b/MySQLOO/include/PingQuery.h deleted file mode 100644 index 2dba8b9..0000000 --- a/MySQLOO/include/PingQuery.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#ifndef PINGQUERY_ -#define PINGQUERY_ -#include -#include "Query.h" -#include "MySQLHeader.h" -#include -#include - - -class PingQuery : Query { - friend class Database; -public: - PingQuery(Database* dbase, GarrysMod::Lua::ILuaBase* LUA); - virtual ~PingQuery(void); -protected: - void executeQuery(MYSQL* m_sql, std::shared_ptr); - bool pingSuccess = false; -}; -#endif \ No newline at end of file diff --git a/MySQLOO/include/PreparedQuery.h b/MySQLOO/include/PreparedQuery.h deleted file mode 100644 index e4c4f77..0000000 --- a/MySQLOO/include/PreparedQuery.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef PREPAREDQUERY_ -#define PREPAREDQUERY_ -#include -#include "Query.h" -#include "MySQLHeader.h" -#include -#include - - -class PreparedQueryField { - friend class PreparedQuery; -public: - PreparedQueryField(unsigned int index, int type) : m_index(index), m_type(type) {} - PreparedQueryField() : m_index(1), m_type(0) {} - virtual ~PreparedQueryField() {} -private: - unsigned int m_index; - int m_type; -}; - -template< typename T > -class TypedQueryField : public PreparedQueryField { - friend class PreparedQuery; -public: - TypedQueryField(unsigned int index, int type, const T& data) - : PreparedQueryField(index, type), m_data(data) {}; - virtual ~TypedQueryField() {} -private: - T m_data; -}; - - -class PreparedQuery : public Query { - friend class Database; -public: - PreparedQuery(Database* dbase, GarrysMod::Lua::ILuaBase* LUA); - virtual ~PreparedQuery(void); - bool executeStatement(MYSQL* connection, std::shared_ptr data); - virtual void onDestroyed(GarrysMod::Lua::ILuaBase* LUA); -protected: - virtual std::shared_ptr buildQueryData(GarrysMod::Lua::ILuaBase* LUA); - void executeQuery(MYSQL* m_sql, std::shared_ptr data); -private: - std::deque>> m_parameters; - static int clearParameters(lua_State* state); - static int setNumber(lua_State* state); - static int setString(lua_State* state); - static int setBoolean(lua_State* state); - static int setNull(lua_State* state); - static int putNewParameters(lua_State* state); - MYSQL_STMT *mysqlStmtInit(MYSQL* sql); - void generateMysqlBinds(MYSQL_BIND* binds, std::unordered_map> &map, unsigned int parameterCount); - void mysqlStmtBindParameter(MYSQL_STMT* sql, MYSQL_BIND* bind); - void mysqlStmtPrepare(MYSQL_STMT* sql, const char* str); - void mysqlStmtExecute(MYSQL_STMT* sql); - void mysqlStmtStoreResult(MYSQL_STMT* sql); - bool mysqlStmtNextResult(MYSQL_STMT* sql); - //This is atomic to prevent visibility issues - std::atomic cachedStatement{ nullptr }; - //This pointer is used to prevent the database being accessed after it was deleted - //when this preparedq query still owns a MYSQL_STMT* - std::weak_ptr weak_database; -}; - -class PreparedQueryData : public QueryData { - friend class PreparedQuery; -protected: - std::deque>> m_parameters; - bool firstAttempt = true; -}; -#endif \ No newline at end of file diff --git a/MySQLOO/include/Query.h b/MySQLOO/include/Query.h deleted file mode 100644 index a20685c..0000000 --- a/MySQLOO/include/Query.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef QUERY_ -#define QUERY_ -#include -#include -#include -#include "IQuery.h" - -class QueryData; -class Query : public IQuery { - friend class Database; - friend class Transaction; -public: - Query(Database* dbase, GarrysMod::Lua::ILuaBase* LUA); - virtual ~Query(void); - void setQuery(std::string query); - virtual bool executeStatement(MYSQL* m_sql, std::shared_ptr data); - virtual void executeQuery(MYSQL* m_sql, std::shared_ptr data); - virtual void onDestroyed(GarrysMod::Lua::ILuaBase* LUA); - virtual void doCallback(GarrysMod::Lua::ILuaBase* LUA, std::shared_ptr queryData); - virtual std::shared_ptr buildQueryData(GarrysMod::Lua::ILuaBase* LUA); -protected: - void dataToLua(GarrysMod::Lua::ILuaBase* LUA, int rowReference, unsigned int column, std::string &columnValue, const char* columnName, int columnType, bool isNull); - static int lastInsert(lua_State* state); - static int affectedRows(lua_State* state); - static int getData_Wrapper(lua_State* state); - static int hasMoreResults(lua_State* state); - static int getNextResults(lua_State* state); - int getData(GarrysMod::Lua::ILuaBase* LUA); - int dataReference = 0; - std::string m_query; -}; - -class QueryData : public IQueryData { - friend class Query; -public: - my_ulonglong getLastInsertID() { - return (m_insertIds.size() == 0) ? 0 : m_insertIds.front(); - } - - my_ulonglong getAffectedRows() { - return (m_affectedRows.size() == 0) ? 0 : m_affectedRows.front(); - } - - bool hasMoreResults() { - return m_insertIds.size() > 0 && m_affectedRows.size() > 0 && m_results.size() > 0; - } - - bool getNextResults() { - if (!hasMoreResults()) return false; - m_results.pop_front(); - m_insertIds.pop_front(); - m_affectedRows.pop_front(); - return true; - } - - ResultData& getResult() { - return m_results.front(); - } - - std::deque getResults() { - return m_results; - } -protected: - std::deque m_affectedRows; - std::deque m_insertIds; - std::deque m_results; -}; -#endif \ No newline at end of file diff --git a/MySQLOO/include/QueryData.h b/MySQLOO/include/QueryData.h deleted file mode 100644 index 7a1e77a..0000000 --- a/MySQLOO/include/QueryData.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef QUERY_DATA_ -#define QUERY_DATA_ -class QueryData -{ - int lastInsert; - std::deque m_affectedRows; - std::deque m_insertIds; - std::deque results; - std::condition_variable m_waitWakeupVariable; -} -#endif \ No newline at end of file diff --git a/MySQLOO/include/Transaction.h b/MySQLOO/include/Transaction.h deleted file mode 100644 index a55828a..0000000 --- a/MySQLOO/include/Transaction.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef TRANSACTION_ -#define TRANSACTION_ -#include -#include -#include -#include "IQuery.h" -#include "Query.h" - - -class Transaction : public IQuery { - friend class Database; -public: - Transaction(Database* dbase, GarrysMod::Lua::ILuaBase* LUA); - void doCallback(GarrysMod::Lua::ILuaBase* LUA, std::shared_ptr data); - virtual std::shared_ptr buildQueryData(GarrysMod::Lua::ILuaBase* LUA); -protected: - static int clearQueries(lua_State* state); - static int addQuery(lua_State* state); - static int getQueries(lua_State* state); - bool executeStatement(MYSQL * connection, std::shared_ptr data); - void onDestroyed(GarrysMod::Lua::ILuaBase* LUA); -private: - std::vector> addedQueryData; -}; - -class TransactionData : public IQueryData { - friend class Transaction; -protected: - std::deque, std::shared_ptr>> m_queries; - bool retried = false; -}; -#endif diff --git a/MySQLOO/source/Database.cpp b/MySQLOO/source/Database.cpp deleted file mode 100644 index f3aa408..0000000 --- a/MySQLOO/source/Database.cpp +++ /dev/null @@ -1,553 +0,0 @@ -#include "Database.h" -#include "Query.h" -#include "IQuery.h" -#include "PreparedQuery.h" -#include "PingQuery.h" -#include "Transaction.h" -#include -#include -#include -#include - -Database::Database(GarrysMod::Lua::ILuaBase* LUA, std::string host, std::string username, std::string pw, std::string database, unsigned int port, std::string unixSocket) : - LuaObjectBase(LUA, TYPE_DATABASE), database(database), host(host), username(username), pw(pw), socket(unixSocket), port(port) { - classname = "Database"; - registerFunction(LUA, "prepare", Database::prepare); - registerFunction(LUA, "escape", Database::escape); - registerFunction(LUA, "query", Database::query); - registerFunction(LUA, "createTransaction", Database::createTransaction); - registerFunction(LUA, "connect", Database::connect); - registerFunction(LUA, "abortAllQueries", Database::abortAllQueries); - registerFunction(LUA, "wait", Database::wait); - registerFunction(LUA, "serverVersion", Database::serverVersion); - registerFunction(LUA, "serverInfo", Database::serverInfo); - registerFunction(LUA, "hostInfo", Database::hostInfo); - registerFunction(LUA, "status", Database::status); - registerFunction(LUA, "queueSize", Database::queueSize); - registerFunction(LUA, "setAutoReconnect", Database::setAutoReconnect); - registerFunction(LUA, "setCachePreparedStatements", Database::setCachePreparedStatements); - registerFunction(LUA, "setCharacterSet", Database::setCharacterSet); - registerFunction(LUA, "setMultiStatements", Database::setMultiStatements); - registerFunction(LUA, "ping", Database::ping); - registerFunction(LUA, "disconnect", Database::disconnect); - registerFunction(LUA, "setSSLSettings", Database::setSSLSettings); -} - -Database::~Database() { - this->shutdown(); - if (this->m_thread.joinable()) { - this->m_thread.join(); - } -} - - -//This makes sure that all stmts always get freed -void Database::cacheStatement(MYSQL_STMT* stmt) { - if (stmt == nullptr) return; - cachedStatements.put(stmt); -} - -//This notifies the database thread to free this statement some time in the future -void Database::freeStatement(MYSQL_STMT* stmt) { - if (stmt == nullptr) return; - cachedStatements.remove(stmt); - freedStatements.put(stmt); -} - -/* Creates and returns a query instance and enqueues it into the queue of accepted queries. -*/ -int Database::query(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - LUA->CheckType(2, GarrysMod::Lua::Type::STRING); - unsigned int outLen = 0; - const char* query = LUA->GetString(2, &outLen); - Query* queryObject = new Query(object, LUA); - queryObject->setQuery(std::string(query, outLen)); - queryObject->pushTableReference(LUA); - return 1; -} - -/* Creates and returns a PreparedQuery instance and enqueues it into the queue of accepted queries. -*/ -int Database::prepare(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - LUA->CheckType(2, GarrysMod::Lua::Type::STRING); - unsigned int outLen = 0; - const char* query = LUA->GetString(2, &outLen); - PreparedQuery* queryObject = new PreparedQuery(object, LUA); - queryObject->setQuery(std::string(query, outLen)); - queryObject->pushTableReference(LUA); - return 1; -} - -/* Creates and returns a PreparedQuery instance and enqueues it into the queue of accepted queries. -*/ -int Database::createTransaction(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - Transaction* transactionObject = new Transaction(object, LUA); - transactionObject->pushTableReference(LUA); - return 1; -} - -/* Enqueues a query into the queue of accepted queries. - */ -void Database::enqueueQuery(IQuery* query, std::shared_ptr queryData) { - query->canbedestroyed = false; - queryQueue.put(std::make_pair(std::dynamic_pointer_cast(query->getSharedPointerInstance()), queryData)); - queryData->setStatus(QUERY_WAITING); - this->m_queryWakupVariable.notify_one(); -} - - -/* Returns the amount of queued querys in the database instance - * If a query is currently being processed, it does not count towards the queue size - */ -int Database::queueSize(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - LUA->PushNumber((double) object->queryQueue.size()); - return 1; -} - - -/* Aborts all queries that are in the queue of started queries and returns the number of successfully aborted queries. - * Does not abort queries that are already taken from the queue and being processed. - */ -int Database::abortAllQueries(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - auto canceledQueries = object->queryQueue.clear(); - for (auto& pair : canceledQueries) { - auto query = pair.first; - auto data = pair.second; - data->setStatus(QUERY_ABORTED); - query->onQueryDataFinished(LUA, data); - } - LUA->PushNumber((double) canceledQueries.size()); - return 1; -} - -/* Waits for the connection of the database to finish by blocking the current thread until the connect thread finished. - * Callbacks are going to be called before this function returns - */ -int Database::wait(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - if (!object->startedConnecting) { - LUA->ThrowError("Tried to wait for database connection to finish without starting the connection!"); - } - std::unique_lock lck(object->m_connectMutex); - while (!object->m_connectionDone) object->m_connectWakeupVariable.wait(lck); - object->think(LUA); - return 0; -} - -/* Escapes an unescaped string using the database taking into account the characterset of the database. - * This might break if the characterset of the database is changed after the connection was done - */ -int Database::escape(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - LUA->CheckType(2, GarrysMod::Lua::Type::STRING); - std::lock_guard lock(object->m_connectMutex); - //No query mutex needed since this doesn't use the connection at all - if (!object->m_connectionDone || object->m_sql == nullptr) return 0; - - unsigned int nQueryLength; - const char* sQuery = LUA->GetString(2, &nQueryLength); - //escaped string can be twice as big as original string - //source: http://dev.mysql.com/doc/refman/5.1/en/mysql-real-escape-string.html - std::vector escapedQuery(nQueryLength * 2 + 1); - unsigned int nEscapedQueryLength = mysql_real_escape_string(object->m_sql, escapedQuery.data(), sQuery, nQueryLength); - - LUA->PushString(escapedQuery.data(), nEscapedQueryLength); - return 1; -} - -/* Changes the character set of the connection - * This will run the query in the server thread, which means the server will be paused - * until the query is done. - * This is so db:escape always has the latest value of mysql->charset - */ -int Database::setCharacterSet(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - LUA->CheckType(2, GarrysMod::Lua::Type::STRING); - if (object->m_status != DATABASE_CONNECTED) { - LUA->ThrowError("Database needs to be connected to change charset."); - } - const char* charset = LUA->GetString(2); - //This mutex makes sure we can safely use the connection to run the query - std::unique_lock lk2(object->m_queryMutex); - if (mysql_set_character_set(object->m_sql, charset)) { - LUA->PushBool(false); - LUA->PushString(mysql_error(object->m_sql)); - return 1; - } else { - LUA->PushBool(true); - return 1; - } -} - -/* Starts the thread that connects to the database and then handles queries. - */ -int Database::connect(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE, true); - if (object->m_status != DATABASE_NOT_CONNECTED || object->startedConnecting) { - LUA->ThrowError("Database already connected."); - } - object->startedConnecting = true; - object->m_status = DATABASE_CONNECTING; - object->m_thread = std::thread(&Database::connectRun, object); - return 0; -} - -void SSLSettings::applySSLSettings(MYSQL* m_sql) { - if (this->key != "") { - mysql_options(m_sql, MYSQL_OPT_SSL_KEY, this->key.c_str()); - } - if (this->cert != "") { - mysql_options(m_sql, MYSQL_OPT_SSL_CERT, this->cert.c_str()); - } - if (this->ca != "") { - mysql_options(m_sql, MYSQL_OPT_SSL_CA, this->ca.c_str()); - } - if (this->capath != "") { - mysql_options(m_sql, MYSQL_OPT_SSL_CAPATH, this->capath.c_str()); - } - if (this->cipher != "") { - mysql_options(m_sql, MYSQL_OPT_SSL_CIPHER, this->cipher.c_str()); - } -} - -/* Manually sets the instances SSL settings to use a custom SSL key, certificate, CA, CAPath, cipher, etc. - * This has to be called before connecting to the database. - */ -int Database::setSSLSettings(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - if (object->m_status != DATABASE_NOT_CONNECTED) { - LUA->ThrowError("Cannot set SSL settings after connecting!"); - } - if (LUA->IsType(2, GarrysMod::Lua::Type::STRING)) { - object->customSSLSettings.key = LUA->GetString(2); - } - if (LUA->IsType(3, GarrysMod::Lua::Type::STRING)) { - object->customSSLSettings.cert = LUA->GetString(3); - } - if (LUA->IsType(4, GarrysMod::Lua::Type::STRING)) { - object->customSSLSettings.ca = LUA->GetString(4); - } - if (LUA->IsType(5, GarrysMod::Lua::Type::STRING)) { - object->customSSLSettings.capath = LUA->GetString(5); - } - if (LUA->IsType(6, GarrysMod::Lua::Type::STRING)) { - object->customSSLSettings.cipher = LUA->GetString(6); - } - return 0; -} - - -void Database::shutdown() { - //This acts as a poison pill - this->queryQueue.put(std::make_pair(std::shared_ptr(), std::shared_ptr())); - //The fact that C++ can't automatically infer the types of the shared_ptr here and that - //I have to specify what type it should be, just proves once again that C++ is a failed language - //that should be replaced as soon as possible -} - -/* Disconnects from the mysql database after finishing all queued queries - * If wait is true, this will wait for the all queries to finish execution and the - * database thread to end. - */ -int Database::disconnect(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - bool wait = false; - if (LUA->IsType(2, GarrysMod::Lua::Type::BOOL)) { - wait = LUA->GetBool(2); - } - if (object->m_status != DATABASE_CONNECTED) { - LUA->ThrowError("Database not connected."); - } - object->shutdown(); - if (wait && object->m_thread.joinable()) { - object->m_thread.join(); - } - object->disconnected = true; - return 0; -} - -/* Returns the status of the database, constants can be found in GMModule - */ -int Database::status(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - LUA->PushNumber(object->m_status); - return 1; -} - -//Any of the serverInfo/Version and hostInfo functions could return outdated information if a reconnect happens -//(for example after a mysql server upgrade) - -/* Returns the server version as a formatted integer (XYYZZ, X= major-, Y=minor, Z=sub-version) - * Only works as soon as the connection has been established - */ -int Database::serverVersion(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - if (!object->m_connectionDone) { - LUA->ThrowError("Tried to get server version when client is not connected to server yet!"); - } - LUA->PushNumber(object->m_serverVersion); - return 1; -} - -/* Returns the server version as a string (for example 5.0.96) - * Only works as soon as the connection has been established - */ -int Database::serverInfo(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - if (!object->m_connectionDone) { - LUA->ThrowError("Tried to get server info when client is not connected to server yet!"); - } - LUA->PushString(object->m_serverInfo.c_str()); - return 1; -} - -/* Returns a string of the hostname connected to as well as the connection type - * Only works as soon as the connection has been established - */ -int Database::hostInfo(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - if (!object->m_connectionDone) { - LUA->ThrowError("Tried to get server info when client is not connected to server yet!"); - } - LUA->PushString(object->m_hostInfo.c_str()); - return 1; -} - -int Database::setAutoReconnect(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - if (object->m_status != DATABASE_NOT_CONNECTED || object->startedConnecting) { - LUA->ThrowError("Database already connected."); - } - LUA->CheckType(2, GarrysMod::Lua::Type::BOOL); - object->shouldAutoReconnect = LUA->GetBool(2); - return 0; -} - -int Database::setMultiStatements(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* object = (Database*)unpackSelf(LUA, TYPE_DATABASE); - if (object->m_status != DATABASE_NOT_CONNECTED || object->startedConnecting) { - LUA->ThrowError("Database already connected."); - } - LUA->CheckType(2, GarrysMod::Lua::Type::BOOL); - object->useMultiStatements = LUA->GetBool(2); - return 0; -} - -int Database::ping(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* database = (Database*)unpackSelf(LUA, TYPE_DATABASE); - if (database->m_status != DATABASE_CONNECTED) { - LUA->PushBool(false); - return 1; - } - //This pretty much uses most of the lua api - //We can't use the sql object directly since only the sql - //thread should use it to prevent threading issues - PingQuery* query = new PingQuery(database, LUA); - LUA->PushCFunction(IQuery::start); - query->pushTableReference(LUA); - LUA->Call(1, 0); - //swaps the query to the front of the queryqueue to reduce wait time - LUA->PushCFunction(IQuery::wait); - query->pushTableReference(LUA); - LUA->PushBool(true); - LUA->Call(2, 0); - LUA->PushBool(query->pingSuccess); - return 1; -} - -//Set this to false if your database server imposes a low prepared statements limit -//Or if you might create a very high amount of prepared queries in a short period of time -int Database::setCachePreparedStatements(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Database* database = (Database*)unpackSelf(LUA, TYPE_DATABASE); - if (database->m_status != DATABASE_NOT_CONNECTED) { - LUA->ThrowError("setCachePreparedStatements has to be called before db:start()"); - return 0; - } - LUA->CheckType(2, GarrysMod::Lua::Type::BOOL); - database->cachePreparedStatements = LUA->GetBool(); - return 0; -} - -//Should only be called from the db thread -//While the mysql documentation says that mysql_options should only be called -//before the connection is done it appears to work after just fine (at least for reconnect) -void Database::setAutoReconnect(bool autoReconnect) { - mysql_options(m_sql, MYSQL_OPT_RECONNECT, &autoReconnect); -} - -//Should only be called from the db thread -bool Database::getAutoReconnect() { - return m_sql->reconnect; -} - - -/* Thread that connects to the database, on success it continues to handle queries in the run method. - */ -void Database::connectRun() { - mysql_thread_init(); - auto threadEnd = finally([&] { - mysql_thread_end(); - if (m_status == DATABASE_CONNECTED) { - m_status = DATABASE_NOT_CONNECTED; - } - }); - { - auto connectionSignaliser = finally([&] { m_connectWakeupVariable.notify_one(); }); - std::lock_guard lock(this->m_connectMutex); - this->m_sql = mysql_init(nullptr); - if (this->m_sql == nullptr) { - m_success = false; - m_connection_err = "Out of memory"; - m_connectionDone = true; - m_status = DATABASE_CONNECTION_FAILED; - return; - } - this->customSSLSettings.applySSLSettings(this->m_sql); - if (this->shouldAutoReconnect) { - setAutoReconnect(true); - } - const char* socket = (this->socket.length() == 0) ? nullptr : this->socket.c_str(); - unsigned long clientFlag = (this->useMultiStatements) ? CLIENT_MULTI_STATEMENTS : 0; - clientFlag |= CLIENT_MULTI_RESULTS; - if (mysql_real_connect(this->m_sql, this->host.c_str(), this->username.c_str(), this->pw.c_str(), - this->database.c_str(), this->port, socket, clientFlag) != this->m_sql) { - m_success = false; - m_connection_err = mysql_error(this->m_sql); - m_connectionDone = true; - m_status = DATABASE_CONNECTION_FAILED; - return; - } - m_success = true; - m_connection_err = ""; - m_connectionDone = true; - m_status = DATABASE_CONNECTED; - m_serverVersion = mysql_get_server_version(this->m_sql); - m_serverInfo = mysql_get_server_info(this->m_sql); - m_hostInfo = mysql_get_host_info(this->m_sql); - } - auto closeConnection = finally([&] { - std::unique_lock queryMutex(m_queryMutex); - mysql_close(this->m_sql); this->m_sql = nullptr; - }); - if (m_success) { - run(); - } -} - -/* Think hook of the database instance. - * In case the database connection was established or failed for the first time the connection callbacks are being run. - * Takes all the queries from the finished queries queue and runs the callback for them. - */ -void Database::think(GarrysMod::Lua::ILuaBase* LUA) { - if (m_connectionDone && !dbCallbackRan) { - dbCallbackRan = true; - if (m_success) { - runCallback(LUA, "onConnected"); - } else { - runCallback(LUA, "onConnectionFailed", "s", m_connection_err.c_str()); - } - this->unreference(LUA); - } - //Needs to lock for condition check to prevent race conditions - auto currentlyFinished = finishedQueries.clear(); - while (!currentlyFinished.empty()) { - auto pair = currentlyFinished.front(); - auto query = pair.first; - auto data = pair.second; - currentlyFinished.pop_front(); - //Unlocking here because the lock isn't needed for the callbacks - //Allows the database thread to add more finished queries - query->setCallbackData(data); - data->setStatus(QUERY_COMPLETE); - query->doCallback(LUA, data); - query->onQueryDataFinished(LUA, data); - } -} - -void Database::freeCachedStatements() { - auto statments = cachedStatements.clear(); - for (auto& stmt : statments) { - mysql_stmt_close(stmt); - } -} - -void Database::freeUnusedStatements() { - auto statments = freedStatements.clear(); - for (auto& stmt : statments) { - mysql_stmt_close(stmt); - } -} - -/* The run method of the thread of the database instance. - */ -void Database::run() { - auto a = finally([&] { - this->freeUnusedStatements(); - this->freeCachedStatements(); - }); - while (true) { - auto pair = this->queryQueue.take(); - //This detects the poison pill that is supposed to shutdown the database - if (pair.first.get() == nullptr) { - return; - } - auto curquery = pair.first; - auto data = pair.second; - { - //New scope so mutex will be released as soon as possible - std::unique_lock queryMutex(m_queryMutex); - curquery->executeStatement(this->m_sql, data); - } - data->setFinished(true); - finishedQueries.put(pair); - { - std::unique_lock queryMutex(curquery->m_waitMutex); - curquery->m_waitWakeupVariable.notify_one(); - } - //So that statements get freed sometimes even if the queue is constantly full - freeUnusedStatements(); - } -} \ No newline at end of file diff --git a/MySQLOO/source/GMModule.cpp b/MySQLOO/source/GMModule.cpp deleted file mode 100644 index c2dcf0b..0000000 --- a/MySQLOO/source/GMModule.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include "GarrysMod/Lua/Interface.h" -#include "LuaObjectBase.h" -#include "Database.h" -#include "MySQLHeader.h" -#include -#include -#define MYSQLOO_VERSION "9" -#define MYSQLOO_MINOR_VERSION "6" - -// Variable to hold the reference to the version check ConVar object -int versionCheckConVar = 0; - -GMOD_MODULE_CLOSE() { - // Free the version check ConVar object reference - LUA->ReferenceFree(versionCheckConVar); - - /* Deletes all the remaining luaobjects when the server changes map - */ - for (auto query : LuaObjectBase::luaRemovalObjects) { - query->onDestroyed(nullptr); - } - LuaObjectBase::luaRemovalObjects.clear(); - LuaObjectBase::luaObjects.clear(); - LuaObjectBase::luaThinkObjects.clear(); - mysql_thread_end(); - mysql_library_end(); - return 0; -} - -/* Connects to the database and returns a Database instance that can be used - * as an interface to the mysql server. - */ -static int connect(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - LUA->CheckType(1, GarrysMod::Lua::Type::STRING); - LUA->CheckType(2, GarrysMod::Lua::Type::STRING); - LUA->CheckType(3, GarrysMod::Lua::Type::STRING); - LUA->CheckType(4, GarrysMod::Lua::Type::STRING); - std::string host = LUA->GetString(1); - std::string username = LUA->GetString(2); - std::string pw = LUA->GetString(3); - std::string database = LUA->GetString(4); - unsigned int port = 3306; - std::string unixSocket = ""; - if (LUA->IsType(5, GarrysMod::Lua::Type::NUMBER)) { - port = (int)LUA->GetNumber(5); - } - if (LUA->IsType(6, GarrysMod::Lua::Type::STRING)) { - unixSocket = LUA->GetString(6); - } - Database* object = new Database(LUA, host, username, pw, database, port, unixSocket); - ((LuaObjectBase*)object)->pushTableReference(LUA); - return 1; -} - -/* Returns the amount of LuaObjectBase objects that are currently in use - * This includes Database and Query instances - */ -static int objectCount(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - LUA->PushNumber((double) LuaObjectBase::luaObjects.size()); - return 1; -} - -static void runInTimer(GarrysMod::Lua::ILuaBase* LUA, double delay, GarrysMod::Lua::CFunc func) { - LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); - LUA->GetField(-1, "timer"); - //In case someone removes the timer library - if (LUA->IsType(-1, GarrysMod::Lua::Type::NIL)) { - LUA->Pop(2); - return; - } - LUA->GetField(-1, "Simple"); - LUA->PushNumber(delay); - LUA->PushCFunction(func); - LUA->Call(2, 0); - LUA->Pop(2); -} - -static void printMessage(GarrysMod::Lua::ILuaBase* LUA, const char* str, int r, int g, int b) { - LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); - LUA->GetField(-1, "Color"); - LUA->PushNumber(r); - LUA->PushNumber(g); - LUA->PushNumber(b); - LUA->Call(3, 1); - int ref = LUA->ReferenceCreate(); - LUA->GetField(-1, "MsgC"); - LUA->ReferencePush(ref); - LUA->PushString(str); - LUA->Call(2, 0); - LUA->Pop(); - LUA->ReferenceFree(ref); -} - -static int printOutdatatedVersion(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - printMessage(LUA, "Your server is using an outdated mysqloo9 version\n", 255, 0, 0); - printMessage(LUA, "Download the latest version from here:\n", 255, 0, 0); - printMessage(LUA, "https://github.com/FredyH/MySQLOO/releases\n", 86, 156, 214); - runInTimer(LUA, 300, printOutdatatedVersion); - return 0; -} - -static int fetchSuccessful(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - std::string version = LUA->GetString(1); - //version.size() < 3 so that the 404 response gets ignored - if (version != MYSQLOO_MINOR_VERSION && version.size() <= 3) { - printOutdatatedVersion(state); - } else { - printMessage(LUA, "Your server is using the latest mysqloo9 version\n", 0, 255, 0); - } - return 0; -} - -static int fetchFailed(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - printMessage(LUA, "Failed to retrieve latest version of mysqloo9\n", 255, 0, 0); - return 0; -} - -static int doVersionCheck(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - - // Check if the reference to the ConVar object is set - if (versionCheckConVar != 0) { - // Retrieve the value of the ConVar - LUA->ReferencePush(versionCheckConVar); // Push the ConVar object - LUA->GetField(-1, "GetInt"); // Push the name of the function - LUA->ReferencePush(versionCheckConVar); // Push the ConVar object as the first self argument - LUA->Call(1, 1); // Call with 1 argument and 1 return - int versionCheckEnabled = (int)LUA->GetNumber(-1); // Retrieve the returned value - - // Check if the version check convar is set to 1 - if (versionCheckEnabled == 1) { - // Execute the HTTP request - LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); - LUA->GetField(-1, "http"); - LUA->GetField(-1, "Fetch"); - LUA->PushString("https://raw.githubusercontent.com/FredyH/MySQLOO/master/minorversion.txt"); - LUA->PushCFunction(fetchSuccessful); - LUA->PushCFunction(fetchFailed); - LUA->PCall(3, 0, 0); - LUA->Pop(2); - } - } - - return 0; -} - -GMOD_MODULE_OPEN() { - if (mysql_library_init(0, nullptr, nullptr)) { - LUA->ThrowError("Could not initialize mysql library."); - } - LuaObjectBase::createMetatables(LUA); - LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); - LUA->GetField(-1, "hook"); - LUA->GetField(-1, "Add"); - LUA->PushString("Think"); - LUA->PushString("__MySQLOOThinkHook"); - LUA->PushCFunction(LuaObjectBase::doThink); - LUA->Call(3, 0); - LUA->Pop(); - LUA->Pop(); - LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); - LUA->CreateTable(); - - LUA->PushString(MYSQLOO_VERSION); LUA->SetField(-2, "VERSION"); - LUA->PushString(MYSQLOO_MINOR_VERSION); LUA->SetField(-2, "MINOR_VERSION"); - - LUA->PushNumber(DATABASE_CONNECTED); LUA->SetField(-2, "DATABASE_CONNECTED"); - LUA->PushNumber(DATABASE_CONNECTING); LUA->SetField(-2, "DATABASE_CONNECTING"); - LUA->PushNumber(DATABASE_NOT_CONNECTED); LUA->SetField(-2, "DATABASE_NOT_CONNECTED"); - LUA->PushNumber(DATABASE_CONNECTION_FAILED); LUA->SetField(-2, "DATABASE_CONNECTION_FAILED"); - - LUA->PushNumber(QUERY_NOT_RUNNING); LUA->SetField(-2, "QUERY_NOT_RUNNING"); - LUA->PushNumber(QUERY_RUNNING); LUA->SetField(-2, "QUERY_RUNNING"); - LUA->PushNumber(QUERY_COMPLETE); LUA->SetField(-2, "QUERY_COMPLETE"); - LUA->PushNumber(QUERY_ABORTED); LUA->SetField(-2, "QUERY_ABORTED"); - LUA->PushNumber(QUERY_WAITING); LUA->SetField(-2, "QUERY_WAITING"); - - LUA->PushNumber(OPTION_NUMERIC_FIELDS); LUA->SetField(-2, "OPTION_NUMERIC_FIELDS"); - LUA->PushNumber(OPTION_INTERPRET_DATA); LUA->SetField(-2, "OPTION_INTERPRET_DATA"); //Not used anymore - LUA->PushNumber(OPTION_NAMED_FIELDS); LUA->SetField(-2, "OPTION_NAMED_FIELDS"); //Not used anymore - LUA->PushNumber(OPTION_CACHE); LUA->SetField(-2, "OPTION_CACHE"); //Not used anymore - - LUA->PushCFunction(connect); LUA->SetField(-2, "connect"); - LUA->PushCFunction(objectCount); LUA->SetField(-2, "objectCount"); - - LUA->SetField(-2, "mysqloo"); - LUA->Pop(); - - LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); // Push the global table - // Create the version check ConVar - LUA->GetField(-1, "CreateConVar"); - LUA->PushString("sv_mysqloo_versioncheck"); // Name - LUA->PushString("1"); // Default value - LUA->PushNumber(128); // FCVAR flags - LUA->PushString("Enable or disable the MySQLOO update checker."); // Help text - LUA->PushNumber(0); // Min value - LUA->PushNumber(1); // Max value - LUA->Call(6, 1); // Call with 6 arguments and 1 result - versionCheckConVar = LUA->ReferenceCreate(); // Store the created ConVar object as a global variable - LUA->Pop(); // Pop the global table - - runInTimer(LUA, 5, doVersionCheck); - - return 1; -} diff --git a/MySQLOO/source/IQuery.cpp b/MySQLOO/source/IQuery.cpp deleted file mode 100644 index 2922237..0000000 --- a/MySQLOO/source/IQuery.cpp +++ /dev/null @@ -1,238 +0,0 @@ -#include "IQuery.h" -#include "Database.h" -#include "ResultData.h" - -//Important: -//Calling any query functions that rely on data from the query thread -//before the callback is called can result in race conditions. -//Always check for QUERY_COMPLETE!!! - -IQuery::IQuery(Database* dbase, GarrysMod::Lua::ILuaBase* LUA) : LuaObjectBase(LUA, false, TYPE_QUERY), m_database(dbase) { - m_options = OPTION_NAMED_FIELDS | OPTION_INTERPRET_DATA | OPTION_CACHE; - registerFunction(LUA, "start", IQuery::start); - registerFunction(LUA, "error", IQuery::error); - registerFunction(LUA, "wait", IQuery::wait); - registerFunction(LUA, "setOption", IQuery::setOption); - registerFunction(LUA, "isRunning", IQuery::isRunning); - registerFunction(LUA, "abort", IQuery::abort); -} - -IQuery::~IQuery() {} - -QueryResultStatus IQuery::getResultStatus() { - if (!hasCallbackData()) { - return QUERY_NONE; - } - return callbackQueryData->getResultStatus(); -} - -//Wrapper for c api calls -//Just throws an exception if anything goes wrong for ease of use - -void IQuery::mysqlAutocommit(MYSQL* sql, bool auto_mode) { - int result = mysql_autocommit(sql, auto_mode); - if (result != 0) { - const char* errorMessage = mysql_error(sql); - int errorCode = mysql_errno(sql); - throw MySQLException(errorCode, errorMessage); - } -} - -//Queues the query into the queue of the database instance associated with it -int IQuery::start(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - IQuery* object = (IQuery*)unpackSelf(LUA, TYPE_QUERY); - if (object->m_database->disconnected) { - LUA->ThrowError("Database already disconnected."); - } - if (object->runningQueryData.size() == 0) { - referenceTable(LUA, object, 1); - } - std::shared_ptr ptr = object->buildQueryData(LUA); - object->addQueryData(LUA, ptr); - object->m_database->enqueueQuery(object, ptr); - object->hasBeenStarted = true; - return 0; -} - -//Returns if the query has been queued with the database instance -int IQuery::isRunning(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - IQuery* object = (IQuery*)unpackSelf(LUA, TYPE_QUERY); - LUA->PushBool(object->runningQueryData.size() > 0); - return 1; -} - -//Blocks the current Thread until the query has finished processing -//Possibly dangerous (dead lock when database goes down while waiting) -//If the second argument is set to true, the query is going to be swapped to the front of the query queue -int IQuery::wait(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - IQuery* object = (IQuery*)unpackSelf(LUA, TYPE_QUERY); - bool shouldSwap = false; - if (LUA->IsType(2, GarrysMod::Lua::Type::BOOL)) { - shouldSwap = LUA->GetBool(2); - } - if (object->runningQueryData.size() == 0) { - LUA->ThrowError("Query not started."); - } - std::shared_ptr lastInsertedQuery = object->runningQueryData.back(); - //Changing the order of the query might have unwanted side effects, so this is disabled by default - if (shouldSwap) { - object->m_database->queryQueue.swapToFrontIf([&](std::pair, std::shared_ptr> const& p) { - return p.second.get() == lastInsertedQuery.get(); - }); - } - { - std::unique_lock lck(object->m_waitMutex); - while (!lastInsertedQuery->isFinished()) object->m_waitWakeupVariable.wait(lck); - } - object->m_database->think(LUA); - return 0; -} - -//Returns the error message produced by the mysql query or 0 if there is none -int IQuery::error(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - IQuery* object = (IQuery*)unpackSelf(LUA, TYPE_QUERY); - if (!object->hasCallbackData()) { - return 0; - } - //Calling affectedRows() after query was executed but before the callback is run can cause race conditions - LUA->PushString(object->callbackQueryData->getError().c_str()); - return 1; -} - -//Attempts to abort the query, returns true if it was able to stop at least one query in time, false otherwise -int IQuery::abort(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - IQuery* object = (IQuery*)unpackSelf(LUA, TYPE_QUERY); - bool wasAborted = false; - //This is copied so that I can remove entries from that vector in onQueryDataFinished - auto vec = object->runningQueryData; - for (auto& data : vec) { - //It doesn't really matter if any of them are in a transaction since in that case they - //aren't in the query queue - bool wasRemoved = object->m_database->queryQueue.removeIf([&](std::pair, std::shared_ptr> const& p) { - return p.second.get() == data.get(); - }); - if (wasRemoved) { - data->setStatus(QUERY_ABORTED); - wasAborted = true; - if (data->getAbortReference() != 0) { - object->runFunction(LUA, data->getAbortReference()); - } else if (data->isFirstData()) { - object->runCallback(LUA, "onAborted"); - } - object->onQueryDataFinished(LUA, data); - } - } - LUA->PushBool(wasAborted); - return 1; -} - -//Sets several query options -int IQuery::setOption(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - IQuery* object = (IQuery*)unpackSelf(LUA, TYPE_QUERY); - LUA->CheckType(2, GarrysMod::Lua::Type::NUMBER); - bool set = true; - int option = (int)LUA->GetNumber(2); - if (option != OPTION_NUMERIC_FIELDS && - option != OPTION_NAMED_FIELDS && - option != OPTION_INTERPRET_DATA && - option != OPTION_CACHE) { - LUA->ThrowError("Invalid option"); - return 0; - } - - if (LUA->Top() >= 3) { - LUA->CheckType(3, GarrysMod::Lua::Type::BOOL); - set = LUA->GetBool(3); - } - - if (set) { - object->m_options |= option; - } else { - object->m_options &= ~option; - } - return 0; -} - -//Wrapper for c api calls -//Just throws an exception if anything goes wrong for ease of use - -void IQuery::mysqlQuery(MYSQL* sql, std::string &query) { - int result = mysql_real_query(sql, query.c_str(), (unsigned long) query.length()); - if (result != 0) { - const char* errorMessage = mysql_error(sql); - int errorCode = mysql_errno(sql); - throw MySQLException(errorCode, errorMessage); - } -} - -MYSQL_RES* IQuery::mysqlStoreResults(MYSQL* sql) { - MYSQL_RES* result = mysql_store_result(sql); - if (result == nullptr) { - int errorCode = mysql_errno(sql); - if (errorCode != 0) { - const char* errorMessage = mysql_error(sql); - throw MySQLException(errorCode, errorMessage); - } - } - return result; -} - -bool IQuery::mysqlNextResult(MYSQL* sql) { - int result = mysql_next_result(sql); - if (result == 0) return true; - if (result == -1) return false; - int errorCode = mysql_errno(sql); - if (errorCode != 0) { - const char* errorMessage = mysql_error(sql); - throw MySQLException(errorCode, errorMessage); - } - return false; -} - -void IQuery::addQueryData(GarrysMod::Lua::ILuaBase* LUA, std::shared_ptr data, bool shouldRefCallbacks) { - if (!hasBeenStarted) { - data->m_wasFirstData = true; - } - runningQueryData.push_back(data); - if (shouldRefCallbacks) { - data->m_onDataReference = this->getCallbackReference(LUA, "onData"); - data->m_errorReference = this->getCallbackReference(LUA, "onError"); - data->m_abortReference = this->getCallbackReference(LUA, "onAborted"); - data->m_successReference = this->getCallbackReference(LUA, "onSuccess"); - } -} -void IQuery::onQueryDataFinished(GarrysMod::Lua::ILuaBase* LUA, std::shared_ptr data) { - runningQueryData.erase(std::remove(runningQueryData.begin(), runningQueryData.end(), data)); - if (runningQueryData.size() == 0) { - canbedestroyed = true; - unreference(LUA); - } - if (data->m_onDataReference) { - LUA->ReferenceFree(data->m_onDataReference); - } - if (data->m_errorReference) { - LUA->ReferenceFree(data->m_errorReference); - } - if (data->m_abortReference) { - LUA->ReferenceFree(data->m_abortReference); - } - if (data->m_successReference) { - LUA->ReferenceFree(data->m_successReference); - } - data->m_onDataReference = 0; - data->m_errorReference = 0; - data->m_abortReference = 0; - data->m_successReference = 0; -} \ No newline at end of file diff --git a/MySQLOO/source/LuaObjectBase.cpp b/MySQLOO/source/LuaObjectBase.cpp deleted file mode 100644 index 982a15a..0000000 --- a/MySQLOO/source/LuaObjectBase.cpp +++ /dev/null @@ -1,337 +0,0 @@ -#include "LuaObjectBase.h" -#include -#include -#include -#include -#include - -int TYPE_DATABASE = -1; -int TYPE_QUERY = -1; - -std::deque> LuaObjectBase::luaObjects = std::deque>(); -std::deque> LuaObjectBase::luaThinkObjects = std::deque>(); -std::deque> LuaObjectBase::luaRemovalObjects = std::deque>(); -int LuaObjectBase::tableMetaTable = 0; - - -LuaObjectBase::LuaObjectBase(GarrysMod::Lua::ILuaBase* LUA, bool shouldthink, unsigned char type) : type(type) { - classname = "LuaObject"; - this->shouldthink = shouldthink; - std::shared_ptr ptr(this); - if (shouldthink) { - luaThinkObjects.push_back(ptr); - } - luaObjects.push_back(ptr); -} - -LuaObjectBase::LuaObjectBase(GarrysMod::Lua::ILuaBase* LUA, unsigned char type) : LuaObjectBase::LuaObjectBase(LUA, true, type) {} - - -//Important!!!! -//LuaObjectBase should never be deleted manually -//Let shared_ptrs handle it -LuaObjectBase::~LuaObjectBase() {} - -//Makes C++ functions callable from lua -void LuaObjectBase::registerFunction(GarrysMod::Lua::ILuaBase* LUA, std::string name, GarrysMod::Lua::CFunc func) { - this->m_callbackFunctions[name] = func; -} - -//Returns the shared_ptr that exists for this instance -std::shared_ptr LuaObjectBase::getSharedPointerInstance() { - return shared_from_this(); -} - -//Gets the C++ object associated with a lua table that represents it in LUA -LuaObjectBase* LuaObjectBase::unpackSelf(GarrysMod::Lua::ILuaBase* LUA, int type, bool shouldReference) { - return unpackLuaObject(LUA, 1, type, shouldReference); -} - -//Gets the C++ object associated with a lua table that represents it in LUA -LuaObjectBase* LuaObjectBase::unpackLuaObject(GarrysMod::Lua::ILuaBase* LUA, int index, int type, bool shouldReference) { - LUA->CheckType(index, GarrysMod::Lua::Type::TABLE); - LUA->GetField(index, "___lua_userdata_object"); - int itype = LUA->GetType(-1); - LuaObjectBase* object = NULL; - if (itype == type || type == -1) { - object = LUA->GetUserType(-1, itype); - } - if (object == NULL) { - std::ostringstream oss; - oss << "Wrong type, expected " << type << " got " << itype; - LUA->ThrowError(oss.str().c_str()); - } - if (shouldReference) { - referenceTable(LUA, object, index); - } - LUA->Pop(); - return object; -} - -void LuaObjectBase::referenceTable(GarrysMod::Lua::ILuaBase* LUA, LuaObjectBase* object, int index) { - if (object->m_userdataReference != 0 || object->m_tableReference != 0) { - LUA->ThrowError("Tried to reference lua object twice (Query started twice?)"); - } - LUA->CheckType(index, GarrysMod::Lua::Type::TABLE); - LUA->Push(index); - object->m_tableReference = LUA->ReferenceCreate(); - LUA->Push(index); - LUA->GetField(index, "___lua_userdata_object"); - object->m_userdataReference = LUA->ReferenceCreate(); -} - -//Pushes the table reference of a C++ object that represents it in LUA -int LuaObjectBase::pushTableReference(GarrysMod::Lua::ILuaBase* LUA) { - if (m_tableReference != 0) { - LUA->ReferencePush(m_tableReference); - return 1; - } - - LUA->PushUserType(this, type); - - LUA->PushMetaTable(type); - LUA->SetMetaTable(-2); - - LUA->CreateTable(); - - LUA->Push(-2); - LUA->SetField(-2, "___lua_userdata_object"); - - for (auto& callback : this->m_callbackFunctions) { - LUA->PushCFunction(callback.second); - LUA->SetField(-2, callback.first.c_str()); - } - - LUA->PushMetaTable(tableMetaTable); - LUA->SetMetaTable(-2); - - LUA->Remove(-2); - - return 1; -} - -//Unreferences the table that represents this C++ object in lua, so that it can be gc'ed -void LuaObjectBase::unreference(GarrysMod::Lua::ILuaBase* LUA) { - if (m_tableReference != 0) { - LUA->ReferenceFree(m_tableReference); - m_tableReference = 0; - } - if (m_userdataReference != 0) { - LUA->ReferenceFree(m_userdataReference); - m_userdataReference = 0; - } -} - -//Checks whether or not a callback exists -bool LuaObjectBase::hasCallback(GarrysMod::Lua::ILuaBase* LUA, const char* functionName) { - if (this->m_tableReference == 0) return false; - LUA->ReferencePush(this->m_tableReference); - LUA->GetField(-1, functionName); - bool hasCallback = LUA->GetType(-1) == GarrysMod::Lua::Type::FUNCTION; - LUA->Pop(2); - return hasCallback; -} - -int LuaObjectBase::getCallbackReference(GarrysMod::Lua::ILuaBase* LUA, const char* functionName) { - if (this->m_tableReference == 0) return 0; - LUA->ReferencePush(this->m_tableReference); - LUA->GetField(-1, functionName); - if (LUA->GetType(-1) != GarrysMod::Lua::Type::FUNCTION) { - LUA->Pop(2); - return 0; - } - //Hacky solution so there isn't too much stuff on the stack after this - int ref = LUA->ReferenceCreate(); - return ref; -} - -void LuaObjectBase::runFunction(GarrysMod::Lua::ILuaBase* LUA, int funcRef, const char* sig, ...) { - if (funcRef == 0) return; - va_list arguments; - va_start(arguments, sig); - runFunctionVarList(LUA, funcRef, sig, arguments); - va_end(arguments); -} - -static int buildErrorStack(lua_State *state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - - LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); - LUA->GetField(-1, "debug"); - LUA->GetField(-1, "traceback"); - - if (LUA->IsType(-1, GarrysMod::Lua::Type::FUNCTION)) { - LUA->Push(1); - LUA->Call(1, 1); - } - else { - LUA->Pop(3); // global, traceback - } - - - return 1; -} - -void LuaObjectBase::runFunctionVarList(GarrysMod::Lua::ILuaBase* LUA, int funcRef, const char* sig, va_list arguments) { - if (funcRef == 0) return; - if (this->m_tableReference == 0) return; - - LUA->PushCFunction(buildErrorStack); - int errorReporterIndex = LUA->Top(); - - LUA->ReferencePush(funcRef); - pushTableReference(LUA); - int numArguments = 1; - if (sig) { - for (unsigned int i = 0; i < std::strlen(sig); i++) { - char option = sig[i]; - if (option == 'i') { - int value = va_arg(arguments, int); - LUA->PushNumber(value); - numArguments++; - } else if (option == 'f') { - float value = static_cast(va_arg(arguments, double)); - LUA->PushNumber(value); - numArguments++; - } else if (option == 'b') { - bool value = va_arg(arguments, int) != 0; - LUA->PushBool(value); - numArguments++; - } else if (option == 's') { - char* value = va_arg(arguments, char*); - LUA->PushString(value); - numArguments++; - } else if (option == 'o') { - int value = va_arg(arguments, int); - LUA->ReferencePush(value); - numArguments++; - } else if (option == 'r') { - int reference = va_arg(arguments, int); - LUA->ReferencePush(reference); - numArguments++; - } else if (option == 'F') { - GarrysMod::Lua::CFunc value = va_arg(arguments, GarrysMod::Lua::CFunc); - LUA->PushCFunction(value); - numArguments++; - } - } - } - - if (LUA->PCall(numArguments, 0, errorReporterIndex)) { - LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); - LUA->GetField(-1, "ErrorNoHalt"); - //In case someone removes ErrorNoHalt this doesn't break everything - if (LUA->IsType(-1, GarrysMod::Lua::Type::FUNCTION)) { - LUA->Push(-3); // error - LUA->PushString("\n"); - LUA->Call(2, 0); - } - else - LUA->Pop(1); // function - - LUA->Pop(2); // error, global - } - - LUA->Pop(1); // error function -} - -//Runs callbacks associated with the lua object -void LuaObjectBase::runCallback(GarrysMod::Lua::ILuaBase* LUA, const char* functionName, const char* sig, ...) { - if (this->m_tableReference == 0) return; - int funcRef = getCallbackReference(LUA, functionName); - if (funcRef == 0) { - LUA->ReferenceFree(funcRef); - return; - } - va_list arguments; - va_start(arguments, sig); - runFunctionVarList(LUA, funcRef, sig, arguments); - va_end(arguments); - LUA->ReferenceFree(funcRef); -} - -//Called every tick, checks if the object can be destroyed -int LuaObjectBase::doThink(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - //Think objects need to be copied because a think call could modify the original thinkObject queue - //which leads to it invalidating the iterator and thus undefined behaviour - std::deque> thinkObjectsCopy = luaThinkObjects; - for (auto& query : luaThinkObjects) { - query->think(LUA); - } - if (luaRemovalObjects.size() > 0) { - for (auto it = luaRemovalObjects.begin(); it != luaRemovalObjects.end(); ) { - LuaObjectBase* obj = (*it).get(); - if (obj->canbedestroyed) { - obj->onDestroyed(LUA); - it = luaRemovalObjects.erase(it); - auto objectIt = std::find_if(luaObjects.begin(), luaObjects.end(), [&](std::shared_ptr const& p) { - return p.get() == obj; - }); - if (objectIt != luaObjects.end()) { - luaObjects.erase(objectIt); - } - auto thinkObjectIt = std::find_if(luaThinkObjects.begin(), luaThinkObjects.end(), [&](std::shared_ptr const& p) { - return p.get() == obj; - }); - if (thinkObjectIt != luaThinkObjects.end()) { - luaThinkObjects.erase(thinkObjectIt); - } - } else { - ++it; - } - } - } - return 0; -} - -//Called when the LUA table representing this C++ object has been gc'ed -//Deletes the associated C++ object -int LuaObjectBase::gcDeleteWrapper(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - int type = LUA->GetType(1); - if (type != TYPE_DATABASE && type != TYPE_QUERY) return 0; - LuaObjectBase* object = LUA->GetUserType(1, type); - if (object == NULL) return 0; - if (!object->scheduledForRemoval) { - if (object->m_userdataReference != 0) { - LUA->ReferenceFree(object->m_userdataReference); - object->m_userdataReference = 0; - } - object->scheduledForRemoval = true; - //This can't go wrong, lua objects are only ever deleted in the main thread, - //which this function is being called by, so the object can't be deleted yet - luaRemovalObjects.push_back(object->getSharedPointerInstance()); - } - return 0; -} - -//Prints the name of the object -int LuaObjectBase::toStringWrapper(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - LuaObjectBase* object = unpackSelf(LUA); - std::stringstream ss; - ss << object->classname << " " << object; - LUA->PushString(ss.str().c_str()); - return 1; -} - -//Creates metatables used for the LUA representation of the C++ table -int LuaObjectBase::createMetatables(GarrysMod::Lua::ILuaBase* LUA) { - TYPE_DATABASE = LUA->CreateMetaTable("MySQLOO database"); - LUA->PushCFunction(LuaObjectBase::gcDeleteWrapper); - LUA->SetField(-2, "__gc"); - - TYPE_QUERY = LUA->CreateMetaTable("MySQLOO query"); - LUA->PushCFunction(LuaObjectBase::gcDeleteWrapper); - LUA->SetField(-2, "__gc"); - - tableMetaTable = LUA->CreateMetaTable("MySQLOO table"); - LUA->PushCFunction(LuaObjectBase::toStringWrapper); - LUA->SetField(-2, "__tostring"); - - return 0; -} \ No newline at end of file diff --git a/MySQLOO/source/PingQuery.cpp b/MySQLOO/source/PingQuery.cpp deleted file mode 100644 index 842735a..0000000 --- a/MySQLOO/source/PingQuery.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "PingQuery.h" -#ifdef LINUX -#include -#endif -#include "Database.h" - - -//Dummy class just used with the Database::ping function -PingQuery::PingQuery(Database* dbase, GarrysMod::Lua::ILuaBase* LUA) : Query(dbase, LUA) { - classname = "PingQuery"; -} - -PingQuery::~PingQuery(void) {} - -/* Executes the ping query -*/ -void PingQuery::executeQuery(MYSQL* connection, std::shared_ptr data) { - bool oldAutoReconnect = this->m_database->getAutoReconnect(); - this->m_database->setAutoReconnect(true); - this->pingSuccess = mysql_ping(connection) == 0; - this->m_database->setAutoReconnect(oldAutoReconnect); -} \ No newline at end of file diff --git a/MySQLOO/source/PreparedQuery.cpp b/MySQLOO/source/PreparedQuery.cpp deleted file mode 100644 index 0d8d215..0000000 --- a/MySQLOO/source/PreparedQuery.cpp +++ /dev/null @@ -1,323 +0,0 @@ -#include "PreparedQuery.h" -#include "Database.h" -#include "errmsg.h" -#ifdef LINUX -#include -#endif -//This is dirty but hopefully will be consistent between mysql connector versions -#define ER_MAX_PREPARED_STMT_COUNT_REACHED 1461 - -PreparedQuery::PreparedQuery(Database* dbase, GarrysMod::Lua::ILuaBase* LUA) : Query(dbase, LUA) { - classname = "PreparedQuery"; - registerFunction(LUA, "setNumber", PreparedQuery::setNumber); - registerFunction(LUA, "setString", PreparedQuery::setString); - registerFunction(LUA, "setBoolean", PreparedQuery::setBoolean); - registerFunction(LUA, "setNull", PreparedQuery::setNull); - registerFunction(LUA, "putNewParameters", PreparedQuery::putNewParameters); - registerFunction(LUA, "clearParameters", PreparedQuery::clearParameters); - this->m_parameters.push_back(std::unordered_map>()); - //This pointer is used to prevent the database being accessed after it was deleted - //when this preparedq query still owns a MYSQL_STMT* - this->weak_database = std::dynamic_pointer_cast(m_database->getSharedPointerInstance()); -} - -PreparedQuery::~PreparedQuery(void) {} - -//When the query is destroyed by lua -void PreparedQuery::onDestroyed(GarrysMod::Lua::ILuaBase* LUA) { - //There can't be any race conditions here - //This always runs after PreparedQuery::executeQuery() is done - //I am using atomic to prevent visibility issues though - auto ptr = this->weak_database.lock(); - if (ptr.get() != nullptr && LUA != NULL) { //When the server shuts down this will be free'd by the database - MYSQL_STMT* stmt = this->cachedStatement; - if (stmt != nullptr) { - ptr->freeStatement(cachedStatement); - cachedStatement = nullptr; - } - } -} - -int PreparedQuery::clearParameters(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - PreparedQuery* object = (PreparedQuery*)unpackSelf(LUA, TYPE_QUERY); - object->m_parameters.clear(); - object->m_parameters.emplace_back(); - return 0; -} - -int PreparedQuery::setNumber(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - PreparedQuery* object = (PreparedQuery*)unpackSelf(LUA, TYPE_QUERY); - LUA->CheckType(2, GarrysMod::Lua::Type::NUMBER); - LUA->CheckType(3, GarrysMod::Lua::Type::NUMBER); - double index = LUA->GetNumber(2); - if (index < 1) LUA->ThrowError("Index must be greater than 0"); - unsigned int uIndex = (unsigned int)index; - double value = LUA->GetNumber(3); - object->m_parameters.back()[uIndex] = std::shared_ptr(new TypedQueryField(uIndex, MYSQL_TYPE_DOUBLE, value)); - return 0; -} - -int PreparedQuery::setString(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - PreparedQuery* object = (PreparedQuery*)unpackSelf(LUA, TYPE_QUERY); - LUA->CheckType(2, GarrysMod::Lua::Type::NUMBER); - LUA->CheckType(3, GarrysMod::Lua::Type::STRING); - double index = LUA->GetNumber(2); - if (index < 1) LUA->ThrowError("Index must be greater than 0"); - unsigned int uIndex = (unsigned int)index; - unsigned int length = 0; - const char* string = LUA->GetString(3, &length); - object->m_parameters.back()[uIndex] = std::shared_ptr(new TypedQueryField(uIndex, MYSQL_TYPE_STRING, std::string(string, length))); - return 0; -} - -int PreparedQuery::setBoolean(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - PreparedQuery* object = (PreparedQuery*)unpackSelf(LUA, TYPE_QUERY); - LUA->CheckType(2, GarrysMod::Lua::Type::NUMBER); - LUA->CheckType(3, GarrysMod::Lua::Type::BOOL); - double index = LUA->GetNumber(2); - if (index < 1) LUA->ThrowError("Index must be greater than 0"); - unsigned int uIndex = (unsigned int)index; - bool value = LUA->GetBool(3); - object->m_parameters.back()[uIndex] = std::shared_ptr(new TypedQueryField(uIndex, MYSQL_TYPE_BIT, value)); - return 0; -} - -int PreparedQuery::setNull(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - PreparedQuery* object = (PreparedQuery*)unpackSelf(LUA, TYPE_QUERY); - LUA->CheckType(2, GarrysMod::Lua::Type::NUMBER); - double index = LUA->GetNumber(2); - if (index < 1) LUA->ThrowError("Index must be greater than 0"); - unsigned int uIndex = (unsigned int)index; - object->m_parameters.back()[uIndex] = std::shared_ptr(new PreparedQueryField(uIndex, MYSQL_TYPE_NULL)); - return 0; -} - -//Adds an additional set of parameters to the prepared query -//This makes it relatively easy to insert multiple rows at once -int PreparedQuery::putNewParameters(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - PreparedQuery* object = (PreparedQuery*)unpackSelf(LUA, TYPE_QUERY); - object->m_parameters.emplace_back(); - return 0; -} - -//Wrapper functions that might throw errors -MYSQL_STMT* PreparedQuery::mysqlStmtInit(MYSQL* sql) { - MYSQL_STMT* stmt = mysql_stmt_init(sql); - if (stmt == nullptr) { - const char* errorMessage = mysql_error(sql); - int errorCode = mysql_errno(sql); - throw MySQLException(errorCode, errorMessage); - } - return stmt; -} - -void PreparedQuery::mysqlStmtBindParameter(MYSQL_STMT* stmt, MYSQL_BIND* bind) { - int result = mysql_stmt_bind_param(stmt, bind); - if (result != 0) { - const char* errorMessage = mysql_stmt_error(stmt); - int errorCode = mysql_stmt_errno(stmt); - throw MySQLException(errorCode, errorMessage); - } -} - -void PreparedQuery::mysqlStmtPrepare(MYSQL_STMT* stmt, const char* str) { - unsigned long length = (unsigned long) strlen(str); - int result = mysql_stmt_prepare(stmt, str, length); - if (result != 0) { - const char* errorMessage = mysql_stmt_error(stmt); - int errorCode = mysql_stmt_errno(stmt); - throw MySQLException(errorCode, errorMessage); - } -} - -void PreparedQuery::mysqlStmtExecute(MYSQL_STMT* stmt) { - int result = mysql_stmt_execute(stmt); - if (result != 0) { - const char* errorMessage = mysql_stmt_error(stmt); - int errorCode = mysql_stmt_errno(stmt); - throw MySQLException(errorCode, errorMessage); - } -} - -void PreparedQuery::mysqlStmtStoreResult(MYSQL_STMT* stmt) { - int result = mysql_stmt_store_result(stmt); - if (result != 0) { - const char* errorMessage = mysql_stmt_error(stmt); - int errorCode = mysql_stmt_errno(stmt); - throw MySQLException(errorCode, errorMessage); - } -} - -bool PreparedQuery::mysqlStmtNextResult(MYSQL_STMT* stmt) { - int result = mysql_stmt_next_result(stmt); - if (result > 0) { - const char* errorMessage = mysql_stmt_error(stmt); - int errorCode = mysql_stmt_errno(stmt); - throw MySQLException(errorCode, errorMessage); - } - return result == 0; -} - -static bool nullBool = 1; -static int trueValue = 1; -static int falseValue = 0; - -//Generates binds for a prepared query. In this case the binds are used to send the parameters to the server -void PreparedQuery::generateMysqlBinds(MYSQL_BIND* binds, std::unordered_map> &map, unsigned int parameterCount) { - for (unsigned int i = 1; i <= parameterCount; i++) { - auto it = map.find(i); - if (it == map.end()) { - MYSQL_BIND* bind = &binds[i - 1]; - bind->buffer_type = MYSQL_TYPE_NULL; - bind->is_null = &nullBool; - continue; - } - unsigned int index = it->second->m_index - 1; - if (index >= parameterCount) { - std::stringstream errStream; - errStream << "Invalid parameter index " << index + 1; - throw MySQLException(0, errStream.str().c_str()); - } - MYSQL_BIND* bind = &binds[index]; - switch (it->second->m_type) { - case MYSQL_TYPE_DOUBLE: - { - TypedQueryField* doubleField = static_cast*>(it->second.get()); - bind->buffer_type = MYSQL_TYPE_DOUBLE; - bind->buffer = (char*)&doubleField->m_data; - break; - } - case MYSQL_TYPE_BIT: - { - TypedQueryField* boolField = static_cast*>(it->second.get()); - bind->buffer_type = MYSQL_TYPE_LONG; - bind->buffer = (char*)& ((boolField->m_data) ? trueValue : falseValue); - break; - } - case MYSQL_TYPE_STRING: - { - TypedQueryField* textField = static_cast*>(it->second.get()); - bind->buffer_type = MYSQL_TYPE_STRING; - bind->buffer = (char*)textField->m_data.c_str(); - bind->buffer_length = (unsigned long) textField->m_data.length(); - break; - } - case MYSQL_TYPE_NULL: - { - bind->buffer_type = MYSQL_TYPE_NULL; - bind->is_null = &nullBool; - break; - } - } - } -} - - - -/* Executes the prepared query -* This function can only ever return one result set -* Note: If an error occurs at the nth query all the actions done before -* that nth query won't be reverted even though this query results in an error -*/ -void PreparedQuery::executeQuery(MYSQL* connection, std::shared_ptr ptr) { - PreparedQueryData* data = (PreparedQueryData*)ptr.get(); - bool oldReconnectStatus = m_database->getAutoReconnect(); - //Autoreconnect has to be disabled for prepared statement since prepared statements - //get reset on the server if the connection fails and auto reconnects - m_database->setAutoReconnect(false); - auto resetReconnectStatus = finally([&] { m_database->setAutoReconnect(oldReconnectStatus); }); - try { - MYSQL_STMT* stmt = nullptr; - auto stmtClose = finally([&] { - if (!m_database->shouldCachePreparedStatements() && stmt != nullptr) { - mysql_stmt_close(stmt); - } - }); - if (this->cachedStatement.load() != nullptr) { - stmt = this->cachedStatement; - } else { - stmt = mysqlStmtInit(connection); - bool attrMaxLength = 1; - mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &attrMaxLength); - mysqlStmtPrepare(stmt, this->m_query.c_str()); - if (m_database->shouldCachePreparedStatements()) { - this->cachedStatement = stmt; - m_database->cacheStatement(stmt); - } - } - unsigned int parameterCount = mysql_stmt_param_count(stmt); - std::vector mysqlParameters(parameterCount); - - for (auto& currentMap : data->m_parameters) { - generateMysqlBinds(mysqlParameters.data(), currentMap, parameterCount); - mysqlStmtBindParameter(stmt, mysqlParameters.data()); - mysqlStmtExecute(stmt); - do { - //There is a potential race condition here. What happens - //when the query executes fine but something goes wrong while storing the result? - mysqlStmtStoreResult(stmt); - auto resultFree = finally([&] { mysql_stmt_free_result(stmt); }); - data->m_affectedRows.push_back(mysql_stmt_affected_rows(stmt)); - data->m_insertIds.push_back(mysql_stmt_insert_id(stmt)); - data->m_results.emplace_back(stmt); - data->m_resultStatus = QUERY_SUCCESS; - } while (mysqlStmtNextResult(stmt)); - } - } catch (const MySQLException& error) { - int errorCode = error.getErrorCode(); - if ((errorCode == CR_SERVER_LOST || errorCode == CR_SERVER_GONE_ERROR || errorCode == ER_MAX_PREPARED_STMT_COUNT_REACHED)) { - m_database->freeStatement(this->cachedStatement); - this->cachedStatement = nullptr; - //Because autoreconnect is disabled we want to try and explicitly execute the prepared query once more - //if we can get the client to reconnect (reconnect is caused by mysql_ping) - //If this fails we just go ahead and error - if (oldReconnectStatus && data->firstAttempt) { - m_database->setAutoReconnect(true); - if (mysql_ping(connection) == 0) { - data->firstAttempt = false; - executeQuery(connection, ptr); - return; - } - } - } - //Rethrow error to be handled by executeStatement() - throw error; - } -} - -bool PreparedQuery::executeStatement(MYSQL* connection, std::shared_ptr ptr) { - PreparedQueryData* data = (PreparedQueryData*)ptr.get(); - data->setStatus(QUERY_RUNNING); - try { - this->executeQuery(connection, ptr); - data->setResultStatus(QUERY_SUCCESS); - } catch (const MySQLException& error) { - data->setResultStatus(QUERY_ERROR); - data->setError(error.what()); - } - return true; -} - - -std::shared_ptr PreparedQuery::buildQueryData(GarrysMod::Lua::ILuaBase* LUA) { - std::shared_ptr ptr(new PreparedQueryData()); - PreparedQueryData* data = (PreparedQueryData*)ptr.get(); - data->m_parameters = this->m_parameters; - while (m_parameters.size() > 1) { - //Front so the last used parameters are the ones that are gonna stay - m_parameters.pop_front(); - } - return ptr; -} \ No newline at end of file diff --git a/MySQLOO/source/Query.cpp b/MySQLOO/source/Query.cpp deleted file mode 100644 index 75c7086..0000000 --- a/MySQLOO/source/Query.cpp +++ /dev/null @@ -1,268 +0,0 @@ -#include "Query.h" -#include -#include -#include -#include -#ifdef LINUX -#include -#endif - -Query::Query(Database* dbase, GarrysMod::Lua::ILuaBase* LUA) : IQuery(dbase, LUA) { - classname = "Query"; - registerFunction(LUA, "affectedRows", Query::affectedRows); - registerFunction(LUA, "lastInsert", Query::lastInsert); - registerFunction(LUA, "getData", Query::getData_Wrapper); - registerFunction(LUA, "hasMoreResults", Query::hasMoreResults); - registerFunction(LUA, "getNextResults", Query::getNextResults); -} - -Query::~Query(void) {} - -//Calls the lua callbacks associated with this query -void Query::doCallback(GarrysMod::Lua::ILuaBase* LUA, std::shared_ptr data) { - if (this->dataReference != 0) { - LUA->ReferenceFree(this->dataReference); - this->dataReference = 0; - } - switch (data->getResultStatus()) { - case QUERY_NONE: - break; - case QUERY_ERROR: - if (data->getErrorReference() != 0) { - this->runFunction(LUA, data->getErrorReference(), "ss", data->getError().c_str(), this->m_query.c_str()); - } else if (data->isFirstData()) { - //This is to preserve somewhat of a backwards compatibility - //In case people set their callbacks after they start their queries - //If it was the first data this query has been started with then - //it can also search on the object for the callback - //This might break some code under very specific circumstances - //but I doubt this will ever be an issue - this->runCallback(LUA, "onError", "ss", data->getError().c_str(), this->m_query.c_str()); - } - break; - case QUERY_SUCCESS: - int dataref = this->getData(LUA); - if (data->getOnDataReference() != 0 || (this->hasCallback(LUA, "onData") && data->isFirstData())) { - LUA->ReferencePush(dataref); - LUA->PushNil(); - while (LUA->Next(-2)) { - //Top is now the row, top-1 row index - int rowReference = LUA->ReferenceCreate(); - if (data->getOnDataReference() != 0) { - this->runFunction(LUA, data->getOnDataReference(), "r", rowReference); - } else if (data->isFirstData()) { - this->runCallback(LUA, "onData", "r", rowReference); - } - LUA->ReferenceFree(rowReference); - //Don't have to pop since reference create consumed the value - } - LUA->Pop(); - } - if (data->getSuccessReference() != 0) { - this->runFunction(LUA, data->getSuccessReference(), "r", dataref); - } else if (data->isFirstData()) { - this->runCallback(LUA, "onSuccess", "r", dataref); - } - break; - } -} - -void Query::executeQuery(MYSQL* connection, std::shared_ptr data) { - QueryData* queryData = (QueryData*)data.get(); - this->mysqlQuery(connection, this->m_query); - //Stores all result sets - //MySQL result sets shouldn't be accessed from different threads! - do { - MYSQL_RES * results = this->mysqlStoreResults(connection); - auto resultFree = finally([&] { mysql_free_result(results); }); - if (results != nullptr) - queryData->m_results.emplace_back(results); - else - queryData->m_results.emplace_back(); - queryData->m_insertIds.push_back(mysql_insert_id(connection)); - queryData->m_affectedRows.push_back(mysql_affected_rows(connection)); - } while (this->mysqlNextResult(connection)); -} - -//Executes the raw query -bool Query::executeStatement(MYSQL* connection, std::shared_ptr data) { - QueryData* queryData = (QueryData*)data.get(); - queryData->setStatus(QUERY_RUNNING); - try { - this->executeQuery(connection, data); - queryData->m_resultStatus = QUERY_SUCCESS; - } catch (const MySQLException& error) { - queryData->setError(error.what()); - queryData->setResultStatus(QUERY_ERROR); - } - return true; -} - -//Sets the mysql query string -void Query::setQuery(std::string query) { - m_query = query; -} - - -//This function just returns the data associated with the query -//Data is only created once (and then the reference to that data is returned) -int Query::getData_Wrapper(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Query* object = (Query*)unpackSelf(LUA, TYPE_QUERY); - if (!object->hasCallbackData() || object->callbackQueryData->getResultStatus() == QUERY_ERROR) { - LUA->PushNil(); - } else { - LUA->ReferencePush(object->getData(LUA)); - } - return 1; -} - -//Stores the data associated with the current result set of the query -//Only called once per result set (and then cached) -int Query::getData(GarrysMod::Lua::ILuaBase* LUA) { - if (this->dataReference != 0) - return this->dataReference; - LUA->CreateTable(); - if (hasCallbackData()) { - QueryData* data = (QueryData*)callbackQueryData.get(); - if (data->hasMoreResults()) { - ResultData& currentData = data->getResult(); - for (unsigned int i = 0; i < currentData.getRows().size(); i++) { - ResultDataRow& row = currentData.getRows()[i]; - LUA->CreateTable(); - int rowObject = LUA->ReferenceCreate(); - for (unsigned int j = 0; j < row.getValues().size(); j++) { - dataToLua(LUA, rowObject, j + 1, row.getValues()[j], currentData.getColumns()[j].c_str(), - currentData.getColumnTypes()[j], row.isFieldNull(j)); - } - LUA->PushNumber(i + 1); - LUA->ReferencePush(rowObject); - LUA->SetTable(-3); - LUA->ReferenceFree(rowObject); - } - } - } - this->dataReference = LUA->ReferenceCreate(); - return this->dataReference; -}; - - -//Function that converts the data stored in a mysql field into a lua type -void Query::dataToLua(GarrysMod::Lua::ILuaBase* LUA, int rowReference, unsigned int column, - std::string &columnValue, const char* columnName, int columnType, bool isNull) { - LUA->ReferencePush(rowReference); - if (this->m_options & OPTION_NUMERIC_FIELDS) { - LUA->PushNumber(column); - } - if (isNull) { - LUA->PushNil(); - } else { - switch (columnType) { - case MYSQL_TYPE_FLOAT: - case MYSQL_TYPE_DOUBLE: - case MYSQL_TYPE_LONGLONG: - case MYSQL_TYPE_LONG: - case MYSQL_TYPE_INT24: - case MYSQL_TYPE_TINY: - case MYSQL_TYPE_SHORT: - LUA->PushNumber(atof(columnValue.c_str())); - break; - case MYSQL_TYPE_BIT: - LUA->PushNumber(static_cast(columnValue[0])); - break; - case MYSQL_TYPE_NULL: - LUA->PushNil(); - break; - default: - LUA->PushString(columnValue.c_str(), (unsigned int) columnValue.length()); - break; - } - } - if (this->m_options & OPTION_NUMERIC_FIELDS) { - LUA->SetTable(-3); - } else { - LUA->SetField(-2, columnName); - } - LUA->Pop(); -} - - -//Returns true if a query has at least one additional ResultSet left -int Query::hasMoreResults(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Query* object = (Query*)unpackSelf(LUA, TYPE_QUERY); - if (!object->hasCallbackData()) { - LUA->ThrowError("Query not completed yet"); - } - QueryData* data = (QueryData*)object->callbackQueryData.get(); - LUA->PushBool(data->hasMoreResults()); - return 1; -} - -//Unreferences the current result set and uses the next result set -int Query::getNextResults(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Query* object = (Query*)unpackSelf(LUA, TYPE_QUERY); - if (!object->hasCallbackData()) { - LUA->ThrowError("Query not completed yet"); - } - QueryData* data = (QueryData*)object->callbackQueryData.get(); - if (!data->getNextResults()) { - LUA->ThrowError("Query doesn't have any more results"); - } - if (object->dataReference != 0) { - LUA->ReferenceFree(object->dataReference); - object->dataReference = 0; - } - LUA->ReferencePush(object->getData(LUA)); - return 1; -} - -//Returns the last insert id produced by INSERT INTO statements (or 0 if there is none) -int Query::lastInsert(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Query* object = (Query*)unpackSelf(LUA, TYPE_QUERY); - if (!object->hasCallbackData()) { - LUA->PushNumber(0); - return 1; - } - QueryData* data = (QueryData*)object->callbackQueryData.get(); - //Calling lastInsert() after query was executed but before the callback is run can cause race conditions - LUA->PushNumber((double)data->getLastInsertID()); - return 1; -} - -//Returns the last affected rows produced by INSERT/DELETE/UPDATE (0 for none, -1 for errors) -//For a SELECT statement this returns the amount of rows returned -int Query::affectedRows(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Query* object = (Query*)unpackSelf(LUA, TYPE_QUERY); - if (!object->hasCallbackData()) { - LUA->PushNumber(0); - return 1; - } - QueryData* data = (QueryData*)object->callbackQueryData.get(); - //Calling affectedRows() after query was executed but before the callback is run can cause race conditions - LUA->PushNumber((double)data->getAffectedRows()); - return 1; -} - - -//When the query is destroyed by lua -void Query::onDestroyed(GarrysMod::Lua::ILuaBase* LUA) { - if (this->dataReference != 0 && LUA != nullptr) { - //Make sure data associated with this query can be freed as well - LUA->ReferenceFree(this->dataReference); - this->dataReference = 0; - } -} - -std::shared_ptr Query::buildQueryData(GarrysMod::Lua::ILuaBase* LUA) { - std::shared_ptr ptr(new QueryData()); - return ptr; -} \ No newline at end of file diff --git a/MySQLOO/source/Transaction.cpp b/MySQLOO/source/Transaction.cpp deleted file mode 100644 index ecfe320..0000000 --- a/MySQLOO/source/Transaction.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include "Transaction.h" -#include "ResultData.h" -#include "errmsg.h" -#include "Database.h" - -Transaction::Transaction(Database* dbase, GarrysMod::Lua::ILuaBase* LUA) : IQuery(dbase, LUA) { - registerFunction(LUA, "addQuery", Transaction::addQuery); - registerFunction(LUA, "getQueries", Transaction::getQueries); - registerFunction(LUA, "clearQueries", Transaction::clearQueries); -} - -void Transaction::onDestroyed(GarrysMod::Lua::ILuaBase* LUA) {} - -//TODO Fix memory leak if transaction is never started -int Transaction::addQuery(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Transaction* transaction = dynamic_cast(unpackSelf(LUA, TYPE_QUERY)); - if (transaction == nullptr) { - LUA->ThrowError("Tried to pass wrong self"); - return 0; - } - IQuery* iQuery = (IQuery*)unpackLuaObject(LUA, 2, TYPE_QUERY, false); - Query* query = dynamic_cast(iQuery); - if (query == nullptr) { - LUA->ThrowError("Tried to pass non query to addQuery()"); - return 0; - } - //We have an array of query data - //We need this so that we can add a single prepared query multiple times, each with possible different data. - transaction->addedQueryData.push_back(query->buildQueryData(LUA)); - //This table here is used to prevent cyclic references and thus memory leaks. - //It is extremely ugly but I have yet to find a better solution. - LUA->Push(1); - LUA->GetField(-1, "__queries"); - if (LUA->IsType(-1, GarrysMod::Lua::Type::NIL)) { - LUA->Pop(); - LUA->CreateTable(); - LUA->SetField(-2, "__queries"); - LUA->GetField(-1, "__queries"); - } - int tblIndex = LUA->Top(); - LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); - LUA->GetField(-1, "table"); - LUA->GetField(-1, "insert"); - LUA->Push(tblIndex); - LUA->Push(2); - LUA->Call(2, 0); - LUA->Push(4); - return 0; -} - -int Transaction::getQueries(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Transaction* transaction = dynamic_cast(unpackSelf(LUA, TYPE_QUERY)); - if (transaction == nullptr) { - LUA->ThrowError("Tried to pass wrong self"); - } - LUA->Push(1); - LUA->GetField(-1, "__queries"); - return 1; -} - -int Transaction::clearQueries(lua_State* state) { - GarrysMod::Lua::ILuaBase* LUA = state->luabase; - LUA->SetState(state); - Transaction* transaction = dynamic_cast(unpackSelf(LUA, TYPE_QUERY)); - if (transaction == nullptr) { - LUA->ThrowError("Tried to pass wrong self"); - } - LUA->Push(1); - LUA->PushNil(); - LUA->SetField(-2, "__queries"); - LUA->Pop(); - return 0; -} - -//Calls the lua callbacks associated with this query -void Transaction::doCallback(GarrysMod::Lua::ILuaBase* LUA, std::shared_ptr ptr) { - TransactionData* data = (TransactionData*)ptr.get(); - data->setStatus(QUERY_COMPLETE); - std::vector queryTableRefs; - for (auto& pair : data->m_queries) { - auto query = pair.first; - //So we get the current data rather than caching it - query->dataReference = 0; - auto queryData = pair.second; - query->setCallbackData(queryData); - queryTableRefs.push_back(query->getData(LUA)); - } - switch (data->getResultStatus()) { - case QUERY_NONE: - break; - case QUERY_ERROR: - if (data->getErrorReference() != 0) { - this->runFunction(LUA, data->getErrorReference(), "s", data->getError().c_str()); - } else if (data->isFirstData()) { - this->runCallback(LUA, "onError", "s", data->getError().c_str()); - } - break; - case QUERY_SUCCESS: - LUA->CreateTable(); - - for (int i = 0; i < queryTableRefs.size(); i++) { - LUA->PushNumber(i + 1); - LUA->ReferencePush(queryTableRefs[i]); - LUA->SetTable(-3); - } - int dataRef = LUA->ReferenceCreate(); - - if (data->getSuccessReference() != 0) { - this->runFunction(LUA, data->getSuccessReference(), "r", dataRef); - } else if (data->isFirstData()) { - this->runCallback(LUA, "onSuccess", "r", dataRef); - } - LUA->ReferenceFree(dataRef); - break; - } - for (auto& pair : data->m_queries) { - auto query = pair.first; - auto queryData = pair.second; - query->onQueryDataFinished(LUA, queryData); - } -} - -bool Transaction::executeStatement(MYSQL* connection, std::shared_ptr ptr) { - TransactionData* data = (TransactionData*)ptr.get(); - data->setStatus(QUERY_RUNNING); - //This temporarily disables reconnect, since a reconnect - //would rollback (and cancel) a transaction - //Which could lead to parts of the transaction being executed outside of a transaction - //If they are being executed after the reconnect - bool oldReconnectStatus = m_database->getAutoReconnect(); - m_database->setAutoReconnect(false); - auto resetReconnectStatus = finally([&] { m_database->setAutoReconnect(oldReconnectStatus); }); - try { - this->mysqlAutocommit(connection, false); - { - for (auto& query : data->m_queries) { - try { - //Errors are cleared in case this is retrying after losing connection - query.second->setResultStatus(QUERY_NONE); - query.second->setError(""); - query.first->executeQuery(connection, query.second); - } catch (const MySQLException& error) { - query.second->setError(error.what()); - query.second->setResultStatus(QUERY_ERROR); - throw error; - } - } - } - mysql_commit(connection); - data->setResultStatus(QUERY_SUCCESS); - this->mysqlAutocommit(connection, true); - } catch (const MySQLException& error) { - //This check makes sure that setting mysqlAutocommit back to true doesn't cause the transaction to fail - //Even though the transaction was executed successfully - if (data->getResultStatus() != QUERY_SUCCESS) { - int errorCode = error.getErrorCode(); - if (oldReconnectStatus && !data->retried && - (errorCode == CR_SERVER_LOST || errorCode == CR_SERVER_GONE_ERROR)) { - //Because autoreconnect is disabled we want to try and explicitly execute the transaction once more - //if we can get the client to reconnect (reconnect is caused by mysql_ping) - //If this fails we just go ahead and error - m_database->setAutoReconnect(true); - if (mysql_ping(connection) == 0) { - data->retried = true; - return executeStatement(connection, ptr); - } - } - //If this call fails it means that the connection was (probably) lost - //In that case the mysql server rolls back any transaction anyways so it doesn't - //matter if it fails - mysql_rollback(connection); - data->setResultStatus(QUERY_ERROR); - } - //If this fails it probably means that the connection was lost - //In that case autocommit is turned back on anyways (once the connection is reestablished) - //See: https://dev.mysql.com/doc/refman/5.7/en/auto-reconnect.html - mysql_autocommit(connection, true); - data->setError(error.what()); - } - for (auto& pair : data->m_queries) { - pair.second->setResultStatus(data->getResultStatus()); - pair.second->setStatus(QUERY_COMPLETE); - } - data->setStatus(QUERY_COMPLETE); - return true; -} - - -std::shared_ptr Transaction::buildQueryData(GarrysMod::Lua::ILuaBase* LUA) { - //At this point the transaction is guaranteed to have a referenced table - //since this is always called shortly after transaction:start() - std::shared_ptr ptr(new TransactionData()); - TransactionData* data = (TransactionData*)ptr.get(); - this->pushTableReference(LUA); - LUA->GetField(-1, "__queries"); - if (!LUA->IsType(-1, GarrysMod::Lua::Type::TABLE)) { - LUA->Pop(2); - return ptr; - } - //Stuff could go horribly wrong here if a lua error occurs - //but it really shouldn't unless someone screws with the __queries field - for (int i = 0; i < this->addedQueryData.size(); i++) { - auto queryDataPtr = this->addedQueryData[i]; - LUA->PushNumber(i + 1); - LUA->GetTable(-2); - if (!LUA->IsType(-1, GarrysMod::Lua::Type::TABLE)) { - LUA->Pop(); - break; - } - //This would error if it's not a query - Query * iQuery = (Query*)unpackLuaObject(LUA, -1, TYPE_QUERY, false); - auto queryPtr = std::dynamic_pointer_cast(iQuery->getSharedPointerInstance()); - iQuery->addQueryData(LUA, queryDataPtr, false); - data->m_queries.push_back(std::make_pair(queryPtr, queryDataPtr)); - LUA->Pop(); - } - LUA->Pop(2); - return ptr; -} \ No newline at end of file diff --git a/README.md b/README.md index 4f94083..8880515 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ This module is an almost entirely rewritten version of MySQLOO 8.1. It supports several new features such as multiple result sets, prepared queries and transactions. The module also fixed the memory leak issues the previous versions of MySQLOO had. -For further information please [visit this forum thread](https://forum.facepunch.com/f/gmodaddon/jjdq/gmsv-mysqloo-v9-Rewritten-MySQL-Module-prepared-statements-transactions/1/). - # Install instructions Download the latest module for your server's operating system and architecture using the links provided below, then place that file within the `garrysmod/lua/bin/` folder on your server. If the `bin` folder doesn't exist, please create it. @@ -132,10 +130,16 @@ Database:ping() -- returns true if the connection is still up, false otherwise Database:setCharacterSet(charSetName) --- Returns [Boolean, String] +-- Returns [Boolean] -- Attempts to set the connection's character set to the one specified. -- Please note that this does block the main server thread if there is a query currently being ran --- Returns true on success, false and an error message on failure +-- Returns true on success, false on failure + +Database:setSSL(key, cert, ca, capath, cipher) +-- Returns nothing +-- Sets the SSL configuration of the database object. This allows you to enable secure connections over the internet using TLS. +-- Every parameter is optional and can be omitted (set to nil) if not required. +-- See https://dev.mysql.com/doc/c-api/8.0/en/mysql-ssl-set.html for the description of each parameter. -- Callbacks Database.onConnected( db ) @@ -164,16 +168,12 @@ Query:getData() Query:abort() -- Returns [Boolean] -- Attempts to abort the query if it is still in the state QUERY_WAITING --- Returns true if aborting was successful, false otherwise +-- Returns true if at least one running instance of the query was aborted successfully, false otherwise Query:lastInsert() -- Returns [Number] -- Gets the autoincrement index of the last inserted row of the current result set -Query:status() --- Returns [Number] (mysqloo.QUERY_* enums) --- Gets the status of the query. - Query:affectedRows() -- Returns [Number] -- Gets the number of rows the query has affected (of the current result set) @@ -192,11 +192,15 @@ Query:wait(shouldSwap) Query:error() -- Returns [String] --- Gets the error caused by the query (if any). +-- Gets the error caused by the query, or "" if there was no error. Query:hasMoreResults() -- Returns [Boolean] -- Returns true if the query still has more data associated with it (which means getNextResults() can be called) +-- Note: This function works unfortunately different that one would expect. +-- hasMoreResults() returns true if there is currently a result that can be popped, rather than if there is an +-- additional result that has data. However, this does make for a nicer code that handles multiple results. +-- See Examples/multi_results.lua for an example how to use it. Query:getNextResults() -- Returns [Table] @@ -252,7 +256,7 @@ PreparedQuery:clearParameters() PreparedQuery:putNewParameters() -- Returns nothing --- This shouldn't be used anymore, just start the same prepared multiple times with different parameters +-- Deprecated: Start the same prepared statement multiple times instead -- Transaction object @@ -283,14 +287,50 @@ Transaction.onSuccess() # Build instructions: -To build the project you first need to generate the appropriate solution for your system using [premake](https://premake.github.io/download.html). +This project uses [CMake](https://cmake.org/) as a build system. +## Windows + +### Visual Studio +Visual Studio has support for CMake since Visual Studio 2017. To open the project, run Visual Studio and under `File > Open > CMake...` +select the CMakeList.txt from this directory. + +The CMakeSettings.json in this project should already define both a 32 and 64 bit configuration. +You can add new configurations in the combo box that contains the x64 config. Here you can change the build type to Release or RelWithDebInfo and duplicate the config +for a 32 bit build. + +To build the project, you can then simply run `` from the toolbar. The output files are placed in the `out/build/{ConfigurationName}/` subfolder +of this project. + + +### CLion +Simply open the project in CLion and import the CMake project. Assuming you have a [valid toolchain](https://www.jetbrains.com/help/clion/how-to-create-toolchain-in-clion.html) setup, +you can simply build the project using `Build > Build Project` in the toolbar. + +To compile for 32 bit rather than 64 bit, you can select a 32 bit VS toolchain, rather than the 64 bit one. + +The output files are placed within the `cmake-build-debug/` directory of this project. + + +## Linux + + +### Prerequisites +To compile the project, you will need CMake and a functioning c++ compiler. For example, under Ubuntu, the following packages +can be used to compile the module. +```bash +sudo apt install build-essential gcc-multilib cmake ``` -premake5 --os=windows --file=BuildProjects.lua vs2017 -premake5 --os=macosx --file=BuildProjects.lua gmake -premake5 --os=linux --file=BuildProjects.lua gmake -``` -Then building MySQLOO should be as easy as either running make (linux) or pressing the build project button in Visual Studio (windows). -**Note**: To build MySQLOO in 64-bit, run `make config=release_x86_64` -**Note**: On Linux you might have to install some additional libraries required in the linking process, but I personally have not experienced any such issues. -**Note:** Mac is currently not supported since the MariaDB connector is not available on mac (at least not precompiled). + +### Compiling +To compile the module, follow the following steps: +- enter the project directory and run `cmake .` in bash. +- in the same directory run `make` in bash. +- The module should be compiled and the resulting binary should be placed directly in the project directory. + + + +## Mac +Mac is currently not supported since the MariaDB connector is not available on Mac (at least not precompiled). +However, if you are able to compile the connector yourself, building for Mac should broadly follow the same instructions +as for Linux. \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 1db8ea0..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,23 +0,0 @@ -image: Visual Studio 2017 - -shallow_clone: true - -configuration: - - Release - -platform: - - Win32 - - x64 - -install: - # Download Premake - - ps: Start-FileDownload 'https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-windows.zip' 'premake.zip' - - # Extract it in-place; premake5.exe is at the top level. - - 7z x premake.zip - - # Generate solution files using premake. - - premake5 --os=windows --file=BuildProjects.lua vs2017 - -build: - project: solutions/windows-vs2017/MySQLOO.sln diff --git a/minorversion.txt b/minorversion.txt index 62f9457..c793025 100644 --- a/minorversion.txt +++ b/minorversion.txt @@ -1 +1 @@ -6 \ No newline at end of file +7 \ No newline at end of file diff --git a/src/BlockingQueue.h b/src/BlockingQueue.h new file mode 100644 index 0000000..d3e13ac --- /dev/null +++ b/src/BlockingQueue.h @@ -0,0 +1,71 @@ +#ifndef BLOCKING_QUEUE_ +#define BLOCKING_QUEUE_ + +#include +#include +#include +#include + +template +class BlockingQueue { +public: + void put(T elem) { + std::lock_guard lock(mutex); + backingQueue.push_back(elem); + waitObj.notify_all(); + } + + bool empty() { + return size() == 0; + } + + bool swapToFrontIf(std::function func) { + std::lock_guard lock(mutex); + auto pos = std::find_if(backingQueue.begin(), backingQueue.end(), func); + if (pos != backingQueue.begin() && pos != backingQueue.end()) { + std::iter_swap(pos, backingQueue.begin()); + return true; + } + return false; + } + + bool removeIf(std::function func) { + std::lock_guard lock(mutex); + auto it = std::remove_if(backingQueue.begin(), backingQueue.end(), func); + bool removed = it != backingQueue.end(); + backingQueue.erase(it, backingQueue.end()); + return removed; + } + + void remove(T elem) { + std::lock_guard lock(mutex); + backingQueue.erase(std::remove(backingQueue.begin(), backingQueue.end(), elem), backingQueue.end()); + } + + size_t size() { + std::lock_guard lock(mutex); + return backingQueue.size(); + } + + T take() { + std::unique_lock lock(mutex); + while (size() == 0) waitObj.wait(lock); + auto front = backingQueue.front(); + backingQueue.pop_front(); + return front; + } + + std::deque clear() { + std::lock_guard lock(mutex); + std::deque returnQueue = backingQueue; + backingQueue.clear(); + return returnQueue; + } + +private: + std::deque backingQueue{}; + std::recursive_mutex mutex{}; + std::condition_variable_any waitObj{}; +}; + +#endif diff --git a/src/Main.cpp b/src/Main.cpp new file mode 100644 index 0000000..4778dcd --- /dev/null +++ b/src/Main.cpp @@ -0,0 +1,46 @@ +#include +#include +#include "mysql/Database.h" + +static std::shared_ptr db; + +int main() { + mysql_library_init(0, nullptr, nullptr); + std::cout << "Test" << std::endl; + db = Database::createDatabase("127.0.0.1", "root", "", "mysql", 3306, ""); + db->connect(); + db->wait(); + std::cout << "DB Connected" << std::endl; + std::cout << "Ping returned: " << db->ping() << std::endl; + + for (int i = 0; i < 100; i++) { + auto query = db->prepare("SELECT ?"); + query->setNumber(1, 2.0); + auto queryData = std::dynamic_pointer_cast(query->buildQueryData()); + query->start(queryData); + query->wait(true); + auto firstResultSet = queryData->getResult(); + auto &firstRow = firstResultSet.getRows().front(); + auto &firstValue = firstRow.getValues().front(); + std::cout << "Result: " << firstValue << std::endl; + } + + auto transaction = db->transaction(); + auto transactionQuery1 = db->prepare("SELECT ?"); + transactionQuery1->setNumber(1, 3.0); + auto transactionData1 = transactionQuery1->buildQueryData(); + auto transactionQuery2 = db->query("SELECT 12"); + auto transactionData2 = transactionQuery1->buildQueryData(); + std::deque, std::shared_ptr>> transactionQueries; + transactionQueries.emplace_back(transactionQuery1, transactionData1); + transactionQueries.emplace_back(transactionQuery2, transactionData2); + auto transactionData = transaction->buildQueryData(transactionQueries); + transaction->start(transactionData); + transaction->wait(true); + auto firstResultSet = transactionData2->getResult(); + auto &firstRow = firstResultSet.getRows().front(); + auto &firstValue = firstRow.getValues().front(); + std::cout << "Transaction Result: " << firstValue << std::endl; + + mysql_library_end(); +} \ No newline at end of file diff --git a/src/lua/GMModule.cpp b/src/lua/GMModule.cpp new file mode 100644 index 0000000..d1d4c4d --- /dev/null +++ b/src/lua/GMModule.cpp @@ -0,0 +1,228 @@ +#include "GarrysMod/Lua/Interface.h" +#include "../mysql/Database.h" +#include +#include +#include "LuaObject.h" +#include "LuaDatabase.h" +#include "LuaTransaction.h" +#include "LuaQuery.h" +#include "LuaPreparedQuery.h" + +#define MYSQLOO_VERSION "9" +#define MYSQLOO_MINOR_VERSION "7" + +// Variable to hold the reference to the version check ConVar object +static int versionCheckConVar = 0; + +GMOD_MODULE_CLOSE() { + // Free the version check ConVar object reference + if (versionCheckConVar != 0) { + LUA->ReferenceFree(versionCheckConVar); + } + + delete LuaDatabase::luaDatabases; + LuaDatabase::luaDatabases = nullptr; + mysql_thread_end(); + mysql_library_end(); + + return 0; +} + +/* Returns the amount of currently allocated objects. + */ +LUA_FUNCTION(objectCount) { + LUA->PushNumber((double) (LuaObject::allocationCount - LuaObject::deallocationCount)); + return 1; +} + +static void runInTimer(GarrysMod::Lua::ILuaBase *LUA, double delay, GarrysMod::Lua::CFunc func) { + LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); + LUA->GetField(-1, "timer"); + //In case someone removes the timer library + if (LUA->IsType(-1, GarrysMod::Lua::Type::Nil)) { + LUA->Pop(2); + return; + } + LUA->GetField(-1, "Simple"); + LUA->PushNumber(delay); + LUA->PushCFunction(func); + LUA->Call(2, 0); + LUA->Pop(2); +} + +static void printMessage(GarrysMod::Lua::ILuaBase *LUA, const char *str, int r, int g, int b) { + LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); + LUA->GetField(-1, "Color"); + LUA->PushNumber(r); + LUA->PushNumber(g); + LUA->PushNumber(b); + LUA->Call(3, 1); + int ref = LUA->ReferenceCreate(); + LUA->GetField(-1, "MsgC"); + LUA->ReferencePush(ref); + LUA->PushString(str); + LUA->Call(2, 0); + LUA->Pop(); + LUA->ReferenceFree(ref); +} + +static int printOutdatedVersion(lua_State *state) { + GarrysMod::Lua::ILuaBase *LUA = state->luabase; + LUA->SetState(state); + printMessage(LUA, "Your server is using an outdated mysqloo9 version\n", 255, 0, 0); + printMessage(LUA, "Download the latest version from here:\n", 255, 0, 0); + printMessage(LUA, "https://github.com/FredyH/MySQLOO/releases\n", 86, 156, 214); + runInTimer(LUA, 3600, printOutdatedVersion); + return 0; +} + +static int fetchSuccessful(lua_State *state) { + GarrysMod::Lua::ILuaBase *LUA = state->luabase; + LUA->SetState(state); + std::string version = LUA->GetString(1); + //version.size() < 3 so that the 404 response gets ignored + if (version != MYSQLOO_MINOR_VERSION && version.size() <= 3) { + printOutdatedVersion(state); + } else { + printMessage(LUA, "Your server is using the latest mysqloo9 version\n", 0, 255, 0); + } + return 0; +} + +static int fetchFailed(lua_State *state) { + GarrysMod::Lua::ILuaBase *LUA = state->luabase; + LUA->SetState(state); + printMessage(LUA, "Failed to retrieve latest version of mysqloo9\n", 255, 0, 0); + return 0; +} + +static int doVersionCheck(lua_State *state) { + GarrysMod::Lua::ILuaBase *LUA = state->luabase; + LUA->SetState(state); + + // Check if the reference to the ConVar object is set + if (versionCheckConVar != 0) { + // Retrieve the value of the ConVar + LUA->ReferencePush(versionCheckConVar); // Push the ConVar object + LUA->GetField(-1, "GetInt"); // Push the name of the function + LUA->ReferencePush(versionCheckConVar); // Push the ConVar object as the first self argument + LUA->Call(1, 1); // Call with 1 argument and 1 return + int versionCheckEnabled = (int) LUA->GetNumber(-1); // Retrieve the returned value + + // Check if the version check convar is set to 1 + if (versionCheckEnabled == 1) { + // Execute the HTTP request + LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); + LUA->GetField(-1, "http"); + LUA->GetField(-1, "Fetch"); + LUA->PushString("https://raw.githubusercontent.com/FredyH/MySQLOO/master/minorversion.txt"); + LUA->PushCFunction(fetchSuccessful); + LUA->PushCFunction(fetchFailed); + LUA->PCall(3, 0, 0); + LUA->Pop(2); + } + } + + return 0; +} + +LUA_FUNCTION(allocationCount) { + LUA->PushNumber(LuaObject::allocationCount); + return 1; +} + +LUA_FUNCTION(deallocationCount) { + LUA->PushNumber(LuaObject::deallocationCount); + return 1; +} + +GMOD_MODULE_OPEN() { + if (mysql_library_init(0, nullptr, nullptr)) { + LUA->ThrowError("Could not initialize mysql library."); + } + LuaDatabase::luaDatabases = new std::unordered_set(); + + //Creating MetaTables + LuaObject::createUserDataMetaTable(LUA); + LuaDatabase::createMetaTable(LUA); + LuaQuery::createMetaTable(LUA); + LuaPreparedQuery::createMetaTable(LUA); + LuaTransaction::createMetaTable(LUA); + + LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); + LUA->GetField(-1, "hook"); + LUA->GetField(-1, "Add"); + LUA->PushString("Think"); + LUA->PushString("__MySQLOOThinkHook"); + LUA->PushCFunction(LuaObject::luaObjectThink); + LUA->Call(3, 0); + LUA->Pop(); + LUA->Pop(); + LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); + LUA->CreateTable(); + + LUA->PushString(MYSQLOO_VERSION); + LUA->SetField(-2, "VERSION"); + LUA->PushString(MYSQLOO_MINOR_VERSION); + LUA->SetField(-2, "MINOR_VERSION"); + + LUA->PushNumber(DATABASE_CONNECTED); + LUA->SetField(-2, "DATABASE_CONNECTED"); + LUA->PushNumber(DATABASE_CONNECTING); + LUA->SetField(-2, "DATABASE_CONNECTING"); + LUA->PushNumber(DATABASE_NOT_CONNECTED); + LUA->SetField(-2, "DATABASE_NOT_CONNECTED"); + LUA->PushNumber(DATABASE_CONNECTION_FAILED); + LUA->SetField(-2, "DATABASE_CONNECTION_FAILED"); + + LUA->PushNumber(QUERY_NOT_RUNNING); + LUA->SetField(-2, "QUERY_NOT_RUNNING"); + LUA->PushNumber(QUERY_RUNNING); + LUA->SetField(-2, "QUERY_RUNNING"); + LUA->PushNumber(QUERY_COMPLETE); + LUA->SetField(-2, "QUERY_COMPLETE"); + LUA->PushNumber(QUERY_ABORTED); + LUA->SetField(-2, "QUERY_ABORTED"); + LUA->PushNumber(QUERY_WAITING); + LUA->SetField(-2, "QUERY_WAITING"); + + LUA->PushNumber(OPTION_NUMERIC_FIELDS); + LUA->SetField(-2, "OPTION_NUMERIC_FIELDS"); + LUA->PushNumber(OPTION_INTERPRET_DATA); + LUA->SetField(-2, "OPTION_INTERPRET_DATA"); //Not used anymore + LUA->PushNumber(OPTION_NAMED_FIELDS); + LUA->SetField(-2, "OPTION_NAMED_FIELDS"); //Not used anymore + LUA->PushNumber(OPTION_CACHE); + LUA->SetField(-2, "OPTION_CACHE"); //Not used anymore + + LUA->PushCFunction(LuaDatabase::create); + LUA->SetField(-2, "connect"); + + //Debug/testing functions + LUA->PushCFunction(objectCount); + LUA->SetField(-2, "objectCount"); + LUA->PushCFunction(allocationCount); + LUA->SetField(-2, "allocationCount"); + LUA->PushCFunction(deallocationCount); + LUA->SetField(-2, "deallocationCount"); + + LUA->SetField(-2, "mysqloo"); + LUA->Pop(); + + LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); // Push the global table + // Create the version check ConVar + LUA->GetField(-1, "CreateConVar"); + LUA->PushString("sv_mysqloo_versioncheck"); // Name + LUA->PushString("1"); // Default value + LUA->PushNumber(128); // FCVAR flags + LUA->PushString("Enable or disable the MySQLOO update checker."); // Help text + LUA->PushNumber(0); // Min value + LUA->PushNumber(1); // Max value + LUA->Call(6, 1); // Call with 6 arguments and 1 result + versionCheckConVar = LUA->ReferenceCreate(); // Store the created ConVar object as a global variable + LUA->Pop(); // Pop the global table + + runInTimer(LUA, 5, doVersionCheck); + + return 1; +} diff --git a/src/lua/LuaDatabase.cpp b/src/lua/LuaDatabase.cpp new file mode 100644 index 0000000..bd0c1aa --- /dev/null +++ b/src/lua/LuaDatabase.cpp @@ -0,0 +1,332 @@ + +#include "LuaDatabase.h" +#include "LuaQuery.h" +#include "LuaPreparedQuery.h" +#include "LuaTransaction.h" + +std::unordered_set* LuaDatabase::luaDatabases = nullptr; + +static void pushLuaObjectTable(ILuaBase *LUA, void *data, int type) { + LUA->CreateTable(); + LUA->PushUserType(data, LuaObject::TYPE_USERDATA); + LUA->SetField(-2, "__CppObject"); + LUA->PushMetaTable(type); + LUA->SetMetaTable(-2); +} + +LUA_CLASS_FUNCTION(LuaDatabase, create) { + LUA->CheckType(1, GarrysMod::Lua::Type::String); + LUA->CheckType(2, GarrysMod::Lua::Type::String); + LUA->CheckType(3, GarrysMod::Lua::Type::String); + LUA->CheckType(4, GarrysMod::Lua::Type::String); + std::string host = LUA->GetString(1); + std::string username = LUA->GetString(2); + std::string pw = LUA->GetString(3); + std::string database = LUA->GetString(4); + unsigned int port = 3306; + std::string unixSocket; + if (LUA->IsType(5, GarrysMod::Lua::Type::Number)) { + port = (int) LUA->GetNumber(5); + } + if (LUA->IsType(6, GarrysMod::Lua::Type::String)) { + unixSocket = LUA->GetString(6); + } + auto createdDatabase = Database::createDatabase(host, username, pw, database, port, unixSocket); + auto luaDatabase = new LuaDatabase(createdDatabase); + + pushLuaObjectTable(LUA, luaDatabase, LuaObject::TYPE_DATABASE); + return 1; +} + +MYSQLOO_LUA_FUNCTION(query) { + auto database = LuaObject::getLuaObject(LUA); + LUA->CheckType(2, GarrysMod::Lua::Type::String); + + unsigned int outLen = 0; + const char *queryStr = LUA->GetString(2, &outLen); + auto query = Query::create(database->m_database, std::string(queryStr, outLen)); + + LUA->Push(1); + int databaseRef = LUA->ReferenceCreate(); + + auto luaQuery = new LuaQuery(query, databaseRef); + + pushLuaObjectTable(LUA, luaQuery, LuaObject::TYPE_QUERY); + return 1; +} + +MYSQLOO_LUA_FUNCTION(prepare) { + auto database = LuaObject::getLuaObject(LUA); + LUA->CheckType(2, GarrysMod::Lua::Type::String); + unsigned int outLen = 0; + const char *queryStr = LUA->GetString(2, &outLen); + auto query = PreparedQuery::create(database->m_database, std::string(queryStr, outLen)); + + LUA->Push(1); + int databaseRef = LUA->ReferenceCreate(); + + auto luaQuery = new LuaPreparedQuery(query, databaseRef); + + pushLuaObjectTable(LUA, luaQuery, LuaObject::TYPE_PREPARED_QUERY); + return 1; +} + +MYSQLOO_LUA_FUNCTION(createTransaction) { + auto database = LuaObject::getLuaObject(LUA); + auto transaction = Transaction::create(database->m_database); + + LUA->Push(1); + int databaseRef = LUA->ReferenceCreate(); + + auto luaTransaction = new LuaTransaction(transaction, databaseRef); + + pushLuaObjectTable(LUA, luaTransaction, LuaObject::TYPE_TRANSACTION); + return 1; +} + +MYSQLOO_LUA_FUNCTION(connect) { + auto database = LuaObject::getLuaObject(LUA); + if (database->m_tableReference == 0) { + LUA->Push(1); + database->m_tableReference = LUA->ReferenceCreate(); + } + database->m_database->connect(); + return 0; +} + +MYSQLOO_LUA_FUNCTION(escape) { + auto database = LuaObject::getLuaObject(LUA); + unsigned int nQueryLength; + const char *sQuery = LUA->GetString(2, &nQueryLength); + auto escaped = database->m_database->escape(std::string(sQuery, nQueryLength)); + LUA->PushString(escaped.c_str(), (unsigned int) escaped.size()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(setCharacterSet) { + auto database = LuaObject::getLuaObject(LUA); + LUA->CheckType(2, GarrysMod::Lua::Type::String); + const char *charset = LUA->GetString(2); + bool success = database->m_database->setCharacterSet(charset); + LUA->PushBool(success); + LUA->PushString(""); + return 2; +} + +MYSQLOO_LUA_FUNCTION(setSSLSettings) { + auto database = LuaObject::getLuaObject(LUA); + SSLSettings sslSettings; + if (LUA->IsType(2, GarrysMod::Lua::Type::String)) { + sslSettings.key = LUA->GetString(2); + } + if (LUA->IsType(3, GarrysMod::Lua::Type::String)) { + sslSettings.cert = LUA->GetString(3); + } + if (LUA->IsType(4, GarrysMod::Lua::Type::String)) { + sslSettings.ca = LUA->GetString(4); + } + if (LUA->IsType(5, GarrysMod::Lua::Type::String)) { + sslSettings.capath = LUA->GetString(5); + } + if (LUA->IsType(6, GarrysMod::Lua::Type::String)) { + sslSettings.cipher = LUA->GetString(6); + } + database->m_database->setSSLSettings(sslSettings); + return 0; +} + +MYSQLOO_LUA_FUNCTION(disconnect) { + auto database = LuaObject::getLuaObject(LUA); + bool wait = false; + if (LUA->IsType(2, GarrysMod::Lua::Type::Bool)) { + wait = LUA->GetBool(2); + } + database->m_database->disconnect(wait); + if (wait) { + database->think(LUA); //To set callback data, run callbacks + } + return 0; +} + +MYSQLOO_LUA_FUNCTION(status) { + auto database = LuaObject::getLuaObject(LUA); + LUA->PushNumber(database->m_database->status()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(serverVersion) { + auto database = LuaObject::getLuaObject(LUA); + LUA->PushNumber(database->m_database->serverVersion()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(serverInfo) { + auto database = LuaObject::getLuaObject(LUA); + LUA->PushString(database->m_database->serverInfo().c_str()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(hostInfo) { + auto database = LuaObject::getLuaObject(LUA); + LUA->PushString(database->m_database->hostInfo().c_str()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(setAutoReconnect) { + auto database = LuaObject::getLuaObject(LUA); + LUA->CheckType(2, GarrysMod::Lua::Type::Bool); + database->m_database->setShouldAutoReconnect(LUA->GetBool(2)); + return 0; +} + +MYSQLOO_LUA_FUNCTION(setMultiStatements) { + auto database = LuaObject::getLuaObject(LUA); + LUA->CheckType(2, GarrysMod::Lua::Type::Bool); + database->m_database->setMultiStatements(LUA->GetBool(2)); + return 0; +} + +MYSQLOO_LUA_FUNCTION(setCachePreparedStatements) { + auto database = LuaObject::getLuaObject(LUA); + LUA->CheckType(2, GarrysMod::Lua::Type::Bool); + database->m_database->setCachePreparedStatements(LUA->GetBool(2)); + return 0; +} + +MYSQLOO_LUA_FUNCTION(abortAllQueries) { + auto database = LuaObject::getLuaObject(LUA); + auto abortedQueries = database->m_database->abortAllQueries(); + for (const auto& pair: abortedQueries) { + LuaIQuery::runAbortedCallback(LUA, pair.second); + LuaIQuery::finishQueryData(LUA, pair.first, pair.second); + } + LUA->PushNumber((double) abortedQueries.size()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(queueSize) { + auto database = LuaObject::getLuaObject(LUA); + LUA->PushNumber((double) database->m_database->queueSize()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(ping) { + auto database = LuaObject::getLuaObject(LUA); + LUA->PushBool(database->m_database->ping()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(wait) { + auto database = LuaObject::getLuaObject(LUA); + database->m_database->wait(); + database->think(LUA); //To set callback data, run callbacks + return 0; +} + +void LuaDatabase::createMetaTable(ILuaBase *LUA) { + LuaObject::TYPE_DATABASE = LUA->CreateMetaTable("MySQLOO Database"); + LuaObject::addMetaTableFunctions(LUA); + + LUA->PushCFunction(connect); + LUA->SetField(-2, "connect"); + + LUA->PushCFunction(escape); + LUA->SetField(-2, "escape"); + + LUA->PushCFunction(setCharacterSet); + LUA->SetField(-2, "setCharacterSet"); + + LUA->PushCFunction(setSSLSettings); + LUA->SetField(-2, "setSSLSettings"); + + LUA->PushCFunction(disconnect); + LUA->SetField(-2, "disconnect"); + + LUA->PushCFunction(status); + LUA->SetField(-2, "status"); + + LUA->PushCFunction(serverVersion); + LUA->SetField(-2, "serverVersion"); + + LUA->PushCFunction(serverInfo); + LUA->SetField(-2, "serverInfo"); + + LUA->PushCFunction(hostInfo); + LUA->SetField(-2, "hostInfo"); + + LUA->PushCFunction(setAutoReconnect); + LUA->SetField(-2, "setSQLAutoReconnect"); + + LUA->PushCFunction(setMultiStatements); + LUA->SetField(-2, "setMultiStatements"); + + LUA->PushCFunction(setCachePreparedStatements); + LUA->SetField(-2, "setCachePreparedStatements"); + + LUA->PushCFunction(abortAllQueries); + LUA->SetField(-2, "abortAllQueries"); + + LUA->PushCFunction(queueSize); + LUA->SetField(-2, "queueSize"); + + LUA->PushCFunction(ping); + LUA->SetField(-2, "ping"); + + LUA->PushCFunction(wait); + LUA->SetField(-2, "wait"); + + LUA->PushCFunction(query); + LUA->SetField(-2, "query"); + + LUA->PushCFunction(prepare); + LUA->SetField(-2, "prepare"); + + LUA->PushCFunction(createTransaction); + LUA->SetField(-2, "createTransaction"); + + LUA->Pop(); +} + +void LuaDatabase::think(ILuaBase *LUA) { + //Connection callbacks + auto database = this->m_database; + if (database->isConnectionDone() && !this->m_dbCallbackRan && this->m_tableReference != 0) { + this->m_dbCallbackRan = true; + LUA->ReferencePush(this->m_tableReference); + if (database->connectionSuccessful()) { + LUA->GetField(-1, "onConnected"); + if (LUA->GetType(-1) == GarrysMod::Lua::Type::Function) { + LUA->ReferencePush(this->m_tableReference); + pcallWithErrorReporter(LUA, 1); + } + LUA->Pop(); //Callback function + } else { + LUA->GetField(-1, "onConnectionFailed"); + if (LUA->GetType(-1) == GarrysMod::Lua::Type::Function) { + LUA->ReferencePush(this->m_tableReference); + auto error = database->connectionError(); + LUA->PushString(error.c_str()); + pcallWithErrorReporter(LUA, 2); + } + LUA->Pop(); //Callback function + } + + LUA->ReferenceFree(this->m_tableReference); + this->m_tableReference = 0; + } + + //Run callbacks of finished queries + auto finishedQueries = database->takeFinishedQueries(); + for (auto &pair: finishedQueries) { + LuaQuery::runCallback(LUA, pair.first, pair.second); + } +} + +void LuaDatabase::onDestroyedByLua(ILuaBase *LUA) { + m_database->disconnect(true); //Wait for any outstanding queries to finish. + //If this is called, LUA is either reloading or no queries exist in the query queue of the database, clear it + //This needs to be cleared to avoid the queries leaking + m_database->takeFinishedQueries(); + m_database->abortAllQueries(); + +} \ No newline at end of file diff --git a/src/lua/LuaDatabase.h b/src/lua/LuaDatabase.h new file mode 100644 index 0000000..8b693d5 --- /dev/null +++ b/src/lua/LuaDatabase.h @@ -0,0 +1,38 @@ + +#ifndef MYSQLOO_LUADATABASE_H +#define MYSQLOO_LUADATABASE_H + + +#include "../mysql/Database.h" + +#include +#include "LuaObject.h" + +class LuaDatabase : public LuaObject { +public: + static void createMetaTable(ILuaBase *LUA); + + static int create(lua_State *L); + + void think(ILuaBase *LUA); + + int m_tableReference = 0; + std::shared_ptr m_database; + bool m_dbCallbackRan = false; + + void onDestroyedByLua(ILuaBase *LUA) override; + + ~LuaDatabase() override { + luaDatabases->erase(this); + } + + explicit LuaDatabase(std::shared_ptr database) : LuaObject("Database"), + m_database(std::move(database)) { + luaDatabases->insert(this); + } + + static std::unordered_set* luaDatabases; +}; + + +#endif //MYSQLOO_LUADATABASE_H diff --git a/src/lua/LuaIQuery.cpp b/src/lua/LuaIQuery.cpp new file mode 100644 index 0000000..a1929f1 --- /dev/null +++ b/src/lua/LuaIQuery.cpp @@ -0,0 +1,182 @@ + +#include "LuaIQuery.h" +#include "LuaQuery.h" +#include "LuaTransaction.h" +#include "LuaDatabase.h" + + +MYSQLOO_LUA_FUNCTION(start) { + auto query = LuaIQuery::getLuaObject(LUA); + auto queryData = query->buildQueryData(LUA, 1, true); + query->m_query->start(queryData); + return 0; +} + +MYSQLOO_LUA_FUNCTION(error) { + auto query = LuaIQuery::getLuaObject(LUA); + LUA->PushString(query->m_query->error().c_str()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(wait) { + bool shouldSwap = false; + if (LUA->IsType(2, GarrysMod::Lua::Type::Bool)) { + shouldSwap = LUA->GetBool(2); + } + auto query = LuaIQuery::getLuaObject(LUA); + query->m_query->wait(shouldSwap); + if (query->m_databaseReference != 0) { + LUA->ReferencePush(query->m_databaseReference); + auto database = LuaObject::getLuaObject(LUA, -1); + database->think(LUA); + LUA->Pop(); + } + + return 0; +} + +MYSQLOO_LUA_FUNCTION(setOption) { + auto query = LuaIQuery::getLuaObject(LUA); + LUA->CheckType(2, GarrysMod::Lua::Type::Number); + bool set = true; + int option = (int) LUA->GetNumber(2); + + if (LUA->Top() >= 3) { + LUA->CheckType(3, GarrysMod::Lua::Type::Bool); + set = LUA->GetBool(3); + } + query->m_query->setOption(option, set); + return 0; +} + +MYSQLOO_LUA_FUNCTION(isRunning) { + auto query = LuaIQuery::getLuaObject(LUA); + LUA->PushBool(query->m_query->isRunning()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(abort) { + auto query = LuaIQuery::getLuaObject(LUA); + auto abortedData = query->m_query->abort(); + for (auto &data: abortedData) { + LuaIQuery::runAbortedCallback(LUA, data); + LuaIQuery::finishQueryData(LUA, query->m_query, data); + } + LUA->PushBool(!abortedData.empty()); + return 1; +} + +void LuaIQuery::runAbortedCallback(ILuaBase *LUA, const std::shared_ptr &data) { + if (data->m_tableReference == 0) return; + + if (!LuaIQuery::pushCallbackReference(LUA, data->m_abortReference, data->m_tableReference, + "onAborted", data->isFirstData())) { + return; + } + LUA->ReferencePush(data->m_tableReference); + LuaObject::pcallWithErrorReporter(LUA, 1); +} + +void LuaIQuery::runErrorCallback(ILuaBase *LUA, const std::shared_ptr &data) { + if (data->m_tableReference == 0) return; + + if (!LuaIQuery::pushCallbackReference(LUA, data->m_errorReference, data->m_tableReference, + "onError", data->isFirstData())) { + return; + } + LUA->ReferencePush(data->m_tableReference); + auto error = data->getError(); + LUA->PushString(error.c_str()); + LuaObject::pcallWithErrorReporter(LUA, 2); +} + +void LuaIQuery::addMetaTableFunctions(ILuaBase *LUA) { + LuaObject::addMetaTableFunctions(LUA); + + LUA->PushCFunction(start); + LUA->SetField(-2, "start"); + LUA->PushCFunction(error); + LUA->SetField(-2, "error"); + LUA->PushCFunction(wait); + LUA->SetField(-2, "wait"); + LUA->PushCFunction(setOption); + LUA->SetField(-2, "setOption"); + LUA->PushCFunction(isRunning); + LUA->SetField(-2, "isRunning"); + LUA->PushCFunction(abort); + LUA->SetField(-2, "abort"); +} + +void LuaIQuery::referenceCallbacks(ILuaBase *LUA, int stackPosition, IQueryData &data) { + LUA->Push(stackPosition); + data.m_tableReference = LUA->ReferenceCreate(); + + if (data.m_successReference == 0) { + data.m_successReference = getFunctionReference(LUA, stackPosition, "onSuccess"); + } + + if (data.m_abortReference == 0) { + data.m_abortReference = getFunctionReference(LUA, stackPosition, "onAborted"); + } + + if (data.m_onDataReference == 0) { + data.m_onDataReference = getFunctionReference(LUA, stackPosition, "onData"); + } + + if (data.m_errorReference == 0) { + data.m_errorReference = getFunctionReference(LUA, stackPosition, "onError"); + } +} + +void LuaIQuery::finishQueryData(GarrysMod::Lua::ILuaBase *LUA, const std::shared_ptr &query, const std::shared_ptr &data) { + query->finishQueryData(data); + if (data->m_tableReference) { + LUA->ReferenceFree(data->m_tableReference); + } + if (data->m_onDataReference) { + LUA->ReferenceFree(data->m_onDataReference); + } + if (data->m_errorReference) { + LUA->ReferenceFree(data->m_errorReference); + } + if (data->m_abortReference) { + LUA->ReferenceFree(data->m_abortReference); + } + if (data->m_successReference) { + LUA->ReferenceFree(data->m_successReference); + } + data->m_onDataReference = 0; + data->m_errorReference = 0; + data->m_abortReference = 0; + data->m_successReference = 0; + data->m_tableReference = 0; +} + +void LuaIQuery::runCallback(ILuaBase *LUA, const std::shared_ptr &iQuery, const std::shared_ptr &data) { + iQuery->setCallbackData(data); + + auto status = data->getResultStatus(); + switch (status) { + case QUERY_NONE: + break; //Should not happen + case QUERY_ERROR: + runErrorCallback(LUA, data); + break; + case QUERY_SUCCESS: + if (auto query = std::dynamic_pointer_cast(iQuery)) { + LuaQuery::runSuccessCallback(LUA, query, std::dynamic_pointer_cast(data)); + } else if (auto transaction = std::dynamic_pointer_cast(iQuery)) { + LuaTransaction::runSuccessCallback(LUA, transaction, std::dynamic_pointer_cast(data)); + } + break; + } + + LuaIQuery::finishQueryData(LUA, iQuery, data); +} + +void LuaIQuery::onDestroyedByLua(ILuaBase *LUA) { + if (m_databaseReference != 0) { + LUA->ReferenceFree(m_databaseReference); + m_databaseReference = 0; + } +} diff --git a/src/lua/LuaIQuery.h b/src/lua/LuaIQuery.h new file mode 100644 index 0000000..42c5917 --- /dev/null +++ b/src/lua/LuaIQuery.h @@ -0,0 +1,41 @@ + +#ifndef MYSQLOO_LUAIQUERY_H +#define MYSQLOO_LUAIQUERY_H + +#include "LuaObject.h" +#include "../mysql/IQuery.h" +#include "../mysql/Query.h" + +#include + +class LuaIQuery : public LuaObject { +public: + static void addMetaTableFunctions(ILuaBase *lua); + + std::shared_ptr m_query; + //Used to ensure that the database stays alive while the query exists. + //This needs to be the case because we can do qu:start() on the query even if the database + //has already gone out of scope in lua. Also, the callbacks need to be run using the Database's think hook + //even after the database is out of scope in lua code. + int m_databaseReference = 0; + + //The table is at the top + virtual std::shared_ptr buildQueryData(ILuaBase *LUA, int stackPosition, bool shouldRef) = 0; + + static void referenceCallbacks(ILuaBase *LUA, int stackPosition, IQueryData &data); + + static void runAbortedCallback(ILuaBase *LUA, const std::shared_ptr &data); + + static void runErrorCallback(ILuaBase *LUA, const std::shared_ptr &data); + + static void runCallback(ILuaBase *LUA, const std::shared_ptr &query, const std::shared_ptr &data); + + static void finishQueryData(ILuaBase *LUA, const std::shared_ptr &query, const std::shared_ptr &data); + + void onDestroyedByLua(ILuaBase *LUA) override; + + explicit LuaIQuery(std::shared_ptr query, std::string className, int databaseRef) : LuaObject( + std::move(className)), m_query(std::move(query)), m_databaseReference(databaseRef) {} +}; + +#endif //MYSQLOO_LUAIQUERY_H diff --git a/src/lua/LuaObject.cpp b/src/lua/LuaObject.cpp new file mode 100644 index 0000000..a674e90 --- /dev/null +++ b/src/lua/LuaObject.cpp @@ -0,0 +1,133 @@ +#include +#include "LuaObject.h" +#include "LuaDatabase.h" +#include + +int LuaObject::TYPE_USERDATA = 0; +int LuaObject::TYPE_DATABASE = 0; +int LuaObject::TYPE_QUERY = 0; +int LuaObject::TYPE_TRANSACTION = 0; +int LuaObject::TYPE_PREPARED_QUERY = 0; + +std::atomic_long LuaObject::allocationCount= { 0 }; +std::atomic_long LuaObject::deallocationCount = { 0 }; + +LUA_FUNCTION(luaObjectGc) { + auto luaObject = LUA->GetUserType(1, LuaObject::TYPE_USERDATA); + luaObject->onDestroyedByLua(LUA); + + delete luaObject; + + //After this function this object will be deleted. + //For the Database this might cause the database thread to join + //But the database can only be destroyed if no queries for it exist, i.e. joining + //should always work instantly, unless the server is changing maps, in which case we want it to wait. + return 0; +} + +LUA_CLASS_FUNCTION(LuaObject, luaObjectThink) { + std::unordered_set databasesCopy = *LuaDatabase::luaDatabases; + for (auto &database: databasesCopy) { + if (LuaDatabase::luaDatabases->find(database) == LuaDatabase::luaDatabases->end()) { + //This means the database instance was collected during the think hook and is thus invalid. + continue; + } + database->think(LUA); + } + return 0; +} + +void LuaObject::createUserDataMetaTable(GarrysMod::Lua::ILuaBase *LUA) { + TYPE_USERDATA = LUA->CreateMetaTable("MySQLOO UserData"); + LUA->PushCFunction(luaObjectGc); + LUA->SetField(-2, "__gc"); + LUA->Pop(); +} + +std::string LuaObject::toString() { + std::stringstream ss; + ss << m_className << " " << this; + return ss.str(); +} + +LUA_FUNCTION(luaObjectToString) { + LUA->GetUserType(1, LuaObject::TYPE_USERDATA); + auto luaObject = LuaObject::getLuaObject(LUA); + auto str = luaObject->toString(); + LUA->PushString(str.c_str()); + return 1; +} + +void LuaObject::addMetaTableFunctions(GarrysMod::Lua::ILuaBase *LUA) { + LUA->Push(-1); + LUA->SetField(-2, "__index"); + + LUA->PushCFunction(luaObjectToString); + LUA->SetField(-2, "__tostring"); +} + +LUA_FUNCTION(errorReporter) { + LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); + LUA->GetField(-1, "debug"); + LUA->GetField(-1, "traceback"); + + if (LUA->IsType(-1, GarrysMod::Lua::Type::Function)) { + LUA->Push(1); + LUA->Call(1, 1); //The resulting stack trace will be returned + } else { + LUA->PushString("MySQLOO Error"); + } + return 1; +} + +void LuaObject::pcallWithErrorReporter(ILuaBase *LUA, int nargs) { + LUA->PushCFunction(errorReporter); + int errorHandlerIndex = LUA->Top() - nargs - 1; + LUA->Insert(errorHandlerIndex); + int pcallResult = LUA->PCall(nargs, 0, errorHandlerIndex); + if (pcallResult == 2) { //LUA_ERRRUN, we now have a stack trace on the stack + LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); + LUA->GetField(-1, "ErrorNoHalt"); + if (LUA->IsType(-1, GarrysMod::Lua::Type::Function)) { + LUA->Push(-3); //Stack trace + LUA->Call(1, 0); + LUA->Pop(2); //Stack trace, global + } else { + LUA->Pop(3); //Stack trace, global, nil + } + } + LUA->Pop(); //Error reporter +} + +bool LuaObject::pushCallbackReference(ILuaBase *LUA, int functionReference, int tableReference, + const std::string &callbackName, bool allowCallback) { + //Push function reference + if (functionReference != 0) { + LUA->ReferencePush(functionReference); + return true; + } else if (allowCallback && tableReference != 0) { + LUA->ReferencePush(tableReference); + LUA->GetField(-1, callbackName.c_str()); + LUA->Remove(LUA->Top() - 2); + if (LUA->IsType(-1, GarrysMod::Lua::Type::Function)) { + return true; + } else { + LUA->Pop(1); //The field that is either nil or some other weird thing + return false; + } + } else { + return false; + } +} + + +int LuaObject::getFunctionReference(ILuaBase *LUA, int stackPosition, const char* fieldName) { + LUA->GetField(stackPosition, fieldName); + int reference = 0; + if (LUA->IsType(-1, GarrysMod::Lua::Type::Function)) { + reference = LUA->ReferenceCreate(); + } else { + LUA->Pop(); + } + return reference; +} diff --git a/src/lua/LuaObject.h b/src/lua/LuaObject.h new file mode 100644 index 0000000..5387646 --- /dev/null +++ b/src/lua/LuaObject.h @@ -0,0 +1,108 @@ + + +#ifndef MYSQLOO_LUAOBJECT_H +#define MYSQLOO_LUAOBJECT_H + +#include +#include +#include +#include +#include +#include "GarrysMod/Lua/Interface.h" +#include "../mysql/MySQLOOException.h" + +#include + +class LuaDatabase; + +using namespace GarrysMod::Lua; + +class LuaObject { +public: + explicit LuaObject(std::string className) : m_className(std::move(className)) { + allocationCount++; + } + + virtual ~LuaObject() { + deallocationCount++; + } + + std::string toString(); + + virtual void onDestroyedByLua(ILuaBase *LUA) {}; + + static int TYPE_USERDATA; + static int TYPE_DATABASE; + static int TYPE_QUERY; + static int TYPE_PREPARED_QUERY; + static int TYPE_TRANSACTION; + + static void addMetaTableFunctions(ILuaBase *LUA); + + static void createUserDataMetaTable(ILuaBase *lua); + + //Lua functions + static int luaObjectThink(lua_State *L); + + static void pcallWithErrorReporter(ILuaBase *LUA, int nargs); + + static bool pushCallbackReference(ILuaBase *LUA, int functionReference, int tableReference, + const std::string &callbackName, bool allowCallback); + + template + static T *getLuaObject(ILuaBase *LUA, int stackPos = 1) { + LUA->CheckType(stackPos, GarrysMod::Lua::Type::Table); + LUA->GetField(stackPos, "__CppObject"); + + auto *luaObject = LUA->GetUserType(-1, TYPE_USERDATA); + if (luaObject == nullptr) { + LUA->ThrowError("[MySQLOO] Expected MySQLOO table"); + } + T *returnValue = dynamic_cast(luaObject); + if (returnValue == nullptr) { + LUA->ThrowError("[MySQLOO] Invalid CPP Object"); + } + LUA->Pop(); + return returnValue; + } + + static int getFunctionReference(ILuaBase *LUA, int stackPosition, const char *fieldName); + static std::atomic_long allocationCount; + static std::atomic_long deallocationCount; +protected: + std::string m_className; +}; + + +#define MYSQLOO_LUA_FUNCTION(FUNC) \ + static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ); \ + static int FUNC( lua_State* L ) \ + { \ + GarrysMod::Lua::ILuaBase* LUA = L->luabase; \ + LUA->SetState(L); \ + try { \ + return FUNC##__Imp( LUA ); \ + } catch (const MySQLOOException& error) { \ + LUA->ThrowError(error.message.c_str()); \ + return 0; \ + } \ + } \ + static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ) + +#define LUA_CLASS_FUNCTION(CLASS, FUNC) \ + static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ); \ + int CLASS::FUNC( lua_State* L ) \ + { \ + GarrysMod::Lua::ILuaBase* LUA = L->luabase; \ + LUA->SetState(L); \ + try { \ + return FUNC##__Imp( LUA ); \ + } catch (const MySQLOOException& error) { \ + LUA->ThrowError(error.message.c_str()); \ + return 0; \ + } \ + } \ + static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ) + + +#endif //MYSQLOO_LUAOBJECT_H diff --git a/src/lua/LuaPreparedQuery.cpp b/src/lua/LuaPreparedQuery.cpp new file mode 100644 index 0000000..589cf1f --- /dev/null +++ b/src/lua/LuaPreparedQuery.cpp @@ -0,0 +1,92 @@ +#include "LuaPreparedQuery.h" + +MYSQLOO_LUA_FUNCTION(setNumber) { + auto luaQuery = LuaObject::getLuaObject(LUA); + auto query = (PreparedQuery *) luaQuery->m_query.get(); + LUA->CheckType(2, GarrysMod::Lua::Type::Number); + LUA->CheckType(3, GarrysMod::Lua::Type::Number); + double index = LUA->GetNumber(2); + auto uIndex = (unsigned int) index; + double value = LUA->GetNumber(3); + + query->setNumber(uIndex, value); + return 0; +} + +MYSQLOO_LUA_FUNCTION(setString) { + auto luaQuery = LuaObject::getLuaObject(LUA); + auto query = (PreparedQuery *) luaQuery->m_query.get(); + LUA->CheckType(2, GarrysMod::Lua::Type::Number); + LUA->CheckType(3, GarrysMod::Lua::Type::String); + double index = LUA->GetNumber(2); + unsigned int length = 0; + const char *string = LUA->GetString(3, &length); + auto uIndex = (unsigned int) index; + query->setString(uIndex, std::string(string, length)); + return 0; +} + +MYSQLOO_LUA_FUNCTION(setBoolean) { + auto luaQuery = LuaObject::getLuaObject(LUA); + auto query = (PreparedQuery *) luaQuery->m_query.get(); + LUA->CheckType(2, GarrysMod::Lua::Type::Number); + LUA->CheckType(3, GarrysMod::Lua::Type::Bool); + double index = LUA->GetNumber(2); + auto uIndex = (unsigned int) index; + bool value = LUA->GetBool(3); + query->setBoolean(uIndex, value); + return 0; +} + +MYSQLOO_LUA_FUNCTION(setNull) { + auto luaQuery = LuaObject::getLuaObject(LUA); + auto query = (PreparedQuery *) luaQuery->m_query.get(); + LUA->CheckType(2, GarrysMod::Lua::Type::Number); + double index = LUA->GetNumber(2); + auto uIndex = (unsigned int) index; + query->setNull(uIndex); + return 0; +} + +MYSQLOO_LUA_FUNCTION(putNewParameters) { + auto luaQuery = LuaObject::getLuaObject(LUA); + auto query = (PreparedQuery *) luaQuery->m_query.get(); + query->putNewParameters(); + return 0; +} + +MYSQLOO_LUA_FUNCTION(clearParameters) { + auto luaQuery = LuaObject::getLuaObject(LUA); + auto query = (PreparedQuery *) luaQuery->m_query.get(); + query->clearParameters(); + return 0; +} + +void LuaPreparedQuery::createMetaTable(ILuaBase *LUA) { + LuaIQuery::TYPE_PREPARED_QUERY = LUA->CreateMetaTable("MySQLOO Prepared Query"); + LuaQuery::addMetaTableFunctions(LUA); + + LUA->PushCFunction(setNumber); + LUA->SetField(-2, "setNumber"); + LUA->PushCFunction(setString); + LUA->SetField(-2, "setString"); + LUA->PushCFunction(setBoolean); + LUA->SetField(-2, "setBoolean"); + LUA->PushCFunction(setNull); + LUA->SetField(-2, "setNull"); + LUA->PushCFunction(putNewParameters); + LUA->SetField(-2, "putNewParameters"); + LUA->PushCFunction(clearParameters); + LUA->SetField(-2, "clearParameters"); + + LUA->Pop(); //Metatable +} + +std::shared_ptr LuaPreparedQuery::buildQueryData(ILuaBase* LUA, int stackPosition, bool shouldRef) { + auto query = (PreparedQuery*) m_query.get(); + auto data = query->buildQueryData(); + if (shouldRef) { + LuaIQuery::referenceCallbacks(LUA, stackPosition, *data); + } + return data; +} diff --git a/src/lua/LuaPreparedQuery.h b/src/lua/LuaPreparedQuery.h new file mode 100644 index 0000000..e4534af --- /dev/null +++ b/src/lua/LuaPreparedQuery.h @@ -0,0 +1,22 @@ + +#ifndef MYSQLOO_LUAPREPAREDQUERY_H +#define MYSQLOO_LUAPREPAREDQUERY_H + + +#include "LuaQuery.h" +#include "../mysql/PreparedQuery.h" + +class LuaPreparedQuery : public LuaQuery { +public: + std::shared_ptr buildQueryData(ILuaBase *LUA, int stackPosition, bool shouldRef) override; + + static void createMetaTable(ILuaBase *LUA); + + explicit LuaPreparedQuery(const std::shared_ptr &query, int databaseRef) : LuaQuery( + std::dynamic_pointer_cast(query), "MySQLOO Prepared Query", databaseRef) { + + } +}; + + +#endif //MYSQLOO_LUAPREPAREDQUERY_H diff --git a/src/lua/LuaQuery.cpp b/src/lua/LuaQuery.cpp new file mode 100644 index 0000000..4d3ae0c --- /dev/null +++ b/src/lua/LuaQuery.cpp @@ -0,0 +1,203 @@ + +#include "LuaQuery.h" + +//Function that converts the data stored in a mysql field into a lua type +//Expects the row table to be at the top of the stack at the start of this function +//Adds a column to the row table +static void dataToLua(Query &query, + GarrysMod::Lua::ILuaBase *LUA, unsigned int column, + std::string &columnValue, const char *columnName, int columnType, bool isNull) { + if (query.hasOption(OPTION_NUMERIC_FIELDS)) { + LUA->PushNumber(column); + } + if (isNull) { + LUA->PushNil(); + } else { + switch (columnType) { + case MYSQL_TYPE_FLOAT: + case MYSQL_TYPE_DOUBLE: + case MYSQL_TYPE_LONGLONG: + case MYSQL_TYPE_LONG: + case MYSQL_TYPE_INT24: + case MYSQL_TYPE_TINY: + case MYSQL_TYPE_SHORT: + LUA->PushNumber(atof(columnValue.c_str())); + break; + case MYSQL_TYPE_BIT: + LUA->PushNumber(static_cast(columnValue[0])); + break; + case MYSQL_TYPE_NULL: + LUA->PushNil(); + break; + default: + LUA->PushString(columnValue.c_str(), (unsigned int) columnValue.length()); + break; + } + } + if (query.hasOption(OPTION_NUMERIC_FIELDS)) { + LUA->SetTable(-3); + } else { + LUA->SetField(-2, columnName); + } +} + +//Stores the data associated with the current result set of the query +//Only called once per result set (and then cached) +int LuaQuery::createDataReference(GarrysMod::Lua::ILuaBase *LUA, Query &query, QueryData &data) { + if (query.m_dataReference != 0) + return query.m_dataReference; + LUA->CreateTable(); + int dataStackPosition = LUA->Top(); + if (query.hasCallbackData() && data.hasMoreResults()) { + ResultData ¤tData = data.getResult(); + for (unsigned int i = 0; i < currentData.getRows().size(); i++) { + ResultDataRow &row = currentData.getRows()[i]; + LUA->CreateTable(); + int rowStackPosition = LUA->Top(); + for (unsigned int j = 0; j < row.getValues().size(); j++) { + dataToLua(query, LUA, j + 1, row.getValues()[j], currentData.getColumns()[j].c_str(), + currentData.getColumnTypes()[j], row.isFieldNull(j)); + } + LUA->Push(dataStackPosition); + LUA->PushNumber(i + 1); + LUA->Push(rowStackPosition); + LUA->SetTable(-3); + LUA->Pop(2); //data + row + } + } + query.m_dataReference = LUA->ReferenceCreate(); + return query.m_dataReference; +} + +static void runOnDataCallbacks( + ILuaBase *LUA, + const std::shared_ptr &query, + const std::shared_ptr &data, + int dataReference +) { + if (!LuaIQuery::pushCallbackReference(LUA, data->m_onDataReference, data->m_tableReference, + "onData", data->isFirstData())) { + return; + } + int callbackPosition = LUA->Top(); + int index = 1; + LUA->ReferencePush(dataReference); + while (true) { + LUA->PushNumber(index++); + LUA->RawGet(-2); + if (LUA->GetType(-1) == GarrysMod::Lua::Type::Nil) { + LUA->Pop(); //Nil + break; + } + int rowPosition = LUA->Top(); + LUA->Push(callbackPosition); + LUA->ReferencePush(data->m_tableReference); + LUA->Push(rowPosition); + LuaObject::pcallWithErrorReporter(LUA, 2); + + LUA->Pop(); //Row + } + + LUA->Pop(2); //Callback, data +} + + +void LuaQuery::runSuccessCallback(ILuaBase *LUA, const std::shared_ptr& query, const std::shared_ptr &data) { + //Need to clear old data, if it exists + freeDataReference(LUA, *query); + int dataReference = LuaQuery::createDataReference(LUA, *query, *data); + runOnDataCallbacks(LUA, query, data, dataReference); + + if (!LuaIQuery::pushCallbackReference(LUA, data->m_successReference, data->m_tableReference, + "onSuccess", data->isFirstData())) { + return; + } + LUA->ReferencePush(data->m_tableReference); + LUA->ReferencePush(dataReference); + LuaObject::pcallWithErrorReporter(LUA, 2); + freeDataReference(LUA, *query); //Only cache data for duration of callback +} + +MYSQLOO_LUA_FUNCTION(affectedRows) { + auto luaQuery = LuaQuery::getLuaObject(LUA); + auto query = (Query *) luaQuery->m_query.get(); + LUA->PushNumber((double) query->affectedRows()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(lastInsert) { + auto luaQuery = LuaQuery::getLuaObject(LUA); + auto query = (Query *) luaQuery->m_query.get(); + LUA->PushNumber((double) query->lastInsert()); + return 1; +} + +MYSQLOO_LUA_FUNCTION(getData) { + auto luaQuery = LuaQuery::getLuaObject(LUA); + auto query = std::dynamic_pointer_cast(luaQuery->m_query); + if (!query->hasCallbackData() || query->callbackQueryData->getResultStatus() == QUERY_ERROR) { + LUA->PushNil(); + } else { + int ref = LuaQuery::createDataReference(LUA, *query, (QueryData &) *(query->callbackQueryData)); + LUA->ReferencePush(ref); + } + return 1; +} + +MYSQLOO_LUA_FUNCTION(hasMoreResults) { + auto luaQuery = LuaQuery::getLuaObject(LUA); + auto query = (Query *) luaQuery->m_query.get(); + LUA->PushBool(query->hasMoreResults()); + return 1; +} + +LUA_FUNCTION(getNextResults) { + auto luaQuery = LuaQuery::getLuaObject(LUA); + auto query = std::dynamic_pointer_cast(luaQuery->m_query); + LuaQuery::freeDataReference(LUA, *query); + query->getNextResults(); + return 0; +} + +void LuaQuery::addMetaTableFunctions(ILuaBase *LUA) { + LuaIQuery::addMetaTableFunctions(LUA); + + LUA->PushCFunction(affectedRows); + LUA->SetField(-2, "affectedRows"); + LUA->PushCFunction(lastInsert); + LUA->SetField(-2, "lastInsert"); + LUA->PushCFunction(getData); + LUA->SetField(-2, "getData"); + LUA->PushCFunction(hasMoreResults); + LUA->SetField(-2, "hasMoreResults"); + LUA->PushCFunction(getNextResults); + LUA->SetField(-2, "getNextResults"); +} + +void LuaQuery::createMetaTable(ILuaBase *LUA) { + LuaIQuery::TYPE_QUERY = LUA->CreateMetaTable("MySQLOO Query"); + LuaQuery::addMetaTableFunctions(LUA); + LUA->Pop(); //Metatable +} + +std::shared_ptr LuaQuery::buildQueryData(ILuaBase *LUA, int stackPosition, bool shouldRef) { + auto query = std::dynamic_pointer_cast(this->m_query); + auto data = query->buildQueryData(); + data->setStatus(QUERY_COMPLETE); + if (shouldRef) { + LuaIQuery::referenceCallbacks(LUA, stackPosition, *data); + } + return data; +} + +void LuaQuery::onDestroyedByLua(ILuaBase *LUA) { + LuaIQuery::onDestroyedByLua(LUA); + freeDataReference(LUA, *std::dynamic_pointer_cast(m_query)); +} + +void LuaQuery::freeDataReference(ILuaBase *LUA, Query &query) { + if (query.m_dataReference != 0) { + LUA->ReferenceFree(query.m_dataReference); + query.m_dataReference = 0; + } +} \ No newline at end of file diff --git a/src/lua/LuaQuery.h b/src/lua/LuaQuery.h new file mode 100644 index 0000000..58ac2de --- /dev/null +++ b/src/lua/LuaQuery.h @@ -0,0 +1,36 @@ + +#ifndef MYSQLOO_LUAQUERY_H +#define MYSQLOO_LUAQUERY_H + + +#include "LuaIQuery.h" + +class LuaQuery : public LuaIQuery { +public: + static int createDataReference(ILuaBase *LUA, Query &query, QueryData &data); + + static void freeDataReference(ILuaBase *LUA, Query &query); + + static void addMetaTableFunctions(ILuaBase *LUA); + + static void createMetaTable(ILuaBase *LUA); + + static void runSuccessCallback(ILuaBase *LUA, const std::shared_ptr& query, const std::shared_ptr &data); + + std::shared_ptr buildQueryData(ILuaBase *LUA, int stackPosition, bool shouldRef) override; + + void onDestroyedByLua(ILuaBase *LUA) override; + +protected: + explicit LuaQuery(const std::shared_ptr &query, const std::string &className, int databaseRef) : LuaIQuery( + std::dynamic_pointer_cast(query), className, databaseRef) { + } + +public: + explicit LuaQuery(const std::shared_ptr &query, int databaseRef) : LuaQuery(query, "MySQLOO Query", + databaseRef) { + + } +}; + +#endif //MYSQLOO_LUAQUERY_H diff --git a/src/lua/LuaTransaction.cpp b/src/lua/LuaTransaction.cpp new file mode 100644 index 0000000..5ef0d26 --- /dev/null +++ b/src/lua/LuaTransaction.cpp @@ -0,0 +1,129 @@ +#include "LuaTransaction.h" +#include "LuaQuery.h" + +MYSQLOO_LUA_FUNCTION(addQuery) { + auto luaTransaction = LuaObject::getLuaObject(LUA); + + auto addedLuaQuery = LuaQuery::getLuaObject(LUA, 2); + LUA->Push(1); + LUA->GetField(-1, "__queries"); + if (LUA->IsType(-1, GarrysMod::Lua::Type::Nil)) { + LUA->Pop(); + LUA->CreateTable(); + LUA->SetField(-2, "__queries"); + LUA->GetField(-1, "__queries"); + } + int tblIndex = LUA->Top(); + LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); + LUA->GetField(-1, "table"); + LUA->GetField(-1, "insert"); + LUA->Push(tblIndex); + LUA->Push(2); + LUA->Call(2, 0); + LUA->Pop(4); + + auto queryData = std::dynamic_pointer_cast(addedLuaQuery->buildQueryData(LUA, 2, false)); + + luaTransaction->m_addedQueryData.push_back(queryData); + return 0; +} + +MYSQLOO_LUA_FUNCTION(getQueries) { + LUA->GetField(1, "__queries"); + if (LUA->IsType(-1, GarrysMod::Lua::Type::Nil)) { + LUA->Pop(); + LUA->CreateTable(); + } + return 1; +} + +MYSQLOO_LUA_FUNCTION(clearQueries) { + auto luaTransaction = LuaObject::getLuaObject(LUA); + + LUA->Push(1); + LUA->CreateTable(); + LUA->SetField(-2, "__queries"); + LUA->Pop(); + + luaTransaction->m_addedQueryData.clear(); + + return 0; +} + +void LuaTransaction::createMetaTable(ILuaBase *LUA) { + LuaObject::TYPE_TRANSACTION = LUA->CreateMetaTable("MySQLOO Transaction"); + + LuaIQuery::addMetaTableFunctions(LUA); + LUA->PushCFunction(addQuery); + LUA->SetField(-2, "addQuery"); + LUA->PushCFunction(getQueries); + LUA->SetField(-2, "getQueries"); + LUA->PushCFunction(clearQueries); + LUA->SetField(-2, "clearQueries"); + LUA->Pop(); +} + +std::shared_ptr LuaTransaction::buildQueryData(ILuaBase *LUA, int stackPosition, bool shouldRef) { + LUA->GetField(stackPosition, "__queries"); + std::deque, std::shared_ptr>> queries; + if (LUA->GetType(-1) != GarrysMod::Lua::Type::Nil) { + for (size_t i = 0; i < this->m_addedQueryData.size(); i++) { + auto &queryData = this->m_addedQueryData[i]; + LUA->PushNumber((double) (i + 1)); + LUA->RawGet(-2); + if (!LUA->IsType(-1, GarrysMod::Lua::Type::Table)) { + LUA->Pop(); //Nil or whatever else is on the stack + break; + } + auto luaQuery = LuaQuery::getLuaObject(LUA, -1); + auto query = std::dynamic_pointer_cast(luaQuery->m_query); + query->addQueryData(queryData); + queries.emplace_back(query, queryData); + LUA->Pop(); //Query + } + } + LUA->Pop(); //Queries table + + auto data = Transaction::buildQueryData(queries); + if (shouldRef) { + LuaIQuery::referenceCallbacks(LUA, stackPosition, *data); + } + return data; +} + +void LuaTransaction::runSuccessCallback(ILuaBase *LUA, const std::shared_ptr &transaction, + const std::shared_ptr &data) { + auto transactionData = std::dynamic_pointer_cast(data); + if (transactionData->m_tableReference == 0) return; + transactionData->setStatus(QUERY_COMPLETE); + LUA->CreateTable(); + int index = 0; + for (auto &pair: transactionData->m_queries) { + LUA->PushNumber((double) (++index)); + auto query = pair.first; + //So we get the current data rather than caching it, if the same query is added multiple times. + LuaQuery::freeDataReference(LUA, *query); + auto queryData = std::dynamic_pointer_cast(pair.second); + query->setCallbackData(pair.second); + int ref = LuaQuery::createDataReference(LUA, *query, *queryData); + LUA->ReferencePush(ref); + LUA->SetTable(-3); + //The last data reference can stay cached in the query and will be freed once the query is gc'ed + } + if (!LuaIQuery::pushCallbackReference(LUA, data->m_successReference, data->m_tableReference, + "onSuccess", data->isFirstData())) { + LUA->Pop(); //Table of results + return; + } + LUA->ReferencePush(transactionData->m_tableReference); + LUA->Push(-3); //Table of results + LuaObject::pcallWithErrorReporter(LUA, 2); + + LUA->Pop(); //Table of results + + for (auto &pair: transactionData->m_queries) { + LuaIQuery::finishQueryData(LUA, pair.first, pair.second); + //We should only cache the data for the duration of the callback + LuaQuery::freeDataReference(LUA, *pair.first); + } +} diff --git a/src/lua/LuaTransaction.h b/src/lua/LuaTransaction.h new file mode 100644 index 0000000..56be789 --- /dev/null +++ b/src/lua/LuaTransaction.h @@ -0,0 +1,27 @@ + +#ifndef MYSQLOO_LUATRANSACTION_H +#define MYSQLOO_LUATRANSACTION_H + +#include "LuaIQuery.h" +#include "../mysql/Transaction.h" + +class LuaTransaction : public LuaIQuery { +public: + std::deque> m_addedQueryData = {}; + + std::shared_ptr buildQueryData(ILuaBase *LUA, int stackPosition, bool shouldRef) override; + + static void createMetaTable(ILuaBase *LUA); + + static void runSuccessCallback(ILuaBase *LUA, const std::shared_ptr &transaction, + const std::shared_ptr &data); + + explicit LuaTransaction(const std::shared_ptr &transaction, int databaseRef) : LuaIQuery( + std::static_pointer_cast(transaction), "MySQLOO Transaction", databaseRef + ) { + + } +}; + + +#endif //MYSQLOO_LUATRANSACTION_H diff --git a/src/mysql/Database.cpp b/src/mysql/Database.cpp new file mode 100644 index 0000000..3c10d6f --- /dev/null +++ b/src/mysql/Database.cpp @@ -0,0 +1,391 @@ +#include "Database.h" +#include "MySQLOOException.h" +#include +#include +#include +#include +#include "../lua/LuaObject.h" + +Database::Database(std::string host, std::string username, std::string pw, std::string database, unsigned int port, + std::string unixSocket) : + database(std::move(database)), host(std::move(host)), username(std::move(username)), pw(std::move(pw)), + socket(std::move(unixSocket)), port(port) { + LuaObject::allocationCount++; +} + +std::shared_ptr +Database::createDatabase(const std::string &host, const std::string &username, const std::string &pw, + const std::string &database, unsigned int port, const std::string &unixSocket) { + return std::shared_ptr(new Database(host, username, pw, database, port, unixSocket)); +} + + +Database::~Database() { + this->shutdown(); + if (this->m_thread.joinable()) { + this->m_thread.join(); + } + LuaObject::allocationCount--; +} + + +//This makes sure that all stmts always get freed +void Database::cacheStatement(MYSQL_STMT *stmt) { + if (stmt == nullptr) return; + std::unique_lock lock(m_statementMutex); + cachedStatements.insert(stmt); +} + +//This notifies the database thread to free this statement some time in the future +void Database::freeStatement(MYSQL_STMT *stmt) { + if (stmt == nullptr) return; + std::unique_lock lock(m_statementMutex); + if (cachedStatements.find(stmt) != cachedStatements.end()) { + //Otherwise, the statement was already freed + cachedStatements.erase(stmt); + freedStatements.insert(stmt); + } +} + +//Frees all statements that were allocated by the database +//This is called when the database shuts down +void Database::freeCachedStatements() { + std::unique_lock lock(m_statementMutex); + for (auto &stmt: cachedStatements) { + mysql_stmt_close(stmt); + } + cachedStatements.clear(); + for (auto &stmt: freedStatements) { + mysql_stmt_close(stmt); + } + freedStatements.clear(); +} + +//Frees all statements that have been marked as unused, i.e. the prepared query has been destroyed. +//Called periodically by the database thread +void Database::freeUnusedStatements() { + std::unique_lock lock(m_statementMutex); + for (auto &stmt: freedStatements) { + mysql_stmt_close(stmt); + } + freedStatements.clear(); +} + +/* Enqueues a query into the queue of accepted queries. + */ +void Database::enqueueQuery(const std::shared_ptr &query, const std::shared_ptr &queryData) { + queryQueue.put(std::make_pair(query, queryData)); + queryData->setStatus(QUERY_WAITING); + this->m_queryWakupVariable.notify_one(); +} + + +/* Returns the amount of queued querys in the database instance + * If a query is currently being processed, it does not count towards the queue size + */ +size_t Database::queueSize() { + return queryQueue.size(); +} + + +/* Aborts all queries that are in the queue of started queries and returns the number of successfully aborted queries. + * Does not abort queries that are already taken from the queue and being processed. + */ +std::deque, std::shared_ptr>> Database::abortAllQueries() { + auto canceledQueries = queryQueue.clear(); + for (auto &pair: canceledQueries) { + if (!pair.first || !pair.second) continue; + auto data = pair.second; + data->setStatus(QUERY_ABORTED); + } + return canceledQueries; +} + +/* Waits for the connection of the database to finish by blocking the current thread until the connection thread finished. + */ +void Database::wait() { + if (!startedConnecting) { + throw MySQLOOException( + "Tried to wait for database connection to finish without starting the connection!"); + } + std::unique_lock lck(m_connectMutex); + while (!m_connectionDone) m_connectWakeupVariable.wait(lck); +} + +/* Escapes an unescaped string using the database taking into account the charset of the database. + * This might break if the charset of the database is changed after the connection was done + */ +std::string Database::escape(const std::string &str) { + //No query mutex needed since this doesn't use the connection at all + std::lock_guard lock(m_connectMutex); + if (!m_connectionDone || m_sql == nullptr) { + throw MySQLOOException("Cannot escape using database that is not connected"); + } + + //escaped string can be twice as big as original string + //source: http://dev.mysql.com/doc/refman/5.1/en/mysql-real-escape-string.html + std::vector escapedQuery(str.size() * 2 + 1); + unsigned int nEscapedQueryLength = mysql_real_escape_string(m_sql, escapedQuery.data(), str.c_str(), + (unsigned long) str.size()); + return {escapedQuery.data(), (size_t) nEscapedQueryLength}; +} + +/* Changes the character set of the connection + * This will run the query in the server thread, which means the server will be paused + * until the query is done. + * This is so db:escape always has the latest value of mysql->charset + */ +bool Database::setCharacterSet(const std::string &characterSet) { + if (this->m_status != DATABASE_CONNECTED) { + throw MySQLOOException("Database needs to be connected to change charset."); + } + //This mutex makes sure we can safely use the connection to run the query + std::unique_lock lk2(m_queryMutex); + if (mysql_set_character_set(m_sql, characterSet.c_str())) { + return false; + } else { + return true; + } +} + +/* Starts the thread that connects to the database and then handles queries. + */ +void Database::connect() { + if (m_status != DATABASE_NOT_CONNECTED || startedConnecting) { + throw MySQLOOException("Database already connected."); + } + startedConnecting = true; + m_status = DATABASE_CONNECTING; + m_thread = std::thread(&Database::connectRun, this); +} + +void SSLSettings::applySSLSettings(MYSQL *m_sql) const { + if (!this->key.empty()) { + mysql_options(m_sql, MYSQL_OPT_SSL_KEY, this->key.c_str()); + } + if (!this->cert.empty()) { + mysql_options(m_sql, MYSQL_OPT_SSL_CERT, this->cert.c_str()); + } + if (!this->ca.empty()) { + mysql_options(m_sql, MYSQL_OPT_SSL_CA, this->ca.c_str()); + } + if (!this->capath.empty()) { + mysql_options(m_sql, MYSQL_OPT_SSL_CAPATH, this->capath.c_str()); + } + if (!this->cipher.empty()) { + mysql_options(m_sql, MYSQL_OPT_SSL_CIPHER, this->cipher.c_str()); + } +} + +/* Manually sets the instances SSL settings to use a custom SSL key, certificate, CA, CAPath, cipher, etc. + * This has to be called before connecting to the database. + */ +void Database::setSSLSettings(const SSLSettings &settings) { + if (m_status != DATABASE_NOT_CONNECTED) { + throw MySQLOOException("Cannot set SSL settings after connecting!"); + } + settings.applySSLSettings(this->m_sql); +} + + +void Database::shutdown() { + //This acts as a poison pill + this->queryQueue.put(std::make_pair(std::shared_ptr(), std::shared_ptr())); + //The fact that C++ can't automatically infer the types of the shared_ptr here and that + //I have to specify what type it should be, just proves once again that C++ is a failed language + //that should be replaced as soon as possible +} + +/* Disconnects from the mysql database after finishing all queued queries + * If wait is true, this will wait for the all queries to finish execution and the + * database thread to end. + */ +void Database::disconnect(bool wait) { + shutdown(); + if (wait && m_thread.joinable()) { + m_thread.join(); + } + disconnected = true; +} + +/* Returns the status of the database, constants can be found in GMModule + */ +DatabaseStatus Database::status() const { + return m_status; +} + +//Any of the serverInfo/Version and hostInfo functions could return outdated information if a reconnect happens +//(for example after a mysql server upgrade) + +/* Returns the server version as a formatted integer (XYYZZ, X= major-, Y=minor, Z=sub-version) + * Only works as soon as the connection has been established + */ +unsigned int Database::serverVersion() { + if (!m_connectionDone) { + throw MySQLOOException("Tried to get server version when client is not connected to server yet!"); + } + return m_serverVersion; +} + +/* Returns the server version as a string (for example 5.0.96) + * Only works as soon as the connection has been established + */ +std::string Database::serverInfo() { + if (!m_connectionDone) { + throw MySQLOOException("Tried to get server info when client is not connected to server yet!"); + } + return m_serverInfo; +} + +/* Returns a string of the hostname connected to as well as the connection type + * Only works as soon as the connection has been established + */ +std::string Database::hostInfo() { + if (!m_connectionDone) { + throw MySQLOOException("Tried to get server info when client is not connected to server yet!"); + } + return m_hostInfo; +} + +void Database::setShouldAutoReconnect(bool autoReconnect) { + if (m_status != DATABASE_NOT_CONNECTED || startedConnecting) { + throw MySQLOOException("Database already connected."); + } + shouldAutoReconnect = autoReconnect; +} + +void Database::setMultiStatements(bool multiStatement) { + if (m_status != DATABASE_NOT_CONNECTED || startedConnecting) { + throw MySQLOOException("Database already connected."); + } + useMultiStatements = multiStatement; +} + +std::shared_ptr Database::query(const std::string &query) { + return std::shared_ptr(new Query(shared_from_this(), query)); +} + +std::shared_ptr Database::prepare(const std::string &query) { + return std::shared_ptr(new PreparedQuery(shared_from_this(), query)); +} + +std::shared_ptr Database::transaction() { + return std::shared_ptr(new Transaction(shared_from_this())); +} + +bool Database::ping() { + auto query = std::shared_ptr(new PingQuery(shared_from_this())); + auto queryData = query->buildQueryData(); + query->start(queryData); + query->wait(true); + return query->pingSuccess; +} + +//Set this to false if your database server imposes a low prepared statements limit +//Or if you might create a very high amount of prepared queries in a short period of time +void Database::setCachePreparedStatements(bool shouldCache) { + if (this->m_status != DATABASE_NOT_CONNECTED) { + throw MySQLOOException("setCachePreparedStatements has to be called before db:start()!"); + } + cachePreparedStatements = shouldCache; +} + +//Should only be called from the db thread +//While the mysql documentation says that mysql_options should only be called +//before the connection is done it appears to work after just fine (at least for reconnect) +void Database::setSQLAutoReconnect(bool shouldReconnect) { + auto myAutoReconnectBool = (my_bool) shouldReconnect; + mysql_optionsv(m_sql, MYSQL_OPT_RECONNECT, &myAutoReconnectBool); +} + +//Should only be called from the db thread +bool Database::getAutoReconnect() { + my_bool autoReconnect; + mysql_get_optionv(m_sql, MYSQL_OPT_RECONNECT, &autoReconnect); + return (bool) autoReconnect; +} + + +/* Thread that connects to the database, on success it continues to handle queries in the run method. + */ +void Database::connectRun() { + mysql_thread_init(); + auto threadEnd = finally([&] { + mysql_thread_end(); + if (m_status == DATABASE_CONNECTED) { + m_status = DATABASE_NOT_CONNECTED; + } + }); + { + auto connectionSignaliser = finally([&] { m_connectWakeupVariable.notify_one(); }); + std::lock_guard lock(this->m_connectMutex); + this->m_sql = mysql_init(nullptr); + if (this->m_sql == nullptr) { + m_success = false; + m_connection_err = "Out of memory"; + m_connectionDone = true; + m_status = DATABASE_CONNECTION_FAILED; + return; + } + this->customSSLSettings.applySSLSettings(this->m_sql); + if (this->shouldAutoReconnect) { + setSQLAutoReconnect(true); + } + const char *socketStr = (this->socket.length() == 0) ? nullptr : this->socket.c_str(); + unsigned long clientFlag = (this->useMultiStatements) ? CLIENT_MULTI_STATEMENTS : 0; + clientFlag |= CLIENT_MULTI_RESULTS; + if (mysql_real_connect(this->m_sql, this->host.c_str(), this->username.c_str(), this->pw.c_str(), + this->database.c_str(), this->port, socketStr, clientFlag) != this->m_sql) { + m_success = false; + m_connection_err = mysql_error(this->m_sql); + m_connectionDone = true; + m_status = DATABASE_CONNECTION_FAILED; + return; + } + m_success = true; + m_connection_err = ""; + m_connectionDone = true; + m_status = DATABASE_CONNECTED; + m_serverVersion = mysql_get_server_version(this->m_sql); + m_serverInfo = mysql_get_server_info(this->m_sql); + m_hostInfo = mysql_get_host_info(this->m_sql); + } + auto closeConnection = finally([&] { + std::unique_lock queryMutex(m_queryMutex); + mysql_close(this->m_sql); + this->m_sql = nullptr; + }); + if (m_success) { + run(); + } +} + +/* The run method of the thread of the database instance. + */ +void Database::run() { + auto a = finally([&] { + this->freeCachedStatements(); + }); + while (true) { + auto pair = this->queryQueue.take(); + //This detects the poison pill that is supposed to shut down the database + if (pair.first == nullptr) { + return; + } + auto curQuery = pair.first; + auto data = pair.second; + { + //New scope so mutex will be released as soon as possible + std::unique_lock queryMutex(m_queryMutex); + curQuery->executeStatement(*this, this->m_sql, data); + } + data->setFinished(true); + finishedQueries.put(pair); + { + std::unique_lock queryMutex(curQuery->m_waitMutex); + curQuery->m_waitWakeupVariable.notify_one(); + } + //So that statements get eventually freed even if the queue is constantly full + freeUnusedStatements(); + } +} \ No newline at end of file diff --git a/src/mysql/Database.h b/src/mysql/Database.h new file mode 100644 index 0000000..4b55bbc --- /dev/null +++ b/src/mysql/Database.h @@ -0,0 +1,156 @@ +#ifndef DATABASE_ +#define DATABASE_ + +#include "MySQLHeader.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "GarrysMod/Lua/Interface.h" +#include "../BlockingQueue.h" +#include "Query.h" +#include "PreparedQuery.h" +#include "IQuery.h" +#include "PingQuery.h" +#include "Transaction.h" + +struct SSLSettings { + std::string key; + std::string cert; + std::string ca; + std::string capath; + std::string cipher; + + void applySSLSettings(MYSQL *m_sql) const; +}; + +enum DatabaseStatus { + DATABASE_CONNECTED = 0, + DATABASE_CONNECTING = 1, + DATABASE_NOT_CONNECTED = 2, + DATABASE_CONNECTION_FAILED = 3 +}; + +class Database : public std::enable_shared_from_this { + friend class IQuery; + +public: + static std::shared_ptr + createDatabase(const std::string &host, const std::string &username, const std::string &pw, + const std::string &database, unsigned int port, + const std::string &unixSocket); + + ~Database(); + + void cacheStatement(MYSQL_STMT *stmt); + + void freeStatement(MYSQL_STMT *stmt); + + void enqueueQuery(const std::shared_ptr &query, const std::shared_ptr &data); + + void setShouldAutoReconnect(bool autoReconnect); + + bool getAutoReconnect(); + + bool shouldCachePreparedStatements() { + return cachePreparedStatements; + } + + std::shared_ptr query(const std::string &query); + + std::shared_ptr prepare(const std::string &query); + + std::shared_ptr transaction(); + + bool ping(); + + std::string escape(const std::string &str); + + bool setCharacterSet(const std::string &characterSet); + + void connect(); + + void wait(); + + std::deque, std::shared_ptr>> abortAllQueries(); + + DatabaseStatus status() const; + + unsigned int serverVersion(); + + std::string serverInfo(); + + std::string hostInfo(); + + size_t queueSize(); + + void setMultiStatements(bool multiStatement); + + void setCachePreparedStatements(bool cachePreparedStatements); + + void disconnect(bool wait); + + void setSSLSettings(const SSLSettings &settings); + + bool isConnectionDone() { return m_connectionDone; } + bool connectionSuccessful() { return m_success; } + std::string connectionError() { return m_connection_err; } + + std::deque, std::shared_ptr>> takeFinishedQueries() { + return finishedQueries.clear(); + } + + void setSQLAutoReconnect(bool autoReconnect); + +private: + Database(std::string host, std::string username, std::string pw, std::string database, unsigned int port, + std::string unixSocket); + + void shutdown(); + + void freeCachedStatements(); + + void freeUnusedStatements(); + + void run(); + + void connectRun(); + + BlockingQueue, std::shared_ptr>> finishedQueries{}; + BlockingQueue, std::shared_ptr>> queryQueue{}; + std::unordered_set cachedStatements{}; + std::unordered_set freedStatements{}; + MYSQL *m_sql = nullptr; + std::thread m_thread; + std::mutex m_connectMutex; //Mutex used during connection + std::mutex m_queryMutex; //Mutex that is locked while query thread operates on m_sql object + std::mutex m_statementMutex; //Mutex that protects cached prepared statements + std::condition_variable m_connectWakeupVariable; + unsigned int m_serverVersion = 0; + std::string m_serverInfo; + std::string m_hostInfo; + std::string m_connection_err; + bool shouldAutoReconnect = true; + bool useMultiStatements = true; + bool startedConnecting = false; + bool disconnected = false; + std::atomic m_success{true}; + std::atomic m_connectionDone{false}; + std::atomic cachePreparedStatements{true}; + std::condition_variable m_queryWakupVariable; + std::string database; + std::string host; + std::string username; + std::string pw; + std::string socket; + unsigned int port; + SSLSettings customSSLSettings{}; + std::atomic m_status{DATABASE_NOT_CONNECTED}; +}; + +#endif \ No newline at end of file diff --git a/src/mysql/IQuery.cpp b/src/mysql/IQuery.cpp new file mode 100644 index 0000000..8f9bac7 --- /dev/null +++ b/src/mysql/IQuery.cpp @@ -0,0 +1,177 @@ +#include "IQuery.h" + +#include +#include "Database.h" +#include "MySQLOOException.h" +#include "../lua/LuaObject.h" + +//Important: +//Calling any query functions that rely on data from the query thread +//before the callback is called can result in race conditions. +//Always check for QUERY_COMPLETE!!! + +IQuery::IQuery(const std::shared_ptr &database) : m_database(database) { + m_options = OPTION_NAMED_FIELDS | OPTION_INTERPRET_DATA | OPTION_CACHE; + LuaObject::allocationCount++; +} + +IQuery::~IQuery() { + LuaObject::allocationCount--; +} + +QueryResultStatus IQuery::getResultStatus() const { + if (!hasCallbackData()) { + return QUERY_NONE; + } + return callbackQueryData->getResultStatus(); +} + +//Wrapper for c api calls +//Just throws an exception if anything goes wrong for ease of use + +void IQuery::mysqlAutocommit(MYSQL *sql, bool auto_mode) { + my_bool result = mysql_autocommit(sql, (my_bool) auto_mode); + if (result) { + const char *errorMessage = mysql_error(sql); + unsigned int errorCode = mysql_errno(sql); + throw MySQLException(errorCode, errorMessage); + } +} + +//Returns if the query has been queued with the database instance +bool IQuery::isRunning() { + return !runningQueryData.empty(); +} + +//Blocks the current Thread until the query has finished processing +//Possibly dangerous (dead lock when database goes down while waiting) +//If the second argument is set to true, the query is going to be swapped to the front of the query queue +void IQuery::wait(bool shouldSwap) { + if (!isRunning()) { + throw MySQLOOException("Query not started"); + } + std::shared_ptr lastInsertedQuery = runningQueryData.back(); + //Changing the order of the query might have unwanted side effects, so this is disabled by default + auto database = m_database; + if (shouldSwap) { + database->queryQueue.swapToFrontIf( + [&](std::pair, std::shared_ptr> const &p) { + return p.second.get() == lastInsertedQuery.get(); + }); + } + { + std::unique_lock lck(m_waitMutex); + while (!lastInsertedQuery->isFinished()) m_waitWakeupVariable.wait(lck); + } +} + +//Returns the error message produced by the mysql query or "" if there is none +std::string IQuery::error() const { + auto currentQueryData = callbackQueryData; + if (!currentQueryData) { + return ""; + } + return currentQueryData->getError(); +} + +//Attempts to abort the query, returns true if it was able to stop at least one query in time, false otherwise +std::vector> IQuery::abort() { + auto database = m_database; + if (!database) return {}; + //This is copied so that I can remove entries from that vector in onQueryDataFinished + auto runningQueries = runningQueryData; + std::vector> abortedQueries; + for (auto &data: runningQueries) { + //It doesn't really matter if any of them are in a transaction since in that case they + //aren't in the query queue + bool wasRemoved = database->queryQueue.removeIf( + [&](std::pair, std::shared_ptr> const &p) { + return p.second == data; + }); + if (wasRemoved) { + data->setStatus(QUERY_ABORTED); + abortedQueries.push_back(data); + } + } + return abortedQueries; +} + +//Sets several query options +void IQuery::setOption(int option, bool enabled) { + if (option != OPTION_NUMERIC_FIELDS && + option != OPTION_NAMED_FIELDS && + option != OPTION_INTERPRET_DATA && + option != OPTION_CACHE) { + throw MySQLOOException("Invalid Option"); + } + + if (enabled) { + m_options |= option; + } else { + m_options &= ~option; + } +} + +//Wrapper for c api calls +//Just throws an exception if anything goes wrong for ease of use + +void IQuery::mysqlQuery(MYSQL *sql, std::string &query) { + int result = mysql_real_query(sql, query.c_str(), (unsigned long) query.length()); + if (result != 0) { + const char *errorMessage = mysql_error(sql); + unsigned int errorCode = mysql_errno(sql); + throw MySQLException(errorCode, errorMessage); + } +} + +MYSQL_RES *IQuery::mysqlStoreResults(MYSQL *sql) { + MYSQL_RES *result = mysql_store_result(sql); + if (result == nullptr) { + unsigned int errorCode = mysql_errno(sql); + if (errorCode != 0) { + const char *errorMessage = mysql_error(sql); + throw MySQLException(errorCode, errorMessage); + } + } + return result; +} + +bool IQuery::mysqlNextResult(MYSQL *sql) { + int result = mysql_next_result(sql); + if (result == 0) return true; + if (result == -1) return false; + unsigned int errorCode = mysql_errno(sql); + if (errorCode != 0) { + const char *errorMessage = mysql_error(sql); + throw MySQLException(errorCode, errorMessage); + } + return false; +} + +//Queues the query into the queue of the database instance associated with it +void IQuery::start(const std::shared_ptr &queryData) { + auto db = m_database; + addQueryData(queryData); + db->enqueueQuery(shared_from_this(), queryData); + hasBeenStarted = true; +} + + +void IQuery::addQueryData(const std::shared_ptr &data) { + if (!hasBeenStarted) { + data->m_wasFirstData = true; + } + runningQueryData.push_back(data); +} + +void IQuery::finishQueryData(const std::shared_ptr &data) { + if (runningQueryData.empty()) return; + auto front = runningQueryData.front(); + if (front == data) { + //Fast path, O(1) + runningQueryData.pop_front(); + } else { + //Slow path, O(n), should only happen in very rare circumstances. + runningQueryData.erase(std::remove(runningQueryData.begin(), runningQueryData.end(), data), runningQueryData.end()); + } +} diff --git a/src/mysql/IQuery.h b/src/mysql/IQuery.h new file mode 100644 index 0000000..748905c --- /dev/null +++ b/src/mysql/IQuery.h @@ -0,0 +1,177 @@ +#ifndef IQUERY_ +#define IQUERY_ + +#include "MySQLHeader.h" +#include +#include +#include +#include +#include +#include +#include + +class Database; + +enum QueryStatus { + QUERY_NOT_RUNNING = 0, + QUERY_RUNNING = 1, + QUERY_COMPLETE = 3, //Query is complete right before callback is run + QUERY_ABORTED = 4, + QUERY_WAITING = 5, +}; +enum QueryResultStatus { + QUERY_NONE = 0, + QUERY_ERROR, + QUERY_SUCCESS +}; +enum { + OPTION_NUMERIC_FIELDS = 1, + OPTION_NAMED_FIELDS = 2, + OPTION_INTERPRET_DATA = 4, + OPTION_CACHE = 8, +}; + +class IQueryData; + +class MySQLException : public std::runtime_error { +public: + MySQLException(unsigned int errorCode, const char *message) : runtime_error(message) { + this->m_errorCode = errorCode; + } + + unsigned int getErrorCode() const { return m_errorCode; } + +private: + unsigned int m_errorCode = 0; +}; + +class IQuery : public std::enable_shared_from_this { + friend class Database; + +public: + explicit IQuery(const std::shared_ptr& database); + + virtual ~IQuery(); + + void setCallbackData(std::shared_ptr data) { + callbackQueryData = std::move(data); + } + + void start(const std::shared_ptr &queryData); + + bool isRunning(); + + void setOption(int option, bool enabled); + + bool hasOption(int option) const { + return m_options & option; + } + + void addQueryData(const std::shared_ptr &data); + + void finishQueryData(const std::shared_ptr &data); + + std::string error() const; + + std::vector> abort(); + + void wait(bool shouldSwap); + + bool hasCallbackData() const { + return callbackQueryData != nullptr; + } + QueryResultStatus getResultStatus() const; + std::shared_ptr callbackQueryData; +protected: + + virtual bool executeStatement(Database &database, MYSQL *m_sql, std::shared_ptr data) = 0; + + //Wrapper functions for c api that throw exceptions + static void mysqlQuery(MYSQL *sql, std::string &query); + + static void mysqlAutocommit(MYSQL *sql, bool auto_mode); + + static MYSQL_RES *mysqlStoreResults(MYSQL *sql); + + static bool mysqlNextResult(MYSQL *sql); + + //fields + std::shared_ptr m_database{}; + std::condition_variable m_waitWakeupVariable; + std::mutex m_waitMutex; + int m_options = 0; + std::deque> runningQueryData; + bool hasBeenStarted = false; +}; + +class IQueryData { + friend class IQuery; + +public: + virtual ~IQueryData() = default; + + std::string getError() { + return m_errorText; + } + + void setError(std::string err) { + m_errorText = std::move(err); + } + + bool isFinished() { + return finished; + } + + void setFinished(bool isFinished) { + finished = isFinished; + } + + QueryStatus getStatus() { + return m_status; + } + + void setStatus(QueryStatus status) { + this->m_status = status; + } + + QueryResultStatus getResultStatus() { + return m_resultStatus; + } + + void setResultStatus(QueryResultStatus status) { + m_resultStatus = status; + } + + int getErrorReference() const { + return m_errorReference; + } + + int getSuccessReference() const { + return m_successReference; + } + + int getOnDataReference() const { + return m_onDataReference; + } + + int getAbortReference() const { + return m_abortReference; + } + + bool isFirstData() const { + return m_wasFirstData; + } + int m_successReference = 0; + int m_errorReference = 0; + int m_abortReference = 0; + int m_onDataReference = 0; + int m_tableReference = 0; +protected: + std::string m_errorText; + std::atomic finished{false}; + std::atomic m_status{QUERY_NOT_RUNNING}; + std::atomic m_resultStatus{QUERY_NONE}; + bool m_wasFirstData = false; +}; + +#endif \ No newline at end of file diff --git a/MySQLOO/include/MySQLHeader.h b/src/mysql/MySQLHeader.h similarity index 89% rename from MySQLOO/include/MySQLHeader.h rename to src/mysql/MySQLHeader.h index e737663..2387957 100644 --- a/MySQLOO/include/MySQLHeader.h +++ b/src/mysql/MySQLHeader.h @@ -1,12 +1,12 @@ #ifndef _MySQL_H #define _MySQL_H -#include +#include //Source: http://stackoverflow.com/a/25510879 //Pretty much an action that is always going to execute when the //scope it was declared in is left (so exceptions/returns/break/etc.) template struct FinalAction { - FinalAction(F f) : clean_{ f } {} + explicit FinalAction(F f) : clean_{ f } {} ~FinalAction() { clean_(); } F clean_; }; diff --git a/src/mysql/MySQLOOException.h b/src/mysql/MySQLOOException.h new file mode 100644 index 0000000..c46d721 --- /dev/null +++ b/src/mysql/MySQLOOException.h @@ -0,0 +1,15 @@ +#ifndef MYSQLOO_MYSQLERROR_H +#define MYSQLOO_MYSQLERROR_H + +#include + +//When called from the outside +class MySQLOOException : std::exception { +public: + explicit MySQLOOException(std::string error) : std::exception(), message(std::move(error)) { + } + + std::string message{}; +}; + +#endif //MYSQLOO_MYSQLERROR_H diff --git a/src/mysql/PingQuery.cpp b/src/mysql/PingQuery.cpp new file mode 100644 index 0000000..3e284e1 --- /dev/null +++ b/src/mysql/PingQuery.cpp @@ -0,0 +1,23 @@ +#include "PingQuery.h" + +#ifdef LINUX +#include +#endif + +#include "Database.h" + +//Dummy class just used with the Database::ping function +PingQuery::PingQuery(const std::shared_ptr &dbase) : Query(dbase, "") { + +} + +PingQuery::~PingQuery() = default; + +/* Executes the ping query +*/ +void PingQuery::executeQuery(Database &database, MYSQL *connection, const std::shared_ptr &data) { + bool oldAutoReconnect = database.getAutoReconnect(); + database.setSQLAutoReconnect(true); + this->pingSuccess = mysql_ping(connection) == 0; + database.setSQLAutoReconnect(oldAutoReconnect); +} \ No newline at end of file diff --git a/src/mysql/PingQuery.h b/src/mysql/PingQuery.h new file mode 100644 index 0000000..05d4e3d --- /dev/null +++ b/src/mysql/PingQuery.h @@ -0,0 +1,20 @@ +#pragma once +#ifndef PINGQUERY_ +#define PINGQUERY_ +#include +#include "Query.h" +#include "MySQLHeader.h" +#include +#include + + +class PingQuery : public Query { + friend class Database; +public: + ~PingQuery() override; +protected: + explicit PingQuery(const std::shared_ptr& dbase); + void executeQuery(Database &database, MYSQL* m_sql, const std::shared_ptr &data) override; + bool pingSuccess = false; +}; +#endif \ No newline at end of file diff --git a/src/mysql/PreparedQuery.cpp b/src/mysql/PreparedQuery.cpp new file mode 100644 index 0000000..fc0e462 --- /dev/null +++ b/src/mysql/PreparedQuery.cpp @@ -0,0 +1,284 @@ +#include "PreparedQuery.h" + +#include +#include "Database.h" +#include "errmsg.h" +#include "mysqld_error.h" +#include "MySQLOOException.h" + +#ifdef LINUX +#include +#endif + +PreparedQuery::PreparedQuery(const std::shared_ptr &dbase, std::string query) : Query(dbase, + std::move(query)) { + putNewParameters(); +} + + +PreparedQuery::~PreparedQuery() { + m_database->freeStatement(cachedStatement); +} + + +void PreparedQuery::clearParameters() { + m_parameters.clear(); + m_parameters.emplace_back(); +} + +void PreparedQuery::setNumber(unsigned int index, double value) { + if (index < 1) { + throw MySQLOOException("Index must be greater than 0"); + } + m_parameters.back()[index] = std::shared_ptr( + new TypedQueryField(index, MYSQL_TYPE_DOUBLE, value)); +} + +void PreparedQuery::setString(unsigned int index, const std::string &value) { + if (index < 1) { + throw MySQLOOException("Index must be greater than 0"); + } + m_parameters.back()[index] = std::shared_ptr( + new TypedQueryField(index, MYSQL_TYPE_STRING, value)); +} + +void PreparedQuery::setBoolean(unsigned int index, bool value) { + if (index < 1) { + throw MySQLOOException("Index must be greater than 0"); + } + m_parameters.back()[index] = std::shared_ptr( + new TypedQueryField(index, MYSQL_TYPE_BIT, value)); +} + +void PreparedQuery::setNull(unsigned int index) { + if (index < 1) { + throw MySQLOOException("Index must be greater than 0"); + } + m_parameters.back()[index] = std::make_shared(index, MYSQL_TYPE_NULL); +} + +//Adds an additional set of parameters to the prepared query +//This makes it relatively easy to insert multiple rows at once +void PreparedQuery::putNewParameters() { + m_parameters.emplace_back(); +} + +//Wrapper functions that might throw errors +MYSQL_STMT *PreparedQuery::mysqlStmtInit(MYSQL *sql) { + MYSQL_STMT *stmt = mysql_stmt_init(sql); + if (stmt == nullptr) { + const char *errorMessage = mysql_error(sql); + unsigned int errorCode = mysql_errno(sql); + throw MySQLException(errorCode, errorMessage); + } + return stmt; +} + +void PreparedQuery::mysqlStmtBindParameter(MYSQL_STMT *stmt, MYSQL_BIND *bind) { + my_bool result = mysql_stmt_bind_param(stmt, bind); + if (result != 0) { + const char *errorMessage = mysql_stmt_error(stmt); + unsigned int errorCode = mysql_stmt_errno(stmt); + throw MySQLException(errorCode, errorMessage); + } +} + +void PreparedQuery::mysqlStmtPrepare(MYSQL_STMT *stmt, const char *str) { + auto length = (unsigned long) strlen(str); + int result = mysql_stmt_prepare(stmt, str, length); + if (result != 0) { + const char *errorMessage = mysql_stmt_error(stmt); + unsigned int errorCode = mysql_stmt_errno(stmt); + throw MySQLException(errorCode, errorMessage); + } +} + +void PreparedQuery::mysqlStmtExecute(MYSQL_STMT *stmt) { + int result = mysql_stmt_execute(stmt); + if (result != 0) { + const char *errorMessage = mysql_stmt_error(stmt); + unsigned int errorCode = mysql_stmt_errno(stmt); + throw MySQLException(errorCode, errorMessage); + } +} + +void PreparedQuery::mysqlStmtStoreResult(MYSQL_STMT *stmt) { + int result = mysql_stmt_store_result(stmt); + if (result != 0) { + const char *errorMessage = mysql_stmt_error(stmt); + unsigned int errorCode = mysql_stmt_errno(stmt); + throw MySQLException(errorCode, errorMessage); + } +} + +bool PreparedQuery::mysqlStmtNextResult(MYSQL_STMT *stmt) { + int result = mysql_stmt_next_result(stmt); + if (result > 0) { + const char *errorMessage = mysql_stmt_error(stmt); + unsigned int errorCode = mysql_stmt_errno(stmt); + throw MySQLException(errorCode, errorMessage); + } + return result == 0; +} + +static my_bool nullBool = 1; +static int trueValue = 1; +static int falseValue = 0; + +//Generates binds for a prepared query. In this case the binds are used to send the parameters to the server +void PreparedQuery::generateMysqlBinds(MYSQL_BIND *binds, + std::unordered_map> &map, + unsigned int parameterCount) { + for (unsigned int i = 1; i <= parameterCount; i++) { + auto it = map.find(i); + if (it == map.end()) { + MYSQL_BIND *bind = &binds[i - 1]; + bind->buffer_type = MYSQL_TYPE_NULL; + bind->is_null = &nullBool; + continue; + } + unsigned int index = it->second->m_index - 1; + if (index >= parameterCount) { + std::stringstream errStream; + errStream << "Invalid parameter index " << index + 1; + throw MySQLException(0, errStream.str().c_str()); + } + MYSQL_BIND *bind = &binds[index]; + switch (it->second->m_type) { + case MYSQL_TYPE_DOUBLE: { + auto *doubleField = dynamic_cast *>(it->second.get()); + bind->buffer_type = MYSQL_TYPE_DOUBLE; + bind->buffer = (char *) &doubleField->m_data; + break; + } + case MYSQL_TYPE_BIT: { + auto *boolField = dynamic_cast *>(it->second.get()); + bind->buffer_type = MYSQL_TYPE_LONG; + bind->buffer = (char *) &((boolField->m_data) ? trueValue : falseValue); + break; + } + case MYSQL_TYPE_STRING: { + auto *textField = dynamic_cast *>(it->second.get()); + bind->buffer_type = MYSQL_TYPE_STRING; + bind->buffer = (char *) textField->m_data.c_str(); + bind->buffer_length = (unsigned long) textField->m_data.length(); + break; + } + case MYSQL_TYPE_NULL: { + bind->buffer_type = MYSQL_TYPE_NULL; + bind->is_null = &nullBool; + break; + } + } + } +} + + +/* Executes the prepared query +* This function can only ever return one result set +* Note: If an error occurs at the nth query all the actions done before +* that nth query won't be reverted even though this query results in an error +*/ +void PreparedQuery::executeQuery(Database &database, MYSQL *connection, const std::shared_ptr &ptr) { + std::shared_ptr data = std::dynamic_pointer_cast(ptr); + bool shouldReconnect = database.getAutoReconnect(); + //Autoreconnect has to be disabled for prepared statement since prepared statements + //get reset on the server if the connection fails and auto reconnects + try { + MYSQL_STMT *stmt = nullptr; + auto stmtClose = finally([&] { + if (!database.shouldCachePreparedStatements() && stmt != nullptr) { + mysql_stmt_close(stmt); + } + }); + if (this->cachedStatement.load() != nullptr) { + stmt = this->cachedStatement; + } else { + stmt = mysqlStmtInit(connection); + my_bool attrMaxLength = 1; + mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &attrMaxLength); + mysqlStmtPrepare(stmt, this->m_query.c_str()); + if (database.shouldCachePreparedStatements()) { + this->cachedStatement = stmt; + database.cacheStatement(stmt); + } + } + unsigned int parameterCount = mysql_stmt_param_count(stmt); + std::vector mysqlParameters(parameterCount); + + for (auto ¤tMap: data->m_parameters) { + generateMysqlBinds(mysqlParameters.data(), currentMap, parameterCount); + mysqlStmtBindParameter(stmt, mysqlParameters.data()); + mysqlStmtExecute(stmt); + do { + data->m_affectedRows.push_back(mysql_stmt_affected_rows(stmt)); + data->m_insertIds.push_back(mysql_stmt_insert_id(stmt)); + data->m_resultStatus = QUERY_SUCCESS; + + MYSQL_RES *metaData = mysql_stmt_result_metadata(stmt); + if (metaData == nullptr) { + //This means the statement does not have a resultset (this apparently happens when calling stored procedures) + //We need to skip this result, otherwise it screws up the mysql connection + //Add an empty ResultData in that case + //This is only necessary due to MariaDB client behaving differently to the Mysql client + //otherwise we get a hang in the rest of the code below + data->m_results.emplace_back(); + continue; + } + auto f = finally([&] { mysql_free_result(metaData); }); + //There is a potential race condition here. What happens + //when the query executes fine but something goes wrong while storing the result? + mysqlStmtStoreResult(stmt); + auto f2 = finally([&] { mysql_stmt_free_result(stmt); }); + data->m_results.emplace_back(stmt, metaData); + } while (mysqlStmtNextResult(stmt)); + } + } catch (const MySQLException &error) { + unsigned int errorCode = error.getErrorCode(); + if (errorCode == CR_SERVER_LOST || errorCode == CR_SERVER_GONE_ERROR || + errorCode == ER_MAX_PREPARED_STMT_COUNT_REACHED || errorCode == CR_NO_PREPARE_STMT || + errorCode == ER_UNKNOWN_STMT_HANDLER) { + database.freeStatement(this->cachedStatement); + this->cachedStatement = nullptr; + //Because autoreconnect is disabled we want to try and explicitly execute the prepared query once more + //if we can get the client to reconnect (reconnect is caused by mysql_ping) + //If this fails we just go ahead and error + if (shouldReconnect && data->firstAttempt) { + if (mysql_ping(connection) == 0) { + data->firstAttempt = false; + executeQuery(database, connection, ptr); + return; + } + } + } + //Rethrow error to be handled by executeStatement() + throw error; + } +} + +bool PreparedQuery::executeStatement(Database &database, MYSQL *connection, std::shared_ptr ptr) { + std::shared_ptr data = std::dynamic_pointer_cast(ptr); + data->setStatus(QUERY_RUNNING); + try { + this->executeQuery(database, connection, ptr); + data->setResultStatus(QUERY_SUCCESS); + } catch (const MySQLException &error) { + data->setResultStatus(QUERY_ERROR); + data->setError(error.what()); + } + return true; +} + +std::shared_ptr PreparedQuery::buildQueryData() { + std::shared_ptr data(new PreparedQueryData()); + data->m_parameters = this->m_parameters; + while (m_parameters.size() > 1) { + //Front so the last used parameters are the ones that are gonna stay + m_parameters.pop_front(); + } + return std::dynamic_pointer_cast(data); +} + +std::shared_ptr PreparedQuery::create(const std::shared_ptr &dbase, std::string query) { + return std::shared_ptr(new PreparedQuery(dbase, std::move(query))); +} diff --git a/src/mysql/PreparedQuery.h b/src/mysql/PreparedQuery.h new file mode 100644 index 0000000..209b11a --- /dev/null +++ b/src/mysql/PreparedQuery.h @@ -0,0 +1,99 @@ +#ifndef PREPAREDQUERY_ +#define PREPAREDQUERY_ + +#include +#include "Query.h" +#include "MySQLHeader.h" +#include + + +class PreparedQueryField { + friend class PreparedQuery; + +public: + PreparedQueryField(unsigned int index, int type) : m_index(index), m_type(type) {} + + PreparedQueryField() : m_index(1), m_type(0) {} + + virtual ~PreparedQueryField() = default; + +private: + unsigned int m_index; + int m_type; +}; + +template +class TypedQueryField : public PreparedQueryField { + friend class PreparedQuery; + +public: + TypedQueryField(unsigned int index, int type, const T &data) + : PreparedQueryField(index, type), m_data(data) {}; + + ~TypedQueryField() override = default; + +private: + T m_data; +}; + +class PreparedQueryData : public QueryData { + friend class PreparedQuery; + +protected: + std::deque>> m_parameters; + bool firstAttempt = true; + PreparedQueryData() = default; +}; + +class PreparedQuery : public Query { + friend class Database; + +public: + ~PreparedQuery() override; + + bool executeStatement(Database &database, MYSQL *connection, std::shared_ptr data) override; + + void clearParameters(); + + void setNumber(unsigned int index, double value); + + void setString(unsigned int index, const std::string &value); + + void setBoolean(unsigned int index, bool value); + + void setNull(unsigned int index); + + void putNewParameters(); + + std::shared_ptr buildQueryData() override; + + static std::shared_ptr create(const std::shared_ptr &dbase, std::string query); +protected: + void executeQuery(Database &database, MYSQL *m_sql, const std::shared_ptr &data) override; + +private: + PreparedQuery(const std::shared_ptr &dbase, std::string query); + + std::deque>> m_parameters{}; + + static MYSQL_STMT *mysqlStmtInit(MYSQL *sql); + + static void + generateMysqlBinds(MYSQL_BIND *binds, std::unordered_map> &map, + unsigned int parameterCount); + + static void mysqlStmtBindParameter(MYSQL_STMT *sql, MYSQL_BIND *bind); + + static void mysqlStmtPrepare(MYSQL_STMT *sql, const char *str); + + static void mysqlStmtExecute(MYSQL_STMT *sql); + + static void mysqlStmtStoreResult(MYSQL_STMT *sql); + + static bool mysqlStmtNextResult(MYSQL_STMT *sql); + + //This is atomic to prevent visibility issues + std::atomic cachedStatement{nullptr}; +}; + +#endif \ No newline at end of file diff --git a/src/mysql/Query.cpp b/src/mysql/Query.cpp new file mode 100644 index 0000000..fb69064 --- /dev/null +++ b/src/mysql/Query.cpp @@ -0,0 +1,96 @@ +#include "Query.h" +#include "MySQLOOException.h" +#include +#include +#include +#ifdef LINUX +#include +#endif + +Query::Query(const std::shared_ptr& dbase, std::string query) : IQuery(dbase), m_query(std::move(query)) { +} + +Query::~Query() = default; + +void Query::executeQuery(Database &database, MYSQL* connection, const std::shared_ptr &data) { + auto queryData = std::dynamic_pointer_cast(data); + Query::mysqlQuery(connection, this->m_query); + //Stores all result sets + //MySQL result sets shouldn't be accessed from different threads! + do { + MYSQL_RES * results = Query::mysqlStoreResults(connection); + auto resultFree = finally([&] { mysql_free_result(results); }); + if (results != nullptr) { + queryData->m_results.emplace_back(results); + } else { + queryData->m_results.emplace_back(); + } + queryData->m_insertIds.push_back(mysql_insert_id(connection)); + queryData->m_affectedRows.push_back(mysql_affected_rows(connection)); + } while (Query::mysqlNextResult(connection)); +} + +//Executes the raw query +bool Query::executeStatement(Database &database, MYSQL* connection, std::shared_ptr data) { + auto queryData = std::dynamic_pointer_cast(data); + data->setStatus(QUERY_RUNNING); + try { + this->executeQuery(database, connection, data); + queryData->m_resultStatus = QUERY_SUCCESS; + } catch (const MySQLException& error) { + data->setError(error.what()); + data->setResultStatus(QUERY_ERROR); + } + return true; +} + + +//Returns true if a query has at least one additional ResultSet left +bool Query::hasMoreResults() { + if (!hasCallbackData()) { + throw MySQLOOException("Query not completed yet"); + } + auto data = std::dynamic_pointer_cast(this->callbackQueryData); + return data->hasMoreResults(); +} + +//Unreferences the current result set and uses the next result set +void Query::getNextResults() { + if (!hasCallbackData()) { + throw MySQLOOException("Query not completed yet"); + } + auto data = std::dynamic_pointer_cast(this->callbackQueryData); + if (!data->getNextResults()) { + throw MySQLOOException("Query doesn't have any more results"); + } +} + +//Returns the last insert id produced by INSERT INTO statements (or 0 if there is none) +my_ulonglong Query::lastInsert() { + if (!hasCallbackData()) { + return 0; + } + auto data = std::dynamic_pointer_cast(this->callbackQueryData); + //Calling lastInsert() after query was executed but before the callback is run can cause race conditions + return data->getLastInsertID(); +} + +//Returns the last affected rows produced by INSERT/DELETE/UPDATE (0 for none, -1 for errors) +//For a SELECT statement this returns the amount of rows returned +my_ulonglong Query::affectedRows() { + if (!hasCallbackData()) { + return 0; + } + auto data = std::dynamic_pointer_cast(this->callbackQueryData); + //Calling affectedRows() after query was executed but before the callback is run can cause race conditions + return data->getAffectedRows(); +} + +std::shared_ptr Query::buildQueryData() { + return std::shared_ptr(new QueryData()); +} + +std::shared_ptr Query::create(const std::shared_ptr &dbase, const std::string& query) { + return std::shared_ptr(new Query(dbase, query)); +} + diff --git a/src/mysql/Query.h b/src/mysql/Query.h new file mode 100644 index 0000000..77aee33 --- /dev/null +++ b/src/mysql/Query.h @@ -0,0 +1,83 @@ +#ifndef QUERY_ +#define QUERY_ + +#include +#include +#include +#include +#include "IQuery.h" +#include "ResultData.h" + +class QueryData; + +class Query : public IQuery { + friend class Database; + + friend class Transaction; + +public: + ~Query() override; + + bool executeStatement(Database &database, MYSQL *m_sql, std::shared_ptr data) override; + + virtual void executeQuery(Database &database, MYSQL *m_sql, const std::shared_ptr &data); + + my_ulonglong lastInsert(); + + my_ulonglong affectedRows(); + + bool hasMoreResults(); + + void getNextResults(); + + virtual std::shared_ptr buildQueryData(); + + int m_dataReference = 0; + + static std::shared_ptr create(const std::shared_ptr &dbase, const std::string& query); +protected: + Query(const std::shared_ptr &dbase, std::string query); + + std::string m_query; +}; + +class QueryData : public IQueryData { + friend class Query; + +public: + my_ulonglong getLastInsertID() { + return (m_insertIds.empty()) ? 0 : m_insertIds.front(); + } + + my_ulonglong getAffectedRows() { + return (m_affectedRows.empty()) ? 0 : m_affectedRows.front(); + } + + bool hasMoreResults() { + return !m_insertIds.empty() && !m_affectedRows.empty() && !m_results.empty(); + } + + bool getNextResults() { + if (!hasMoreResults()) return false; + m_results.pop_front(); + m_insertIds.pop_front(); + m_affectedRows.pop_front(); + return true; + } + + ResultData &getResult() { + return m_results.front(); + } + + std::deque getResults() { + return m_results; + } + +protected: + std::deque m_affectedRows; + std::deque m_insertIds; + std::deque m_results; + QueryData() = default; +}; + +#endif \ No newline at end of file diff --git a/MySQLOO/source/ResultData.cpp b/src/mysql/ResultData.cpp similarity index 81% rename from MySQLOO/source/ResultData.cpp rename to src/mysql/ResultData.cpp index 694128a..c0d6675 100644 --- a/MySQLOO/source/ResultData.cpp +++ b/src/mysql/ResultData.cpp @@ -1,123 +1,118 @@ -#include "ResultData.h" -#include "IQuery.h" -#include "Database.h" -#include "string.h" -#include -#include - -ResultData::ResultData(unsigned int columnCount, unsigned int rows) { - this->columnCount = columnCount; - this->columns.resize(columnCount); - this->columnTypes.resize(columnCount); - this->rows.reserve(rows); -} - -ResultData::ResultData() : ResultData(0, 0) {} - -//Stores all of the rows of a result set -//This is used so the result set can be free'd and doesn't have to be used in -//another thread (which is not safe) -ResultData::ResultData(MYSQL_RES* result) : ResultData((unsigned int)mysql_num_fields(result), (unsigned int)mysql_num_rows(result)) { - if (columnCount == 0) return; - for (unsigned int i = 0; i < columnCount; i++) { - MYSQL_FIELD *field = mysql_fetch_field_direct(result, i); - columnTypes[i] = field->type; - columns[i] = field->name; - } - MYSQL_ROW currentRow; - //This shouldn't error since mysql_store_results stores ALL rows already - while ((currentRow = mysql_fetch_row(result)) != nullptr) { - unsigned long *lengths = mysql_fetch_lengths(result); - this->rows.emplace_back(lengths, currentRow, columnCount); - } -} - -static bool mysqlStmtFetch(MYSQL_STMT* stmt) { - int result = mysql_stmt_fetch(stmt); - if (result == 0) return true; - if (result == 1) { - const char* errorMessage = mysql_stmt_error(stmt); - int errorCode = mysql_stmt_errno(stmt); - throw MySQLException(errorCode, errorMessage); - } else { - return false; - } -} -static void mysqlStmtBindResult(MYSQL_STMT* stmt, MYSQL_BIND* bind) { - int result = mysql_stmt_bind_result(stmt, bind); - if (result != 0) { - const char* errorMessage = mysql_stmt_error(stmt); - int errorCode = mysql_stmt_errno(stmt); - throw MySQLException(errorCode, errorMessage); - } -} - -//Stores all of the rows of a prepared query -//This needs to be done because the query shouldn't be accessed from a different thread -ResultData::ResultData(MYSQL_STMT* result) : ResultData((unsigned int)mysql_stmt_field_count(result), (unsigned int)mysql_stmt_num_rows(result)) { - if (this->columnCount == 0) return; - MYSQL_RES * metaData = mysql_stmt_result_metadata(result); - if (metaData == nullptr) { throw std::runtime_error("mysql_stmt_result_metadata: Unknown Error"); } - auto f = finally([&] { mysql_free_result(metaData); }); - MYSQL_FIELD* fields = mysql_fetch_fields(metaData); - std::vector binds(columnCount); - std::vector> buffers; - std::vector lengths(columnCount); - //This is needed because C++ is stupid and std::vector is using bit encoding.... - bool* isFieldNullArr = new bool[columnCount]; - auto fieldNullArrFree = finally([&] { - delete[] isFieldNullArr; - }); - for (unsigned int i = 0; i < columnCount; i++) { - columnTypes[i] = fields[i].type; - columns[i] = fields[i].name; - MYSQL_BIND& bind = binds[i]; - bind.buffer_type = MYSQL_TYPE_STRING; - buffers.emplace_back(fields[i].max_length + 2); - bind.buffer = buffers.back().data(); - bind.buffer_length = fields[i].max_length + 1; - bind.length = &lengths[i]; - bind.is_null = &isFieldNullArr[i]; - bind.is_unsigned = 0; - } - mysqlStmtBindResult(result, binds.data()); - while (mysqlStmtFetch(result)) { - this->rows.emplace_back(result, binds.data(), columnCount); - } -} - -ResultData::~ResultData() {} - -ResultDataRow::ResultDataRow(unsigned int columnCount) { - this->columnCount = columnCount; - this->values.resize(columnCount); - this->nullFields.resize(columnCount); -} - -//Datastructure that stores a row of mysql data -ResultDataRow::ResultDataRow(unsigned long *lengths, MYSQL_ROW row, unsigned int columnCount) : ResultDataRow(columnCount) { - for (unsigned int i = 0; i < columnCount; i++) { - if (row[i]) { - this->values[i] = std::string(row[i], lengths[i]); - } else { - if (lengths[i] == 0) { - this->nullFields[i] = true; - } - this->values[i] = ""; - } - } -} - -//Datastructure that stores a row of mysql data of a prepared query -ResultDataRow::ResultDataRow(MYSQL_STMT* statement, MYSQL_BIND* bind, unsigned int columnCount) : ResultDataRow(columnCount) { - for (unsigned int i = 0; i < columnCount; i++) { - if (!*(bind[i].is_null) && bind[i].buffer) { - this->values[i] = std::string((char*)bind[i].buffer, *bind[i].length); - } else { - if (*(bind[i].is_null)) { - this->nullFields[i] = true; - } - this->values[i] = ""; - } - } +#include "ResultData.h" +#include "IQuery.h" +#include "Database.h" +#include + +ResultData::ResultData(unsigned int columnCount, unsigned int rows) { + this->columnCount = columnCount; + this->columns.resize(columnCount); + this->columnTypes.resize(columnCount); + this->rows.reserve(rows); +} + +ResultData::ResultData() : ResultData((unsigned int) 0, (unsigned int) 0) {} //Avoids conflict with pointers + +//Stores all of the rows of a result set +//This is used so the result set can be free'd and doesn't have to be used in +//another thread (which is not safe) +ResultData::ResultData(MYSQL_RES* result) : ResultData((unsigned int)mysql_num_fields(result), (unsigned int)mysql_num_rows(result)) { + if (columnCount == 0) return; + for (unsigned int i = 0; i < columnCount; i++) { + MYSQL_FIELD *field = mysql_fetch_field_direct(result, i); + columnTypes[i] = field->type; + columns[i] = field->name; + } + MYSQL_ROW currentRow; + //This shouldn't error since mysql_store_results stores ALL rows already + while ((currentRow = mysql_fetch_row(result)) != nullptr) { + unsigned long *lengths = mysql_fetch_lengths(result); + this->rows.emplace_back(lengths, currentRow, columnCount); + } +} + +static bool mysqlStmtFetch(MYSQL_STMT* stmt) { + int result = mysql_stmt_fetch(stmt); + if (result == 0) return true; + if (result == 1) { + const char* errorMessage = mysql_stmt_error(stmt); + unsigned int errorCode = mysql_stmt_errno(stmt); + throw MySQLException(errorCode, errorMessage); + } else { + return false; + } +} +static void mysqlStmtBindResult(MYSQL_STMT* stmt, MYSQL_BIND* bind) { + my_bool result = mysql_stmt_bind_result(stmt, bind); + if (result) { + const char* errorMessage = mysql_stmt_error(stmt); + unsigned int errorCode = mysql_stmt_errno(stmt); + throw MySQLException(errorCode, errorMessage); + } +} + +//Stores all of the rows of a prepared query +//This needs to be done because the query shouldn't be accessed from a different thread +ResultData::ResultData(MYSQL_STMT* result, MYSQL_RES* metaData) : ResultData((unsigned int)mysql_stmt_field_count(result), (unsigned int)mysql_stmt_num_rows(result)) { + if (this->columnCount == 0) return; + MYSQL_FIELD* fields = mysql_fetch_fields(metaData); + std::vector binds(columnCount); + std::vector> buffers; + std::vector lengths(columnCount); + //This is needed because C++ is stupid and std::vector is using bit encoding.... + auto* isFieldNullArr = new my_bool[columnCount]; + auto fieldNullArrFree = finally([&] { + delete[] isFieldNullArr; + }); + for (unsigned int i = 0; i < columnCount; i++) { + columnTypes[i] = fields[i].type; + columns[i] = fields[i].name; + MYSQL_BIND& bind = binds[i]; + bind.buffer_type = MYSQL_TYPE_STRING; + buffers.emplace_back(fields[i].max_length + 2); + bind.buffer = buffers.back().data(); + bind.buffer_length = fields[i].max_length + 1; + bind.length = &lengths[i]; + bind.is_null = &isFieldNullArr[i]; + bind.is_unsigned = 0; + } + mysqlStmtBindResult(result, binds.data()); + while (mysqlStmtFetch(result)) { + this->rows.emplace_back(result, binds.data(), columnCount); + } +} + +ResultData::~ResultData() = default; + +ResultDataRow::ResultDataRow(unsigned int columnCount) { + this->columnCount = columnCount; + this->values.resize(columnCount); + this->nullFields.resize(columnCount); +} + +//Datastructure that stores a row of mysql data +ResultDataRow::ResultDataRow(unsigned long *lengths, MYSQL_ROW row, unsigned int columnCount) : ResultDataRow(columnCount) { + for (unsigned int i = 0; i < columnCount; i++) { + if (row[i]) { + this->values[i] = std::string(row[i], lengths[i]); + } else { + if (lengths[i] == 0) { + this->nullFields[i] = true; + } + this->values[i] = ""; + } + } +} + +//Datastructure that stores a row of mysql data of a prepared query +ResultDataRow::ResultDataRow(MYSQL_STMT* statement, MYSQL_BIND* bind, unsigned int columnCount) : ResultDataRow(columnCount) { + for (unsigned int i = 0; i < columnCount; i++) { + if (!*(bind[i].is_null) && bind[i].buffer) { + this->values[i] = std::string((char*)bind[i].buffer, *bind[i].length); + } else { + if (*(bind[i].is_null)) { + this->nullFields[i] = true; + } + this->values[i] = ""; + } + } } \ No newline at end of file diff --git a/MySQLOO/include/ResultData.h b/src/mysql/ResultData.h similarity index 84% rename from MySQLOO/include/ResultData.h rename to src/mysql/ResultData.h index 21e1f70..0f2125f 100644 --- a/MySQLOO/include/ResultData.h +++ b/src/mysql/ResultData.h @@ -12,11 +12,11 @@ class ResultDataRow { std::vector & getValues() { return values; } - bool isFieldNull(int index) { + bool isFieldNull(unsigned int index) { return nullFields[index]; } private: - ResultDataRow(unsigned int columns); + explicit ResultDataRow(unsigned int columns); unsigned long long columnCount = 0; std::vector nullFields; std::vector values; @@ -24,8 +24,8 @@ class ResultDataRow { class ResultData { public: - ResultData(MYSQL_RES* result); - ResultData(MYSQL_STMT* result); + explicit ResultData(MYSQL_RES* result); + ResultData(MYSQL_STMT* result, MYSQL_RES* metaData); ResultData(); ~ResultData(); std::vector & getColumns() { return columns; } diff --git a/src/mysql/Transaction.cpp b/src/mysql/Transaction.cpp new file mode 100644 index 0000000..bd701e5 --- /dev/null +++ b/src/mysql/Transaction.cpp @@ -0,0 +1,81 @@ +#include "Transaction.h" + +#include +#include "errmsg.h" +#include "Database.h" + +bool Transaction::executeStatement(Database &database, MYSQL* connection, std::shared_ptr ptr) { + std::shared_ptr data = std::dynamic_pointer_cast(ptr); + data->setStatus(QUERY_RUNNING); + //This temporarily disables reconnect, since a reconnect + //would rollback (and cancel) a transaction + //Which could lead to parts of the transaction being executed outside of a transaction + //If they are being executed after the reconnect + bool oldReconnectStatus = database.getAutoReconnect(); + database.setSQLAutoReconnect(false); + auto resetReconnectStatus = finally([&] { database.setSQLAutoReconnect(oldReconnectStatus); }); + try { + Transaction::mysqlAutocommit(connection, false); + { + for (auto& query : data->m_queries) { + try { + //Errors are cleared in case this is retrying after losing connection + query.second->setResultStatus(QUERY_NONE); + query.second->setError(""); + query.first->executeQuery(database, connection, query.second); + } catch (const MySQLException& error) { + query.second->setError(error.what()); + query.second->setResultStatus(QUERY_ERROR); + throw error; + } + } + } + mysql_commit(connection); + data->setResultStatus(QUERY_SUCCESS); + Transaction::mysqlAutocommit(connection, true); + } catch (const MySQLException& error) { + //This check makes sure that setting mysqlAutocommit back to true doesn't cause the transaction to fail + //Even though the transaction was executed successfully + if (data->getResultStatus() != QUERY_SUCCESS) { + unsigned int errorCode = error.getErrorCode(); + if (oldReconnectStatus && !data->retried && + (errorCode == CR_SERVER_LOST || errorCode == CR_SERVER_GONE_ERROR)) { + //Because autoreconnect is disabled we want to try and explicitly execute the transaction once more + //if we can get the client to reconnect (reconnect is caused by mysql_ping) + //If this fails we just go ahead and error + database.setSQLAutoReconnect(true); + if (mysql_ping(connection) == 0) { + data->retried = true; + return executeStatement(database, connection, ptr); + } + } + //If this call fails it means that the connection was (probably) lost + //In that case the mysql server rolls back any transaction anyways so it doesn't + //matter if it fails + mysql_rollback(connection); + data->setResultStatus(QUERY_ERROR); + } + //If this fails it probably means that the connection was lost + //In that case autocommit is turned back on anyways (once the connection is reestablished) + //See: https://dev.mysql.com/doc/refman/5.7/en/auto-reconnect.html + mysql_autocommit(connection, true); + data->setError(error.what()); + } + for (auto& pair : data->m_queries) { + pair.second->setResultStatus(data->getResultStatus()); + pair.second->setStatus(QUERY_COMPLETE); + } + data->setStatus(QUERY_COMPLETE); + return true; +} + + +std::shared_ptr Transaction::buildQueryData(const std::deque, std::shared_ptr>>& queries) { + //At this point the transaction is guaranteed to have a referenced table + //since this is always called shortly after transaction:start() + return std::shared_ptr(new TransactionData(queries)); +} + +std::shared_ptr Transaction::create(const std::shared_ptr &database) { + return std::shared_ptr(new Transaction(database)); +} diff --git a/src/mysql/Transaction.h b/src/mysql/Transaction.h new file mode 100644 index 0000000..ac4234d --- /dev/null +++ b/src/mysql/Transaction.h @@ -0,0 +1,43 @@ +#ifndef TRANSACTION_ +#define TRANSACTION_ + +#include +#include +#include +#include +#include +#include "IQuery.h" +#include "Query.h" + + +class TransactionData : public IQueryData { + friend class Transaction; + +public: + std::deque, std::shared_ptr>> m_queries; +protected: + explicit TransactionData(std::deque, std::shared_ptr>> queries) : + m_queries(std::move(queries)) { + }; + + bool retried = false; +}; + +class Transaction : public IQuery { + friend class Database; + +public: + static std::shared_ptr + buildQueryData(const std::deque, std::shared_ptr>> &queries); + + static std::shared_ptr create(const std::shared_ptr &database); + +protected: + bool executeStatement(Database &database, MYSQL *connection, std::shared_ptr data) override; + + explicit Transaction(const std::shared_ptr &database) : IQuery(database) { + + } +}; + +#endif