mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Integrate MySQL module.
This commit is contained in:
parent
0d254ed90b
commit
2ee661ee65
@ -41,6 +41,16 @@ add_library(SqModule MODULE
|
||||
Library/IO.cpp Library/IO.hpp
|
||||
Library/IO/File.cpp Library/IO/File.hpp
|
||||
Library/IO/INI.cpp Library/IO/INI.hpp
|
||||
|
||||
Library/MySQL.cpp Library/MySQL.hpp
|
||||
Library/MySQL/Account.cpp Library/MySQL/Account.hpp
|
||||
Library/MySQL/Common.cpp Library/MySQL/Common.hpp
|
||||
Library/MySQL/Connection.cpp Library/MySQL/Connection.hpp
|
||||
Library/MySQL/Field.cpp Library/MySQL/Field.hpp
|
||||
Library/MySQL/Parameter.cpp Library/MySQL/Parameter.hpp
|
||||
Library/MySQL/ResultSet.cpp Library/MySQL/ResultSet.hpp
|
||||
Library/MySQL/Statement.cpp Library/MySQL/Statement.hpp
|
||||
|
||||
Library/Numeric.cpp Library/Numeric.hpp
|
||||
Library/Numeric/LongInt.cpp Library/Numeric/LongInt.hpp
|
||||
Library/Numeric/Math.cpp Library/Numeric/Math.hpp
|
||||
@ -74,6 +84,8 @@ add_library(SqModule MODULE
|
||||
target_link_libraries(SqModule VCMP Squirrel Sqrat SqSDK)
|
||||
# Link to third-party libraries
|
||||
target_link_libraries(SqModule SimpleINI HashLib B64Lib AES256Lib WhirlpoolLib TinyDir PUGIXML SQLite)
|
||||
# Link to mysql client library
|
||||
target_link_libraries(SqModule mariadbclient)
|
||||
#
|
||||
if(FORCE_32BIT_BIN)
|
||||
set_target_properties(SqModule PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
|
||||
|
13
module/Library/MySQL.cpp
Normal file
13
module/Library/MySQL.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ================================================================================================
|
||||
void Register_MySQL(HSQUIRRELVM vm)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
11
module/Library/MySQL.hpp
Normal file
11
module/Library/MySQL.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Base/Shared.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
|
||||
|
||||
} // Namespace:: SqMod
|
249
module/Library/MySQL/Account.cpp
Normal file
249
module/Library/MySQL/Account.cpp
Normal file
@ -0,0 +1,249 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/Account.hpp"
|
||||
#include "Library/MySQL/Connection.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cstring>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const String Account::s_String = String(_SC(""));
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Account::Typename(HSQUIRRELVM vm)
|
||||
{
|
||||
static const SQChar name[] = _SC("SqMySQLAccount");
|
||||
sq_pushstring(vm, name, sizeof(name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Account::Account(CSStr host, CSStr user, CSStr pass, CSStr name, SQInteger port, CSStr socket)
|
||||
: m_Port(0)
|
||||
, m_Host()
|
||||
, m_User()
|
||||
, m_Pass()
|
||||
, m_Name()
|
||||
, m_Socket()
|
||||
, m_Flags(CLIENT_MULTI_STATEMENTS)
|
||||
, m_SSL_Key()
|
||||
, m_SSL_Cert()
|
||||
, m_SSL_CA()
|
||||
, m_SSL_CA_Path()
|
||||
, m_SSL_Cipher()
|
||||
, m_Options()
|
||||
, m_AutoCommit(true)
|
||||
{
|
||||
// Validate the specified port number
|
||||
if (port >= 0xFFFF)
|
||||
{
|
||||
STHROWF("Port number out of range: " _PRINT_INT_FMT, port);
|
||||
}
|
||||
// Assign the specified port
|
||||
else
|
||||
{
|
||||
m_Port = ConvTo< Uint16 >::From(port);
|
||||
}
|
||||
// Assign the remaining values
|
||||
SetHost(host);
|
||||
SetUser(user);
|
||||
SetPass(pass);
|
||||
SetName(name);
|
||||
SetSocket(socket);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Int32 Account::Cmp(const Account & o) const
|
||||
{
|
||||
if (m_User == o.m_User && m_Pass == o.m_Pass)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (m_User > o.m_User && m_Pass > o.m_Pass)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CSStr Account::ToString() const
|
||||
{
|
||||
return ToStringF("%s:%s@%s:%u", m_User.c_str(), m_Pass.c_str(), m_Host.c_str(), m_Port);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Account::SetHost(CSStr addr)
|
||||
{
|
||||
// Clear the current host address
|
||||
m_Host.assign(_SC(""));
|
||||
// Validate the given address
|
||||
if (!addr || *addr == '\0')
|
||||
{
|
||||
return; // Nothing to set.
|
||||
}
|
||||
// See if there'sa colon in the address
|
||||
CSStr pos = std::strchr(addr, ':');
|
||||
// Should we look for a port number?
|
||||
if (pos != nullptr)
|
||||
{
|
||||
// Assign the address portion
|
||||
m_Host.assign(addr, pos - addr);
|
||||
// Attempt to extract the numeric value
|
||||
const Ulong num = std::strtoul(++pos, nullptr, 10);
|
||||
// Is the port number withing range?
|
||||
if (num > 0xFFFF)
|
||||
{
|
||||
STHROWF("Port number out of range: %lu", num);
|
||||
}
|
||||
// Assign the extracted port number
|
||||
m_Port = ConvTo< Uint16 >::From(num);
|
||||
}
|
||||
// Assign the address as is
|
||||
else
|
||||
{
|
||||
m_Host.assign(addr);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Account::SetPortNum(SQInteger port)
|
||||
{
|
||||
// Validate the specified port number
|
||||
if (port >= 0xFFFF)
|
||||
{
|
||||
STHROWF("Port number out of range: " _PRINT_INT_FMT, port);
|
||||
}
|
||||
// Assign the specified port number
|
||||
m_Port = ConvTo< Uint16 >::From(port);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Account::SetSSL(CSStr key, CSStr cert, CSStr ca, CSStr ca_path, CSStr cipher)
|
||||
{
|
||||
if (!key || *key == '\0')
|
||||
{
|
||||
m_SSL_Key.clear();
|
||||
m_SSL_Cert.clear();
|
||||
m_SSL_CA.clear();
|
||||
m_SSL_CA_Path.clear();
|
||||
m_SSL_Cipher.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_SSL_Key.assign(key ? key : _SC(""));
|
||||
m_SSL_Cert.assign(cert ? cert : _SC(""));
|
||||
m_SSL_CA.assign(ca ? ca : _SC(""));
|
||||
m_SSL_CA_Path.assign(ca_path ? ca_path : _SC(""));
|
||||
m_SSL_Cipher.assign(cipher ? cipher : _SC(""));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Table Account::GetOptionsTable() const
|
||||
{
|
||||
// Allocate an empty table
|
||||
Table tbl(DefaultVM::Get());
|
||||
// Insert every option into the table
|
||||
for (const auto & opt : m_Options)
|
||||
{
|
||||
tbl.SetValue(opt.first.c_str(), opt.second);
|
||||
}
|
||||
// Return the resulted table
|
||||
return tbl;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const String & Account::GetOption(CSStr name) const
|
||||
{
|
||||
// Make sure the specified name is valid
|
||||
if (!name || *name == '\0')
|
||||
{
|
||||
STHROWF("Invalid or empty option name");
|
||||
}
|
||||
// Attempt to find the requested option
|
||||
const Options::const_iterator itr = m_Options.find(name);
|
||||
// Return the result
|
||||
return (itr == m_Options.cend()) ? s_String : itr->second;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Account::SetOption(CSStr name, CSStr value)
|
||||
{
|
||||
// Make sure the specified name is valid
|
||||
if (!name || *name == '\0')
|
||||
{
|
||||
STHROWF("Invalid or empty option name");
|
||||
}
|
||||
// Assign the specified value
|
||||
m_Options[name] = value ? value : _SC("");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Account::RemoveOption(CSStr name)
|
||||
{
|
||||
// Make sure the specified name is valid
|
||||
if (!name || *name == '\0')
|
||||
{
|
||||
STHROWF("Invalid or empty option name");
|
||||
}
|
||||
// Erase the specified value
|
||||
m_Options.erase(name);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Connection Account::Connect() const
|
||||
{
|
||||
return Connection(*this);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Account(Table & sqlns)
|
||||
{
|
||||
sqlns.Bind(_SC("Account")
|
||||
, Class< Account >(sqlns.GetVM(), _SC("SqMySQLAccount"))
|
||||
// Constructors
|
||||
.Ctor< const Account & >()
|
||||
.Ctor< CSStr, CSStr >()
|
||||
.Ctor< CSStr, CSStr, CSStr >()
|
||||
.Ctor< CSStr, CSStr, CSStr, CSStr >()
|
||||
.Ctor< CSStr, CSStr, CSStr, CSStr, SQInteger >()
|
||||
.Ctor< CSStr, CSStr, CSStr, CSStr, SQInteger, CSStr >()
|
||||
// Core Meta-methods
|
||||
.Func(_SC("_cmp"), &Account::Cmp)
|
||||
.SquirrelFunc(_SC("_typename"), &Account::Typename)
|
||||
.Func(_SC("_tostring"), &Account::ToString)
|
||||
// Properties
|
||||
.Prop(_SC("Port"), &Account::GetPortNum, &Account::SetPortNum)
|
||||
.Prop(_SC("Host"), &Account::GetHost, &Account::SetHost)
|
||||
.Prop(_SC("User"), &Account::GetUser, &Account::SetUser)
|
||||
.Prop(_SC("Pass"), &Account::GetPass, &Account::SetPass)
|
||||
.Prop(_SC("Socket"), &Account::GetSocket, &Account::SetSocket)
|
||||
.Prop(_SC("Flags"), &Account::GetFlags, &Account::SetFlags)
|
||||
.Prop(_SC("SSL_Key"), &Account::GetSSL_Key, &Account::SetSSL_Key)
|
||||
.Prop(_SC("SSL_Cert"), &Account::GetSSL_Cert, &Account::SetSSL_Cert)
|
||||
.Prop(_SC("SSL_CA"), &Account::GetSSL_CA, &Account::SetSSL_CA)
|
||||
.Prop(_SC("SSL_CA_Path"), &Account::GetSSL_CA_Path, &Account::SetSSL_CA_Path)
|
||||
.Prop(_SC("SSL_Cipher"), &Account::GetSSL_Cipher, &Account::SetSSL_Cipher)
|
||||
.Prop(_SC("AutoCommit"), &Account::GetAutoCommit, &Account::SetAutoCommit)
|
||||
.Prop(_SC("Options"), &Account::GetOptionsTable)
|
||||
.Prop(_SC("OptionsCount"), &Account::OptionsCount)
|
||||
.Prop(_SC("OptionsEmpty"), &Account::OptionsEmpty)
|
||||
// Member Methods
|
||||
.Func(_SC("EnableFlags"), &Account::EnableFlags)
|
||||
.Func(_SC("DisableFlags"), &Account::DisableFlags)
|
||||
.Func(_SC("SetSSL"), &Account::SetSSL)
|
||||
.Func(_SC("GetOption"), &Account::GetOption)
|
||||
.Func(_SC("SetOption"), &Account::SetOption)
|
||||
.Func(_SC("RemoveOption"), &Account::RemoveOption)
|
||||
.Func(_SC("OptionsClear"), &Account::OptionsClear)
|
||||
.Func(_SC("Connect"), &Account::Connect)
|
||||
);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
411
module/Library/MySQL/Account.hpp
Normal file
411
module/Library/MySQL/Account.hpp
Normal file
@ -0,0 +1,411 @@
|
||||
#pragma once
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/Common.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Helper class containing shared connection information to avoid repetition.
|
||||
*/
|
||||
class Account
|
||||
{
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef std::unordered_map< String, String > Options;
|
||||
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Uint16 m_Port; // Server port.
|
||||
String m_Host; // Host address.
|
||||
String m_User; // User name.
|
||||
String m_Pass; // User password.
|
||||
String m_Name; // Database name.
|
||||
String m_Socket; // Unix socket.
|
||||
Ulong m_Flags; // Client connection flags.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
String m_SSL_Key; // SSL key.
|
||||
String m_SSL_Cert; // SSL certificate.
|
||||
String m_SSL_CA; // SSL certificate authority.
|
||||
String m_SSL_CA_Path; // SSL certificate authority path.
|
||||
String m_SSL_Cipher; // SSL Cipher.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Options m_Options; // Option container.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
bool m_AutoCommit; // Toggle autocommit.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
static const String s_String; // Dummy used to return a reference to a null string.
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base Constructor.
|
||||
*/
|
||||
Account(CSStr host, CSStr user)
|
||||
: Account(host, user, _SC(""), _SC(""), 3306, _SC(""))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base Constructor.
|
||||
*/
|
||||
Account(CSStr host, CSStr user, CSStr pass)
|
||||
: Account(host, user, pass, _SC(""), 3306, _SC(""))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base Constructor.
|
||||
*/
|
||||
Account(CSStr host, CSStr user, CSStr pass, CSStr name)
|
||||
: Account(host, user, pass, name, 3306, _SC(""))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base Constructor.
|
||||
*/
|
||||
Account(CSStr host, CSStr user, CSStr pass, CSStr name, SQInteger port)
|
||||
: Account(host, user, pass, name, port, _SC(""))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base Constructor.
|
||||
*/
|
||||
Account(CSStr host, CSStr user, CSStr pass, CSStr name, SQInteger port, CSStr socket);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
*/
|
||||
Account(const Account & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
Account(Account && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~Account() = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator.
|
||||
*/
|
||||
Account & operator = (const Account & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Account & operator = (Account && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to compare two instances of this type.
|
||||
*/
|
||||
Int32 Cmp(const Account & o) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to convert an instance of this type to a string.
|
||||
*/
|
||||
CSStr ToString() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to retrieve the name from instances of this type.
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the host address specified during creation.
|
||||
*/
|
||||
const String & GetHost() const
|
||||
{
|
||||
return m_Host;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the host address specified during creation.
|
||||
*/
|
||||
void SetHost(CSStr addr);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the user name specified during creation.
|
||||
*/
|
||||
const String & GetUser() const
|
||||
{
|
||||
return m_User;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the user name specified during creation.
|
||||
*/
|
||||
void SetUser(CSStr user)
|
||||
{
|
||||
m_User.assign(user != nullptr ? user : _SC(""));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the password specified during creation.
|
||||
*/
|
||||
const String & GetPass() const
|
||||
{
|
||||
return m_Pass;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the password specified during creation.
|
||||
*/
|
||||
void SetPass(CSStr pass)
|
||||
{
|
||||
m_Pass.assign(pass != nullptr ? pass : _SC(""));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the database name specified during creation.
|
||||
*/
|
||||
const String & GetName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the database name specified during creation.
|
||||
*/
|
||||
void SetName(CSStr name)
|
||||
{
|
||||
m_Name.assign(name != nullptr ? name : _SC(""));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the server port specified during creation.
|
||||
*/
|
||||
Uint16 GetPortNum() const
|
||||
{
|
||||
return m_Port;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the server port specified during creation.
|
||||
*/
|
||||
void SetPortNum(SQInteger port);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the server socket.
|
||||
*/
|
||||
const String & GetSocket() const
|
||||
{
|
||||
return m_Socket;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the server socket.
|
||||
*/
|
||||
void SetSocket(CSStr socket)
|
||||
{
|
||||
m_Socket.assign(socket != nullptr ? socket : _SC(""));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the current client connection flags.
|
||||
*/
|
||||
SQInteger GetFlags() const
|
||||
{
|
||||
return m_Flags;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the current client connection flags.
|
||||
*/
|
||||
void SetFlags(SQInteger flags)
|
||||
{
|
||||
m_Flags = flags;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the current client connection flags.
|
||||
*/
|
||||
void EnableFlags(SQInteger flags)
|
||||
{
|
||||
m_Flags |= flags;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the current client connection flags.
|
||||
*/
|
||||
void DisableFlags(SQInteger flags)
|
||||
{
|
||||
m_Flags |= flags;
|
||||
m_Flags ^= flags;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the SSL key.
|
||||
*/
|
||||
const String & GetSSL_Key() const
|
||||
{
|
||||
return m_SSL_Key;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the SSL key.
|
||||
*/
|
||||
void SetSSL_Key(CSStr key)
|
||||
{
|
||||
m_SSL_Key.assign(key != nullptr ? key : _SC(""));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the SSL certificate.
|
||||
*/
|
||||
const String & GetSSL_Cert() const
|
||||
{
|
||||
return m_SSL_Cert;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the SSL certificate.
|
||||
*/
|
||||
void SetSSL_Cert(CSStr cert)
|
||||
{
|
||||
m_SSL_Cert.assign(cert != nullptr ? cert : _SC(""));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the SSL certificate authority.
|
||||
*/
|
||||
const String & GetSSL_CA() const
|
||||
{
|
||||
return m_SSL_CA;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the SSL certificate authority.
|
||||
*/
|
||||
void SetSSL_CA(CSStr ca)
|
||||
{
|
||||
m_SSL_CA.assign(ca != nullptr ? ca : _SC(""));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the SSL certificate authority path.
|
||||
*/
|
||||
const String & GetSSL_CA_Path() const
|
||||
{
|
||||
return m_SSL_CA_Path;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the SSL certificate authority path.
|
||||
*/
|
||||
void SetSSL_CA_Path(CSStr capath)
|
||||
{
|
||||
m_SSL_CA_Path.assign(capath != nullptr ? capath : _SC(""));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the SSL cipher.
|
||||
*/
|
||||
const String & GetSSL_Cipher() const
|
||||
{
|
||||
return m_SSL_Cipher;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the SSL cipher.
|
||||
*/
|
||||
void SetSSL_Cipher(CSStr cipher)
|
||||
{
|
||||
m_SSL_Cipher.assign(cipher != nullptr ? cipher : _SC(""));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set the SSL information.
|
||||
*/
|
||||
void SetSSL(CSStr key, CSStr cert, CSStr ca, CSStr ca_path, CSStr cipher);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether autocommit is enabled or not.
|
||||
*/
|
||||
bool GetAutoCommit() const
|
||||
{
|
||||
return m_AutoCommit;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set whether autocommit should be enabled or not.
|
||||
*/
|
||||
void SetAutoCommit(bool toggle)
|
||||
{
|
||||
m_AutoCommit = toggle;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the entire options container as a table.
|
||||
*/
|
||||
const Options & GetOptions() const
|
||||
{
|
||||
return m_Options;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the entire options container as a table.
|
||||
*/
|
||||
Table GetOptionsTable() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve a value from the options container.
|
||||
*/
|
||||
const String & GetOption(CSStr name) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set a value in the options container.
|
||||
*/
|
||||
void SetOption(CSStr name, CSStr value);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Remove a value from the options container.
|
||||
*/
|
||||
void RemoveOption(CSStr name);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the number of values in the options container.
|
||||
*/
|
||||
Uint32 OptionsCount() const
|
||||
{
|
||||
return static_cast< Uint32 >(m_Options.size());
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the options container is empty or not.
|
||||
*/
|
||||
bool OptionsEmpty() const
|
||||
{
|
||||
return m_Options.empty();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Remove all the options from the options container.
|
||||
*/
|
||||
void OptionsClear()
|
||||
{
|
||||
m_Options.clear();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create a connection with the current account information.
|
||||
*/
|
||||
Connection Connect() const;
|
||||
};
|
||||
|
||||
} // Namespace:: SqMod
|
1397
module/Library/MySQL/Common.cpp
Normal file
1397
module/Library/MySQL/Common.cpp
Normal file
File diff suppressed because it is too large
Load Diff
691
module/Library/MySQL/Common.hpp
Normal file
691
module/Library/MySQL/Common.hpp
Normal file
@ -0,0 +1,691 @@
|
||||
#pragma once
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Base/Shared.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/Numeric/LongInt.hpp"
|
||||
#include "Library/Utils/Buffer.hpp"
|
||||
#include "Library/Chrono.hpp"
|
||||
#include "Library/Chrono/Date.hpp"
|
||||
#include "Library/Chrono/Datetime.hpp"
|
||||
#include "Library/Chrono/Time.hpp"
|
||||
#include "Library/Chrono/Timestamp.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <unordered_map>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <mysql.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Handle validation.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
#define SQMOD_THROW_CURRENT(x, a) (x).ThrowCurrent(a, __FILE__, __LINE__)
|
||||
#define SQMOD_VALIDATE(x) (x).Validate(__FILE__, __LINE__)
|
||||
#define SQMOD_VALIDATE_CREATED(x) (x).ValidateCreated(__FILE__, __LINE__)
|
||||
#define SQMOD_VALIDATE_PARAM(x, i) (x).ValidateParam((i), __FILE__, __LINE__)
|
||||
#define SQMOD_VALIDATE_FIELD(x, i) (x).ValidateField((i), __FILE__, __LINE__)
|
||||
#define SQMOD_VALIDATE_STEPPED(x) (x).ValidateStepped(__FILE__, __LINE__)
|
||||
#define SQMOD_GET_VALID(x) (x).GetValid(__FILE__, __LINE__)
|
||||
#define SQMOD_GET_CREATED(x) (x).GetCreated(__FILE__, __LINE__)
|
||||
#define SQMOD_GET_STEPPED(x) (x).GetStepped(__FILE__, __LINE__)
|
||||
#else
|
||||
#define SQMOD_THROW_CURRENT(x, a) (x).ThrowCurrent(a)
|
||||
#define SQMOD_VALIDATE(x) (x).Validate()
|
||||
#define SQMOD_VALIDATE_CREATED(x) (x).ValidateCreated()
|
||||
#define SQMOD_VALIDATE_PARAM(x, i) (x).ValidateParam((i))
|
||||
#define SQMOD_VALIDATE_FIELD(x, i) (x).ValidateField((i))
|
||||
#define SQMOD_VALIDATE_STEPPED(x) (x).ValidateStepped()
|
||||
#define SQMOD_GET_VALID(x) (x).GetValid()
|
||||
#define SQMOD_GET_CREATED(x) (x).GetCreated()
|
||||
#define SQMOD_GET_STEPPED(x) (x).GetStepped()
|
||||
#endif // _DEBUG
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Forward declarations.
|
||||
*/
|
||||
struct ConnHnd;
|
||||
struct StmtHnd;
|
||||
struct ResHnd;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class Account;
|
||||
class Column;
|
||||
class Connection;
|
||||
class ResultSet;
|
||||
class Statement;
|
||||
class Transaction;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Common typedefs.
|
||||
*/
|
||||
typedef SharedPtr< ConnHnd > ConnRef;
|
||||
typedef SharedPtr< StmtHnd > StmtRef;
|
||||
typedef SharedPtr< ResHnd > ResRef;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Replicate the values of a script Date type to a database time type.
|
||||
*/
|
||||
void SqDateToMySQLTime(const Date & value, MYSQL_TIME & t);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Replicate the values of a script Date type to a database time type.
|
||||
*/
|
||||
void SqTimeToMySQLTime(const Time & value, MYSQL_TIME & t);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Replicate the values of a script Date type to a database time type.
|
||||
*/
|
||||
void SqDatetimeToMySQLTime(const Datetime & value, MYSQL_TIME & t);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the lowercase name of a MySQL data-type.
|
||||
*/
|
||||
CSStr SqMySQLTypename(enum_field_types type);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the capitalized name of a MySQL data-type.
|
||||
*/
|
||||
CSStr SqMySQLTypenameC(enum_field_types type);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Utility used to convert from database types to known types.
|
||||
*/
|
||||
template < typename T > struct DbConvTo;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for signed 8 bit integer.
|
||||
*/
|
||||
template<> struct DbConvTo< Int8 >
|
||||
{
|
||||
static Int8 From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Int8"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for unsigned 8 bit integer.
|
||||
*/
|
||||
template<> struct DbConvTo< Uint8 >
|
||||
{
|
||||
static Uint8 From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Uint8"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for signed 16 bit integer.
|
||||
*/
|
||||
template<> struct DbConvTo< Int16 >
|
||||
{
|
||||
static Int16 From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Int16"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for unsigned 16 bit integer.
|
||||
*/
|
||||
template<> struct DbConvTo< Uint16 >
|
||||
{
|
||||
static Uint16 From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Uint16"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for signed 32 bit integer.
|
||||
*/
|
||||
template<> struct DbConvTo< Int32 >
|
||||
{
|
||||
static Int32 From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Int32"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for unsigned 32 bit integer.
|
||||
*/
|
||||
template<> struct DbConvTo< Uint32 >
|
||||
{
|
||||
static Uint32 From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Uint32"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for signed 64 bit integer.
|
||||
*/
|
||||
template<> struct DbConvTo< Int64 >
|
||||
{
|
||||
static Int64 From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Int64"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for unsigned 64 bit integer.
|
||||
*/
|
||||
template<> struct DbConvTo< Uint64 >
|
||||
{
|
||||
static Uint64 From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Uint64"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for 32 floating point.
|
||||
*/
|
||||
template<> struct DbConvTo< Float32 >
|
||||
{
|
||||
static Float32 From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Float32"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for 64 floating point.
|
||||
*/
|
||||
template<> struct DbConvTo< Float64 >
|
||||
{
|
||||
static Float64 From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Float64"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Specialization for boolean value.
|
||||
*/
|
||||
template<> struct DbConvTo< bool >
|
||||
{
|
||||
static bool From(CSStr value, Ulong length, enum_field_types type, CSStr tn = _SC("Boolean"));
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* The structure that holds the data associated with a certain connection.
|
||||
*/
|
||||
struct ConnHnd
|
||||
{
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef MYSQL Type; // The managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type* Pointer; // Pointer to the managed type.
|
||||
typedef const Type* ConstPtr; // Constant pointer to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type& Reference; // Reference to the managed type.
|
||||
typedef const Type& ConstRef; // Constant reference to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef MYSQL_RES ResType; // Database result type.
|
||||
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Pointer mPtr; // The connection handle resource.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Uint32 mErrNo; // Last received error string.
|
||||
String mErrStr; // Last received error message.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Uint16 mPort; // Server port.
|
||||
String mHost; // Host address.
|
||||
String mUser; // User name user.
|
||||
String mPass; // User password.
|
||||
String mName; // Database name.
|
||||
String mSocket; // Unix socket.
|
||||
Ulong mFlags; // Client flags.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
String mSSL_Key; // SSL key.
|
||||
String mSSL_Cert; // SSL certificate.
|
||||
String mSSL_CA; // SSL certificate authority.
|
||||
String mSSL_CA_Path; // SSL certificate authority path.
|
||||
String mSSL_Cipher; // SSL Cipher.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
String mCharset; // Default connection character set.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
bool mAutoCommit; // Whether autocommit is enabled on this connection.
|
||||
bool mInTransaction; // Whether the connection is in the middle of a transaction.
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
ConnHnd();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~ConnHnd();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Grab the current error in the connection handle.
|
||||
*/
|
||||
void GrabCurrent();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Grab the current error in the connection handle and throw it.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ThrowCurrent(CCStr act, CCStr file, Int32 line);
|
||||
#else
|
||||
void ThrowCurrent(CCStr act);
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create the connection handle.
|
||||
*/
|
||||
void Create(const Account & acc);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Disconnect the managed connection handle.
|
||||
*/
|
||||
void Disconnect();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Execute a query on the server.
|
||||
*/
|
||||
Uint64 Execute(CSStr query, Ulong size = 0UL);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* The structure that holds the data associated with a certain bind point.
|
||||
*/
|
||||
struct StmtBind
|
||||
{
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef MYSQL_STMT Type; // The managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type* Pointer; // Pointer to the managed type.
|
||||
typedef const Type* ConstPtr; // Constant pointer to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type& Reference; // Reference to the managed type.
|
||||
typedef const Type& ConstRef; // Constant reference to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef MYSQL_BIND BindType; // Database bind type.
|
||||
typedef MYSQL_TIME TimeType; // Database time type.
|
||||
typedef my_bool BoolType; // Database boolean type.
|
||||
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
BoolType mIsNull; // Allows the database to specify if the parameter is null.
|
||||
BoolType mError; // Allows the database if errors occured on this parameter.
|
||||
Buffer mData; // Buffer to store non fundamental data for the parameter.
|
||||
BindType * mBind; // The associated database bind point handle.
|
||||
TimeType mTime; // Structure used to store time data from database.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
union
|
||||
{
|
||||
Uint64 mUint64; // Store unsigned integer values for the parameter.
|
||||
Int64 mInt64; // Store signed integer values for the parameter.
|
||||
Int32 mInt32[2]; // Store 32 bit signed integer values for the parameter.
|
||||
Float64 mFloat64; // Store 32 bit floating point values for the parameter.
|
||||
Float32 mFloat32[2]; // Store 64 bit floating point values for the parameter.
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
StmtBind()
|
||||
: mIsNull(0), mError(0), mData(), mBind(nullptr), mTime(), mUint64(0)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StmtBind(const StmtBind & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
StmtBind(StmtBind && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
StmtBind & operator = (const StmtBind & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
StmtBind & operator = (StmtBind && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the used buffer.
|
||||
*/
|
||||
CStr GetBuffer()
|
||||
{
|
||||
return mData ? mData.Data() : reinterpret_cast< CStr >(&mUint64);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the buffer length.
|
||||
*/
|
||||
Ulong GetLength() const
|
||||
{
|
||||
return (mBind == nullptr) ? 0 : mBind->buffer_length;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Configure the input of a certain statement parameter.
|
||||
*/
|
||||
void SetInput(enum_field_types type, BindType * bind, CCStr buffer = nullptr, Ulong length = 0);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* The structure that holds the data associated with a certain statement handle.
|
||||
*/
|
||||
struct StmtHnd
|
||||
{
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef MYSQL_STMT Type; // The managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type* Pointer; // Pointer to the managed type.
|
||||
typedef const Type* ConstPtr; // Constant pointer to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type& Reference; // Reference to the managed type.
|
||||
typedef const Type& ConstRef; // Constant reference to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef MYSQL_BIND BindType; // Database bind type.
|
||||
typedef MYSQL_TIME TimeType; // Database time type.
|
||||
typedef my_bool BoolType; // Database boolean type.
|
||||
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Pointer mPtr; // The managed statement handle.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Uint32 mErrNo; // Last received error string.
|
||||
String mErrStr; // Last received error message.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Ulong mParams; // Number of parameters in the statement.
|
||||
StmtBind * mBinds; // List of parameter binds.
|
||||
BindType * mMyBinds; // List of parameter binds.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConnRef mConnection; // Reference to the associated connection.
|
||||
String mQuery; // The query string.
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
StmtHnd();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~StmtHnd();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Grab the current error in the associated statement handle.
|
||||
*/
|
||||
void GrabCurrent();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Grab the current error in the associated statement handle and throw it.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ThrowCurrent(CCStr act, CCStr file, Int32 line);
|
||||
#else
|
||||
void ThrowCurrent(CCStr act);
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the associated statement handle and parameter index and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateParam(Uint32 idx, CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateParam(Uint32 idx) const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check whether a specific param index is within range.
|
||||
*/
|
||||
bool CheckParamIndex(Uint32 idx) const
|
||||
{
|
||||
return (idx < mParams);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create the actual statement.
|
||||
*/
|
||||
void Create(const ConnRef & conn, CSStr query);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* The structure that holds the data associated with a certain field.
|
||||
*/
|
||||
struct ResBind
|
||||
{
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef MYSQL_RES Type; // The managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type* Pointer; // Pointer to the managed type.
|
||||
typedef const Type* ConstPtr; // Constant pointer to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type& Reference; // Reference to the managed type.
|
||||
typedef const Type& ConstRef; // Constant reference to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef MYSQL_FIELD FieldType; // Database field type.
|
||||
typedef MYSQL_BIND BindType; // Database bind type.
|
||||
typedef MYSQL_TIME TimeType; // Database time type.
|
||||
typedef MYSQL_ROW RowType; // Database row type.
|
||||
typedef my_bool BoolType; // Database boolean type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef std::unordered_map< String, Uint32 > IndexMap;
|
||||
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
BoolType mIsNull; // Allows the database to specify if the field is null.
|
||||
BoolType mError; // Allows the database if errors occured on this field.
|
||||
Buffer mData; // Buffer to store non fundamental data for the field.
|
||||
BindType * mBind; // The associated database bind point handle.
|
||||
TimeType mTime; // Structure used to retrieve time data from database.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
union
|
||||
{
|
||||
Uint64 mUint64; // Retrieve unsigned integer values from a field.
|
||||
Int64 mInt64; // Retrieve signed integer values from a field.
|
||||
Int32 mInt32[2]; // Retrieve 32 bit signed integer values from a field.
|
||||
Float64 mFloat64; // Retrieve 32 bit floating point values from a field.
|
||||
Float32 mFloat32[2]; // Retrieve 64 bit floating point values from the field.
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
ResBind()
|
||||
: mIsNull(0), mError(0), mData(), mBind(nullptr), mTime(), mUint64(0)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
ResBind(const ResBind & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
ResBind(ResBind && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
ResBind & operator = (const ResBind & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
ResBind & operator = (ResBind && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the used buffer.
|
||||
*/
|
||||
CStr GetBuffer()
|
||||
{
|
||||
return mData ? mData.Data() : reinterpret_cast< CStr >(&mUint64);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the buffer length.
|
||||
*/
|
||||
Ulong GetLength() const
|
||||
{
|
||||
return mBind == nullptr ? 0 : mBind->buffer_length;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Configure the output to match the requirements of a certain field.
|
||||
*/
|
||||
void SetOutput(const FieldType & field, BindType * bind);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* The structure that holds the data associated with a certain result-set handle.
|
||||
*/
|
||||
struct ResHnd
|
||||
{
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef MYSQL_RES Type; // The managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type* Pointer; // Pointer to the managed type.
|
||||
typedef const Type* ConstPtr; // Constant pointer to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type& Reference; // Reference to the managed type.
|
||||
typedef const Type& ConstRef; // Constant reference to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef MYSQL_FIELD FieldType; // Database field type.
|
||||
typedef MYSQL_BIND BindType; // Database bind type.
|
||||
typedef MYSQL_TIME TimeType; // Database time type.
|
||||
typedef MYSQL_ROW RowType; // Database row type.
|
||||
typedef my_bool BoolType; // Database boolean type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef std::unordered_map< String, Uint32 > IndexMap; // Name to index association of fields.
|
||||
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Pointer mPtr; // The managed result-set handle.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Uint32 mFieldCount; // Number of fields in the result-set.
|
||||
Ulong * mLengths; // Data length when the result-set came from a connection.
|
||||
FieldType * mFields; // Fields in the results set.
|
||||
ResBind * mBinds; // Bind wrappers.
|
||||
BindType * mMyBinds; // Bind points.
|
||||
RowType mRow; // Row data.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConnRef mConnection; // Associated connection.
|
||||
StmtRef mStatement; // Associated statement.
|
||||
IndexMap mIndexes; // Field names and their associated index.
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
ResHnd();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~ResHnd();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Grab the current error in the associated statement or connection handle.
|
||||
*/
|
||||
void GrabCurrent();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Grab the current error in the associated statement or connection handle and throw it.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ThrowCurrent(CCStr act, CCStr file, Int32 line);
|
||||
#else
|
||||
void ThrowCurrent(CCStr act);
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the statement handle and field index and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateField(Uint32 idx, CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateField(Uint32 idx) const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check whether a specific field index is within range.
|
||||
*/
|
||||
bool CheckFieldIndex(Uint32 idx) const
|
||||
{
|
||||
return (idx < mFieldCount);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the field index associated with the specified name.
|
||||
*/
|
||||
Uint32 GetFieldIndex(CSStr name);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create the result-set from a Connection.
|
||||
*/
|
||||
void Create(const ConnRef & conn);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create the result-set from a Statement.
|
||||
*/
|
||||
void Create(const StmtRef & stmt);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Returns the current position of the row cursor for the last Next().
|
||||
*/
|
||||
Uint64 RowIndex() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Returns the number of rows in the result set.
|
||||
*/
|
||||
Uint64 RowCount() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the next row from the query.
|
||||
*/
|
||||
bool Next();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Seeks to an arbitrary row in a query result set.
|
||||
*/
|
||||
bool SetRowIndex(Uint64 index);
|
||||
|
||||
};
|
||||
|
||||
} // Namespace:: SqMod
|
402
module/Library/MySQL/Connection.cpp
Normal file
402
module/Library/MySQL/Connection.cpp
Normal file
@ -0,0 +1,402 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/Connection.hpp"
|
||||
#include "Library/MySQL/Account.hpp"
|
||||
#include "Library/MySQL/Statement.hpp"
|
||||
#include "Library/MySQL/ResultSet.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Connection::Typename(HSQUIRRELVM vm)
|
||||
{
|
||||
static const SQChar name[] = _SC("SqMySQLConnection");
|
||||
sq_pushstring(vm, name, sizeof(name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Connection::Validate(CCStr file, Int32 line) const
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL connection reference =>[%s:%d]", file, line);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void Connection::Validate() const
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL connection reference");
|
||||
}
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Connection::ValidateCreated(CCStr file, Int32 line) const
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL connection reference =>[%s:%d]", file, line);
|
||||
}
|
||||
else if (m_Handle->mPtr == nullptr)
|
||||
{
|
||||
SqThrowF("Invalid MySQL connection =>[%s:%d]", file, line);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void Connection::ValidateCreated() const
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL connection reference");
|
||||
}
|
||||
else if (m_Handle->mPtr == nullptr)
|
||||
{
|
||||
SqThrowF("Invalid MySQL connection");
|
||||
}
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ConnRef & Connection::GetValid(CCStr file, Int32 line) const
|
||||
{
|
||||
Validate(file, line);
|
||||
return m_Handle;
|
||||
}
|
||||
#else
|
||||
const ConnRef & Connection::GetValid() const
|
||||
{
|
||||
Validate();
|
||||
return m_Handle;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ConnRef & Connection::GetCreated(CCStr file, Int32 line) const
|
||||
{
|
||||
ValidateCreated(file, line);
|
||||
return m_Handle;
|
||||
}
|
||||
#else
|
||||
const ConnRef & Connection::GetCreated() const
|
||||
{
|
||||
ValidateCreated();
|
||||
return m_Handle;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object Connection::Insert(CSStr query)
|
||||
{
|
||||
// Make sure the specified query is valid
|
||||
if (!query || *query == '\0')
|
||||
{
|
||||
STHROWF("Invalid or empty MySQL query");
|
||||
}
|
||||
// Attempt to execute the specified query
|
||||
else if (mysql_real_query(SQMOD_GET_CREATED(*this)->mPtr, query, std::strlen(query)) != 0)
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Unable to execute MySQL query");
|
||||
}
|
||||
// Return the identifier of the inserted row
|
||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), mysql_insert_id(m_Handle->mPtr));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ResultSet Connection::Query(CSStr query)
|
||||
{
|
||||
// Make sure the specified query is valid
|
||||
if (!query || *query == '\0')
|
||||
{
|
||||
STHROWF("Invalid or empty MySQL query");
|
||||
}
|
||||
// Attempt to execute the specified query
|
||||
else if (mysql_real_query(SQMOD_GET_CREATED(*this)->mPtr, query, std::strlen(query)) != 0)
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Unable to execute MySQL query");
|
||||
}
|
||||
// Return the identifier of the inserted row
|
||||
return ResultSet(m_Handle);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Statement Connection::GetStatement(CSStr query)
|
||||
{
|
||||
return Statement(SQMOD_GET_CREATED(*this), query);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Connection::ExecuteF(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
// Was the query value specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
return sq_throwerror(vm, "Missing query value");
|
||||
}
|
||||
// The connection instance
|
||||
Connection * conn = nullptr;
|
||||
// Attempt to extract the argument values
|
||||
try
|
||||
{
|
||||
conn = Var< Connection * >(vm, 1).value;
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Propagate the error
|
||||
return sq_throwerror(vm, e.what());
|
||||
}
|
||||
// Do we have a valid connection instance?
|
||||
if (!conn)
|
||||
{
|
||||
return sq_throwerror(vm, "Invalid MySQL connection instance");
|
||||
}
|
||||
// Validate the connection info
|
||||
try
|
||||
{
|
||||
SQMOD_VALIDATE_CREATED(*conn);
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Propagate the error
|
||||
return sq_throwerror(vm, e.what());
|
||||
}
|
||||
// Attempt to retrieve the value from the stack as a string
|
||||
StackStrF val(vm, 2);
|
||||
// Have we failed to retrieve the string?
|
||||
if (SQ_FAILED(val.Proc(true)))
|
||||
{
|
||||
return val.mRes; // Propagate the error!
|
||||
}
|
||||
// Make sure the query string is valid
|
||||
else if (!(val.mPtr) || *(val.mPtr) == '\0')
|
||||
{
|
||||
STHROWF("Invalid or empty MySQL query");
|
||||
}
|
||||
// Attempt to execute the specified query
|
||||
try
|
||||
{
|
||||
Var< ULongInt >::push(vm, ULongInt(conn->m_Handle->Execute(val.mPtr, val.mLen)));
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Propagate the error
|
||||
return sq_throwerror(vm, e.what());
|
||||
}
|
||||
// This function returned a value
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Connection::InsertF(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
// Was the query value specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
return sq_throwerror(vm, "Missing query value");
|
||||
}
|
||||
// The connection instance
|
||||
Connection * conn = nullptr;
|
||||
// Attempt to extract the argument values
|
||||
try
|
||||
{
|
||||
conn = Var< Connection * >(vm, 1).value;
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Propagate the error
|
||||
return sq_throwerror(vm, e.what());
|
||||
}
|
||||
// Do we have a valid connection instance?
|
||||
if (!conn)
|
||||
{
|
||||
return sq_throwerror(vm, "Invalid MySQL connection instance");
|
||||
}
|
||||
// Validate the connection info
|
||||
try
|
||||
{
|
||||
SQMOD_VALIDATE_CREATED(*conn);
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Propagate the error
|
||||
return sq_throwerror(vm, e.what());
|
||||
}
|
||||
// Attempt to retrieve the value from the stack as a string
|
||||
StackStrF val(vm, 2);
|
||||
// Have we failed to retrieve the string?
|
||||
if (SQ_FAILED(val.Proc(true)))
|
||||
{
|
||||
return val.mRes; // Propagate the error!
|
||||
}
|
||||
// Make sure the query string is valid
|
||||
else if (!(val.mPtr) || *(val.mPtr) == '\0')
|
||||
{
|
||||
return sq_throwerror(vm, "Invalid or empty MySQL query");
|
||||
}
|
||||
// Attempt to execute the specified query
|
||||
try
|
||||
{
|
||||
if (mysql_real_query(conn->m_Handle->mPtr, val.mPtr, val.mLen) != 0)
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*(conn->m_Handle), "Unable to execute MySQL query");
|
||||
}
|
||||
// Return the identifier of the inserted row
|
||||
Var< ULongInt >::push(vm, ULongInt(mysql_insert_id(conn->m_Handle->mPtr)));
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Propagate the error
|
||||
return sq_throwerror(vm, e.what());
|
||||
}
|
||||
// This function returned a value
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Connection::QueryF(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
// Was the query value specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
return sq_throwerror(vm, "Missing query value");
|
||||
}
|
||||
// The connection instance
|
||||
Connection * conn = nullptr;
|
||||
// Attempt to extract the argument values
|
||||
try
|
||||
{
|
||||
conn = Var< Connection * >(vm, 1).value;
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Propagate the error
|
||||
return sq_throwerror(vm, e.what());
|
||||
}
|
||||
// Do we have a valid connection instance?
|
||||
if (!conn)
|
||||
{
|
||||
return sq_throwerror(vm, "Invalid MySQL connection instance");
|
||||
}
|
||||
// Validate the connection info
|
||||
try
|
||||
{
|
||||
SQMOD_VALIDATE_CREATED(*conn);
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Propagate the error
|
||||
return sq_throwerror(vm, e.what());
|
||||
}
|
||||
// Attempt to retrieve the value from the stack as a string
|
||||
StackStrF val(vm, 2);
|
||||
// Have we failed to retrieve the string?
|
||||
if (SQ_FAILED(val.Proc(true)))
|
||||
{
|
||||
return val.mRes; // Propagate the error!
|
||||
}
|
||||
// Make sure the query string is valid
|
||||
else if (!(val.mPtr) || *(val.mPtr) == '\0')
|
||||
{
|
||||
return sq_throwerror(vm, "Invalid or empty MySQL query");
|
||||
}
|
||||
// Attempt to execute the specified query
|
||||
try
|
||||
{
|
||||
if (mysql_real_query(conn->m_Handle->mPtr, val.mPtr, val.mLen) != 0)
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*(conn->m_Handle), "Unable to execute MySQL query");
|
||||
}
|
||||
// Return a new instance with the obtained result set
|
||||
Var< ResultSet * >::push(vm, new ResultSet(conn->m_Handle));
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Propagate the error
|
||||
return sq_throwerror(vm, e.what());
|
||||
}
|
||||
// This function returned a value
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
LightObj Connection::EscapeString(StackStrF & str)
|
||||
{
|
||||
// Is there even a string to escape?
|
||||
if (str.mLen <= 0)
|
||||
{
|
||||
return LightObj(_SC(""), 0, str.mVM); // Default to empty string
|
||||
}
|
||||
// Allocate a buffer for the given string
|
||||
std::vector< SQChar > buffer(str.mLen * 2 + 1);
|
||||
// Attempt to ecape the specified string
|
||||
const Ulong len = mysql_real_escape_string(m_Handle->mPtr, buffer.data(), str.mPtr, str.mLen);
|
||||
// Return the resulted string
|
||||
return LightObj(buffer.data(), static_cast< SQInteger >(len), str.mVM);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Connection(Table & sqlns)
|
||||
{
|
||||
sqlns.Bind(_SC("Connection")
|
||||
, Class< Connection >(sqlns.GetVM(), _SC("SqMySQLConnection"))
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< const Account & >()
|
||||
// Core Meta-methods
|
||||
.Func(_SC("_cmp"), &Connection::Cmp)
|
||||
.SquirrelFunc(_SC("_typename"), &Connection::Typename)
|
||||
.Func(_SC("_tostring"), &Connection::ToString)
|
||||
// Properties
|
||||
.Prop(_SC("IsValid"), &Connection::IsValid)
|
||||
.Prop(_SC("Connected"), &Connection::IsConnected)
|
||||
.Prop(_SC("References"), &Connection::GetRefCount)
|
||||
.Prop(_SC("ErrNo"), &Connection::GetErrNo)
|
||||
.Prop(_SC("ErrStr"), &Connection::GetErrStr)
|
||||
.Prop(_SC("LastErrNo"), &Connection::GetLastErrNo)
|
||||
.Prop(_SC("LastErrStr"), &Connection::GetLastErrStr)
|
||||
.Prop(_SC("Port"), &Connection::GetPortNum)
|
||||
.Prop(_SC("Host"), &Connection::GetHost)
|
||||
.Prop(_SC("User"), &Connection::GetUser)
|
||||
.Prop(_SC("Pass"), &Connection::GetPass)
|
||||
.Prop(_SC("Name"), &Connection::GetName, &Connection::SetName)
|
||||
.Prop(_SC("Socket"), &Connection::GetSocket)
|
||||
.Prop(_SC("Flags"), &Connection::GetFlags)
|
||||
.Prop(_SC("SSL_Key"), &Connection::GetSSL_Key)
|
||||
.Prop(_SC("SSL_Cert"), &Connection::GetSSL_Cert)
|
||||
.Prop(_SC("SSL_CA"), &Connection::GetSSL_CA)
|
||||
.Prop(_SC("SSL_CA_Path"), &Connection::GetSSL_CA_Path)
|
||||
.Prop(_SC("SSL_Cipher"), &Connection::GetSSL_Cipher)
|
||||
.Prop(_SC("Charset"), &Connection::GetCharset, &Connection::SetCharset)
|
||||
.Prop(_SC("AutoCommit"), &Connection::GetAutoCommit, &Connection::SetAutoCommit)
|
||||
.Prop(_SC("InTransaction"), &Connection::GetInTransaction)
|
||||
// Member Methods
|
||||
.Func(_SC("Disconnect"), &Connection::Disconnect)
|
||||
.Func(_SC("SelectDb"), &Connection::SetName)
|
||||
.Func(_SC("Execute"), &Connection::Execute)
|
||||
.Func(_SC("Insert"), &Connection::Insert)
|
||||
.Func(_SC("Query"), &Connection::Query)
|
||||
.Func(_SC("Statement"), &Connection::GetStatement)
|
||||
//.Func(_SC("Transaction"), &Connection::GetTransaction)
|
||||
.FmtFunc(_SC("EscapeString"), &Connection::EscapeString)
|
||||
// Squirrel Methods
|
||||
.SquirrelFunc(_SC("ExecuteF"), &Connection::ExecuteF)
|
||||
.SquirrelFunc(_SC("InsertF"), &Connection::InsertF)
|
||||
.SquirrelFunc(_SC("QueryF"), &Connection::QueryF)
|
||||
);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
435
module/Library/MySQL/Connection.hpp
Normal file
435
module/Library/MySQL/Connection.hpp
Normal file
@ -0,0 +1,435 @@
|
||||
#pragma once
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/Common.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Allows management and interaction with a connection handle.
|
||||
*/
|
||||
class Connection
|
||||
{
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConnRef m_Handle; // Reference to the actual database connection.
|
||||
|
||||
protected:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed connection handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Validate(CCStr file, Int32 line) const;
|
||||
#else
|
||||
void Validate() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed connection handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateCreated(CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateCreated() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed connection handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ConnRef & GetValid(CCStr file, Int32 line) const;
|
||||
#else
|
||||
const ConnRef & GetValid() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed connection handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ConnRef & GetCreated(CCStr file, Int32 line) const;
|
||||
#else
|
||||
const ConnRef & GetCreated() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Connection()
|
||||
: m_Handle()
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
Connection(const Account & acc)
|
||||
: m_Handle(new ConnHnd())
|
||||
{
|
||||
m_Handle->Create(acc);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
Connection(const ConnRef & conn)
|
||||
: m_Handle(conn)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
*/
|
||||
Connection(const Connection & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
Connection(Connection && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator.
|
||||
*/
|
||||
Connection & operator = (const Connection & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Connection & operator = (Connection && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to compare two instances of this type.
|
||||
*/
|
||||
Int32 Cmp(const Connection & o) const
|
||||
{
|
||||
if (m_Handle.Get() == o.m_Handle.Get())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (m_Handle.Get() > o.m_Handle.Get())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to convert an instance of this type to a string.
|
||||
*/
|
||||
CSStr ToString() const
|
||||
{
|
||||
return m_Handle ? mysql_get_host_info(m_Handle->mPtr) : _SC("");
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to retrieve the name from instances of this type.
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated connection handle.
|
||||
*/
|
||||
const ConnRef & GetHandle() const
|
||||
{
|
||||
return m_Handle;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the managed handle is valid.
|
||||
*/
|
||||
bool IsValid() const
|
||||
{
|
||||
return m_Handle;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the managed connection handle was connected.
|
||||
*/
|
||||
bool IsConnected() const
|
||||
{
|
||||
return m_Handle && (m_Handle->mPtr != nullptr);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Return the number of active references to this connection handle.
|
||||
*/
|
||||
Uint32 GetRefCount() const
|
||||
{
|
||||
return m_Handle.Count();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the current error number.
|
||||
*/
|
||||
SQInteger GetErrNo() const
|
||||
{
|
||||
return static_cast< SQInteger >(mysql_errno(SQMOD_GET_CREATED(*this)->mPtr));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the current error message.
|
||||
*/
|
||||
CSStr GetErrStr() const
|
||||
{
|
||||
return mysql_error(SQMOD_GET_CREATED(*this)->mPtr);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the last received error number.
|
||||
*/
|
||||
SQInteger GetLastErrNo() const
|
||||
{
|
||||
return static_cast< SQInteger >(SQMOD_GET_VALID(*this)->mErrNo);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the last received error message.
|
||||
*/
|
||||
const String & GetLastErrStr() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mErrStr;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection port number.
|
||||
*/
|
||||
SQInteger GetPortNum() const
|
||||
{
|
||||
return static_cast< SQInteger >(SQMOD_GET_VALID(*this)->mPort);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection host address.
|
||||
*/
|
||||
const String & GetHost() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mHost;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection user name.
|
||||
*/
|
||||
const String & GetUser() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mUser;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection password.
|
||||
*/
|
||||
const String & GetPass() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mPass;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the selected database name.
|
||||
*/
|
||||
const String & GetName() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mName;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the selected database name.
|
||||
*/
|
||||
void SetName(CSStr name)
|
||||
{
|
||||
// Validate the specified name
|
||||
if (!name)
|
||||
{
|
||||
STHROWF("Invalid MySQL database name");
|
||||
}
|
||||
// Attempt to select the database with the given name
|
||||
else if (mysql_select_db(SQMOD_GET_CREATED(*this)->mPtr, name) != 0)
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot select MySQL database");
|
||||
}
|
||||
// Remember the database name
|
||||
m_Handle->mName.assign(name);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection socket.
|
||||
*/
|
||||
const String & GetSocket() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mSocket;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection flags.
|
||||
*/
|
||||
SQInteger GetFlags() const
|
||||
{
|
||||
return static_cast< SQInteger >(SQMOD_GET_VALID(*this)->mFlags);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection SSL key.
|
||||
*/
|
||||
const String & GetSSL_Key() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mSSL_Key;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection SSL certificate.
|
||||
*/
|
||||
const String & GetSSL_Cert() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mSSL_Cert;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection SSL certificate authority.
|
||||
*/
|
||||
const String & GetSSL_CA() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mSSL_CA;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection SSL certificate authority path.
|
||||
*/
|
||||
const String & GetSSL_CA_Path() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mSSL_CA_Path;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection SSL cipher.
|
||||
*/
|
||||
const String & GetSSL_Cipher() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mSSL_Cipher;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the default character set for the managed connection.
|
||||
*/
|
||||
const String & GetCharset() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mCharset;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the default character set for the managed connection.
|
||||
*/
|
||||
void SetCharset(CSStr charset)
|
||||
{
|
||||
// Validate the specified string
|
||||
if (!charset)
|
||||
{
|
||||
STHROWF("Invalid charset string");
|
||||
}
|
||||
// Attempt to Set the default character set for the managed connection
|
||||
else if (mysql_set_character_set(SQMOD_GET_CREATED(*this)->mPtr, charset) != 0)
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot apply character set");
|
||||
}
|
||||
// Remember the character set
|
||||
m_Handle->mCharset.assign(charset);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether auto-commit is enabled or not.
|
||||
*/
|
||||
bool GetAutoCommit() const
|
||||
{
|
||||
return SQMOD_GET_VALID((*this))->mAutoCommit;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set whether auto-commit should be enabled or not.
|
||||
*/
|
||||
void SetAutoCommit(bool toggle)
|
||||
{
|
||||
// Attempt to toggle auto-commit if necessary
|
||||
if (SQMOD_GET_CREATED(*this)->mAutoCommit != toggle &&
|
||||
mysql_autocommit(m_Handle->mPtr, toggle) != 0)
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot toggle auto-commit");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Handle->mAutoCommit = toggle;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the connection is in the middle of a transaction.
|
||||
*/
|
||||
bool GetInTransaction() const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->mInTransaction;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Disconnect from the currently connected database.
|
||||
*/
|
||||
void Disconnect()
|
||||
{
|
||||
SQMOD_GET_CREATED(*this)->Disconnect();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Execute a query on the server.
|
||||
*/
|
||||
Object Execute(CSStr query)
|
||||
{
|
||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), SQMOD_GET_CREATED(*this)->Execute(query));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Execute a query on the server.
|
||||
*/
|
||||
Object Insert(CSStr query);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Execute a query on the server.
|
||||
*/
|
||||
ResultSet Query(CSStr query);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create a new statement on the managed connection.
|
||||
*/
|
||||
Statement GetStatement(CSStr query);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create a new transaction on the managed connection.
|
||||
*/
|
||||
Transaction GetTransaction();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Escape unwanted characters from a given string.
|
||||
*/
|
||||
LightObj EscapeString(StackStrF & str);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to execute the specified query.
|
||||
*/
|
||||
static SQInteger ExecuteF(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to execute the specified query.
|
||||
*/
|
||||
static SQInteger InsertF(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to execute the specified query.
|
||||
*/
|
||||
static SQInteger QueryF(HSQUIRRELVM vm);
|
||||
|
||||
};
|
||||
|
||||
} // Namespace:: SqMod
|
572
module/Library/MySQL/Field.cpp
Normal file
572
module/Library/MySQL/Field.cpp
Normal file
@ -0,0 +1,572 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/Field.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static inline bool IsDigitsOnly(CSStr str)
|
||||
{
|
||||
while (std::isdigit(*str) || std::isspace(*str))
|
||||
{
|
||||
++str;
|
||||
}
|
||||
// Return whether we reached the end while searching
|
||||
return *str == '\0';
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Uint32 Field::INVALID_INDEX = std::numeric_limits< Uint32 >::max();
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Field::Typename(HSQUIRRELVM vm)
|
||||
{
|
||||
static const SQChar name[] = _SC("SqMySQLField");
|
||||
sq_pushstring(vm, name, sizeof(name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Field::Validate(CCStr file, Int32 line) const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference =>[%s:%d]", file, line);
|
||||
}
|
||||
// Are we pointing to a valid index?
|
||||
else if (m_Index >= m_Handle->mFieldCount)
|
||||
{
|
||||
SqThrowF("Field index is out of range: %u >= %lu =>[%s:%d]",
|
||||
m_Index, m_Handle->mFieldCount, file, line);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void Field::Validate() const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference");
|
||||
}
|
||||
// Are we pointing to a valid index?
|
||||
else if (m_Index >= m_Handle->mFieldCount)
|
||||
{
|
||||
SqThrowF("Field index is out of range: %u >= %lu", m_Index, m_Handle->mFieldCount);
|
||||
}
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Field::ValidateCreated(CCStr file, Int32 line) const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference =>[%s:%d]", file, line);
|
||||
}
|
||||
// Are we pointing to a valid index?
|
||||
m_Handle->ValidateField(m_Index, file, line);
|
||||
}
|
||||
#else
|
||||
void Field::ValidateCreated() const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference");
|
||||
}
|
||||
// Are we pointing to a valid index?
|
||||
m_Handle->ValidateField(m_Index);
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Field::ValidateStepped(CCStr file, Int32 line) const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference =>[%s:%d]", file, line);
|
||||
}
|
||||
// Do we have a valid row available?
|
||||
else if (m_Handle->mRow == nullptr)
|
||||
{
|
||||
SqThrowF("No row available in MySQL result-set =>[%s:%d]", file, line);
|
||||
}
|
||||
// Are we pointing to a valid index?
|
||||
m_Handle->ValidateField(m_Index, file, line);
|
||||
}
|
||||
#else
|
||||
void Field::ValidateStepped() const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference");
|
||||
}
|
||||
// Do we have a valid row available?
|
||||
else if (m_Handle->mRow == nullptr)
|
||||
{
|
||||
SqThrowF("No row available in MySQL result-set");
|
||||
}
|
||||
// Are we pointing to a valid index?
|
||||
m_Handle->ValidateField(m_Index);
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & Field::GetValid(CCStr file, Int32 line) const
|
||||
{
|
||||
Validate(file, line);
|
||||
return m_Handle;
|
||||
}
|
||||
#else
|
||||
const ResRef & Field::GetValid() const
|
||||
{
|
||||
Validate();
|
||||
return m_Handle;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & Field::GetCreated(CCStr file, Int32 line) const
|
||||
{
|
||||
ValidateCreated(file, line);
|
||||
return m_Handle;
|
||||
}
|
||||
#else
|
||||
const ResRef & Field::GetCreated() const
|
||||
{
|
||||
ValidateCreated();
|
||||
return m_Handle;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & Field::GetStepped(CCStr file, Int32 line) const
|
||||
{
|
||||
ValidateStepped(file, line);
|
||||
return m_Handle;
|
||||
}
|
||||
#else
|
||||
const ResRef & Field::GetStepped() const
|
||||
{
|
||||
ValidateStepped();
|
||||
return m_Handle;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Field::ValidateField(Uint32 idx, CCStr file, Int32 line) const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference =>[%s:%d]", file, line);
|
||||
}
|
||||
// Validate the specified field index
|
||||
m_Handle->ValidateField(idx, file, line);
|
||||
}
|
||||
#else
|
||||
void Field::ValidateField(Uint32 idx) const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference");
|
||||
}
|
||||
// Validate the specified field index
|
||||
m_Handle->ValidateField(idx);
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Field::SetIndex(const Object & field)
|
||||
{
|
||||
// Where the index will be extracted
|
||||
Uint32 idx = INVALID_INDEX;
|
||||
// Grab the object virtual machine
|
||||
HSQUIRRELVM vm = field.GetVM();
|
||||
// Remember the current stack size
|
||||
const StackGuard sg(vm);
|
||||
// Push the specified object onto the stack
|
||||
Var< const Object & >::push(vm, field);
|
||||
// Identify the type of field was given
|
||||
switch (field.GetType())
|
||||
{
|
||||
// Is this a string value?
|
||||
case OT_STRING:
|
||||
{
|
||||
// Obtain the object from the stack as a string
|
||||
StackStrF val(vm, -1);
|
||||
// Validate the result
|
||||
if (SQ_FAILED(val.Proc(false)))
|
||||
{
|
||||
STHROWF("%s", LastErrorString(vm).c_str());
|
||||
}
|
||||
// Is the obtained string empty?
|
||||
else if (val.mLen <= 0)
|
||||
{
|
||||
STHROWF("Cannot use an empty field name");
|
||||
}
|
||||
// Attempt to find a field with the specified name
|
||||
idx = m_Handle->GetFieldIndex(val.mPtr);
|
||||
} break;
|
||||
// Is this an integer value? (or at least can be easily converted to one)
|
||||
case OT_INTEGER:
|
||||
case OT_FLOAT:
|
||||
case OT_BOOL:
|
||||
{
|
||||
idx = ConvTo< Uint32 >::From(PopStackInteger(vm, -1));
|
||||
} break;
|
||||
// Is this an instance that we can extract either a string or integer from it?
|
||||
case OT_INSTANCE:
|
||||
{
|
||||
// Obtain the object from the stack as a string
|
||||
StackStrF val(vm, -1);
|
||||
// Validate the result
|
||||
if (SQ_FAILED(val.Proc(false)))
|
||||
{
|
||||
STHROWF("%s", LastErrorString(vm).c_str());
|
||||
}
|
||||
// Is the obtained string empty?
|
||||
else if (val.mLen <= 0)
|
||||
{
|
||||
STHROWF("Cannot use an empty field name");
|
||||
}
|
||||
// Check if this value is made only of digits
|
||||
else if (IsDigitsOnly(val.mPtr))
|
||||
{
|
||||
idx = ConvNum< Uint32 >::FromStr(val.mPtr);
|
||||
}
|
||||
// Attempt to find a field with the specified name
|
||||
else
|
||||
{
|
||||
idx = m_Handle->GetFieldIndex(val.mPtr);
|
||||
}
|
||||
} break;
|
||||
// We don't recognize this kind of value!
|
||||
default: STHROWF("Unknown field index of type (%s)", SqTypeName(field.GetType()));
|
||||
}
|
||||
// Validate the obtained field index
|
||||
SQMOD_VALIDATE_FIELD(*this, idx);
|
||||
// Assign the new index
|
||||
m_Index = idx;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object Field::GetResultSet() const
|
||||
{
|
||||
return Object();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object Field::GetConnection() const
|
||||
{
|
||||
return Object();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Field::GetBoolean() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< bool >::From(m_Handle->mBinds[m_Index].mUint64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< bool >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Field::GetChar() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< SQChar >::From(m_Handle->mBinds[m_Index].mInt32[0]);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< SQChar >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Field::GetInteger() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
#ifdef _SQ64
|
||||
return ConvTo< SQInteger >::From(m_Handle->mBinds[m_Index].mInt64);
|
||||
#else
|
||||
return ConvTo< SQInteger >::From(m_Handle->mBinds[m_Index].mInt32[0]);
|
||||
#endif // _SQ64
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< SQInteger >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQFloat Field::GetFloat() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
#ifdef SQUSEDOUBLE
|
||||
return ConvTo< SQFloat >::From(m_Handle->mBinds[m_Index].mFloat64);
|
||||
#else
|
||||
return ConvTo< SQFloat >::From(m_Handle->mBinds[m_Index].mFloat32[0]);
|
||||
#endif // SQUSEDOUBLE
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< SQFloat >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Field::GetInt8() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Int8 >::From(m_Handle->mBinds[m_Index].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< Int8 >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Field::GetUint8() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Uint8 >::From(m_Handle->mBinds[m_Index].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< Uint8 >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Field::GetInt16() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Int16 >::From(m_Handle->mBinds[m_Index].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< Int16 >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Field::GetUint16() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Uint16 >::From(m_Handle->mBinds[m_Index].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< Uint16 >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Field::GetInt32() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Int32 >::From(m_Handle->mBinds[m_Index].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< Int32 >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Field::GetUint32() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Uint32 >::From(m_Handle->mBinds[m_Index].mInt64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< Uint32 >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object Field::GetInt64() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Obtain the initial stack size
|
||||
const StackGuard sg;
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return Object(SqTypeIdentity< SLongInt >{}, SqVM(),
|
||||
ConvTo< Int64 >::From(m_Handle->mBinds[m_Index].mInt64));
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return Object(SqTypeIdentity< SLongInt >{}, SqVM(),
|
||||
DbConvTo< Int64 >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object Field::GetUint64() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Obtain the initial stack size
|
||||
const StackGuard sg;
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(),
|
||||
ConvTo< Uint64 >::From(m_Handle->mBinds[m_Index].mUint64));
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(),
|
||||
DbConvTo< Uint64 >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQFloat Field::GetFloat32() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Float32 >::From(m_Handle->mBinds[m_Index].mFloat32[0]);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< Float32 >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQFloat Field::GetFloat64() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Should we retrieve the value from the bind wrapper?
|
||||
if (m_Handle->mStatement)
|
||||
{
|
||||
return ConvTo< Float64 >::From(m_Handle->mBinds[m_Index].mFloat64);
|
||||
}
|
||||
// Retrieve the value directly from the row
|
||||
return DbConvTo< Float64 >::From(m_Handle->mRow[m_Index],
|
||||
m_Handle->mLengths[m_Index],
|
||||
m_Handle->mFields[m_Index].type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object Field::GetString() const
|
||||
{
|
||||
SQMOD_VALIDATE_STEPPED(*this);
|
||||
// Obtain the initial stack size
|
||||
const StackGuard sg;
|
||||
// Retrieve the value directly from the row and push it on the stack
|
||||
sq_pushstring(DefaultVM::Get(), m_Handle->mRow[m_Index], m_Handle->mLengths[m_Index]);
|
||||
// Obtain the object from the stack
|
||||
Object stro(-1, DefaultVM::Get());
|
||||
// Restore the stack
|
||||
sg.Restore();
|
||||
// Return it the string object
|
||||
return stro;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object Field::GetBuffer() const
|
||||
{
|
||||
return NullObject();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object Field::GetBlob() const
|
||||
{
|
||||
return NullObject();
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Field(Table & sqlns)
|
||||
{
|
||||
sqlns.Bind(_SC("Field"),
|
||||
Class< Field >(sqlns.GetVM(), _SC("SqMySQLField"))
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< const Field & >()
|
||||
// Meta-methods
|
||||
.Func(_SC("_cmp"), &Field::Cmp)
|
||||
.SquirrelFunc(_SC("_typename"), &Field::Typename)
|
||||
.Func(_SC("_tostring"), &Field::ToString)
|
||||
// Properties
|
||||
.Prop(_SC("IsValid"), &Field::IsValid)
|
||||
.Prop(_SC("References"), &Field::GetRefCount)
|
||||
.Prop(_SC("Index"), &Field::GetIndex)
|
||||
.Prop(_SC("ResultSet"), &Field::GetResultSet)
|
||||
.Prop(_SC("Connection"), &Field::GetConnection)
|
||||
.Prop(_SC("Bool"), &Field::GetBoolean)
|
||||
.Prop(_SC("Boolean"), &Field::GetBoolean)
|
||||
.Prop(_SC("Char"), &Field::GetChar)
|
||||
.Prop(_SC("Integer"), &Field::GetInteger)
|
||||
.Prop(_SC("Float"), &Field::GetFloat)
|
||||
.Prop(_SC("Int8"), &Field::GetInt8)
|
||||
.Prop(_SC("Uint8"), &Field::GetUint8)
|
||||
.Prop(_SC("Int16"), &Field::GetInt16)
|
||||
.Prop(_SC("Uint16"), &Field::GetUint16)
|
||||
.Prop(_SC("Int32"), &Field::GetInt32)
|
||||
.Prop(_SC("Uint32"), &Field::GetUint32)
|
||||
.Prop(_SC("Int64"), &Field::GetInt64)
|
||||
.Prop(_SC("Uint64"), &Field::GetUint64)
|
||||
.Prop(_SC("Float32"), &Field::GetFloat32)
|
||||
.Prop(_SC("Float64"), &Field::GetFloat64)
|
||||
.Prop(_SC("String"), &Field::GetString)
|
||||
.Prop(_SC("Buffer"), &Field::GetBuffer)
|
||||
.Prop(_SC("Blob"), &Field::GetBlob)
|
||||
// Member Methods
|
||||
.Func(_SC("Release"), &Field::Release)
|
||||
);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
382
module/Library/MySQL/Field.hpp
Normal file
382
module/Library/MySQL/Field.hpp
Normal file
@ -0,0 +1,382 @@
|
||||
#pragma once
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/Common.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Used to manage and interact with fields from result-sets.
|
||||
*/
|
||||
class Field
|
||||
{
|
||||
// --------------------------------------------------------------------------------------------
|
||||
friend class ResultSet;
|
||||
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Uint32 m_Index; // The actual index of the referenced field.
|
||||
ResRef m_Handle; // Reference to the actual database result-set.
|
||||
|
||||
protected:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the associated result-set handle and field index, and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Validate(CCStr file, Int32 line) const;
|
||||
#else
|
||||
void Validate() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the associated result-set handle and field index, and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateCreated(CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateCreated() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the associated result-set handle, field index and row, and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateStepped(CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateStepped() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the associated result-set handle and field index, and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & GetValid(CCStr file, Int32 line) const;
|
||||
#else
|
||||
const ResRef & GetValid() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the associated result-set handle and field index, and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & GetCreated(CCStr file, Int32 line) const;
|
||||
#else
|
||||
const ResRef & GetCreated() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the associated result-set handle field index and row, and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & GetStepped(CCStr file, Int32 line) const;
|
||||
#else
|
||||
const ResRef & GetStepped() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the associated result-set handle and field index, and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateField(Uint32 idx, CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateField(Uint32 idx) const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the index to the specified value.
|
||||
*/
|
||||
void SetIndex(Int32 idx)
|
||||
{
|
||||
SQMOD_VALIDATE_FIELD(*this, idx);
|
||||
// Assign the new index
|
||||
m_Index = idx;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the index to the specified value.
|
||||
*/
|
||||
void SetIndex(CSStr name)
|
||||
{
|
||||
SetIndex(SQMOD_GET_CREATED(*this)->GetFieldIndex(name));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the index to the specified value.
|
||||
*/
|
||||
void SetIndex(const Object & field);
|
||||
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
static const Uint32 INVALID_INDEX; // Value that represents an invalid index.
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor (null).
|
||||
*/
|
||||
Field()
|
||||
: m_Index(INVALID_INDEX), m_Handle()
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* No field constructor.
|
||||
*/
|
||||
Field(const ResRef & rset)
|
||||
: m_Index(INVALID_INDEX), m_Handle(rset)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Index constructor.
|
||||
*/
|
||||
Field(const ResRef & rset, Uint32 idx)
|
||||
: m_Index(idx), m_Handle(rset)
|
||||
{
|
||||
SQMOD_VALIDATE_FIELD(*this, m_Index);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Name constructor.
|
||||
*/
|
||||
Field(const ResRef & rset, CSStr name)
|
||||
: m_Index(rset ? rset->GetFieldIndex(name) : -1), m_Handle(rset)
|
||||
{
|
||||
SQMOD_VALIDATE_FIELD(*this, m_Index);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Dynamic constructor.
|
||||
*/
|
||||
Field(const ResRef & rset, const Object & field)
|
||||
: m_Index(INVALID_INDEX), m_Handle(rset)
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
STHROWF("Invalid MySQL result-set reference");
|
||||
}
|
||||
// Extract the index
|
||||
SetIndex(field);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
*/
|
||||
Field(const Field & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
Field(Field && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator.
|
||||
*/
|
||||
Field & operator = (const Field & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Field & operator = (Field && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Perform an equality comparison between two result-set field indexes.
|
||||
*/
|
||||
bool operator == (const Field & o) const
|
||||
{
|
||||
return (m_Index == o.m_Index);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Perform an inequality comparison between two result-set field indexes.
|
||||
*/
|
||||
bool operator != (const Field & o) const
|
||||
{
|
||||
return (m_Index != o.m_Index);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Implicit conversion to boolean for use in boolean operations.
|
||||
*/
|
||||
operator bool () const
|
||||
{
|
||||
return (m_Handle && m_Handle->CheckFieldIndex(m_Index));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to compare two instances of this type.
|
||||
*/
|
||||
Int32 Cmp(const Field & o) const
|
||||
{
|
||||
if (m_Index == o.m_Index)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (m_Index > o.m_Index)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to convert an instance of this type to a string.
|
||||
*/
|
||||
CSStr ToString() const
|
||||
{
|
||||
CSStr val = nullptr;
|
||||
// Can we attempt to return the parameter name?
|
||||
if (m_Handle && m_Handle->CheckFieldIndex(m_Index))
|
||||
{
|
||||
val = m_Handle->mFields[m_Index].name;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = ToStrF(_SC("%d"), m_Index);
|
||||
}
|
||||
// Return the value if valid
|
||||
return val ? val : _SC("");
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to retrieve the name from instances of this type.
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the field is valid.
|
||||
*/
|
||||
bool IsValid() const
|
||||
{
|
||||
return m_Handle; // An invalid result-set means an invalid field
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Return the number of active references to the associated result-set handle.
|
||||
*/
|
||||
Uint32 GetRefCount() const
|
||||
{
|
||||
return m_Handle.Count();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the referenced field index.
|
||||
*/
|
||||
SQInteger GetIndex() const
|
||||
{
|
||||
return ConvTo< SQInteger >::From(m_Index);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the referenced database result-set.
|
||||
*/
|
||||
Object GetResultSet() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the referenced database connection.
|
||||
*/
|
||||
Object GetConnection() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Release the reference to the referenced database result-set and field index.
|
||||
*/
|
||||
void Release()
|
||||
{
|
||||
m_Handle.Reset();
|
||||
m_Index = INVALID_INDEX;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a boolean value.
|
||||
*/
|
||||
bool GetBoolean() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a character.
|
||||
*/
|
||||
SQChar GetChar() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a native script integer.
|
||||
*/
|
||||
SQInteger GetInteger() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a native script floating point.
|
||||
*/
|
||||
SQFloat GetFloat() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a signed 8 bit integer value.
|
||||
*/
|
||||
SQInteger GetInt8() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as an unsigned 8 bit integer value.
|
||||
*/
|
||||
SQInteger GetUint8() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a signed 16 bit integer value.
|
||||
*/
|
||||
SQInteger GetInt16() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as an unsigned 16 bit integer value.
|
||||
*/
|
||||
SQInteger GetUint16() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a signed 32 bit integer value.
|
||||
*/
|
||||
SQInteger GetInt32() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as an unsigned 32 bit integer value.
|
||||
*/
|
||||
SQInteger GetUint32() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a signed 64 bit integer value.
|
||||
*/
|
||||
Object GetInt64() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as an unsigned 64 bit integer value.
|
||||
*/
|
||||
Object GetUint64() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a 32 bit floating point value.
|
||||
*/
|
||||
SQFloat GetFloat32() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a 64 bit floating point value.
|
||||
*/
|
||||
SQFloat GetFloat64() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a string value.
|
||||
*/
|
||||
Object GetString() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a memory buffer.
|
||||
*/
|
||||
Object GetBuffer() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the referenced field as a memory blob.
|
||||
*/
|
||||
Object GetBlob() const;
|
||||
};
|
||||
|
||||
} // Namespace:: SqMod
|
10
module/Library/MySQL/Parameter.cpp
Normal file
10
module/Library/MySQL/Parameter.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/Parameter.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
} // Namespace:: SqMod
|
51
module/Library/MySQL/Parameter.hpp
Normal file
51
module/Library/MySQL/Parameter.hpp
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef _SQMYSQL_PARAMETER_HPP_
|
||||
#define _SQMYSQL_PARAMETER_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/Common.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
class Parameter
|
||||
{
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Parameter();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
*/
|
||||
Parameter(const Parameter & o);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
Parameter(Parameter && o);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~Parameter();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator.
|
||||
*/
|
||||
Parameter & operator = (const Parameter & o);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Parameter & operator = (Parameter && o);
|
||||
|
||||
};
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _SQMYSQL_PARAMETER_HPP_
|
287
module/Library/MySQL/ResultSet.cpp
Normal file
287
module/Library/MySQL/ResultSet.cpp
Normal file
@ -0,0 +1,287 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/ResultSet.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cstdlib>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger ResultSet::Typename(HSQUIRRELVM vm)
|
||||
{
|
||||
static const SQChar name[] = _SC("SqMySQLResultSet");
|
||||
sq_pushstring(vm, name, sizeof(name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ResultSet::Validate(CCStr file, Int32 line) const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference =>[%s:%d]", file, line);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void ResultSet::Validate() const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference");
|
||||
}
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ResultSet::ValidateCreated(CCStr file, Int32 line) const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference =>[%s:%d]", file, line);
|
||||
}
|
||||
else if (m_Handle->mPtr == nullptr)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set =>[%s:%d]", file, line);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void ResultSet::ValidateCreated() const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference");
|
||||
}
|
||||
else if (m_Handle->mPtr == nullptr)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set");
|
||||
}
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ResultSet::ValidateStepped(CCStr file, Int32 line) const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference =>[%s:%d]", file, line);
|
||||
}
|
||||
// Do we have a valid row available?
|
||||
else if (m_Handle->mRow == nullptr)
|
||||
{
|
||||
SqThrowF("No row available in MySQL result-set =>[%s:%d]", file, line);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void ResultSet::ValidateStepped() const
|
||||
{
|
||||
// Do we have a valid result-set handle?
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL result-set reference");
|
||||
}
|
||||
// Do we have a valid row available?
|
||||
else if (m_Handle->mRow == nullptr)
|
||||
{
|
||||
SqThrowF("No row available in MySQL result-set");
|
||||
}
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & ResultSet::GetValid(CCStr file, Int32 line) const
|
||||
{
|
||||
Validate(file, line);
|
||||
return m_Handle;
|
||||
}
|
||||
#else
|
||||
const ResRef & ResultSet::GetValid() const
|
||||
{
|
||||
Validate();
|
||||
return m_Handle;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & ResultSet::GetCreated(CCStr file, Int32 line) const
|
||||
{
|
||||
ValidateCreated(file, line);
|
||||
return m_Handle;
|
||||
}
|
||||
#else
|
||||
const ResRef & ResultSet::GetCreated() const
|
||||
{
|
||||
ValidateCreated();
|
||||
return m_Handle;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & ResultSet::GetStepped(CCStr file, Int32 line) const
|
||||
{
|
||||
ValidateStepped(file, line);
|
||||
return m_Handle;
|
||||
}
|
||||
#else
|
||||
const ResRef & ResultSet::GetStepped() const
|
||||
{
|
||||
ValidateStepped();
|
||||
return m_Handle;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ResultSet::ValidateField(Int32 idx, CCStr file, Int32 line) const
|
||||
{
|
||||
ValidateCreated(file, line);
|
||||
m_Handle->ValidateField(idx, file, line);
|
||||
}
|
||||
#else
|
||||
void ResultSet::ValidateField(Int32 idx) const
|
||||
{
|
||||
ValidateCreated();
|
||||
m_Handle->ValidateField(idx);
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Array ResultSet::GetFieldNames() const
|
||||
{
|
||||
SQMOD_VALIDATE_CREATED(*this);
|
||||
// Grab the number of available fields
|
||||
const SQInteger fcount = ConvTo< SQInteger >::From(m_Handle->mFieldCount);
|
||||
// Grab the array with field instances
|
||||
const ResHnd::FieldType * fields = m_Handle->mFields;
|
||||
// Is there even something to process?
|
||||
if (!fcount || !fields)
|
||||
{
|
||||
return Array(DefaultVM::Get(), 0);
|
||||
}
|
||||
// Allocate an array with the same amount of elements as the number of fields
|
||||
Array arr(DefaultVM::Get(), fcount);
|
||||
// Iterate over all the available fields and insert them into the created array
|
||||
for (SQInteger n = 0; n < fcount; ++n)
|
||||
{
|
||||
arr.SetValue(n, (fields[n].name == nullptr) ? ToStrF("<field_%ld>", n) : fields[n].name);
|
||||
}
|
||||
// Return the resulted array
|
||||
return arr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Array ResultSet::GetFieldsArray() const
|
||||
{
|
||||
SQMOD_VALIDATE_CREATED(*this);
|
||||
// Grab the number of available fields
|
||||
const SQInteger fcount = ConvTo< SQInteger >::From(m_Handle->mFieldCount);
|
||||
// Is there even something to process?
|
||||
if (!fcount)
|
||||
{
|
||||
return Array(DefaultVM::Get(), 0);
|
||||
}
|
||||
// Create a field instance to insert as copy
|
||||
Field field(m_Handle);
|
||||
// Allocate an array with the same amount of elements as the number of fields
|
||||
Array arr(DefaultVM::Get(), fcount);
|
||||
// Iterate over all the available fields and insert them into the created array
|
||||
for (SQInteger n = 0; n < fcount; ++n)
|
||||
{
|
||||
// Update the field index
|
||||
field.SetIndex(ConvTo< Int32 >::From(n));
|
||||
// Insert a copy of the field instance into the array
|
||||
arr.SetValue(n, field);
|
||||
}
|
||||
// Return the resulted array
|
||||
return arr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Table ResultSet::GetFieldsTable() const
|
||||
{
|
||||
SQMOD_VALIDATE_CREATED(*this);
|
||||
// Grab the number of available fields
|
||||
const SQInteger fcount = ConvTo< SQInteger >::From(m_Handle->mFieldCount);
|
||||
// Grab the array with field instances
|
||||
const ResHnd::FieldType * fields = m_Handle->mFields;
|
||||
// Is there even something to process?
|
||||
if (!fcount || !fields)
|
||||
{
|
||||
return Table();
|
||||
}
|
||||
// Create a field instance to insert as copy
|
||||
Field field(m_Handle);
|
||||
// Allocate a table to be populated with field instances
|
||||
Table tbl(DefaultVM::Get(), fcount);
|
||||
// Iterate over all the available fields and insert them into the created table
|
||||
for (SQInteger n = 0; n < fcount; ++n)
|
||||
{
|
||||
// Update the field index
|
||||
field.SetIndex(ConvTo< Int32 >::From(n));
|
||||
// Insert a copy of the field instance into the table
|
||||
tbl.SetValue((fields[n].name == nullptr) ? ToStrF("<field_%ld>", n) : fields[n].name, field);
|
||||
}
|
||||
// Return the resulted table
|
||||
return tbl;
|
||||
}
|
||||
|
||||
|
||||
// ================================================================================================
|
||||
void Register_ResultSet(Table & sqlns)
|
||||
{
|
||||
sqlns.Bind(_SC("ResultSet")
|
||||
, Class< ResultSet >(sqlns.GetVM(), _SC("SqMySQLResultSet"))
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< const ResultSet & >()
|
||||
// Core Meta-methods
|
||||
.Func(_SC("_cmp"), &ResultSet::Cmp)
|
||||
.SquirrelFunc(_SC("_typename"), &ResultSet::Typename)
|
||||
.Func(_SC("_tostring"), &ResultSet::ToString)
|
||||
// Properties
|
||||
.Prop(_SC("IsValid"), &ResultSet::IsValid)
|
||||
.Prop(_SC("FieldNames"), &ResultSet::GetFieldNames)
|
||||
.Prop(_SC("FieldsArray"), &ResultSet::GetFieldsArray)
|
||||
.Prop(_SC("FieldsTable"), &ResultSet::GetFieldsTable)
|
||||
.Prop(_SC("RowIndex"), &ResultSet::RowIndex)
|
||||
.Prop(_SC("RowCount"), &ResultSet::RowCount)
|
||||
// Member Methods
|
||||
.Func(_SC("Next"), &ResultSet::Next)
|
||||
.Func(_SC("Step"), &ResultSet::Next)
|
||||
.Func(_SC("SetRowIndex"), &ResultSet::SetRowIndex)
|
||||
.Func(_SC("SetLongRowIndex"), &ResultSet::SetLongRowIndex)
|
||||
.Func(_SC("Get"), &ResultSet::GetField)
|
||||
.Func(_SC("GetField"), &ResultSet::GetField)
|
||||
.Func(_SC("GetBool"), &ResultSet::GetBoolean)
|
||||
.Func(_SC("GetBoolean"), &ResultSet::GetBoolean)
|
||||
.Func(_SC("GetChar"), &ResultSet::GetChar)
|
||||
.Func(_SC("GetInteger"), &ResultSet::GetInteger)
|
||||
.Func(_SC("GetFloat"), &ResultSet::GetFloat)
|
||||
.Func(_SC("GetInt8"), &ResultSet::GetInt8)
|
||||
.Func(_SC("GetUint8"), &ResultSet::GetUint8)
|
||||
.Func(_SC("GetInt16"), &ResultSet::GetInt16)
|
||||
.Func(_SC("GetUint16"), &ResultSet::GetUint16)
|
||||
.Func(_SC("GetInt32"), &ResultSet::GetInt32)
|
||||
.Func(_SC("GetUint32"), &ResultSet::GetUint32)
|
||||
.Func(_SC("GetInt64"), &ResultSet::GetInt64)
|
||||
.Func(_SC("GetUint64"), &ResultSet::GetUint64)
|
||||
.Func(_SC("GetFloat32"), &ResultSet::GetFloat32)
|
||||
.Func(_SC("GetFloat64"), &ResultSet::GetFloat64)
|
||||
.Func(_SC("GetString"), &ResultSet::GetString)
|
||||
.Func(_SC("GetBuffer"), &ResultSet::GetBuffer)
|
||||
.Func(_SC("GetBlob"), &ResultSet::GetBlob)
|
||||
);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
399
module/Library/MySQL/ResultSet.hpp
Normal file
399
module/Library/MySQL/ResultSet.hpp
Normal file
@ -0,0 +1,399 @@
|
||||
#ifndef _SQMYSQL_RESULTSET_HPP_
|
||||
#define _SQMYSQL_RESULTSET_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <utility>
|
||||
|
||||
#include "Library/MySQL/Common.hpp"
|
||||
#include "Library/MySQL/Field.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Allows management and interaction with a result set handle.
|
||||
*/
|
||||
class ResultSet
|
||||
{
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ResRef m_Handle; // Reference to the actual database result-set.
|
||||
|
||||
protected:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed statement handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Validate(CCStr file, Int32 line) const;
|
||||
#else
|
||||
void Validate() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed statement handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateCreated(CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateCreated() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed statement handle and row, and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateStepped(CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateStepped() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed statement handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & GetValid(CCStr file, Int32 line) const;
|
||||
#else
|
||||
const ResRef & GetValid() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed statement handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & GetCreated(CCStr file, Int32 line) const;
|
||||
#else
|
||||
const ResRef & GetCreated() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed statement handle and row, and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const ResRef & GetStepped(CCStr file, Int32 line) const;
|
||||
#else
|
||||
const ResRef & GetStepped() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the statement reference and field index, and throw an error if they're invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateField(Int32 idx, CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateField(Int32 idx) const;
|
||||
#endif // _DEBUG
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
ResultSet()
|
||||
: m_Handle()
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Connection constructor.
|
||||
*/
|
||||
explicit ResultSet(const ConnRef & conn)
|
||||
: m_Handle(new ResHnd())
|
||||
{
|
||||
m_Handle->Create(conn);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Statement constructor.
|
||||
*/
|
||||
explicit ResultSet(const StmtRef & stmt)
|
||||
: m_Handle(new ResHnd())
|
||||
{
|
||||
m_Handle->Create(stmt);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Handle constructor.
|
||||
*/
|
||||
explicit ResultSet(ResRef hnd)
|
||||
: m_Handle(std::move(hnd))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
*/
|
||||
ResultSet(const ResultSet & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
ResultSet(ResultSet && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~ResultSet() = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator.
|
||||
*/
|
||||
ResultSet & operator = (const ResultSet & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
ResultSet & operator = (ResultSet && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to compare two instances of this type.
|
||||
*/
|
||||
Int32 Cmp(const ResultSet & o) const
|
||||
{
|
||||
if (m_Handle.Get() == o.m_Handle.Get())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (m_Handle.Get() > o.m_Handle.Get())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to convert an instance of this type to a string.
|
||||
*/
|
||||
CSStr ToString() const
|
||||
{
|
||||
// Do we have a valid handle?
|
||||
if (m_Handle)
|
||||
{
|
||||
ToStrF("%u", m_Handle->mFieldCount);
|
||||
}
|
||||
// Default to a negative value
|
||||
return _SC("-1");
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to retrieve the name from instances of this type.
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the managed handle is valid.
|
||||
*/
|
||||
bool IsValid() const
|
||||
{
|
||||
return m_Handle;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Returns an array with all the field names available in the managed result set.
|
||||
*/
|
||||
Array GetFieldNames() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Returns an array with wrapper instances for all the field available in the managed result set.
|
||||
*/
|
||||
Array GetFieldsArray() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Returns a table with wrapper instances for all the field available in the managed result set.
|
||||
*/
|
||||
Table GetFieldsTable() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Returns the current position of the row cursor for the last Next().
|
||||
*/
|
||||
Object RowIndex() const
|
||||
{
|
||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), SQMOD_GET_CREATED(*this)->RowIndex());
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Returns the number of rows in the result set.
|
||||
*/
|
||||
Object RowCount() const
|
||||
{
|
||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), SQMOD_GET_CREATED(*this)->RowCount());
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the next row from the query.
|
||||
*/
|
||||
bool Next() const
|
||||
{
|
||||
return SQMOD_GET_CREATED(*this)->Next();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Seeks to an arbitrary row in a query result set.
|
||||
*/
|
||||
bool SetRowIndex(SQInteger index) const
|
||||
{
|
||||
return SQMOD_GET_CREATED(*this)->SetRowIndex(ConvTo< Uint64 >::From(index));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Seeks to an arbitrary row in a query result set.
|
||||
*/
|
||||
bool SetLongRowIndex(const ULongInt & index) const
|
||||
{
|
||||
return SQMOD_GET_CREATED(*this)->SetRowIndex(index.GetNum());
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the field with the specified name or index.
|
||||
*/
|
||||
Field GetField(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a boolean value.
|
||||
*/
|
||||
bool GetBoolean(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetBoolean();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a character.
|
||||
*/
|
||||
SQChar GetChar(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetChar();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a native script integer.
|
||||
*/
|
||||
SQInteger GetInteger(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetInteger();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a native script floating point.
|
||||
*/
|
||||
SQFloat GetFloat(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetFloat();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a signed 8 bit integer value.
|
||||
*/
|
||||
SQInteger GetInt8(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetInt8();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as an unsigned 8 bit integer value.
|
||||
*/
|
||||
SQInteger GetUint8(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetUint8();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a signed 16 bit integer value.
|
||||
*/
|
||||
SQInteger GetInt16(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetInt16();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as an unsigned 16 bit integer value.
|
||||
*/
|
||||
SQInteger GetUint16(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetUint16();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a signed 32 bit integer value.
|
||||
*/
|
||||
SQInteger GetInt32(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetInt32();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as an unsigned 32 bit integer value.
|
||||
*/
|
||||
SQInteger GetUint32(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetUint32();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a signed 64 bit integer value.
|
||||
*/
|
||||
Object GetInt64(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetInt64();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as an unsigned 64 bit integer value.
|
||||
*/
|
||||
Object GetUint64(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetUint64();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a 32 bit floating point value.
|
||||
*/
|
||||
SQFloat GetFloat32(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetFloat32();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a 64 bit floating point value.
|
||||
*/
|
||||
SQFloat GetFloat64(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetFloat64();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a string value.
|
||||
*/
|
||||
Object GetString(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetString();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a memory buffer.
|
||||
*/
|
||||
Object GetBuffer(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetBuffer();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the value inside the specified field as a memory blob.
|
||||
*/
|
||||
Object GetBlob(const Object & field) const
|
||||
{
|
||||
return Field(SQMOD_GET_STEPPED(*this), field).GetBlob();
|
||||
}
|
||||
};
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _SQMYSQL_RESULTSET_HPP_
|
464
module/Library/MySQL/Statement.cpp
Normal file
464
module/Library/MySQL/Statement.cpp
Normal file
@ -0,0 +1,464 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/Statement.hpp"
|
||||
#include "Library/MySQL/Connection.hpp"
|
||||
#include "Library/MySQL/ResultSet.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
#include <cstring>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Statement::Typename(HSQUIRRELVM vm)
|
||||
{
|
||||
static const SQChar name[] = _SC("SqMySQLStatement");
|
||||
sq_pushstring(vm, name, sizeof(name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Statement::Validate(CCStr file, Int32 line) const
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL statement reference =>[%s:%d]", file, line);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void Statement::Validate() const
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL statement reference");
|
||||
}
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Statement::ValidateCreated(CCStr file, Int32 line) const
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL statement reference =>[%s:%d]", file, line);
|
||||
}
|
||||
else if (m_Handle->mPtr == nullptr)
|
||||
{
|
||||
SqThrowF("Invalid MySQL statement =>[%s:%d]", file, line);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void Statement::ValidateCreated() const
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
SqThrowF("Invalid MySQL statement reference");
|
||||
}
|
||||
else if (m_Handle->mPtr == nullptr)
|
||||
{
|
||||
SqThrowF("Invalid MySQL statement");
|
||||
}
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const StmtRef & Statement::GetValid(CCStr file, Int32 line) const
|
||||
{
|
||||
Validate(file, line);
|
||||
return m_Handle;
|
||||
}
|
||||
#else
|
||||
const StmtRef & Statement::GetValid() const
|
||||
{
|
||||
Validate();
|
||||
return m_Handle;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const StmtRef & Statement::GetCreated(CCStr file, Int32 line) const
|
||||
{
|
||||
ValidateCreated(file, line);
|
||||
return m_Handle;
|
||||
}
|
||||
#else
|
||||
const StmtRef & Statement::GetCreated() const
|
||||
{
|
||||
ValidateCreated();
|
||||
return m_Handle;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Statement::ValidateParam(Int32 idx, CCStr file, Int32 line) const
|
||||
{
|
||||
ValidateCreated(file, line);
|
||||
m_Handle->ValidateParam(idx, file, line);
|
||||
}
|
||||
#else
|
||||
void Statement::ValidateParam(Int32 idx) const
|
||||
{
|
||||
ValidateCreated();
|
||||
m_Handle->ValidateParam(idx);
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Statement::Statement(const Connection & connection, CSStr query)
|
||||
: Statement(connection.GetHandle(), query)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Connection Statement::GetConnection() const
|
||||
{
|
||||
return Connection(SQMOD_GET_VALID(*this)->mConnection);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetConnection(const Connection & conn)
|
||||
{
|
||||
SQMOD_GET_VALID(*this)->mConnection = conn.GetHandle();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Int32 Statement::Execute()
|
||||
{
|
||||
// Attempt to bind the parameters
|
||||
if (mysql_stmt_bind_param(SQMOD_GET_CREATED(*this)->mPtr, m_Handle->mMyBinds))
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot bind MySQL statement parameters");
|
||||
}
|
||||
// Attempt to execute the statement
|
||||
else if (mysql_stmt_execute(m_Handle->mPtr))
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot execute MySQL statement");
|
||||
}
|
||||
// Return the number of rows affected by this query
|
||||
return mysql_stmt_affected_rows(m_Handle->mPtr);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Uint32 Statement::Insert()
|
||||
{
|
||||
// Attempt to bind the parameters
|
||||
if (mysql_stmt_bind_param(SQMOD_GET_CREATED(*this)->mPtr, m_Handle->mMyBinds))
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot bind MySQL statement parameters");
|
||||
}
|
||||
// Attempt to execute the statement
|
||||
else if (mysql_stmt_execute(m_Handle->mPtr))
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot execute MySQL statement");
|
||||
}
|
||||
// Return the identifier of the inserted row
|
||||
return mysql_stmt_insert_id(m_Handle->mPtr);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
ResultSet Statement::Query()
|
||||
{
|
||||
// Attempt to bind the parameters
|
||||
if (mysql_stmt_bind_param(SQMOD_GET_CREATED(*this)->mPtr, m_Handle->mMyBinds))
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot bind MySQL statement parameters");
|
||||
}
|
||||
// Attempt to execute the statement
|
||||
else if (mysql_stmt_execute(m_Handle->mPtr))
|
||||
{
|
||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot execute MySQL statement");
|
||||
}
|
||||
// Return the results of this query
|
||||
return ResultSet(m_Handle);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetInt8(Uint32 idx, SQInteger val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_TINY, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mInt64 = ConvTo< Int8 >::From(val);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetUint8(Uint32 idx, SQInteger val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_TINY, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mUint64 = ConvTo< Uint8 >::From(val);
|
||||
// Specify that this value is unsigned
|
||||
m_Handle->mMyBinds[idx].is_unsigned = true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetInt16(Uint32 idx, SQInteger val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_SHORT, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mInt64 = ConvTo< Int16 >::From(val);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetUint16(Uint32 idx, SQInteger val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_SHORT, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mUint64 = ConvTo< Uint16 >::From(val);
|
||||
// Specify that this value is unsigned
|
||||
m_Handle->mMyBinds[idx].is_unsigned = true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetInt32(Uint32 idx, SQInteger val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONG, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mInt64 = ConvTo< Int32 >::From(val);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetUint32(Uint32 idx, SQInteger val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONG, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mUint64 = ConvTo< Uint32 >::From(val);
|
||||
// Specify that this value is unsigned
|
||||
m_Handle->mMyBinds[idx].is_unsigned = true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetInt64(Uint32 idx, SQInteger val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mInt64 = ConvTo< Int64 >::From(val);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetUint64(Uint32 idx, SQInteger val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mUint64 = ConvTo< Uint64 >::From(val);
|
||||
// Specify that this value is unsigned
|
||||
m_Handle->mMyBinds[idx].is_unsigned = true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetSLongInt(Uint32 idx, const SLongInt & val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
||||
// Attempt to assign the numeric value inside the specified object
|
||||
m_Handle->mBinds[idx].mInt64 = val.GetNum();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetULongInt(Uint32 idx, const ULongInt & val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
||||
// Attempt to assign the numeric value inside the specified object
|
||||
m_Handle->mBinds[idx].mUint64 = val.GetNum();
|
||||
// Specify that this value is unsigned
|
||||
m_Handle->mMyBinds[idx].is_unsigned = true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetInteger(Uint32 idx, SQInteger val) const
|
||||
{
|
||||
#ifdef _SQ64
|
||||
SetInt64(idx, val);
|
||||
#else
|
||||
SetInt32(idx, val);
|
||||
#endif // _SQ64
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetFloat32(Uint32 idx, SQFloat val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_FLOAT, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mFloat32[0] = ConvTo< Float32 >::From(val);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetFloat64(Uint32 idx, SQFloat val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_DOUBLE, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mFloat64 = ConvTo< Float64 >::From(val);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetFloat(Uint32 idx, SQFloat val) const
|
||||
{
|
||||
#ifdef SQUSEDOUBLE
|
||||
SetFloat64(idx, val);
|
||||
#else
|
||||
SetFloat32(idx, val);
|
||||
#endif // SQUSEDOUBLE
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetBoolean(Uint32 idx, bool val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_TINY, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
m_Handle->mBinds[idx].mUint64 = val;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetDate(Uint32 idx, const Date & val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_DATE, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
SqDateToMySQLTime(val, m_Handle->mBinds[idx].mTime);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetTime(Uint32 idx, const Time & val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_TIME, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
SqTimeToMySQLTime(val, m_Handle->mBinds[idx].mTime);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetDatetime(Uint32 idx, const Datetime & val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_DATETIME, &(m_Handle->mMyBinds[idx]));
|
||||
// Assign the value to the input
|
||||
SqDatetimeToMySQLTime(val, m_Handle->mBinds[idx].mTime);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetString(Uint32 idx, CSStr val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_STRING, &(m_Handle->mMyBinds[idx]), val, std::strlen(val));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetEnum(Uint32 idx, CSStr val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_ENUM, &(m_Handle->mMyBinds[idx]), val, std::strlen(val));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetSet(Uint32 idx, CSStr val) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_SET, &(m_Handle->mMyBinds[idx]), val, std::strlen(val));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetBlob(Uint32 /*idx*/, Object & /*val*/) const
|
||||
{
|
||||
// TODO...
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetData(Uint32 /*idx*/, Object & /*val*/) const
|
||||
{
|
||||
// TODO...
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Statement::SetNull(Uint32 idx) const
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||
// Attempt to set the input value
|
||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_NULL, &(m_Handle->mMyBinds[idx]));
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Statement(Table & sqlns)
|
||||
{
|
||||
sqlns.Bind(_SC("Statement")
|
||||
, Class< Statement >(sqlns.GetVM(), _SC("SqMySQLStatement"))
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< const Statement & >()
|
||||
.Ctor< const Connection &, CSStr >()
|
||||
// Core Meta-methods
|
||||
.Func(_SC("_cmp"), &Statement::Cmp)
|
||||
.SquirrelFunc(_SC("_typename"), &Statement::Typename)
|
||||
.Func(_SC("_tostring"), &Statement::ToString)
|
||||
// Properties
|
||||
.Prop(_SC("IsValid"), &Statement::IsValid)
|
||||
.Prop(_SC("Connection"), &Statement::GetConnection, &Statement::SetConnection)
|
||||
// Member Methods
|
||||
.Func(_SC("Execute"), &Statement::Execute)
|
||||
.Func(_SC("Insert"), &Statement::Insert)
|
||||
.Func(_SC("Query"), &Statement::Query)
|
||||
.Func(_SC("SetInt8"), &Statement::SetInt8)
|
||||
.Func(_SC("SetUint8"), &Statement::SetUint8)
|
||||
.Func(_SC("SetInt16"), &Statement::SetInt16)
|
||||
.Func(_SC("SetUint16"), &Statement::SetUint16)
|
||||
.Func(_SC("SetInt32"), &Statement::SetInt32)
|
||||
.Func(_SC("SetUint32"), &Statement::SetUint32)
|
||||
.Func(_SC("SetInt64"), &Statement::SetInt64)
|
||||
.Func(_SC("SetUint64"), &Statement::SetUint64)
|
||||
.Func(_SC("SetSLongInt"), &Statement::SetSLongInt)
|
||||
.Func(_SC("SetULongInt"), &Statement::SetULongInt)
|
||||
.Func(_SC("SetInteger"), &Statement::SetInteger)
|
||||
.Func(_SC("SetFloat32"), &Statement::SetFloat32)
|
||||
.Func(_SC("SetFloat64"), &Statement::SetFloat64)
|
||||
.Func(_SC("SetFloat"), &Statement::SetFloat)
|
||||
.Func(_SC("SetBoolean"), &Statement::SetBoolean)
|
||||
.Func(_SC("SetDate"), &Statement::SetDate)
|
||||
.Func(_SC("SetTime"), &Statement::SetTime)
|
||||
.Func(_SC("SetDatetime"), &Statement::SetDatetime)
|
||||
.Func(_SC("SetString"), &Statement::SetString)
|
||||
.Func(_SC("SetEnum"), &Statement::SetEnum)
|
||||
.Func(_SC("SetSet"), &Statement::SetSet)
|
||||
.Func(_SC("SetBlob"), &Statement::SetBlob)
|
||||
.Func(_SC("SetData"), &Statement::SetData)
|
||||
.Func(_SC("SetBuffer"), &Statement::SetData)
|
||||
.Func(_SC("SetNull"), &Statement::SetNull)
|
||||
);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
311
module/Library/MySQL/Statement.hpp
Normal file
311
module/Library/MySQL/Statement.hpp
Normal file
@ -0,0 +1,311 @@
|
||||
#pragma once
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/MySQL/Common.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Allows management and interaction with a statement handle.
|
||||
*/
|
||||
class Statement
|
||||
{
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
StmtRef m_Handle; // Reference to the actual database statement.
|
||||
|
||||
protected:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed statement handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void Validate(CCStr file, Int32 line) const;
|
||||
#else
|
||||
void Validate() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed statement handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateCreated(CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateCreated() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed statement handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const StmtRef & GetValid(CCStr file, Int32 line) const;
|
||||
#else
|
||||
const StmtRef & GetValid() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed statement handle and throw an error if invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
const StmtRef & GetCreated(CCStr file, Int32 line) const;
|
||||
#else
|
||||
const StmtRef & GetCreated() const;
|
||||
#endif // _DEBUG
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the statement reference and parameter index, and throw an error if they're invalid.
|
||||
*/
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
void ValidateParam(Int32 idx, CCStr file, Int32 line) const;
|
||||
#else
|
||||
void ValidateParam(Int32 idx) const;
|
||||
#endif // _DEBUG
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Statement()
|
||||
: m_Handle()
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct a statement under the specified connection using the specified string.
|
||||
*/
|
||||
Statement(const ConnRef & connection, CSStr query)
|
||||
: m_Handle(new StmtHnd())
|
||||
{
|
||||
m_Handle->Create(connection, query);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct a statement under the specified connection using the specified string.
|
||||
*/
|
||||
Statement(const Connection & connection, CSStr query);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
*/
|
||||
Statement(const Statement & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
Statement(Statement && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator.
|
||||
*/
|
||||
Statement & operator = (const Statement & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Statement & operator = (Statement && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to compare two instances of this type.
|
||||
*/
|
||||
Int32 Cmp(const Statement & o) const
|
||||
{
|
||||
if (m_Handle.Get() == o.m_Handle.Get())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (m_Handle.Get() > o.m_Handle.Get())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to convert an instance of this type to a string.
|
||||
*/
|
||||
const String & ToString() const
|
||||
{
|
||||
// Do we have a valid handle?
|
||||
if (m_Handle)
|
||||
{
|
||||
m_Handle->mQuery;
|
||||
}
|
||||
// Default to an empty string
|
||||
return NullString();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to retrieve the name from instances of this type.
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated connection handle.
|
||||
*/
|
||||
const StmtRef & GetHandle() const
|
||||
{
|
||||
return m_Handle;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the managed handle is valid.
|
||||
*/
|
||||
bool IsValid() const
|
||||
{
|
||||
return m_Handle;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the currently associated statement connection.
|
||||
*/
|
||||
Connection GetConnection() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the currently associated statement connection.
|
||||
*/
|
||||
void SetConnection(const Connection & conn);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Execute the statement.
|
||||
*/
|
||||
Int32 Execute();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Execute the statement.
|
||||
*/
|
||||
Uint32 Insert();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Execute the statement.
|
||||
*/
|
||||
ResultSet Query();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a signed 8bit integer to a parameter.
|
||||
*/
|
||||
void SetInt8(Uint32 idx, SQInteger val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign an unsigned 8bit integer to a parameter.
|
||||
*/
|
||||
void SetUint8(Uint32 idx, SQInteger val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a signed 16bit integer to a parameter.
|
||||
*/
|
||||
void SetInt16(Uint32 idx, SQInteger val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign an unsigned 16bit integer to a parameter.
|
||||
*/
|
||||
void SetUint16(Uint32 idx, SQInteger val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a signed 32bit integer to a parameter.
|
||||
*/
|
||||
void SetInt32(Uint32 idx, SQInteger val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign an unsigned 32bit integer to a parameter.
|
||||
*/
|
||||
void SetUint32(Uint32 idx, SQInteger val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a signed 64bit integer to a parameter.
|
||||
*/
|
||||
void SetInt64(Uint32 idx, SQInteger val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign an unsigned 64bit integer to a parameter.
|
||||
*/
|
||||
void SetUint64(Uint32 idx, SQInteger val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a signed long integer to a parameter.
|
||||
*/
|
||||
void SetSLongInt(Uint32 idx, const SLongInt & val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign an unsigned long integer to a parameter.
|
||||
*/
|
||||
void SetULongInt(Uint32 idx, const ULongInt & val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a native integer to a parameter.
|
||||
*/
|
||||
void SetInteger(Uint32 idx, SQInteger val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a 32bit floating point to a parameter.
|
||||
*/
|
||||
void SetFloat32(Uint32 idx, SQFloat val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a 64bit floating point to a parameter.
|
||||
*/
|
||||
void SetFloat64(Uint32 idx, SQFloat val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a native float to a parameter.
|
||||
*/
|
||||
void SetFloat(Uint32 idx, SQFloat val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a boolean to a parameter.
|
||||
*/
|
||||
void SetBoolean(Uint32 idx, bool val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a date to a parameter.
|
||||
*/
|
||||
void SetDate(Uint32 idx, const Date & val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a time to a parameter.
|
||||
*/
|
||||
void SetTime(Uint32 idx, const Time & val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a date and time to a parameter.
|
||||
*/
|
||||
void SetDatetime(Uint32 idx, const Datetime & val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a string to a parameter.
|
||||
*/
|
||||
void SetString(Uint32 idx, CSStr val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign an enumeration to a parameter.
|
||||
*/
|
||||
void SetEnum(Uint32 idx, CSStr val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign an enumeration to a parameter.
|
||||
*/
|
||||
void SetSet(Uint32 idx, CSStr val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a blob to a parameter.
|
||||
*/
|
||||
void SetBlob(Uint32 idx, Object & val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a buffer to a paramete.
|
||||
*/
|
||||
void SetData(Uint32 idx, Object & val) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Assign a null to a parameter.
|
||||
*/
|
||||
void SetNull(Uint32 idx) const;
|
||||
|
||||
};
|
||||
} // Namespace:: SqMod
|
4
module/Vendor/CMakeLists.txt
vendored
4
module/Vendor/CMakeLists.txt
vendored
@ -6,3 +6,7 @@ add_subdirectory(PUGIXML)
|
||||
add_subdirectory(SQLite)
|
||||
add_subdirectory(TinyDir)
|
||||
add_subdirectory(Whirlpool)
|
||||
# Build our own mysql client on windows
|
||||
if(WIN32)
|
||||
add_subdirectory(MDBC)
|
||||
endif(WIN32)
|
||||
|
349
module/Vendor/MDBC/CMakeLists.txt
vendored
Normal file
349
module/Vendor/MDBC/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,349 @@
|
||||
# CMakeLists.txt
|
||||
|
||||
|
||||
# This is the LGPL libmariadb project.
|
||||
PROJECT(mariadb-connector-c C)
|
||||
|
||||
# Is C/C built as subproject?
|
||||
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)
|
||||
|
||||
# do not inherit include directories from the parent project
|
||||
SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
|
||||
FOREACH(V WITH_MYSQLCOMPAT WITH_MSI WITH_SIGNCODE WITH_RTC WITH_UNIT_TESTS WITH_EXTERNAL_ZLIB WITH_SQLITE INSTALL_LAYOUT)
|
||||
SET(${V} ${${OPT}${V}})
|
||||
ENDFOREACH()
|
||||
|
||||
SET(CC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
SET(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR 2)
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR 3)
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH 7)
|
||||
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
MATH(EXPR MARIADB_PACKAGE_VERSION_ID "${CPACK_PACKAGE_VERSION_MAJOR} * 10000 + ${CPACK_PACKAGE_VERSION_MINOR} * 100 + ${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
#Minimum required version is Cmake 2.8.8, since we need to build object libraries
|
||||
IF(WIN32)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
|
||||
ELSE()
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
|
||||
ENDIF()
|
||||
IF(COMMAND CMAKE_POLICY)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
ENDIF()
|
||||
|
||||
#Allow access to non existing targets
|
||||
#IF(CMAKE_VERSION VERSION_GREATER "2.9.9")
|
||||
#CMAKE_POLICY(SET CMP0026 OLD)
|
||||
#CMAKE_POLICY(SET CMP0045 OLD)
|
||||
#CMAKE_POLICY(SET CMP0042 OLD)
|
||||
#ENDIF()
|
||||
|
||||
### Options ###
|
||||
IF(NOT WIN32)
|
||||
OPTION(WITH_MYSQLCOMPAT "creates libmysql* symbolic links" OFF)
|
||||
OPTION(WITH_OPENSSL "enables SSL support" ON)
|
||||
ELSE()
|
||||
OPTION(WITH_OPENSSL "enables SSL support" OFF)
|
||||
OPTION(WITH_SIGNCODE "digitally sign files" OFF)
|
||||
OPTION(WITH_RTC "enables run time checks for debug builds" OFF)
|
||||
ENDIF()
|
||||
|
||||
OPTION(WITH_UNIT_TESTS "builds unittests" OFF)
|
||||
OPTION(WITH_EXTERNAL_ZLIB "Enables use of external zlib" OFF)
|
||||
###############
|
||||
|
||||
IF(WITH_SIGNCODE)
|
||||
IF(WIN32 AND NOT SIGN_OPTIONS)
|
||||
SET(SIGN_OPTIONS /a /t http://timestamp.verisign.com/scripts/timstamp.dll)
|
||||
ELSE()
|
||||
SEPARATE_ARGUMENTS(SIGN_OPTIONS)
|
||||
ENDIF()
|
||||
MARK_AS_ADVANCED(SIGN_OPTIONS)
|
||||
ENDIF()
|
||||
|
||||
IF(WITH_RTC)
|
||||
SET(RTC_OPTIONS "/RTC1 /RTCc")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT IS_SUBPROJECT)
|
||||
IF(MSVC)
|
||||
# Speedup system tests
|
||||
INCLUDE(${CC_SOURCE_DIR}/cmake/WindowsCache.cmake)
|
||||
IF (MSVC)
|
||||
SET(CONFIG_TYPES "DEBUG" "RELEASE" "RELWITHDEBINFO")
|
||||
FOREACH(BUILD_TYPE ${CONFIG_TYPES})
|
||||
FOREACH(COMPILER CXX C)
|
||||
SET(COMPILER_FLAGS "${CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}}")
|
||||
IF (NOT COMPILER_FLAGS STREQUAL "")
|
||||
STRING(REPLACE "/MD" "/MT" COMPILER_FLAGS ${COMPILER_FLAGS})
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
SET(COMPILER_FLAGS "${COMPILER_FLAGS} ${RTC_OPTIONS}")
|
||||
STRING(REPLACE "/Zi" "/ZI" COMPILER_FLAGS ${COMPILER_FLAGS})
|
||||
ENDIF()
|
||||
MESSAGE (STATUS "CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}= ${COMPILER_FLAGS}")
|
||||
SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS} CACHE
|
||||
STRING "overwritten by libmariadb" FORCE)
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
ENDFOREACH()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF(NOT IS_SUBPROJECT)
|
||||
|
||||
# Disable dbug information for release builds
|
||||
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF")
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused -Wno-unused-value -Wno-unused-but-set-variable -Wno-incompatible-pointer-types -Wno-uninitialized")
|
||||
ENDIF()
|
||||
|
||||
# If the build type isn't specified, set to Relwithdebinfo as default.
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE "Relwithdebinfo")
|
||||
ENDIF()
|
||||
|
||||
# various defines for generating include/mysql_version.h
|
||||
|
||||
SET(PROTOCOL_VERSION 10) # we adapted new password option from PHP's mysqlnd !
|
||||
SET(MYSQL_CLIENT_VERSION_MAJOR "5")
|
||||
SET(MYSQL_CLIENT_VERSION_MINOR "5")
|
||||
SET(MYSQL_CLIENT_VERSION_PATCH "1")
|
||||
SET(MYSQL_CLIENT_VERSION "${MYSQL_CLIENT_VERSION_MAJOR}.${MYSQL_CLIENT_VERSION_MINOR}.${MYSQL_CLIENT_VERSION_PATCH}")
|
||||
MATH(EXPR MYSQL_VERSION_ID "${MYSQL_CLIENT_VERSION_MAJOR} * 10000 + ${MYSQL_CLIENT_VERSION_MINOR} * 100 + ${MYSQL_CLIENT_VERSION_PATCH}")
|
||||
|
||||
IF (NOT MYSQL_PORT)
|
||||
SET(MYSQL_PORT 3306)
|
||||
ENDIF ()
|
||||
IF(NOT MYSQL_UNIX_ADDR)
|
||||
SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(${CC_SOURCE_DIR}/cmake/version_info.cmake)
|
||||
INCLUDE(${CC_SOURCE_DIR}/cmake/sign.cmake)
|
||||
INCLUDE("${CC_SOURCE_DIR}/cmake/install.cmake")
|
||||
|
||||
SET(DEFAULT_CHARSET_HOME "${CMAKE_INSTALL_PREFIX}")
|
||||
SET(PLUGINDIR "${CMAKE_INSTALL_PREFIX}/lib/plugin")
|
||||
|
||||
INCLUDE(${CC_SOURCE_DIR}/cmake/SearchLibrary.cmake)
|
||||
|
||||
IF(WITH_EXTERNAL_ZLIB)
|
||||
FIND_PACKAGE(ZLIB QUIET)
|
||||
IF(${ZLIB_FOUND})
|
||||
SET(LIBZ "-z")
|
||||
ENDIF()
|
||||
ELSE()
|
||||
add_subdirectory(zlib)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(TestBigEndian)
|
||||
TEST_BIG_ENDIAN(HAVE_BIGENDIAN)
|
||||
|
||||
IF(UNIX)
|
||||
SEARCH_LIBRARY(DEFAULT_LIB inet_ntoa "c")
|
||||
IF(NOT DEFAULT_LIB)
|
||||
SEARCH_LIBRARY(LIBNSL inet_ntoa "nsl_r;nsl")
|
||||
ENDIF()
|
||||
SEARCH_LIBRARY(DEFAULT_LIB bind "c")
|
||||
IF(NOT DEFAULT_LIB)
|
||||
SEARCH_LIBRARY(LIBBIND bind "bind;socket")
|
||||
ENDIF()
|
||||
SEARCH_LIBRARY(DEFAULT_LIB setsockopt "c")
|
||||
IF(NOT DEFAULT_LIB)
|
||||
SEARCH_LIBRARY(LIBSOCKET setsockopt "socket")
|
||||
ENDIF()
|
||||
SEARCH_LIBRARY(LIBDL dlopen "dl")
|
||||
SEARCH_LIBRARY(LIBM floor m)
|
||||
SEARCH_LIBRARY(LIBPTHREAD pthread_getspecific "pthread;pthreads")
|
||||
SET(EXTRA_LIBS "${LIBNSL}" "${LIBBIND}" "${LIBSOCKET}" "${LIBDL}" "${LIBM}" "${LIBPTHREAD}")
|
||||
FIND_PACKAGE(Threads)
|
||||
#remove possible dups from required libraries
|
||||
LIST(LENGTH SYS_LIBS rllength)
|
||||
IF(${rllength} GREATER 0)
|
||||
LIST(REMOVE_DUPLICATES SYS_LIBS)
|
||||
ENDIF()
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${SYS_LIBS})
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(CMAKE_HAVE_PTHREAD_H)
|
||||
SET(CMAKE_REQUIRED_INCLUDES pthread.h)
|
||||
ENDIF()
|
||||
|
||||
IF(WIN32)
|
||||
SET(HAVE_THREADS 1)
|
||||
ADD_DEFINITIONS(-DHAVE_DLOPEN)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
IF(MSVC)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996" )
|
||||
ENDIF()
|
||||
ELSEIF()
|
||||
SET(HAVE_THREADS ${CMAKE_USE_PTHREADS})
|
||||
ENDIF()
|
||||
|
||||
# check for various include files
|
||||
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckIncludeFiles.cmake)
|
||||
# check for various functions
|
||||
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckFunctions.cmake)
|
||||
# check for various types
|
||||
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckTypes.cmake)
|
||||
|
||||
# Check for OpenSSL
|
||||
IF(WITH_OPENSSL)
|
||||
FIND_PACKAGE(OpenSSL)
|
||||
IF(OPENSSL_FOUND)
|
||||
ADD_DEFINITIONS(-DHAVE_OPENSSL)
|
||||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
|
||||
SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
|
||||
IF(OPENSSL_CRYPTO_LIBRARIES)
|
||||
SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "OpenSSL not found. Please install OpenSSL or disable SSL support via option -DWITH_OPENSSL=Off")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(WITH_SQLITE)
|
||||
ADD_DEFINITIONS(-DHAVE_SQLITE)
|
||||
ENDIF()
|
||||
|
||||
IF(NOT WIN32)
|
||||
INCLUDE(${CC_SOURCE_DIR}/cmake/FindIconv.cmake)
|
||||
ENDIF()
|
||||
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/mysql_version.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/mysql_version.h)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/my_config.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/my_config.h)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/mysql_version.h.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mysql_version.h)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/my_config.h.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/my_config.h)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||
|
||||
IF(WIN32)
|
||||
SET(SYSTEM_LIBS ws2_32 advapi32 kernel32)
|
||||
ELSE()
|
||||
SET(SYSTEM_LIBS ${LIBPTHREAD} ${LIBDL} ${LIBM})
|
||||
IF(ICONV_EXTERNAL)
|
||||
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${ICONV_LIBRARIES})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
IF(OPENSSL_FOUND)
|
||||
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${SSL_LIBRARIES})
|
||||
ENDIF()
|
||||
|
||||
ADD_SUBDIRECTORY(include)
|
||||
ADD_SUBDIRECTORY(libmariadb)
|
||||
ADD_SUBDIRECTORY(plugins)
|
||||
IF(NOT WIN32)
|
||||
ADD_SUBDIRECTORY(mariadb_config)
|
||||
ENDIF()
|
||||
|
||||
IF(IS_DIRECTORY ${CC_SOURCE_DIR}/unittest)
|
||||
IF(WITH_UNIT_TESTS)
|
||||
ADD_SUBDIRECTORY(unittest/mytap)
|
||||
ADD_SUBDIRECTORY(unittest/libmariadb)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(CLIENT_DOCS)
|
||||
INSTALL(DIRECTORY ${CLIENT_DOCS}
|
||||
DESTINATION ${DOCS_INSTALL_DIR_${INSTALL_LAYOUT}})
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(WIN32 AND WITH_MSI AND CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
ADD_SUBDIRECTORY(win/packaging)
|
||||
ENDIF()
|
||||
|
||||
SET(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION "MariaDB Connector/C. A library for connecting to MariaDB and MySQL servers")
|
||||
SET(CPACK_PACKAGE_NAME "mariadb_connector_c")
|
||||
STRING(TOLOWER ${CMAKE_SYSTEM_NAME} system_name)
|
||||
SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-${system_name}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LIB")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
|
||||
INCLUDE(cmake/ConnectorName.cmake)
|
||||
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-src")
|
||||
|
||||
# Build source packages
|
||||
IF(GIT_BUILD_SRCPKG)
|
||||
# get branch name
|
||||
EXECUTE_PROCESS(COMMAND git show-branch OUTPUT_VARIABLE git_branch)
|
||||
STRING(REGEX MATCH "\\[([^]]+)\\]" git_branch ${git_branch})
|
||||
STRING(REGEX REPLACE "\\[|\\]" "" GIT_BRANCH ${git_branch})
|
||||
MESSAGE(STATUS "${GIT_BRANCH}")
|
||||
IF(WIN32)
|
||||
EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip)
|
||||
ELSE()
|
||||
EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip)
|
||||
EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=tar --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar)
|
||||
EXECUTE_PROCESS(COMMAND gzip -9 -f ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
SET(CPACK_SOURCE_IGNORE_FILES
|
||||
\\\\.git/
|
||||
\\\\.gitignore
|
||||
\\\\.gitattributes
|
||||
CMakeCache.txt
|
||||
cmake_dist.cmake
|
||||
CPackSourceConfig.cmake
|
||||
CPackConfig.cmake
|
||||
mariadb_config/mariadb_config.c$
|
||||
.build/
|
||||
html/
|
||||
unittest
|
||||
/cmake_install.cmake
|
||||
/CTestTestfile.cmake
|
||||
/CMakeFiles/
|
||||
/version_resources/
|
||||
/_CPack_Packages/
|
||||
.*gz$
|
||||
.*zip$
|
||||
.*so$
|
||||
.*so.*$
|
||||
.*dll$
|
||||
.*a$
|
||||
.*pdb$
|
||||
/CMakeFiles/
|
||||
/version_resources/
|
||||
/_CPack_Packages/
|
||||
Makefile$
|
||||
include/my_config.h$
|
||||
/autom4te.cache/
|
||||
errmsg.sys$
|
||||
)
|
||||
|
||||
IF(WIN32)
|
||||
SET(CPACK_GENERATOR "ZIP")
|
||||
SET(CPACK_SOURCE_GENERATOR "ZIP")
|
||||
ELSE()
|
||||
SET(CPACK_GENERATOR "TGZ")
|
||||
SET(CPACK_SOURCE_GENERATOR "TGZ")
|
||||
ENDIF()
|
||||
INCLUDE(CPack)
|
||||
|
||||
MESSAGE(STATUS "MariaDB Connector/c configuration:")
|
||||
MESSAGE(STATUS "CPack generation: ${CPACK_GENERATOR}")
|
||||
IF(CLIENT_DOCS)
|
||||
MESSAGE(STATUS "Documentation included from ${CLIENT_DOCS}")
|
||||
ENDIF()
|
||||
MESSAGE(STATUS "SSL support: ${WITH_OPENSSL}")
|
||||
MESSAGE(STATUS "Experimental Sqlite support: ${WITH_SQLITE}")
|
||||
IF(WITH_EXTERNAL_ZLIB)
|
||||
MESSAGE(STATUS "Zlib support: ${WITH_EXTERNAL_ZLIB}")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "Zlib support: yes (using bundled zlib)")
|
||||
ENDIF()
|
||||
MESSAGE(STATUS "Installation layout: ${INSTALL_LAYOUT}")
|
||||
MESSAGE(STATUS "Include files will be installed in ${PREFIX_INSTALL_DIR}/${INCLUDE_INSTALL_DIR}/${SUFFIX_INSTALL_DIR}")
|
||||
MESSAGE(STATUS "Libraries will be installed in ${PREFIX_INSTALL_DIR}/${LIB_INSTALL_DIR}/${LIBSUFFIX_INSTALL_DIR}")
|
||||
MESSAGE(STATUS "Binaries will be installed in ${PREFIX_INSTALL_DIR}/${BIN_INSTALL_DIR}")
|
||||
|
||||
MESSAGE(STATUS "Required: ${CMAKE_REQUIRED_LIBRARIES}")
|
502
module/Vendor/MDBC/COPYING.LIB
vendored
Normal file
502
module/Vendor/MDBC/COPYING.LIB
vendored
Normal file
@ -0,0 +1,502 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
23
module/Vendor/MDBC/README
vendored
Normal file
23
module/Vendor/MDBC/README
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
This is LGPL MariaDB client library that can be used to connect to MySQL
|
||||
or MariaDB.
|
||||
|
||||
This code is based on the LGPL libmysql client library from MySQL 3.23
|
||||
and PHP's mysqlnd extension.
|
||||
|
||||
This product includes PHP software, freely available from
|
||||
<http://www.php.net/software/>
|
||||
|
||||
The following are the main known limitations:
|
||||
|
||||
- double to string conversion for prepared statements
|
||||
doesn't work correctly
|
||||
- support for dynamic columns is not integrated yet
|
||||
- Asynchronus interface is not integrated yet
|
||||
|
||||
If you want to be part of this development effort, you can discuss this at
|
||||
maria-developers@lists.launchpad.org.
|
||||
|
||||
If you are interested in sponsoring this effort, you can contact us at
|
||||
sales@askmonty.org
|
||||
|
||||
The MariaDB team
|
22
module/Vendor/MDBC/cmake/COPYING-CMAKE-SCRIPTS
vendored
Normal file
22
module/Vendor/MDBC/cmake/COPYING-CMAKE-SCRIPTS
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
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 copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR 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.
|
116
module/Vendor/MDBC/cmake/CheckFunctions.cmake
vendored
Normal file
116
module/Vendor/MDBC/cmake/CheckFunctions.cmake
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
# This file is included by CMakeLists.txt and
|
||||
# checks for various functions.
|
||||
# You will find the appropiate defines in
|
||||
# include/my_config.h.in
|
||||
|
||||
INCLUDE(CheckFunctionExists)
|
||||
|
||||
CHECK_FUNCTION_EXISTS (access HAVE_ACCESS)
|
||||
CHECK_FUNCTION_EXISTS (aiowait HAVE_AIOWAIT)
|
||||
CHECK_FUNCTION_EXISTS (alarm HAVE_ALARM)
|
||||
CHECK_FUNCTION_EXISTS (alloca HAVE_ALLOCA)
|
||||
CHECK_FUNCTION_EXISTS (bcmp HAVE_BCMP)
|
||||
CHECK_FUNCTION_EXISTS (bfill HAVE_BFILL)
|
||||
CHECK_FUNCTION_EXISTS (bmove HAVE_BMOVE)
|
||||
CHECK_FUNCTION_EXISTS (bzero HAVE_BZERO)
|
||||
CHECK_FUNCTION_EXISTS (clock_gettime HAVE_CLOCK_GETTIME)
|
||||
CHECK_FUNCTION_EXISTS (compress HAVE_COMPRESS)
|
||||
CHECK_FUNCTION_EXISTS (crypt HAVE_CRYPT)
|
||||
CHECK_FUNCTION_EXISTS (dlerror HAVE_DLERROR)
|
||||
CHECK_FUNCTION_EXISTS (dlopen HAVE_DLOPEN)
|
||||
CHECK_FUNCTION_EXISTS (fchmod HAVE_FCHMOD)
|
||||
CHECK_FUNCTION_EXISTS (fcntl HAVE_FCNTL)
|
||||
CHECK_FUNCTION_EXISTS (fconvert HAVE_FCONVERT)
|
||||
CHECK_FUNCTION_EXISTS (fdatasync HAVE_FDATASYNC)
|
||||
CHECK_FUNCTION_EXISTS (fesetround HAVE_FESETROUND)
|
||||
CHECK_FUNCTION_EXISTS (finite HAVE_FINITE)
|
||||
CHECK_FUNCTION_EXISTS (fseeko HAVE_FSEEKO)
|
||||
CHECK_FUNCTION_EXISTS (fsync HAVE_FSYNC)
|
||||
CHECK_FUNCTION_EXISTS (getaddrinfo HAVE_GETADDRINFO)
|
||||
CHECK_FUNCTION_EXISTS (getcwd HAVE_GETCWD)
|
||||
CHECK_FUNCTION_EXISTS (gethostbyaddr_r HAVE_GETHOSTBYADDR_R)
|
||||
CHECK_FUNCTION_EXISTS (gethostbyname_r HAVE_GETHOSTBYNAME_R)
|
||||
CHECK_FUNCTION_EXISTS (gethrtime HAVE_GETHRTIME)
|
||||
CHECK_FUNCTION_EXISTS (getnameinfo HAVE_GETNAMEINFO)
|
||||
CHECK_FUNCTION_EXISTS (getpagesize HAVE_GETPAGESIZE)
|
||||
CHECK_FUNCTION_EXISTS (getpass HAVE_GETPASS)
|
||||
CHECK_FUNCTION_EXISTS (getpassphrase HAVE_GETPASSPHRASE)
|
||||
CHECK_FUNCTION_EXISTS (getpwnam HAVE_GETPWNAM)
|
||||
CHECK_FUNCTION_EXISTS (getpwuid HAVE_GETPWUID)
|
||||
CHECK_FUNCTION_EXISTS (getrlimit HAVE_GETRLIMIT)
|
||||
CHECK_FUNCTION_EXISTS (getrusage HAVE_GETRUSAGE)
|
||||
CHECK_FUNCTION_EXISTS (getwd HAVE_GETWD)
|
||||
CHECK_FUNCTION_EXISTS (gmtime_r HAVE_GMTIME_R)
|
||||
CHECK_FUNCTION_EXISTS (initgroups HAVE_INITGROUPS)
|
||||
CHECK_FUNCTION_EXISTS (ldiv HAVE_LDIV)
|
||||
CHECK_FUNCTION_EXISTS (localtime_r HAVE_LOCALTIME_R)
|
||||
CHECK_FUNCTION_EXISTS (log2 HAVE_LOG2)
|
||||
CHECK_FUNCTION_EXISTS (longjmp HAVE_LONGJMP)
|
||||
CHECK_FUNCTION_EXISTS (lstat HAVE_LSTAT)
|
||||
CHECK_FUNCTION_EXISTS (madvise HAVE_MADVISE)
|
||||
CHECK_FUNCTION_EXISTS (mallinfo HAVE_MALLINFO)
|
||||
CHECK_FUNCTION_EXISTS (memalign HAVE_MEMALIGN)
|
||||
CHECK_FUNCTION_EXISTS (memcpy HAVE_MEMCPY)
|
||||
CHECK_FUNCTION_EXISTS (memmove HAVE_MEMMOVE)
|
||||
CHECK_FUNCTION_EXISTS (mkstemp HAVE_MKSTEMP)
|
||||
CHECK_FUNCTION_EXISTS (mlock HAVE_MLOCK)
|
||||
CHECK_FUNCTION_EXISTS (mlockall HAVE_MLOCKALL)
|
||||
CHECK_FUNCTION_EXISTS (mmap HAVE_MMAP)
|
||||
CHECK_FUNCTION_EXISTS (mmap64 HAVE_MMAP64)
|
||||
CHECK_FUNCTION_EXISTS (perror HAVE_PERROR)
|
||||
CHECK_FUNCTION_EXISTS (poll HAVE_POLL)
|
||||
CHECK_FUNCTION_EXISTS (pread HAVE_PREAD)
|
||||
CHECK_FUNCTION_EXISTS (pthread_attr_create HAVE_PTHREAD_ATTR_CREATE)
|
||||
CHECK_FUNCTION_EXISTS (pthread_attr_getstacksize HAVE_PTHREAD_ATTR_GETSTACKSIZE)
|
||||
CHECK_FUNCTION_EXISTS (pthread_attr_setprio HAVE_PTHREAD_ATTR_SETPRIO)
|
||||
CHECK_FUNCTION_EXISTS (pthread_attr_setschedparam HAVE_PTHREAD_ATTR_SETSCHEDPARAM)
|
||||
CHECK_FUNCTION_EXISTS (pthread_attr_setscope HAVE_PTHREAD_ATTR_SETSCOPE)
|
||||
CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE)
|
||||
CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE)
|
||||
CHECK_FUNCTION_EXISTS (pthread_init HAVE_PTHREAD_INIT)
|
||||
CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE)
|
||||
CHECK_FUNCTION_EXISTS (pthread_kill HAVE_PTHREAD_KILL)
|
||||
CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK)
|
||||
CHECK_FUNCTION_EXISTS (pthread_setprio_np HAVE_PTHREAD_SETPRIO_NP)
|
||||
CHECK_FUNCTION_EXISTS (pthread_setschedparam HAVE_PTHREAD_SETSCHEDPARAM)
|
||||
CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK)
|
||||
CHECK_FUNCTION_EXISTS (pthread_threadmask HAVE_PTHREAD_THREADMASK)
|
||||
CHECK_FUNCTION_EXISTS (pthread_yield_np HAVE_PTHREAD_YIELD_NP)
|
||||
CHECK_FUNCTION_EXISTS (readdir_r HAVE_READDIR_R)
|
||||
CHECK_FUNCTION_EXISTS (readlink HAVE_READLINK)
|
||||
CHECK_FUNCTION_EXISTS (realpath HAVE_REALPATH)
|
||||
CHECK_FUNCTION_EXISTS (rename HAVE_RENAME)
|
||||
CHECK_FUNCTION_EXISTS (sched_yield HAVE_SCHED_YIELD)
|
||||
CHECK_FUNCTION_EXISTS (select HAVE_SELECT)
|
||||
CHECK_FUNCTION_EXISTS (setfd HAVE_SETFD)
|
||||
CHECK_FUNCTION_EXISTS (setfilepointer HAVE_SETFILEPOINTER)
|
||||
CHECK_FUNCTION_EXISTS (sigaction HAVE_SIGACTION)
|
||||
CHECK_FUNCTION_EXISTS (sigthreadmask HAVE_SIGTHREADMASK)
|
||||
CHECK_FUNCTION_EXISTS (sigwait HAVE_SIGWAIT)
|
||||
CHECK_FUNCTION_EXISTS (sleep HAVE_SLEEP)
|
||||
CHECK_FUNCTION_EXISTS (snprintf HAVE_SNPRINTF)
|
||||
CHECK_FUNCTION_EXISTS (stpcpy HAVE_STPCPY)
|
||||
CHECK_FUNCTION_EXISTS (strerror HAVE_STRERROR)
|
||||
CHECK_FUNCTION_EXISTS (strlcpy HAVE_STRLCPY)
|
||||
CHECK_FUNCTION_EXISTS (strnlen HAVE_STRNLEN)
|
||||
CHECK_FUNCTION_EXISTS (strpbrk HAVE_STRPBRK)
|
||||
CHECK_FUNCTION_EXISTS (strsep HAVE_STRSEP)
|
||||
CHECK_FUNCTION_EXISTS (strstr HAVE_STRSTR)
|
||||
CHECK_FUNCTION_EXISTS (strtok_r HAVE_STRTOK_R)
|
||||
CHECK_FUNCTION_EXISTS (strtol HAVE_STRTOL)
|
||||
CHECK_FUNCTION_EXISTS (strtoll HAVE_STRTOLL)
|
||||
CHECK_FUNCTION_EXISTS (strtoul HAVE_STRTOUL)
|
||||
CHECK_FUNCTION_EXISTS (strtoull HAVE_STRTOULL)
|
||||
CHECK_FUNCTION_EXISTS (tell HAVE_TELL)
|
||||
CHECK_FUNCTION_EXISTS (thr_setconcurrency HAVE_THR_SETCONCURRENCY)
|
||||
CHECK_FUNCTION_EXISTS (thr_yield HAVE_THR_YIELD)
|
||||
CHECK_FUNCTION_EXISTS (vasprintf HAVE_VASPRINTF)
|
||||
CHECK_FUNCTION_EXISTS (vsnprintf HAVE_VSNPRINTF)
|
80
module/Vendor/MDBC/cmake/CheckIncludeFiles.cmake
vendored
Normal file
80
module/Vendor/MDBC/cmake/CheckIncludeFiles.cmake
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
# This file is included by CMakeLists.txt and
|
||||
# checks for various header files.
|
||||
# You will find the appropiate defines in
|
||||
# include/my_config.h.in
|
||||
|
||||
INCLUDE(CheckIncludeFiles)
|
||||
|
||||
CHECK_INCLUDE_FILES (alloca.h HAVE_ALLOCA_H)
|
||||
CHECK_INCLUDE_FILES (arpa/inet.h HAVE_ARPA_INET_H)
|
||||
CHECK_INCLUDE_FILES (crypt.h HAVE_CRYPT_H)
|
||||
CHECK_INCLUDE_FILES (dirent.h HAVE_DIRENT_H)
|
||||
CHECK_INCLUDE_FILES (dlfcn.h HAVE_DLFCN_H)
|
||||
CHECK_INCLUDE_FILES (execinfo.h HAVE_EXECINFO_H)
|
||||
CHECK_INCLUDE_FILES (fcntl.h HAVE_FCNTL_H)
|
||||
CHECK_INCLUDE_FILES (fenv.h HAVE_FENV_H)
|
||||
CHECK_INCLUDE_FILES (float.h HAVE_FLOAT_H)
|
||||
CHECK_INCLUDE_FILES (fpu/control.h HAVE_FPU_CONTROL_H)
|
||||
CHECK_INCLUDE_FILES (grp.h HAVE_GRP_H)
|
||||
CHECK_INCLUDE_FILES (ieeefp.h HAVE_IEEEFP_H)
|
||||
CHECK_INCLUDE_FILES (limits.h HAVE_LIMITS_H)
|
||||
CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
|
||||
CHECK_INCLUDE_FILES (memory.h HAVE_MEMORY_H)
|
||||
CHECK_INCLUDE_FILES (netinet/in.h HAVE_NETINET_IN_H)
|
||||
CHECK_INCLUDE_FILES (paths.h HAVE_PATHS_H)
|
||||
CHECK_INCLUDE_FILES (pwd.h HAVE_PWD_H)
|
||||
CHECK_INCLUDE_FILES (sched.h HAVE_SCHED_H)
|
||||
CHECK_INCLUDE_FILES (select.h HAVE_SELECT_H)
|
||||
|
||||
CHECK_INCLUDE_FILES (signal.h INCLUDE_SIGNAL)
|
||||
IF(INCLUDE_SIGNAL)
|
||||
SET(HAVE_SIGNAL 1)
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES signal.h)
|
||||
ENDIF(INCLUDE_SIGNAL)
|
||||
|
||||
CHECK_INCLUDE_FILES (stddef.h HAVE_STDDEF_H)
|
||||
|
||||
CHECK_INCLUDE_FILES (stdint.h HAVE_STDINT_H)
|
||||
IF(HAVE_STDINT_H)
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES stdint.h)
|
||||
ENDIF(HAVE_STDINT_H)
|
||||
|
||||
CHECK_INCLUDE_FILES (stdlib.h HAVE_STDLIB_H)
|
||||
CHECK_INCLUDE_FILES (string.h HAVE_STRING_H)
|
||||
CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H)
|
||||
CHECK_INCLUDE_FILES (synch.h HAVE_SYNCH_H)
|
||||
CHECK_INCLUDE_FILES (sys/fpu.h HAVE_SYS_FPU_H)
|
||||
CHECK_INCLUDE_FILES (sys/ioctl.h HAVE_SYS_IOCTL_H)
|
||||
CHECK_INCLUDE_FILES (sys/ipc.h HAVE_SYS_IPC_H)
|
||||
CHECK_INCLUDE_FILES (sys/mman.h HAVE_SYS_MMAN_H)
|
||||
CHECK_INCLUDE_FILES (sys/prctl.h HAVE_SYS_PRCTL_H)
|
||||
CHECK_INCLUDE_FILES (sys/select.h HAVE_SYS_SELECT_H)
|
||||
CHECK_INCLUDE_FILES (sys/shm.h HAVE_SYS_SHM_H)
|
||||
|
||||
CHECK_INCLUDE_FILES (sys/socket.h HAVE_SYS_SOCKET_H)
|
||||
IF(HAVE_SYS_SOCKET_H)
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
|
||||
ENDIF(HAVE_SYS_SOCKET_H)
|
||||
|
||||
CHECK_INCLUDE_FILES (sys/stat.h HAVE_SYS_STAT_H)
|
||||
CHECK_INCLUDE_FILES (sys/stream.h HAVE_SYS_STREAM_H)
|
||||
CHECK_INCLUDE_FILES (sys/timeb.h HAVE_SYS_TIMEB_H)
|
||||
CHECK_INCLUDE_FILES (sys/types.h HAVE_SYS_TYPES_H)
|
||||
CHECK_INCLUDE_FILES (sys/un.h HAVE_SYS_UN_H)
|
||||
CHECK_INCLUDE_FILES (sysent.h HAVE_SYSENT_H)
|
||||
CHECK_INCLUDE_FILES (termio.h HAVE_TERMIO_H)
|
||||
CHECK_INCLUDE_FILES (termios.h HAVE_TERMIOS_H)
|
||||
CHECK_INCLUDE_FILES (ucontext.h HAVE_UCONTEXT_H)
|
||||
IF(NOT HAVE_UCONTEXT_H)
|
||||
CHECK_INCLUDE_FILES (sys/ucontext.h HAVE_UCONTEXT_H)
|
||||
ENDIF()
|
||||
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILES (utime.h HAVE_UTIME_H)
|
114
module/Vendor/MDBC/cmake/CheckTypes.cmake
vendored
Normal file
114
module/Vendor/MDBC/cmake/CheckTypes.cmake
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
# This file is included by CMakeLists.txt and
|
||||
# checks for type sizes.
|
||||
# You will find the appropiate defines in
|
||||
# include/my_config.h.in
|
||||
INCLUDE (CheckTypeSize)
|
||||
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES signal.h)
|
||||
CHECK_TYPE_SIZE(sigset_t SIZEOF_SIGSET_T)
|
||||
CHECK_TYPE_SIZE(char SIZEOF_CHAR)
|
||||
CHECK_TYPE_SIZE("char *" SIZEOF_CHARP)
|
||||
CHECK_TYPE_SIZE(short SIZEOF_SHORT)
|
||||
CHECK_TYPE_SIZE(int SIZEOF_INT)
|
||||
CHECK_TYPE_SIZE(long SIZEOF_LONG)
|
||||
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES stdio.h)
|
||||
CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T)
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
|
||||
CHECK_TYPE_SIZE(off_t SIZEOF_OFF_T)
|
||||
CHECK_TYPE_SIZE(uchar SIZEOF_UCHAR)
|
||||
CHECK_TYPE_SIZE(uint SIZEOF_UINT)
|
||||
CHECK_TYPE_SIZE(ulong SIZEOF_ULONG)
|
||||
CHECK_TYPE_SIZE(int8 SIZEOF_INT8)
|
||||
CHECK_TYPE_SIZE(uint8 SIZEOF_UINT8)
|
||||
CHECK_TYPE_SIZE(int16 SIZEOF_INT16)
|
||||
CHECK_TYPE_SIZE(uint16 SIZEOF_UINT16)
|
||||
CHECK_TYPE_SIZE(int32 SIZEOF_INT32)
|
||||
CHECK_TYPE_SIZE(uint32 SIZEOF_UINT32)
|
||||
CHECK_TYPE_SIZE(u_int32_t SIZEOF_UINT_32_T)
|
||||
CHECK_TYPE_SIZE(int64 SIZEOF_INT64)
|
||||
CHECK_TYPE_SIZE(uint64 SIZEOF_UINT64)
|
||||
CHECK_TYPE_SIZE(socklen_t SIZEOF_SOCKLEN_T)
|
||||
|
||||
#
|
||||
# Compile testing
|
||||
#
|
||||
INCLUDE (CheckCSourceCompiles)
|
||||
|
||||
#
|
||||
# signal handler
|
||||
#
|
||||
CHECK_C_SOURCE_COMPILES("
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef signal
|
||||
#undef signal
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern \"C\" void (*signal (int, void (*)(int)))(int);
|
||||
#else
|
||||
void (*signal ()) ();
|
||||
#endif
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
}"
|
||||
IS_VOID_SIGNAL)
|
||||
|
||||
IF(IS_VOID_SIGNAL)
|
||||
SET(RETSIGTYPE "void")
|
||||
ELSE(IS_VOID_SIGNAL)
|
||||
SET(RETSIGTYPE "int")
|
||||
ENDIF(IS_VOID_SIGNAL)
|
||||
|
||||
#
|
||||
# quick sort
|
||||
#
|
||||
CHECK_C_SOURCE_COMPILES("
|
||||
#include <stdlib.h>
|
||||
#ifdef __cplusplus
|
||||
extern \"C\" void qsort(void *base, size_t nel, size_t width, int (*compar) (const void *, const void *));
|
||||
#else
|
||||
void qsort(void *base, size_t nel, size_t width, int (*compar) (const void *, const void *));
|
||||
#endif
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
}"
|
||||
IS_VOID_QSORT)
|
||||
IF(IS_VOID_QSORT)
|
||||
SET(RETQSORTTYPE "void")
|
||||
ELSE(IS_VOID_QSORT)
|
||||
SET(RETQSORTTYPE "int")
|
||||
ENDIF(IS_VOID_QSORT)
|
||||
|
||||
#
|
||||
# SOCKET_SIZE
|
||||
#
|
||||
IF(WIN32)
|
||||
SET(SOCKET_SIZE_TYPE int)
|
||||
ELSE(WIN32)
|
||||
FOREACH(CHECK_TYPE "socklen_t" "size_t" "int")
|
||||
IF (NOT SOCKET_SIZE_TYPE)
|
||||
CHECK_C_SOURCE_COMPILES("
|
||||
#include <sys/socket.h>
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
getsockname(0, 0, (${CHECK_TYPE} *)0);
|
||||
return 0;
|
||||
}"
|
||||
SOCKET_SIZE_FOUND_${CHECK_TYPE})
|
||||
IF(SOCKET_SIZE_FOUND_${CHECK_TYPE})
|
||||
SET(SOCKET_SIZE_TYPE ${CHECK_TYPE})
|
||||
ENDIF(SOCKET_SIZE_FOUND_${CHECK_TYPE})
|
||||
ENDIF (NOT SOCKET_SIZE_TYPE)
|
||||
ENDFOREACH()
|
||||
ENDIF(WIN32)
|
30
module/Vendor/MDBC/cmake/ConnectorName.cmake
vendored
Normal file
30
module/Vendor/MDBC/cmake/ConnectorName.cmake
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
MACRO(GET_CONNECTOR_PACKAGE_NAME name)
|
||||
# check if we have 64bit
|
||||
IF(SIZEOF_VOIDP EQUAL 8)
|
||||
SET(IS64 1)
|
||||
ENDIF()
|
||||
|
||||
SET (PLAFORM_NAME CMAKE_SYSTEM_NAME)
|
||||
SET (MACHINE_NAME CMAKE_SYSTEM_PROCESSOR)
|
||||
SET (CONCAT_SIGN "-")
|
||||
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
SET(PLATFORM_NAME "win")
|
||||
SET(CONCAT_SIGN "")
|
||||
IF(IS64)
|
||||
SET(MACHINE_NAME "x64")
|
||||
ELSE()
|
||||
SET(MACHINE_NAME "32")
|
||||
END()
|
||||
ENDIF()
|
||||
|
||||
SET(product_name "mysql-connector-c-${CPACK_PACKAGE_VERSION}-${PLATFORM_NAME}${CONCAT_SIGN}${MACHINE_NAME}")
|
||||
STRING(TOLOWER ${product_name} ${name})
|
||||
ENDMACRO()
|
64
module/Vendor/MDBC/cmake/FindIconv.cmake
vendored
Normal file
64
module/Vendor/MDBC/cmake/FindIconv.cmake
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
#
|
||||
# Copyright (C) 2010 Michael Bell <michael.bell@web.de>
|
||||
# 2015-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
# ICONV_EXTERNAL - Iconv is an external library (not libc)
|
||||
# ICONV_FOUND - system has Iconv
|
||||
# ICONV_INCLUDE_DIR - the Iconv include directory
|
||||
# ICONV_LIBRARIES - Link these to use Iconv
|
||||
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
|
||||
# ICONV_VERSION - Iconv version string
|
||||
#
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
find_path(ICONV_INCLUDE_DIR iconv.h)
|
||||
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
# There is some libiconv.so in /usr/local that must
|
||||
# be avoided, iconv routines are in libc
|
||||
find_library(ICONV_LIBRARIES NAMES c)
|
||||
ELSEIF(APPLE)
|
||||
find_library(ICONV_LIBRARIES NAMES iconv libiconv PATHS
|
||||
/usr/lib/
|
||||
NO_CMAKE_SYSTEM_PATH)
|
||||
set(ICONV_EXTERNAL TRUE)
|
||||
ELSE()
|
||||
find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2)
|
||||
IF(ICONV_LIBRARIES)
|
||||
set(ICONV_EXTERNAL TRUE)
|
||||
ELSE()
|
||||
find_library(ICONV_LIBRARIES NAMES c)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ICONV REQUIRED_VARS ICONV_LIBRARIES ICONV_INCLUDE_DIR VERSION_VAR ICONV_VERSION)
|
||||
|
||||
if (ICONV_FOUND)
|
||||
check_c_source_compiles("
|
||||
#include <iconv.h>
|
||||
int main(){
|
||||
iconv_t conv = 0;
|
||||
const char* in = 0;
|
||||
size_t ilen = 0;
|
||||
char* out = 0;
|
||||
size_t olen = 0;
|
||||
iconv(conv, &in, &ilen, &out, &olen);
|
||||
return 0;
|
||||
}
|
||||
" ICONV_SECOND_ARGUMENT_IS_CONST )
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
|
||||
endif(ICONV_FOUND)
|
||||
|
||||
mark_as_advanced(
|
||||
ICONV_INCLUDE_DIR
|
||||
ICONV_LIBRARIES
|
||||
ICONV_SECOND_ARGUMENT_IS_CONST
|
||||
)
|
||||
|
31
module/Vendor/MDBC/cmake/SearchLibrary.cmake
vendored
Normal file
31
module/Vendor/MDBC/cmake/SearchLibrary.cmake
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
INCLUDE(CheckFunctionExists)
|
||||
INCLUDE(CheckLibraryExists)
|
||||
|
||||
FUNCTION(SEARCH_LIBRARY library_name function liblist)
|
||||
IF(${${library_name}})
|
||||
RETURN()
|
||||
ENDIF()
|
||||
CHECK_FUNCTION_EXISTS(${function} ${function}_IS_SYS_FUNC)
|
||||
# check if function is part of libc
|
||||
IF(HAVE_${function}_IS_SYS_FUNC)
|
||||
SET(${library_name} "" PARENT_SCOPE)
|
||||
RETURN()
|
||||
ENDIF()
|
||||
FOREACH(lib ${liblist})
|
||||
CHECK_LIBRARY_EXISTS(${lib} ${function} "" HAVE_${function}_IN_${lib})
|
||||
IF(HAVE_${function}_IN_${lib})
|
||||
SET(${library_name} ${lib} PARENT_SCOPE)
|
||||
SET(HAVE_${library_name} 1 PARENT_SCOPE)
|
||||
RETURN()
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
ENDFUNCTION()
|
||||
|
399
module/Vendor/MDBC/cmake/WindowsCache.cmake
vendored
Normal file
399
module/Vendor/MDBC/cmake/WindowsCache.cmake
vendored
Normal file
@ -0,0 +1,399 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
IF(MSVC)
|
||||
SET(BFD_H_EXISTS 0 CACHE INTERNAL "")
|
||||
SET(HAVE_ACCESS 1 CACHE INTERNAL "")
|
||||
SET(HAVE_AIO_H CACHE INTERNAL "")
|
||||
SET(HAVE_AIO_READ CACHE INTERNAL "")
|
||||
SET(HAVE_ALARM CACHE INTERNAL "")
|
||||
SET(HAVE_ALLOCA_H CACHE INTERNAL "")
|
||||
SET(HAVE_ARPA_INET_H CACHE INTERNAL "")
|
||||
SET(HAVE_ASM_MSR_H CACHE INTERNAL "")
|
||||
SET(HAVE_BACKTRACE CACHE INTERNAL "")
|
||||
SET(HAVE_BACKTRACE_SYMBOLS CACHE INTERNAL "")
|
||||
SET(HAVE_BACKTRACE_SYMBOLS_FD CACHE INTERNAL "")
|
||||
SET(HAVE_BFILL CACHE INTERNAL "")
|
||||
SET(HAVE_BMOVE CACHE INTERNAL "")
|
||||
SET(HAVE_BSD_SIGNALS CACHE INTERNAL "")
|
||||
SET(HAVE_BSEARCH 1 CACHE INTERNAL "")
|
||||
SET(HAVE_BSS_START CACHE INTERNAL "")
|
||||
SET(HAVE_BZERO CACHE INTERNAL "")
|
||||
SET(HAVE_CHOWN CACHE INTERNAL "")
|
||||
SET(HAVE_CLOCK_GETTIME CACHE INTERNAL "")
|
||||
SET(HAVE_COMPRESS CACHE INTERNAL "")
|
||||
SET(HAVE_CRYPT CACHE INTERNAL "")
|
||||
SET(HAVE_CRYPT_H CACHE INTERNAL "")
|
||||
SET(HAVE_CUSERID CACHE INTERNAL "")
|
||||
SET(HAVE_CXX_NEW 1 CACHE INTERNAL "")
|
||||
SET(HAVE_DECL_MADVISE CACHE INTERNAL "")
|
||||
SET(HAVE_DIRECTIO CACHE INTERNAL "")
|
||||
SET(HAVE_DIRENT_H CACHE INTERNAL "")
|
||||
SET(HAVE_DLERROR CACHE INTERNAL "")
|
||||
SET(HAVE_DLFCN_H CACHE INTERNAL "")
|
||||
SET(HAVE_DLOPEN CACHE INTERNAL "")
|
||||
SET(HAVE_DOPRNT CACHE INTERNAL "")
|
||||
SET(HAVE_EXECINFO_H CACHE INTERNAL "")
|
||||
SET(HAVE_FCHMOD CACHE INTERNAL "")
|
||||
SET(HAVE_FCNTL CACHE INTERNAL "")
|
||||
SET(HAVE_FCNTL_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_FCNTL_NONBLOCK CACHE INTERNAL "")
|
||||
SET(HAVE_FCONVERT CACHE INTERNAL "")
|
||||
SET(HAVE_FDATASYNC CACHE INTERNAL "")
|
||||
SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "")
|
||||
SET(HAVE_FEDISABLEEXCEPT CACHE INTERNAL "")
|
||||
SET(HAVE_FENV_H CACHE INTERNAL "")
|
||||
SET(HAVE_FESETROUND CACHE INTERNAL "")
|
||||
SET(HAVE_FGETLN CACHE INTERNAL "")
|
||||
SET(HAVE_FINITE CACHE INTERNAL "")
|
||||
SET(HAVE_FINITE_IN_MATH_H CACHE INTERNAL "")
|
||||
SET(HAVE_FLOATINGPOINT_H CACHE INTERNAL "")
|
||||
SET(HAVE_FLOAT_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_FLOCKFILE CACHE INTERNAL "")
|
||||
SET(HAVE_FNMATCH_H CACHE INTERNAL "")
|
||||
SET(HAVE_FPSETMASK CACHE INTERNAL "")
|
||||
SET(HAVE_FPU_CONTROL_H CACHE INTERNAL "")
|
||||
SET(HAVE_FSEEKO CACHE INTERNAL "")
|
||||
SET(HAVE_FSYNC CACHE INTERNAL "")
|
||||
SET(HAVE_FTIME 1 CACHE INTERNAL "")
|
||||
SET(HAVE_FTRUNCATE CACHE INTERNAL "")
|
||||
SET(HAVE_GETADDRINFO 1 CACHE INTERNAL "")
|
||||
SET(HAVE_GETCWD 1 CACHE INTERNAL "")
|
||||
SET(HAVE_GETHOSTBYADDR_R CACHE INTERNAL "")
|
||||
SET(HAVE_GETHRTIME CACHE INTERNAL "")
|
||||
SET(HAVE_GETLINE CACHE INTERNAL "")
|
||||
SET(HAVE_GETNAMEINFO CACHE INTERNAL "")
|
||||
SET(HAVE_GETPAGESIZE CACHE INTERNAL "")
|
||||
SET(HAVE_GETPASS CACHE INTERNAL "")
|
||||
SET(HAVE_GETPASSPHRASE CACHE INTERNAL "")
|
||||
SET(HAVE_GETPWNAM CACHE INTERNAL "")
|
||||
SET(HAVE_GETPWUID CACHE INTERNAL "")
|
||||
SET(HAVE_GETRLIMIT CACHE INTERNAL "")
|
||||
SET(HAVE_GETRUSAGE CACHE INTERNAL "")
|
||||
SET(HAVE_GETTIMEOFDAY CACHE INTERNAL "")
|
||||
SET(HAVE_GETWD CACHE INTERNAL "")
|
||||
SET(HAVE_GMTIME_R CACHE INTERNAL "")
|
||||
SET(HAVE_GRP_H CACHE INTERNAL "")
|
||||
SET(HAVE_IA64INTRIN_H CACHE INTERNAL "")
|
||||
SET(HAVE_IEEEFP_H CACHE INTERNAL "")
|
||||
SET(HAVE_INDEX CACHE INTERNAL "")
|
||||
SET(HAVE_INITGROUPS CACHE INTERNAL "")
|
||||
SET(HAVE_INTTYPES_H CACHE INTERNAL "")
|
||||
SET(HAVE_IPPROTO_IPV6 CACHE INTERNAL "")
|
||||
SET(HAVE_IPV6 TRUE CACHE INTERNAL "")
|
||||
SET(HAVE_IPV6_V6ONLY 1 CACHE INTERNAL "")
|
||||
SET(HAVE_ISINF CACHE INTERNAL "")
|
||||
SET(HAVE_ISNAN CACHE INTERNAL "")
|
||||
SET(HAVE_ISSETUGID CACHE INTERNAL "")
|
||||
SET(HAVE_GETUID CACHE INTERNAL "")
|
||||
SET(HAVE_GETEUID CACHE INTERNAL "")
|
||||
SET(HAVE_GETGID CACHE INTERNAL "")
|
||||
SET(HAVE_GETEGID CACHE INTERNAL "")
|
||||
SET(HAVE_LANGINFO_H CACHE INTERNAL "")
|
||||
SET(HAVE_LDIV 1 CACHE INTERNAL "")
|
||||
SET(HAVE_LIMITS_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_LOCALE_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_LOCALTIME_R CACHE INTERNAL "")
|
||||
SET(HAVE_LOG2 CACHE INTERNAL "")
|
||||
SET(HAVE_LONGJMP 1 CACHE INTERNAL "")
|
||||
SET(HAVE_LRAND48 CACHE INTERNAL "")
|
||||
SET(HAVE_LSTAT CACHE INTERNAL "")
|
||||
SET(HAVE_MADVISE CACHE INTERNAL "")
|
||||
SET(HAVE_MALLINFO CACHE INTERNAL "")
|
||||
SET(HAVE_MALLOC_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_MEMALIGN CACHE INTERNAL "")
|
||||
SET(HAVE_MEMCPY 1 CACHE INTERNAL "")
|
||||
SET(HAVE_MEMMOVE 1 CACHE INTERNAL "")
|
||||
SET(HAVE_MEMORY_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_MKSTEMP CACHE INTERNAL "")
|
||||
SET(HAVE_MLOCK CACHE INTERNAL "")
|
||||
SET(HAVE_MLOCKALL CACHE INTERNAL "")
|
||||
SET(HAVE_MMAP CACHE INTERNAL "")
|
||||
SET(HAVE_MMAP64 CACHE INTERNAL "")
|
||||
SET(HAVE_NETDB_H CACHE INTERNAL "")
|
||||
SET(HAVE_NETINET_IN6_H CACHE INTERNAL "")
|
||||
SET(HAVE_NETINET_IN_H CACHE INTERNAL "")
|
||||
SET(HAVE_NL_LANGINFO CACHE INTERNAL "")
|
||||
SET(HAVE_PASE_ENVIRONMENT CACHE INTERNAL "")
|
||||
SET(HAVE_PATHS_H CACHE INTERNAL "")
|
||||
SET(HAVE_PCLOSE CACHE INTERNAL "")
|
||||
SET(HAVE_PERROR 1 CACHE INTERNAL "")
|
||||
SET(HAVE_PEERCRED CACHE INTERNAL "")
|
||||
SET(HAVE_PAM_APPL_H CACHE INTERNAL "")
|
||||
SET(HAVE_POLL_H CACHE INTERNAL "")
|
||||
SET(HAVE_POPEN CACHE INTERNAL "")
|
||||
SET(HAVE_POLL CACHE INTERNAL "")
|
||||
SET(HAVE_PORT_CREATE CACHE INTERNAL "")
|
||||
SET(HAVE_PORT_H CACHE INTERNAL "")
|
||||
SET(HAVE_POSIX_FALLOCATE CACHE INTERNAL "")
|
||||
SET(HAVE_POSIX_SIGNALS CACHE INTERNAL "")
|
||||
SET(HAVE_PREAD CACHE INTERNAL "")
|
||||
SET(HAVE_PRINTSTACK CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_CREATE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_GETSTACKSIZE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_SETSCOPE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_SETSTACKSIZE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_CONDATTR_CREATE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_CONDATTR_SETCLOCK CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_INIT CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_KEY_DELETE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_RWLOCK_RDLOCK CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_SIGMASK CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_THREADMASK CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_YIELD_NP CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_YIELD_ZERO_ARG CACHE INTERNAL "")
|
||||
SET(HAVE_PUTENV 1 CACHE INTERNAL "")
|
||||
SET(HAVE_PWD_H CACHE INTERNAL "")
|
||||
SET(HAVE_RDTSCLL CACHE INTERNAL "")
|
||||
SET(HAVE_READDIR_R CACHE INTERNAL "")
|
||||
SET(HAVE_READLINK CACHE INTERNAL "")
|
||||
SET(HAVE_READ_REAL_TIME CACHE INTERNAL "")
|
||||
SET(HAVE_REALPATH CACHE INTERNAL "")
|
||||
SET(HAVE_REGCOMP CACHE INTERNAL "")
|
||||
SET(HAVE_RENAME 1 CACHE INTERNAL "")
|
||||
SET(HAVE_RE_COMP CACHE INTERNAL "")
|
||||
SET(HAVE_RINT CACHE INTERNAL "")
|
||||
SET(HAVE_RWLOCK_INIT CACHE INTERNAL "")
|
||||
SET(HAVE_SCHED_H CACHE INTERNAL "")
|
||||
SET(HAVE_SCHED_YIELD CACHE INTERNAL "")
|
||||
SET(HAVE_SELECT 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SELECT_H CACHE INTERNAL "")
|
||||
SET(HAVE_SEMAPHORE_H CACHE INTERNAL "")
|
||||
SET(HAVE_SETENV CACHE INTERNAL "")
|
||||
SET(HAVE_SETFD CACHE INTERNAL "")
|
||||
SET(HAVE_SETLOCALE 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SHMAT CACHE INTERNAL "")
|
||||
SET(HAVE_SHMCTL CACHE INTERNAL "")
|
||||
SET(HAVE_SHMDT CACHE INTERNAL "")
|
||||
SET(HAVE_SHMGET CACHE INTERNAL "")
|
||||
SET(HAVE_SIGACTION CACHE INTERNAL "")
|
||||
SET(HAVE_SIGADDSET CACHE INTERNAL "")
|
||||
SET(HAVE_SIGEMPTYSET CACHE INTERNAL "")
|
||||
SET(HAVE_SIGHOLD CACHE INTERNAL "")
|
||||
SET(HAVE_SIGINT 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SIGPIPE CACHE INTERNAL "")
|
||||
SET(HAVE_SIGQUIT CACHE INTERNAL "")
|
||||
SET(HAVE_SIGSET CACHE INTERNAL "")
|
||||
SET(HAVE_SIGTERM 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SIGTHREADMASK CACHE INTERNAL "")
|
||||
SET(HAVE_SIGWAIT CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_BOOL FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_CHAR TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_CHAR 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_CHARP TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_CHARP ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_IN6_ADDR TRUE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_INT TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_INT 4 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_INT16 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_INT32 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_INT64 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_INT8 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_LONG TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_LONG 4 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_LONG_LONG TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_LONG_LONG 8 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_MODE_T FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_OFF_T TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_OFF_T 4 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_SHORT TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_SHORT 2 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_SIGSET_T FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_SIZE_T TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_SIZE_T ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_SOCKADDR_IN6 TRUE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_SOCKLEN_T FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UCHAR FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UINT FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UINT16 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UINT32 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UINT64 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UINT8 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_ULONG FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_U_INT32_T FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZE_OF_SSIZE_T FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SLEEP CACHE INTERNAL "")
|
||||
SET(HAVE_SNPRINTF CACHE INTERNAL "")
|
||||
SET(HAVE_SOCKADDR_STORAGE_SS_FAMILY 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SOLARIS_STYLE_GETHOST CACHE INTERNAL "")
|
||||
SET(STACK_DIRECTION -1 CACHE INTERNAL "")
|
||||
SET(HAVE_STDARG_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STDDEF_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STDINT_H CACHE INTERNAL "")
|
||||
SET(HAVE_STDLIB_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STPCPY CACHE INTERNAL "")
|
||||
SET(HAVE_STRCASECMP CACHE INTERNAL "")
|
||||
SET(HAVE_STRCOLL 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRDUP 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRERROR 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRINGS_H CACHE INTERNAL "")
|
||||
SET(HAVE_STRING_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRLCAT CACHE INTERNAL "")
|
||||
SET(HAVE_STRLCPY CACHE INTERNAL "")
|
||||
SET(HAVE_STRNCASECMP CACHE INTERNAL "")
|
||||
SET(HAVE_STRNDUP CACHE INTERNAL "")
|
||||
IF(MSVC_VERSION GREATER 1310)
|
||||
SET(HAVE_STRNLEN 1 CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
SET(HAVE_STRPBRK 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRSEP CACHE INTERNAL "")
|
||||
SET(HAVE_STRSIGNAL CACHE INTERNAL "")
|
||||
SET(HAVE_STRSTR 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRTOK_R CACHE INTERNAL "")
|
||||
SET(HAVE_STRTOL 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRTOLL CACHE INTERNAL "")
|
||||
SET(HAVE_STRTOUL 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRTOULL CACHE INTERNAL "")
|
||||
SET(HAVE_SVR3_SIGNALS CACHE INTERNAL "")
|
||||
SET(HAVE_SYNCH_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYSENT_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_CDEFS_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_DIR_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_ERRLIST CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_FILE_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_FPU_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_IOCTL_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_IPC_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_MALLOC_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_MMAN_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_PARAM_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_PRCTL_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_PTEM_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_PTE_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_RESOURCE_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_SELECT_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_SHM_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_SOCKIO_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_SOCKET_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_STAT_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_STREAM_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_TERMCAP_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_TIMEB_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_TIMES_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_TIME_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_TYPES_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_UN_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_UTIME_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_VADVISE_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_WAIT_H CACHE INTERNAL "")
|
||||
SET(HAVE_TCGETATTR CACHE INTERNAL "")
|
||||
SET(HAVE_TELL 1 CACHE INTERNAL "")
|
||||
SET(HAVE_TEMPNAM 1 CACHE INTERNAL "")
|
||||
SET(HAVE_TERMCAP_H CACHE INTERNAL "")
|
||||
SET(HAVE_TERMIOS_H CACHE INTERNAL "")
|
||||
SET(HAVE_TERMIO_H CACHE INTERNAL "")
|
||||
SET(HAVE_TERM_H CACHE INTERNAL "")
|
||||
SET(HAVE_THR_SETCONCURRENCY CACHE INTERNAL "")
|
||||
SET(HAVE_THR_YIELD CACHE INTERNAL "")
|
||||
SET(HAVE_TIME 1 CACHE INTERNAL "")
|
||||
SET(HAVE_TIMES CACHE INTERNAL "")
|
||||
SET(HAVE_TIMESPEC_TS_SEC CACHE INTERNAL "")
|
||||
SET(HAVE_TIME_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_TZNAME 1 CACHE INTERNAL "")
|
||||
SET(HAVE_UNISTD_H CACHE INTERNAL "")
|
||||
SET(HAVE_UTIME_H CACHE INTERNAL "")
|
||||
SET(HAVE_VALLOC CACHE INTERNAL "")
|
||||
SET(HAVE_VARARGS_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_VASPRINTF CACHE INTERNAL "")
|
||||
SET(HAVE_VPRINTF 1 CACHE INTERNAL "")
|
||||
IF(MSVC_VERSION GREATER 1310)
|
||||
SET(HAVE_VSNPRINTF 1 CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
SET(HAVE_WEAK_SYMBOL CACHE INTERNAL "")
|
||||
SET(HAVE_WORDS_BIGENDIAN TRUE CACHE INTERNAL "")
|
||||
SET(WORDS_BIGENDIAN CACHE INTERNAL "")
|
||||
SET(HAVE__S_IFIFO 1 CACHE INTERNAL "")
|
||||
SET(HAVE__S_IREAD 1 CACHE INTERNAL "")
|
||||
SET(HAVE__finite 1 CACHE INTERNAL "")
|
||||
SET(HAVE__isnan 1 CACHE INTERNAL "")
|
||||
SET(HAVE__pclose 1 CACHE INTERNAL "")
|
||||
SET(HAVE__popen 1 CACHE INTERNAL "")
|
||||
SET(HAVE__snprintf 1 CACHE INTERNAL "")
|
||||
SET(HAVE__stricmp 1 CACHE INTERNAL "")
|
||||
SET(HAVE__strnicmp 1 CACHE INTERNAL "")
|
||||
SET(HAVE__strtoi64 1 CACHE INTERNAL "")
|
||||
SET(HAVE__strtoui64 1 CACHE INTERNAL "")
|
||||
IF(MSVC_VERSION GREATER 1310)
|
||||
SET(HAVE_strtok_s 1 CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
SET(STDC_HEADERS CACHE 1 INTERNAL "")
|
||||
SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "")
|
||||
SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "")
|
||||
SET(STRUCT_DIRENT_HAS_D_NAMLEN CACHE INTERNAL "")
|
||||
SET(TIME_WITH_SYS_TIME CACHE INTERNAL "")
|
||||
SET(TIME_T_UNSIGNED 1 CACHE INTERNAL "")
|
||||
SET(TIOCSTAT_IN_SYS_IOCTL CACHE INTERNAL "")
|
||||
SET(HAVE_S_IROTH CACHE INTERNAL "")
|
||||
SET(HAVE_S_IFIFO CACHE INTERNAL "")
|
||||
SET(QSORT_TYPE_IS_VOID 1 CACHE INTERNAL "")
|
||||
SET(SIGNAL_RETURN_TYPE_IS_VOID 1 CACHE INTERNAL "")
|
||||
SET(C_HAS_inline CACHE INTERNAL "")
|
||||
SET(C_HAS___inline 1 CACHE INTERNAL "")
|
||||
SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "")
|
||||
SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "")
|
||||
SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "")
|
||||
SET(HAVE_CXXABI_H CACHE INTERNAL "")
|
||||
SET(HAVE_NDIR_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_NDIR_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_NDIR_H CACHE INTERNAL "")
|
||||
SET(HAVE_ASM_TERMBITS_H CACHE INTERNAL "")
|
||||
SET(HAVE_TERMBITS_H CACHE INTERNAL "")
|
||||
SET(HAVE_VIS_H CACHE INTERNAL "")
|
||||
SET(HAVE_WCHAR_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_WCTYPE_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP CACHE INTERNAL "")
|
||||
SET(HAVE_SOCKADDR_IN_SIN_LEN CACHE INTERNAL "")
|
||||
SET(HAVE_SOCKADDR_IN6_SIN6_LEN CACHE INTERNAL "")
|
||||
SET(HAVE_VALGRIND CACHE INTERNAL "")
|
||||
SET(HAVE_EVENT_H CACHE INTERNAL "")
|
||||
SET(HAVE_LINUX_UNISTD_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "")
|
||||
SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "")
|
||||
SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "")
|
||||
SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "")
|
||||
SET(HAVE_ACCESS 1 CACHE INTERNAL "")
|
||||
SET(HAVE_AIOWAIT CACHE INTERNAL "")
|
||||
SET(HAVE_AIO_H CACHE INTERNAL "")
|
||||
SET(HAVE_AIO_READ CACHE INTERNAL "")
|
||||
SET(HAVE_ALARM CACHE INTERNAL "")
|
||||
SET(HAVE_ALLOCA CACHE INTERNAL "")
|
||||
SET(HAVE_ALLOCA_H CACHE INTERNAL "")
|
||||
SET(HAVE_ARPA_INET_H CACHE INTERNAL "")
|
||||
SET(HAVE_ASM_MSR_H CACHE INTERNAL "")
|
||||
SET(HAVE_ASM_TERMBITS_H CACHE INTERNAL "")
|
||||
SET(HAVE_BACKTRACE CACHE INTERNAL "")
|
||||
SET(HAVE_BACKTRACE_SYMBOLS CACHE INTERNAL "")
|
||||
SET(HAVE_BACKTRACE_SYMBOLS_FD CACHE INTERNAL "")
|
||||
SET(HAVE_BCMP CACHE INTERNAL "")
|
||||
SET(HAVE_BFILL CACHE INTERNAL "")
|
||||
SET(HAVE_BMOVE CACHE INTERNAL "")
|
||||
SET(HAVE_BSD_SIGNALS CACHE INTERNAL "")
|
||||
SET(HAVE_BSEARCH CACHE INTERNAL "")
|
||||
SET(HAVE_BSS_START CACHE INTENAL "")
|
||||
SET(HAVE_BZERO CACHE INTERNAL "")
|
||||
SET(HAVE_CHOWN CACHE INTERNAL "")
|
||||
SET(HAVE_CLOCK_GETTIME CACHE INTERNAL "")
|
||||
SET(HAVE_COMPRESS CACHE INTERNAL "")
|
||||
SET(HAVE_CRYPT CACHE INTERNAL "")
|
||||
SET(HAVE_CRYPT_H CACHE INTERNAL "")
|
||||
SET(HAVE_CUSERID CACHE INTERNAL "")
|
||||
SET(HAVE_CXXABI_H CACHE INTERNAL "")
|
||||
SET(HAVE_CXX_NEW CACHE INTERNAL "")
|
||||
SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "")
|
||||
SET(HAVE_SIGNAL_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_GETHOSTBYNAME_R CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_SETPRIO CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_SETSCHEDPARAM CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_KILL CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_SETPRIO_NP CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_SETSCHEDPARAM CACHE INTERNAL "")
|
||||
SET(HAVE_SETFILEPOINTER CACHE INTERNAL "")
|
||||
SET(SIZEOF_U_INT32_T CACHE INTERNAL "")
|
||||
SET(IS_VOID_SIGNAL 1 CACHE INTERNAL "")
|
||||
SET(IS_VOID_QSORT 1 CACHE INTERNAL "")
|
||||
ENDIF()
|
139
module/Vendor/MDBC/cmake/install.cmake
vendored
Normal file
139
module/Vendor/MDBC/cmake/install.cmake
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
#
|
||||
# This file contains settings for the following layouts:
|
||||
#
|
||||
# - RPM
|
||||
# Built with default prefix=/usr
|
||||
#
|
||||
#
|
||||
# The following va+riables are used and can be overwritten
|
||||
#
|
||||
# INSTALL_LAYOUT installation layout (DEFAULT = standard for tar.gz and zip packages
|
||||
# RPM packages
|
||||
#
|
||||
# BIN_INSTALL_DIR location of binaries (mariadb_config)
|
||||
# LIB_INSTALL_DIR location of libraries
|
||||
# PLUGIN_INSTALL_DIR location of plugins
|
||||
|
||||
IF(NOT INSTALL_LAYOUT)
|
||||
SET(INSTALL_LAYOUT "DEFAULT")
|
||||
ENDIF()
|
||||
|
||||
SET(INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE
|
||||
STRING "Installation layout. Currently supported options are DEFAULT (tar.gz and zip), RPM and DEB")
|
||||
|
||||
# On Windows we only provide zip and .msi. Latter one uses a different packager.
|
||||
IF(UNIX)
|
||||
IF(INSTALL_LAYOUT MATCHES "RPM")
|
||||
SET(libmariadb_prefix "/usr")
|
||||
ELSEIF(INSTALL_LAYOUT MATCHES "DEFAULT|DEB")
|
||||
SET(libmariadb_prefix ${CMAKE_INSTALL_PREFIX})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(CMAKE_DEFAULT_PREFIX_INITIALIZED_BY_DEFAULT)
|
||||
SET(CMAKE_DEFAULT_PREFIX ${libmariadb_prefix} CACHE PATH "Installation prefix" FORCE)
|
||||
ENDIF()
|
||||
|
||||
# check if the specified installation layout is valid
|
||||
SET(VALID_INSTALL_LAYOUTS "DEFAULT" "RPM" "DEB")
|
||||
LIST(FIND VALID_INSTALL_LAYOUTS "${INSTALL_LAYOUT}" layout_no)
|
||||
IF(layout_no EQUAL -1)
|
||||
MESSAGE(FATAL_ERROR "Invalid installation layout. Please specify one of the following layouts: ${VALID_INSTALL_LAYOUTS}")
|
||||
ENDIF()
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Todo: We don't generate man pages yet, will fix it
|
||||
# later (webhelp to man transformation)
|
||||
#
|
||||
|
||||
#
|
||||
# DEFAULT layout
|
||||
#
|
||||
SET(LIBSUFFIX_INSTALL_DIR_DEFAULT "mariadb")
|
||||
SET(SUFFIX_INSTALL_DIR_DEFAULT "mariadb")
|
||||
SET(BIN_INSTALL_DIR_DEFAULT "bin")
|
||||
SET(LIB_INSTALL_DIR_DEFAULT "lib")
|
||||
SET(INCLUDE_INSTALL_DIR_DEFAULT "include")
|
||||
SET(DOCS_INSTALL_DIR_DEFAULT "docs")
|
||||
SET(PLUGIN_INSTALL_DIR_DEFAULT "lib/plugin")
|
||||
SET(LIBMARIADB_STATIC_DEFAULT "mariadbclient")
|
||||
|
||||
#
|
||||
# RPM layout
|
||||
#
|
||||
SET(LIBSUFFIX_INSTALL_DIR_RPM "mariadb")
|
||||
SET(SUFFIX_INSTALL_DIR_RPM "mariadb")
|
||||
SET(BIN_INSTALL_DIR_RPM "bin")
|
||||
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
|
||||
SET(LIB_INSTALL_DIR_RPM "lib64")
|
||||
SET(PLUGIN_INSTALL_DIR_RPM "lib64/plugin")
|
||||
ELSE()
|
||||
SET(LIB_INSTALL_DIR_RPM "lib")
|
||||
SET(PLUGIN_INSTALL_DIRDIR_RPM "lib/plugin")
|
||||
ENDIF()
|
||||
SET(LIBMARIADB_STATIC_RPM "mariadbclient")
|
||||
SET(INCLUDE_INSTALL_DIR_RPM "include")
|
||||
SET(DOCS_INSTALL_DIR_RPM "docs")
|
||||
SET(PLUGIN_INSTALL_DIR_RPM "lib/plugin")
|
||||
|
||||
#
|
||||
# DEB Layout
|
||||
#
|
||||
SET(SUFFIX_INSTALL_DIR_DEB "mariadb")
|
||||
SET(LIBSUFFIX_INSTALL_DIR_DEB "${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
SET(BIN_INSTALL_DIR_DEB "bin")
|
||||
SET(LIB_INSTALL_DIR_DEB "lib")
|
||||
SET(PLUGIN_INSTALL_DIR_DEB "lib/${CMAKE_LIBRARY_ARCHITECTURE}/plugin")
|
||||
SET(INCLUDE_INSTALL_DIR_DEB "include")
|
||||
SET(DOCS_INSTALL_DIR_DEB "docs")
|
||||
SET(PLUGIN_INSTALL_DIR_DEB "lib/${CMAKE_LIBRARY_ARCHITECTURE}/mariadb/plugin")
|
||||
SET(LIBMARIADB_STATIC_DEB "mariadb")
|
||||
|
||||
#
|
||||
# Overwrite defaults
|
||||
#
|
||||
IF(LIB_INSTALL_DIR)
|
||||
SET(LIB_INSTALL_DIR_${INSTALL_LAYOUT} ${LIB_INSTALL_DIR})
|
||||
ENDIF()
|
||||
|
||||
IF(PLUGIN_INSTALL_DIR)
|
||||
SET(PLUGIN_INSTALL_DIR_${INSTALL_LAYOUT} ${PLUGIN_INSTALL_DIR})
|
||||
ENDIF()
|
||||
|
||||
IF(INCLUDE_INSTALL_DIR)
|
||||
SET(INCLUDE_INSTALL_DIR_${INSTALL_LAYOUT} ${INCLUDE_INSTALL_DIR})
|
||||
ENDIF()
|
||||
|
||||
IF(BIN_INSTALL_DIR)
|
||||
SET(BIN_INSTALL_DIR_${INSTALL_LAYOUT} ${BIN_INSTALL_DIR})
|
||||
ENDIF()
|
||||
|
||||
IF(NOT PREFIX_INSTALL_DIR)
|
||||
SET(PREFIX_INSTALL_DIR_${INSTALL_LAYOUT} ${libmariadb_prefix})
|
||||
ELSE()
|
||||
SET(PREFIX_INSTALL_DIR_${INSTALL_LAYOUT} ${PREFIX_INSTALL_DIR})
|
||||
ENDIF()
|
||||
|
||||
IF(NOT SUFFIX_INSTALL_DIR)
|
||||
SET(SUFFIX_INSTALL_DIR_${INSTALL_LAYOUT} "mariadb")
|
||||
ELSE()
|
||||
SET(SUFFIX_INSTALL_DIR_${INSTALL_LAYOUT} ${SUFFIX_INSTALL_DIR})
|
||||
ENDIF()
|
||||
|
||||
FOREACH(dir "BIN" "LIB" "INCLUDE" "DOCS" "PREFIX" "SUFFIX" "LIBSUFFIX" "PLUGIN")
|
||||
SET(${dir}_INSTALL_DIR ${${dir}_INSTALL_DIR_${INSTALL_LAYOUT}})
|
||||
MARK_AS_ADVANCED(${dir}_INSTALL_DIR)
|
||||
ENDFOREACH()
|
||||
|
||||
SET(LIBMARIADB_STATIC_NAME ${LIBMARIADB_STATIC_${INSTALL_LAYOUT}})
|
||||
MARK_AS_ADVANCED(LIBMARIADB_STATIC_NAME)
|
19
module/Vendor/MDBC/cmake/linux_x86_toolchain.cmake
vendored
Normal file
19
module/Vendor/MDBC/cmake/linux_x86_toolchain.cmake
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
# toolchain file for building a 32bit version on a 64bit host
|
||||
|
||||
# Usage:
|
||||
# cmake -DCMAKE_TOOLCHAIN_FILE=linux_86.toolchain.cmake
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
set(CMAKE_SYSTEM_PROCESSOR "i686")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
|
21
module/Vendor/MDBC/cmake/sign.cmake
vendored
Normal file
21
module/Vendor/MDBC/cmake/sign.cmake
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
MACRO(SIGN_TARGET target)
|
||||
IF(WITH_SIGNCODE)
|
||||
IF(WIN32)
|
||||
IF(WITH_SIGNCODE STREQUAL 2)
|
||||
SET(SIGN_OPTIONS "/a /fd sha256 /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td sha256 ")
|
||||
ENDIF()
|
||||
IF(EXISTS "/tools/sign.bat")
|
||||
ADD_CUSTOM_COMMAND(TARGET ${target} COMMAND /tools/sign.bat ARGS ${target_file})
|
||||
ELSEIF()
|
||||
ADD_CUSTOM_COMMAND(TARGET ${target} COMMAND signtool ARGS sign ${SIGN_OPTIONS} ${target_file})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDMACRO()
|
37
module/Vendor/MDBC/cmake/symlink.cmake
vendored
Normal file
37
module/Vendor/MDBC/cmake/symlink.cmake
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
MACRO(create_symlink symlink_name target install_path)
|
||||
# According to cmake documentation symlinks work on unix systems only
|
||||
IF(UNIX)
|
||||
# Get target components
|
||||
GET_TARGET_PROPERTY(target_location ${target} LOCATION)
|
||||
GET_FILENAME_COMPONENT(target_path ${target_location} PATH)
|
||||
GET_FILENAME_COMPONENT(target_name ${target_location} NAME)
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${target_path}/${symlink_name}
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${target_path}/${symlink_name}
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink ${target_name} ${symlink_name}
|
||||
WORKING_DIRECTORY ${target_path}
|
||||
DEPENDS ${target}
|
||||
)
|
||||
|
||||
ADD_CUSTOM_TARGET(SYM_${symlink_name}
|
||||
ALL
|
||||
DEPENDS ${target_path}/${symlink_name})
|
||||
SET_TARGET_PROPERTIES(SYM_${symlink_name} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
IF(CMAKE_GENERATOR MATCHES "Xcode")
|
||||
# For Xcode, replace project config with install config
|
||||
STRING(REPLACE "${CMAKE_CFG_INTDIR}"
|
||||
"\${CMAKE_INSTALL_CONFIG_NAME}" output ${target_path}/${symlink_name})
|
||||
ENDIF()
|
||||
|
||||
INSTALL(FILES ${target_path}/${symlink_name} DESTINATION ${install_path})
|
||||
ENDIF()
|
||||
ENDMACRO()
|
44
module/Vendor/MDBC/cmake/version_info.cmake
vendored
Normal file
44
module/Vendor/MDBC/cmake/version_info.cmake
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
#
|
||||
# Copyright (C) 2013-2016 MariaDB Corporation AB
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
FUNCTION(GET_FILE_VERSION FILE_NAME FILE_VERSION)
|
||||
|
||||
# if we build from a git repository, we calculate the file version:
|
||||
# Patch number is numer of commits for given file
|
||||
IF(EXISTS ${CC_SOURCE_DIR}/.git)
|
||||
EXECUTE_PROCESS(COMMAND git --git-dir=${CC_SOURCE_DIR}/.git --work-tree=${CC_SOURCE_DIR} rev-list HEAD --count -- ${FILE_NAME}
|
||||
OUTPUT_VARIABLE FV)
|
||||
STRING(REPLACE "\n" "" FV ${FV})
|
||||
SET(${FILE_VERSION} ${FV} PARENT_SCOPE)
|
||||
ELSE()
|
||||
SET(${FILE_VERSION} 0)
|
||||
ENDIF()
|
||||
ENDFUNCTION()
|
||||
|
||||
MACRO(SET_VERSION_INFO)
|
||||
SET(FILE_VERSION "0")
|
||||
FOREACH(PROPERTY ${ARGN})
|
||||
IF(${PROPERTY} MATCHES "TARGET:")
|
||||
STRING(REGEX REPLACE "^[TARGET:\\s]" "" TARGET ${PROPERTY})
|
||||
ELSEIF(${PROPERTY} MATCHES "FILE_TYPE:")
|
||||
STRING(REGEX REPLACE "^[FILE_TYPE:\\s]" "" FILE_TYPE ${PROPERTY})
|
||||
ELSEIF(${PROPERTY} MATCHES "ORIGINAL_FILE_NAME:")
|
||||
STRING(REGEX REPLACE "^[ORIGINAL_FILE_NAME:\\s]" "" ORIGINAL_FILE_NAME ${PROPERTY})
|
||||
ELSEIF(${PROPERTY} MATCHES "SOURCE_FILE:")
|
||||
STRING(REGEX REPLACE "^[SOURCE_FILE:\\s]" "" SOURCE ${PROPERTY})
|
||||
GET_FILE_VERSION(${SOURCE} FILE_VERSION)
|
||||
ELSEIF(${PROPERTY} MATCHES "FILE_DESCRIPTION:")
|
||||
STRING(REPLACE "FILE_DESCRIPTION:" "" FILE_DESCRIPTION ${PROPERTY})
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
CONFIGURE_FILE(${CC_SOURCE_DIR}/win/resource.rc.in
|
||||
${CC_BINARY_DIR}/win/${TARGET}.rc)
|
||||
SET(${TARGET}_RC ${CC_BINARY_DIR}/win/${TARGET}.rc)
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
|
18
module/Vendor/MDBC/examples/CMakeLists.txt
vendored
Normal file
18
module/Vendor/MDBC/examples/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
SET(EXAMPLE_FILES "mysql_affected_rows"
|
||||
"mysql_debug")
|
||||
|
||||
INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include)
|
||||
|
||||
ENABLE_TESTING()
|
||||
|
||||
# this will be the main tests which saves output
|
||||
# from example files
|
||||
ADD_EXECUTABLE(test_output test_output.c)
|
||||
|
||||
FOREACH(EXAMPLE_FILE ${EXAMPLE_FILES})
|
||||
SET(XML_EXAMPLE_FILES $XML_EXAMPLE_FILES "examples/${EXAMPLE_FILE}.c")
|
||||
ADD_EXECUTABLE(${EXAMPLE_FILE} ${EXAMPLE_FILE}.c)
|
||||
TARGET_LINK_LIBRARIES(${EXAMPLE_FILE} mariadbclient)
|
||||
ADD_TEST(TEST_${EXAMPLE_FILE} ./${EXECUTABLE_OUTPUT_PATH}/test_output ./${EXAMPLE_FILE} ${CC_SOURCE_DIR}/examples/${EXAMPLE_FILE}.out ${CC_SOURCE_DIR}/examples/${EXAMPLE_FILE}.exp)
|
||||
|
||||
ENDFOREACH(EXAMPLE_FILE ${EXAMPLE_FILES})
|
82
module/Vendor/MDBC/examples/mysql_affected_rows.c
vendored
Normal file
82
module/Vendor/MDBC/examples/mysql_affected_rows.c
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
#include <mysql.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void show_error(MYSQL *mysql)
|
||||
{
|
||||
printf("Error(%d) [%s] \"%s\"", mysql_errno(mysql),
|
||||
mysql_sqlstate(mysql),
|
||||
mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
MYSQL *mysql;
|
||||
const char *query;
|
||||
MYSQL_RES *result;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
if (!mysql_real_connect(mysql, "localhost", "example", "example_pw",
|
||||
"example_db", 0, "/tmp/mysql.sock", 0))
|
||||
show_error(mysql);
|
||||
|
||||
query= "DROP TABLE IF EXISTS affected_rows";
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
show_error(mysql);
|
||||
|
||||
query= "CREATE TABLE affected_rows (id int not null, my_name varchar(50),"
|
||||
"PRIMARY KEY(id))";
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
show_error(mysql);
|
||||
|
||||
/* Affected rows with INSERT statement */
|
||||
query= "INSERT INTO affected_rows VALUES (1, \"First value\"),"
|
||||
"(2, \"Second value\")";
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
show_error(mysql);
|
||||
printf("Affected_rows after INSERT: %lu\n",
|
||||
(unsigned long) mysql_affected_rows(mysql));
|
||||
|
||||
/* Affected rows with REPLACE statement */
|
||||
query= "REPLACE INTO affected_rows VALUES (1, \"First value\"),"
|
||||
"(2, \"Second value\")";
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
show_error(mysql);
|
||||
printf("Affected_rows after REPLACE: %lu\n",
|
||||
(unsigned long) mysql_affected_rows(mysql));
|
||||
|
||||
/* Affected rows with UPDATE statement */
|
||||
query= "UPDATE affected_rows SET id=1 WHERE id=1";
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
show_error(mysql);
|
||||
printf("Affected_rows after UPDATE: %lu\n",
|
||||
(unsigned long) mysql_affected_rows(mysql));
|
||||
|
||||
query= "UPDATE affected_rows SET my_name=\"Monty\" WHERE id=1";
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
show_error(mysql);
|
||||
printf("Affected_rows after UPDATE: %lu\n",
|
||||
(unsigned long) mysql_affected_rows(mysql));
|
||||
|
||||
/* Affected rows after select */
|
||||
query= "SELECT id, my_name FROM affected_rows";
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
show_error(mysql);
|
||||
result= mysql_store_result(mysql);
|
||||
printf("Affected_rows after SELECT and storing result set: %lu\n",
|
||||
(unsigned long) mysql_affected_rows(mysql));
|
||||
mysql_free_result(result);
|
||||
|
||||
/* Affected rows with DELETE statment */
|
||||
query= "DELETE FROM affected_rows";
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
show_error(mysql);
|
||||
printf("Affected_rows after DELETE: %lu\n",
|
||||
(unsigned long) mysql_affected_rows(mysql));
|
||||
|
||||
mysql_close(mysql);
|
||||
return 0;
|
||||
}
|
40
module/Vendor/MDBC/examples/mysql_debug.c
vendored
Normal file
40
module/Vendor/MDBC/examples/mysql_debug.c
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
#include <mysql.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void show_error(MYSQL *mysql)
|
||||
{
|
||||
printf("Error(%d) [%s] \"%s\"", mysql_errno(mysql),
|
||||
mysql_sqlstate(mysql),
|
||||
mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
MYSQL *mysql;
|
||||
const char *query;
|
||||
|
||||
mysql_debug("d:t:O");
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
if (!mysql_real_connect(mysql, "localhost", "example", "example_pw",
|
||||
"example_db", 0, "/tmp/mysql.sock", 0))
|
||||
show_error(mysql);
|
||||
|
||||
query= "DROP TABLE IF EXISTS debug_example";
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
show_error(mysql);
|
||||
|
||||
query= "CREATE TABLE debug_example (id int not null, my_name varchar(50),"
|
||||
"PRIMARY KEY(id))";
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
show_error(mysql);
|
||||
|
||||
mysql_close(mysql);
|
||||
|
||||
return 0;
|
||||
}
|
72
module/Vendor/MDBC/examples/test_output.c
vendored
Normal file
72
module/Vendor/MDBC/examples/test_output.c
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef _WIN32
|
||||
#define popen _popen
|
||||
#define pclose _pclose
|
||||
#endif
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char cmd_output[1024];
|
||||
char cmd_exp[1024];
|
||||
FILE *fp_exec, *fp_out, *fp_exp;
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
printf("Syntax: test_output test output expected");
|
||||
exit(-1);
|
||||
}
|
||||
if (!(fp_exec= popen(argv[1], "r")))
|
||||
{
|
||||
printf("Failed to run %s\n", argv[1]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!(fp_out= fopen(argv[2], "w")))
|
||||
{
|
||||
printf("Failed to open %s for write\n", argv[2]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
while (NULL != fgets(cmd_output, sizeof(cmd_output-1), fp_exec))
|
||||
{
|
||||
fputs(cmd_output, fp_out);
|
||||
}
|
||||
pclose(fp_exec);
|
||||
fflush(fp_out);
|
||||
fclose(fp_out);
|
||||
|
||||
if (argc == 3)
|
||||
return 0;
|
||||
|
||||
if (!(fp_exp= fopen(argv[3], "r")))
|
||||
{
|
||||
/* if no exp file exists, we just return
|
||||
without an error = skip check */
|
||||
return(0);
|
||||
}
|
||||
if (!(fp_out= fopen(argv[2], "r")))
|
||||
{
|
||||
printf("Failed to open %s for read\n", argv[2]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
while (fgets(cmd_exp, sizeof(cmd_exp)-1, fp_exp))
|
||||
{
|
||||
if (!fgets(cmd_output, sizeof(cmd_output)-1, fp_out))
|
||||
{
|
||||
printf("Can't read from output file\n");
|
||||
goto error;
|
||||
}
|
||||
if (strcmp(cmd_output, cmd_exp))
|
||||
{
|
||||
printf("output and expected output are different\n");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
error:
|
||||
fclose(fp_exp);
|
||||
fclose(fp_out);
|
||||
return 1;
|
||||
}
|
37
module/Vendor/MDBC/include/CMakeLists.txt
vendored
Normal file
37
module/Vendor/MDBC/include/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
SET(MARIADB_CLIENT_INCLUDES config-win.h
|
||||
dbug.h
|
||||
errmsg.h
|
||||
getopt.h
|
||||
hash.h
|
||||
ma_common.h
|
||||
m_ctype.h
|
||||
m_string.h
|
||||
ma_dyncol.h
|
||||
ma_secure.h
|
||||
my_alarm.h
|
||||
my_base.h
|
||||
my_config.h.in
|
||||
my_dir.h
|
||||
my_global.h
|
||||
my_list.h
|
||||
my_net.h
|
||||
my_no_pthread.h
|
||||
my_pthread.h
|
||||
my_stmt.h
|
||||
my_sys.h
|
||||
mysql.h
|
||||
mysql_com.h
|
||||
mysql_io.h
|
||||
mysql_mm.h
|
||||
mysql_priv.h
|
||||
mysql_version.h
|
||||
mysql_wireprotocol.h
|
||||
mysqld_error.h
|
||||
mysys_err.h
|
||||
sha1.h
|
||||
thr_alarm.h
|
||||
violite.h
|
||||
mysql/client_plugin.h
|
||||
mysql/plugin_auth_common.h
|
||||
mysql/plugin_auth.h
|
||||
PARENT_SCOPE)
|
279
module/Vendor/MDBC/include/config-win.h
vendored
Normal file
279
module/Vendor/MDBC/include/config-win.h
vendored
Normal file
@ -0,0 +1,279 @@
|
||||
/* 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 */
|
||||
|
||||
/* Defines for Win32 to make it compatible for MySQL */
|
||||
|
||||
#ifndef _config_win_h_
|
||||
#define _config_win_h_
|
||||
|
||||
#include <sys/locking.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <math.h> /* Because of rint() */
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <malloc.h>
|
||||
#include <sys/stat.h>
|
||||
#include <process.h>
|
||||
|
||||
#ifndef THREAD
|
||||
#define THREAD
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
#define MACHINE_TYPE "ia64" /* Define to machine type name */
|
||||
#else
|
||||
#define MACHINE_TYPE "i32" /* Define to machine type name */
|
||||
#endif /* _WIN64 */
|
||||
|
||||
/* File and lock constants */
|
||||
#define O_SHARE 0x1000 /* Open file in sharing mode */
|
||||
#ifdef __BORLANDC__
|
||||
#define F_RDLCK LK_NBLCK /* read lock */
|
||||
#define F_WRLCK LK_NBRLCK /* write lock */
|
||||
#define F_UNLCK LK_UNLCK /* remove lock(s) */
|
||||
#else
|
||||
#define F_RDLCK _LK_NBLCK /* read lock */
|
||||
#define F_WRLCK _LK_NBRLCK /* write lock */
|
||||
#define F_UNLCK _LK_UNLCK /* remove lock(s) */
|
||||
#endif
|
||||
|
||||
#define F_EXCLUSIVE 1 /* We have only exclusive locking */
|
||||
#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */
|
||||
#define F_OK 0 /* parameter to access() */
|
||||
|
||||
#ifndef S_IROTH
|
||||
#define S_IROTH S_IREAD /* for my_lib */
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
|
||||
#define O_TEMPORARY 0
|
||||
#define O_SHORT_LIVED 0
|
||||
#define SH_DENYNO _SH_DENYNO
|
||||
#else
|
||||
#define O_BINARY _O_BINARY /* compability with MSDOS */
|
||||
#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */
|
||||
#define O_TEMPORARY _O_TEMPORARY
|
||||
#define O_SHORT_LIVED _O_SHORT_LIVED
|
||||
#define SH_DENYNO _SH_DENYNO
|
||||
#endif
|
||||
#define NO_OPEN_3 /* For my_create() */
|
||||
|
||||
#define SIGQUIT SIGTERM /* No SIGQUIT */
|
||||
|
||||
#undef _REENTRANT /* Crashes something for win32 */
|
||||
#undef SAFE_MUTEX /* Can't be used on windows */
|
||||
|
||||
#define LL(A) ((__int64) A)
|
||||
|
||||
/* Type information */
|
||||
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
|
||||
typedef __int64 longlong;
|
||||
typedef int sigset_t;
|
||||
#define longlong_defined
|
||||
/* off_t should not be __int64 because of conflicts in header files;
|
||||
Use my_off_t or os_off_t instead */
|
||||
typedef long off_t;
|
||||
typedef __int64 os_off_t;
|
||||
#ifdef _WIN64
|
||||
typedef UINT_PTR rf_SetTimer;
|
||||
#else
|
||||
typedef uint rf_SetTimer;
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && !(_MSC_VER < 1800))
|
||||
#define HAVE_STRTOULL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#endif
|
||||
|
||||
#define Socket_defined
|
||||
#define my_socket SOCKET
|
||||
#ifndef bool
|
||||
#define bool BOOL
|
||||
#endif
|
||||
#define SIGPIPE SIGINT
|
||||
#define RETQSORTTYPE void
|
||||
#define QSORT_TYPE_IS_VOID
|
||||
#define RETSIGTYPE void
|
||||
#define SOCKET_SIZE_TYPE int
|
||||
#define my_socket_defined
|
||||
#define bool_defined
|
||||
#define byte_defined
|
||||
#define HUGE_PTR
|
||||
#define STDCALL __stdcall /* Used by libmariadb.dll */
|
||||
|
||||
#define VOID_SIGHANDLER
|
||||
#define SIZEOF_CHAR 1
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF_OFF_T 8
|
||||
#define HAVE_BROKEN_NETINET_INCLUDES
|
||||
#ifdef __NT__
|
||||
#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
|
||||
#endif
|
||||
|
||||
/* Use all character sets in MySQL */
|
||||
#define USE_MB 1
|
||||
#define USE_MB_IDENT 1
|
||||
#define USE_STRCOLL 1
|
||||
|
||||
/* Convert some simple functions to Posix */
|
||||
|
||||
#define sigset(A,B) signal((A),(B))
|
||||
#define finite(A) _finite(A)
|
||||
#define sleep(A) Sleep((A)*1000)
|
||||
|
||||
#ifndef __BORLANDC__
|
||||
#define access(A,B) _access(A,B)
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
inline double rint(double nr)
|
||||
{
|
||||
double f = floor(nr);
|
||||
double c = ceil(nr);
|
||||
return (((c-nr) >= (nr-f)) ? f :c);
|
||||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
#define ulonglong2double(A) ((double) (A))
|
||||
#define my_off_t2double(A) ((double) (A))
|
||||
|
||||
#else
|
||||
inline double ulonglong2double(ulonglong value)
|
||||
{
|
||||
longlong nr=(longlong) value;
|
||||
if (nr >= 0)
|
||||
return (double) nr;
|
||||
return (18446744073709551616.0 + (double) nr);
|
||||
}
|
||||
#define my_off_t2double(A) ulonglong2double(A)
|
||||
#endif /* _WIN64 */
|
||||
#else
|
||||
#define inline __inline
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define __attribute(A)
|
||||
|
||||
#if SIZEOF_OFF_T > 4
|
||||
#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
|
||||
#define tell(A) _telli64(A)
|
||||
#endif
|
||||
|
||||
#define STACK_DIRECTION -1
|
||||
|
||||
/* redefine deprecated functions
|
||||
#define sprintf sprintf_s
|
||||
#define strcpy strcpy_s
|
||||
#define strcat strcat_s
|
||||
#define fopen fopen_r
|
||||
#define freopen freopen_r
|
||||
#define getenv _dupenv_s
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#define HAVE_PERROR
|
||||
#define HAVE_VFPRINT
|
||||
#define HAVE_CHSIZE /* System has chsize() function */
|
||||
#define HAVE_RENAME /* Have rename() as function */
|
||||
#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */
|
||||
#define HAVE_LONG_JMP /* Have long jump function */
|
||||
#define HAVE_LOCKING /* have locking() call */
|
||||
#define HAVE_ERRNO_AS_DEFINE /* errno is a define */
|
||||
#define HAVE_STDLIB /* everything is include in this file */
|
||||
#define HAVE_MEMCPY
|
||||
#define HAVE_MEMMOVE
|
||||
#define HAVE_GETCWD
|
||||
#define HAVE_TELL
|
||||
#define HAVE_TZNAME
|
||||
#define HAVE_PUTENV
|
||||
#define HAVE_SELECT
|
||||
#define HAVE_SETLOCALE
|
||||
#define HAVE_SOCKET /* Giangi */
|
||||
#define HAVE_FLOAT_H
|
||||
#define HAVE_LIMITS_H
|
||||
#define HAVE_STDDEF_H
|
||||
#define HAVE_RINT /* defined in this file */
|
||||
#define NO_FCNTL_NONBLOCK /* No FCNTL */
|
||||
#define HAVE_ALLOCA
|
||||
#define HAVE_STRPBRK
|
||||
#define HAVE_STRSTR
|
||||
|
||||
#ifdef WIN32
|
||||
#define HAVE_SNPRINTF /* Gave link error */
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
|
||||
#define HAVE_ANSI_INCLUDE
|
||||
#define HAVE_SYS_UTIME_H
|
||||
#define HAVE_STRTOUL
|
||||
#endif
|
||||
#define my_reinterpret_cast(A) reinterpret_cast <A>
|
||||
#define my_const_cast(A) const_cast<A>
|
||||
|
||||
/* MYSQL OPTIONS */
|
||||
|
||||
#ifdef _CUSTOMCONFIG_
|
||||
#include <custom_conf.h>
|
||||
#else
|
||||
#define DEFAULT_MYSQL_HOME "c:\\mysql"
|
||||
#define PACKAGE "mysql"
|
||||
#define DEFAULT_BASEDIR "C:\\"
|
||||
#define SHAREDIR "share"
|
||||
#define DEFAULT_CHARSET_HOME "C:/mysql/"
|
||||
#endif
|
||||
|
||||
/* File name handling */
|
||||
|
||||
#define FN_LIBCHAR '\\'
|
||||
#define FN_ROOTDIR "\\"
|
||||
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
|
||||
#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
|
||||
#define MY_NFILE 1024
|
||||
|
||||
#define DO_NOT_REMOVE_THREAD_WRAPPERS
|
||||
#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
|
||||
/* The following is only used for statistics, so it should be good enough */
|
||||
#ifdef __NT__ /* This should also work on Win98 but .. */
|
||||
#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
|
||||
#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
|
||||
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
|
||||
#else
|
||||
#define thread_safe_add(V,C,L) \
|
||||
pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
|
||||
#define thread_safe_sub(V,C,L) \
|
||||
pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
|
||||
#define statistic_add(V,C,L) (V)+=(C)
|
||||
#endif
|
||||
#define statistic_increment(V,L) thread_safe_increment((V),(L))
|
||||
#define strcasecmp(A,B) _stricmp((A),(B))
|
||||
|
||||
#define close(A) _close((A))
|
||||
#define fdopen(A,B) _fdopen((A),(B))
|
||||
#define sopen(A,B,C,D) _sopen((A),(B),(C),(D))
|
||||
|
||||
|
||||
#endif
|
151
module/Vendor/MDBC/include/dbug.h
vendored
Normal file
151
module/Vendor/MDBC/include/dbug.h
vendored
Normal file
@ -0,0 +1,151 @@
|
||||
/* 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 _dbug_h
|
||||
#define _dbug_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* unsupported macros (used by async) */
|
||||
#define DBUG_SWAP_CODE_STATE(a) {}
|
||||
#define DBUG_FREE_CODE_STATE(a) {}
|
||||
|
||||
#if !defined(DBUG_OFF) && !defined(_lint)
|
||||
|
||||
struct _db_stack_frame_ {
|
||||
const char *func; /* function name of the previous stack frame */
|
||||
const char *file; /* filename of the function of previous frame */
|
||||
uint level; /* this nesting level, highest bit enables tracing */
|
||||
struct _db_stack_frame_ *prev; /* pointer to the previous frame */
|
||||
};
|
||||
|
||||
struct _db_code_state_;
|
||||
extern my_bool _dbug_on_;
|
||||
extern my_bool _db_keyword_(struct _db_code_state_ *, const char *, int);
|
||||
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
|
||||
extern int _db_explain_init_(char *buf, size_t len);
|
||||
extern int _db_is_pushed_(void);
|
||||
extern void _db_setjmp_(void);
|
||||
extern void _db_longjmp_(void);
|
||||
extern void _db_process_(const char *name);
|
||||
extern void _db_push_(const char *control);
|
||||
extern void _db_pop_(void);
|
||||
extern void _db_set_(const char *control);
|
||||
extern void _db_set_init_(const char *control);
|
||||
extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
|
||||
struct _db_stack_frame_ *_stack_frame_);
|
||||
extern void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_);
|
||||
extern void _db_pargs_(uint _line_,const char *keyword);
|
||||
extern void _db_doprnt_ _VARARGS((const char *format,...));
|
||||
extern void _db_dump_(uint _line_,const char *keyword,
|
||||
const unsigned char *memory, size_t length);
|
||||
extern void _db_end_(void);
|
||||
extern void _db_lock_file_(void);
|
||||
extern void _db_unlock_file_(void);
|
||||
extern FILE *_db_fp_(void);
|
||||
extern void _db_flush_();
|
||||
extern const char* _db_get_func_(void);
|
||||
/*
|
||||
#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \
|
||||
_db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
|
||||
#define DBUG_LEAVE \
|
||||
(_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_))
|
||||
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
|
||||
#define DBUG_VOID_RETURN {DBUG_LEAVE; return;}
|
||||
#define DBUG_END() _db_end_ ()
|
||||
#define DBUG_EXECUTE(keyword,a1) \
|
||||
{if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}}
|
||||
#define DBUG_PRINT(keyword,arglist) \
|
||||
{if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}}
|
||||
#define DBUG_PUSH(a1) _db_push_ (a1)
|
||||
#define DBUG_POP() _db_pop_ ()
|
||||
#define DBUG_PROCESS(a1) (_db_process_ = a1)
|
||||
#define DBUG_FILE (_db_fp_)
|
||||
#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
|
||||
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
|
||||
#define DBUG_DUMP(keyword,a1,a2)\
|
||||
{if (_db_on_) {_db_dump_(__LINE__,keyword,a1,a2);}}
|
||||
#define DBUG_IN_USE (_db_fp_ && _db_fp_ != stderr)
|
||||
#define DEBUGGER_OFF _no_db_=1;_db_on_=0;
|
||||
#define DEBUGGER_ON _no_db_=0
|
||||
#define DBUG_LOCK_FILE { _db_lock_file(); }
|
||||
#define DBUG_UNLOCK_FILE { _db_unlock_file(); }
|
||||
#define DBUG_ASSERT(A) assert(A) */
|
||||
#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \
|
||||
_db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
|
||||
#define DBUG_LEAVE _db_return_ (__LINE__, &_db_stack_frame_)
|
||||
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
|
||||
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
|
||||
#define DBUG_EXECUTE(keyword,a1) \
|
||||
do {if (_db_keyword_(0, (keyword), 0)) { a1 }} while(0)
|
||||
#define DBUG_EXECUTE_IF(keyword,a1) \
|
||||
do {if (_db_keyword_(0, (keyword), 1)) { a1 }} while(0)
|
||||
#define DBUG_EVALUATE(keyword,a1,a2) \
|
||||
(_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
|
||||
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
|
||||
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
|
||||
#define DBUG_PRINT(keyword,arglist) \
|
||||
do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
|
||||
#define DBUG_PUSH(a1) _db_push_ (a1)
|
||||
#define DBUG_POP() _db_pop_ ()
|
||||
#define DBUG_SET(a1) _db_set_ (a1)
|
||||
#define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
|
||||
#define DBUG_PROCESS(a1) _db_process_(a1)
|
||||
#define DBUG_FILE _db_fp_()
|
||||
#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
|
||||
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
|
||||
#define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
|
||||
#define DBUG_END() _db_end_ ()
|
||||
#define DBUG_LOCK_FILE _db_lock_file_()
|
||||
#define DBUG_UNLOCK_FILE _db_unlock_file_()
|
||||
#define DBUG_ASSERT(A) assert(A)
|
||||
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
|
||||
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
|
||||
#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
|
||||
#define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
|
||||
#ifndef _WIN32
|
||||
#define DBUG_ABORT() (_db_flush_(), abort())
|
||||
#else
|
||||
#define DBUG_ABORT() (_db_flush_(), exit(3))
|
||||
#endif
|
||||
|
||||
#else /* No debugger */
|
||||
#define DBUG_ENTER(a1)
|
||||
#define DBUG_END() {}
|
||||
#define DBUG_RETURN(a1) return(a1)
|
||||
#define DBUG_VOID_RETURN return
|
||||
#define DBUG_EXECUTE(keyword,a1) {}
|
||||
#define DBUG_PRINT(keyword,arglist) {}
|
||||
#define DBUG_PUSH(a1) {}
|
||||
#define DBUG_POP() {}
|
||||
#define DBUG_PROCESS(a1) {}
|
||||
#define DBUG_FILE (stderr)
|
||||
#define DBUG_SETJMP setjmp
|
||||
#define DBUG_LONGJMP longjmp
|
||||
#define DBUG_DUMP(keyword,a1,a2) {}
|
||||
#define DBUG_IN_USE 0
|
||||
#define DEBUGGER_OFF
|
||||
#define DEBUGGER_ON
|
||||
#define DBUG_LOCK_FILE
|
||||
#define DBUG_UNLOCK_FILE
|
||||
#define DBUG_ASSERT(A) {}
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
81
module/Vendor/MDBC/include/errmsg.h
vendored
Normal file
81
module/Vendor/MDBC/include/errmsg.h
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/* 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 */
|
||||
|
||||
/* 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 */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define CR_MIN_ERROR 2000 /* For easier client code */
|
||||
#define CR_MAX_ERROR 2999
|
||||
#if defined(OS2) && defined( MYSQL_SERVER)
|
||||
#define CER(X) client_errors[(X)-CR_MIN_ERROR]
|
||||
#else
|
||||
#define ER(X) client_errors[(X)-CR_MIN_ERROR]
|
||||
#endif
|
||||
#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */
|
||||
|
||||
#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
|
||||
#define CR_LOCALHOST_CONNECTION 2010
|
||||
#define CR_TCP_CONNECTION 2011
|
||||
#define CR_SERVER_HANDSHAKE_ERR 2012
|
||||
#define CR_SERVER_LOST 2013
|
||||
#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_NET_PACKET_TOO_LARGE 2020
|
||||
#define CR_SSL_CONNECTION_ERROR 2026
|
||||
#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_UNSUPPORTED_PARAM_TYPE 2036
|
||||
#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
|
||||
#define CR_NEW_STMT_METADATA 2057
|
||||
#define CR_AUTH_PLUGIN_CANNOT_LOAD 2058
|
||||
#define CR_ALREADY_CONNECTED 2059
|
||||
#define CR_PLUGIN_FUNCTION_NOT_SUPPORTED 2060
|
||||
|
||||
#define SQLSTATE_UNKNOWN "HY000"
|
||||
|
||||
#endif
|
135
module/Vendor/MDBC/include/getopt.h
vendored
Normal file
135
module/Vendor/MDBC/include/getopt.h
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
The GNU C 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.
|
||||
|
||||
The GNU C 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 the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
#define _GETOPT_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns EOF, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
#if defined (__STDC__) && __STDC__ || defined(__cplusplus)
|
||||
const char *name;
|
||||
#else
|
||||
char *name;
|
||||
#endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
#if ( defined (__STDC__) && __STDC__ ) || defined(__cplusplus) || defined(MSDOS)
|
||||
#ifdef __EMX__
|
||||
int getopt (int, char **, __const__ char *);
|
||||
#elif defined( __GNU_LIBRARY__)
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
||||
#else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt (int argc, char *const *argv, const char *optstring);
|
||||
#endif /* __GNU_LIBRARY__ */
|
||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
extern int getopt_long_only (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int _getopt_internal (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind,
|
||||
int long_only);
|
||||
#else /* not __STDC__ */
|
||||
extern int getopt ();
|
||||
extern int getopt_long ();
|
||||
extern int getopt_long_only ();
|
||||
|
||||
extern int _getopt_internal ();
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GETOPT_H */
|
70
module/Vendor/MDBC/include/hash.h
vendored
Normal file
70
module/Vendor/MDBC/include/hash.h
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
/************************************************************************************
|
||||
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 <http://www.gnu.org/licenses>
|
||||
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
|
||||
*************************************************************************************/
|
||||
|
||||
#ifndef _hash_h
|
||||
#define _hash_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef uchar *(*hash_get_key)(const uchar *,uint*,my_bool);
|
||||
typedef void (*hash_free_key)(void *);
|
||||
|
||||
/* flags for hash_init */
|
||||
#define HASH_CASE_INSENSITIVE 1
|
||||
|
||||
typedef struct st_hash_info {
|
||||
uint next; /* index to next key */
|
||||
uchar *data; /* data for current entry */
|
||||
} HASH_LINK;
|
||||
|
||||
typedef struct st_hash {
|
||||
uint key_offset,key_length; /* Length of key if const length */
|
||||
uint records,blength,current_record;
|
||||
uint flags;
|
||||
DYNAMIC_ARRAY array; /* Place for hash_keys */
|
||||
hash_get_key get_key;
|
||||
void (*free)(void *);
|
||||
uint (*calc_hashnr)(const uchar *key,uint length);
|
||||
} HASH;
|
||||
|
||||
#define hash_init(A,B,C,D,E,F,G) _hash_init(A,B,C,D,E,F,G CALLER_INFO)
|
||||
my_bool _hash_init(HASH *hash,uint default_array_elements, uint key_offset,
|
||||
uint key_length, hash_get_key get_key,
|
||||
void (*free_element)(void*), uint flags CALLER_INFO_PROTO);
|
||||
void hash_free(HASH *tree);
|
||||
uchar *hash_element(HASH *hash,uint idx);
|
||||
gptr hash_search(HASH *info,const uchar *key,uint length);
|
||||
gptr hash_next(HASH *info,const uchar *key,uint length);
|
||||
my_bool hash_insert(HASH *info,const uchar *data);
|
||||
my_bool hash_delete(HASH *hash,uchar *record);
|
||||
my_bool hash_update(HASH *hash,uchar *record,uchar *old_key,uint old_key_length);
|
||||
my_bool hash_check(HASH *hash); /* Only in debug library */
|
||||
|
||||
#define hash_clear(H) bzero((char*) (H),sizeof(*(H)))
|
||||
#define hash_inited(H) ((H)->array.buffer != 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
74
module/Vendor/MDBC/include/m_ctype.h
vendored
Normal file
74
module/Vendor/MDBC/include/m_ctype.h
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
/* 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 inplementation of the UNIX ctype(3) library.
|
||||
Notes: my_global.h should be included before ctype.h
|
||||
*/
|
||||
|
||||
#ifndef _m_ctype_h
|
||||
#define _m_ctype_h
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#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"
|
||||
|
||||
/* we use the mysqlnd implementation */
|
||||
typedef struct charset_info_st
|
||||
{
|
||||
unsigned int nr; /* so far only 1 byte for charset */
|
||||
unsigned int state;
|
||||
char *csname;
|
||||
char *name;
|
||||
char *dir;
|
||||
unsigned int codepage;
|
||||
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);
|
||||
} CHARSET_INFO;
|
||||
|
||||
extern const CHARSET_INFO compiled_charsets[];
|
||||
extern CHARSET_INFO *default_charset_info;
|
||||
extern CHARSET_INFO *my_charset_bin;
|
||||
extern CHARSET_INFO *my_charset_latin1;
|
||||
extern CHARSET_INFO *my_charset_utf8_general_ci;
|
||||
|
||||
CHARSET_INFO *find_compiled_charset(unsigned int cs_number);
|
||||
CHARSET_INFO *find_compiled_charset_by_name(const char *name);
|
||||
|
||||
size_t mysql_cset_escape_quotes(const CHARSET_INFO *cset, char *newstr, const char *escapestr, size_t escapestr_len);
|
||||
size_t mysql_cset_escape_slashes(const CHARSET_INFO *cset, char *newstr, const char *escapestr, size_t escapestr_len);
|
||||
char* madb_get_os_character_set(void);
|
||||
#ifdef _WIN32
|
||||
int madb_get_windows_cp(const char *charset);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
240
module/Vendor/MDBC/include/m_string.h
vendored
Normal file
240
module/Vendor/MDBC/include/m_string.h
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
/* 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 */
|
||||
|
||||
/* There may be prolems include all of theese. Try to test in
|
||||
configure with ones are needed? */
|
||||
|
||||
/* This is needed for the definitions of strchr... on solaris */
|
||||
|
||||
#ifndef _m_string_h
|
||||
#define _m_string_h
|
||||
#ifndef __USE_GNU
|
||||
#define __USE_GNU /* We want to use stpcpy */
|
||||
#endif
|
||||
#if defined(HAVE_STRINGS_H)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#if defined(HAVE_STRING_H)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
/* Correct some things for UNIXWARE7 */
|
||||
#ifdef HAVE_UNIXWARE7_THREADS
|
||||
#undef HAVE_STRINGS_H
|
||||
#undef HAVE_MEMORY_H
|
||||
#define HAVE_MEMCPY
|
||||
#ifndef HAVE_MEMMOVE
|
||||
#define HAVE_MEMMOVE
|
||||
#endif
|
||||
#undef HAVE_BCMP
|
||||
#undef bcopy
|
||||
#undef bcmp
|
||||
#undef bzero
|
||||
#endif /* HAVE_UNIXWARE7_THREADS */
|
||||
#ifdef _AIX
|
||||
#undef HAVE_BCMP
|
||||
#endif
|
||||
|
||||
/* This is needed for the definitions of bzero... on solaris */
|
||||
#if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
/* This is needed for the definitions of memcpy... on solaris */
|
||||
#if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
|
||||
# define memcpy(d, s, n) bcopy ((s), (d), (n))
|
||||
# define memset(A,C,B) bfill((A),(B),(C))
|
||||
# define memmove(d, s, n) bmove ((d), (s), (n))
|
||||
#elif defined(HAVE_MEMMOVE)
|
||||
# define bmove(d, s, n) memmove((d), (s), (n))
|
||||
#else
|
||||
# define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
|
||||
#endif
|
||||
|
||||
/* Unixware 7 */
|
||||
#if !defined(HAVE_BFILL)
|
||||
# define bfill(A,B,C) memset((A),(C),(B))
|
||||
# define bmove_allign(A,B,C) memcpy((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_BCMP)
|
||||
# define bcopy(s, d, n) memcpy((d), (s), (n))
|
||||
# define bcmp(A,B,C) memcmp((A),(B),(C))
|
||||
# define bzero(A,B) memset((A),0,(B))
|
||||
# define bmove_allign(A,B,C) memcpy((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
|
||||
#define strmov(A,B) stpcpy((A),(B))
|
||||
#endif
|
||||
|
||||
extern char NEAR _dig_vec[]; /* Declared in int2str() */
|
||||
|
||||
#ifdef BAD_STRING_COMPILER
|
||||
#define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
|
||||
#else
|
||||
#define strmov_overlapp(A,B) strmov(A,B)
|
||||
#define strmake_overlapp(A,B,C) strmake(A,B,C)
|
||||
#endif
|
||||
|
||||
#ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
|
||||
#define memcpy_fixed(A,B,C) bmove((A),(B),(C))
|
||||
#else
|
||||
#define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
|
||||
#define bmove512(A,B,C) memcpy(A,B,C)
|
||||
#endif
|
||||
|
||||
/* Prototypes for string functions */
|
||||
|
||||
#if !defined(bfill) && !defined(HAVE_BFILL)
|
||||
extern void bfill(gptr dst, size_t len, pchar fill);
|
||||
#endif
|
||||
|
||||
#if !defined(bzero) && !defined(HAVE_BZERO)
|
||||
extern void bzero(gptr dst, size_t len);
|
||||
#endif
|
||||
|
||||
#if !defined(bcmp) && !defined(HAVE_BCMP)
|
||||
extern int bcmp(const char *s1,const char *s2, size_t len);
|
||||
#ifdef HAVE_purify
|
||||
extern int my_bcmp(const char *s1,const char *s2, size_t len);
|
||||
#define bcmp(A,B,C) my_bcmp((A),(B),(C))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef bmove512
|
||||
extern void bmove512(gptr dst,const gptr src, size_t len);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_BMOVE) && !defined(bmove)
|
||||
extern void bmove(char *dst, const char *src, size_t len);
|
||||
#endif
|
||||
|
||||
extern void bmove_upp(char *dst,const char *src, size_t len);
|
||||
extern void bchange(char *dst, size_t old_len, const char *src,
|
||||
size_t new_len, size_t tot_len);
|
||||
extern void strappend(char *s,size_t len,pchar fill);
|
||||
extern char *strend(const char *s);
|
||||
extern char *strcend(const char *, char);
|
||||
extern char *strfield(char *src,int fields,int chars,int blanks,
|
||||
int tabch);
|
||||
extern char *strfill(my_string s, size_t len, pchar fill);
|
||||
extern uint strinstr(const char *str,const char *search);
|
||||
extern uint r_strinstr(reg1 my_string str,int from, reg4 my_string search);
|
||||
extern char *strkey(char *dst,char *head,char *tail,char *flags);
|
||||
extern char *strmake(char *dst,const char *src, size_t length);
|
||||
#ifndef strmake_overlapp
|
||||
extern char *strmake_overlapp(char *dst,const char *src, size_t length);
|
||||
#endif
|
||||
|
||||
#ifndef strmov
|
||||
extern char *strmov(char *dst,const char *src);
|
||||
#endif
|
||||
extern char *strnmov(char *dst,const char *src,uint n);
|
||||
extern char *strsuff(const char *src,const char *suffix);
|
||||
extern char *strcont(const char *src,const char *set);
|
||||
extern char *strxcat _VARARGS((char *dst,const char *src, ...));
|
||||
extern char *strxmov _VARARGS((char *dst,const char *src, ...));
|
||||
extern char *strxcpy _VARARGS((char *dst,const char *src, ...));
|
||||
extern char *strxncat _VARARGS((char *dst, size_t len, const char *src, ...));
|
||||
extern char *strxnmov _VARARGS((char *dst, size_t len, const char *src, ...));
|
||||
extern char *strxncpy _VARARGS((char *dst, size_t len, const char *src, ...));
|
||||
|
||||
/* Prototypes of normal stringfunctions (with may ours) */
|
||||
|
||||
#ifdef WANT_STRING_PROTOTYPES
|
||||
extern char *strcat(char *, const char *);
|
||||
extern char *strchr(const char *, pchar);
|
||||
extern char *strrchr(const char *, pchar);
|
||||
extern char *strcpy(char *, const char *);
|
||||
extern int strcmp(const char *, const char *);
|
||||
#ifndef __GNUC__
|
||||
extern size_t strlen(const char *);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#ifndef HAVE_STRPBRK
|
||||
extern char *strpbrk(const char *, const char *);
|
||||
#endif
|
||||
#ifndef HAVE_STRSTR
|
||||
extern char *strstr(const char *, const char *);
|
||||
#endif
|
||||
#endif
|
||||
extern int is_prefix(const char *, const char *);
|
||||
|
||||
/* Conversion rutins */
|
||||
|
||||
#ifdef USE_MY_ITOA
|
||||
extern char *my_itoa(int val,char *dst,int radix);
|
||||
extern char *my_ltoa(long val,char *dst,int radix);
|
||||
#endif
|
||||
|
||||
extern char *llstr(longlong value,char *buff);
|
||||
#ifndef HAVE_STRTOUL
|
||||
extern long strtol(const char *str, char **ptr, int base);
|
||||
extern ulong strtoul(const char *str, char **ptr, int base);
|
||||
#endif
|
||||
|
||||
extern char *int2str(long val,char *dst,int radix);
|
||||
extern char *int10_to_str(long val,char *dst,int radix);
|
||||
extern char *str2int(const char *src,int radix,long lower,long upper,
|
||||
long *val);
|
||||
#if SIZEOF_LONG == SIZEOF_LONG_LONG
|
||||
#define longlong2str(A,B,C) int2str((A),(B),(C))
|
||||
#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
|
||||
#define strtoll(A,B,C) strtol((A),(B),(C))
|
||||
#define strtoull(A,B,C) strtoul((A),(B),(C))
|
||||
#ifndef HAVE_STRTOULL
|
||||
#define HAVE_STRTOULL
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_LONG_LONG
|
||||
extern char *longlong2str(longlong val,char *dst,int radix);
|
||||
extern char *longlong10_to_str(longlong val,char *dst,int radix);
|
||||
#if (!defined(HAVE_STRTOULL) || defined(HAVE_mit_thread)) || defined(NO_STRTOLL_PROTO)
|
||||
extern longlong strtoll(const char *str, char **ptr, int base);
|
||||
extern ulonglong strtoull(const char *str, char **ptr, int base);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
MY_GCVT_ARG_FLOAT,
|
||||
MY_GCVT_ARG_DOUBLE
|
||||
} my_gcvt_arg_type;
|
||||
|
||||
size_t ma_fcvt(double x, int precision, char *to, my_bool *error);
|
||||
size_t ma_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
|
||||
my_bool *error);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
58
module/Vendor/MDBC/include/ma_common.h
vendored
Normal file
58
module/Vendor/MDBC/include/ma_common.h
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
/* Copyright (C) 2013 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
|
||||
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 */
|
||||
|
||||
/* defines for the libmariadb library */
|
||||
|
||||
#ifndef _ma_common_h
|
||||
#define _ma_common_h
|
||||
|
||||
#include <mysql.h>
|
||||
#include <hash.h>
|
||||
|
||||
|
||||
typedef struct st_mariadb_db_driver
|
||||
{
|
||||
struct st_mariadb_client_plugin_DB *plugin;
|
||||
char *name;
|
||||
void *buffer;
|
||||
} MARIADB_DB_DRIVER;
|
||||
|
||||
struct mysql_async_context;
|
||||
|
||||
struct st_mysql_options_extension {
|
||||
char *plugin_dir;
|
||||
char *default_auth;
|
||||
char *ssl_crl;
|
||||
char *ssl_crlpath;
|
||||
char *server_public_key_path;
|
||||
struct mysql_async_context *async_context;
|
||||
HASH connect_attrs;
|
||||
size_t connect_attrs_len;
|
||||
void (*report_progress)(const MYSQL *mysql,
|
||||
unsigned int stage,
|
||||
unsigned int max_stage,
|
||||
double progress,
|
||||
const char *proc_info,
|
||||
unsigned int proc_info_length);
|
||||
MARIADB_DB_DRIVER *db_driver;
|
||||
char *ssl_fp; /* finger print of server certificate */
|
||||
char *ssl_fp_list; /* white list of finger prints */
|
||||
int (*verify_local_infile)(void *data, const char *filename);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
256
module/Vendor/MDBC/include/ma_dyncol.h
vendored
Normal file
256
module/Vendor/MDBC/include/ma_dyncol.h
vendored
Normal file
@ -0,0 +1,256 @@
|
||||
/* 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 <COPYRIGHT HOLDER> ``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 <COPYRIGHT HOLDER> 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 <decimal.h>
|
||||
#include <my_decimal_limits.h>
|
||||
#endif
|
||||
#include <mysql.h>
|
||||
|
||||
#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;
|
||||
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,
|
||||
CHARSET_INFO *cs, my_bool 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) (V)->type= DYN_COL_NULL
|
||||
|
||||
/*
|
||||
Prepare value for using as decimal
|
||||
*/
|
||||
void mariadb_dyncol_prepare_decimal(DYNAMIC_COLUMN_VALUE *value);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
45
module/Vendor/MDBC/include/ma_secure.h
vendored
Normal file
45
module/Vendor/MDBC/include/ma_secure.h
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/************************************************************************************
|
||||
Copyright (C) 2012 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 <http://www.gnu.org/licenses>
|
||||
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
|
||||
*************************************************************************************/
|
||||
#ifndef _ma_secure_h_
|
||||
#define _ma_secure_h_
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
#include <mysql.h>
|
||||
#include <openssl/ssl.h> /* SSL and SSL_CTX */
|
||||
#include <openssl/err.h> /* error reporting */
|
||||
#include <openssl/conf.h>
|
||||
|
||||
struct MYSQL;
|
||||
|
||||
size_t my_ssl_read(Vio *vio, uchar* buf, size_t size);
|
||||
int my_ssl_close(Vio *vio);
|
||||
size_t my_ssl_write(Vio *vio, const uchar* buf, size_t size);
|
||||
SSL *my_ssl_init(MYSQL *mysql);
|
||||
int my_ssl_connect(SSL *ssl);
|
||||
int my_ssl_verify_server_cert(SSL *ssl);
|
||||
int ma_ssl_verify_fingerprint(SSL *ssl);
|
||||
|
||||
int my_ssl_start(MYSQL *mysql);
|
||||
void my_ssl_end(void);
|
||||
|
||||
#endif /* HAVE_OPENSSL */
|
||||
#endif /* _ma_secure_h_ */
|
60
module/Vendor/MDBC/include/my_alarm.h
vendored
Normal file
60
module/Vendor/MDBC/include/my_alarm.h
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
/* 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 */
|
||||
|
||||
/*
|
||||
File to include when we want to use alarm or a loop_counter to display
|
||||
some information when a program is running
|
||||
*/
|
||||
#ifndef _my_alarm_h
|
||||
#define _my_alarm_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int volatile my_have_got_alarm;
|
||||
extern ulong my_time_to_wait_for_lock;
|
||||
|
||||
#if defined(HAVE_ALARM) && !defined(NO_ALARM_LOOP)
|
||||
#include <signal.h>
|
||||
#define ALARM_VARIABLES uint alarm_old=0; \
|
||||
sig_return alarm_signal=0
|
||||
#define ALARM_INIT my_have_got_alarm=0 ; \
|
||||
alarm_old=(uint) alarm(MY_HOW_OFTEN_TO_ALARM); \
|
||||
alarm_signal=signal(SIGALRM,my_set_alarm_variable);
|
||||
#define ALARM_END VOID(signal(SIGALRM,alarm_signal)); \
|
||||
VOID(alarm(alarm_old));
|
||||
#define ALARM_TEST my_have_got_alarm
|
||||
#ifdef DONT_REMEMBER_SIGNAL
|
||||
#define ALARM_REINIT VOID(alarm(MY_HOW_OFTEN_TO_ALARM)); \
|
||||
VOID(signal(SIGALRM,my_set_alarm_variable));\
|
||||
my_have_got_alarm=0;
|
||||
#else
|
||||
#define ALARM_REINIT VOID(alarm((uint) MY_HOW_OFTEN_TO_ALARM)); \
|
||||
my_have_got_alarm=0;
|
||||
#endif /* DONT_REMEMBER_SIGNAL */
|
||||
#else
|
||||
#define ALARM_VARIABLES long alarm_pos=0,alarm_end_pos=MY_HOW_OFTEN_TO_WRITE-1
|
||||
#define ALARM_INIT
|
||||
#define ALARM_END
|
||||
#define ALARM_TEST (alarm_pos++ >= alarm_end_pos)
|
||||
#define ALARM_REINIT alarm_end_pos+=MY_HOW_OFTEN_TO_WRITE
|
||||
#endif /* HAVE_ALARM */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
287
module/Vendor/MDBC/include/my_base.h
vendored
Normal file
287
module/Vendor/MDBC/include/my_base.h
vendored
Normal file
@ -0,0 +1,287 @@
|
||||
/* 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 */
|
||||
|
||||
/* This file includes constants used with all databases */
|
||||
/* Author: Michael Widenius */
|
||||
|
||||
#ifndef _my_base_h
|
||||
#define _my_base_h
|
||||
|
||||
#ifndef stdin /* Included first in handler */
|
||||
#define USES_TYPES /* my_dir with sys/types is included */
|
||||
#define CHSIZE_USED
|
||||
#include <global.h>
|
||||
#include <my_dir.h> /* This includes types */
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <errno.h>
|
||||
#ifdef MSDOS
|
||||
#include <share.h> /* Neaded for sopen() */
|
||||
#endif
|
||||
#if !defined(USE_MY_FUNC) && !defined(THREAD)
|
||||
#include <my_nosys.h> /* For faster code, after test */
|
||||
#endif /* USE_MY_FUNC */
|
||||
#endif /* stdin */
|
||||
#include <my_list.h>
|
||||
|
||||
/* The following is bits in the flag parameter to ha_open() */
|
||||
|
||||
#define HA_OPEN_ABORT_IF_LOCKED 0 /* default */
|
||||
#define HA_OPEN_WAIT_IF_LOCKED 1
|
||||
#define HA_OPEN_IGNORE_IF_LOCKED 2
|
||||
#define HA_OPEN_TMP_TABLE 4 /* Table is a temp table */
|
||||
#define HA_OPEN_DELAY_KEY_WRITE 8 /* Don't update index */
|
||||
#define HA_OPEN_ABORT_IF_CRASHED 16
|
||||
#define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */
|
||||
|
||||
/* The following is parameter to ha_rkey() how to use key */
|
||||
|
||||
enum ha_rkey_function {
|
||||
HA_READ_KEY_EXACT, /* Find first record else error */
|
||||
HA_READ_KEY_OR_NEXT, /* Record or next record */
|
||||
HA_READ_KEY_OR_PREV, /* Record or previous */
|
||||
HA_READ_AFTER_KEY, /* Find next rec. after key-record */
|
||||
HA_READ_BEFORE_KEY, /* Find next rec. before key-record */
|
||||
HA_READ_PREFIX, /* Key which as same prefix */
|
||||
HA_READ_PREFIX_LAST /* Last key with the same prefix */
|
||||
};
|
||||
|
||||
/* The following is parameter to ha_extra() */
|
||||
|
||||
enum ha_extra_function {
|
||||
HA_EXTRA_NORMAL=0, /* Optimize for space (def) */
|
||||
HA_EXTRA_QUICK=1, /* Optimize for speed */
|
||||
HA_EXTRA_RESET=2, /* Reset database to after open */
|
||||
HA_EXTRA_CACHE=3, /* Cash record in HA_rrnd() */
|
||||
HA_EXTRA_NO_CACHE=4, /* End cacheing of records (def) */
|
||||
HA_EXTRA_NO_READCHECK=5, /* No readcheck on update */
|
||||
HA_EXTRA_READCHECK=6, /* Use readcheck (def) */
|
||||
HA_EXTRA_KEYREAD=7, /* Read only key to database */
|
||||
HA_EXTRA_NO_KEYREAD=8, /* Normal read of records (def) */
|
||||
HA_EXTRA_NO_USER_CHANGE=9, /* No user is allowed to write */
|
||||
HA_EXTRA_KEY_CACHE=10,
|
||||
HA_EXTRA_NO_KEY_CACHE=11,
|
||||
HA_EXTRA_WAIT_LOCK=12, /* Wait until file is avalably (def) */
|
||||
HA_EXTRA_NO_WAIT_LOCK=13, /* If file is locked, return quickly */
|
||||
HA_EXTRA_WRITE_CACHE=14, /* Use write cache in ha_write() */
|
||||
HA_EXTRA_FLUSH_CACHE=15, /* flush write_record_cache */
|
||||
HA_EXTRA_NO_KEYS=16, /* Remove all update of keys */
|
||||
HA_EXTRA_KEYREAD_CHANGE_POS=17, /* Keyread, but change pos */
|
||||
/* xxxxchk -r must be used */
|
||||
HA_EXTRA_REMEMBER_POS=18, /* Remember pos for next/prev */
|
||||
HA_EXTRA_RESTORE_POS=19,
|
||||
HA_EXTRA_REINIT_CACHE=20, /* init cache from current record */
|
||||
HA_EXTRA_FORCE_REOPEN=21, /* Datafile have changed on disk */
|
||||
HA_EXTRA_FLUSH, /* Flush tables to disk */
|
||||
HA_EXTRA_NO_ROWS, /* Don't write rows */
|
||||
HA_EXTRA_RESET_STATE, /* Reset positions */
|
||||
HA_EXTRA_IGNORE_DUP_KEY, /* Dup keys don't rollback everything*/
|
||||
HA_EXTRA_NO_IGNORE_DUP_KEY,
|
||||
HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE /* Cursor will not be used for update */
|
||||
};
|
||||
|
||||
/* The following is parameter to ha_panic() */
|
||||
|
||||
enum ha_panic_function {
|
||||
HA_PANIC_CLOSE, /* Close all databases */
|
||||
HA_PANIC_WRITE, /* Unlock and write status */
|
||||
HA_PANIC_READ /* Lock and read keyinfo */
|
||||
};
|
||||
|
||||
/* The following is parameter to ha_create(); keytypes */
|
||||
|
||||
enum ha_base_keytype {
|
||||
HA_KEYTYPE_END=0,
|
||||
HA_KEYTYPE_TEXT=1, /* Key is sorted as letters */
|
||||
HA_KEYTYPE_BINARY=2, /* Key is sorted as unsigned chars */
|
||||
HA_KEYTYPE_SHORT_INT=3,
|
||||
HA_KEYTYPE_LONG_INT=4,
|
||||
HA_KEYTYPE_FLOAT=5,
|
||||
HA_KEYTYPE_DOUBLE=6,
|
||||
HA_KEYTYPE_NUM=7, /* Not packed num with pre-space */
|
||||
HA_KEYTYPE_USHORT_INT=8,
|
||||
HA_KEYTYPE_ULONG_INT=9,
|
||||
HA_KEYTYPE_LONGLONG=10,
|
||||
HA_KEYTYPE_ULONGLONG=11,
|
||||
HA_KEYTYPE_INT24=12,
|
||||
HA_KEYTYPE_UINT24=13,
|
||||
HA_KEYTYPE_INT8=14,
|
||||
HA_KEYTYPE_VARTEXT=15, /* Key is sorted as letters */
|
||||
HA_KEYTYPE_VARBINARY=16 /* Key is sorted as unsigned chars */
|
||||
};
|
||||
|
||||
#define HA_MAX_KEYTYPE 31 /* Must be log2-1 */
|
||||
|
||||
/* These flags kan be OR:ed to key-flag */
|
||||
|
||||
#define HA_NOSAME 1 /* Set if not dupplicated records */
|
||||
#define HA_PACK_KEY 2 /* Pack string key to previous key */
|
||||
#define HA_AUTO_KEY 16
|
||||
#define HA_BINARY_PACK_KEY 32 /* Packing of all keys to prev key */
|
||||
#define HA_FULLTEXT 128 /* SerG: for full-text search */
|
||||
#define HA_UNIQUE_CHECK 256 /* Check the key for uniqueness */
|
||||
|
||||
/* Automatic bits in key-flag */
|
||||
|
||||
#define HA_SPACE_PACK_USED 4 /* Test for if SPACE_PACK used */
|
||||
#define HA_VAR_LENGTH_KEY 8
|
||||
#define HA_NULL_PART_KEY 64
|
||||
#ifndef ISAM_LIBRARY
|
||||
#define HA_SORT_ALLOWS_SAME 512 /* Intern bit when sorting records */
|
||||
#else
|
||||
/* poor old NISAM has 8-bit flags :-( */
|
||||
#define HA_SORT_ALLOWS_SAME 128 /* Intern bit when sorting records */
|
||||
#endif
|
||||
|
||||
/* These flags can be order to key-seg-flag */
|
||||
|
||||
#define HA_SPACE_PACK 1 /* Pack space in key-seg */
|
||||
#define HA_PART_KEY 4 /* Used by MySQL for part-key-cols */
|
||||
#define HA_VAR_LENGTH 8
|
||||
#define HA_NULL_PART 16
|
||||
#define HA_BLOB_PART 32
|
||||
#define HA_SWAP_KEY 64
|
||||
#define HA_REVERSE_SORT 128 /* Sort key in reverse order */
|
||||
|
||||
/* optionbits for database */
|
||||
#define HA_OPTION_PACK_RECORD 1
|
||||
#define HA_OPTION_PACK_KEYS 2
|
||||
#define HA_OPTION_COMPRESS_RECORD 4
|
||||
#define HA_OPTION_LONG_BLOB_PTR 8 /* new ISAM format */
|
||||
#define HA_OPTION_TMP_TABLE 16
|
||||
#define HA_OPTION_CHECKSUM 32
|
||||
#define HA_OPTION_DELAY_KEY_WRITE 64
|
||||
#define HA_OPTION_NO_PACK_KEYS 128 /* Reserved for MySQL */
|
||||
#define HA_OPTION_TEMP_COMPRESS_RECORD ((uint) 16384) /* set by isamchk */
|
||||
#define HA_OPTION_READ_ONLY_DATA ((uint) 32768) /* Set by isamchk */
|
||||
|
||||
/* Bits in flag to create() */
|
||||
|
||||
#define HA_DONT_TOUCH_DATA 1 /* Don't empty datafile (isamchk) */
|
||||
#define HA_PACK_RECORD 2 /* Request packed record format */
|
||||
#define HA_CREATE_TMP_TABLE 4
|
||||
#define HA_CREATE_CHECKSUM 8
|
||||
#define HA_CREATE_DELAY_KEY_WRITE 64
|
||||
|
||||
/* Bits in flag to _status */
|
||||
|
||||
#define HA_STATUS_POS 1 /* Return position */
|
||||
#define HA_STATUS_NO_LOCK 2 /* Don't use external lock */
|
||||
#define HA_STATUS_TIME 4 /* Return update time */
|
||||
#define HA_STATUS_CONST 8 /* Return constants values */
|
||||
#define HA_STATUS_VARIABLE 16
|
||||
#define HA_STATUS_ERRKEY 32
|
||||
#define HA_STATUS_AUTO 64
|
||||
|
||||
/* Errorcodes given by functions */
|
||||
|
||||
#define HA_ERR_KEY_NOT_FOUND 120 /* Didn't find key on read or update */
|
||||
#define HA_ERR_FOUND_DUPP_KEY 121 /* Dupplicate key on write */
|
||||
#define HA_ERR_RECORD_CHANGED 123 /* Uppdate with is recoverable */
|
||||
#define HA_ERR_WRONG_INDEX 124 /* Wrong index given to function */
|
||||
#define HA_ERR_CRASHED 126 /* Indexfile is crashed */
|
||||
#define HA_ERR_WRONG_IN_RECORD 127 /* Record-file is crashed */
|
||||
#define HA_ERR_OUT_OF_MEM 128 /* Record-file is crashed */
|
||||
#define HA_ERR_WRONG_COMMAND 131 /* Command not supported */
|
||||
#define HA_ERR_OLD_FILE 132 /* old databasfile */
|
||||
#define HA_ERR_NO_ACTIVE_RECORD 133 /* No record read in update() */
|
||||
#define HA_ERR_RECORD_DELETED 134 /* Intern error-code */
|
||||
#define HA_ERR_RECORD_FILE_FULL 135 /* No more room in file */
|
||||
#define HA_ERR_INDEX_FILE_FULL 136 /* No more room in file */
|
||||
#define HA_ERR_END_OF_FILE 137 /* end in next/prev/first/last */
|
||||
#define HA_ERR_UNSUPPORTED 138 /* unsupported extension used */
|
||||
#define HA_ERR_TO_BIG_ROW 139 /* Too big row */
|
||||
#define HA_WRONG_CREATE_OPTION 140 /* Wrong create option */
|
||||
#define HA_ERR_FOUND_DUPP_UNIQUE 141 /* Dupplicate unique on write */
|
||||
#define HA_ERR_UNKNOWN_CHARSET 142 /* Can't open charset */
|
||||
#define HA_ERR_WRONG_TABLE_DEF 143
|
||||
#define HA_ERR_CRASHED_ON_REPAIR 144 /* Last (automatic?) repair failed */
|
||||
#define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */
|
||||
#define HA_ERR_LOCK_WAIT_TIMEOUT 146
|
||||
#define HA_ERR_LOCK_TABLE_FULL 147
|
||||
#define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */
|
||||
#define HA_ERR_LOCK_DEADLOCK 149
|
||||
#define HA_ERR_CANNOT_ADD_FOREIGN 150 /* Cannot add a foreign key constr. */
|
||||
#define HA_ERR_NO_REFERENCED_ROW 151 /* Cannot add a child row */
|
||||
#define HA_ERR_ROW_IS_REFERENCED 152 /* Cannot delete a parent row */
|
||||
|
||||
/* Other constants */
|
||||
|
||||
#define HA_NAMELEN 64 /* Max length of saved filename */
|
||||
|
||||
/* Intern constants in databases */
|
||||
|
||||
/* bits in _search */
|
||||
#define SEARCH_FIND 1
|
||||
#define SEARCH_NO_FIND 2
|
||||
#define SEARCH_SAME 4
|
||||
#define SEARCH_BIGGER 8
|
||||
#define SEARCH_SMALLER 16
|
||||
#define SEARCH_SAVE_BUFF 32
|
||||
#define SEARCH_UPDATE 64
|
||||
#define SEARCH_PREFIX 128
|
||||
#define SEARCH_LAST 256
|
||||
|
||||
/* bits in opt_flag */
|
||||
#define QUICK_USED 1
|
||||
#define READ_CACHE_USED 2
|
||||
#define READ_CHECK_USED 4
|
||||
#define KEY_READ_USED 8
|
||||
#define WRITE_CACHE_USED 16
|
||||
#define OPT_NO_ROWS 32
|
||||
|
||||
/* bits in update */
|
||||
#define HA_STATE_CHANGED 1 /* Database has changed */
|
||||
#define HA_STATE_AKTIV 2 /* Has a current record */
|
||||
#define HA_STATE_WRITTEN 4 /* Record is written */
|
||||
#define HA_STATE_DELETED 8
|
||||
#define HA_STATE_NEXT_FOUND 16 /* Next found record (record before) */
|
||||
#define HA_STATE_PREV_FOUND 32 /* Prev found record (record after) */
|
||||
#define HA_STATE_NO_KEY 64 /* Last read didn't find record */
|
||||
#define HA_STATE_KEY_CHANGED 128
|
||||
#define HA_STATE_WRITE_AT_END 256 /* set in _ps_find_writepos */
|
||||
#define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */
|
||||
#define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */
|
||||
#define HA_STATE_EXTEND_BLOCK 2048
|
||||
|
||||
enum en_fieldtype {
|
||||
FIELD_LAST=-1,FIELD_NORMAL,FIELD_SKIPP_ENDSPACE,FIELD_SKIPP_PRESPACE,
|
||||
FIELD_SKIPP_ZERO,FIELD_BLOB,FIELD_CONSTANT,FIELD_INTERVALL,FIELD_ZERO,
|
||||
FIELD_VARCHAR,FIELD_CHECK
|
||||
};
|
||||
|
||||
enum data_file_type {
|
||||
STATIC_RECORD,DYNAMIC_RECORD,COMPRESSED_RECORD
|
||||
};
|
||||
|
||||
/* For number of records */
|
||||
#ifdef BIG_TABLES
|
||||
typedef my_off_t ha_rows;
|
||||
#else
|
||||
typedef ulong ha_rows;
|
||||
#endif
|
||||
|
||||
#define HA_POS_ERROR (~ (ha_rows) 0)
|
||||
#define HA_OFFSET_ERROR (~ (my_off_t) 0)
|
||||
|
||||
#if SYSTEM_SIZEOF_OFF_T == 4
|
||||
#define MAX_FILE_SIZE INT_MAX32
|
||||
#else
|
||||
#define MAX_FILE_SIZE LONGLONG_MAX
|
||||
#endif
|
||||
|
||||
#endif /* _my_base_h */
|
280
module/Vendor/MDBC/include/my_config.h
vendored
Normal file
280
module/Vendor/MDBC/include/my_config.h
vendored
Normal file
@ -0,0 +1,280 @@
|
||||
|
||||
/*
|
||||
* Include file constants (processed in LibmysqlIncludeFiles.txt 1
|
||||
*/
|
||||
/* #undef HAVE_ALLOCA_H */
|
||||
/* #undef HAVE_BIGENDIAN */
|
||||
/* #undef HAVE_ARPA_INET_H */
|
||||
/* #undef HAVE_CRYPT_H */
|
||||
#define HAVE_DIRENT_H 1
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
/* #undef HAVE_EXECINFO_H */
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_FENV_H 1
|
||||
#define HAVE_FLOAT_H 1
|
||||
/* #undef HAVE_FPU_CONTROL_H */
|
||||
/* #undef HAVE_GRP_H */
|
||||
#define HAVE_IEEEFP_H 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_MALLOC_H 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
/* #undef HAVE_NETINET_IN_H */
|
||||
/* #undef HAVE_PATHS_H */
|
||||
/* #undef HAVE_PWD_H */
|
||||
#define HAVE_SCHED_H 1
|
||||
/* #undef HAVE_SELECT_H */
|
||||
#define HAVE_STDDEF_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
/* #undef HAVE_SYNCH_H */
|
||||
/* #undef HAVE_SYS_FPU_H */
|
||||
/* #undef HAVE_SYS_IOCTL_H */
|
||||
/* #undef HAVE_SYS_IPC_H */
|
||||
/* #undef HAVE_SYS_MMAN_H */
|
||||
/* #undef HAVE_SYS_PRCTL_H */
|
||||
/* #undef HAVE_SYS_SELECT_H */
|
||||
/* #undef HAVE_SYS_SHM_H */
|
||||
/* #undef HAVE_SYS_SOCKET_H */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
/* #undef HAVE_SYS_STREAM_H */
|
||||
#define HAVE_SYS_TIMEB_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
/* #undef HAVE_SYS_UN_H */
|
||||
/* #undef HAVE_SYSENT_H */
|
||||
/* #undef HAVE_TERMIO_H */
|
||||
/* #undef HAVE_TERMIOS_H */
|
||||
/* #undef HAVE_UCONTEXT_H */
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_UTIME_H 1
|
||||
|
||||
/*
|
||||
* function definitions - processed in LibmysqlFunctions.txt
|
||||
*/
|
||||
#define HAVE_ACCESS 1
|
||||
/* #undef HAVE_AIOWAIT */
|
||||
#define HAVE_ALARM 1
|
||||
/* #undef HAVE_ALLOCA */
|
||||
/* #undef HAVE_BCMP */
|
||||
/* #undef HAVE_BFILL */
|
||||
/* #undef HAVE_BMOVE */
|
||||
/* #undef HAVE_BZERO */
|
||||
#define HAVE_CLOCK_GETTIME 1
|
||||
/* #undef HAVE_COMPRESS */
|
||||
/* #undef HAVE_CRYPT */
|
||||
/* #undef HAVE_DLERROR */
|
||||
/* #undef HAVE_DLOPEN */
|
||||
/* #undef HAVE_FCHMOD */
|
||||
/* #undef HAVE_FCNTL */
|
||||
/* #undef HAVE_FCONVERT */
|
||||
/* #undef HAVE_FDATASYNC */
|
||||
#define HAVE_FESETROUND 1
|
||||
#define HAVE_FINITE 1
|
||||
#define HAVE_FSEEKO 1
|
||||
/* #undef HAVE_FSYNC */
|
||||
/* #undef HAVE_GETADDRINFO */
|
||||
#define HAVE_GETCWD 1
|
||||
/* #undef HAVE_GETHOSTBYADDR_R */
|
||||
/* #undef HAVE_GETHOSTBYNAME_R */
|
||||
/* #undef HAVE_GETHRTIME */
|
||||
/* #undef HAVE_GETNAMEINFO */
|
||||
#define HAVE_GETPAGESIZE 1
|
||||
/* #undef HAVE_GETPASS */
|
||||
/* #undef HAVE_GETPASSPHRASE */
|
||||
/* #undef HAVE_GETPWNAM */
|
||||
/* #undef HAVE_GETPWUID */
|
||||
/* #undef HAVE_GETRLIMIT */
|
||||
/* #undef HAVE_GETRUSAGE */
|
||||
/* #undef HAVE_GETWD */
|
||||
/* #undef HAVE_GMTIME_R */
|
||||
/* #undef HAVE_INITGROUPS */
|
||||
#define HAVE_LDIV 1
|
||||
/* #undef HAVE_LOCALTIME_R */
|
||||
#define HAVE_LOG2 1
|
||||
#define HAVE_LONGJMP 1
|
||||
/* #undef HAVE_LSTAT */
|
||||
/* #undef HAVE_MADVISE */
|
||||
/* #undef HAVE_MALLINFO */
|
||||
/* #undef HAVE_MEMALIGN */
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MKSTEMP 1
|
||||
/* #undef HAVE_MLOCK */
|
||||
/* #undef HAVE_MLOCKALL */
|
||||
/* #undef HAVE_MMAP */
|
||||
/* #undef HAVE_MMAP64 */
|
||||
#define HAVE_PERROR 1
|
||||
/* #undef HAVE_POLL */
|
||||
/* #undef HAVE_PREAD */
|
||||
/* #undef HAVE_PTHREAD_ATTR_CREATE */
|
||||
#define HAVE_PTHREAD_ATTR_GETSTACKSIZE 1
|
||||
/* #undef HAVE_PTHREAD_ATTR_SETPRIO */
|
||||
#define HAVE_PTHREAD_ATTR_SETSCHEDPARAM 1
|
||||
#define HAVE_PTHREAD_ATTR_SETSCOPE 1
|
||||
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
|
||||
/* #undef HAVE_PTHREAD_CONDATTR_CREATE */
|
||||
/* #undef HAVE_PTHREAD_INIT */
|
||||
#define HAVE_PTHREAD_KEY_DELETE 1
|
||||
#define HAVE_PTHREAD_KILL 1
|
||||
#define HAVE_PTHREAD_RWLOCK_RDLOCK 1
|
||||
/* #undef HAVE_PTHREAD_SETPRIO_NP */
|
||||
#define HAVE_PTHREAD_SETSCHEDPARAM 1
|
||||
/* #undef HAVE_PTHREAD_SIGMASK */
|
||||
/* #undef HAVE_PTHREAD_THREADMASK */
|
||||
/* #undef HAVE_PTHREAD_YIELD_NP */
|
||||
/* #undef HAVE_READDIR_R */
|
||||
/* #undef HAVE_READLINK */
|
||||
/* #undef HAVE_REALPATH */
|
||||
#define HAVE_RENAME 1
|
||||
#define HAVE_SCHED_YIELD 1
|
||||
/* #undef HAVE_SELECT */
|
||||
/* #undef HAVE_SETFD */
|
||||
/* #undef HAVE_SETFILEPOINTER */
|
||||
#define HAVE_SIGNAL 1
|
||||
/* #undef HAVE_SIGACTION */
|
||||
/* #undef HAVE_SIGTHREADMASK */
|
||||
/* #undef HAVE_SIGWAIT */
|
||||
#define HAVE_SLEEP 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
/* #undef HAVE_SQLITE */
|
||||
/* #undef HAVE_STPCPY */
|
||||
#define HAVE_STRERROR 1
|
||||
/* #undef HAVE_STRLCPY */
|
||||
#define HAVE_STRNLEN 1
|
||||
#define HAVE_STRPBRK 1
|
||||
/* #undef HAVE_STRSEP */
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOK_R 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOULL 1
|
||||
#define HAVE_TELL 1
|
||||
/* #undef HAVE_THR_SETCONCURRENCY */
|
||||
/* #undef HAVE_THR_YIELD */
|
||||
#define HAVE_VASPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/*
|
||||
* types and sizes
|
||||
*/
|
||||
/* Types we may use */
|
||||
#define SIZEOF_CHAR 1
|
||||
#if SIZEOF_CHAR
|
||||
# define HAVE_CHAR 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_CHARP 8
|
||||
#if SIZEOF_CHARP
|
||||
# define HAVE_CHARP 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_SHORT 2
|
||||
#if SIZEOF_SHORT
|
||||
# define HAVE_SHORT 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_INT 4
|
||||
#if SIZEOF_INT
|
||||
# define HAVE_INT 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_LONG 4
|
||||
#if SIZEOF_LONG
|
||||
# define HAVE_LONG 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#if SIZEOF_LONG_LONG
|
||||
# define HAVE_LONG_LONG 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_OFF_T 4
|
||||
#if SIZEOF_OFF_T
|
||||
# define HAVE_OFF_T 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_SIGSET_T */
|
||||
#if SIZEOF_SIGSET_T
|
||||
# define HAVE_SIGSET_T 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_SIZE_T 8
|
||||
#if SIZEOF_SIZE_T
|
||||
# define HAVE_SIZE_T 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_UCHAR */
|
||||
#if SIZEOF_UCHAR
|
||||
# define HAVE_UCHAR 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_UINT */
|
||||
#if SIZEOF_UINT
|
||||
# define HAVE_UINT 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_ULONG */
|
||||
#if SIZEOF_ULONG
|
||||
# define HAVE_ULONG 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT8 */
|
||||
#if SIZEOF_INT8
|
||||
# define HAVE_INT8 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT8 */
|
||||
#if SIZEOF_UINT8
|
||||
# define HAVE_UINT8 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT16 */
|
||||
#if SIZEOF_INT16
|
||||
# define HAVE_INT16 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT16 */
|
||||
#if SIZEOF_UINT16
|
||||
# define HAVE_UINT16 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT32 */
|
||||
#if SIZEOF_INT32
|
||||
# define HAVE_INT32 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT32 */
|
||||
#if SIZEOF_UINT32
|
||||
# define HAVE_UINT32 1
|
||||
#endif
|
||||
/* #undef SIZEOF_U_INT32_T */
|
||||
#if SIZEOF_U_INT32_T
|
||||
# define HAVE_U_INT32_T 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT64 */
|
||||
#if SIZEOF_INT64
|
||||
# define HAVE_INT64 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT64 */
|
||||
#if SIZEOF_UINT64
|
||||
# define HAVE_UINT64 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_SOCKLEN_T */
|
||||
#if SIZEOF_SOCKLEN_T
|
||||
# define HAVE_SOCKLEN_T 1
|
||||
#endif
|
||||
|
||||
#define SOCKET_SIZE_TYPE int
|
||||
|
||||
#define RETSIGTYPE void
|
||||
#define RETQSORTTYPE void
|
||||
|
||||
/*
|
||||
* various other defines
|
||||
*/
|
||||
#define HAVE_THREADS 1
|
||||
/* #undef SHAREDIR */
|
||||
#define DEFAULT_CHARSET_HOME "C:/Program Files (x86)/SqMod"
|
||||
#define PLUGINDIR "/lib/plugin"
|
||||
|
280
module/Vendor/MDBC/include/my_config.h.in
vendored
Normal file
280
module/Vendor/MDBC/include/my_config.h.in
vendored
Normal file
@ -0,0 +1,280 @@
|
||||
|
||||
/*
|
||||
* Include file constants (processed in LibmysqlIncludeFiles.txt 1
|
||||
*/
|
||||
#cmakedefine HAVE_ALLOCA_H 1
|
||||
#cmakedefine HAVE_BIGENDIAN 1
|
||||
#cmakedefine HAVE_ARPA_INET_H 1
|
||||
#cmakedefine HAVE_CRYPT_H 1
|
||||
#cmakedefine HAVE_DIRENT_H 1
|
||||
#cmakedefine HAVE_DLFCN_H 1
|
||||
#cmakedefine HAVE_EXECINFO_H 1
|
||||
#cmakedefine HAVE_FCNTL_H 1
|
||||
#cmakedefine HAVE_FENV_H 1
|
||||
#cmakedefine HAVE_FLOAT_H 1
|
||||
#cmakedefine HAVE_FPU_CONTROL_H 1
|
||||
#cmakedefine HAVE_GRP_H 1
|
||||
#cmakedefine HAVE_IEEEFP_H 1
|
||||
#cmakedefine HAVE_LIMITS_H 1
|
||||
#cmakedefine HAVE_MALLOC_H 1
|
||||
#cmakedefine HAVE_MEMORY_H 1
|
||||
#cmakedefine HAVE_NETINET_IN_H 1
|
||||
#cmakedefine HAVE_PATHS_H 1
|
||||
#cmakedefine HAVE_PWD_H 1
|
||||
#cmakedefine HAVE_SCHED_H 1
|
||||
#cmakedefine HAVE_SELECT_H 1
|
||||
#cmakedefine HAVE_STDDEF_H 1
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
#cmakedefine HAVE_STDLIB_H 1
|
||||
#cmakedefine HAVE_STRING_H 1
|
||||
#cmakedefine HAVE_STRINGS_H 1
|
||||
#cmakedefine HAVE_SYNCH_H 1
|
||||
#cmakedefine HAVE_SYS_FPU_H 1
|
||||
#cmakedefine HAVE_SYS_IOCTL_H 1
|
||||
#cmakedefine HAVE_SYS_IPC_H 1
|
||||
#cmakedefine HAVE_SYS_MMAN_H 1
|
||||
#cmakedefine HAVE_SYS_PRCTL_H 1
|
||||
#cmakedefine HAVE_SYS_SELECT_H 1
|
||||
#cmakedefine HAVE_SYS_SHM_H 1
|
||||
#cmakedefine HAVE_SYS_SOCKET_H 1
|
||||
#cmakedefine HAVE_SYS_STAT_H 1
|
||||
#cmakedefine HAVE_SYS_STREAM_H 1
|
||||
#cmakedefine HAVE_SYS_TIMEB_H 1
|
||||
#cmakedefine HAVE_SYS_TYPES_H 1
|
||||
#cmakedefine HAVE_SYS_UN_H 1
|
||||
#cmakedefine HAVE_SYSENT_H 1
|
||||
#cmakedefine HAVE_TERMIO_H 1
|
||||
#cmakedefine HAVE_TERMIOS_H 1
|
||||
#cmakedefine HAVE_UCONTEXT_H 1
|
||||
#cmakedefine HAVE_UNISTD_H 1
|
||||
#cmakedefine HAVE_UTIME_H 1
|
||||
|
||||
/*
|
||||
* function definitions - processed in LibmysqlFunctions.txt
|
||||
*/
|
||||
#cmakedefine HAVE_ACCESS 1
|
||||
#cmakedefine HAVE_AIOWAIT 1
|
||||
#cmakedefine HAVE_ALARM 1
|
||||
#cmakedefine HAVE_ALLOCA 1
|
||||
#cmakedefine HAVE_BCMP 1
|
||||
#cmakedefine HAVE_BFILL 1
|
||||
#cmakedefine HAVE_BMOVE 1
|
||||
#cmakedefine HAVE_BZERO 1
|
||||
#cmakedefine HAVE_CLOCK_GETTIME 1
|
||||
#cmakedefine HAVE_COMPRESS 1
|
||||
#cmakedefine HAVE_CRYPT 1
|
||||
#cmakedefine HAVE_DLERROR 1
|
||||
#cmakedefine HAVE_DLOPEN 1
|
||||
#cmakedefine HAVE_FCHMOD 1
|
||||
#cmakedefine HAVE_FCNTL 1
|
||||
#cmakedefine HAVE_FCONVERT 1
|
||||
#cmakedefine HAVE_FDATASYNC 1
|
||||
#cmakedefine HAVE_FESETROUND 1
|
||||
#cmakedefine HAVE_FINITE 1
|
||||
#cmakedefine HAVE_FSEEKO 1
|
||||
#cmakedefine HAVE_FSYNC 1
|
||||
#cmakedefine HAVE_GETADDRINFO 1
|
||||
#cmakedefine HAVE_GETCWD 1
|
||||
#cmakedefine HAVE_GETHOSTBYADDR_R 1
|
||||
#cmakedefine HAVE_GETHOSTBYNAME_R 1
|
||||
#cmakedefine HAVE_GETHRTIME 1
|
||||
#cmakedefine HAVE_GETNAMEINFO 1
|
||||
#cmakedefine HAVE_GETPAGESIZE 1
|
||||
#cmakedefine HAVE_GETPASS 1
|
||||
#cmakedefine HAVE_GETPASSPHRASE 1
|
||||
#cmakedefine HAVE_GETPWNAM 1
|
||||
#cmakedefine HAVE_GETPWUID 1
|
||||
#cmakedefine HAVE_GETRLIMIT 1
|
||||
#cmakedefine HAVE_GETRUSAGE 1
|
||||
#cmakedefine HAVE_GETWD 1
|
||||
#cmakedefine HAVE_GMTIME_R 1
|
||||
#cmakedefine HAVE_INITGROUPS 1
|
||||
#cmakedefine HAVE_LDIV 1
|
||||
#cmakedefine HAVE_LOCALTIME_R 1
|
||||
#cmakedefine HAVE_LOG2 1
|
||||
#cmakedefine HAVE_LONGJMP 1
|
||||
#cmakedefine HAVE_LSTAT 1
|
||||
#cmakedefine HAVE_MADVISE 1
|
||||
#cmakedefine HAVE_MALLINFO 1
|
||||
#cmakedefine HAVE_MEMALIGN 1
|
||||
#cmakedefine HAVE_MEMCPY 1
|
||||
#cmakedefine HAVE_MEMMOVE 1
|
||||
#cmakedefine HAVE_MKSTEMP 1
|
||||
#cmakedefine HAVE_MLOCK 1
|
||||
#cmakedefine HAVE_MLOCKALL 1
|
||||
#cmakedefine HAVE_MMAP 1
|
||||
#cmakedefine HAVE_MMAP64 1
|
||||
#cmakedefine HAVE_PERROR 1
|
||||
#cmakedefine HAVE_POLL 1
|
||||
#cmakedefine HAVE_PREAD 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_CREATE 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_GETSTACKSIZE 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_SETPRIO 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_SETSCHEDPARAM 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_SETSCOPE 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
|
||||
#cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1
|
||||
#cmakedefine HAVE_PTHREAD_INIT 1
|
||||
#cmakedefine HAVE_PTHREAD_KEY_DELETE 1
|
||||
#cmakedefine HAVE_PTHREAD_KILL 1
|
||||
#cmakedefine HAVE_PTHREAD_RWLOCK_RDLOCK 1
|
||||
#cmakedefine HAVE_PTHREAD_SETPRIO_NP 1
|
||||
#cmakedefine HAVE_PTHREAD_SETSCHEDPARAM 1
|
||||
#cmakedefine HAVE_PTHREAD_SIGMASK 1
|
||||
#cmakedefine HAVE_PTHREAD_THREADMASK 1
|
||||
#cmakedefine HAVE_PTHREAD_YIELD_NP 1
|
||||
#cmakedefine HAVE_READDIR_R 1
|
||||
#cmakedefine HAVE_READLINK 1
|
||||
#cmakedefine HAVE_REALPATH 1
|
||||
#cmakedefine HAVE_RENAME 1
|
||||
#cmakedefine HAVE_SCHED_YIELD 1
|
||||
#cmakedefine HAVE_SELECT 1
|
||||
#cmakedefine HAVE_SETFD 1
|
||||
#cmakedefine HAVE_SETFILEPOINTER 1
|
||||
#cmakedefine HAVE_SIGNAL 1
|
||||
#cmakedefine HAVE_SIGACTION 1
|
||||
#cmakedefine HAVE_SIGTHREADMASK 1
|
||||
#cmakedefine HAVE_SIGWAIT 1
|
||||
#cmakedefine HAVE_SLEEP 1
|
||||
#cmakedefine HAVE_SNPRINTF 1
|
||||
#cmakedefine HAVE_SQLITE 1
|
||||
#cmakedefine HAVE_STPCPY 1
|
||||
#cmakedefine HAVE_STRERROR 1
|
||||
#cmakedefine HAVE_STRLCPY 1
|
||||
#cmakedefine HAVE_STRNLEN 1
|
||||
#cmakedefine HAVE_STRPBRK 1
|
||||
#cmakedefine HAVE_STRSEP 1
|
||||
#cmakedefine HAVE_STRSTR 1
|
||||
#cmakedefine HAVE_STRTOK_R 1
|
||||
#cmakedefine HAVE_STRTOL 1
|
||||
#cmakedefine HAVE_STRTOLL 1
|
||||
#cmakedefine HAVE_STRTOUL 1
|
||||
#cmakedefine HAVE_STRTOULL 1
|
||||
#cmakedefine HAVE_TELL 1
|
||||
#cmakedefine HAVE_THR_SETCONCURRENCY 1
|
||||
#cmakedefine HAVE_THR_YIELD 1
|
||||
#cmakedefine HAVE_VASPRINTF 1
|
||||
#cmakedefine HAVE_VSNPRINTF 1
|
||||
|
||||
/*
|
||||
* types and sizes
|
||||
*/
|
||||
/* Types we may use */
|
||||
#cmakedefine SIZEOF_CHAR @SIZEOF_CHAR@
|
||||
#if SIZEOF_CHAR
|
||||
# define HAVE_CHAR 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_CHARP @SIZEOF_CHARP@
|
||||
#if SIZEOF_CHARP
|
||||
# define HAVE_CHARP 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_SHORT @SIZEOF_SHORT@
|
||||
#if SIZEOF_SHORT
|
||||
# define HAVE_SHORT 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_INT @SIZEOF_INT@
|
||||
#if SIZEOF_INT
|
||||
# define HAVE_INT 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_LONG @SIZEOF_LONG@
|
||||
#if SIZEOF_LONG
|
||||
# define HAVE_LONG 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@
|
||||
#if SIZEOF_LONG_LONG
|
||||
# define HAVE_LONG_LONG 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_OFF_T @SIZEOF_OFF_T@
|
||||
#if SIZEOF_OFF_T
|
||||
# define HAVE_OFF_T 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_SIGSET_T @SIZEOF_SIGSET_T@
|
||||
#if SIZEOF_SIGSET_T
|
||||
# define HAVE_SIGSET_T 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@
|
||||
#if SIZEOF_SIZE_T
|
||||
# define HAVE_SIZE_T 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_UCHAR @SIZEOF_UCHAR@
|
||||
#if SIZEOF_UCHAR
|
||||
# define HAVE_UCHAR 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_UINT @SIZEOF_UINT@
|
||||
#if SIZEOF_UINT
|
||||
# define HAVE_UINT 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_ULONG @SIZEOF_ULONG@
|
||||
#if SIZEOF_ULONG
|
||||
# define HAVE_ULONG 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_INT8 @SIZEOF_INT8@
|
||||
#if SIZEOF_INT8
|
||||
# define HAVE_INT8 1
|
||||
#endif
|
||||
#cmakedefine SIZEOF_UINT8 @SIZEOF_UINT8@
|
||||
#if SIZEOF_UINT8
|
||||
# define HAVE_UINT8 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_INT16 @SIZEOF_INT16@
|
||||
#if SIZEOF_INT16
|
||||
# define HAVE_INT16 1
|
||||
#endif
|
||||
#cmakedefine SIZEOF_UINT16 @SIZEOF_UINT16@
|
||||
#if SIZEOF_UINT16
|
||||
# define HAVE_UINT16 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_INT32 @SIZEOF_INT32@
|
||||
#if SIZEOF_INT32
|
||||
# define HAVE_INT32 1
|
||||
#endif
|
||||
#cmakedefine SIZEOF_UINT32 @SIZEOF_UINT32@
|
||||
#if SIZEOF_UINT32
|
||||
# define HAVE_UINT32 1
|
||||
#endif
|
||||
#cmakedefine SIZEOF_U_INT32_T @SIZEOF_U_INT32_T@
|
||||
#if SIZEOF_U_INT32_T
|
||||
# define HAVE_U_INT32_T 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_INT64 @SIZEOF_INT64@
|
||||
#if SIZEOF_INT64
|
||||
# define HAVE_INT64 1
|
||||
#endif
|
||||
#cmakedefine SIZEOF_UINT64 @SIZEOF_UINT64@
|
||||
#if SIZEOF_UINT64
|
||||
# define HAVE_UINT64 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_SOCKLEN_T @SIZEOF_SOCKLEN_T@
|
||||
#if SIZEOF_SOCKLEN_T
|
||||
# define HAVE_SOCKLEN_T 1
|
||||
#endif
|
||||
|
||||
#cmakedefine SOCKET_SIZE_TYPE @SOCKET_SIZE_TYPE@
|
||||
|
||||
#cmakedefine RETSIGTYPE @RETSIGTYPE@
|
||||
#cmakedefine RETQSORTTYPE @RETQSORTTYPE@
|
||||
|
||||
/*
|
||||
* various other defines
|
||||
*/
|
||||
#cmakedefine HAVE_THREADS 1
|
||||
#cmakedefine SHAREDIR "@SHAREDIR@"
|
||||
#cmakedefine DEFAULT_CHARSET_HOME "@DEFAULT_CHARSET_HOME@"
|
||||
#cmakedefine PLUGINDIR "@PREFIX_INSTALL_DIR@/@PLUGIN_INSTALL_DIR@"
|
||||
|
232
module/Vendor/MDBC/include/my_context.h
vendored
Normal file
232
module/Vendor/MDBC/include/my_context.h
vendored
Normal file
@ -0,0 +1,232 @@
|
||||
/*
|
||||
Copyright 2011 Kristian Nielsen and Monty Program Ab
|
||||
|
||||
This file is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
Simple API for spawning a co-routine, to be used for async libmysqlclient.
|
||||
|
||||
Idea is that by implementing this interface using whatever facilities are
|
||||
available for given platform, we can use the same code for the generic
|
||||
libmysqlclient-async code.
|
||||
|
||||
(This particular implementation uses Posix ucontext swapcontext().)
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MY_CONTEXT_USE_WIN32_FIBERS 1
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__x86_64__) && !defined(__ILP32__)
|
||||
#define MY_CONTEXT_USE_X86_64_GCC_ASM
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__i386__)
|
||||
#define MY_CONTEXT_USE_I386_GCC_ASM
|
||||
#elif defined(HAVE_UCONTEXT_H)
|
||||
#define MY_CONTEXT_USE_UCONTEXT
|
||||
#else
|
||||
#define MY_CONTEXT_DISABLE
|
||||
#endif
|
||||
|
||||
#ifdef MY_CONTEXT_USE_WIN32_FIBERS
|
||||
struct my_context {
|
||||
void (*user_func)(void *);
|
||||
void *user_arg;
|
||||
void *app_fiber;
|
||||
void *lib_fiber;
|
||||
int return_value;
|
||||
#ifndef DBUG_OFF
|
||||
void *dbug_state;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MY_CONTEXT_USE_UCONTEXT
|
||||
#include <ucontext.h>
|
||||
|
||||
struct my_context {
|
||||
void (*user_func)(void *);
|
||||
void *user_data;
|
||||
void *stack;
|
||||
size_t stack_size;
|
||||
ucontext_t base_context;
|
||||
ucontext_t spawned_context;
|
||||
int active;
|
||||
#ifdef HAVE_VALGRIND
|
||||
unsigned int valgrind_stack_id;
|
||||
#endif
|
||||
#ifndef DBUG_OFF
|
||||
void *dbug_state;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MY_CONTEXT_USE_X86_64_GCC_ASM
|
||||
#include <stdint.h>
|
||||
|
||||
struct my_context {
|
||||
uint64_t save[9];
|
||||
void *stack_top;
|
||||
void *stack_bot;
|
||||
#ifdef HAVE_VALGRIND
|
||||
unsigned int valgrind_stack_id;
|
||||
#endif
|
||||
#ifndef DBUG_OFF
|
||||
void *dbug_state;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MY_CONTEXT_USE_I386_GCC_ASM
|
||||
#include <stdint.h>
|
||||
|
||||
struct my_context {
|
||||
uint64_t save[7];
|
||||
void *stack_top;
|
||||
void *stack_bot;
|
||||
#ifdef HAVE_VALGRIND
|
||||
unsigned int valgrind_stack_id;
|
||||
#endif
|
||||
#ifndef DBUG_OFF
|
||||
void *dbug_state;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MY_CONTEXT_DISABLE
|
||||
struct my_context {
|
||||
int dummy;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Initialize an asynchroneous context object.
|
||||
Returns 0 on success, non-zero on failure.
|
||||
*/
|
||||
extern int my_context_init(struct my_context *c, size_t stack_size);
|
||||
|
||||
/* Free an asynchroneous context object, deallocating any resources used. */
|
||||
extern void my_context_destroy(struct my_context *c);
|
||||
|
||||
/*
|
||||
Spawn an asynchroneous context. The context will run the supplied user
|
||||
function, passing the supplied user data pointer.
|
||||
|
||||
The context must have been initialised with my_context_init() prior to
|
||||
this call.
|
||||
|
||||
The user function may call my_context_yield(), which will cause this
|
||||
function to return 1. Then later my_context_continue() may be called, which
|
||||
will resume the asynchroneous context by returning from the previous
|
||||
my_context_yield() call.
|
||||
|
||||
When the user function returns, this function returns 0.
|
||||
|
||||
In case of error, -1 is returned.
|
||||
*/
|
||||
extern int my_context_spawn(struct my_context *c, void (*f)(void *), void *d);
|
||||
|
||||
/*
|
||||
Suspend an asynchroneous context started with my_context_spawn.
|
||||
|
||||
When my_context_yield() is called, execution immediately returns from the
|
||||
last my_context_spawn() or my_context_continue() call. Then when later
|
||||
my_context_continue() is called, execution resumes by returning from this
|
||||
my_context_yield() call.
|
||||
|
||||
Returns 0 if ok, -1 in case of error.
|
||||
*/
|
||||
extern int my_context_yield(struct my_context *c);
|
||||
|
||||
/*
|
||||
Resume an asynchroneous context. The context was spawned by
|
||||
my_context_spawn(), and later suspended inside my_context_yield().
|
||||
|
||||
The asynchroneous context may be repeatedly suspended with
|
||||
my_context_yield() and resumed with my_context_continue().
|
||||
|
||||
Each time it is suspended, this function returns 1. When the originally
|
||||
spawned user function returns, this function returns 0.
|
||||
|
||||
In case of error, -1 is returned.
|
||||
*/
|
||||
extern int my_context_continue(struct my_context *c);
|
||||
|
||||
|
||||
struct mysql_async_context {
|
||||
/*
|
||||
This is set to the value that should be returned from foo_start() or
|
||||
foo_cont() when a call is suspended.
|
||||
*/
|
||||
unsigned int events_to_wait_for;
|
||||
/*
|
||||
It is also set to the event(s) that triggered when a suspended call is
|
||||
resumed, eg. whether we woke up due to connection completed or timeout
|
||||
in mysql_real_connect_cont().
|
||||
*/
|
||||
unsigned int events_occured;
|
||||
/*
|
||||
This is set to the result of the whole asynchronous operation when it
|
||||
completes. It uses a union, as different calls have different return
|
||||
types.
|
||||
*/
|
||||
union {
|
||||
void *r_ptr;
|
||||
const void *r_const_ptr;
|
||||
int r_int;
|
||||
my_bool r_my_bool;
|
||||
} ret_result;
|
||||
/*
|
||||
The timeout value (in millisecods), for suspended calls that need to wake
|
||||
up on a timeout (eg. mysql_real_connect_start().
|
||||
*/
|
||||
unsigned int timeout_value;
|
||||
/*
|
||||
This flag is set when we are executing inside some asynchronous call
|
||||
foo_start() or foo_cont(). It is used to decide whether to use the
|
||||
synchronous or asynchronous version of calls that may block such as
|
||||
recv().
|
||||
|
||||
Note that this flag is not set when a call is suspended, eg. after
|
||||
returning from foo_start() and before re-entering foo_cont().
|
||||
*/
|
||||
my_bool active;
|
||||
/*
|
||||
This flag is set when an asynchronous operation is in progress, but
|
||||
suspended. Ie. it is set when foo_start() or foo_cont() returns because
|
||||
the operation needs to block, suspending the operation.
|
||||
|
||||
It is used to give an error (rather than crash) if the application
|
||||
attempts to call some foo_cont() method when no suspended operation foo is
|
||||
in progress.
|
||||
*/
|
||||
my_bool suspended;
|
||||
/*
|
||||
If non-NULL, this is a pointer to a callback hook that will be invoked with
|
||||
the user data argument just before the context is suspended, and just after
|
||||
it is resumed.
|
||||
*/
|
||||
void (*suspend_resume_hook)(my_bool suspend, void *user_data);
|
||||
void *suspend_resume_hook_user_data;
|
||||
/*
|
||||
This is used to save the execution contexts so that we can suspend an
|
||||
operation and switch back to the application context, to resume the
|
||||
suspended context later when the application re-invokes us with
|
||||
foo_cont().
|
||||
*/
|
||||
struct my_context async_context;
|
||||
};
|
100
module/Vendor/MDBC/include/my_dir.h
vendored
Normal file
100
module/Vendor/MDBC/include/my_dir.h
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
/* 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 _my_dir_h
|
||||
#define _my_dir_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef MY_DIR_H
|
||||
#define MY_DIR_H
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* Defines for my_dir and my_stat */
|
||||
|
||||
#define MY_S_IFMT S_IFMT /* type of file */
|
||||
#define MY_S_IFDIR S_IFDIR /* directory */
|
||||
#define MY_S_IFCHR S_IFCHR /* character special */
|
||||
#define MY_S_IFBLK S_IFBLK /* block special */
|
||||
#define MY_S_IFREG S_IFREG /* regular */
|
||||
#define MY_S_IFIFO S_IFIFO /* fifo */
|
||||
#define MY_S_ISUID S_ISUID /* set user id on execution */
|
||||
#define MY_S_ISGID S_ISGID /* set group id on execution */
|
||||
#define MY_S_ISVTX S_ISVTX /* save swapped text even after use */
|
||||
#define MY_S_IREAD S_IREAD /* read permission, owner */
|
||||
#define MY_S_IWRITE S_IWRITE /* write permission, owner */
|
||||
#define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */
|
||||
|
||||
#define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR)
|
||||
#define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR)
|
||||
#define MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK)
|
||||
#define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG)
|
||||
#define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO)
|
||||
|
||||
#define MY_DONT_SORT 512 /* my_lib; Don't sort files */
|
||||
#define MY_WANT_STAT 1024 /* my_lib; stat files */
|
||||
|
||||
/* typedefs for my_dir & my_stat */
|
||||
|
||||
#ifdef USE_MY_STAT_STRUCT
|
||||
|
||||
typedef struct my_stat
|
||||
{
|
||||
dev_t st_dev; /* major & minor device numbers */
|
||||
ino_t st_ino; /* inode number */
|
||||
ushort st_mode; /* file permissons (& suid sgid .. bits) */
|
||||
short st_nlink; /* number of links to file */
|
||||
ushort st_uid; /* user id */
|
||||
ushort st_gid; /* group id */
|
||||
dev_t st_rdev; /* more major & minor device numbers (???) */
|
||||
off_t st_size; /* size of file */
|
||||
time_t st_atime; /* time for last read */
|
||||
time_t st_mtime; /* time for last contens modify */
|
||||
time_t st_ctime; /* time for last inode or contents modify */
|
||||
} MY_STAT;
|
||||
|
||||
#else
|
||||
|
||||
#define MY_STAT struct stat /* Orginal struct have what we need */
|
||||
|
||||
#endif /* USE_MY_STAT_STRUCT */
|
||||
|
||||
typedef struct fileinfo /* Struct returned from my_dir & my_stat */
|
||||
{
|
||||
char *name;
|
||||
MY_STAT mystat;
|
||||
} FILEINFO;
|
||||
|
||||
typedef struct st_my_dir /* Struct returned from my_dir */
|
||||
{
|
||||
struct fileinfo *dir_entry;
|
||||
uint number_off_files;
|
||||
} MY_DIR;
|
||||
|
||||
extern MY_DIR *my_dir(const char *path,myf MyFlags);
|
||||
extern void my_dirend(MY_DIR *buffer);
|
||||
extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags);
|
||||
extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags);
|
||||
|
||||
#endif /* MY_DIR_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
1114
module/Vendor/MDBC/include/my_global.h
vendored
Normal file
1114
module/Vendor/MDBC/include/my_global.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
47
module/Vendor/MDBC/include/my_list.h
vendored
Normal file
47
module/Vendor/MDBC/include/my_list.h
vendored
Normal file
@ -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,gptr argument);
|
||||
|
||||
#define 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((gptr) old,MYF(MY_FAE)); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
48
module/Vendor/MDBC/include/my_net.h
vendored
Normal file
48
module/Vendor/MDBC/include/my_net.h
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/* 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 */
|
||||
|
||||
/* thread safe version of some common functions */
|
||||
|
||||
/* for thread safe my_inet_ntoa */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if !defined(MSDOS) && !defined(_WIN32) && !defined(__BEOS__)
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#endif /* !defined(MSDOS) && !defined(_WIN32) */
|
||||
|
||||
|
||||
/* On SCO you get a link error when refering to h_errno */
|
||||
#ifdef SCO
|
||||
#undef h_errno
|
||||
#define h_errno errno
|
||||
#endif
|
||||
|
||||
void my_inet_ntoa(struct in_addr in, char *buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
32
module/Vendor/MDBC/include/my_no_pthread.h
vendored
Normal file
32
module/Vendor/MDBC/include/my_no_pthread.h
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/* 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 */
|
||||
|
||||
/*
|
||||
This undefs some pthread mutex locks when one isn't using threads
|
||||
to make thread safe code, that should also work in single thread
|
||||
environment, easier to use.
|
||||
*/
|
||||
|
||||
#if !defined(_my_no_pthread_h) && !defined(THREAD)
|
||||
#define _my_no_pthread_h
|
||||
|
||||
#define pthread_mutex_init(A,B)
|
||||
#define pthread_mutex_lock(A)
|
||||
#define pthread_mutex_unlock(A)
|
||||
#define pthread_mutex_destroy(A)
|
||||
|
||||
#endif
|
590
module/Vendor/MDBC/include/my_pthread.h
vendored
Normal file
590
module/Vendor/MDBC/include/my_pthread.h
vendored
Normal file
@ -0,0 +1,590 @@
|
||||
/* 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 */
|
||||
|
||||
/* Defines to make different thread packages compatible */
|
||||
|
||||
#ifndef _my_pthread_h
|
||||
#define _my_pthread_h
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef ETIME
|
||||
#define ETIME ETIMEDOUT /* For FreeBSD */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
typedef CRITICAL_SECTION pthread_mutex_t;
|
||||
|
||||
typedef HANDLE pthread_t;
|
||||
typedef struct thread_attr {
|
||||
DWORD dwStackSize ;
|
||||
DWORD dwCreatingFlag ;
|
||||
int priority ;
|
||||
} pthread_attr_t ;
|
||||
|
||||
typedef struct { int dummy; } pthread_condattr_t;
|
||||
|
||||
/* Implementation of posix conditions */
|
||||
|
||||
typedef struct st_pthread_link {
|
||||
DWORD thread_id;
|
||||
struct st_pthread_link *next;
|
||||
} pthread_link;
|
||||
|
||||
typedef struct {
|
||||
uint32 waiting;
|
||||
|
||||
enum {
|
||||
SIGNAL = 0,
|
||||
BROADCAST = 1,
|
||||
MAX_EVENTS = 2
|
||||
} EVENTS;
|
||||
HANDLE events[MAX_EVENTS];
|
||||
CRITICAL_SECTION waiters_count_lock;
|
||||
} pthread_cond_t;
|
||||
|
||||
#ifndef _TIMESPEC_DEFINED
|
||||
#if (!defined(_MSC_VER) || _MSC_VER < 1900)
|
||||
struct timespec { /* For pthread_cond_timedwait() */
|
||||
time_t tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef int pthread_mutexattr_t;
|
||||
#define pthread_self() GetCurrentThreadId()
|
||||
|
||||
#define pthread_handler_decl(A,B) void * __cdecl A(void *B)
|
||||
typedef void * (__cdecl *pthread_handler)(void *);
|
||||
|
||||
void win_pthread_init(void);
|
||||
|
||||
int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
|
||||
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
|
||||
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
|
||||
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
struct timespec *abstime);
|
||||
int pthread_cond_signal(pthread_cond_t *cond);
|
||||
int pthread_cond_broadcast(pthread_cond_t *cond);
|
||||
int pthread_cond_destroy(pthread_cond_t *cond);
|
||||
int pthread_attr_init(pthread_attr_t *connect_att);
|
||||
int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
|
||||
int pthread_attr_setprio(pthread_attr_t *connect_att,int priority);
|
||||
int pthread_attr_destroy(pthread_attr_t *connect_att);
|
||||
struct tm *localtime_r(const time_t *timep,struct tm *tmp);
|
||||
|
||||
void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
|
||||
|
||||
#ifndef OS2
|
||||
#define getpid() GetCurrentThreadId()
|
||||
#endif
|
||||
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
#define _REENTRANT 1
|
||||
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
|
||||
|
||||
#undef SAFE_MUTEX /* This will cause conflicts */
|
||||
#define pthread_key(T,V) DWORD V
|
||||
#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
|
||||
#define pthread_getspecific(A) (TlsGetValue(A))
|
||||
#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
|
||||
#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V))
|
||||
#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V)))
|
||||
#define pthread_setspecific(A,B) (!TlsSetValue((A),(B)))
|
||||
|
||||
|
||||
#define pthread_equal(A,B) ((A) == (B))
|
||||
|
||||
#define pthread_mutex_init(A,B) InitializeCriticalSection(A)
|
||||
#define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
|
||||
#define pthread_mutex_trylock(A) (WaitForSingleObject((A), 0) == WAIT_TIMEOUT)
|
||||
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
|
||||
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
|
||||
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
|
||||
#define pthread_kill(A,B) pthread_dummy(0)
|
||||
|
||||
|
||||
/* Dummy defines for easier code */
|
||||
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
|
||||
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B)
|
||||
#define pthread_attr_setscope(A,B)
|
||||
#define pthread_detach_this_thread()
|
||||
#define pthread_condattr_init(A)
|
||||
#define pthread_condattr_destroy(A)
|
||||
|
||||
/*Irena: compiler does not like this: */
|
||||
/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */
|
||||
#define my_pthread_getprio(thread_id) pthread_dummy(0)
|
||||
|
||||
#elif defined(HAVE_UNIXWARE7_THREADS)
|
||||
|
||||
#include <thread.h>
|
||||
#include <synch.h>
|
||||
|
||||
#ifndef _REENTRANT
|
||||
#define _REENTRANT
|
||||
#endif
|
||||
|
||||
#define HAVE_NONPOSIX_SIGWAIT
|
||||
#define pthread_t thread_t
|
||||
#define pthread_cond_t cond_t
|
||||
#define pthread_mutex_t mutex_t
|
||||
#define pthread_key_t thread_key_t
|
||||
typedef int pthread_attr_t; /* Needed by Unixware 7.0.0 */
|
||||
|
||||
#define pthread_key_create(A,B) thr_keycreate((A),(B))
|
||||
|
||||
#define pthread_handler_decl(A,B) void *A(void *B)
|
||||
#define pthread_key(T,V) pthread_key_t V
|
||||
|
||||
void * my_pthread_getspecific_imp(pthread_key_t key);
|
||||
#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
|
||||
#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,V)
|
||||
|
||||
#define pthread_setspecific(A,B) thr_setspecific(A,B)
|
||||
#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,V)
|
||||
|
||||
#define pthread_create(A,B,C,D) thr_create(NULL,65536L,(C),(D),THR_DETACHED,(A))
|
||||
#define pthread_cond_init(a,b) cond_init((a),USYNC_THREAD,NULL)
|
||||
#define pthread_cond_destroy(a) cond_destroy(a)
|
||||
#define pthread_cond_signal(a) cond_signal(a)
|
||||
#define pthread_cond_wait(a,b) cond_wait((a),(b))
|
||||
#define pthread_cond_timedwait(a,b,c) cond_timedwait((a),(b),(c))
|
||||
#define pthread_cond_broadcast(a) cond_broadcast(a)
|
||||
|
||||
#define pthread_mutex_init(a,b) mutex_init((a),USYNC_THREAD,NULL)
|
||||
#define pthread_mutex_lock(a) mutex_lock(a)
|
||||
#define pthread_mutex_unlock(a) mutex_unlock(a)
|
||||
#define pthread_mutex_destroy(a) mutex_destroy(a)
|
||||
|
||||
#define pthread_self() thr_self()
|
||||
#define pthread_exit(A) thr_exit(A)
|
||||
#define pthread_equal(A,B) (((A) == (B)) ? 1 : 0)
|
||||
#define pthread_kill(A,B) thr_kill((A),(B))
|
||||
#define HAVE_PTHREAD_KILL
|
||||
|
||||
#define pthread_sigmask(A,B,C) thr_sigsetmask((A),(B),(C))
|
||||
|
||||
extern int my_sigwait(const sigset_t *set,int *sig);
|
||||
|
||||
#define pthread_detach_this_thread() pthread_dummy(0)
|
||||
|
||||
#define pthread_attr_init(A) pthread_dummy(0)
|
||||
#define pthread_attr_destroy(A) pthread_dummy(0)
|
||||
#define pthread_attr_setscope(A,B) pthread_dummy(0)
|
||||
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
|
||||
#define my_pthread_setprio(A,B) pthread_dummy (0)
|
||||
#define my_pthread_getprio(A) pthread_dummy (0)
|
||||
#define my_pthread_attr_setprio(A,B) pthread_dummy(0)
|
||||
|
||||
#else /* Normal threads */
|
||||
|
||||
#ifdef HAVE_rts_threads
|
||||
#define sigwait org_sigwait
|
||||
#include <signal.h>
|
||||
#undef sigwait
|
||||
#endif
|
||||
#undef _REENTRANT /* Fix if _REENTRANT is in pthread.h */
|
||||
#include <pthread.h>
|
||||
#ifndef _REENTRANT
|
||||
#define _REENTRANT
|
||||
#endif
|
||||
#ifdef HAVE_THR_SETCONCURRENCY
|
||||
#include <thread.h> /* Probably solaris */
|
||||
#endif
|
||||
#ifdef HAVE_SCHED_H
|
||||
#include <sched.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYNCH_H
|
||||
#include <synch.h>
|
||||
#endif
|
||||
#if defined(__EMX__) && (!defined(EMX_PTHREAD_REV) || (EMX_PTHREAD_REV < 2))
|
||||
#error Requires at least rev 2 of EMX pthreads library.
|
||||
#endif
|
||||
|
||||
extern int my_pthread_getprio(pthread_t thread_id);
|
||||
|
||||
#define pthread_key(T,V) pthread_key_t V
|
||||
#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V))
|
||||
#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V))
|
||||
#define pthread_detach_this_thread()
|
||||
#define pthread_handler_decl(A,B) void *A(void *B)
|
||||
typedef void *(* pthread_handler)(void *);
|
||||
|
||||
/* Test first for RTS or FSU threads */
|
||||
|
||||
#if defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM)
|
||||
#define HAVE_rts_threads
|
||||
extern int my_pthread_create_detached;
|
||||
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
|
||||
#define PTHREAD_CREATE_DETACHED &my_pthread_create_detached
|
||||
#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_GLOBAL
|
||||
#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_LOCAL
|
||||
#define USE_ALARM_THREAD
|
||||
#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */
|
||||
|
||||
#if defined(HAVE_UNIXWARE7_POSIX)
|
||||
#undef HAVE_NONPOSIX_SIGWAIT
|
||||
#define HAVE_NONPOSIX_SIGWAIT /* sigwait takes only 1 argument */
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_NONPOSIX_SIGWAIT
|
||||
#define my_sigwait(A,B) sigwait((A),(B))
|
||||
#else
|
||||
int my_sigwait(const sigset_t *set,int *sig);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT
|
||||
#ifndef SAFE_MUTEX
|
||||
#define pthread_mutex_init(a,b) my_pthread_mutex_init((a),(b))
|
||||
extern int my_pthread_mutex_init(pthread_mutex_t *mp,
|
||||
const pthread_mutexattr_t *attr);
|
||||
#endif /* SAFE_MUTEX */
|
||||
#define pthread_cond_init(a,b) my_pthread_cond_init((a),(b))
|
||||
extern int my_pthread_cond_init(pthread_cond_t *mp,
|
||||
const pthread_condattr_t *attr);
|
||||
#endif /* HAVE_NONPOSIX_PTHREAD_MUTEX_INIT */
|
||||
|
||||
#if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK)
|
||||
#define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
|
||||
int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
|
||||
#endif
|
||||
#if !defined(HAVE_SIGSET) && !defined(my_sigset)
|
||||
#define my_sigset(A,B) do { struct sigaction s; sigset_t set; \
|
||||
sigemptyset(&set); \
|
||||
s.sa_handler = (B); \
|
||||
s.sa_mask = set; \
|
||||
s.sa_flags = 0; \
|
||||
sigaction((A), &s, (struct sigaction *) NULL); \
|
||||
} while (0)
|
||||
#elif !defined(my_sigset)
|
||||
#define my_sigset(A,B) signal((A),(B))
|
||||
#endif
|
||||
|
||||
#ifndef my_pthread_setprio
|
||||
#if defined(HAVE_PTHREAD_SETPRIO_NP) /* FSU threads */
|
||||
#define my_pthread_setprio(A,B) pthread_setprio_np((A),(B))
|
||||
#elif defined(HAVE_PTHREAD_SETPRIO)
|
||||
#define my_pthread_setprio(A,B) pthread_setprio((A),(B))
|
||||
#else
|
||||
extern void my_pthread_setprio(pthread_t thread_id,int prior);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef my_pthread_attr_setprio
|
||||
#ifdef HAVE_PTHREAD_ATTR_SETPRIO
|
||||
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B))
|
||||
#else
|
||||
extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS)
|
||||
#define pthread_attr_setscope(A,B)
|
||||
#undef HAVE_GETHOSTBYADDR_R /* No definition */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT) && !defined(SAFE_MUTEX)
|
||||
extern int my_pthread_cond_timedwait(pthread_cond_t *cond,
|
||||
pthread_mutex_t *mutex,
|
||||
struct timespec *abstime);
|
||||
#define pthread_cond_timedwait(A,B,C) my_pthread_cond_timedwait((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if !defined( HAVE_NONPOSIX_PTHREAD_GETSPECIFIC)
|
||||
#define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B))
|
||||
#else
|
||||
#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
|
||||
void *my_pthread_getspecific_imp(pthread_key_t key);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
struct tm *localtime_r(const time_t *clock, struct tm *res);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD_CONDATTR_CREATE
|
||||
/* DCE threads on HPUX 10.20 */
|
||||
#define pthread_condattr_init pthread_condattr_create
|
||||
#define pthread_condattr_destroy pthread_condattr_delete
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */
|
||||
#define pthread_cond_destroy(A) pthread_dummy(0)
|
||||
#define pthread_mutex_destroy(A) pthread_dummy(0)
|
||||
#define pthread_attr_delete(A) pthread_dummy(0)
|
||||
#define pthread_condattr_delete(A) pthread_dummy(0)
|
||||
#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
|
||||
#define pthread_equal(A,B) ((A) == (B))
|
||||
#define pthread_cond_timedwait(a,b,c) pthread_cond_wait((a),(b))
|
||||
#define pthread_attr_init(A) pthread_attr_create(A)
|
||||
#define pthread_attr_destroy(A) pthread_attr_delete(A)
|
||||
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
|
||||
#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
|
||||
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
|
||||
#define pthread_kill(A,B) pthread_dummy(0)
|
||||
#undef pthread_detach_this_thread
|
||||
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DARWIN_THREADS
|
||||
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
|
||||
#define pthread_kill(A,B) pthread_dummy(0)
|
||||
#define pthread_condattr_init(A) pthread_dummy(0)
|
||||
#define pthread_condattr_destroy(A) pthread_dummy(0)
|
||||
#define pthread_signal(A,B) pthread_dummy(0)
|
||||
#undef pthread_detach_this_thread
|
||||
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); }
|
||||
#undef sigset
|
||||
#define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
|
||||
#endif
|
||||
|
||||
#if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
|
||||
/* This is set on AIX_3_2 and Siemens unix (and DEC OSF/1 3.2 too) */
|
||||
#define pthread_key_create(A,B) \
|
||||
pthread_keycreate(A,(B) ?\
|
||||
(pthread_destructor_t) (B) :\
|
||||
(pthread_destructor_t) pthread_dummy)
|
||||
#define pthread_attr_init(A) pthread_attr_create(A)
|
||||
#define pthread_attr_destroy(A) pthread_attr_delete(A)
|
||||
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
|
||||
#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
|
||||
#ifndef pthread_sigmask
|
||||
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
|
||||
#endif
|
||||
#define pthread_kill(A,B) pthread_dummy(0)
|
||||
#undef pthread_detach_this_thread
|
||||
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
|
||||
+#elif !defined(HAVE_PTHREAD_KILL) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */
|
||||
#define HAVE_PTHREAD_KILL
|
||||
#endif
|
||||
|
||||
#endif /* defined(_WIN32) */
|
||||
|
||||
#if defined(HPUX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
|
||||
#undef pthread_cond_timedwait
|
||||
#define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c))
|
||||
int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
struct timespec *abstime);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_POSIX1003_4a_MUTEX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
|
||||
#undef pthread_mutex_trylock
|
||||
#define pthread_mutex_trylock(a) my_pthread_mutex_trylock((a))
|
||||
int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
|
||||
#endif
|
||||
|
||||
/* safe_mutex adds checking to mutex for easier debugging */
|
||||
|
||||
typedef struct st_safe_mutex_t
|
||||
{
|
||||
pthread_mutex_t global,mutex;
|
||||
char *file;
|
||||
uint line,count;
|
||||
pthread_t thread;
|
||||
} safe_mutex_t;
|
||||
|
||||
int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr);
|
||||
int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line);
|
||||
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line);
|
||||
int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line);
|
||||
int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file,
|
||||
uint line);
|
||||
int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
|
||||
struct timespec *abstime, const char *file, uint line);
|
||||
|
||||
/* Wrappers if safe mutex is actually used */
|
||||
#ifdef SAFE_MUTEX
|
||||
#undef pthread_mutex_init
|
||||
#undef pthread_mutex_lock
|
||||
#undef pthread_mutex_unlock
|
||||
#undef pthread_mutex_destroy
|
||||
#undef pthread_mutex_wait
|
||||
#undef pthread_mutex_timedwait
|
||||
#undef pthread_mutex_t
|
||||
#undef pthread_cond_wait
|
||||
#undef pthread_cond_timedwait
|
||||
#undef pthread_mutex_trylock
|
||||
#define pthread_mutex_init(A,B) safe_mutex_init((A),(B))
|
||||
#define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__)
|
||||
#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
|
||||
#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__)
|
||||
#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__)
|
||||
#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
|
||||
#define pthread_mutex_trylock(A) pthread_mutex_lock(A)
|
||||
#define pthread_mutex_t safe_mutex_t
|
||||
#define safe_mutex_assert_owner(mp) DBUG_ASSERT((mp)->count > 0 && pthread_equal(pthread_self(),(mp)->thread))
|
||||
#else
|
||||
#define safe_mutex_assert_owner(mp)
|
||||
#endif /* SAFE_MUTEX */
|
||||
|
||||
/* READ-WRITE thread locking */
|
||||
|
||||
#if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS)
|
||||
/* use these defs for simple mutex locking */
|
||||
#define rw_lock_t pthread_mutex_t
|
||||
#define my_rwlock_init(A,B) pthread_mutex_init((A),(B))
|
||||
#define rw_rdlock(A) pthread_mutex_lock((A))
|
||||
#define rw_wrlock(A) pthread_mutex_lock((A))
|
||||
#define rw_tryrdlock(A) pthread_mutex_trylock((A))
|
||||
#define rw_trywrlock(A) pthread_mutex_trylock((A))
|
||||
#define rw_unlock(A) pthread_mutex_unlock((A))
|
||||
#define rwlock_destroy(A) pthread_mutex_destroy((A))
|
||||
#elif defined(HAVE_PTHREAD_RWLOCK_RDLOCK)
|
||||
#define rw_lock_t pthread_rwlock_t
|
||||
#define my_rwlock_init(A,B) pthread_rwlock_init((A),(B))
|
||||
#define rw_rdlock(A) pthread_rwlock_rdlock(A)
|
||||
#define rw_wrlock(A) pthread_rwlock_wrlock(A)
|
||||
#define rw_tryrdlock(A) pthread_rwlock_tryrdlock((A))
|
||||
#define rw_trywrlock(A) pthread_rwlock_trywrlock((A))
|
||||
#define rw_unlock(A) pthread_rwlock_unlock(A)
|
||||
#define rwlock_destroy(A) pthread_rwlock_destroy(A)
|
||||
#elif defined(HAVE_RWLOCK_INIT)
|
||||
#ifdef HAVE_RWLOCK_T /* For example Solaris 2.6-> */
|
||||
#define rw_lock_t rwlock_t
|
||||
#endif
|
||||
#define my_rwlock_init(A,B) rwlock_init((A),USYNC_THREAD,0)
|
||||
#else
|
||||
/* Use our own version of read/write locks */
|
||||
typedef struct _my_rw_lock_t {
|
||||
pthread_mutex_t lock; /* lock for structure */
|
||||
pthread_cond_t readers; /* waiting readers */
|
||||
pthread_cond_t writers; /* waiting writers */
|
||||
int state; /* -1:writer,0:free,>0:readers */
|
||||
int waiters; /* number of waiting writers */
|
||||
} my_rw_lock_t;
|
||||
|
||||
#define rw_lock_t my_rw_lock_t
|
||||
#define rw_rdlock(A) my_rw_rdlock((A))
|
||||
#define rw_wrlock(A) my_rw_wrlock((A))
|
||||
#define rw_tryrdlock(A) my_rw_tryrdlock((A))
|
||||
#define rw_trywrlock(A) my_rw_trywrlock((A))
|
||||
#define rw_unlock(A) my_rw_unlock((A))
|
||||
#define rwlock_destroy(A) my_rwlock_destroy((A))
|
||||
|
||||
extern int my_rwlock_init(my_rw_lock_t *, void *);
|
||||
extern int my_rwlock_destroy(my_rw_lock_t *);
|
||||
extern int my_rw_rdlock(my_rw_lock_t *);
|
||||
extern int my_rw_wrlock(my_rw_lock_t *);
|
||||
extern int my_rw_unlock(my_rw_lock_t *);
|
||||
extern int my_rw_tryrdlock(my_rw_lock_t *);
|
||||
extern int my_rw_trywrlock(my_rw_lock_t *);
|
||||
#endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */
|
||||
|
||||
#define GETHOSTBYADDR_BUFF_SIZE 2048
|
||||
|
||||
#ifndef HAVE_THR_SETCONCURRENCY
|
||||
#define thr_setconcurrency(A) pthread_dummy(0)
|
||||
#endif
|
||||
#if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize)
|
||||
#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
|
||||
#endif
|
||||
|
||||
/* Define mutex types */
|
||||
#define MY_MUTEX_INIT_SLOW NULL
|
||||
#define MY_MUTEX_INIT_FAST NULL
|
||||
#define MY_MUTEX_INIT_ERRCHK NULL
|
||||
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
|
||||
extern pthread_mutexattr_t my_fast_mutexattr;
|
||||
#undef MY_MUTEX_INIT_FAST
|
||||
#define MY_MUTEX_INIT_FAST &my_fast_mutexattr
|
||||
#endif
|
||||
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
|
||||
extern pthread_mutexattr_t my_errchk_mutexattr;
|
||||
#undef MY_INIT_MUTEX_ERRCHK
|
||||
#define MY_INIT_MUTEX_ERRCHK &my_errchk_mutexattr
|
||||
#endif
|
||||
|
||||
extern my_bool my_thread_global_init(void);
|
||||
extern void my_thread_global_end(void);
|
||||
extern my_bool my_thread_init(void);
|
||||
extern void my_thread_end(void);
|
||||
extern const char *my_thread_name(void);
|
||||
extern long my_thread_id(void);
|
||||
extern int pthread_no_free(void *);
|
||||
extern int pthread_dummy(int);
|
||||
|
||||
/* All thread specific variables are in the following struct */
|
||||
|
||||
#define THREAD_NAME_SIZE 10
|
||||
#if defined(__ia64__)
|
||||
#define DEFAULT_THREAD_STACK (128*1024)
|
||||
#else
|
||||
#define DEFAULT_THREAD_STACK (64*1024)
|
||||
#endif
|
||||
|
||||
struct st_my_thread_var
|
||||
{
|
||||
int thr_errno;
|
||||
pthread_cond_t suspend;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_mutex_t * volatile current_mutex;
|
||||
pthread_cond_t * volatile current_cond;
|
||||
pthread_t pthread_self;
|
||||
long id;
|
||||
int cmp_length;
|
||||
int volatile abort;
|
||||
#ifndef DBUG_OFF
|
||||
gptr dbug;
|
||||
char name[THREAD_NAME_SIZE+1];
|
||||
#endif
|
||||
my_bool initialized;
|
||||
};
|
||||
|
||||
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
|
||||
extern void **my_thread_var_dbug();
|
||||
#define my_thread_var (_my_thread_var())
|
||||
#define my_errno my_thread_var->thr_errno
|
||||
|
||||
/* statistics_xxx functions are for not essential statistic */
|
||||
|
||||
#ifndef thread_safe_increment
|
||||
#ifdef HAVE_ATOMIC_ADD
|
||||
#define thread_safe_increment(V,L) atomic_add(1,(atomic_t*) &V);
|
||||
#define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V);
|
||||
#define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V);
|
||||
#define statistic_increment(V,L) thread_safe_increment((V),(L))
|
||||
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
|
||||
#else
|
||||
#define thread_safe_increment(V,L) \
|
||||
pthread_mutex_lock((L)); (V)++; pthread_mutex_unlock((L));
|
||||
#define thread_safe_add(V,C,L) \
|
||||
pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
|
||||
#define thread_safe_sub(V,C,L) \
|
||||
pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
|
||||
#ifdef SAFE_STATISTICS
|
||||
#define statistic_increment(V,L) thread_safe_increment((V),(L))
|
||||
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
|
||||
#else
|
||||
#define statistic_increment(V,L) (V)++
|
||||
#define statistic_add(V,C,L) (V)+=(C)
|
||||
#endif /* SAFE_STATISTICS */
|
||||
#endif /* HAVE_ATOMIC_ADD */
|
||||
#endif /* thread_safe_increment */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _my_ptread_h */
|
254
module/Vendor/MDBC/include/my_stmt.h
vendored
Normal file
254
module/Vendor/MDBC/include/my_stmt.h
vendored
Normal file
@ -0,0 +1,254 @@
|
||||
/************************************************************************
|
||||
|
||||
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 SET_CLIENT_STMT_ERROR(a, b, c, d) \
|
||||
{ \
|
||||
(a)->last_errno= (b);\
|
||||
strncpy((a)->sqlstate, (c), sizeof((a)->sqlstate));\
|
||||
strncpy((a)->last_error, (d) ? (d) : ER((b)), sizeof((a)->last_error));\
|
||||
}
|
||||
|
||||
#define CLEAR_CLIENT_STMT_ERROR(a) \
|
||||
{ \
|
||||
(a)->last_errno= 0;\
|
||||
strcpy((a)->sqlstate, "00000");\
|
||||
(a)->last_error[0]= 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
|
||||
};
|
||||
|
||||
enum enum_cursor_type
|
||||
{
|
||||
CURSOR_TYPE_NO_CURSOR= 0,
|
||||
CURSOR_TYPE_READ_ONLY= 1,
|
||||
CURSOR_TYPE_FOR_UPDATE= 2,
|
||||
CURSOR_TYPE_SCROLLABLE= 4
|
||||
};
|
||||
|
||||
typedef enum mysql_stmt_state
|
||||
{
|
||||
MYSQL_STMT_INITTED = 0,
|
||||
MYSQL_STMT_PREPARED,
|
||||
MYSQL_STMT_EXECUTED,
|
||||
// MYSQL_STMT_USE_RESULT,
|
||||
// MYSQL_STMT_STORE_RESULT,
|
||||
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;
|
||||
unsigned char *row_ptr; /* for the current data position */
|
||||
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;
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong 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, unsigned int 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, my_ulonglong 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, unsigned long length);
|
||||
MYSQL_RES *(*get_parameter_metadata)(const MYSQL_STMT * stmt);
|
||||
MYSQL_RES *(*get_result_metadata)(const MYSQL_STMT * stmt);
|
||||
my_ulonglong (*get_last_insert_id)(const MYSQL_STMT * stmt);
|
||||
my_ulonglong (*get_affected_rows)(const MYSQL_STMT * stmt);
|
||||
my_ulonglong (*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);
|
||||
};
|
||||
|
||||
typedef int (*mysql_stmt_fetch_row_func)(MYSQL_STMT *stmt, unsigned char **row);
|
||||
|
||||
struct st_mysql_stmt
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
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 net_safe_read(MYSQL *mysql);
|
||||
void mysql_init_ps_subsystem(void);
|
||||
unsigned long net_field_length(unsigned char **packet);
|
||||
int 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, 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);
|
||||
int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt);
|
||||
my_bool STDCALL mysql_stmt_more_results(MYSQL_STMT *stmt);
|
619
module/Vendor/MDBC/include/my_sys.h
vendored
Normal file
619
module/Vendor/MDBC/include/my_sys.h
vendored
Normal file
@ -0,0 +1,619 @@
|
||||
/* 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 _my_sys_h
|
||||
#define _my_sys_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AIOWAIT
|
||||
#include <sys/asynch.h> /* Used by record-cache */
|
||||
typedef struct my_aio_result {
|
||||
aio_result_t result;
|
||||
int pending;
|
||||
} my_aio_result;
|
||||
#endif
|
||||
|
||||
#ifndef THREAD
|
||||
extern int NEAR my_errno; /* Last error in mysys */
|
||||
#else
|
||||
#include <my_pthread.h>
|
||||
#endif
|
||||
|
||||
#ifndef _m_ctype_h
|
||||
#include <m_ctype.h> /* for CHARSET_INFO */
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; }
|
||||
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
|
||||
#define MY_INIT(name); { my_progname= name; my_init(); }
|
||||
|
||||
#define MAXMAPS (4) /* Number of error message maps */
|
||||
#define ERRMOD (1000) /* Max number of errors in a map */
|
||||
#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */
|
||||
#define NRERRBUFFS (2) /* Buffers for parameters */
|
||||
#define MY_FILE_ERROR ((uint) ~0)
|
||||
|
||||
/* General bitmaps for my_func's */
|
||||
#define MY_FFNF 1 /* Fatal if file not found */
|
||||
#define MY_FNABP 2 /* Fatal if not all bytes read/writen */
|
||||
#define MY_NABP 4 /* Error if not all bytes read/writen */
|
||||
#define MY_FAE 8 /* Fatal if any error */
|
||||
#define MY_WME 16 /* Write message on error */
|
||||
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
|
||||
#define MY_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
|
||||
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
|
||||
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
|
||||
#define MY_COPYTIME 64 /* my_redel() copys time */
|
||||
#define MY_DELETE_OLD 256 /* my_create_with_symlink() */
|
||||
#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
|
||||
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
|
||||
#define MY_REDEL_MAKE_BACKUP 256
|
||||
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
|
||||
#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */
|
||||
#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */
|
||||
#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */
|
||||
#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */
|
||||
#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */
|
||||
#define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */
|
||||
#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy; Don't overwrite file */
|
||||
|
||||
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
|
||||
#define MY_GIVE_INFO 2 /* Give time info about process*/
|
||||
|
||||
#define ME_HIGHBYTE 8 /* Shift for colours */
|
||||
#define ME_NOCUR 1 /* Don't use curses message */
|
||||
#define ME_OLDWIN 2 /* Use old window */
|
||||
#define ME_BELL 4 /* Ring bell then printing message */
|
||||
#define ME_HOLDTANG 8 /* Don't delete last keys */
|
||||
#define ME_WAITTOT 16 /* Wait for errtime secs of for a action */
|
||||
#define ME_WAITTANG 32 /* Wait for a user action */
|
||||
#define ME_NOREFRESH 64 /* Dont refresh screen */
|
||||
#define ME_NOINPUT 128 /* Dont use the input libary */
|
||||
#define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */
|
||||
#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
|
||||
#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
|
||||
|
||||
/* My seek flags */
|
||||
#define MY_SEEK_SET 0
|
||||
#define MY_SEEK_CUR 1
|
||||
#define MY_SEEK_END 2
|
||||
|
||||
/* My charsets_list flags */
|
||||
#define MY_NO_SETS 0
|
||||
#define MY_COMPILED_SETS 1 /* show compiled-in sets */
|
||||
#define MY_CONFIG_SETS 2 /* sets that have a *.conf file */
|
||||
#define MY_INDEX_SETS 4 /* all sets listed in the Index file */
|
||||
#define MY_LOADED_SETS 8 /* the sets that are currently loaded */
|
||||
|
||||
/* Some constants */
|
||||
#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */
|
||||
#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */
|
||||
#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */
|
||||
#define KEYCACHE_BLOCK_SIZE 1024
|
||||
|
||||
/* root_alloc flags */
|
||||
#define MY_KEEP_PREALLOC 1
|
||||
|
||||
/* defines when allocating data */
|
||||
|
||||
#define my_checkmalloc() (0)
|
||||
#undef TERMINATE
|
||||
#define TERMINATE(A) {}
|
||||
#define QUICK_SAFEMALLOC
|
||||
#define NORMAL_SAFEMALLOC
|
||||
extern gptr my_malloc(size_t Size,myf MyFlags);
|
||||
#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
|
||||
extern gptr my_realloc(gptr oldpoint, size_t Size,myf MyFlags);
|
||||
extern void my_no_flags_free(void *ptr);
|
||||
extern gptr my_memdup(const unsigned char *from, size_t length,myf MyFlags);
|
||||
extern my_string my_strdup(const char *from,myf MyFlags);
|
||||
extern my_string my_strndup(const char *from, size_t length, myf MyFlags);
|
||||
#define my_free(PTR) my_no_flags_free(PTR)
|
||||
#define CALLER_INFO_PROTO /* nothing */
|
||||
#define CALLER_INFO /* nothing */
|
||||
#define ORIG_CALLER_INFO /* nothing */
|
||||
|
||||
#ifdef HAVE_ALLOCA
|
||||
#if defined(_AIX) && !defined(__GNUC__)
|
||||
#pragma alloca
|
||||
#endif /* _AIX */
|
||||
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H)
|
||||
#ifndef alloca
|
||||
#define alloca __builtin_alloca
|
||||
#endif
|
||||
#endif /* GNUC */
|
||||
#define my_alloca(SZ) alloca((size_t) (SZ))
|
||||
#define my_afree(PTR) {}
|
||||
#else
|
||||
#define my_alloca(SZ) my_malloc(SZ,MYF(0))
|
||||
#define my_afree(PTR) my_free(PTR)
|
||||
#endif /* HAVE_ALLOCA */
|
||||
|
||||
#ifdef MSDOS
|
||||
#ifdef __ZTC__
|
||||
void * __CDECL halloc(long count,size_t length);
|
||||
void __CDECL hfree(void *ptr);
|
||||
#endif
|
||||
#if defined(USE_HALLOC)
|
||||
#if defined(_VCM_) || defined(M_IC80386)
|
||||
#undef USE_HALLOC
|
||||
#endif
|
||||
#endif
|
||||
#ifdef USE_HALLOC
|
||||
#define malloc(a) halloc((long) (a),1)
|
||||
#define free(a) hfree(a)
|
||||
#endif
|
||||
#endif /* MSDOS */
|
||||
|
||||
#ifndef errno
|
||||
#ifdef HAVE_ERRNO_AS_DEFINE
|
||||
#include <errno.h> /* errno is a define */
|
||||
#else
|
||||
extern int errno; /* declare errno */
|
||||
#endif
|
||||
#endif
|
||||
extern const char ** NEAR my_errmsg[];
|
||||
extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
|
||||
extern char *home_dir; /* Home directory for user */
|
||||
extern char *my_progname; /* program-name (printed in errors) */
|
||||
extern char NEAR curr_dir[]; /* Current directory for user */
|
||||
extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
|
||||
extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
|
||||
myf MyFlags);
|
||||
|
||||
/* charsets */
|
||||
extern uint get_charset_number(const char *cs_name);
|
||||
extern const char *get_charset_name(uint cs_number);
|
||||
extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
|
||||
extern my_bool set_default_charset(uint cs, myf flags);
|
||||
extern CHARSET_INFO *get_charset_by_name(const char *cs_name);
|
||||
extern CHARSET_INFO *get_charset_by_nr(uint cs_number);
|
||||
extern my_bool set_default_charset_by_name(const char *cs_name, myf flags);
|
||||
extern void free_charsets(void);
|
||||
extern char *list_charsets(myf want_flags); /* my_free() this string... */
|
||||
extern char *get_charsets_dir(char *buf);
|
||||
|
||||
|
||||
/* statistics */
|
||||
extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
|
||||
_my_cache_read;
|
||||
extern ulong _my_blocks_used,_my_blocks_changed;
|
||||
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
|
||||
extern my_bool key_cache_inited;
|
||||
|
||||
/* Point to current my_message() */
|
||||
extern void (*my_sigtstp_cleanup)(void),
|
||||
/* Executed before jump to shell */
|
||||
(*my_sigtstp_restart)(void),
|
||||
(*my_abort_hook)(int);
|
||||
/* Executed when comming from shell */
|
||||
extern int NEAR my_umask, /* Default creation mask */
|
||||
NEAR my_umask_dir,
|
||||
NEAR my_recived_signals, /* Signals we have got */
|
||||
NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
|
||||
NEAR my_dont_interrupt; /* call remember_intr when set */
|
||||
extern my_bool NEAR mysys_uses_curses, my_use_symdir;
|
||||
extern size_t lCurMemory,lMaxMemory; /* from safemalloc */
|
||||
|
||||
extern ulong my_default_record_cache_size;
|
||||
extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
|
||||
NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks;
|
||||
extern char wild_many,wild_one,wild_prefix;
|
||||
extern const char *charsets_dir;
|
||||
extern char *defaults_extra_file;
|
||||
|
||||
typedef struct wild_file_pack /* Struct to hold info when selecting files */
|
||||
{
|
||||
uint wilds; /* How many wildcards */
|
||||
uint not_pos; /* Start of not-theese-files */
|
||||
my_string *wild; /* Pointer to wildcards */
|
||||
} WF_PACK;
|
||||
|
||||
struct my_rnd_struct {
|
||||
unsigned long seed1,seed2,max_value;
|
||||
double max_value_dbl;
|
||||
};
|
||||
|
||||
typedef struct st_typelib { /* Different types saved here */
|
||||
uint count; /* How many types */
|
||||
const char *name; /* Name of typelib */
|
||||
const char **type_names;
|
||||
} TYPELIB;
|
||||
|
||||
enum cache_type {READ_CACHE,WRITE_CACHE,READ_FIFO,READ_NET,WRITE_NET};
|
||||
enum flush_type { FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED,
|
||||
FLUSH_FORCE_WRITE};
|
||||
|
||||
typedef struct st_record_cache /* Used when cacheing records */
|
||||
{
|
||||
File file;
|
||||
int rc_seek,error,inited;
|
||||
uint rc_length,read_length,reclength;
|
||||
my_off_t rc_record_pos,end_of_file;
|
||||
unsigned char *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
|
||||
#ifdef HAVE_AIOWAIT
|
||||
int use_async_io;
|
||||
my_aio_result aio_result;
|
||||
#endif
|
||||
enum cache_type type;
|
||||
} RECORD_CACHE;
|
||||
|
||||
enum file_type { UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE,
|
||||
STREAM_BY_FOPEN, STREAM_BY_FDOPEN, FILE_BY_MKSTEMP };
|
||||
|
||||
extern struct my_file_info
|
||||
{
|
||||
my_string name;
|
||||
enum file_type type;
|
||||
#if defined(THREAD) && !defined(HAVE_PREAD)
|
||||
pthread_mutex_t mutex;
|
||||
#endif
|
||||
} my_file_info[MY_NFILE];
|
||||
|
||||
|
||||
typedef struct st_dynamic_array {
|
||||
char *buffer;
|
||||
uint elements,max_element;
|
||||
uint alloc_increment;
|
||||
uint size_of_element;
|
||||
} DYNAMIC_ARRAY;
|
||||
|
||||
typedef struct st_dynamic_string {
|
||||
char *str;
|
||||
size_t length,max_length,alloc_increment;
|
||||
} DYNAMIC_STRING;
|
||||
|
||||
|
||||
typedef struct st_io_cache /* Used when cacheing files */
|
||||
{
|
||||
my_off_t pos_in_file,end_of_file;
|
||||
unsigned char *rc_pos,*rc_end,*buffer,*rc_request_pos;
|
||||
int (*read_function)(struct st_io_cache *,unsigned char *,uint);
|
||||
char *file_name; /* if used with 'open_cached_file' */
|
||||
char *dir,*prefix;
|
||||
File file;
|
||||
int seek_not_done,error;
|
||||
uint buffer_length,read_length;
|
||||
myf myflags; /* Flags used to my_read/my_write */
|
||||
enum cache_type type;
|
||||
#ifdef HAVE_AIOWAIT
|
||||
uint inited;
|
||||
my_off_t aio_read_pos;
|
||||
my_aio_result aio_result;
|
||||
#endif
|
||||
} IO_CACHE;
|
||||
|
||||
typedef int (*qsort2_cmp)(const void *, const void *, const void *);
|
||||
|
||||
/* defines for mf_iocache */
|
||||
|
||||
/* Test if buffer is inited */
|
||||
#define my_b_clear(info) (info)->buffer=0
|
||||
#define my_b_inited(info) (info)->buffer
|
||||
#define my_b_EOF INT_MIN
|
||||
|
||||
#define my_b_read(info,Buffer,Count) \
|
||||
((info)->rc_pos + (Count) <= (info)->rc_end ?\
|
||||
(memcpy(Buffer,(info)->rc_pos,(size_t) (Count)), \
|
||||
((info)->rc_pos+=(Count)),0) :\
|
||||
(*(info)->read_function)((info),Buffer,Count))
|
||||
|
||||
#define my_b_get(info) \
|
||||
((info)->rc_pos != (info)->rc_end ?\
|
||||
((info)->rc_pos++, (int) (uchar) (info)->rc_pos[-1]) :\
|
||||
_my_b_get(info))
|
||||
|
||||
#define my_b_write(info,Buffer,Count) \
|
||||
((info)->rc_pos + (Count) <= (info)->rc_end ?\
|
||||
(memcpy((info)->rc_pos,Buffer,(size_t) (Count)), \
|
||||
((info)->rc_pos+=(Count)),0) :\
|
||||
_my_b_write(info,Buffer,Count))
|
||||
|
||||
/* my_b_write_byte dosn't have any err-check */
|
||||
#define my_b_write_byte(info,chr) \
|
||||
(((info)->rc_pos < (info)->rc_end) ?\
|
||||
((*(info)->rc_pos++)=(chr)) :\
|
||||
(_my_b_write(info,0,0) , ((*(info)->rc_pos++)=(chr))))
|
||||
|
||||
#define my_b_fill_cache(info) \
|
||||
(((info)->rc_end=(info)->rc_pos),(*(info)->read_function)(info,0,0))
|
||||
|
||||
#define my_b_tell(info) ((info)->pos_in_file + \
|
||||
((info)->rc_pos - (info)->rc_request_pos))
|
||||
|
||||
#define my_b_bytes_in_cache(info) ((uint) ((info)->rc_end - (info)->rc_pos))
|
||||
|
||||
typedef struct st_changeable_var {
|
||||
const char *name; /* Name of variable */
|
||||
long *varptr; /* Pointer to variable */
|
||||
long def_value, /* Default value */
|
||||
min_value, /* Min allowed value */
|
||||
max_value, /* Max allowed value */
|
||||
sub_size, /* Subtract this from given value */
|
||||
block_size; /* Value should be a mult. of this */
|
||||
} CHANGEABLE_VAR;
|
||||
|
||||
|
||||
/* structs for alloc_root */
|
||||
|
||||
#ifndef ST_USED_MEM_DEFINED
|
||||
#define ST_USED_MEM_DEFINED
|
||||
typedef struct st_used_mem { /* struct for once_alloc */
|
||||
struct st_used_mem *next; /* Next block in use */
|
||||
size_t left; /* memory left in block */
|
||||
size_t size; /* Size of block */
|
||||
} USED_MEM;
|
||||
|
||||
typedef struct st_mem_root {
|
||||
USED_MEM *free;
|
||||
USED_MEM *used;
|
||||
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);
|
||||
} MEM_ROOT;
|
||||
#endif
|
||||
|
||||
/* Prototypes for mysys and my_func functions */
|
||||
|
||||
extern int my_copy(const char *from,const char *to,myf MyFlags);
|
||||
extern int my_append(const char *from,const char *to,myf MyFlags);
|
||||
extern int my_delete(const char *name,myf MyFlags);
|
||||
extern int my_getwd(my_string buf,uint size,myf MyFlags);
|
||||
extern int my_setwd(const char *dir,myf MyFlags);
|
||||
extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
|
||||
extern gptr my_once_alloc(uint Size,myf MyFlags);
|
||||
extern void my_once_free(void);
|
||||
extern my_string my_tempnam(const char *dir,const char *pfx,myf MyFlags);
|
||||
extern File my_open(const char *FileName,int Flags,myf MyFlags);
|
||||
extern File my_register_filename(File fd, const char *FileName,
|
||||
enum file_type type_of_file,
|
||||
uint error_message_number, myf MyFlags);
|
||||
extern File my_create(const char *FileName,int CreateFlags,
|
||||
int AccsesFlags, myf MyFlags);
|
||||
extern int my_close(File Filedes,myf MyFlags);
|
||||
extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
|
||||
extern int my_readlink(char *to, const char *filename, myf MyFlags);
|
||||
extern int my_realpath(char *to, const char *filename, myf MyFlags);
|
||||
extern File my_create_with_symlink(const char *linkname, const char *filename,
|
||||
int createflags, int access_flags,
|
||||
myf MyFlags);
|
||||
extern int my_delete_with_symlink(const char *name, myf MyFlags);
|
||||
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
|
||||
extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
|
||||
extern uint my_read(File Filedes,unsigned char *Buffer,uint Count,myf MyFlags);
|
||||
extern uint my_pread(File Filedes,unsigned char *Buffer,uint Count,my_off_t offset,
|
||||
myf MyFlags);
|
||||
extern int my_rename(const char *from,const char *to,myf MyFlags);
|
||||
extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
|
||||
extern my_off_t my_tell(File fd,myf MyFlags);
|
||||
extern uint my_write(File Filedes,const unsigned char *Buffer,uint Count,
|
||||
myf MyFlags);
|
||||
extern uint my_pwrite(File Filedes,const unsigned char *Buffer,uint Count,
|
||||
my_off_t offset,myf MyFlags);
|
||||
extern uint my_fread(FILE *stream,unsigned char *Buffer,uint Count,myf MyFlags);
|
||||
extern uint my_fwrite(FILE *stream,const unsigned char *Buffer,uint Count,
|
||||
myf MyFlags);
|
||||
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
|
||||
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
|
||||
extern gptr _mymalloc(size_t uSize,const char *sFile,
|
||||
uint uLine, myf MyFlag);
|
||||
extern gptr _myrealloc(gptr pPtr,size_t uSize,const char *sFile,
|
||||
uint uLine, myf MyFlag);
|
||||
extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
|
||||
extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
|
||||
extern int _sanity(const char *sFile,unsigned int uLine);
|
||||
extern gptr _my_memdup(const unsigned char *from, size_t length,
|
||||
const char *sFile, uint uLine,myf MyFlag);
|
||||
extern my_string _my_strdup(const char *from, const char *sFile, uint uLine,
|
||||
myf MyFlag);
|
||||
#ifndef TERMINATE
|
||||
extern void TERMINATE(FILE *file);
|
||||
#endif
|
||||
extern void init_glob_errs(void);
|
||||
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
|
||||
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
|
||||
extern int my_fclose(FILE *fd,myf MyFlags);
|
||||
extern int my_chsize(File fd,my_off_t newlength,myf MyFlags);
|
||||
extern int my_error _VARARGS((int nr,myf MyFlags, ...));
|
||||
extern int my_printf_error _VARARGS((uint my_err, const char *format,
|
||||
myf MyFlags, ...)
|
||||
__attribute__ ((format (printf, 2, 4))));
|
||||
extern int my_vsnprintf( char *str, size_t n,
|
||||
const char *format, va_list ap );
|
||||
extern int my_snprintf(char* to, size_t n, const char* fmt, ...);
|
||||
extern int my_message(uint my_err, const char *str,myf MyFlags);
|
||||
extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
|
||||
extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
|
||||
extern void my_init(void);
|
||||
extern void my_end(int infoflag);
|
||||
extern int my_redel(const char *from, const char *to, int MyFlags);
|
||||
extern int my_copystat(const char *from, const char *to, int MyFlags);
|
||||
extern my_string my_filename(File fd);
|
||||
|
||||
#ifndef THREAD
|
||||
extern void dont_break(void);
|
||||
extern void allow_break(void);
|
||||
#else
|
||||
#define dont_break()
|
||||
#define allow_break()
|
||||
#endif
|
||||
|
||||
extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
|
||||
extern void caseup(my_string str,uint length);
|
||||
extern void casedn(my_string str,uint length);
|
||||
extern void caseup_str(my_string str);
|
||||
extern void casedn_str(my_string str);
|
||||
extern void case_sort(my_string str,uint length);
|
||||
extern uint dirname_part(my_string to,const char *name);
|
||||
extern uint dirname_length(const char *name);
|
||||
#define base_name(A) (A+dirname_length(A))
|
||||
extern int test_if_hard_path(const char *dir_name);
|
||||
extern char *convert_dirname(my_string name);
|
||||
extern void to_unix_path(my_string name);
|
||||
extern my_string fn_ext(const char *name);
|
||||
extern my_string fn_same(my_string toname,const char *name,int flag);
|
||||
extern my_string fn_format(my_string to,const char *name,const char *dsk,
|
||||
const char *form,int flag);
|
||||
extern size_s strlength(const char *str);
|
||||
extern void pack_dirname(my_string to,const char *from);
|
||||
extern uint unpack_dirname(my_string to,const char *from);
|
||||
extern uint cleanup_dirname(my_string to,const char *from);
|
||||
extern uint system_filename(my_string to,const char *from);
|
||||
extern my_string unpack_filename(my_string to,const char *from);
|
||||
extern my_string intern_filename(my_string to,const char *from);
|
||||
extern my_string directory_file_name(my_string dst, const char *src);
|
||||
extern int pack_filename(my_string to, const char *name, size_s max_length);
|
||||
extern my_string my_path(my_string to,const char *progname,
|
||||
const char *own_pathname_part);
|
||||
extern my_string my_load_path(my_string to, const char *path,
|
||||
const char *own_path_prefix);
|
||||
extern int wild_compare(const char *str,const char *wildstr);
|
||||
extern my_string my_strcasestr(const char *src,const char *suffix);
|
||||
extern int my_strcasecmp(const char *s,const char *t);
|
||||
extern int my_strsortcmp(const char *s,const char *t);
|
||||
extern int my_casecmp(const char *s,const char *t,uint length);
|
||||
extern int my_sortcmp(const char *s,const char *t,uint length);
|
||||
extern int my_sortncmp(const char *s,uint s_len, const char *t,uint t_len);
|
||||
extern WF_PACK *wf_comp(my_string str);
|
||||
extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
|
||||
extern void wf_end(struct wild_file_pack *buffer);
|
||||
extern size_s strip_sp(my_string str);
|
||||
extern void get_date(my_string to,int timeflag,time_t use_time);
|
||||
extern void soundex(my_string out_pntr, my_string in_pntr,pbool remove_garbage);
|
||||
extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
|
||||
uint reclength,enum cache_type type,
|
||||
pbool use_async_io);
|
||||
extern int read_cache_record(RECORD_CACHE *info,unsigned char *to);
|
||||
extern int end_record_cache(RECORD_CACHE *info);
|
||||
extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
|
||||
const unsigned char *record,uint length);
|
||||
extern int flush_write_cache(RECORD_CACHE *info);
|
||||
extern long my_clock(void);
|
||||
extern sig_handler sigtstp_handler(int signal_number);
|
||||
extern void handle_recived_signals(void);
|
||||
extern int init_key_cache(ulong use_mem,ulong leave_this_much_mem);
|
||||
extern unsigned char *key_cache_read(File file,my_off_t filepos,unsigned char* buff,uint length,
|
||||
uint block_length,int return_buffer);
|
||||
extern int key_cache_write(File file,my_off_t filepos,unsigned char* buff,uint length,
|
||||
uint block_length,int force_write);
|
||||
extern int flush_key_blocks(int file, enum flush_type type);
|
||||
extern void end_key_cache(void);
|
||||
extern sig_handler my_set_alarm_variable(int signo);
|
||||
extern void my_string_ptr_sort(void *base,uint items,size_s size);
|
||||
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
|
||||
size_s size_of_element,uchar *buffer[]);
|
||||
extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
|
||||
qsort2_cmp cmp, void *cmp_argument);
|
||||
extern qsort2_cmp get_ptr_compare(uint);
|
||||
extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
|
||||
enum cache_type type,my_off_t seek_offset,
|
||||
pbool use_async_io, myf cache_myflags);
|
||||
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
|
||||
my_off_t seek_offset,pbool use_async_io,
|
||||
pbool clear_cache);
|
||||
extern int _my_b_read(IO_CACHE *info,unsigned char *Buffer,uint Count);
|
||||
extern int _my_b_net_read(IO_CACHE *info,unsigned char *Buffer,uint Count);
|
||||
extern int _my_b_get(IO_CACHE *info);
|
||||
extern int _my_b_async_read(IO_CACHE *info,unsigned char *Buffer,uint Count);
|
||||
extern int _my_b_write(IO_CACHE *info,const unsigned char *Buffer,uint Count);
|
||||
extern int my_block_write(IO_CACHE *info, const unsigned char *Buffer,
|
||||
uint Count, my_off_t pos);
|
||||
extern int flush_io_cache(IO_CACHE *info);
|
||||
extern int end_io_cache(IO_CACHE *info);
|
||||
extern uint my_b_fill(IO_CACHE *info);
|
||||
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
|
||||
extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
|
||||
extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
|
||||
extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
|
||||
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
|
||||
const char *prefix, uint cache_size,
|
||||
myf cache_myflags);
|
||||
extern my_bool real_open_cached_file(IO_CACHE *cache);
|
||||
extern void close_cached_file(IO_CACHE *cache);
|
||||
File create_temp_file(char *to, const char *dir, const char *pfx,
|
||||
int mode, myf MyFlags);
|
||||
#define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO)
|
||||
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO)
|
||||
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
|
||||
uint init_alloc,uint alloc_increment CALLER_INFO_PROTO);
|
||||
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element);
|
||||
extern unsigned char *alloc_dynamic(DYNAMIC_ARRAY *array);
|
||||
extern unsigned char *pop_dynamic(DYNAMIC_ARRAY*);
|
||||
extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
|
||||
extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
|
||||
extern void delete_dynamic(DYNAMIC_ARRAY *array);
|
||||
extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
|
||||
extern void freeze_size(DYNAMIC_ARRAY *array);
|
||||
#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
|
||||
#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
|
||||
#define push_dynamic(A,B) insert_dynamic(A,B)
|
||||
|
||||
extern int find_type(my_string x,TYPELIB *typelib,uint full_name);
|
||||
extern void make_type(my_string to,uint nr,TYPELIB *typelib);
|
||||
extern const char *get_type(TYPELIB *typelib,uint nr);
|
||||
extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
|
||||
size_t init_alloc, size_t alloc_increment);
|
||||
extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
|
||||
my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
|
||||
size_t length);
|
||||
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
|
||||
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size);
|
||||
extern void dynstr_free(DYNAMIC_STRING *str);
|
||||
void set_all_changeable_vars(CHANGEABLE_VAR *vars);
|
||||
my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars);
|
||||
my_bool set_changeable_varval(const char *var, ulong val,
|
||||
CHANGEABLE_VAR *vars);
|
||||
#ifdef HAVE_MLOCK
|
||||
extern unsigned char *my_malloc_lock(size_t length,myf flags);
|
||||
extern void my_free_lock(unsigned char *ptr,myf flags);
|
||||
#else
|
||||
#define my_malloc_lock(A,B) my_malloc((A),(B))
|
||||
#define my_free_lock(A,B) my_free((A),(B))
|
||||
#endif
|
||||
#define alloc_root_inited(A) ((A)->min_malloc != 0)
|
||||
void init_alloc_root(MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size);
|
||||
gptr alloc_root(MEM_ROOT *mem_root, size_t Size);
|
||||
void free_root(MEM_ROOT *root, myf MyFLAGS);
|
||||
char *strdup_root(MEM_ROOT *root,const char *str);
|
||||
char *memdup_root(MEM_ROOT *root,const char *str, size_t len);
|
||||
void load_defaults(const char *conf_file, const char **groups,
|
||||
int *argc, char ***argv);
|
||||
void free_defaults(char **argv);
|
||||
void print_defaults(const char *conf_file, const char **groups);
|
||||
my_bool my_compress(unsigned char *, size_t *, size_t *);
|
||||
my_bool my_uncompress(unsigned char *, size_t *, size_t *);
|
||||
unsigned char *my_compress_alloc(const unsigned char *packet, size_t *len, size_t *complen);
|
||||
ulong checksum(const unsigned char *mem, uint count);
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_WIN32)
|
||||
extern void sleep(int sec);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
extern my_bool have_tcpip; /* Is set if tcpip is used */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _my_sys_h */
|
648
module/Vendor/MDBC/include/mysql.h
vendored
Normal file
648
module/Vendor/MDBC/include/mysql.h
vendored
Normal file
@ -0,0 +1,648 @@
|
||||
/* 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
|
||||
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 */
|
||||
|
||||
/* defines for the libmariadb library */
|
||||
|
||||
#ifndef _mysql_h
|
||||
#define _mysql_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef LIBMARIADB
|
||||
#define LIBMARIADB
|
||||
#endif
|
||||
|
||||
#ifndef _global_h /* If not standard header */
|
||||
#include <sys/types.h>
|
||||
typedef char my_bool;
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#define STDCALL
|
||||
#else
|
||||
#define STDCALL __stdcall
|
||||
#endif
|
||||
typedef char * gptr;
|
||||
|
||||
|
||||
|
||||
#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 "mysql_com.h"
|
||||
#include "mysql_version.h"
|
||||
#include "my_list.h"
|
||||
#include "m_ctype.h"
|
||||
|
||||
#ifndef ST_USED_MEM_DEFINED
|
||||
#define ST_USED_MEM_DEFINED
|
||||
typedef struct st_used_mem { /* struct for once_alloc */
|
||||
struct st_used_mem *next; /* Next block in use */
|
||||
size_t left; /* memory left in block */
|
||||
size_t size; /* Size of block */
|
||||
} USED_MEM;
|
||||
|
||||
typedef struct st_mem_root {
|
||||
USED_MEM *free;
|
||||
USED_MEM *used;
|
||||
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);
|
||||
} 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) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR)
|
||||
#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 */
|
||||
|
||||
#if defined(NO_CLIENT_LONG_LONG)
|
||||
typedef unsigned long my_ulonglong;
|
||||
#elif defined (_WIN32)
|
||||
typedef unsigned __int64 my_ulonglong;
|
||||
#else
|
||||
typedef unsigned long long my_ulonglong;
|
||||
#endif
|
||||
|
||||
/* mysql compatibility macro */
|
||||
#define mysql_options4(A,B,C,D) mysql_optionsv((A),(B),(C),(D))
|
||||
|
||||
#define SET_CLIENT_ERROR(a, b, c, d) \
|
||||
{ \
|
||||
(a)->net.last_errno= (b);\
|
||||
strncpy((a)->net.sqlstate, (c), sizeof((a)->net.sqlstate));\
|
||||
strncpy((a)->net.last_error, (d) ? (d) : ER((b)), sizeof((a)->net.last_error));\
|
||||
}
|
||||
|
||||
/* For mysql_async.c */
|
||||
#define set_mysql_error(A,B,C) SET_CLIENT_ERROR((A),(B),(C),0)
|
||||
#define unknown_sqlstate SQLSTATE_UNKNOWN
|
||||
|
||||
#define CLEAR_CLIENT_ERROR(a) \
|
||||
{ \
|
||||
(a)->net.last_errno= 0;\
|
||||
strcpy((a)->net.sqlstate, "00000");\
|
||||
(a)->net.last_error[0]= '\0';\
|
||||
}
|
||||
|
||||
#define MYSQL_COUNT_ERROR (~(my_ulonglong) 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 {
|
||||
my_ulonglong rows;
|
||||
unsigned int fields;
|
||||
MYSQL_ROWS *data;
|
||||
MEM_ROOT alloc;
|
||||
} 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,
|
||||
|
||||
/* MariaDB specific */
|
||||
MYSQL_PROGRESS_CALLBACK=5999,
|
||||
MYSQL_OPT_NONBLOCK,
|
||||
/* MariaDB Connector/C specific */
|
||||
MYSQL_DATABASE_DRIVER=7000,
|
||||
MARIADB_OPT_SSL_FP, /* single finger print for server certificate verification */
|
||||
MARIADB_OPT_SSL_FP_LIST, /* finger print white list for server certificate verification */
|
||||
MARIADB_OPT_VERIFY_LOCAL_INFILE_CALLBACK
|
||||
};
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
enum mysql_protocol_type
|
||||
{
|
||||
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
|
||||
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
|
||||
};
|
||||
|
||||
struct st_mysql_options_extension;
|
||||
|
||||
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 unused_1, unused_2, unused_3, unused_4;
|
||||
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[2];
|
||||
struct st_mysql_options_extension *extension;
|
||||
};
|
||||
|
||||
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 charset_info_st *charset; /* character set */
|
||||
MYSQL_FIELD *fields;
|
||||
MEM_ROOT field_alloc;
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
|
||||
my_ulonglong 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,server_capabilities; /* changed from int to long in 4.1 protocol */
|
||||
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 reconnect; /* set to 1 if automatic reconnect */
|
||||
char scramble_buff[20+ 1];
|
||||
/* madded after 3.23.58 */
|
||||
my_bool unused_1;
|
||||
void *unused_2, *unused_3, *unused_4, *unused_5;
|
||||
LIST *stmts;
|
||||
const struct st_mysql_methods *methods;
|
||||
void *thd;
|
||||
my_bool *unbuffered_fetch_owner;
|
||||
char *info_buffer;
|
||||
void *extension;
|
||||
} MYSQL;
|
||||
|
||||
typedef struct st_mysql_res {
|
||||
my_ulonglong row_count;
|
||||
unsigned int field_count, current_field;
|
||||
MYSQL_FIELD *fields;
|
||||
MYSQL_DATA *data;
|
||||
MYSQL_ROWS *data_cursor;
|
||||
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 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 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 31
|
||||
#define SEC_PART_DIGITS 6
|
||||
#define MARIADB_INVALID_SOCKET -1
|
||||
|
||||
/* Ansynchronous 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; /* 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 */
|
||||
} MY_CHARSET_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long *p_max_allowed_packet;
|
||||
unsigned long *p_net_buffer_length;
|
||||
void *extension;
|
||||
} MYSQL_PARAMETERS;
|
||||
|
||||
#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length)
|
||||
#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet)
|
||||
|
||||
/* Local infile support functions */
|
||||
#define LOCAL_INFILE_ERROR_LEN 512
|
||||
|
||||
#include "my_stmt.h"
|
||||
|
||||
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 *);
|
||||
|
||||
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);
|
||||
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);
|
||||
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_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);
|
||||
|
||||
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);
|
||||
int STDCALL mysql_ssl_clear(MYSQL *mysql);
|
||||
MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
|
||||
const char *user, const char *passwd);
|
||||
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_create_db(MYSQL *mysql, const char *DB);
|
||||
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
|
||||
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,
|
||||
my_ulonglong 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);
|
||||
void STDCALL mysql_debug(const char *debug);
|
||||
#define mysql_debug_init(A) mysql_debug((A));
|
||||
void STDCALL mysql_debug_end(void);
|
||||
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
|
||||
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);
|
||||
CHARSET_INFO * STDCALL mysql_get_charset_by_name(const char *csname);
|
||||
CHARSET_INFO * STDCALL mysql_get_charset_by_nr(unsigned int csnr);
|
||||
size_t STDCALL mariadb_convert_string(const char *from, size_t *from_len, CHARSET_INFO *from_cs,
|
||||
char *to, size_t *to_len, CHARSET_INFO *to_cs, int *errorcode);
|
||||
int STDCALL mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...);
|
||||
MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void);
|
||||
unsigned long STDCALL mysql_hex_string(char *to, const char *from, unsigned long len);
|
||||
my_socket STDCALL mysql_get_socket(const MYSQL *mysql);
|
||||
unsigned int STDCALL mysql_get_timeout_value(const MYSQL *mysql);
|
||||
unsigned int STDCALL mysql_get_timeout_value_ms(const MYSQL *mysql);
|
||||
|
||||
/* 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_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_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_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_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_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);
|
||||
MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result);
|
||||
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_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);
|
||||
my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt);
|
||||
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);
|
||||
|
||||
|
||||
|
||||
/* these methods can be overwritten by db plugins */
|
||||
struct st_mysql_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);
|
||||
};
|
||||
|
||||
/* 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
|
||||
|
||||
/* new api functions */
|
||||
|
||||
#define HAVE_MYSQL_REAL_CONNECT
|
||||
|
||||
#ifndef MYSQL_SERVER
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
206
module/Vendor/MDBC/include/mysql/client_plugin.h
vendored
Normal file
206
module/Vendor/MDBC/include/mysql/client_plugin.h
vendored
Normal file
@ -0,0 +1,206 @@
|
||||
/* 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
|
||||
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 <http://www.gnu.org/licenses>
|
||||
or write to the Free Software Foundation, Inc.,
|
||||
51 Franklin St., Fifth Floor, Boston, MA 02110, USA */
|
||||
|
||||
/**
|
||||
@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
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef PLUGINDIR
|
||||
#define PLUGINDIR "lib/plugin"
|
||||
#endif
|
||||
|
||||
/* known plugin types */
|
||||
#define MYSQL_CLIENT_DB_PLUGIN 0
|
||||
#define MYSQL_CLIENT_reserved 1
|
||||
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN 2
|
||||
|
||||
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0100
|
||||
#define MYSQL_CLIENT_DB_PLUGIN_INTERFACE_VERSION 0x0100
|
||||
|
||||
#define MYSQL_CLIENT_MAX_PLUGINS 3
|
||||
|
||||
#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)(); \
|
||||
int (*options)(const char *option, const void *);
|
||||
|
||||
struct st_mysql_client_plugin
|
||||
{
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
};
|
||||
|
||||
struct st_mysql;
|
||||
|
||||
/********* database api plugin specific declarations **********/
|
||||
typedef struct st_mariadb_client_plugin_DB
|
||||
{
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
/* functions */
|
||||
struct st_mysql_methods *methods;
|
||||
/*
|
||||
MYSQL * (*db_connect)(MYSQL *mysql,const char *host, const char *user,
|
||||
const char *passwd, const char *db, uint port,
|
||||
const char *unix_socket,unsigned long client_flag);
|
||||
void (*db_close)(MYSQL *mysql);
|
||||
int (*db_query)(MYSQL *mysql, const char *query, size_t query_len);
|
||||
int (*db_read_one_row)(MYSQL *mysql, uint fields, MYSQL_ROW row,
|
||||
ulong *lengths);
|
||||
MYSQL_DATA *(*db_read_all_rows)(MYSQL *mysql,
|
||||
MYSQL_FIELD *mysql_fields, uint fields);
|
||||
void (*db_query_end)(MYSQL *mysql);
|
||||
int (*db_stmt_prepare)(MYSQL_STMT *stmt, const char *stmt_str, ulong length);
|
||||
my_bool (*db_stmt_close)(MYSQL_STMT *stmt);
|
||||
my_bool (*is_supported_buffer_type)(enum enum_field_types type);
|
||||
int (*db_stmt_fetch)(MYSQL_STMT *stmt);
|
||||
int (*db_stmt_execute)(MYSQL_STMT *stmt); */
|
||||
} MARIADB_DB_PLUGIN;
|
||||
|
||||
#define MARIADB_DB_DRIVER(a) ((a)->ext_db)
|
||||
|
||||
/******** authentication plugin specific declarations *********/
|
||||
#include <mysql/plugin_auth_common.h>
|
||||
|
||||
struct st_mysql_client_plugin_AUTHENTICATION
|
||||
{
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql);
|
||||
};
|
||||
|
||||
/**
|
||||
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);
|
||||
/******** using plugins ************/
|
||||
|
||||
/**
|
||||
loads a plugin and initializes it
|
||||
|
||||
@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
|
||||
function
|
||||
@param ... arguments for the plugin initialization function
|
||||
|
||||
@retval
|
||||
a pointer to the loaded plugin, or NULL in case of a failure
|
||||
*/
|
||||
struct st_mysql_client_plugin * STDCALL
|
||||
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
|
||||
|
||||
This is the same as mysql_load_plugin, but take va_list instead of
|
||||
a list of arguments.
|
||||
|
||||
@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
|
||||
function
|
||||
@param args arguments for the plugin initialization function
|
||||
|
||||
@retval
|
||||
a pointer to the loaded plugin, or NULL in case of a failure
|
||||
*/
|
||||
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. 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 * STDCALL
|
||||
mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type);
|
||||
|
||||
/**
|
||||
adds a plugin structure to the list of loaded plugins
|
||||
|
||||
This is useful if an application has the necessary functionality
|
||||
(for example, a special load data handler) statically linked into
|
||||
the application binary. It can use this function to register the plugin
|
||||
directly, avoiding the need to factor it out into a shared object.
|
||||
|
||||
@param mysql MYSQL structure. It is only used for error reporting
|
||||
@param plugin an st_mysql_client_plugin structure to register
|
||||
|
||||
@retval
|
||||
a pointer to the plugin, or NULL in case of a failure
|
||||
*/
|
||||
struct st_mysql_client_plugin * STDCALL
|
||||
mysql_client_register_plugin(struct st_mysql *mysql,
|
||||
struct st_mysql_client_plugin *plugin);
|
||||
|
||||
extern struct st_mysql_client_plugin *mysql_client_builtins[];
|
||||
|
||||
#endif
|
||||
|
||||
|
107
module/Vendor/MDBC/include/mysql/plugin_auth.h
vendored
Normal file
107
module/Vendor/MDBC/include/mysql/plugin_auth.h
vendored
Normal file
@ -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
|
||||
|
109
module/Vendor/MDBC/include/mysql/plugin_auth_common.h
vendored
Normal file
109
module/Vendor/MDBC/include/mysql/plugin_auth_common.h
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
/* 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 */
|
||||
|
||||
#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
|
||||
/**
|
||||
@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;
|
||||
#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
|
||||
} 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
|
||||
|
41
module/Vendor/MDBC/include/mysql_async.h
vendored
Normal file
41
module/Vendor/MDBC/include/mysql_async.h
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2012 MariaDB Services and Kristian Nielsen
|
||||
2015 MariaDB Corporation
|
||||
|
||||
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 */
|
||||
|
||||
/* Common definitions for MariaDB non-blocking client library. */
|
||||
|
||||
#ifndef MYSQL_ASYNC_H
|
||||
#define MYSQL_ASYNC_H
|
||||
|
||||
extern int my_connect_async(struct mysql_async_context *b, my_socket fd,
|
||||
const struct sockaddr *name, uint namelen,
|
||||
int vio_timeout);
|
||||
extern ssize_t my_recv_async(struct mysql_async_context *b, int fd,
|
||||
unsigned char *buf, size_t size, int timeout);
|
||||
extern ssize_t my_send_async(struct mysql_async_context *b, int fd,
|
||||
const unsigned char *buf, size_t size,
|
||||
int timeout);
|
||||
extern my_bool my_io_wait_async(struct mysql_async_context *b,
|
||||
enum enum_vio_io_event event, int timeout);
|
||||
#ifdef HAVE_OPENSSL
|
||||
extern int my_ssl_read_async(struct mysql_async_context *b, SSL *ssl,
|
||||
void *buf, int size);
|
||||
extern int my_ssl_write_async(struct mysql_async_context *b, SSL *ssl,
|
||||
const void *buf, int size);
|
||||
#endif
|
||||
|
||||
#endif /* MYSQL_ASYNC_H */
|
405
module/Vendor/MDBC/include/mysql_com.h
vendored
Normal file
405
module/Vendor/MDBC/include/mysql_com.h
vendored
Normal file
@ -0,0 +1,405 @@
|
||||
/************************************************************************************
|
||||
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 <http://www.gnu.org/licenses>
|
||||
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 MYSQL_NAMEDPIPE "MySQL"
|
||||
#define MYSQL_SERVICENAME "MySql"
|
||||
#endif /* _WIN32 */
|
||||
|
||||
enum mysql_enum_shutdown_level
|
||||
{
|
||||
SHUTDOWN_DEFAULT = 0,
|
||||
KILL_QUERY= 254,
|
||||
KILL_CONNECTION= 255
|
||||
};
|
||||
|
||||
enum enum_server_command
|
||||
{
|
||||
MYSQL_COM_SLEEP = 0,
|
||||
MYSQL_COM_QUIT,
|
||||
MYSQL_COM_INIT_DB,
|
||||
MYSQL_COM_QUERY,
|
||||
MYSQL_COM_FIELD_LIST,
|
||||
MYSQL_COM_CREATE_DB,
|
||||
MYSQL_COM_DROP_DB,
|
||||
MYSQL_COM_REFRESH,
|
||||
MYSQL_COM_SHUTDOWN,
|
||||
MYSQL_COM_STATISTICS,
|
||||
MYSQL_COM_PROCESS_INFO,
|
||||
MYSQL_COM_CONNECT,
|
||||
MYSQL_COM_PROCESS_KILL,
|
||||
MYSQL_COM_DEBUG,
|
||||
MYSQL_COM_PING,
|
||||
MYSQL_COM_TIME = 15,
|
||||
MYSQL_COM_DELAYED_INSERT,
|
||||
MYSQL_COM_CHANGE_USER,
|
||||
MYSQL_COM_BINLOG_DUMP,
|
||||
MYSQL_COM_TABLE_DUMP,
|
||||
MYSQL_COM_CONNECT_OUT = 20,
|
||||
MYSQL_COM_REGISTER_SLAVE,
|
||||
MYSQL_COM_STMT_PREPARE = 22,
|
||||
MYSQL_COM_STMT_EXECUTE = 23,
|
||||
MYSQL_COM_STMT_SEND_LONG_DATA = 24,
|
||||
MYSQL_COM_STMT_CLOSE = 25,
|
||||
MYSQL_COM_STMT_RESET = 26,
|
||||
MYSQL_COM_SET_OPTION = 27,
|
||||
MYSQL_COM_STMT_FETCH = 28,
|
||||
MYSQL_COM_DAEMON,
|
||||
MYSQL_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_LONG_PASSWORD 1 /* new more secure passwords */
|
||||
#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_PROGRESS (1UL << 29) /* client supports progress indicator */
|
||||
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
|
||||
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
|
||||
|
||||
#define CLIENT_SUPPORTED_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_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_CONNECT_ATTRS)
|
||||
|
||||
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD |\
|
||||
CLIENT_LONG_FLAG |\
|
||||
CLIENT_TRANSACTIONS |\
|
||||
CLIENT_SECURE_CONNECTION |\
|
||||
CLIENT_MULTI_RESULTS | \
|
||||
CLIENT_PS_MULTI_RESULTS |\
|
||||
CLIENT_PROTOCOL_41 |\
|
||||
CLIENT_PLUGIN_AUTH |\
|
||||
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_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 */
|
||||
|
||||
#ifndef Vio_defined
|
||||
#define Vio_defined
|
||||
#ifdef HAVE_VIO
|
||||
class Vio; /* Fill Vio class in C++ */
|
||||
#else
|
||||
struct st_vio; /* Only C */
|
||||
typedef struct st_vio Vio;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */
|
||||
#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
|
||||
|
||||
|
||||
typedef struct st_net {
|
||||
Vio *vio;
|
||||
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;
|
||||
my_bool unused_1, unused_2;
|
||||
my_bool compress;
|
||||
my_bool unused_3;
|
||||
unsigned char *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];
|
||||
void *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_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,
|
||||
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 compability */
|
||||
#define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM /* For compability */
|
||||
#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 my_net_init(NET *net, Vio *vio);
|
||||
void net_end(NET *net);
|
||||
void net_clear(NET *net);
|
||||
int net_flush(NET *net);
|
||||
int my_net_write(NET *net,const char *packet, size_t len);
|
||||
int net_write_command(NET *net,unsigned char command,const char *packet,
|
||||
size_t len);
|
||||
int net_real_write(NET *net,const char *packet, size_t len);
|
||||
unsigned long my_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};
|
||||
|
||||
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;
|
||||
|
||||
/* 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
|
||||
|
||||
void randominit(struct rand_struct *,unsigned long seed1,
|
||||
unsigned long seed2);
|
||||
double rnd(struct rand_struct *);
|
||||
void make_scrambled_password(char *to,const char *password);
|
||||
void get_salt_from_password(unsigned long *res,const char *password);
|
||||
void make_password_from_salt(char *to, unsigned long *hash_res);
|
||||
char *scramble_323(char *to,const char *message,const char *password);
|
||||
void my_scramble_41(const unsigned char *buffer, const char *scramble, const char *password);
|
||||
my_bool check_scramble(const char *, const char *message,
|
||||
unsigned long *salt,my_bool old_ver);
|
||||
void hash_password(unsigned long *result, const char *password, size_t len);
|
||||
|
||||
/* Some other useful functions */
|
||||
|
||||
void load_defaults(const char *conf_file, const char **groups,
|
||||
int *argc, char ***argv);
|
||||
my_bool my_thread_init(void);
|
||||
void my_thread_end(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
|
||||
|
||||
#endif
|
31
module/Vendor/MDBC/include/mysql_io.h
vendored
Normal file
31
module/Vendor/MDBC/include/mysql_io.h
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 6 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2006-2007 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef MYSQL_IO_H
|
||||
#define MYSQL_IO_H
|
||||
|
||||
#ifdef _WIN32
|
||||
void mysql_io_win_init(void);
|
||||
#endif
|
||||
|
||||
MYSQL_STREAM * mysql_io_open(const char *name, size_t namelen);
|
||||
size_t mysql_io_read(MYSQL_STREAM *stream, char *buf, size_t size);
|
||||
size_t mysql_io_write(MYSQL_STREAM *stream, const char *buf, size_t count);
|
||||
void mysql_io_close(MYSQL_STREAM *stream);
|
||||
|
||||
#endif /* MYSQLND_IO_H */
|
44
module/Vendor/MDBC/include/mysql_mm.h
vendored
Normal file
44
module/Vendor/MDBC/include/mysql_mm.h
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 6 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2006-2007 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Georg Richter <georg@mysql.com> |
|
||||
| Andrey Hristov <andrey@mysql.com> |
|
||||
| Ulf Wendel <uwendel@mysql.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef MYSQLND_MM_H
|
||||
#define MYSQLND_MM_H
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
char * mnd_strndup(const char *s, size_t length);
|
||||
char * mnd_strdup(const char *src);
|
||||
|
||||
|
||||
#define mnd_malloc(size) malloc((size))
|
||||
#define mnd_calloc(nmemb, size) calloc((nmemb), (size))
|
||||
#define mnd_realloc(ptr, new_size) realloc((ptr), (new_size))
|
||||
#define mnd_free(ptr) free((ptr))
|
||||
|
||||
#endif /* MYSQLND_MM_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
4
module/Vendor/MDBC/include/mysql_priv.h
vendored
Normal file
4
module/Vendor/MDBC/include/mysql_priv.h
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/* internal functions */
|
||||
MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, uint fields);
|
||||
void free_rows(MYSQL_DATA *cur);
|
||||
MYSQL_FIELD * unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, my_bool default_value, my_bool long_flag_protocol);
|
29
module/Vendor/MDBC/include/mysql_version.h
vendored
Normal file
29
module/Vendor/MDBC/include/mysql_version.h
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/* 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 */
|
||||
|
||||
#ifdef _CUSTOMCONFIG_
|
||||
#include <custom_conf.h>
|
||||
#else
|
||||
#define PROTOCOL_VERSION 10
|
||||
#define MYSQL_CLIENT_VERSION "5.5.1"
|
||||
#define MYSQL_SERVER_VERSION "5.5.1"
|
||||
#define MYSQL_SERVER_SUFFIX ""
|
||||
#define FRM_VER
|
||||
#define MYSQL_VERSION_ID 50501
|
||||
#define MYSQL_PORT 3306
|
||||
#define MYSQL_UNIX_ADDR "/tmp/mysql.sock"
|
||||
#define MYSQL_CONFIG_NAME "my"
|
||||
|
||||
#define MARIADB_PACKAGE_VERSION "2.3.7"
|
||||
#define MARIADB_PACKAGE_VERSION_ID 20307
|
||||
#define MARIADB_SYSTEM_TYPE "Windows"
|
||||
#define MARIADB_MACHINE_TYPE "AMD64"
|
||||
|
||||
/* mysqld compile time options */
|
||||
#ifndef MYSQL_CHARSET
|
||||
#define MYSQL_CHARSET ""
|
||||
#endif
|
||||
#endif
|
||||
|
29
module/Vendor/MDBC/include/mysql_version.h.in
vendored
Normal file
29
module/Vendor/MDBC/include/mysql_version.h.in
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/* 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 */
|
||||
|
||||
#ifdef _CUSTOMCONFIG_
|
||||
#include <custom_conf.h>
|
||||
#else
|
||||
#define PROTOCOL_VERSION @PROTOCOL_VERSION@
|
||||
#define MYSQL_CLIENT_VERSION "@MYSQL_CLIENT_VERSION@"
|
||||
#define MYSQL_SERVER_VERSION "@MYSQL_CLIENT_VERSION@"
|
||||
#define MYSQL_SERVER_SUFFIX "@MYSQL_SERVER_SUFFIX@"
|
||||
#define FRM_VER @DOT_FRM_VERSION@
|
||||
#define MYSQL_VERSION_ID @MYSQL_VERSION_ID@
|
||||
#define MYSQL_PORT @MYSQL_PORT@
|
||||
#define MYSQL_UNIX_ADDR "@MYSQL_UNIX_ADDR@"
|
||||
#define MYSQL_CONFIG_NAME "my"
|
||||
|
||||
#define MARIADB_PACKAGE_VERSION "@CPACK_PACKAGE_VERSION@"
|
||||
#define MARIADB_PACKAGE_VERSION_ID @MARIADB_PACKAGE_VERSION_ID@
|
||||
#define MARIADB_SYSTEM_TYPE "@CMAKE_SYSTEM_NAME@"
|
||||
#define MARIADB_MACHINE_TYPE "@CMAKE_SYSTEM_PROCESSOR@"
|
||||
|
||||
/* mysqld compile time options */
|
||||
#ifndef MYSQL_CHARSET
|
||||
#define MYSQL_CHARSET "@default_charset@"
|
||||
#endif
|
||||
#endif
|
||||
|
295
module/Vendor/MDBC/include/mysql_wireprotocol.h
vendored
Normal file
295
module/Vendor/MDBC/include/mysql_wireprotocol.h
vendored
Normal file
@ -0,0 +1,295 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 6 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2006-2007 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Georg Richter <georg@mysql.com> |
|
||||
| Andrey Hristov <andrey@mysql.com> |
|
||||
| Ulf Wendel <uwendel@mysql.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id: mysql_wireprotocol.h,v 1.4.2.2 2007/10/05 21:23:56 andrey Exp $ */
|
||||
|
||||
#ifndef MYSQL_WIREPROTOCOL_H
|
||||
#define MYSQL_WIREPROTOCOL_H
|
||||
|
||||
#define MYSQL_HEADER_SIZE 4
|
||||
|
||||
#define MYSQL_NULL_LENGTH (unsigned long) ~0
|
||||
|
||||
typedef unsigned char mysql_1b;
|
||||
typedef unsigned short mysql_2b;
|
||||
typedef unsigned int mysql_4b;
|
||||
|
||||
/* Used in mysql_debug.c */
|
||||
extern char * mysql_read_header_name;
|
||||
extern char * mysql_read_body_name;
|
||||
|
||||
|
||||
/* Packet handling */
|
||||
#define PACKET_INIT(packet, enum_type, c_type) \
|
||||
{ \
|
||||
packet = (c_type) my_mcalloc( packet_methods[enum_type].struct_size, MYF(MY_WME | MY_ZEROFILL)); \
|
||||
((c_type) (packet))->header.m = &packet_methods[enum_type]; \
|
||||
}
|
||||
#define PACKET_WRITE(packet, conn) ((packet)->header.m->write_to_net((packet), (conn)))
|
||||
#define PACKET_READ(packet, conn) ((packet)->header.m->read_from_net((packet), (conn)))
|
||||
#define PACKET_FREE(packet) ((packet)->header.m->free_mem((packet), FALSE))
|
||||
|
||||
#define PACKET_INIT_ALLOCA(packet, enum_type) \
|
||||
{ \
|
||||
memset(&(packet), 0, packet_methods[enum_type].struct_size); \
|
||||
(packet).header.m = &packet_methods[enum_type]; \
|
||||
}
|
||||
#define PACKET_WRITE_ALLOCA(packet, conn) PACKET_WRITE(&(packet), (conn))
|
||||
#define PACKET_READ_ALLOCA(packet, conn) PACKET_READ(&(packet), (conn))
|
||||
#define PACKET_FREE_ALLOCA(packet) (packet.header.m->free_mem(&(packet), TRUE))
|
||||
|
||||
/* Enums */
|
||||
enum php_mysql_packet_type
|
||||
{
|
||||
PROT_GREET_PACKET= 0,
|
||||
PROT_AUTH_PACKET,
|
||||
PROT_OK_PACKET,
|
||||
PROT_EOF_PACKET,
|
||||
PROT_CMD_PACKET,
|
||||
PROT_RSET_HEADER_PACKET,
|
||||
PROT_RSET_FLD_PACKET,
|
||||
PROT_ROW_PACKET,
|
||||
PROT_STATS_PACKET,
|
||||
PROT_PREPARE_RESP_PACKET,
|
||||
PROT_CHG_USER_PACKET,
|
||||
PROT_LAST, /* should always be last */
|
||||
};
|
||||
|
||||
|
||||
extern const char * const mysql_command_to_text[MYSQL_COM_END];
|
||||
|
||||
/* Low-level extraction functionality */
|
||||
typedef struct st_mysql_packet_methods {
|
||||
size_t struct_size;
|
||||
my_bool (*read_from_net)(void *packet, MYSQL *conn);
|
||||
size_t (*write_to_net)(void *packet, MYSQL *conn);
|
||||
void (*free_mem)(void *packet, my_bool alloca);
|
||||
} mysql_packet_methods;
|
||||
|
||||
extern mysql_packet_methods packet_methods[];
|
||||
|
||||
|
||||
typedef struct st_mysql_packet_header {
|
||||
size_t size;
|
||||
uchar packet_no;
|
||||
mysql_packet_methods *m;
|
||||
} mysql_packet_header;
|
||||
|
||||
/* Server greets the client */
|
||||
typedef struct st_php_mysql_packet_greet {
|
||||
mysql_packet_header header;
|
||||
mysql_1b protocol_version;
|
||||
char *server_version;
|
||||
mysql_4b thread_id;
|
||||
uchar scramble_buf[SCRAMBLE_LENGTH];
|
||||
/* 1 byte pad */
|
||||
mysql_2b server_capabilities;
|
||||
mysql_1b charset_no;
|
||||
mysql_2b server_status;
|
||||
/* 13 byte pad*/
|
||||
my_bool pre41;
|
||||
/* If error packet, we use these */
|
||||
char error[MYSQL_ERRMSG_SIZE+1];
|
||||
char sqlstate[SQLSTATE_LENGTH + 1];
|
||||
unsigned int error_no;
|
||||
} php_mysql_packet_greet;
|
||||
|
||||
|
||||
/* Client authenticates */
|
||||
typedef struct st_php_mysql_packet_auth {
|
||||
mysql_packet_header header;
|
||||
mysql_4b client_flags;
|
||||
uint32 max_packet_size;
|
||||
mysql_1b charset_no;
|
||||
/* 23 byte pad */
|
||||
const char *user;
|
||||
/* 8 byte scramble */
|
||||
const char *db;
|
||||
/* 12 byte scramble */
|
||||
|
||||
/* Here the packet ends. This is user supplied data */
|
||||
const char *password;
|
||||
/* +1 for \0 because of scramble() */
|
||||
unsigned char *server_scramble_buf;
|
||||
size_t db_len;
|
||||
} php_mysql_packet_auth;
|
||||
|
||||
/* OK packet */
|
||||
typedef struct st_php_mysql_packet_ok {
|
||||
mysql_packet_header header;
|
||||
mysql_1b field_count; /* always 0x0 */
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong last_insert_id;
|
||||
mysql_2b server_status;
|
||||
mysql_2b warning_count;
|
||||
char *message;
|
||||
size_t message_len;
|
||||
/* If error packet, we use these */
|
||||
char error[MYSQL_ERRMSG_SIZE+1];
|
||||
char sqlstate[SQLSTATE_LENGTH + 1];
|
||||
unsigned int error_no;
|
||||
} php_mysql_packet_ok;
|
||||
|
||||
|
||||
/* Command packet */
|
||||
typedef struct st_php_mysql_packet_command {
|
||||
mysql_packet_header header;
|
||||
enum enum_server_command command;
|
||||
const char *argument;
|
||||
size_t arg_len;
|
||||
} php_mysql_packet_command;
|
||||
|
||||
|
||||
/* EOF packet */
|
||||
typedef struct st_php_mysql_packet_eof {
|
||||
mysql_packet_header header;
|
||||
mysql_1b field_count; /* 0xFE */
|
||||
mysql_2b warning_count;
|
||||
mysql_2b server_status;
|
||||
/* If error packet, we use these */
|
||||
char error[MYSQL_ERRMSG_SIZE+1];
|
||||
char sqlstate[SQLSTATE_LENGTH + 1];
|
||||
unsigned int error_no;
|
||||
} php_mysql_packet_eof;
|
||||
/* EOF packet */
|
||||
|
||||
|
||||
/* Result Set header*/
|
||||
typedef struct st_php_mysql_packet_rset_header {
|
||||
mysql_packet_header header;
|
||||
/*
|
||||
0x00 => ok
|
||||
~0 => LOAD DATA LOCAL
|
||||
error_no != 0 => error
|
||||
others => result set -> Read res_field packets up to field_count
|
||||
*/
|
||||
unsigned long field_count;
|
||||
/*
|
||||
These are filled if no SELECT query. For SELECT warning_count
|
||||
and server status are in the last row packet, the EOF packet.
|
||||
*/
|
||||
mysql_2b warning_count;
|
||||
mysql_2b server_status;
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong last_insert_id;
|
||||
/* This is for both LOAD DATA or info, when no result set */
|
||||
char *info_or_local_file;
|
||||
size_t info_or_local_file_len;
|
||||
/* If error packet, we use these */
|
||||
mysql_error_info error_info;
|
||||
} php_mysql_packet_rset_header;
|
||||
|
||||
|
||||
/* Result set field packet */
|
||||
typedef struct st_php_mysql_packet_res_field {
|
||||
mysql_packet_header header;
|
||||
MYSQL_FIELD *metadata;
|
||||
/* For table definitions, empty for result sets */
|
||||
my_bool skip_parsing;
|
||||
my_bool stupid_list_fields_eof;
|
||||
} php_mysql_packet_res_field;
|
||||
|
||||
|
||||
/* Row packet */
|
||||
struct st_php_mysql_packet_row {
|
||||
mysql_packet_header header;
|
||||
uchar **fields; /* ??? */
|
||||
mysql_4b field_count;
|
||||
my_bool eof;
|
||||
/*
|
||||
These are, of course, only for SELECT in the EOF packet,
|
||||
which is detected by this packet
|
||||
*/
|
||||
mysql_2b warning_count;
|
||||
mysql_2b server_status;
|
||||
|
||||
uchar *row_buffer;
|
||||
|
||||
my_bool skip_extraction;
|
||||
my_bool binary_protocol;
|
||||
MYSQL_FIELD *fields_metadata;
|
||||
/* We need this to alloc bigger bufs in non-PS mode */
|
||||
unsigned int bit_fields_count;
|
||||
size_t bit_fields_total_len; /* trailing \0 not counted */
|
||||
|
||||
/* If error packet, we use these */
|
||||
mysql_error_info error_info;
|
||||
};
|
||||
typedef struct st_php_mysql_packet_row php_mysql_packet_row;
|
||||
|
||||
/* Statistics packet */
|
||||
typedef struct st_php_mysql_packet_stats {
|
||||
mysql_packet_header header;
|
||||
char *message;
|
||||
/* message_len is not part of the packet*/
|
||||
size_t message_len;
|
||||
} php_mysql_packet_stats;
|
||||
|
||||
|
||||
/* COM_PREPARE response packet */
|
||||
typedef struct st_php_mysql_packet_prepare_response {
|
||||
mysql_packet_header header;
|
||||
/* also known as field_count 0x00=OK , 0xFF=error */
|
||||
unsigned char error_code;
|
||||
unsigned long stmt_id;
|
||||
unsigned int field_count;
|
||||
unsigned int param_count;
|
||||
unsigned int warning_count;
|
||||
|
||||
/* present in case of error */
|
||||
mysql_error_info error_info;
|
||||
} php_mysql_packet_prepare_response;
|
||||
|
||||
|
||||
/* Statistics packet */
|
||||
typedef struct st_php_mysql_packet_chg_user_resp {
|
||||
mysql_packet_header header;
|
||||
mysql_4b field_count;
|
||||
|
||||
/* message_len is not part of the packet*/
|
||||
mysql_2b server_capabilities;
|
||||
/* If error packet, we use these */
|
||||
mysql_error_info error_info;
|
||||
} php_mysql_packet_chg_user_resp;
|
||||
|
||||
|
||||
size_t mysql_stream_write(MYSQL *conn, const char * buf, size_t count);
|
||||
size_t mysql_stream_write_w_header(MYSQL *conn, const char * buf, size_t count);
|
||||
|
||||
#ifdef MYSQL_DO_WIRE_CHECK_BEFORE_COMMAND
|
||||
size_t php_mysql_consume_uneaten_data(const MYSQL *conn, enum php_mysql_server_command cmd);
|
||||
#endif
|
||||
|
||||
|
||||
unsigned long php_mysql_net_field_length(uchar **packet);
|
||||
uchar * php_mysql_net_store_length(uchar *packet, my_ulonglong length);
|
||||
|
||||
extern char * const mysql_empty_string;
|
||||
|
||||
#endif /* MYSQL_WIREPROTOCOL_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
772
module/Vendor/MDBC/include/mysqld_error.h
vendored
Normal file
772
module/Vendor/MDBC/include/mysqld_error.h
vendored
Normal file
@ -0,0 +1,772 @@
|
||||
/* This file was automatically generated from errmsg.sys.
|
||||
Todo: Several error messages are no longer in use
|
||||
*/
|
||||
|
||||
#define ER_HASHCHK 1000 /* no longer in use ?! */
|
||||
#define ER_NISAMCHK 1001 /* no longer in use ? */
|
||||
#define ER_NO 1002
|
||||
#define ER_YES 1003
|
||||
#define ER_CANT_CREATE_FILE 1004
|
||||
#define ER_CANT_CREATE_TABLE 1005
|
||||
#define ER_CANT_CREATE_DB 1006
|
||||
#define ER_DB_CREATE_EXISTS 1007
|
||||
#define ER_DB_DROP_EXISTS 1008
|
||||
#define ER_DB_DROP_DELETE 1009 /* no longer in use ?! */
|
||||
#define ER_DB_DROP_RMDIR 1010
|
||||
#define ER_CANT_DELETE_FILE 1011
|
||||
#define ER_CANT_FIND_SYSTEM_REC 1012
|
||||
#define ER_CANT_GET_STAT 1013
|
||||
#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 ER_CANT_SET_WD 1019
|
||||
#define ER_CHECKREAD 1020
|
||||
#define ER_DISK_FULL 1021
|
||||
#define ER_DUP_KEY 1022
|
||||
#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 ER_FORM_NOT_FOUND 1029 /* no longer in use ?! */
|
||||
#define ER_GET_ERRNO 1030
|
||||
#define ER_ILLEGAL_HA 1031
|
||||
#define ER_KEY_NOT_FOUND 1032
|
||||
#define ER_NOT_FORM_FILE 1033
|
||||
#define ER_NOT_KEYFILE 1034
|
||||
#define ER_OLD_KEYFILE 1035
|
||||
#define ER_OPEN_AS_READONLY 1036
|
||||
#define ER_OUTOFMEMORY 1037
|
||||
#define ER_OUT_OF_SORTMEMORY 1038
|
||||
#define ER_UNEXPECTED_EOF 1039
|
||||
#define ER_CON_COUNT_ERROR 1040
|
||||
#define ER_OUT_OF_RESOURCES 1041
|
||||
#define ER_BAD_HOST_ERROR 1042
|
||||
#define ER_HANDSHAKE_ERROR 1043
|
||||
#define ER_DBACCESS_DENIED_ERROR 1044
|
||||
#define ER_ACCESS_DENIED_ERROR 1045
|
||||
#define ER_NO_DB_ERROR 1046
|
||||
#define ER_UNKNOWN_COM_ERROR 1047
|
||||
#define ER_BAD_NULL_ERROR 1048
|
||||
#define ER_BAD_DB_ERROR 1049
|
||||
#define ER_TABLE_EXISTS_ERROR 1050
|
||||
#define ER_BAD_TABLE_ERROR 1051
|
||||
#define ER_NON_UNIQ_ERROR 1052
|
||||
#define ER_SERVER_SHUTDOWN 1053
|
||||
#define ER_BAD_FIELD_ERROR 1054
|
||||
#define ER_WRONG_FIELD_WITH_GROUP 1055
|
||||
#define ER_WRONG_GROUP_FIELD 1056
|
||||
#define ER_WRONG_SUM_SELECT 1057
|
||||
#define ER_WRONG_VALUE_COUNT 1058
|
||||
#define ER_TOO_LONG_IDENT 1059
|
||||
#define ER_DUP_FIELDNAME 1060
|
||||
#define ER_DUP_KEYNAME 1061
|
||||
#define ER_DUP_ENTRY 1062
|
||||
#define ER_WRONG_FIELD_SPEC 1063
|
||||
#define ER_PARSE_ERROR 1064
|
||||
#define ER_EMPTY_QUERY 1065
|
||||
#define ER_NONUNIQ_TABLE 1066
|
||||
#define ER_INVALID_DEFAULT 1067
|
||||
#define ER_MULTIPLE_PRI_KEY 1068
|
||||
#define ER_TOO_MANY_KEYS 1069
|
||||
#define ER_TOO_MANY_KEY_PARTS 1070
|
||||
#define ER_TOO_LONG_KEY 1071
|
||||
#define ER_KEY_COLUMN_DOES_NOT_EXITS 1072
|
||||
#define ER_BLOB_USED_AS_KEY 1073
|
||||
#define ER_TOO_BIG_FIELDLENGTH 1074
|
||||
#define ER_WRONG_AUTO_KEY 1075
|
||||
#define ER_READY 1076 /* no longer in use !? */
|
||||
#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
|
||||
#define ER_NO_SUCH_INDEX 1082
|
||||
#define ER_WRONG_FIELD_TERMINATORS 1083
|
||||
#define ER_BLOBS_AND_NO_TERMINATED 1084
|
||||
#define ER_TEXTFILE_NOT_READABLE 1085
|
||||
#define ER_FILE_EXISTS_ERROR 1086
|
||||
#define ER_LOAD_INFO 1087
|
||||
#define ER_ALTER_INFO 1088 /* no longer in use !? */
|
||||
#define ER_WRONG_SUB_KEY 1089
|
||||
#define ER_CANT_REMOVE_ALL_FIELDS 1090
|
||||
#define ER_CANT_DROP_FIELD_OR_KEY 1091
|
||||
#define ER_INSERT_INFO 1092
|
||||
#define ER_INSERT_TABLE_USED 1093 /* no longer in use !? */
|
||||
#define ER_NO_SUCH_THREAD 1094
|
||||
#define ER_KILL_DENIED_ERROR 1095
|
||||
#define ER_NO_TABLES_USED 1096
|
||||
#define ER_TOO_BIG_SET 1097
|
||||
#define ER_NO_UNIQUE_LOGFILE 1098
|
||||
#define ER_TABLE_NOT_LOCKED_FOR_WRITE 1099
|
||||
#define ER_TABLE_NOT_LOCKED 1100
|
||||
#define ER_BLOB_CANT_HAVE_DEFAULT 1101
|
||||
#define ER_WRONG_DB_NAME 1102
|
||||
#define ER_WRONG_TABLE_NAME 1103
|
||||
#define ER_TOO_BIG_SELECT 1104
|
||||
#define ER_UNKNOWN_ERROR 1105
|
||||
#define ER_UNKNOWN_PROCEDURE 1106
|
||||
#define ER_WRONG_PARAMCOUNT_TO_PROCEDURE 1107
|
||||
#define ER_WRONG_PARAMETERS_TO_PROCEDURE 1108
|
||||
#define ER_UNKNOWN_TABLE 1109
|
||||
#define ER_FIELD_SPECIFIED_TWICE 1110
|
||||
#define ER_INVALID_GROUP_FUNC_USE 1111
|
||||
#define ER_UNSUPPORTED_EXTENSION 1112
|
||||
#define ER_TABLE_MUST_HAVE_COLUMNS 1113
|
||||
#define ER_RECORD_FILE_FULL 1114
|
||||
#define ER_UNKNOWN_CHARACTER_SET 1115
|
||||
#define ER_TOO_MANY_TABLES 1116
|
||||
#define ER_TOO_MANY_FIELDS 1117
|
||||
#define ER_TOO_BIG_ROWSIZE 1118
|
||||
#define ER_STACK_OVERRUN 1119
|
||||
#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
|
||||
#define ER_UDF_NO_PATHS 1124
|
||||
#define ER_UDF_EXISTS 1125
|
||||
#define ER_CANT_OPEN_LIBRARY 1126
|
||||
#define ER_CANT_FIND_DL_ENTRY 1127
|
||||
#define ER_FUNCTION_NOT_DEFINED 1128
|
||||
#define ER_HOST_IS_BLOCKED 1129
|
||||
#define ER_HOST_NOT_PRIVILEGED 1130
|
||||
#define ER_PASSWORD_ANONYMOUS_USER 1131
|
||||
#define ER_PASSWORD_NOT_ALLOWED 1132 /* no longer in use !? */
|
||||
#define ER_PASSWORD_NO_MATCH 1133
|
||||
#define ER_UPDATE_INFO 1134
|
||||
#define ER_CANT_CREATE_THREAD 1135
|
||||
#define ER_WRONG_VALUE_COUNT_ON_ROW 1136
|
||||
#define ER_CANT_REOPEN_TABLE 1137
|
||||
#define ER_INVALID_USE_OF_NULL 1138 /* no longer in use !? */
|
||||
#define ER_REGEXP_ERROR 1139
|
||||
#define ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140
|
||||
#define ER_NONEXISTING_GRANT 1141
|
||||
#define ER_TABLEACCESS_DENIED_ERROR 1142
|
||||
#define ER_COLUMNACCESS_DENIED_ERROR 1143
|
||||
#define ER_ILLEGAL_GRANT_FOR_TABLE 1144
|
||||
#define ER_GRANT_WRONG_HOST_OR_USER 1145 /* no longer in use !? */
|
||||
#define ER_NO_SUCH_TABLE 1146
|
||||
#define ER_NONEXISTING_TABLE_GRANT 1147
|
||||
#define ER_NOT_ALLOWED_COMMAND 1148
|
||||
#define ER_SYNTAX_ERROR 1149
|
||||
#define ER_DELAYED_CANT_CHANGE_LOCK 1150
|
||||
#define ER_TOO_MANY_DELAYED_THREADS 1151 /* no longer in use !? */
|
||||
#define ER_ABORTING_CONNECTION 1152 /* no longer in use !? */
|
||||
#define ER_NET_PACKET_TOO_LARGE 1153
|
||||
#define ER_NET_READ_ERROR_FROM_PIPE 1154 /* no longer in use !? */
|
||||
#define ER_NET_FCNTL_ERROR 1155
|
||||
#define ER_NET_PACKETS_OUT_OF_ORDER 1156
|
||||
#define ER_NET_UNCOMPRESS_ERROR 1157
|
||||
#define ER_NET_READ_ERROR 1158
|
||||
#define ER_NET_READ_INTERRUPTED 1159
|
||||
#define ER_NET_ERROR_ON_WRITE 1160
|
||||
#define ER_NET_WRITE_INTERRUPTED 1161
|
||||
#define ER_TOO_LONG_STRING 1162 /* no longer in use !? */
|
||||
#define ER_TABLE_CANT_HANDLE_BLOB 1163
|
||||
#define ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164
|
||||
#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
|
||||
#define ER_DUP_UNIQUE 1169
|
||||
#define ER_BLOB_KEY_WITHOUT_LENGTH 1170
|
||||
#define ER_PRIMARY_CANT_HAVE_NULL 1171
|
||||
#define ER_TOO_MANY_ROWS 1172
|
||||
#define ER_REQUIRES_PRIMARY_KEY 1173
|
||||
#define ER_NO_RAID_COMPILED 1174 /* no longer in use !? */
|
||||
#define ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175
|
||||
#define ER_KEY_DOES_NOT_EXITS 1176
|
||||
#define ER_CHECK_NO_SUCH_TABLE 1177
|
||||
#define ER_CHECK_NOT_IMPLEMENTED 1178
|
||||
#define ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179 /* no longer in use !? */
|
||||
#define ER_ERROR_DURING_COMMIT 1180
|
||||
#define ER_ERROR_DURING_ROLLBACK 1181
|
||||
#define ER_ERROR_DURING_FLUSH_LOGS 1182
|
||||
#define ER_ERROR_DURING_CHECKPOINT 1183 /* no longer in use !? */
|
||||
#define ER_NEW_ABORTING_CONNECTION 1184
|
||||
#define ER_DUMP_NOT_IMPLEMENTED 1185 /* no longer in use !? */
|
||||
#define ER_FLUSH_MASTER_BINLOG_CLOSED 1186
|
||||
#define ER_INDEX_REBUILD 1187 /* no longer in use !? */
|
||||
#define ER_MASTER 1188
|
||||
#define ER_MASTER_NET_READ 1189 /* no longer in use !? */
|
||||
#define ER_MASTER_NET_WRITE 1190 /* no longer in use !? */
|
||||
#define ER_FT_MATCHING_KEY_NOT_FOUND 1191
|
||||
#define ER_LOCK_OR_ACTIVE_TRANSACTION 1192
|
||||
#define ER_UNKNOWN_SYSTEM_VARIABLE 1193
|
||||
#define ER_CRASHED_ON_USAGE 1194
|
||||
#define ER_CRASHED_ON_REPAIR 1195
|
||||
#define ER_WARNING_NOT_COMPLETE_ROLLBACK 1196
|
||||
#define ER_TRANS_CACHE_FULL 1197
|
||||
#define ER_SLAVE_MUST_STOP 1198
|
||||
#define ER_SLAVE_NOT_RUNNING 1199
|
||||
#define ER_BAD_SLAVE 1200
|
||||
#define ER_MASTER_INFO 1201
|
||||
#define ER_SLAVE_THREAD 1202
|
||||
#define ER_TOO_MANY_USER_CONNECTIONS 1203
|
||||
#define ER_SET_CONSTANTS_ONLY 1204
|
||||
#define ER_LOCK_WAIT_TIMEOUT 1205
|
||||
#define ER_LOCK_TABLE_FULL 1206
|
||||
#define ER_READ_ONLY_TRANSACTION 1207
|
||||
#define ER_DROP_DB_WITH_READ_LOCK 1208 /* no longer in use !? */
|
||||
#define ER_CREATE_DB_WITH_READ_LOCK 1209 /* no longer in use !? */
|
||||
#define ER_WRONG_ARGUMENTS 1210
|
||||
#define ER_NO_PERMISSION_TO_CREATE_USER 1211 /* no longer in use !? */
|
||||
#define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212 /* no longer in use !? */
|
||||
#define ER_LOCK_DEADLOCK 1213
|
||||
#define ER_TABLE_CANT_HANDLE_FULLTEXT 1214 /* no longer in use !? */
|
||||
#define ER_CANNOT_ADD_FOREIGN 1215
|
||||
#define ER_NO_REFERENCED_ROW 1216
|
||||
#define ER_ROW_IS_REFERENCED 1217
|
||||
|
||||
/* new server messages (added after 3.23.49) */
|
||||
#define ER_CONNECT_TO_MASTER 1218 /* no longer in use !? */
|
||||
#define ER_QUERY_ON_MASTER 1219 /* no longer in use !? */
|
||||
#define ER_ERROR_WHEN_EXECUTING_COMMAND 1220
|
||||
#define ER_WRONG_USAGE 1221
|
||||
#define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1222
|
||||
#define ER_CANT_UPDATE_WITH_READLOCK 1223 /* no longer in use !? */
|
||||
#define ER_MIXING_NOT_ALLOWED 1224 /* no longer in use !? */
|
||||
#define ER_DUP_ARGUMENT 1225
|
||||
#define ER_USER_LIMIT_REACHED 1226
|
||||
#define ER_SPECIFIC_ACCESS_DENIED_ERROR 1227
|
||||
#define ER_LOCAL_VARIABLE 1228
|
||||
#define ER_GLOBAL_VARIABLE 1229
|
||||
#define ER_NO_DEFAULT 1230
|
||||
#define ER_WRONG_VALUE_FOR_VAR 1231
|
||||
#define ER_WRONG_TYPE_FOR_VAR 1232
|
||||
#define ER_VAR_CANT_BE_READ 1233
|
||||
#define ER_CANT_USE_OPTION_HERE 1234
|
||||
#define ER_NOT_SUPPORTED_YET 1235
|
||||
#define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
|
||||
#define ER_SLAVE_IGNORED_TABLE 1237
|
||||
#define ER_INCORRECT_GLOBAL_LOCAL_VAR 1238
|
||||
#define ER_WRONG_FK_DEF 1239
|
||||
#define ER_KEY_REF_DO_NOT_MATCH_TABLE_REF 1240
|
||||
#define ER_OPERAND_COLUMNS 1241
|
||||
#define ER_SUBQUERY_NO_1_ROW 1242
|
||||
#define ER_UNKNOWN_STMT_HANDLER 1243
|
||||
#define ER_CORRUPT_HELP_DB 1244
|
||||
#define ER_CYCLIC_REFERENCE 1245 /* no longer in use ?! */
|
||||
#define ER_AUTO_CONVERT 1246
|
||||
#define ER_ILLEGAL_REFERENCE 1247
|
||||
#define ER_DERIVED_MUST_HAVE_ALIAS 1248
|
||||
#define ER_SELECT_REDUCED 1249
|
||||
#define ER_TABLENAME_NOT_ALLOWED_HERE 1250
|
||||
#define ER_NOT_SUPPORTED_AUTH_MODE 1251
|
||||
#define ER_SPATIAL_CANT_HAVE_NULL 1252
|
||||
#define ER_COLLATION_CHARSET_MISMATCH 1253
|
||||
#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
|
||||
#define ER_ZLIB_Z_DATA_ERROR 1259
|
||||
#define ER_CUT_VALUE_GROUP_CONCAT 1260
|
||||
#define ER_WARN_TOO_FEW_RECORDS 1261
|
||||
#define ER_WARN_TOO_MANY_RECORDS 1262
|
||||
#define ER_WARN_NULL_TO_NOTNULL 1263
|
||||
#define ER_WARN_DATA_OUT_OF_RANGE 1264
|
||||
#define WARN_DATA_TRUNCATED 1265
|
||||
#define ER_WARN_USING_OTHER_HANDLER 1266
|
||||
#define ER_CANT_AGGREGATE_2COLLATIONS 1267
|
||||
#define ER_DROP_USER 1268 /* no longer in use ?! */
|
||||
#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 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 /* no longer in use ?! */
|
||||
#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
|
||||
#define ER_UNKNOWN_STORAGE_ENGINE 1286
|
||||
#define ER_WARN_DEPRECATED_SYNTAX 1287
|
||||
#define ER_NON_UPDATABLE_TABLE 1288
|
||||
#define ER_FEATURE_DISABLED 1289
|
||||
#define ER_OPTION_PREVENTS_STATEMENT 1290
|
||||
#define ER_DUPLICATED_VALUE_IN_TYPE 1291
|
||||
#define ER_TRUNCATED_WRONG_VALUE 1292
|
||||
#define ER_TOO_MUCH_AUTO_TIMESTAMP_COLS 1293
|
||||
#define ER_INVALID_ON_UPDATE 1294
|
||||
#define ER_UNSUPPORTED_PS 1295
|
||||
#define ER_GET_ERRMSG 1296
|
||||
#define ER_GET_TEMPORARY_ERRMSG 1297
|
||||
#define ER_UNKNOWN_TIME_ZONE 1298
|
||||
#define ER_WARN_INVALID_TIMESTAMP 1299
|
||||
#define ER_INVALID_CHARACTER_STRING 1300
|
||||
#define ER_WARN_ALLOWED_PACKET_OVERFLOWED 1301
|
||||
#define ER_CONFLICTING_DECLARATIONS 1302
|
||||
#define ER_SP_NO_RECURSIVE_CREATE 1303
|
||||
#define ER_SP_ALREADY_EXISTS 1304
|
||||
#define ER_SP_DOES_NOT_EXIST 1305
|
||||
#define ER_SP_DROP_FAILED 1306
|
||||
#define ER_SP_STORE_FAILED 1307
|
||||
#define ER_SP_LILABEL_MISMATCH 1308
|
||||
#define ER_SP_LABEL_REDEFINE 1309
|
||||
#define ER_SP_LABEL_MISMATCH 1310
|
||||
#define ER_SP_UNINIT_VAR 1311 /* no longer in use ?! */
|
||||
#define ER_SP_BADSELECT 1312
|
||||
#define ER_SP_BADRETURN 1313
|
||||
#define ER_SP_BADSTATEMENT 1314
|
||||
#define ER_UPDATE_LOG_DEPRECATED_IGNORED 1315 /* no longer in use ?! */
|
||||
#define ER_UPDATE_LOG_DEPRECATED_TRANSLATED 1316 /* no longer in use ?! */
|
||||
#define ER_QUERY_INTERRUPTED 1317
|
||||
#define ER_SP_WRONG_NO_OF_ARGS 1318
|
||||
#define ER_SP_COND_MISMATCH 1319
|
||||
#define ER_SP_NORETURN 1320
|
||||
#define ER_SP_NORETURNEND 1321
|
||||
#define ER_SP_BAD_CURSOR_QUERY 1322
|
||||
#define ER_SP_BAD_CURSOR_SELECT 1323
|
||||
#define ER_SP_CURSOR_MISMATCH 1324
|
||||
#define ER_SP_CURSOR_ALREADY_OPEN 1325
|
||||
#define ER_SP_CURSOR_NOT_OPEN 1326
|
||||
#define ER_SP_UNDECLARED_VAR 1327
|
||||
#define ER_SP_WRONG_NO_OF_FETCH_ARGS 1328
|
||||
#define ER_SP_FETCH_NO_DATA 1329
|
||||
#define ER_SP_DUP_PARAM 1330
|
||||
#define ER_SP_DUP_VAR 1331
|
||||
#define ER_SP_DUP_COND 1332
|
||||
#define ER_SP_DUP_CURS 1333
|
||||
#define ER_SP_CANT_ALTER 1334
|
||||
#define ER_SP_SUBSELECT_NYI 1335 /* no longer in use ?! */
|
||||
#define ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG 1336 /* no longer in use ?! */
|
||||
#define ER_SP_VARCOND_AFTER_CURSHNDLR 1337
|
||||
#define ER_SP_CURSOR_AFTER_HANDLER 1338
|
||||
#define ER_SP_CASE_NOT_FOUND 1339
|
||||
#define ER_FPARSER_TOO_BIG_FILE 1340
|
||||
#define ER_FPARSER_BAD_HEADER 1341
|
||||
#define ER_FPARSER_EOF_IN_COMMENT 1342
|
||||
#define ER_FPARSER_ERROR_IN_PARAMETER 1343
|
||||
#define ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER 1344
|
||||
#define ER_VIEW_NO_EXPLAIN 1345
|
||||
#define ER_FRM_UNKNOWN_TYPE 1346
|
||||
#define ER_WRONG_OBJECT 1347
|
||||
#define ER_NONUPDATEABLE_COLUMN 1348
|
||||
#define ER_VIEW_SELECT_DERIVED 1349
|
||||
#define ER_VIEW_SELECT_CLAUSE 1350
|
||||
#define ER_VIEW_SELECT_VARIABLE 1351
|
||||
#define ER_VIEW_SELECT_TMPTABLE 1352
|
||||
#define ER_VIEW_WRONG_LIST 1353
|
||||
#define ER_WARN_VIEW_MERGE 1354
|
||||
#define ER_WARN_VIEW_WITHOUT_KEY 1355
|
||||
#define ER_VIEW_INVALID 1356
|
||||
#define ER_SP_NO_DROP_SP 1357
|
||||
#define ER_SP_GOTO_IN_HNDLR 1358 /* no longer in use ?! */
|
||||
#define ER_TRG_ALREADY_EXISTS 1359
|
||||
#define ER_TRG_DOES_NOT_EXIST 1360
|
||||
#define ER_TRG_ON_VIEW_OR_TEMP_TABLE 1361
|
||||
#define ER_TRG_CANT_CHANGE_ROW 1362
|
||||
#define ER_TRG_NO_SUCH_ROW_IN_TRG 1363
|
||||
#define ER_NO_DEFAULT_FOR_FIELD 1364
|
||||
#define ER_DIVISION_BY_ZERO 1365
|
||||
#define ER_TRUNCATED_WRONG_VALUE_FOR_FIELD 1366
|
||||
#define ER_ILLEGAL_VALUE_FOR_TYPE 1367
|
||||
#define ER_VIEW_NONUPD_CHECK 1368
|
||||
#define ER_VIEW_CHECK_FAILED 1369
|
||||
#define ER_PROCACCESS_DENIED_ERROR 1370
|
||||
#define ER_RELAY_LOG_FAIL 1371
|
||||
#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
|
||||
#define ER_FSEEK_FAIL 1376
|
||||
#define ER_BINLOG_PURGE_FATAL_ERR 1377
|
||||
#define ER_LOG_IN_USE 1378
|
||||
#define ER_LOG_PURGE_UNKNOWN_ERR 1379
|
||||
#define ER_RELAY_LOG_INIT 1380
|
||||
#define ER_NO_BINARY_LOGGING 1381
|
||||
#define ER_RESERVED_SYNTAX 1382
|
||||
#define ER_WSAS_FAILED 1383 /* no longer in use ?! */
|
||||
#define ER_DIFF_GROUPS_PROC 1384
|
||||
#define ER_NO_GROUP_FOR_PROC 1385 /* no longer in use ?! */
|
||||
#define ER_ORDER_WITH_PROC 1386
|
||||
#define ER_LOGGING_PROHIBIT_CHANGING_OF 1387 /* no longer in use ?! */
|
||||
#define ER_NO_FILE_MAPPING 1388 /* no longer in use ?! */
|
||||
#define ER_WRONG_MAGIC 1389 /* no longer in use ?! */
|
||||
#define ER_PS_MANY_PARAM 1390
|
||||
#define ER_KEY_PART_0 1391
|
||||
#define ER_VIEW_CHECKSUM 1392
|
||||
#define ER_VIEW_MULTIUPDATE 1393
|
||||
#define ER_VIEW_NO_INSERT_FIELD_LIST 1394
|
||||
#define ER_VIEW_DELETE_MERGE_VIEW 1395
|
||||
#define ER_CANNOT_USER 1396
|
||||
#define ER_XAER_NOTA 1397
|
||||
#define ER_XAER_INVAL 1398
|
||||
#define ER_XAER_RMFAIL 1399
|
||||
#define ER_XAER_OUTSIDE 1400
|
||||
#define ER_XAER_RMERR 1401
|
||||
#define ER_XA_RBROLLBACK 1402
|
||||
#define ER_NONEXISTING_PROC_GRANT 1403
|
||||
#define ER_PROC_AUTO_GRANT_FAIL 1404
|
||||
#define ER_PROC_AUTO_REVOKE_FAIL 1405
|
||||
#define ER_DATA_TOO_LONG 1406
|
||||
#define ER_SP_BAD_SQLSTATE 1407
|
||||
#define ER_STARTUP 1408
|
||||
#define ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR 1409
|
||||
#define ER_CANT_CREATE_USER_WITH_GRANT 1410
|
||||
#define ER_WRONG_VALUE_FOR_TYPE 1411
|
||||
#define ER_TABLE_DEF_CHANGED 1412
|
||||
#define ER_SP_DUP_HANDLER 1413
|
||||
#define ER_SP_NOT_VAR_ARG 1414
|
||||
#define ER_SP_NO_RETSET 1415 /* no longer in use ?! */
|
||||
#define ER_CANT_CREATE_GEOMETRY_OBJECT 1416
|
||||
#define ER_FAILED_ROUTINE_BREAK_BINLOG 1417 /* no longer in use ?! */
|
||||
#define ER_BINLOG_UNSAFE_ROUTINE 1418
|
||||
#define ER_BINLOG_CREATE_ROUTINE_NEED_SUPER 1419
|
||||
#define ER_EXEC_STMT_WITH_OPEN_CURSOR 1420 /* no longer in use ?! */
|
||||
#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
|
||||
#define ER_SP_NO_RECURSION 1424
|
||||
#define ER_TOO_BIG_SCALE 1425
|
||||
#define ER_TOO_BIG_PRECISION 1426
|
||||
#define ER_M_BIGGER_THAN_D 1427
|
||||
#define ER_WRONG_LOCK_OF_SYSTEM_TABLE 1428
|
||||
#define ER_CONNECT_TO_FOREIGN_DATA_SOURCE 1429
|
||||
#define ER_QUERY_ON_FOREIGN_DATA_SOURCE 1430
|
||||
#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 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
|
||||
#define ER_WARN_CANT_DROP_DEFAULT_KEYCACHE 1438 /* no longer in use ?! */
|
||||
#define ER_TOO_BIG_DISPLAYWIDTH 1439
|
||||
#define ER_XAER_DUPID 1440
|
||||
#define ER_DATETIME_FUNCTION_OVERFLOW 1441
|
||||
#define ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG 1442
|
||||
#define ER_VIEW_PREVENT_UPDATE 1443
|
||||
#define ER_PS_NO_RECURSION 1444
|
||||
#define ER_SP_CANT_SET_AUTOCOMMIT 1445 /* no longer in use ?! */
|
||||
#define ER_MALFORMED_DEFINER 1446 /* no longer in use ?! */
|
||||
#define ER_VIEW_FRM_NO_USER 1447
|
||||
#define ER_VIEW_OTHER_USER 1448 /* no longer in use ?! */
|
||||
#define ER_NO_SUCH_USER 1449
|
||||
#define ER_FORBID_SCHEMA_CHANGE 1450
|
||||
#define ER_ROW_IS_REFERENCED_2 1451
|
||||
#define ER_NO_REFERENCED_ROW_2 1452
|
||||
#define ER_SP_BAD_VAR_SHADOW 1453
|
||||
#define ER_TRG_NO_DEFINER 1454
|
||||
#define ER_OLD_FILE_FORMAT 1455
|
||||
#define ER_SP_RECURSION_LIMIT 1456
|
||||
#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 /* no longer in use ?! */
|
||||
#define ER_MAX_PREPARED_STMT_COUNT_REACHED 1461
|
||||
#define ER_VIEW_RECURSIVE 1462
|
||||
#define ER_NON_GROUPING_FIELD_USED 1463
|
||||
#define ER_TABLE_CANT_HANDLE_SPKEYS 1464
|
||||
#define ER_NO_TRIGGERS_ON_SYSTEM_SCHEMA 1465
|
||||
#define ER_REMOVED_SPACES 1466
|
||||
#define ER_AUTOINC_READ_FAILED 1467
|
||||
#define ER_USERNAME 1468
|
||||
#define ER_HOSTNAME 1469
|
||||
#define ER_WRONG_STRING_LENGTH 1470
|
||||
#define ER_NON_INSERTABLE_TABLE 1471
|
||||
#define ER_ADMIN_WRONG_MRG_TABLE 1472
|
||||
#define ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT 1473
|
||||
#define ER_NAME_BECOMES_EMPTY 1474
|
||||
#define ER_AMBIGUOUS_FIELD_TERM 1475
|
||||
#define ER_FOREIGN_SERVER_EXISTS 1476
|
||||
#define ER_FOREIGN_SERVER_DOESNT_EXIST 1477
|
||||
#define ER_ILLEGAL_HA_CREATE_OPTION 1478
|
||||
#define ER_PARTITION_REQUIRES_VALUES_ERROR 1479
|
||||
#define ER_PARTITION_WRONG_VALUES_ERROR 1480
|
||||
#define ER_PARTITION_MAXVALUE_ERROR 1481
|
||||
#define ER_PARTITION_SUBPARTITION_ERROR 1482 /* no longer in use ?! */
|
||||
#define ER_PARTITION_SUBPART_MIX_ERROR 1483 /* no longer in use ?! */
|
||||
#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 ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR 1487 /* no longer in use ?! */
|
||||
#define ER_FIELD_NOT_FOUND_PART_ERROR 1488
|
||||
#define ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR 1489 /* no longer in use ?! */
|
||||
#define ER_INCONSISTENT_PARTITION_INFO_ERROR 1490
|
||||
#define ER_PARTITION_FUNC_NOT_ALLOWED_ERROR 1491
|
||||
#define ER_PARTITIONS_MUST_BE_DEFINED_ERROR 1492
|
||||
#define ER_RANGE_NOT_INCREASING_ERROR 1493
|
||||
#define ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR 1494 /* no longer in use ?! */
|
||||
#define ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR 1495
|
||||
#define ER_PARTITION_ENTRY_ERROR 1496
|
||||
#define ER_MIX_HANDLER_ERROR 1497
|
||||
#define ER_PARTITION_NOT_DEFINED_ERROR 1498
|
||||
#define ER_TOO_MANY_PARTITIONS_ERROR 1499
|
||||
#define ER_SUBPARTITION_ERROR 1500
|
||||
#define ER_CANT_CREATE_HANDLER_FILE 1501
|
||||
#define ER_BLOB_FIELD_IN_PART_FUNC_ERROR 1502
|
||||
#define ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF 1503
|
||||
#define ER_NO_PARTS_ERROR 1504
|
||||
#define ER_PARTITION_MGMT_ON_NONPARTITIONED 1505
|
||||
#define ER_FOREIGN_KEY_ON_PARTITIONED 1506
|
||||
#define ER_DROP_PARTITION_NON_EXISTENT 1507
|
||||
#define ER_DROP_LAST_PARTITION 1508
|
||||
#define ER_COALESCE_ONLY_ON_HASH_PARTITION 1509
|
||||
#define ER_REORG_HASH_ONLY_ON_SAME_NO 1510
|
||||
#define ER_REORG_NO_PARAM_ERROR 1511
|
||||
#define ER_ONLY_ON_RANGE_LIST_PARTITION 1512
|
||||
#define ER_ADD_PARTITION_SUBPART_ERROR 1513
|
||||
#define ER_ADD_PARTITION_NO_NEW_PARTITION 1514
|
||||
#define ER_COALESCE_PARTITION_NO_PARTITION 1515
|
||||
#define ER_REORG_PARTITION_NOT_EXIST 1516
|
||||
#define ER_SAME_NAME_PARTITION 1517
|
||||
#define ER_NO_BINLOG_ERROR 1518
|
||||
#define ER_CONSECUTIVE_REORG_PARTITIONS 1519
|
||||
#define ER_REORG_OUTSIDE_RANGE 1520
|
||||
#define ER_PARTITION_FUNCTION_FAILURE 1521
|
||||
#define ER_PART_STATE_ERROR 1522 /* no longer in use ?! */
|
||||
#define ER_LIMITED_PART_RANGE 1523
|
||||
#define ER_PLUGIN_IS_NOT_LOADED 1524
|
||||
#define ER_WRONG_VALUE 1525
|
||||
#define ER_NO_PARTITION_FOR_GIVEN_VALUE 1526
|
||||
#define ER_FILEGROUP_OPTION_ONLY_ONCE 1527
|
||||
#define ER_CREATE_FILEGROUP_FAILED 1528
|
||||
#define ER_DROP_FILEGROUP_FAILED 1529
|
||||
#define ER_TABLESPACE_AUTO_EXTEND_ERROR 1530
|
||||
#define ER_WRONG_SIZE_NUMBER 1531
|
||||
#define ER_SIZE_OVERFLOW_ERROR 1532
|
||||
#define ER_ALTER_FILEGROUP_FAILED 1533
|
||||
#define ER_BINLOG_ROW_LOGGING_FAILED 1534
|
||||
#define ER_BINLOG_ROW_WRONG_TABLE_DEF 1535 /* no longer in use ?! */
|
||||
#define ER_BINLOG_ROW_RBR_TO_SBR 1536 /* no longer in use ?! */
|
||||
#define ER_EVENT_ALREADY_EXISTS 1537
|
||||
#define ER_EVENT_STORE_FAILED 1538
|
||||
#define ER_EVENT_DOES_NOT_EXIST 1539
|
||||
#define ER_EVENT_CANT_ALTER 1540 /* no longer in use ?! */
|
||||
#define ER_EVENT_DROP_FAILED 1541 /* no longer in use ?! */
|
||||
#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 ER_EVENT_OPEN_TABLE_FAILED 1545
|
||||
#define ER_EVENT_NEITHER_M_EXPR_NOR_M_AT 1546 /* no longer in use ?! */
|
||||
#define ER_COL_COUNT_DOESNT_MATCH_CORRUPTED 1547
|
||||
#define ER_CANNOT_LOAD_FROM_TABLE 1548
|
||||
#define ER_EVENT_CANNOT_DELETE 1549 /* no longer in use ?! */
|
||||
#define ER_EVENT_COMPILE_ERROR 1550 /* no longer in use ?! */
|
||||
#define ER_EVENT_SAME_NAME 1551
|
||||
#define ER_EVENT_DATA_TOO_LONG 1552
|
||||
#define ER_DROP_INDEX_FK 1553
|
||||
#define ER_WARN_DEPRECATED_SYNTAX_WITH_VER 1554 /* no longer in use ?! */
|
||||
#define ER_CANT_WRITE_LOCK_LOG_TABLE 1555 /* no longer in use ?! */
|
||||
#define ER_CANT_LOCK_LOG_TABLE 1556
|
||||
#define ER_FOREIGN_DUPLICATE_KEY 1557
|
||||
#define ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE 1558
|
||||
#define ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR 1559
|
||||
#define ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT 1560
|
||||
#define ER_NDB_CANT_SWITCH_BINLOG_FORMAT 1561 /* no longer in use ?! */
|
||||
#define ER_PARTITION_NO_TEMPORARY 1562
|
||||
#define ER_PARTITION_CONST_DOMAIN_ERROR 1563
|
||||
#define ER_PARTITION_FUNCTION_IS_NOT_ALLOWED 1564
|
||||
#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_ISOLATION 1568 /* no longer in use ?! */
|
||||
#define ER_DUP_ENTRY_AUTOINCREMENT_CASE 1569
|
||||
#define ER_EVENT_MODIFY_QUEUE_ERROR 1570 /* no longer in use ?! */
|
||||
#define ER_EVENT_SET_VAR_ERROR 1571
|
||||
#define ER_PARTITION_MERGE_ERROR 1572
|
||||
#define ER_CANT_ACTIVATE_LOG 1573 /* no longer in use ?! */
|
||||
#define ER_RBR_NOT_AVAILABLE 1574 /* no longer in use ?! */
|
||||
#define ER_BASE64_DECODE_ERROR 1575
|
||||
#define ER_EVENT_RECURSION_FORBIDDEN 1576
|
||||
#define ER_EVENTS_DB_ERROR 1577
|
||||
#define ER_ONLY_INTEGERS_ALLOWED 1578
|
||||
#define ER_UNSUPORTED_LOG_ENGINE 1579
|
||||
#define ER_BAD_LOG_STATEMENT 1580
|
||||
#define ER_CANT_RENAME_LOG_TABLE 1581
|
||||
#define ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT 1582
|
||||
#define ER_WRONG_PARAMETERS_TO_NATIVE_FCT 1583
|
||||
#define ER_WRONG_PARAMETERS_TO_STORED_FCT 1584
|
||||
#define ER_NATIVE_FCT_NAME_COLLISION 1585
|
||||
#define ER_DUP_ENTRY_WITH_KEY_NAME 1586
|
||||
#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 ER_SLAVE_INCIDENT 1590
|
||||
#define ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT 1591
|
||||
#define ER_BINLOG_UNSAFE_STATEMENT 1592
|
||||
#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 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 ER_CANT_CREATE_SROUTINE 1607
|
||||
#define ER_NEVER_USED 1608 /* no longer in use ?! */
|
||||
#define ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT 1609
|
||||
#define ER_SLAVE_CORRUPT_EVENT 1610
|
||||
#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 ER_DELAYED_NOT_SUPPORTED 1616
|
||||
#define WARN_NO_MASTER_INFO 1617
|
||||
#define WARN_OPTION_IGNORED 1618
|
||||
#define WARN_PLUGIN_DELETE_BUILTIN 1619
|
||||
#define WARN_PLUGIN_BUSY 1620
|
||||
#define ER_VARIABLE_IS_READONLY 1621
|
||||
#define ER_WARN_ENGINE_TRANSACTION_ROLLBACK 1622 /* no longer in use ?! */
|
||||
#define ER_SLAVE_HEARTBEAT_FAILURE 1623
|
||||
#define ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE 1624
|
||||
#define ER_NDB_REPLICATION_SCHEMA_ERROR 1625 /* no longer in use ?! */
|
||||
#define ER_CONFLICT_FN_PARSE_ERROR 1626 /* no longer in use ?! */
|
||||
#define ER_EXCEPTIONS_WRITE_ERROR 1627 /* no longer in use ?! */
|
||||
#define ER_TOO_LONG_TABLE_COMMENT 1628
|
||||
#define ER_TOO_LONG_FIELD_COMMENT 1629
|
||||
#define ER_FUNC_INEXISTENT_NAME_COLLISION 1630
|
||||
#define ER_DATABASE_NAME 1631
|
||||
#define ER_TABLE_NAME 1632
|
||||
#define ER_PARTITION_NAME 1633
|
||||
#define ER_SUBPARTITION_NAME 1634
|
||||
#define ER_TEMPORARY_NAME 1635
|
||||
#define ER_RENAMED_NAME 1636
|
||||
#define ER_TOO_MANY_CONCURRENT_TRXS 1637
|
||||
#define WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED 1638
|
||||
#define ER_DEBUG_SYNC_TIMEOUT 1639
|
||||
#define ER_DEBUG_SYNC_HIT_LIMIT 1640
|
||||
#define ER_DUP_SIGNAL_SET 1641
|
||||
#define ER_SIGNAL_WARN 1642
|
||||
#define ER_SIGNAL_NOT_FOUND 1643
|
||||
#define ER_SIGNAL_EXCEPTION 1644
|
||||
#define ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER 1645
|
||||
#define ER_SIGNAL_BAD_CONDITION_TYPE 1646
|
||||
#define WARN_COND_ITEM_TRUNCATED 1647
|
||||
#define ER_COND_ITEM_TOO_LONG 1648
|
||||
#define ER_UNKNOWN_LOCALE 1649
|
||||
#define ER_SLAVE_IGNORE_SERVER_IDS 1650
|
||||
#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
|
||||
#define ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR 1655
|
||||
#define ER_MAXVALUE_IN_VALUES_IN 1656
|
||||
#define ER_TOO_MANY_VALUES_ERROR 1657
|
||||
#define ER_ROW_SINGLE_PARTITION_FIELD_ERROR 1658
|
||||
#define ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD 1659
|
||||
#define ER_PARTITION_FIELDS_TOO_LONG 1660
|
||||
#define ER_BINLOG_ROW_ENGINE_AND_STMT_ENGINE 1661
|
||||
#define ER_BINLOG_ROW_MODE_AND_STMT_ENGINE 1662
|
||||
#define ER_BINLOG_UNSAFE_AND_STMT_ENGINE 1663
|
||||
#define ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE 1664
|
||||
#define ER_BINLOG_STMT_MODE_AND_ROW_ENGINE 1665
|
||||
#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 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
|
||||
#define ER_BINLOG_UNSAFE_SYSTEM_VARIABLE 1673
|
||||
#define ER_BINLOG_UNSAFE_SYSTEM_FUNCTION 1674
|
||||
#define ER_BINLOG_UNSAFE_NONTRANS_AFTER_TRANS 1675
|
||||
#define ER_MESSAGE_AND_STATEMENT 1676
|
||||
#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
|
||||
#define ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT 1681
|
||||
#define ER_WRONG_NATIVE_TABLE_STRUCTURE 1682
|
||||
#define ER_WRONG_PERFSCHEMA_USAGE 1683
|
||||
#define ER_WARN_I_S_SKIPPED_TABLE 1684
|
||||
#define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT 1685
|
||||
#define ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_DIRECT 1686
|
||||
#define ER_SPATIAL_MUST_HAVE_GEOM_COL 1687 /* no longer in use ?! */
|
||||
#define ER_TOO_LONG_INDEX_COMMENT 1688
|
||||
#define ER_LOCK_ABORTED 1689
|
||||
#define ER_DATA_OUT_OF_RANGE 1690 /* no longer in use ?! */
|
||||
#define ER_WRONG_SPVAR_TYPE_IN_LIMIT 1691
|
||||
#define ER_BINLOG_UNSAFE_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE 1692
|
||||
#define ER_BINLOG_UNSAFE_MIXED_STATEMENT 1693
|
||||
#define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN 1694
|
||||
#define ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN 1695
|
||||
#define ER_FAILED_READ_FROM_PAR_FILE 1696
|
||||
#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 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
|
||||
#define ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAX 1704
|
||||
#define ER_STMT_CACHE_FULL 1705
|
||||
#define ER_MULTI_UPDATE_KEY_CONFLICT 1706
|
||||
#define ER_TABLE_NEEDS_REBUILD 1707
|
||||
#define WARN_OPTION_BELOW_LIMIT 1708
|
||||
#define ER_INDEX_COLUMN_TOO_LONG 1709
|
||||
#define ER_ERROR_IN_TRIGGER_BODY 1710
|
||||
#define ER_ERROR_IN_UNKNOWN_TRIGGER_BODY 1711
|
||||
#define ER_INDEX_CORRUPT 1712
|
||||
#define ER_UNDO_RECORD_TOO_BIG 1713
|
||||
#define ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT 1714
|
||||
#define ER_BINLOG_UNSAFE_INSERT_SELECT_UPDATE 1715
|
||||
#define ER_BINLOG_UNSAFE_REPLACE_SELECT 1716
|
||||
#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 /* no longer in use ?! */
|
||||
#define ER_PLUGIN_NO_INSTALL 1721 /* no longer in use ?! */
|
||||
#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_UNUSED_1 1726 /* not in use ?! */
|
||||
#define ER_BINLOG_UNSAFE_AUTOINC_NOT_FIRST 1727
|
||||
#define ER_LAST_MYSQL_ERROR_MESSAGE 1728
|
||||
|
||||
/* MariaDB only errors */
|
||||
#define ER_VCOL_BASED_ON_VCOL 1900
|
||||
#define ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED 1901
|
||||
#define ER_DATA_CONVERSION_ERROR_FOR_VIRTUAL_COLUMN 1902
|
||||
#define ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN 1903
|
||||
#define ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN 1904
|
||||
#define ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN 1905
|
||||
#define ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN 1906
|
||||
#define ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN 1907
|
||||
#define ER_CONST_EXPR_IN_VCOL 1908
|
||||
#define ER_ROW_EXPR_FOR_VCOL 1909
|
||||
#define ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS 1910
|
||||
#define ER_UNKNOWN_OPTION 1911
|
||||
#define ER_BAD_OPTION_VALUE 1912
|
||||
#define ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE 1913
|
||||
#define ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE 1914
|
||||
#define ER_CANT_DO_ONLINE 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_INTERNAL_ERROR 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_GEOMETRY_SRID_MISMATCH 1933
|
||||
#define ER_NO_SUCH_SPATIAL_REF_ID 1934
|
69
module/Vendor/MDBC/include/mysys_err.h
vendored
Normal file
69
module/Vendor/MDBC/include/mysys_err.h
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
/* 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 _mysys_err_h
|
||||
#define _mysys_err_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define GLOB 0 /* Error maps */
|
||||
#define GLOBERRS EE_LASTERROR - EE_FIRSTERROR + 1 /* Max number of error messages in map's */
|
||||
#define EE(X) globerrs[ (X) - EE_FIRSTERROR ] /* Defines to add error to right map */
|
||||
|
||||
extern const char * NEAR globerrs[]; /* my_error_messages is here */
|
||||
|
||||
/* Error message numbers in global map
|
||||
|
||||
*/
|
||||
#define EE_FIRSTERROR 1
|
||||
#define EE_CANTCREATEFILE 1
|
||||
#define EE_READ 2
|
||||
#define EE_WRITE 3
|
||||
#define EE_BADCLOSE 4
|
||||
#define EE_OUTOFMEMORY 5
|
||||
#define EE_DELETE 6
|
||||
#define EE_LINK 7
|
||||
#define EE_EOFERR 9
|
||||
#define EE_CANTLOCK 10
|
||||
#define EE_CANTUNLOCK 11
|
||||
#define EE_DIR 12
|
||||
#define EE_STAT 13
|
||||
#define EE_CANT_CHSIZE 14
|
||||
#define EE_CANT_OPEN_STREAM 15
|
||||
#define EE_GETWD 16
|
||||
#define EE_SETWD 17
|
||||
#define EE_LINK_WARNING 18
|
||||
#define EE_OPEN_WARNING 19
|
||||
#define EE_DISK_FULL 20
|
||||
#define EE_CANT_MKDIR 21
|
||||
#define EE_UNKNOWN_CHARSET 22
|
||||
#define EE_OUT_OF_FILERESOURCES 23
|
||||
#define EE_CANT_READLINK 24
|
||||
#define EE_CANT_SYMLINK 25
|
||||
#define EE_REALPATH 26
|
||||
#define EE_SYNC 27
|
||||
#define EE_UNKNOWN_COLLATION 28
|
||||
#define EE_FILENOTFOUND 29
|
||||
#define EE_FILE_NOT_CLOSED 30
|
||||
#define EE_CANT_CHMOD 31
|
||||
#define EE_LASTERROR 31
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
41
module/Vendor/MDBC/include/sha1.h
vendored
Normal file
41
module/Vendor/MDBC/include/sha1.h
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/****************************************************************************
|
||||
Copyright (C) 2012 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 <http://www.gnu.org/licenses>
|
||||
or write to the Free Software Foundation, Inc.,
|
||||
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
|
||||
*****************************************************************************/
|
||||
|
||||
/* This code came from the PHP project, initially written by
|
||||
Stefan Esser */
|
||||
|
||||
#ifndef SHA1_H
|
||||
#define SHA1_H
|
||||
|
||||
#define SHA1_MAX_LENGTH 20
|
||||
#define SCRAMBLE_LENGTH 20
|
||||
#define SCRAMBLE_LENGTH_323 8
|
||||
|
||||
/* SHA1 context. */
|
||||
typedef struct {
|
||||
uint32 state[5]; /* state (ABCD) */
|
||||
uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */
|
||||
unsigned char buffer[64]; /* input buffer */
|
||||
} MYSQL_SHA1_CTX;
|
||||
|
||||
void MYSQL_SHA1Init(MYSQL_SHA1_CTX *);
|
||||
void MYSQL_SHA1Update(MYSQL_SHA1_CTX *, const unsigned char *, size_t);
|
||||
void MYSQL_SHA1Final(unsigned char[20], MYSQL_SHA1_CTX *);
|
||||
|
||||
#endif
|
112
module/Vendor/MDBC/include/thr_alarm.h
vendored
Normal file
112
module/Vendor/MDBC/include/thr_alarm.h
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
/* 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 */
|
||||
|
||||
/* Prototypes when using thr_alarm library functions */
|
||||
|
||||
#ifndef _thr_alarm_h
|
||||
#define _thr_alarm_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef USE_ALARM_THREAD
|
||||
#define USE_ONE_SIGNAL_HAND /* One must call process_alarm */
|
||||
#endif
|
||||
#ifdef HAVE_LINUXTHREADS
|
||||
#define THR_CLIENT_ALARM SIGALRM
|
||||
#else
|
||||
#define THR_CLIENT_ALARM SIGUSR1
|
||||
#endif
|
||||
#ifdef HAVE_rts_threads
|
||||
#undef USE_ONE_SIGNAL_HAND
|
||||
#define USE_ALARM_THREAD
|
||||
#define THR_SERVER_ALARM SIGUSR1
|
||||
#else
|
||||
#define THR_SERVER_ALARM SIGALRM
|
||||
#endif
|
||||
|
||||
#if defined(DONT_USE_THR_ALARM)
|
||||
|
||||
#define USE_ALARM_THREAD
|
||||
#undef USE_ONE_SIGNAL_HAND
|
||||
|
||||
typedef struct st_thr_alarm_entry
|
||||
{
|
||||
uint crono;
|
||||
} thr_alarm_entry;
|
||||
|
||||
#define thr_alarm_init(A) (A)->crono=0
|
||||
#define thr_alarm_in_use(A) (A)->crono
|
||||
#define init_thr_alarm(A)
|
||||
#define thr_alarm_kill(A)
|
||||
#define end_thr_alarm()
|
||||
#define thr_alarm(A,B) (((A)->crono=1)-1)
|
||||
#define thr_got_alarm(A) (A)->crono
|
||||
#define thr_end_alarm(A)
|
||||
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
typedef struct st_thr_alarm_entry
|
||||
{
|
||||
rf_SetTimer crono;
|
||||
} thr_alarm_entry;
|
||||
|
||||
#elif defined(__EMX__) || defined(OS2)
|
||||
|
||||
typedef struct st_thr_alarm_entry
|
||||
{
|
||||
uint crono;
|
||||
uint event;
|
||||
} thr_alarm_entry;
|
||||
|
||||
#else /* System with posix threads */
|
||||
|
||||
typedef int thr_alarm_entry;
|
||||
|
||||
#define thr_got_alarm(thr_alarm) (**(thr_alarm))
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
typedef thr_alarm_entry* thr_alarm_t;
|
||||
|
||||
typedef struct st_alarm {
|
||||
ulong expire_time;
|
||||
thr_alarm_entry alarmed; /* set when alarm is due */
|
||||
pthread_t thread;
|
||||
my_bool malloced;
|
||||
} ALARM;
|
||||
|
||||
#define thr_alarm_init(A) (*(A))=0
|
||||
#define thr_alarm_in_use(A) (*(A)!= 0)
|
||||
void init_thr_alarm(uint max_alarm);
|
||||
bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
|
||||
void thr_alarm_kill(pthread_t thread_id);
|
||||
void thr_end_alarm(thr_alarm_t *alarmed);
|
||||
void end_thr_alarm(void);
|
||||
sig_handler process_alarm(int);
|
||||
#ifndef thr_got_alarm
|
||||
bool thr_got_alarm(thr_alarm_t *alrm);
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* DONT_USE_THR_ALARM */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* _thr_alarm_h */
|
||||
|
167
module/Vendor/MDBC/include/violite.h
vendored
Normal file
167
module/Vendor/MDBC/include/violite.h
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
/* 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 */
|
||||
|
||||
/*
|
||||
* Vio Lite.
|
||||
* Purpose: include file for Vio that will work with C and C++
|
||||
*/
|
||||
|
||||
#ifndef vio_violite_h_
|
||||
#define vio_violite_h_
|
||||
|
||||
|
||||
|
||||
#include "my_net.h" /* needed because of struct in_addr */
|
||||
|
||||
#ifdef HAVE_VIO
|
||||
#include <Vio.h> /* Full VIO interface */
|
||||
#else
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
#include <openssl/ssl.h>
|
||||
#endif
|
||||
|
||||
enum enum_vio_io_event
|
||||
{
|
||||
VIO_IO_EVENT_READ,
|
||||
VIO_IO_EVENT_WRITE,
|
||||
VIO_IO_EVENT_CONNECT
|
||||
};
|
||||
|
||||
/* Simple vio interface in C; The functions are implemented in violite.c */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef Vio_defined
|
||||
#define Vio_defined
|
||||
struct st_vio; /* Only C */
|
||||
typedef struct st_vio Vio;
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#define HANDLE void *
|
||||
#endif
|
||||
|
||||
/* vio read-ahead cachine */
|
||||
#define VIO_CACHE_SIZE 16384
|
||||
#define VIO_CACHE_MIN_SIZE 2048
|
||||
|
||||
enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
|
||||
VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
|
||||
|
||||
Vio* vio_new(my_socket sd,
|
||||
enum enum_vio_type type,
|
||||
my_bool localhost);
|
||||
#ifdef _WIN32
|
||||
Vio* vio_new_win32pipe(HANDLE hPipe);
|
||||
#endif
|
||||
void vio_delete(Vio* vio);
|
||||
void vio_reset(Vio* vio, enum enum_vio_type type,
|
||||
my_socket sd, HANDLE hPipe,
|
||||
my_bool localhost);
|
||||
|
||||
/*
|
||||
* vio_read and vio_write should have the same semantics
|
||||
* as read(2) and write(2).
|
||||
*/
|
||||
size_t vio_read(Vio* vio, gptr buf, size_t size);
|
||||
my_bool vio_read_peek(Vio *vio, size_t *bytes);
|
||||
size_t vio_write(Vio* vio, const gptr buf, size_t size);
|
||||
/*
|
||||
* Whenever the socket is set to blocking mode or not.
|
||||
*/
|
||||
int vio_blocking( Vio* vio,
|
||||
my_bool onoff,
|
||||
my_bool *prevmode);
|
||||
my_bool vio_is_blocking( Vio* vio);
|
||||
/*
|
||||
* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible.
|
||||
*/
|
||||
int vio_fastsend( Vio* vio);
|
||||
/*
|
||||
* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible.
|
||||
*/
|
||||
int vio_keepalive( Vio* vio,
|
||||
my_bool onoff);
|
||||
/*
|
||||
* Whenever we should retry the last read/write operation.
|
||||
*/
|
||||
my_bool vio_should_retry( Vio* vio);
|
||||
/*
|
||||
* When the workday is over...
|
||||
*/
|
||||
int vio_close( Vio* vio);
|
||||
/*
|
||||
* Short text description of the socket for those, who are curious..
|
||||
*/
|
||||
const char* vio_description( Vio* vio);
|
||||
|
||||
/* Return the type of the connection */
|
||||
enum enum_vio_type vio_type(Vio* vio);
|
||||
|
||||
/* set timeout */
|
||||
void vio_read_timeout(Vio *vio, uint seconds);
|
||||
void vio_write_timeout(Vio *vio, uint seconds);
|
||||
|
||||
/* Return last error number */
|
||||
int vio_errno(Vio *vio);
|
||||
|
||||
/* Get socket number */
|
||||
my_socket vio_fd(Vio *vio);
|
||||
|
||||
/*
|
||||
* Remote peer's address and name in text form.
|
||||
*/
|
||||
my_bool vio_peer_addr(Vio * vio, char *buf);
|
||||
|
||||
/* Remotes in_addr */
|
||||
|
||||
void vio_in_addr(Vio *vio, struct in_addr *in);
|
||||
|
||||
/* Return 1 if there is data to be read */
|
||||
my_bool vio_poll_read(Vio *vio,uint timeout);
|
||||
int vio_wait_or_timeout(Vio *vio, my_bool is_read, int timeout);
|
||||
|
||||
|
||||
struct st_vio
|
||||
{
|
||||
my_socket sd; /* my_socket - real or imaginary */
|
||||
HANDLE hPipe;
|
||||
my_bool localhost; /* Are we from localhost? */
|
||||
int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
|
||||
struct sockaddr_in local; /* Local internet address */
|
||||
struct sockaddr_in remote; /* Remote internet address */
|
||||
struct mysql_async_context *async_context; /* For non-blocking API */
|
||||
unsigned int write_timeout;
|
||||
unsigned int read_timeout;
|
||||
enum enum_vio_type type; /* Type of connection */
|
||||
char desc[30]; /* String description */
|
||||
#ifdef HAVE_OPENSSL
|
||||
SSL *ssl;
|
||||
#endif
|
||||
uchar *cache; /* read-ahead cache to reduce reads (see CONC-79) */
|
||||
uchar *cache_pos; /* position of read-ahead cached data */
|
||||
size_t cache_size; /* <= VIO_CACHE_SIZE */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_VIO */
|
||||
#endif /* vio_violite_h_ */
|
468
module/Vendor/MDBC/libmariadb/CMakeLists.txt
vendored
Normal file
468
module/Vendor/MDBC/libmariadb/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,468 @@
|
||||
INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include
|
||||
${ZLIB_INC}
|
||||
${CC_SOURCE_DIR}/libmariadb)
|
||||
|
||||
ADD_DEFINITIONS(-D ENABLED_LOCAL_INFILE)
|
||||
ADD_DEFINITIONS(-D HAVE_COMPRESS)
|
||||
ADD_DEFINITIONS(-D LIBMARIADB)
|
||||
ADD_DEFINITIONS(-D THREAD)
|
||||
|
||||
SET(EXPORT_SYMBOLS
|
||||
load_defaults
|
||||
mariadb_connection
|
||||
mariadb_convert_string
|
||||
mariadb_dyncol_check
|
||||
mariadb_dyncol_column_cmp_named
|
||||
mariadb_dyncol_column_count
|
||||
mariadb_dyncol_create_many_named
|
||||
mariadb_dyncol_create_many_num
|
||||
mariadb_dyncol_exists_named
|
||||
mariadb_dyncol_exists_num
|
||||
mariadb_dyncol_free
|
||||
mariadb_dyncol_get_named
|
||||
mariadb_dyncol_get_num
|
||||
mariadb_dyncol_has_names
|
||||
mariadb_dyncol_json
|
||||
mariadb_dyncol_list_named
|
||||
mariadb_dyncol_list_num
|
||||
mariadb_dyncol_unpack
|
||||
mariadb_dyncol_update_many_named
|
||||
mariadb_dyncol_update_many_num
|
||||
mariadb_dyncol_val_double
|
||||
mariadb_dyncol_val_long
|
||||
mariadb_dyncol_val_str
|
||||
myodbc_remove_escape
|
||||
mysql_affected_rows
|
||||
mysql_autocommit
|
||||
mysql_autocommit_cont
|
||||
mysql_autocommit_start
|
||||
mysql_change_user
|
||||
mysql_change_user_cont
|
||||
mysql_change_user_start
|
||||
mysql_character_set_name
|
||||
mysql_client_find_plugin
|
||||
mysql_client_register_plugin
|
||||
mysql_close
|
||||
mysql_close_cont
|
||||
mysql_close_start
|
||||
mysql_commit
|
||||
mysql_commit_cont
|
||||
mysql_commit_start
|
||||
mysql_data_seek
|
||||
mysql_debug
|
||||
mysql_dump_debug_info
|
||||
mysql_dump_debug_info_cont
|
||||
mysql_dump_debug_info_start
|
||||
mysql_eof
|
||||
mysql_errno
|
||||
mysql_error
|
||||
mysql_escape_string
|
||||
mysql_fetch_field
|
||||
mysql_fetch_field_direct
|
||||
mysql_fetch_fields
|
||||
mysql_fetch_lengths
|
||||
mysql_fetch_row
|
||||
mysql_fetch_row_cont
|
||||
mysql_fetch_row_start
|
||||
mysql_field_count
|
||||
mysql_field_seek
|
||||
mysql_field_tell
|
||||
mysql_free_result
|
||||
mysql_free_result_cont
|
||||
mysql_free_result_start
|
||||
mysql_get_character_set_info
|
||||
mysql_get_charset_by_name
|
||||
mysql_get_charset_by_nr
|
||||
mysql_get_client_info
|
||||
mysql_get_client_version
|
||||
mysql_get_host_info
|
||||
mysql_get_parameters
|
||||
mysql_get_proto_info
|
||||
mysql_get_server_info
|
||||
mysql_get_server_name
|
||||
mysql_get_server_version
|
||||
mysql_get_socket
|
||||
mysql_get_ssl_cipher
|
||||
mysql_get_timeout_value
|
||||
mysql_get_timeout_value_ms
|
||||
mysql_hex_string
|
||||
mysql_info
|
||||
mysql_init
|
||||
mysql_insert_id
|
||||
mysql_kill
|
||||
mysql_kill_cont
|
||||
mysql_kill_start
|
||||
mysql_list_dbs
|
||||
mysql_list_dbs_cont
|
||||
mysql_list_dbs_start
|
||||
mysql_list_fields
|
||||
mysql_list_fields_cont
|
||||
mysql_list_fields_start
|
||||
mysql_list_processes
|
||||
mysql_list_processes_cont
|
||||
mysql_list_processes_start
|
||||
mysql_list_tables
|
||||
mysql_list_tables_cont
|
||||
mysql_list_tables_start
|
||||
mysql_load_plugin;
|
||||
mysql_load_plugin_v
|
||||
mysql_more_results
|
||||
mysql_next_result
|
||||
mysql_next_result_cont
|
||||
mysql_next_result_start
|
||||
mysql_num_fields
|
||||
mysql_num_rows
|
||||
mysql_options
|
||||
mysql_optionsv
|
||||
mysql_ping
|
||||
mysql_ping_cont
|
||||
mysql_ping_start
|
||||
mysql_ps_fetch_functions
|
||||
mysql_query
|
||||
mysql_query_cont
|
||||
mysql_query_start
|
||||
mysql_read_query_result
|
||||
mysql_read_query_result_cont
|
||||
mysql_read_query_result_start
|
||||
mysql_real_connect
|
||||
mysql_real_connect_cont
|
||||
mysql_real_connect_start
|
||||
mysql_real_escape_string
|
||||
mysql_real_query
|
||||
mysql_real_query_cont
|
||||
mysql_real_query_start
|
||||
mysql_refresh
|
||||
mysql_refresh_cont
|
||||
mysql_refresh_start
|
||||
mysql_rollback
|
||||
mysql_rollback_cont
|
||||
mysql_rollback_start
|
||||
mysql_row_seek
|
||||
mysql_row_tell
|
||||
mysql_select_db
|
||||
mysql_select_db_cont
|
||||
mysql_select_db_start
|
||||
mysql_send_query
|
||||
mysql_send_query_cont
|
||||
mysql_send_query_start
|
||||
mysql_server_end
|
||||
mysql_server_init
|
||||
mysql_set_character_set
|
||||
mysql_set_character_set_cont
|
||||
mysql_set_character_set_start
|
||||
mysql_set_local_infile_default
|
||||
mysql_set_local_infile_handler
|
||||
mysql_set_server_option
|
||||
mysql_set_server_option_cont
|
||||
mysql_set_server_option_start
|
||||
mysql_shutdown
|
||||
mysql_shutdown_cont
|
||||
mysql_shutdown_start
|
||||
mysql_sqlstate
|
||||
mysql_ssl_set
|
||||
mysql_stat
|
||||
mysql_stat_cont
|
||||
mysql_stat_start
|
||||
mysql_stmt_affected_rows
|
||||
mysql_stmt_attr_get
|
||||
mysql_stmt_attr_set
|
||||
mysql_stmt_bind_param
|
||||
mysql_stmt_bind_result
|
||||
mysql_stmt_close
|
||||
mysql_stmt_close_cont
|
||||
mysql_stmt_close_start
|
||||
mysql_stmt_data_seek
|
||||
mysql_stmt_errno
|
||||
mysql_stmt_error
|
||||
mysql_stmt_execute
|
||||
mysql_stmt_execute_cont
|
||||
mysql_stmt_execute_start
|
||||
mysql_stmt_fetch
|
||||
mysql_stmt_fetch_column
|
||||
mysql_stmt_fetch_cont
|
||||
mysql_stmt_fetch_start
|
||||
mysql_stmt_field_count
|
||||
mysql_stmt_free_result
|
||||
mysql_stmt_free_result_cont
|
||||
mysql_stmt_free_result_start
|
||||
mysql_stmt_init
|
||||
mysql_stmt_insert_id
|
||||
mysql_stmt_more_results
|
||||
mysql_stmt_next_result
|
||||
mysql_stmt_next_result_cont
|
||||
mysql_stmt_next_result_start
|
||||
mysql_stmt_num_rows
|
||||
mysql_stmt_param_count
|
||||
mysql_stmt_param_metadata
|
||||
mysql_stmt_prepare
|
||||
mysql_stmt_prepare_cont
|
||||
mysql_stmt_prepare_start
|
||||
mysql_stmt_reset
|
||||
mysql_stmt_reset_cont
|
||||
mysql_stmt_reset_start
|
||||
mysql_stmt_result_metadata
|
||||
mysql_stmt_row_seek
|
||||
mysql_stmt_row_tell
|
||||
mysql_stmt_send_long_data
|
||||
mysql_stmt_send_long_data_cont
|
||||
mysql_stmt_send_long_data_start
|
||||
mysql_stmt_sqlstate
|
||||
mysql_stmt_store_result
|
||||
mysql_stmt_store_result_cont
|
||||
mysql_stmt_store_result_start
|
||||
mysql_store_result
|
||||
mysql_store_result_cont
|
||||
mysql_store_result_start
|
||||
mysql_thread_end
|
||||
mysql_thread_id
|
||||
mysql_thread_init
|
||||
mysql_thread_safe
|
||||
mysql_use_result
|
||||
mysql_warning_count)
|
||||
|
||||
IF(WITH_OPENSSL)
|
||||
SET(EXPORT_SYMBOLS ${EXPORT_SYMBOLS} mariadb_deinitialize_ssl)
|
||||
ENDIF()
|
||||
|
||||
IF(WIN32)
|
||||
SET(EXPORT_CONTENT "EXPORTS\n")
|
||||
FOREACH(SYMBOL ${EXPORT_SYMBOLS})
|
||||
SET(EXPORT_CONTENT "${EXPORT_CONTENT} ${SYMBOL}\n")
|
||||
ENDFOREACH()
|
||||
SET(EXPORT_FILE "${CC_BINARY_DIR}/libmariadb/exports.def")
|
||||
SET(EXPORT_LINK ${EXPORT_FILE})
|
||||
ELSE()
|
||||
SET(EXPORT_CONTENT "{\nglobal:\n")
|
||||
FOREACH(SYMBOL ${EXPORT_SYMBOLS})
|
||||
SET(EXPORT_CONTENT "${EXPORT_CONTENT} ${SYMBOL}\\;\n")
|
||||
ENDFOREACH()
|
||||
SET(EXPORT_FILE "${CC_BINARY_DIR}/libmariadb/exports.txt")
|
||||
SET(EXPORT_CONTENT "${EXPORT_CONTENT}local:\n *\\;\n}\\;")
|
||||
ENDIF()
|
||||
|
||||
FILE(WRITE ${EXPORT_FILE} ${EXPORT_CONTENT})
|
||||
|
||||
SET(LIBMARIADB_SOURCES
|
||||
array.c
|
||||
ma_dyncol.c
|
||||
bchange.c
|
||||
bmove.c
|
||||
bmove_upp.c
|
||||
my_charset.c
|
||||
hash.c
|
||||
violite.c
|
||||
net.c
|
||||
charset.c
|
||||
ma_time.c
|
||||
dbug.c
|
||||
default.c
|
||||
errmsg.c
|
||||
my_vsnprintf.c
|
||||
errors.c
|
||||
getopt1.c
|
||||
getopt.c
|
||||
int2str.c
|
||||
is_prefix.c
|
||||
libmariadb.c
|
||||
list.c
|
||||
llstr.c
|
||||
longlong2str.c
|
||||
ma_dtoa.c
|
||||
mf_dirname.c
|
||||
mf_fn_ext.c
|
||||
mf_format.c
|
||||
mf_loadpath.c
|
||||
mf_pack.c
|
||||
mf_path.c
|
||||
mf_unixpath.c
|
||||
mf_wcomp.c
|
||||
mulalloc.c
|
||||
my_alloc.c
|
||||
my_compress.c
|
||||
my_context.c
|
||||
my_div.c
|
||||
my_error.c
|
||||
my_fopen.c
|
||||
my_fstream.c
|
||||
my_getwd.c
|
||||
my_init.c
|
||||
my_lib.c
|
||||
my_malloc.c
|
||||
my_messnc.c
|
||||
my_net.c
|
||||
my_once.c
|
||||
my_open.c
|
||||
my_port.c
|
||||
my_pthread.c
|
||||
my_read.c
|
||||
my_realloc.c
|
||||
my_seek.c
|
||||
my_static.c
|
||||
my_symlink.c
|
||||
my_thr_init.c
|
||||
my_write.c
|
||||
mysql_async.c
|
||||
password.c
|
||||
str2int.c
|
||||
strcend.c
|
||||
strcont.c
|
||||
strend.c
|
||||
strfill.c
|
||||
string.c
|
||||
strinstr.c
|
||||
strmake.c
|
||||
strmov.c
|
||||
strnmov.c
|
||||
strtoll.c
|
||||
strtoull.c
|
||||
strxmov.c
|
||||
strxnmov.c
|
||||
thr_mutex.c
|
||||
typelib.c
|
||||
sha1.c
|
||||
my_stmt.c
|
||||
my_loaddata.c
|
||||
my_stmt_codec.c
|
||||
client_plugin.c
|
||||
my_auth.c
|
||||
)
|
||||
|
||||
# some gcc versions fail to compile asm parts of my_context.c,
|
||||
# if build type is "Release" (see CONC-133), so we need to add -g flag
|
||||
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
SET_SOURCE_FILES_PROPERTIES(my_context.c PROPERTIES COMPILE_FLAGS -g)
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(WITH_OPENSSL)
|
||||
SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ma_secure.c)
|
||||
ENDIF()
|
||||
|
||||
IF(WIN32)
|
||||
INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/win-iconv)
|
||||
SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES}
|
||||
${CC_SOURCE_DIR}/win-iconv/win_iconv.c)
|
||||
ENDIF()
|
||||
|
||||
IF(ZLIB_FOUND)
|
||||
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
|
||||
LINK_LIBRARIES(${ZLIB_LIBRARY})
|
||||
ELSE()
|
||||
#[[ SET(ZLIB_SOURCES
|
||||
../zlib/adler32.c
|
||||
../zlib/compress.c
|
||||
../zlib/crc32.c
|
||||
../zlib/deflate.c
|
||||
../zlib/gzclose.c
|
||||
../zlib/gzlib.c
|
||||
../zlib/gzread.c
|
||||
../zlib/gzwrite.c
|
||||
../zlib/infback.c
|
||||
../zlib/inffast.c
|
||||
../zlib/inflate.c
|
||||
../zlib/inftrees.c
|
||||
../zlib/trees.c
|
||||
../zlib/uncompr.c
|
||||
../zlib/zutil.c
|
||||
)]]
|
||||
#SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ${ZLIB_SOURCES})
|
||||
#INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/zlib)
|
||||
ENDIF()
|
||||
|
||||
IF(WIN32)
|
||||
SET_VERSION_INFO("TARGET:libmariadb"
|
||||
"FILE_TYPE:VFT_DLL"
|
||||
"SOURCE_FILE:libmariadb/libmariadb.c"
|
||||
"ORIGINAL_FILE_NAME:libmariadb.dll"
|
||||
"FILE_DESCRIPTION:Dynamic lib for client/server communication")
|
||||
SET_VERSION_INFO("TARGET:mariadbclient"
|
||||
"FILE_TYPE:VFT_STATIC_LIB"
|
||||
"SOURCE_FILE:libmariadb/libmariadb.c"
|
||||
"ORIGINAL_FILE_NAME:mariadbclient.lib"
|
||||
"FILE_DESCRIPTION:Static lib for client/server communication")
|
||||
ENDIF()
|
||||
|
||||
# CREATE OBJECT LIBRARY
|
||||
ADD_LIBRARY(mariadb_obj OBJECT ${LIBMARIADB_SOURCES})
|
||||
IF(UNIX)
|
||||
SET_TARGET_PROPERTIES(mariadb_obj PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
|
||||
ENDIF()
|
||||
|
||||
# Xcode doesn't support targets that have only object files,
|
||||
# so let's add an empty file to keep Xcode happy
|
||||
IF(CMAKE_GENERATOR MATCHES Xcode)
|
||||
FILE(WRITE ${CC_SOURCE_DIR}/libmariadb/empty.c "")
|
||||
SET(EMPTY_FILE ${CC_SOURCE_DIR}/libmariadb/empty.c)
|
||||
ENDIF()
|
||||
|
||||
ADD_LIBRARY(mariadbclient STATIC ${mariadbclient_RC} $<TARGET_OBJECTS:mariadb_obj> ${EMPTY_FILE} ${EXPORT_LINK})
|
||||
TARGET_LINK_LIBRARIES(mariadbclient ${SYSTEM_LIBS})
|
||||
target_include_directories(mariadbclient PUBLIC ${CC_SOURCE_DIR}/include)
|
||||
|
||||
ADD_LIBRARY(libmariadb SHARED ${libmariadb_RC} $<TARGET_OBJECTS:mariadb_obj> ${EMPTY_FILE} ${EXPORT_LINK})
|
||||
TARGET_LINK_LIBRARIES(libmariadb ${SYSTEM_LIBS})
|
||||
target_include_directories(libmariadb PUBLIC ${CC_SOURCE_DIR}/include)
|
||||
|
||||
IF(NOT ZLIB_FOUND)
|
||||
TARGET_LINK_LIBRARIES(mariadbclient zlibstatic)
|
||||
TARGET_LINK_LIBRARIES(libmariadb zlibstatic)
|
||||
ENDIF()
|
||||
|
||||
IF(UNIX)
|
||||
SET_TARGET_PROPERTIES(libmariadb PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
|
||||
ENDIF()
|
||||
SIGN_TARGET(libmariadb)
|
||||
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
TARGET_LINK_LIBRARIES (libmariadb "-Wl,--no-undefined")
|
||||
SET_TARGET_PROPERTIES(libmariadb PROPERTIES LINK_FLAGS "-Wl,--version-script=${EXPORT_FILE}")
|
||||
TARGET_LINK_LIBRARIES (mariadbclient "-Wl,--no-undefined")
|
||||
SET_TARGET_PROPERTIES(mariadbclient PROPERTIES LINK_FLAGS "-Wl,--version-script=${EXPORT_FILE}")
|
||||
ENDIF()
|
||||
|
||||
SET_TARGET_PROPERTIES(libmariadb PROPERTIES PREFIX "")
|
||||
|
||||
SET_TARGET_PROPERTIES(libmariadb PROPERTIES VERSION
|
||||
${CPACK_PACKAGE_VERSION_MAJOR}
|
||||
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
|
||||
|
||||
IF(NOT WIN32)
|
||||
SET_TARGET_PROPERTIES(mariadbclient PROPERTIES OUTPUT_NAME "${LIBMARIADB_STATIC_NAME}")
|
||||
ENDIF()
|
||||
|
||||
|
||||
#
|
||||
# Installation
|
||||
#
|
||||
INCLUDE(${CC_SOURCE_DIR}/cmake/symlink.cmake)
|
||||
|
||||
|
||||
# There are still several projects which don't make use
|
||||
# of the config program. To make sure these programs can
|
||||
# use mariadb client library we provide libmysql symlinks
|
||||
IF(NOT WIN32 AND WITH_MYSQLCOMPAT)
|
||||
SET(INSTALL_PATH ${LIB_INSTALL_DIR}/${LIBSUFFIX_INSTALL_DIR})
|
||||
create_symlink(libmysqlclient${CMAKE_SHARED_LIBRARY_SUFFIX} libmariadb ${INSTALL_PATH})
|
||||
create_symlink(libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX} libmariadb ${INSTALL_PATH})
|
||||
create_symlink(libmysqlclient${CMAKE_STATIC_LIBRARY_SUFFIX} mariadbclient ${INSTALL_PATH})
|
||||
create_symlink(libmysqlclient_r${CMAKE_STATIC_LIBRARY_SUFFIX} mariadbclient ${INSTALL_PATH})
|
||||
ENDIF()
|
||||
|
||||
|
||||
INSTALL(TARGETS
|
||||
libmariadb mariadbclient
|
||||
RUNTIME DESTINATION "${LIB_INSTALL_DIR}/${LIBSUFFIX_INSTALL_DIR}"
|
||||
LIBRARY DESTINATION "${LIB_INSTALL_DIR}/${LIBSUFFIX_INSTALL_DIR}"
|
||||
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}/${LIBSUFFIX_INSTALL_DIR}")
|
||||
|
||||
INSTALL(DIRECTORY ${CC_SOURCE_DIR}/include/
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/${SUFFIX_INSTALL_DIR}
|
||||
PATTERN "*.h.in" EXCLUDE
|
||||
PATTERN "CMakeLists.txt" EXCLUDE
|
||||
PATTERN "Makefile.am" EXCLUDE)
|
||||
INSTALL(FILES
|
||||
${CC_BINARY_DIR}/include/my_config.h
|
||||
${CC_BINARY_DIR}/include/mysql_version.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/${SUFFIX_INSTALL_DIR})
|
||||
|
||||
|
91
module/Vendor/MDBC/libmariadb/acinclude.m4
vendored
Normal file
91
module/Vendor/MDBC/libmariadb/acinclude.m4
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
# Local macros for automake & autoconf
|
||||
|
||||
AC_DEFUN(MYSQL_TYPE_ACCEPT,
|
||||
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
AC_CACHE_CHECK([base type of last arg to accept], mysql_cv_btype_last_arg_accept,
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
if test "$ac_cv_prog_gxx" = "yes"
|
||||
then
|
||||
CXXFLAGS="$CXXFLAGS -Werror"
|
||||
fi
|
||||
mysql_cv_btype_last_arg_accept=none
|
||||
[AC_TRY_COMPILE([#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
],
|
||||
[int a = accept(1, (struct sockaddr *) 0, (socklen_t *) 0);],
|
||||
mysql_cv_btype_last_arg_accept=socklen_t)]
|
||||
if test $mysql_cv_btype_last_arg_accept = none; then
|
||||
[AC_TRY_COMPILE([#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
],
|
||||
[int a = accept(1, (struct sockaddr *) 0, (size_t *) 0);],
|
||||
mysql_cv_btype_last_arg_accept=size_t)]
|
||||
fi
|
||||
if test $mysql_cv_btype_last_arg_accept = none; then
|
||||
mysql_cv_btype_last_arg_accept=int
|
||||
fi)
|
||||
AC_LANG_RESTORE
|
||||
AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $mysql_cv_btype_last_arg_accept)
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
])
|
||||
|
||||
|
||||
#---START: Used in for client configure
|
||||
AC_DEFUN(MYSQL_CHECK_ULONG,
|
||||
[AC_MSG_CHECKING(for type ulong)
|
||||
AC_CACHE_VAL(ac_cv_ulong,
|
||||
[AC_TRY_RUN([#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
main()
|
||||
{
|
||||
ulong foo;
|
||||
foo++;
|
||||
exit(0);
|
||||
}], ac_cv_ulong=yes, ac_cv_ulong=no, ac_cv_ulong=no)])
|
||||
AC_MSG_RESULT($ac_cv_ulong)
|
||||
if test "$ac_cv_ulong" = "yes"
|
||||
then
|
||||
AC_DEFINE(HAVE_ULONG)
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN(MYSQL_CHECK_UCHAR,
|
||||
[AC_MSG_CHECKING(for type uchar)
|
||||
AC_CACHE_VAL(ac_cv_uchar,
|
||||
[AC_TRY_RUN([#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
main()
|
||||
{
|
||||
uchar foo;
|
||||
foo++;
|
||||
exit(0);
|
||||
}], ac_cv_uchar=yes, ac_cv_uchar=no, ac_cv_uchar=no)])
|
||||
AC_MSG_RESULT($ac_cv_uchar)
|
||||
if test "$ac_cv_uchar" = "yes"
|
||||
then
|
||||
AC_DEFINE(HAVE_UCHAR)
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN(MYSQL_CHECK_UINT,
|
||||
[AC_MSG_CHECKING(for type uint)
|
||||
AC_CACHE_VAL(ac_cv_uint,
|
||||
[AC_TRY_RUN([#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
main()
|
||||
{
|
||||
uint foo;
|
||||
foo++;
|
||||
exit(0);
|
||||
}], ac_cv_uint=yes, ac_cv_uint=no, ac_cv_uint=no)])
|
||||
AC_MSG_RESULT($ac_cv_uint)
|
||||
if test "$ac_cv_uint" = "yes"
|
||||
then
|
||||
AC_DEFINE(HAVE_UINT)
|
||||
fi
|
||||
])
|
||||
|
||||
#---END:
|
175
module/Vendor/MDBC/libmariadb/array.c
vendored
Normal file
175
module/Vendor/MDBC/libmariadb/array.c
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
/* 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 */
|
||||
|
||||
/* Handling of arrays that can grow dynamicly. */
|
||||
|
||||
#undef SAFEMALLOC /* Problems with threads */
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#include "m_string.h"
|
||||
|
||||
/*
|
||||
Initiate array and alloc space for init_alloc elements. Array is usable
|
||||
even if space allocation failed
|
||||
*/
|
||||
|
||||
my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
|
||||
uint init_alloc, uint alloc_increment CALLER_INFO_PROTO)
|
||||
{
|
||||
DBUG_ENTER("init_dynamic_array");
|
||||
if (!alloc_increment)
|
||||
{
|
||||
alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
|
||||
if (init_alloc > 8 && alloc_increment > init_alloc * 2)
|
||||
alloc_increment=init_alloc*2;
|
||||
}
|
||||
|
||||
if (!init_alloc)
|
||||
init_alloc=alloc_increment;
|
||||
array->elements=0;
|
||||
array->max_element=init_alloc;
|
||||
array->alloc_increment=alloc_increment;
|
||||
array->size_of_element=element_size;
|
||||
if (!(array->buffer=(char*) my_malloc_ci(element_size*init_alloc,MYF(MY_WME))))
|
||||
{
|
||||
array->max_element=0;
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
|
||||
my_bool insert_dynamic(DYNAMIC_ARRAY *array, gptr element)
|
||||
{
|
||||
gptr buffer;
|
||||
if (array->elements == array->max_element)
|
||||
{ /* Call only when nessesary */
|
||||
if (!(buffer=alloc_dynamic(array)))
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer=array->buffer+(array->elements * array->size_of_element);
|
||||
array->elements++;
|
||||
}
|
||||
memcpy(buffer,element,(size_t) array->size_of_element);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Alloc room for one element */
|
||||
|
||||
unsigned char *alloc_dynamic(DYNAMIC_ARRAY *array)
|
||||
{
|
||||
if (array->elements == array->max_element)
|
||||
{
|
||||
char *new_ptr;
|
||||
if (!(new_ptr=(char*) my_realloc(array->buffer,(array->max_element+
|
||||
array->alloc_increment)*
|
||||
array->size_of_element,
|
||||
MYF(MY_WME | MY_ALLOW_ZERO_PTR))))
|
||||
return 0;
|
||||
array->buffer=new_ptr;
|
||||
array->max_element+=array->alloc_increment;
|
||||
}
|
||||
return array->buffer+(array->elements++ * array->size_of_element);
|
||||
}
|
||||
|
||||
|
||||
/* remove last element from array and return it */
|
||||
|
||||
unsigned char *pop_dynamic(DYNAMIC_ARRAY *array)
|
||||
{
|
||||
if (array->elements)
|
||||
return array->buffer+(--array->elements * array->size_of_element);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
my_bool set_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx)
|
||||
{
|
||||
if (idx >= array->elements)
|
||||
{
|
||||
if (idx >= array->max_element)
|
||||
{
|
||||
uint size;
|
||||
char *new_ptr;
|
||||
size=(idx+array->alloc_increment)/array->alloc_increment;
|
||||
size*= array->alloc_increment;
|
||||
if (!(new_ptr=(char*) my_realloc(array->buffer,size*
|
||||
array->size_of_element,
|
||||
MYF(MY_WME | MY_ALLOW_ZERO_PTR))))
|
||||
return TRUE;
|
||||
array->buffer=new_ptr;
|
||||
array->max_element=size;
|
||||
}
|
||||
bzero((gptr) (array->buffer+array->elements*array->size_of_element),
|
||||
(idx - array->elements)*array->size_of_element);
|
||||
array->elements=idx+1;
|
||||
}
|
||||
memcpy(array->buffer+(idx * array->size_of_element),element,
|
||||
(size_t) array->size_of_element);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void get_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx)
|
||||
{
|
||||
if (idx >= array->elements)
|
||||
{
|
||||
DBUG_PRINT("warning",("To big array idx: %d, array size is %d",
|
||||
idx,array->elements));
|
||||
bzero(element,array->size_of_element);
|
||||
return;
|
||||
}
|
||||
memcpy(element,array->buffer+idx*array->size_of_element,
|
||||
(size_t) array->size_of_element);
|
||||
}
|
||||
|
||||
|
||||
void delete_dynamic(DYNAMIC_ARRAY *array)
|
||||
{
|
||||
if (array->buffer)
|
||||
{
|
||||
my_free(array->buffer);
|
||||
array->buffer=0;
|
||||
array->elements=array->max_element=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx)
|
||||
{
|
||||
char *ptr=array->buffer+array->size_of_element*idx;
|
||||
array->elements--;
|
||||
memmove(ptr,ptr+array->size_of_element,
|
||||
(array->elements-idx)*array->size_of_element);
|
||||
}
|
||||
|
||||
|
||||
void freeze_size(DYNAMIC_ARRAY *array)
|
||||
{
|
||||
uint elements=max(array->elements,1);
|
||||
|
||||
if (array->buffer && array->max_element != elements)
|
||||
{
|
||||
array->buffer=(char*) my_realloc(array->buffer,
|
||||
elements*array->size_of_element,
|
||||
MYF(MY_WME));
|
||||
array->max_element=elements;
|
||||
}
|
||||
}
|
39
module/Vendor/MDBC/libmariadb/bchange.c
vendored
Normal file
39
module/Vendor/MDBC/libmariadb/bchange.c
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
/* 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 */
|
||||
|
||||
/* File : bchange.c
|
||||
Author : Michael widenius
|
||||
Updated: 1987-03-20
|
||||
Defines: bchange()
|
||||
|
||||
bchange(dst, old_length, src, new_length, tot_length)
|
||||
replaces old_length characters at dst to new_length characters from
|
||||
src in a buffer with tot_length bytes.
|
||||
*/
|
||||
|
||||
#include <my_global.h>
|
||||
#include "m_string.h"
|
||||
|
||||
void bchange(register char *dst, size_t old_length, register const char *src, size_t new_length, size_t tot_length)
|
||||
{
|
||||
size_t rest=tot_length-old_length;
|
||||
if (old_length < new_length)
|
||||
bmove_upp(dst+rest+new_length,dst+tot_length,rest);
|
||||
else
|
||||
bmove(dst+new_length,dst+old_length,rest);
|
||||
memcpy(dst,src,new_length);
|
||||
}
|
80
module/Vendor/MDBC/libmariadb/bmove.c
vendored
Normal file
80
module/Vendor/MDBC/libmariadb/bmove.c
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
/* Copyright (C) 2002 MySQL 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 : bmove.c
|
||||
Author : Richard A. O'Keefe.
|
||||
Michael Widenius; ifdef MC68000
|
||||
Updated: 23 April 1984
|
||||
Defines: bmove()
|
||||
|
||||
bmove(dst, src, len) moves exactly "len" bytes from the source "src"
|
||||
to the destination "dst". It does not check for NUL characters as
|
||||
strncpy() and strnmov() do. Thus if your C compiler doesn't support
|
||||
structure assignment, you can simulate it with
|
||||
bmove(&to, &from, sizeof from);
|
||||
The standard 4.2bsd routine for this purpose is bcopy. But as bcopy
|
||||
has its first two arguments the other way around you may find this a
|
||||
bit easier to get right.
|
||||
No value is returned.
|
||||
|
||||
Note: the "b" routines are there to exploit certain VAX order codes,
|
||||
but the MOVC3 instruction will only move 65535 characters. The asm
|
||||
code is presented for your interest and amusement.
|
||||
*/
|
||||
|
||||
#include <my_global.h>
|
||||
#include "m_string.h"
|
||||
|
||||
#if !defined(HAVE_BMOVE) && !defined(bmove)
|
||||
|
||||
#if VaxAsm
|
||||
|
||||
void bmove(dst, src, len)
|
||||
char *dst, *src;
|
||||
uint len;
|
||||
{
|
||||
asm("movc3 12(ap),*8(ap),*4(ap)");
|
||||
}
|
||||
|
||||
#else
|
||||
#if defined(MC68000) && defined(DS90)
|
||||
|
||||
void bmove(dst, src, len)
|
||||
char *dst,*src;
|
||||
uint len; /* 0 <= len <= 65535 */
|
||||
{
|
||||
asm(" movl 12(a7),d0 ");
|
||||
asm(" subql #1,d0 ");
|
||||
asm(" blt .L5 ");
|
||||
asm(" movl 4(a7),a1 ");
|
||||
asm(" movl 8(a7),a0 ");
|
||||
asm(".L4: movb (a0)+,(a1)+ ");
|
||||
asm(" dbf d0,.L4 ");
|
||||
asm(".L5: ");
|
||||
}
|
||||
#else
|
||||
|
||||
void bmove(dst, src, len)
|
||||
register char *dst;
|
||||
register const char *src;
|
||||
register uint len;
|
||||
{
|
||||
while (len-- != 0) *dst++ = *src++;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
51
module/Vendor/MDBC/libmariadb/bmove_upp.c
vendored
Normal file
51
module/Vendor/MDBC/libmariadb/bmove_upp.c
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
/* 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 */
|
||||
|
||||
/* File : bmove.c
|
||||
Author : Michael widenius
|
||||
Updated: 1987-03-20
|
||||
Defines: bmove_upp()
|
||||
|
||||
bmove_upp(dst, src, len) moves exactly "len" bytes from the source
|
||||
"src-len" to the destination "dst-len" counting downwards.
|
||||
*/
|
||||
|
||||
#include <my_global.h>
|
||||
#include "m_string.h"
|
||||
|
||||
#if defined(MC68000) && defined(DS90)
|
||||
|
||||
/* 0 <= len <= 65535 */
|
||||
void bmove_upp(byte *dst, const byte *src, size_t len)
|
||||
{
|
||||
asm(" movl 12(a7),d0 ");
|
||||
asm(" subql #1,d0 ");
|
||||
asm(" blt .L5 ");
|
||||
asm(" movl 4(a7),a1 ");
|
||||
asm(" movl 8(a7),a0 ");
|
||||
asm(".L4: movb -(a0),-(a1) ");
|
||||
asm(" dbf d0,.L4 ");
|
||||
asm(".L5: ");
|
||||
}
|
||||
#else
|
||||
|
||||
void bmove_upp(register char *dst, register const char *src, register size_t len)
|
||||
{
|
||||
while (len-- != 0) *--dst = *--src;
|
||||
}
|
||||
|
||||
#endif
|
78
module/Vendor/MDBC/libmariadb/charset.c
vendored
Normal file
78
module/Vendor/MDBC/libmariadb/charset.c
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/* 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 */
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#include "mysys_err.h"
|
||||
#include <m_ctype.h>
|
||||
#include <m_string.h>
|
||||
#include <my_dir.h>
|
||||
|
||||
CHARSET_INFO *default_charset_info = (CHARSET_INFO *)&compiled_charsets[5];
|
||||
CHARSET_INFO *my_charset_bin= (CHARSET_INFO *)&compiled_charsets[32];
|
||||
CHARSET_INFO *my_charset_latin1= (CHARSET_INFO *)&compiled_charsets[5];
|
||||
CHARSET_INFO *my_charset_utf8_general_ci= (CHARSET_INFO *)&compiled_charsets[21];
|
||||
|
||||
CHARSET_INFO * STDCALL mysql_get_charset_by_nr(uint cs_number)
|
||||
{
|
||||
int i= 0;
|
||||
|
||||
while (compiled_charsets[i].nr && cs_number != compiled_charsets[i].nr)
|
||||
i++;
|
||||
|
||||
return (compiled_charsets[i].nr) ? (CHARSET_INFO *)&compiled_charsets[i] : NULL;
|
||||
}
|
||||
|
||||
my_bool set_default_charset(uint cs, myf flags)
|
||||
{
|
||||
CHARSET_INFO *new_charset;
|
||||
DBUG_ENTER("set_default_charset");
|
||||
DBUG_PRINT("enter",("character set: %d",(int) cs));
|
||||
new_charset = mysql_get_charset_by_nr(cs);
|
||||
if (!new_charset)
|
||||
{
|
||||
DBUG_PRINT("error",("Couldn't set default character set"));
|
||||
DBUG_RETURN(TRUE); /* error */
|
||||
}
|
||||
default_charset_info = new_charset;
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
CHARSET_INFO * STDCALL mysql_get_charset_by_name(const char *cs_name)
|
||||
{
|
||||
int i= 0;
|
||||
|
||||
while (compiled_charsets[i].nr && strcmp(cs_name, compiled_charsets[i].csname) != 0)
|
||||
i++;
|
||||
|
||||
return (compiled_charsets[i].nr) ? (CHARSET_INFO *)&compiled_charsets[i] : NULL;
|
||||
}
|
||||
|
||||
my_bool set_default_charset_by_name(const char *cs_name, myf flags)
|
||||
{
|
||||
CHARSET_INFO *new_charset;
|
||||
DBUG_ENTER("set_default_charset_by_name");
|
||||
DBUG_PRINT("enter",("character set: %s", cs_name));
|
||||
new_charset = mysql_get_charset_by_name(cs_name);
|
||||
if (!new_charset)
|
||||
{
|
||||
DBUG_PRINT("error",("Couldn't set default character set"));
|
||||
DBUG_RETURN(TRUE); /* error */
|
||||
}
|
||||
|
||||
default_charset_info = new_charset;
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
466
module/Vendor/MDBC/libmariadb/client_plugin.c
vendored
Normal file
466
module/Vendor/MDBC/libmariadb/client_plugin.c
vendored
Normal file
@ -0,0 +1,466 @@
|
||||
/* Copyright (C) 2010 - 2012 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 see <http://www.gnu.org/licenses>
|
||||
or write to the Free Software Foundation, Inc.,
|
||||
51 Franklin St., Fifth Floor, Boston, MA 02110, USA */
|
||||
|
||||
/**
|
||||
@file
|
||||
|
||||
Support code for the client side (libmariadb) plugins
|
||||
|
||||
Client plugins are somewhat different from server plugins, they are simpler.
|
||||
|
||||
They do not need to be installed or in any way explicitly loaded on the
|
||||
client, they are loaded automatically on demand.
|
||||
One client plugin per shared object, soname *must* match the plugin name.
|
||||
|
||||
There is no reference counting and no unloading either.
|
||||
*/
|
||||
|
||||
#if _MSC_VER
|
||||
/* Silence warnings about variable 'unused' being used. */
|
||||
#define FORCE_INIT_OF_VARS 1
|
||||
#endif
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <ma_common.h>
|
||||
#include <m_string.h>
|
||||
#ifdef THREAD
|
||||
#include <my_pthread.h>
|
||||
#else
|
||||
#include <my_no_pthread.h>
|
||||
#endif
|
||||
|
||||
#include "errmsg.h"
|
||||
#include <mysql/client_plugin.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
struct st_client_plugin_int {
|
||||
struct st_client_plugin_int *next;
|
||||
void *dlhandle;
|
||||
struct st_mysql_client_plugin *plugin;
|
||||
};
|
||||
|
||||
static my_bool initialized= 0;
|
||||
static MEM_ROOT mem_root;
|
||||
|
||||
#define plugin_declarations_sym "_mysql_client_plugin_declaration_"
|
||||
|
||||
static uint plugin_version[MYSQL_CLIENT_MAX_PLUGINS]=
|
||||
{
|
||||
MYSQL_CLIENT_DB_PLUGIN_INTERFACE_VERSION, /* these two are taken by Connector/C */
|
||||
0, /* these two are taken by Connector/C */
|
||||
MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION
|
||||
};
|
||||
|
||||
/*
|
||||
Loaded plugins are stored in a linked list.
|
||||
The list is append-only, the elements are added to the head (like in a stack).
|
||||
The elements are added under a mutex, but the list can be read and traversed
|
||||
without any mutex because once an element is added to the list, it stays
|
||||
there. The main purpose of a mutex is to prevent two threads from
|
||||
loading the same plugin twice in parallel.
|
||||
*/
|
||||
struct st_client_plugin_int *plugin_list[MYSQL_CLIENT_MAX_PLUGINS];
|
||||
#ifdef THREAD
|
||||
static pthread_mutex_t LOCK_load_client_plugin;
|
||||
#endif
|
||||
|
||||
static int is_not_initialized(MYSQL *mysql, const char *name)
|
||||
{
|
||||
if (initialized)
|
||||
return 0;
|
||||
|
||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD,
|
||||
SQLSTATE_UNKNOWN, ER(CR_AUTH_PLUGIN_CANNOT_LOAD),
|
||||
name, "not initialized");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
finds a plugin in the list
|
||||
|
||||
@param name plugin name to search for
|
||||
@param type plugin type
|
||||
|
||||
@note this does NOT necessarily need a mutex, take care!
|
||||
|
||||
@retval a pointer to a found plugin or 0
|
||||
*/
|
||||
|
||||
static struct st_mysql_client_plugin *find_plugin(const char *name, int type)
|
||||
{
|
||||
struct st_client_plugin_int *p;
|
||||
|
||||
DBUG_ASSERT(initialized);
|
||||
DBUG_ASSERT(type >= 0 && type < MYSQL_CLIENT_MAX_PLUGINS);
|
||||
if (type < 0 || type >= MYSQL_CLIENT_MAX_PLUGINS)
|
||||
return 0;
|
||||
|
||||
for (p= plugin_list[type]; p; p= p->next)
|
||||
{
|
||||
if (strcmp(p->plugin->name, name) == 0)
|
||||
return p->plugin;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
verifies the plugin and adds it to the list
|
||||
|
||||
@param mysql MYSQL structure (for error reporting)
|
||||
@param plugin plugin to install
|
||||
@param dlhandle a handle to the shared object (returned by dlopen)
|
||||
or 0 if the plugin was not dynamically loaded
|
||||
@param argc number of arguments in the 'va_list args'
|
||||
@param args arguments passed to the plugin initialization function
|
||||
|
||||
@retval a pointer to an installed plugin or 0
|
||||
*/
|
||||
|
||||
static struct st_mysql_client_plugin *
|
||||
add_plugin(MYSQL *mysql, struct st_mysql_client_plugin *plugin, void *dlhandle,
|
||||
int argc, va_list args)
|
||||
{
|
||||
const char *errmsg;
|
||||
struct st_client_plugin_int plugin_int, *p;
|
||||
char errbuf[1024];
|
||||
|
||||
DBUG_ASSERT(initialized);
|
||||
|
||||
plugin_int.plugin= plugin;
|
||||
plugin_int.dlhandle= dlhandle;
|
||||
|
||||
if (plugin->type >= MYSQL_CLIENT_MAX_PLUGINS)
|
||||
{
|
||||
errmsg= "Unknown client plugin type";
|
||||
goto err1;
|
||||
}
|
||||
|
||||
if (plugin->interface_version < plugin_version[plugin->type] ||
|
||||
(plugin->interface_version >> 8) >
|
||||
(plugin_version[plugin->type] >> 8))
|
||||
{
|
||||
errmsg= "Incompatible client plugin interface";
|
||||
goto err1;
|
||||
}
|
||||
|
||||
/* Call the plugin initialization function, if any */
|
||||
if (plugin->init && plugin->init(errbuf, sizeof(errbuf), argc, args))
|
||||
{
|
||||
errmsg= errbuf;
|
||||
goto err1;
|
||||
}
|
||||
|
||||
p= (struct st_client_plugin_int *)
|
||||
memdup_root(&mem_root, (char *)&plugin_int, sizeof(plugin_int));
|
||||
|
||||
if (!p)
|
||||
{
|
||||
errmsg= "Out of memory";
|
||||
goto err2;
|
||||
}
|
||||
|
||||
#ifdef THREAD
|
||||
safe_mutex_assert_owner(&LOCK_load_client_plugin);
|
||||
#endif
|
||||
|
||||
p->next= plugin_list[plugin->type];
|
||||
plugin_list[plugin->type]= p;
|
||||
|
||||
return plugin;
|
||||
|
||||
err2:
|
||||
if (plugin->deinit)
|
||||
plugin->deinit();
|
||||
err1:
|
||||
if (dlhandle)
|
||||
(void)dlclose(dlhandle);
|
||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD, SQLSTATE_UNKNOWN,
|
||||
ER(CR_AUTH_PLUGIN_CANNOT_LOAD), plugin->name, errmsg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Loads plugins which are specified in the environment variable
|
||||
LIBMYSQL_PLUGINS.
|
||||
|
||||
Multiple plugins must be separated by semicolon. This function doesn't
|
||||
return or log an error.
|
||||
|
||||
The function is be called by mysql_client_plugin_init
|
||||
|
||||
@todo
|
||||
Support extended syntax, passing parameters to plugins, for example
|
||||
LIBMYSQL_PLUGINS="plugin1(param1,param2);plugin2;..."
|
||||
or
|
||||
LIBMYSQL_PLUGINS="plugin1=int:param1,str:param2;plugin2;..."
|
||||
*/
|
||||
|
||||
static void load_env_plugins(MYSQL *mysql)
|
||||
{
|
||||
char *plugs, *free_env, *s= getenv("LIBMYSQL_PLUGINS");
|
||||
|
||||
/* no plugins to load */
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
free_env= plugs= my_strdup(s, MYF(MY_WME));
|
||||
|
||||
do {
|
||||
if ((s= strchr(plugs, ';')))
|
||||
*s= '\0';
|
||||
mysql_load_plugin(mysql, plugs, -1, 0);
|
||||
plugs= s + 1;
|
||||
} while (s);
|
||||
|
||||
my_free(free_env);
|
||||
}
|
||||
|
||||
/********** extern functions to be used by libmariadb *********************/
|
||||
|
||||
/**
|
||||
Initializes the client plugin layer.
|
||||
|
||||
This function must be called before any other client plugin function.
|
||||
|
||||
@retval 0 successful
|
||||
@retval != 0 error occured
|
||||
*/
|
||||
|
||||
int mysql_client_plugin_init()
|
||||
{
|
||||
MYSQL mysql;
|
||||
struct st_mysql_client_plugin **builtin;
|
||||
va_list unused;
|
||||
LINT_INIT_STRUCT(unused);
|
||||
|
||||
if (initialized)
|
||||
return 0;
|
||||
|
||||
bzero(&mysql, sizeof(mysql)); /* dummy mysql for set_mysql_extended_error */
|
||||
|
||||
pthread_mutex_init(&LOCK_load_client_plugin, MY_MUTEX_INIT_SLOW);
|
||||
init_alloc_root(&mem_root, 128, 128);
|
||||
|
||||
bzero(&plugin_list, sizeof(plugin_list));
|
||||
|
||||
initialized= 1;
|
||||
|
||||
pthread_mutex_lock(&LOCK_load_client_plugin);
|
||||
|
||||
for (builtin= mysql_client_builtins; *builtin; builtin++)
|
||||
add_plugin(&mysql, *builtin, 0, 0, unused);
|
||||
pthread_mutex_unlock(&LOCK_load_client_plugin);
|
||||
|
||||
load_env_plugins(&mysql);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Deinitializes the client plugin layer.
|
||||
|
||||
Unloades all client plugins and frees any associated resources.
|
||||
*/
|
||||
|
||||
void mysql_client_plugin_deinit()
|
||||
{
|
||||
int i;
|
||||
struct st_client_plugin_int *p;
|
||||
|
||||
if (!initialized)
|
||||
return;
|
||||
|
||||
for (i=0; i < MYSQL_CLIENT_MAX_PLUGINS; i++)
|
||||
for (p= plugin_list[i]; p; p= p->next)
|
||||
{
|
||||
if (p->plugin->deinit)
|
||||
p->plugin->deinit();
|
||||
if (p->dlhandle)
|
||||
(void)dlclose(p->dlhandle);
|
||||
}
|
||||
|
||||
bzero(&plugin_list, sizeof(plugin_list));
|
||||
initialized= 0;
|
||||
free_root(&mem_root, MYF(0));
|
||||
pthread_mutex_destroy(&LOCK_load_client_plugin);
|
||||
}
|
||||
|
||||
/************* public facing functions, for client consumption *********/
|
||||
|
||||
/* see <mysql/client_plugin.h> for a full description */
|
||||
struct st_mysql_client_plugin * STDCALL
|
||||
mysql_client_register_plugin(MYSQL *mysql,
|
||||
struct st_mysql_client_plugin *plugin)
|
||||
{
|
||||
va_list unused;
|
||||
LINT_INIT_STRUCT(unused);
|
||||
|
||||
if (is_not_initialized(mysql, plugin->name))
|
||||
return NULL;
|
||||
|
||||
pthread_mutex_lock(&LOCK_load_client_plugin);
|
||||
|
||||
/* make sure the plugin wasn't loaded meanwhile */
|
||||
if (find_plugin(plugin->name, plugin->type))
|
||||
{
|
||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD,
|
||||
SQLSTATE_UNKNOWN, ER(CR_AUTH_PLUGIN_CANNOT_LOAD),
|
||||
plugin->name, "it is already loaded");
|
||||
plugin= NULL;
|
||||
}
|
||||
else
|
||||
plugin= add_plugin(mysql, plugin, 0, 0, unused);
|
||||
|
||||
pthread_mutex_unlock(&LOCK_load_client_plugin);
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
||||
/* see <mysql/client_plugin.h> for a full description */
|
||||
struct st_mysql_client_plugin * STDCALL
|
||||
mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
|
||||
int argc, va_list args)
|
||||
{
|
||||
const char *errmsg;
|
||||
#ifdef _WIN32
|
||||
char errbuf[255];
|
||||
#endif
|
||||
char dlpath[FN_REFLEN+1];
|
||||
void *sym, *dlhandle;
|
||||
struct st_mysql_client_plugin *plugin;
|
||||
char *env_plugin_dir= getenv("MARIADB_PLUGIN_DIR");
|
||||
|
||||
if (is_not_initialized(mysql, name))
|
||||
return NULL;
|
||||
|
||||
pthread_mutex_lock(&LOCK_load_client_plugin);
|
||||
|
||||
/* make sure the plugin wasn't loaded meanwhile */
|
||||
if (type >= 0 && find_plugin(name, type))
|
||||
{
|
||||
errmsg= "it is already loaded";
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Compile dll path */
|
||||
strxnmov(dlpath, sizeof(dlpath) - 1,
|
||||
mysql->options.extension && mysql->options.extension->plugin_dir ?
|
||||
mysql->options.extension->plugin_dir : (env_plugin_dir) ? env_plugin_dir :
|
||||
PLUGINDIR, "/",
|
||||
name, SO_EXT, NullS);
|
||||
|
||||
/* Open new dll handle */
|
||||
if (!(dlhandle= dlopen((const char *)dlpath, RTLD_NOW)))
|
||||
{
|
||||
#ifdef _WIN32
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&errbuf, 255, NULL);
|
||||
errmsg= errbuf;
|
||||
#else
|
||||
errmsg= dlerror();
|
||||
#endif
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!(sym= dlsym(dlhandle, plugin_declarations_sym)))
|
||||
{
|
||||
errmsg= "not a plugin";
|
||||
(void)dlclose(dlhandle);
|
||||
goto err;
|
||||
}
|
||||
|
||||
plugin= (struct st_mysql_client_plugin*)sym;
|
||||
|
||||
if (type >=0 && type != plugin->type)
|
||||
{
|
||||
errmsg= "type mismatch";
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (strcmp(name, plugin->name))
|
||||
{
|
||||
errmsg= "name mismatch";
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (type < 0 && find_plugin(name, plugin->type))
|
||||
{
|
||||
errmsg= "it is already loaded";
|
||||
goto err;
|
||||
}
|
||||
|
||||
plugin= add_plugin(mysql, plugin, dlhandle, argc, args);
|
||||
|
||||
pthread_mutex_unlock(&LOCK_load_client_plugin);
|
||||
|
||||
return plugin;
|
||||
|
||||
err:
|
||||
pthread_mutex_unlock(&LOCK_load_client_plugin);
|
||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD, SQLSTATE_UNKNOWN,
|
||||
ER(CR_AUTH_PLUGIN_CANNOT_LOAD), name, errmsg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* see <mysql/client_plugin.h> for a full description */
|
||||
struct st_mysql_client_plugin * STDCALL
|
||||
mysql_load_plugin(MYSQL *mysql, const char *name, int type, int argc, ...)
|
||||
{
|
||||
struct st_mysql_client_plugin *p;
|
||||
va_list args;
|
||||
va_start(args, argc);
|
||||
p= mysql_load_plugin_v(mysql, name, type, argc, args);
|
||||
va_end(args);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/* see <mysql/client_plugin.h> for a full description */
|
||||
struct st_mysql_client_plugin * STDCALL
|
||||
mysql_client_find_plugin(MYSQL *mysql, const char *name, int type)
|
||||
{
|
||||
struct st_mysql_client_plugin *p;
|
||||
|
||||
if (is_not_initialized(mysql, name))
|
||||
return NULL;
|
||||
|
||||
if (type < 0 || type >= MYSQL_CLIENT_MAX_PLUGINS)
|
||||
{
|
||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD, SQLSTATE_UNKNOWN,
|
||||
ER(CR_AUTH_PLUGIN_CANNOT_LOAD), name, "invalid type");
|
||||
}
|
||||
|
||||
if ((p= find_plugin(name, type)))
|
||||
return p;
|
||||
|
||||
/* not found, load it */
|
||||
return mysql_load_plugin(mysql, name, type, 0);
|
||||
}
|
||||
|
||||
|
2457
module/Vendor/MDBC/libmariadb/dbug.c
vendored
Normal file
2457
module/Vendor/MDBC/libmariadb/dbug.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
433
module/Vendor/MDBC/libmariadb/default.c
vendored
Normal file
433
module/Vendor/MDBC/libmariadb/default.c
vendored
Normal file
@ -0,0 +1,433 @@
|
||||
/* 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 */
|
||||
|
||||
/****************************************************************************
|
||||
** Add all options from files named "group".cnf from the default_directories
|
||||
** before the command line arguments.
|
||||
** On Windows defaults will also search in the Windows directory for a file
|
||||
** called 'group'.ini
|
||||
** As long as the program uses the last argument for conflicting
|
||||
** options one only have to add a call to "load_defaults" to enable
|
||||
** use of default values.
|
||||
** pre- and end 'blank space' are removed from options and values. The
|
||||
** following escape sequences are recognized in values: \b \t \n \r \\
|
||||
**
|
||||
** The following arguments are handled automaticly; If used, they must be
|
||||
** first argument on the command line!
|
||||
** --no-defaults ; no options are read.
|
||||
** --defaults-file=full-path-to-default-file ; Only this file will be read.
|
||||
** --defaults-extra-file=full-path-to-default-file ; Read this file before ~/
|
||||
** --print-defaults ; Print the modified command line and exit
|
||||
****************************************************************************/
|
||||
|
||||
#undef SAFEMALLOC /* safe_malloc is not yet initailized */
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#include "m_string.h"
|
||||
#include <ctype.h>
|
||||
#include "m_ctype.h"
|
||||
#include <my_dir.h>
|
||||
|
||||
char *defaults_extra_file=0;
|
||||
|
||||
/* Which directories are searched for options (and in which order) */
|
||||
|
||||
const char *default_directories[]= {
|
||||
#ifdef _WIN32
|
||||
"C:/",
|
||||
#else
|
||||
"/etc/",
|
||||
#endif
|
||||
#ifdef DATADIR
|
||||
DATADIR,
|
||||
#endif
|
||||
"", /* Place for defaults_extra_dir */
|
||||
#ifndef _WIN32
|
||||
"~/",
|
||||
#endif
|
||||
NullS,
|
||||
};
|
||||
|
||||
#define default_ext ".cnf" /* extension for config file */
|
||||
#ifdef _WIN32
|
||||
#include <winbase.h>
|
||||
#define windows_ext ".ini"
|
||||
#endif
|
||||
|
||||
static my_bool search_default_file(DYNAMIC_ARRAY *args,MEM_ROOT *alloc,
|
||||
const char *dir, const char *config_file,
|
||||
const char *ext, TYPELIB *group);
|
||||
|
||||
|
||||
void load_defaults(const char *conf_file, const char **groups,
|
||||
int *argc, char ***argv)
|
||||
{
|
||||
DYNAMIC_ARRAY args;
|
||||
const char **dirs, *forced_default_file;
|
||||
TYPELIB group;
|
||||
my_bool found_print_defaults=0;
|
||||
uint args_used=0;
|
||||
MEM_ROOT alloc;
|
||||
char *ptr,**res;
|
||||
DBUG_ENTER("load_defaults");
|
||||
|
||||
init_alloc_root(&alloc,128,0);
|
||||
if (*argc >= 2 && !strcmp(argv[0][1],"--no-defaults"))
|
||||
{
|
||||
/* remove the --no-defaults argument and return only the other arguments */
|
||||
uint i;
|
||||
if (!(ptr=(char*) alloc_root(&alloc,sizeof(alloc)+
|
||||
(*argc + 1)*sizeof(char*))))
|
||||
goto err;
|
||||
res= (char**) (ptr+sizeof(alloc));
|
||||
res[0]= **argv; /* Copy program name */
|
||||
for (i=2 ; i < (uint) *argc ; i++)
|
||||
res[i-1]=argv[0][i];
|
||||
(*argc)--;
|
||||
*argv=res;
|
||||
*(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
/* Check if we want to force the use a specific default file */
|
||||
forced_default_file=0;
|
||||
if (*argc >= 2)
|
||||
{
|
||||
if (is_prefix(argv[0][1],"--defaults-file="))
|
||||
{
|
||||
forced_default_file=strchr(argv[0][1],'=')+1;
|
||||
args_used++;
|
||||
}
|
||||
else if (is_prefix(argv[0][1],"--defaults-extra-file="))
|
||||
{
|
||||
defaults_extra_file=strchr(argv[0][1],'=')+1;
|
||||
args_used++;
|
||||
}
|
||||
}
|
||||
|
||||
group.count=0;
|
||||
group.name= "defaults";
|
||||
group.type_names= groups;
|
||||
for (; *groups ; groups++)
|
||||
group.count++;
|
||||
|
||||
if (my_init_dynamic_array(&args, sizeof(char*),*argc, 32))
|
||||
goto err;
|
||||
if (forced_default_file)
|
||||
{
|
||||
if (search_default_file(&args, &alloc, "", forced_default_file, "",
|
||||
&group))
|
||||
goto err;
|
||||
}
|
||||
else if (dirname_length(conf_file))
|
||||
{
|
||||
if (search_default_file(&args, &alloc, NullS, conf_file, default_ext,
|
||||
&group))
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char system_dir[FN_REFLEN];
|
||||
GetWindowsDirectory(system_dir,sizeof(system_dir));
|
||||
if (search_default_file(&args, &alloc, system_dir, conf_file, windows_ext,
|
||||
&group))
|
||||
goto err;
|
||||
#endif
|
||||
#if defined(__EMX__) || defined(OS2)
|
||||
if (getenv("ETC") &&
|
||||
search_default_file(&args, &alloc, getenv("ETC"), conf_file,
|
||||
default_ext, &group))
|
||||
goto err;
|
||||
#endif
|
||||
for (dirs=default_directories ; *dirs; dirs++)
|
||||
{
|
||||
int error=0;
|
||||
if (**dirs)
|
||||
error=search_default_file(&args, &alloc, *dirs, conf_file,
|
||||
default_ext, &group);
|
||||
else if (defaults_extra_file)
|
||||
error=search_default_file(&args, &alloc, NullS, defaults_extra_file,
|
||||
default_ext, &group);
|
||||
if (error)
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!(ptr=(char*) alloc_root(&alloc,sizeof(alloc)+
|
||||
(args.elements + *argc +1) *sizeof(char*))))
|
||||
goto err;
|
||||
res= (char**) (ptr+sizeof(alloc));
|
||||
|
||||
/* copy name + found arguments + command line arguments to new array */
|
||||
res[0]=argv[0][0];
|
||||
memcpy((gptr) (res+1), args.buffer, args.elements*sizeof(char*));
|
||||
/* Skipp --defaults-file and --defaults-extra-file */
|
||||
(*argc)-= args_used;
|
||||
(*argv)+= args_used;
|
||||
|
||||
/* Check if we wan't to see the new argument list */
|
||||
if (*argc >= 2 && !strcmp(argv[0][1],"--print-defaults"))
|
||||
{
|
||||
found_print_defaults=1;
|
||||
--*argc; ++*argv; /* skipp argument */
|
||||
}
|
||||
|
||||
memcpy((gptr) (res+1+args.elements), (char*) ((*argv)+1),
|
||||
(*argc-1)*sizeof(char*));
|
||||
res[args.elements+ *argc]=0; /* last null */
|
||||
|
||||
(*argc)+=args.elements;
|
||||
*argv= (char**) res;
|
||||
*(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */
|
||||
delete_dynamic(&args);
|
||||
if (found_print_defaults)
|
||||
{
|
||||
int i;
|
||||
printf("%s would have been started with the following arguments:\n",
|
||||
**argv);
|
||||
for (i=1 ; i < *argc ; i++)
|
||||
printf("%s ", (*argv)[i]);
|
||||
puts("");
|
||||
exit(1);
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
err:
|
||||
fprintf(stderr,"Program aborted\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
void free_defaults(char **argv)
|
||||
{
|
||||
MEM_ROOT ptr;
|
||||
memcpy_fixed((char*) &ptr,(char *) argv - sizeof(ptr), sizeof(ptr));
|
||||
free_root(&ptr,MYF(0));
|
||||
}
|
||||
|
||||
|
||||
static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
|
||||
const char *dir, const char *config_file,
|
||||
const char *ext, TYPELIB *group)
|
||||
{
|
||||
char name[FN_REFLEN+10],buff[4096],*ptr,*end,*value,*tmp;
|
||||
FILE *fp;
|
||||
uint line=0;
|
||||
my_bool read_values= 0, found_group= 0, is_escaped= 0, is_quoted= 0;
|
||||
|
||||
if ((dir ? strlen(dir) : 0 )+strlen(config_file) >= FN_REFLEN-3)
|
||||
return 0; /* Ignore wrong paths */
|
||||
if (dir)
|
||||
{
|
||||
strmov(name,dir);
|
||||
convert_dirname(name);
|
||||
if (dir[0] == FN_HOMELIB) /* Add . to filenames in home */
|
||||
strcat(name,".");
|
||||
strxmov(strend(name),config_file,ext,NullS);
|
||||
}
|
||||
else
|
||||
{
|
||||
strmov(name,config_file);
|
||||
}
|
||||
fn_format(name,name,"","",4);
|
||||
#if !defined(_WIN32) && !defined(OS2)
|
||||
{
|
||||
MY_STAT stat_info;
|
||||
if (!my_stat(name,&stat_info,MYF(0)))
|
||||
return 0;
|
||||
if (stat_info.st_mode & S_IWOTH) /* ignore world-writeable files */
|
||||
{
|
||||
fprintf(stderr, "warning: World-writeable config file %s is ignored\n",
|
||||
name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!(fp = my_fopen(fn_format(name,name,"","",4),O_RDONLY,MYF(0))))
|
||||
return 0; /* Ignore wrong files */
|
||||
|
||||
while (fgets(buff,sizeof(buff)-1,fp))
|
||||
{
|
||||
line++;
|
||||
/* Ignore comment and empty lines */
|
||||
for (ptr=buff ; isspace(*ptr) ; ptr++ );
|
||||
if (!is_escaped && (*ptr == '\"' || *ptr== '\''))
|
||||
{
|
||||
is_quoted= !is_quoted;
|
||||
continue;
|
||||
}
|
||||
if (*ptr == '#' || *ptr == ';' || !*ptr)
|
||||
continue;
|
||||
is_escaped= (*ptr == '\\');
|
||||
if (*ptr == '[') /* Group name */
|
||||
{
|
||||
found_group=1;
|
||||
if (!(end=(char *) strchr(++ptr,']')))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"error: Wrong group definition in config file: %s at line %d\n",
|
||||
name,line);
|
||||
goto err;
|
||||
}
|
||||
for ( ; isspace(end[-1]) ; end--) ; /* Remove end space */
|
||||
end[0]=0;
|
||||
read_values=find_type(ptr,group,3) > 0;
|
||||
continue;
|
||||
}
|
||||
if (!found_group)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"error: Found option without preceding group in config file: %s at line: %d\n",
|
||||
name,line);
|
||||
goto err;
|
||||
}
|
||||
if (!read_values)
|
||||
continue;
|
||||
if (!(end=value=strchr(ptr,'=')))
|
||||
end=strend(ptr); /* Option without argument */
|
||||
for ( ; isspace(end[-1]) ; end--) ;
|
||||
if (!value)
|
||||
{
|
||||
if (!(tmp=alloc_root(alloc,(uint) (end-ptr)+3)))
|
||||
goto err;
|
||||
strmake(strmov(tmp,"--"),ptr,(uint) (end-ptr));
|
||||
if (insert_dynamic(args,(gptr) &tmp))
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Remove pre- and end space */
|
||||
char *value_end;
|
||||
for (value++ ; isspace(*value); value++) ;
|
||||
value_end=strend(value);
|
||||
for ( ; isspace(value_end[-1]) ; value_end--) ;
|
||||
/* remove possible quotes */
|
||||
if (*value == '\'' || *value == '\"')
|
||||
{
|
||||
value++;
|
||||
if (value_end[-1] == '\'' || value_end[-1] == '\"')
|
||||
value_end--;
|
||||
}
|
||||
if (value_end < value) /* Empty string */
|
||||
value_end=value;
|
||||
if (!(tmp=alloc_root(alloc,(uint) (end-ptr)+3 +
|
||||
(uint) (value_end-value)+1)))
|
||||
goto err;
|
||||
if (insert_dynamic(args,(gptr) &tmp))
|
||||
goto err;
|
||||
ptr=strnmov(strmov(tmp,"--"),ptr,(uint) (end-ptr));
|
||||
*ptr++= '=';
|
||||
for ( ; value != value_end; value++)
|
||||
{
|
||||
if (*value == '\\' && value != value_end-1)
|
||||
{
|
||||
switch(*++value) {
|
||||
case 'n':
|
||||
*ptr++='\n';
|
||||
break;
|
||||
case 't':
|
||||
*ptr++= '\t';
|
||||
break;
|
||||
case 'r':
|
||||
*ptr++ = '\r';
|
||||
break;
|
||||
case 'b':
|
||||
*ptr++ = '\b';
|
||||
break;
|
||||
case 's':
|
||||
*ptr++= ' '; /* space */
|
||||
break;
|
||||
case '\"':
|
||||
*ptr++= '\"';
|
||||
break;
|
||||
case '\'':
|
||||
*ptr++= '\'';
|
||||
break;
|
||||
case '\\':
|
||||
*ptr++= '\\';
|
||||
break;
|
||||
default: /* Unknown; Keep '\' */
|
||||
*ptr++= '\\';
|
||||
*ptr++= *value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
*ptr++= *value;
|
||||
}
|
||||
*ptr=0;
|
||||
}
|
||||
}
|
||||
my_fclose(fp,MYF(0));
|
||||
return(0);
|
||||
|
||||
err:
|
||||
my_fclose(fp,MYF(0));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void print_defaults(const char *conf_file, const char **groups)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
bool have_ext=fn_ext(conf_file)[0] != 0;
|
||||
#endif
|
||||
char name[FN_REFLEN];
|
||||
const char **dirs;
|
||||
puts("\nDefault options are read from the following files in the given order:");
|
||||
|
||||
if (dirname_length(conf_file))
|
||||
fputs(conf_file,stdout);
|
||||
else
|
||||
{
|
||||
#ifdef _WIN32
|
||||
GetWindowsDirectory(name,sizeof(name));
|
||||
printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_ext);
|
||||
#endif
|
||||
#if defined(__EMX__) || defined(OS2)
|
||||
if (getenv("ETC"))
|
||||
printf("%s\\%s%s ", getenv("ETC"), conf_file, default_ext);
|
||||
#endif
|
||||
for (dirs=default_directories ; *dirs; dirs++)
|
||||
{
|
||||
if (**dirs)
|
||||
strmov(name,*dirs);
|
||||
else if (defaults_extra_file)
|
||||
strmov(name,defaults_extra_file);
|
||||
else
|
||||
continue;
|
||||
convert_dirname(name);
|
||||
if (name[0] == FN_HOMELIB) /* Add . to filenames in home */
|
||||
strcat(name,".");
|
||||
strxmov(strend(name),conf_file,default_ext," ",NullS);
|
||||
fputs(name,stdout);
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
fputs("The following groups are read:",stdout);
|
||||
for ( ; *groups ; groups++)
|
||||
{
|
||||
fputc(' ',stdout);
|
||||
fputs(*groups,stdout);
|
||||
}
|
||||
puts("\nThe following options may be given as the first argument:\n\
|
||||
--print-defaults Print the program argument list and exit\n\
|
||||
--no-defaults Don't read default options from any options file\n\
|
||||
--defaults-file=# Only read default options from the given file #\n\
|
||||
--defaults-extra-file=# Read this file after the global files are read");
|
||||
}
|
||||
|
152
module/Vendor/MDBC/libmariadb/errmsg.c
vendored
Normal file
152
module/Vendor/MDBC/libmariadb/errmsg.c
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
/* 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 */
|
||||
|
||||
/* Error messages for MySQL clients */
|
||||
/* error messages for the demon is in share/language/errmsg.sys */
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include "errmsg.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef GERMAN
|
||||
const char *client_errors[]=
|
||||
{
|
||||
"Unbekannter MySQL Fehler",
|
||||
"Kann UNIX-Socket nicht anlegen (%d)",
|
||||
"Keine Verbindung zu lokalem MySQL Server, socket: '%-.64s' (%d)",
|
||||
"Keine Verbindung zu MySQL Server auf %-.64s (%d)",
|
||||
"Kann TCP/IP-Socket nicht anlegen (%d)",
|
||||
"Unbekannter MySQL Server Host (%-.64s) (%d)",
|
||||
"MySQL Server nicht vorhanden",
|
||||
"Protokolle ungleich. Server Version = % d Client Version = %d",
|
||||
"MySQL client got out of memory",
|
||||
"Wrong host info",
|
||||
"Localhost via UNIX socket",
|
||||
"%-.64s via TCP/IP",
|
||||
"Error in server handshake",
|
||||
"Lost connection to MySQL server during query",
|
||||
"Commands out of sync; you can't run this command now",
|
||||
"Verbindung ueber Named Pipe; Host: %-.64s",
|
||||
"Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)",
|
||||
"Can't initialize character set %-.64s (path: %-.64s)",
|
||||
"Got packet bigger than 'max_allowed_packet'"
|
||||
};
|
||||
|
||||
/* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */
|
||||
|
||||
#elif defined PORTUGUESE
|
||||
const char *client_errors[]=
|
||||
{
|
||||
"Erro desconhecido do MySQL",
|
||||
"Não pode criar 'UNIX socket' (%d)",
|
||||
"Não pode se conectar ao servidor MySQL local através do 'socket' '%-.64s' (%d)",
|
||||
"Não pode se conectar ao servidor MySQL em '%-.64s' (%d)",
|
||||
"Não pode criar 'socket TCP/IP' (%d)",
|
||||
"'Host' servidor MySQL '%-.64s' (%d) desconhecido",
|
||||
"Servidor MySQL desapareceu",
|
||||
"Incompatibilidade de protocolos. Versão do Servidor: %d - Versão do Cliente: %d",
|
||||
"Cliente do MySQL com falta de memória",
|
||||
"Informação inválida de 'host'",
|
||||
"Localhost via 'UNIX socket'",
|
||||
"%-.64s via 'TCP/IP'",
|
||||
"Erro na negociação de acesso ao servidor",
|
||||
"Conexão perdida com servidor MySQL durante 'query'",
|
||||
"Comandos fora de sincronismo. Você não pode executar este comando agora",
|
||||
"%-.64s via 'named pipe'",
|
||||
"Não pode esperar pelo 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)",
|
||||
"Não pode abrir 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)",
|
||||
"Não pode estabelecer o estado do 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)",
|
||||
"Não pode inicializar conjunto de caracteres %-.64s (caminho %-.64s)",
|
||||
"Obteve pacote maior do que 'max_allowed_packet'"
|
||||
};
|
||||
|
||||
#else /* ENGLISH */
|
||||
const char *client_errors[]=
|
||||
{
|
||||
/* 2000 */ "Unknown MySQL error",
|
||||
/* 2001 */ "Can't create UNIX socket (%d)",
|
||||
/* 2002 */ "Can't connect to local MySQL server through socket '%-.64s' (%d)",
|
||||
/* 2003 */ "Can't connect to MySQL server on '%-.64s' (%d)",
|
||||
/* 2004 */ "Can't create TCP/IP socket (%d)",
|
||||
/* 2005 */ "Unknown MySQL Server Host '%-.64s' (%d)",
|
||||
/* 2006 */ "MySQL server has gone away",
|
||||
/* 2007 */ "Protocol mismatch. Server Version = %d Client Version = %d",
|
||||
/* 2008 */ "MySQL client run out of memory",
|
||||
/* 2009 */ "Wrong host info",
|
||||
/* 2010 */ "Localhost via UNIX socket",
|
||||
/* 2011 */ "%-.64s via TCP/IP",
|
||||
/* 2012 */ "Error in server handshake",
|
||||
/* 2013 */ "Lost connection to MySQL server during query",
|
||||
/* 2014 */ "Commands out of sync; you can't run this command now",
|
||||
/* 2015 */ "%-.64s via named pipe",
|
||||
/* 2016 */ "Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)",
|
||||
/* 2017 */ "Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)",
|
||||
/* 2018 */ "Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)",
|
||||
/* 2019 */ "Can't initialize character set %-.64s (path: %-.64s)",
|
||||
/* 2020 */ "Got packet bigger than 'max_allowed_packet'",
|
||||
/* 2021 */ "",
|
||||
/* 2022 */ "",
|
||||
/* 2023 */ "",
|
||||
/* 2024 */ "",
|
||||
/* 2025 */ "",
|
||||
/* 2026 */ "SSL connection error: %100s",
|
||||
/* 2027 */ "received malformed packet",
|
||||
/* 2028 */ "",
|
||||
/* 2029 */ "",
|
||||
/* 2030 */ "Statement is not prepared",
|
||||
/* 2031 */ "No data supplied for parameters in prepared statement",
|
||||
/* 2032 */ "",
|
||||
/* 2033 */ "",
|
||||
/* 2034 */ "",
|
||||
/* 2035 */ "",
|
||||
/* 2036 */ "Buffer type is not supported",
|
||||
/* 2037 */ "",
|
||||
/* 2038 */ "",
|
||||
/* 2039 */ "",
|
||||
/* 2040 */ "",
|
||||
/* 2041 */ "",
|
||||
/* 2042 */ "",
|
||||
/* 2043 */ "",
|
||||
/* 2044 */ "",
|
||||
/* 2045 */ "",
|
||||
/* 2046 */ "",
|
||||
/* 2047 */ "",
|
||||
/* 2048 */ "",
|
||||
/* 2049 */ "Connection with old authentication protocol refused.",
|
||||
/* 2050 */ "",
|
||||
/* 2051 */ "",
|
||||
/* 2052 */ "Prepared statement contains no metadata",
|
||||
/* 2053 */ "",
|
||||
/* 2054 */ "This feature is not implemented or disabled",
|
||||
/* 2055 */ "Lost connection to MySQL server at '%s', system error: %d",
|
||||
/* 2056 */ "",
|
||||
/* 2057 */ "The number of parameters in bound buffers differs from number of columns in resultset",
|
||||
/* 2058 */ "Plugin %s could not be loaded: %s",
|
||||
/* 2059 */ "Can't connect twice. Already connected",
|
||||
/* 2060 */ "Plugin doesn't support this function",
|
||||
""
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
void init_client_errs(void)
|
||||
{
|
||||
my_errmsg[CLIENT_ERRMAP] = &client_errors[0];
|
||||
}
|
96
module/Vendor/MDBC/libmariadb/errors.c
vendored
Normal file
96
module/Vendor/MDBC/libmariadb/errors.c
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
/* 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 */
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#include "mysys_err.h"
|
||||
|
||||
#ifndef SHARED_LIBRARY
|
||||
|
||||
const char * NEAR globerrs[GLOBERRS]=
|
||||
{
|
||||
"Can't create/write to file '%s' (Errcode: %d)",
|
||||
"Error reading file '%s' (Errcode: %d)",
|
||||
"Error writing file '%s' (Errcode: %d)",
|
||||
"Error on close of '%s' (Errcode: %d)",
|
||||
"Out of memory (Needed %u bytes)",
|
||||
"Error on delete of '%s' (Errcode: %d)",
|
||||
"Error on rename of '%s' to '%s' (Errcode: %d)",
|
||||
"",
|
||||
"Unexpected eof found when reading file '%s' (Errcode: %d)",
|
||||
"Can't lock file (Errcode: %d)",
|
||||
"Can't unlock file (Errcode: %d)",
|
||||
"Can't read dir of '%s' (Errcode: %d)",
|
||||
"Can't get stat of '%s' (Errcode: %d)",
|
||||
"Can't change size of file (Errcode: %d)",
|
||||
"Can't open stream from handle (Errcode: %d)",
|
||||
"Can't get working dirctory (Errcode: %d)",
|
||||
"Can't change dir to '%s' (Errcode: %d)",
|
||||
"Warning: '%s' had %d links",
|
||||
"Warning: %d files and %d streams is left open\n",
|
||||
"Disk is full writing '%s' (Errcode: %d). Waiting for someone to free space... (Expect up to %d secs delay for server to continue after freeing disk space)",
|
||||
"Can't create directory '%s' (Errcode: %d)",
|
||||
"Character set '%s' is not a compiled character set and is not specified in the '%s' file",
|
||||
"Out of resources when opening file '%s' (Errcode: %d)",
|
||||
"Can't read value for symlink '%s' (Error %d)",
|
||||
"Can't create symlink '%s' pointing at '%s' (Error %d)",
|
||||
"Error on realpath() on '%s' (Error %d)",
|
||||
"Can't sync file '%s' to disk (Errcode: %d)",
|
||||
"Collation '%s' is not a compiled collation and is not specified in the '%s' file",
|
||||
"File '%s' not found (Errcode: %d)",
|
||||
"File '%s' (fileno: %d) was not closed",
|
||||
"Can't change mode for file '%s' to 0x%lx (Error: %d)"
|
||||
};
|
||||
|
||||
void init_glob_errs(void)
|
||||
{
|
||||
my_errmsg[GLOB] = & globerrs[0];
|
||||
} /* init_glob_errs */
|
||||
|
||||
#else
|
||||
|
||||
void init_glob_errs()
|
||||
{
|
||||
my_errmsg[GLOB] = & globerrs[0];
|
||||
|
||||
EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)";
|
||||
EE(EE_CANTCREATEFILE) = "Can't create/write to file '%s' (Errcode: %d)";
|
||||
EE(EE_READ) = "Error reading file '%s' (Errcode: %d)";
|
||||
EE(EE_WRITE) = "Error writing file '%s' (Errcode: %d)";
|
||||
EE(EE_BADCLOSE) = "Error on close of '%'s (Errcode: %d)";
|
||||
EE(EE_OUTOFMEMORY) = "Out of memory (Needed %u bytes)";
|
||||
EE(EE_DELETE) = "Error on delete of '%s' (Errcode: %d)";
|
||||
EE(EE_LINK) = "Error on rename of '%s' to '%s' (Errcode: %d)";
|
||||
EE(EE_EOFERR) = "Unexpected eof found when reading file '%s' (Errcode: %d)";
|
||||
EE(EE_CANTLOCK) = "Can't lock file (Errcode: %d)";
|
||||
EE(EE_CANTUNLOCK) = "Can't unlock file (Errcode: %d)";
|
||||
EE(EE_DIR) = "Can't read dir of '%s' (Errcode: %d)";
|
||||
EE(EE_STAT) = "Can't get stat of '%s' (Errcode: %d)";
|
||||
EE(EE_CANT_CHSIZE) = "Can't change size of file (Errcode: %d)";
|
||||
EE(EE_CANT_OPEN_STREAM)= "Can't open stream from handle (Errcode: %d)";
|
||||
EE(EE_GETWD) = "Can't get working dirctory (Errcode: %d)";
|
||||
EE(EE_SETWD) = "Can't change dir to '%s' (Errcode: %d)";
|
||||
EE(EE_LINK_WARNING) = "Warning: '%s' had %d links";
|
||||
EE(EE_OPEN_WARNING) = "%d files and %d streams is left open\n";
|
||||
EE(EE_DISK_FULL) = "Disk is full writing '%s'. Waiting for someone to free space...";
|
||||
EE(EE_CANT_MKDIR) ="Can't create directory '%s' (Errcode: %d)";
|
||||
EE(EE_UNKNOWN_CHARSET)= "Character set is not a compiled character set and is not specified in the %s file";
|
||||
EE(EE_OUT_OF_FILERESOURCES)="Out of resources when opening file '%s' (Errcode: %d)";
|
||||
EE(EE_CANT_READLINK)="Can't read value for symlink '%s' (Error %d)";
|
||||
EE(EE_CANT_SYMLINK)="Can't create symlink '%s' pointing at '%s' (Error %d)";
|
||||
EE(EE_REALPATH)="Error on realpath() on '%s' (Error %d)";
|
||||
}
|
||||
#endif
|
175
module/Vendor/MDBC/libmariadb/get_password.c
vendored
Normal file
175
module/Vendor/MDBC/libmariadb/get_password.c
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
/************************************************************************************
|
||||
Copyright (C) 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
|
||||
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 <http://www.gnu.org/licenses>
|
||||
or write to the Free Software Foundation, Inc.,
|
||||
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
|
||||
*************************************************************************************/
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include "mysql.h"
|
||||
#include <m_string.h>
|
||||
#include <m_ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <termios.h>
|
||||
#else
|
||||
#include <conio.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* {{{ static char *get_password() */
|
||||
/*
|
||||
read password from device
|
||||
|
||||
SYNOPSIS
|
||||
get_password
|
||||
Hdl/file file handle
|
||||
buffer input buffer
|
||||
length buffer length
|
||||
|
||||
RETURN
|
||||
buffer zero terminated input buffer
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
static char *get_password(HANDLE Hdl, char *buffer, DWORD length)
|
||||
#else
|
||||
static char *get_password(FILE *file, char *buffer, int length)
|
||||
#endif
|
||||
{
|
||||
char inChar;
|
||||
int CharsProcessed= 1;
|
||||
#ifdef _WIN32
|
||||
DWORD Offset= 0;
|
||||
#else
|
||||
int Offset= 0;
|
||||
#endif
|
||||
|
||||
memset(buffer, 0, length);
|
||||
|
||||
do
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!ReadConsole(Hdl, &inChar, 1, &CharsProcessed, NULL) ||
|
||||
!CharsProcessed)
|
||||
break;
|
||||
#else
|
||||
inChar= fgetc(file);
|
||||
#endif
|
||||
|
||||
switch(inChar) {
|
||||
case '\b': /* backslash */
|
||||
if (Offset)
|
||||
{
|
||||
/* cursor is always at the end */
|
||||
Offset--;
|
||||
buffer[Offset]= 0;
|
||||
#ifdef _WIN32
|
||||
_cputs("\b \b");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
case '\r':
|
||||
break;
|
||||
default:
|
||||
buffer[Offset]= inChar;
|
||||
if (Offset < length - 2)
|
||||
Offset++;
|
||||
#ifdef _WIN32
|
||||
_cputs("*");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
} while (CharsProcessed && inChar != '\n' && inChar != '\r');
|
||||
return buffer;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ static char* get_tty_password */
|
||||
/*
|
||||
reads password from tty/console
|
||||
|
||||
SYNOPSIS
|
||||
get_tty_password()
|
||||
buffer input buffer
|
||||
length length of input buffer
|
||||
|
||||
DESCRIPTION
|
||||
reads a password from console (Windows) or tty without echoing
|
||||
it's characters. Input buffer must be allocated by calling function.
|
||||
|
||||
RETURNS
|
||||
buffer pointer to input buffer
|
||||
*/
|
||||
char* get_tty_password(char *prompt, char *buffer, int length)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD SaveState;
|
||||
HANDLE Hdl;
|
||||
int Offset= 0;
|
||||
DWORD CharsProcessed= 0;
|
||||
|
||||
if (prompt)
|
||||
fprintf(stderr, "%s", prompt);
|
||||
|
||||
if (!(Hdl= CreateFile("CONIN$",
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING, 0, NULL)))
|
||||
{
|
||||
/* todo: provide a graphical dialog */
|
||||
return buffer;
|
||||
}
|
||||
/* Save ConsoleMode and set ENABLE_PROCESSED_INPUT:
|
||||
CTRL+C is processed by the system and is not placed in the input buffer */
|
||||
GetConsoleMode(Hdl, &SaveState);
|
||||
SetConsoleMode(Hdl, ENABLE_PROCESSED_INPUT);
|
||||
|
||||
buffer= get_password(Hdl, buffer, length);
|
||||
SetConsoleMode(Hdl, SaveState);
|
||||
CloseHandle(Hdl);
|
||||
return buffer;
|
||||
#else
|
||||
struct termios term_old,
|
||||
term_new;
|
||||
FILE *readfrom;
|
||||
|
||||
if (prompt && isatty(fileno(stderr)))
|
||||
fputs(prompt, stderr);
|
||||
|
||||
if (!(readfrom= fopen("/dev/tty", "r")))
|
||||
readfrom= stdin;
|
||||
|
||||
/* try to disable echo */
|
||||
tcgetattr(fileno(readfrom), &term_old);
|
||||
term_new= term_old;
|
||||
term_new.c_cc[VMIN] = 1;
|
||||
term_new.c_cc[VTIME]= 0;
|
||||
term_new.c_lflag&= ~(ECHO | ISIG | ICANON | ECHONL);
|
||||
tcsetattr(fileno(readfrom), TCSADRAIN, &term_new);
|
||||
|
||||
buffer= get_password(readfrom, buffer, length);
|
||||
|
||||
if (isatty(fileno(readfrom)))
|
||||
tcsetattr(fileno(readfrom), TCSADRAIN, &term_old);
|
||||
|
||||
fclose(readfrom);
|
||||
|
||||
return buffer;
|
||||
#endif
|
||||
}
|
||||
/* }}} */
|
746
module/Vendor/MDBC/libmariadb/getopt.c
vendored
Normal file
746
module/Vendor/MDBC/libmariadb/getopt.c
vendored
Normal file
@ -0,0 +1,746 @@
|
||||
/* Getopt for GNU.
|
||||
NOTE: getopt is now part of the C library, so if you don't know what
|
||||
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
|
||||
before changing it!
|
||||
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
Changes by monty:
|
||||
- Added include of string.h when nessessary.
|
||||
- Removed two warnings from gcc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
The GNU C 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.
|
||||
|
||||
The GNU C 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 the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
|
||||
Ditto for AIX 3.2 and <stdlib.h>. */
|
||||
#ifndef _NO_PROTO
|
||||
#define _NO_PROTO
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS) && !defined(OS2)
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <my_global.h> /* Changes for mysys */
|
||||
#include <m_string.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* Don't include stdlib.h for non-GNU C libraries because some of them
|
||||
contain conflicting prototypes for getopt. */
|
||||
#include <stdlib.h>
|
||||
#endif /* GNU C library. */
|
||||
|
||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
||||
but it behaves differently for the user, since it allows the user
|
||||
to intersperse the options with the other arguments.
|
||||
|
||||
As `getopt' works, it permutes the elements of ARGV so that,
|
||||
when it is done, all the options precede everything else. Thus
|
||||
all application programs are extended to handle flexible argument order.
|
||||
|
||||
Setting the environment variable POSIXLY_CORRECT disables permutation.
|
||||
Then the behavior is completely standard.
|
||||
|
||||
GNU application programs can use a third alternative mode in which
|
||||
they can distinguish the relative order of options and other arguments. */
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
char *optarg = NULL;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns EOF, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
/* XXX 1003.2 says this must be 1 before any call. */
|
||||
int optind = 1;
|
||||
|
||||
/* The next char to be scanned in the option-element
|
||||
in which the last option character we returned was found.
|
||||
This allows us to pick up the scan where we left off.
|
||||
|
||||
If this is zero, or a null string, it means resume the scan
|
||||
by advancing to the next ARGV-element. */
|
||||
|
||||
static char *nextchar;
|
||||
|
||||
/* Callers store zero here to inhibit the error message
|
||||
for unrecognized options. */
|
||||
|
||||
int opterr = 1;
|
||||
|
||||
/* Set to an option character which was unrecognized.
|
||||
This must be initialized on some systems to avoid linking in the
|
||||
system's own getopt implementation. */
|
||||
|
||||
int optopt = '?';
|
||||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything,
|
||||
the default is REQUIRE_ORDER if the environment variable
|
||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
||||
|
||||
REQUIRE_ORDER means don't recognize them as options;
|
||||
stop option processing when the first non-option is seen.
|
||||
This is what Unix does.
|
||||
This mode of operation is selected by either setting the environment
|
||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
||||
of the list of option characters.
|
||||
|
||||
PERMUTE is the default. We permute the contents of ARGV as we scan,
|
||||
so that eventually all the non-options are at the end. This allows options
|
||||
to be given in any order, even with programs that were not written to
|
||||
expect this.
|
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were written
|
||||
to expect options and other ARGV-elements in any order and that care about
|
||||
the ordering of the two. We describe each non-option ARGV-element
|
||||
as if it were the argument of an option with character code 1.
|
||||
Using `-' as the first character of the list of option characters
|
||||
selects this mode of operation.
|
||||
|
||||
The special argument `--' forces an end of option-scanning regardless
|
||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
|
||||
|
||||
static enum
|
||||
{
|
||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
||||
} ordering;
|
||||
|
||||
/* Value of POSIXLY_CORRECT environment variable. */
|
||||
static char *posixly_correct;
|
||||
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* We want to avoid inclusion of string.h with non-GNU libraries
|
||||
because there are many ways it can cause trouble.
|
||||
On some systems, it contains special magic macros that don't work
|
||||
in GCC. */
|
||||
#include <string.h>
|
||||
#define my_index strchr
|
||||
#else
|
||||
|
||||
/* Avoid depending on library functions or files
|
||||
whose names are inconsistent. */
|
||||
|
||||
static char *
|
||||
my_index (const char *str, int chr)
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
if (*str == chr)
|
||||
return (char *) str;
|
||||
str++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If using GCC, we can safely declare strlen this way.
|
||||
If not using GCC, it is ok not to declare it. */
|
||||
#ifdef __GNUC__
|
||||
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
|
||||
That was relevant to code that was here before. */
|
||||
#if !defined (__STDC__) || !__STDC__
|
||||
/* gcc with -traditional declares the built-in strlen to return int,
|
||||
and has done so at least since version 2.4.5. -- rms. */
|
||||
extern int strlen (const char *);
|
||||
#endif /* not __STDC__ */
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#endif /* not __GNU_LIBRARY__ */
|
||||
|
||||
/* Handle permutation of arguments. */
|
||||
|
||||
/* Describe the part of ARGV that contains non-options that have
|
||||
been skipped. `first_nonopt' is the index in ARGV of the first of them;
|
||||
`last_nonopt' is the index after the last of them. */
|
||||
|
||||
static int first_nonopt;
|
||||
static int last_nonopt;
|
||||
|
||||
/* Exchange two adjacent subsequences of ARGV.
|
||||
One subsequence is elements [first_nonopt,last_nonopt)
|
||||
which contains all the non-options that have been skipped so far.
|
||||
The other is elements [last_nonopt,optind), which contains all
|
||||
the options processed since those non-options were skipped.
|
||||
|
||||
`first_nonopt' and `last_nonopt' are relocated so that they describe
|
||||
the new indices of the non-options in ARGV after they are moved. */
|
||||
|
||||
static void
|
||||
exchange (char **argv)
|
||||
{
|
||||
int bottom = first_nonopt;
|
||||
int middle = last_nonopt;
|
||||
int top = optind;
|
||||
char *tem;
|
||||
|
||||
/* Exchange the shorter segment with the far end of the longer segment.
|
||||
That puts the shorter segment into the right place.
|
||||
It leaves the longer segment in the right place overall,
|
||||
but it consists of two parts that need to be swapped next. */
|
||||
|
||||
while (top > middle && middle > bottom)
|
||||
{
|
||||
if (top - middle > middle - bottom)
|
||||
{
|
||||
/* Bottom segment is the short one. */
|
||||
int len = middle - bottom;
|
||||
register int i;
|
||||
|
||||
/* Swap it with the top part of the top segment. */
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
tem = argv[bottom + i];
|
||||
argv[bottom + i] = argv[top - (middle - bottom) + i];
|
||||
argv[top - (middle - bottom) + i] = tem;
|
||||
}
|
||||
/* Exclude the moved bottom segment from further swapping. */
|
||||
top -= len;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Top segment is the short one. */
|
||||
int len = top - middle;
|
||||
register int i;
|
||||
|
||||
/* Swap it with the bottom part of the bottom segment. */
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
tem = argv[bottom + i];
|
||||
argv[bottom + i] = argv[middle + i];
|
||||
argv[middle + i] = tem;
|
||||
}
|
||||
/* Exclude the moved top segment from further swapping. */
|
||||
bottom += len;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update records for the slots the non-options now occupy. */
|
||||
|
||||
first_nonopt += (optind - last_nonopt);
|
||||
last_nonopt = optind;
|
||||
}
|
||||
|
||||
/* Initialize the internal data when the first call is made. */
|
||||
|
||||
static const char *
|
||||
_getopt_initialize (const char *optstring)
|
||||
{
|
||||
/* Start processing options with ARGV-element 1 (since ARGV-element 0
|
||||
is the program name); the sequence of previously skipped
|
||||
non-option ARGV-elements is empty. */
|
||||
|
||||
first_nonopt = last_nonopt = optind = 1;
|
||||
|
||||
nextchar = NULL;
|
||||
|
||||
posixly_correct = getenv ("POSIXLY_CORRECT");
|
||||
|
||||
/* Determine how to handle the ordering of options and nonoptions. */
|
||||
|
||||
if (optstring[0] == '-')
|
||||
{
|
||||
ordering = RETURN_IN_ORDER;
|
||||
++optstring;
|
||||
}
|
||||
else if (optstring[0] == '+')
|
||||
{
|
||||
ordering = REQUIRE_ORDER;
|
||||
++optstring;
|
||||
}
|
||||
else if (posixly_correct != NULL)
|
||||
ordering = REQUIRE_ORDER;
|
||||
else
|
||||
ordering = PERMUTE;
|
||||
|
||||
return optstring;
|
||||
}
|
||||
|
||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
||||
given in OPTSTRING.
|
||||
|
||||
If an element of ARGV starts with '-', and is not exactly "-" or "--",
|
||||
then it is an option element. The characters of this element
|
||||
(aside from the initial '-') are option characters. If `getopt'
|
||||
is called repeatedly, it returns successively each of the option characters
|
||||
from each of the option elements.
|
||||
|
||||
If `getopt' finds another option character, it returns that character,
|
||||
updating `optind' and `nextchar' so that the next call to `getopt' can
|
||||
resume the scan with the following option character or ARGV-element.
|
||||
|
||||
If there are no more option characters, `getopt' returns `EOF'.
|
||||
Then `optind' is the index in ARGV of the first ARGV-element
|
||||
that is not an option. (The ARGV-elements have been permuted
|
||||
so that those that are not options now come last.)
|
||||
|
||||
OPTSTRING is a string containing the legitimate option characters.
|
||||
If an option character is seen that is not listed in OPTSTRING,
|
||||
return '?' after printing an error message. If you set `opterr' to
|
||||
zero, the error message is suppressed but we still return '?'.
|
||||
|
||||
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
|
||||
so the following text in the same ARGV-element, or the text of the following
|
||||
ARGV-element, is returned in `optarg'. Two colons mean an option that
|
||||
wants an optional arg; if there is text in the current ARGV-element,
|
||||
it is returned in `optarg', otherwise `optarg' is set to zero.
|
||||
|
||||
If OPTSTRING starts with `-' or `+', it requests different methods of
|
||||
handling the non-option ARGV-elements.
|
||||
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
|
||||
|
||||
Long-named options begin with `--' instead of `-'.
|
||||
Their names may be abbreviated as long as the abbreviation is unique
|
||||
or is an exact match for some defined option. If they have an
|
||||
argument, it follows the option name in the same ARGV-element, separated
|
||||
from the option name by a `=', or else the in next ARGV-element.
|
||||
When `getopt' finds a long-named option, it returns 0 if that option's
|
||||
`flag' field is nonzero, the value of the option's `val' field
|
||||
if the `flag' field is zero.
|
||||
|
||||
The elements of ARGV aren't really const, because we permute them.
|
||||
But we pretend they're const in the prototype to be compatible
|
||||
with other systems.
|
||||
|
||||
LONGOPTS is a vector of `struct option' terminated by an
|
||||
element containing a name which is zero.
|
||||
|
||||
LONGIND returns the index in LONGOPT of the long-named option found.
|
||||
It is only valid when a long-named option has been found by the most
|
||||
recent call.
|
||||
|
||||
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
|
||||
long-named options. */
|
||||
|
||||
int
|
||||
_getopt_internal (int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only)
|
||||
{
|
||||
optarg = NULL;
|
||||
|
||||
if (optind == 0)
|
||||
optstring = _getopt_initialize (optstring);
|
||||
|
||||
if (nextchar == NULL || *nextchar == '\0')
|
||||
{
|
||||
/* Advance to the next ARGV-element. */
|
||||
|
||||
if (ordering == PERMUTE)
|
||||
{
|
||||
/* If we have just processed some options following some non-options,
|
||||
exchange them so that the options come first. */
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||
exchange ((char **) argv);
|
||||
else if (last_nonopt != optind)
|
||||
first_nonopt = optind;
|
||||
|
||||
/* Skip any additional non-options
|
||||
and extend the range of non-options previously skipped. */
|
||||
|
||||
while (optind < argc
|
||||
&& (argv[optind][0] != '-' || argv[optind][1] == '\0'))
|
||||
optind++;
|
||||
last_nonopt = optind;
|
||||
}
|
||||
|
||||
/* The special ARGV-element `--' means premature end of options.
|
||||
Skip it like a null option,
|
||||
then exchange with previous non-options as if it were an option,
|
||||
then skip everything else like a non-option. */
|
||||
|
||||
if (optind != argc && !strcmp (argv[optind], "--"))
|
||||
{
|
||||
optind++;
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||
exchange ((char **) argv);
|
||||
else if (first_nonopt == last_nonopt)
|
||||
first_nonopt = optind;
|
||||
last_nonopt = argc;
|
||||
|
||||
optind = argc;
|
||||
}
|
||||
|
||||
/* If we have done all the ARGV-elements, stop the scan
|
||||
and back over any non-options that we skipped and permuted. */
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
/* Set the next-arg-index to point at the non-options
|
||||
that we previously skipped, so the caller will digest them. */
|
||||
if (first_nonopt != last_nonopt)
|
||||
optind = first_nonopt;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* If we have come to a non-option and did not permute it,
|
||||
either stop the scan or describe it to the caller and pass it by. */
|
||||
|
||||
if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
|
||||
{
|
||||
if (ordering == REQUIRE_ORDER)
|
||||
return EOF;
|
||||
optarg = argv[optind++];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* We have found another option-ARGV-element.
|
||||
Skip the initial punctuation. */
|
||||
|
||||
nextchar = (argv[optind] + 1
|
||||
+ (longopts != NULL && argv[optind][1] == '-'));
|
||||
}
|
||||
|
||||
/* Decode the current option-ARGV-element. */
|
||||
|
||||
/* Check whether the ARGV-element is a long option.
|
||||
|
||||
If long_only and the ARGV-element has the form "-f", where f is
|
||||
a valid short option, don't consider it an abbreviated form of
|
||||
a long option that starts with f. Otherwise there would be no
|
||||
way to give the -f short option.
|
||||
|
||||
On the other hand, if there's a long option "fubar" and
|
||||
the ARGV-element is "-fu", do consider that an abbreviation of
|
||||
the long option, just like "--fu", and not "-f" with arg "u".
|
||||
|
||||
This distinction seems to be the most useful approach. */
|
||||
|
||||
if (longopts != NULL
|
||||
&& (argv[optind][1] == '-'
|
||||
|| (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
|
||||
{
|
||||
char *nameend;
|
||||
const struct option *p;
|
||||
const struct option *pfound = NULL;
|
||||
int exact = 0;
|
||||
int ambig = 0;
|
||||
int indfound=0; /* Keep gcc happy */
|
||||
int option_index;
|
||||
|
||||
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
/* Test all long options for either exact match
|
||||
or abbreviated matches. */
|
||||
for (p = longopts, option_index = 0; p->name; p++, option_index++)
|
||||
if (!strncmp (p->name, nextchar, nameend - nextchar))
|
||||
{
|
||||
if ((size_t) (nameend - nextchar) == (size_t) strlen (p->name))
|
||||
{
|
||||
/* Exact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
exact = 1;
|
||||
break;
|
||||
}
|
||||
else if (pfound == NULL)
|
||||
{
|
||||
/* First nonexact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
}
|
||||
else
|
||||
/* Second or later nonexact match found. */
|
||||
ambig = 1;
|
||||
}
|
||||
|
||||
if (ambig && !exact)
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, "%s: option `%s' is ambiguous\n",
|
||||
argv[0], argv[optind]);
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
|
||||
if (pfound != NULL)
|
||||
{
|
||||
option_index = indfound;
|
||||
optind++;
|
||||
if (*nameend)
|
||||
{
|
||||
/* Don't test has_arg with >, because some C compilers don't
|
||||
allow it to be used on enums. */
|
||||
if (pfound->has_arg)
|
||||
optarg = nameend + 1;
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
"%s: option `--%s' doesn't allow an argument\n",
|
||||
argv[0], pfound->name);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr,
|
||||
"%s: option `%c%s' doesn't allow an argument\n",
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
else if (pfound->has_arg == 1)
|
||||
{
|
||||
if (optind < argc)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, "%s: option `%s' requires an argument\n",
|
||||
argv[0], argv[optind - 1]);
|
||||
nextchar += strlen (nextchar);
|
||||
return optstring[0] == ':' ? ':' : '?';
|
||||
}
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
if (longind != NULL)
|
||||
*longind = option_index;
|
||||
if (pfound->flag)
|
||||
{
|
||||
*(pfound->flag) = pfound->val;
|
||||
return 0;
|
||||
}
|
||||
return pfound->val;
|
||||
}
|
||||
|
||||
/* Can't find it as a long option. If this is not getopt_long_only,
|
||||
or the option starts with '--' or is not a valid short
|
||||
option, then it's an error.
|
||||
Otherwise interpret it as a short option. */
|
||||
if (!long_only || argv[optind][1] == '-'
|
||||
|| my_index (optstring, *nextchar) == NULL)
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (argv[optind][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr, "%s: unrecognized option `--%s'\n",
|
||||
argv[0], nextchar);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
|
||||
argv[0], argv[optind][0], nextchar);
|
||||
}
|
||||
nextchar = (char *) "";
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
/* Look at and handle the next short option-character. */
|
||||
|
||||
{
|
||||
char c = *nextchar++;
|
||||
char *temp = my_index (optstring, c);
|
||||
|
||||
/* Increment `optind' when we start to process its last character. */
|
||||
if (*nextchar == '\0')
|
||||
++optind;
|
||||
|
||||
if (temp == NULL || c == ':')
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (posixly_correct)
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
|
||||
else
|
||||
fprintf (stderr, "%s: invalid option -- %c\n", argv[0], c);
|
||||
}
|
||||
optopt = c;
|
||||
return '?';
|
||||
}
|
||||
if (temp[1] == ':')
|
||||
{
|
||||
if (temp[2] == ':')
|
||||
{
|
||||
/* This is an option that accepts an argument optionally. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
optarg = NULL;
|
||||
nextchar = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an option that requires an argument. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
/* If we end this ARGV-element by taking the rest as an arg,
|
||||
we must advance to the next element now. */
|
||||
optind++;
|
||||
}
|
||||
else if (optind == argc)
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
fprintf (stderr, "%s: option requires an argument -- %c\n",
|
||||
argv[0], c);
|
||||
}
|
||||
optopt = c;
|
||||
if (optstring[0] == ':')
|
||||
c = ':';
|
||||
else
|
||||
c = '?';
|
||||
}
|
||||
else
|
||||
/* We already incremented `optind' once;
|
||||
increment it again when taking next ARGV-elt as argument. */
|
||||
optarg = argv[optind++];
|
||||
nextchar = NULL;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __EMX__
|
||||
int getopt (int argc, char **argv, __const__ char *optstring)
|
||||
#else
|
||||
int
|
||||
getopt (int argc, char *const *argv, const char *optstring)
|
||||
#endif
|
||||
{
|
||||
return _getopt_internal (argc, argv, optstring,
|
||||
(const struct option *) 0,
|
||||
(int *) 0,
|
||||
0);
|
||||
}
|
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
/* Compile with -DTEST to make an executable for use in testing
|
||||
the above definition of `getopt'. */
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
|
||||
c = getopt (argc, argv, "abc:d:0123456789");
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
170
module/Vendor/MDBC/libmariadb/getopt1.c
vendored
Normal file
170
module/Vendor/MDBC/libmariadb/getopt1.c
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
The GNU C 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.
|
||||
|
||||
The GNU C 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 the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <my_global.h>
|
||||
#include "getopt.h"
|
||||
|
||||
#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS) && !defined(OS2)
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <stdlib.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
If an option that starts with '-' (not '--') doesn't match a long option,
|
||||
but does match a short option, it is parsed as a short option
|
||||
instead. */
|
||||
|
||||
int
|
||||
getopt_long_only (int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
||||
}
|
||||
|
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
644
module/Vendor/MDBC/libmariadb/hash.c
vendored
Normal file
644
module/Vendor/MDBC/libmariadb/hash.c
vendored
Normal file
@ -0,0 +1,644 @@
|
||||
/************************************************************************************
|
||||
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 <http://www.gnu.org/licenses>
|
||||
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
|
||||
*************************************************************************************/
|
||||
|
||||
/* The hash functions used for saveing keys */
|
||||
/* One of key_length or key_length_offset must be given */
|
||||
/* Key length of 0 isn't allowed */
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#include <m_string.h>
|
||||
#include <m_ctype.h>
|
||||
#include "hash.h"
|
||||
|
||||
#define NO_RECORD ((uint) -1)
|
||||
#define LOWFIND 1
|
||||
#define LOWUSED 2
|
||||
#define HIGHFIND 4
|
||||
#define HIGHUSED 8
|
||||
|
||||
static uint hash_mask(uint hashnr,uint buffmax,uint maxlength);
|
||||
static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink);
|
||||
static uint calc_hashnr(const uchar *key,uint length);
|
||||
static uint calc_hashnr_caseup(const uchar *key,uint length);
|
||||
static int hashcmp(HASH *hash,HASH_LINK *pos,const uchar *key,uint length);
|
||||
|
||||
|
||||
my_bool _hash_init(HASH *hash,uint size,uint key_offset,uint key_length,
|
||||
hash_get_key get_key,
|
||||
void (*free_element)(void*),uint flags CALLER_INFO_PROTO)
|
||||
{
|
||||
DBUG_ENTER("hash_init");
|
||||
DBUG_PRINT("enter",("hash: %lx size: %d",hash,size));
|
||||
|
||||
hash->records=0;
|
||||
if (my_init_dynamic_array_ci(&hash->array,sizeof(HASH_LINK),size,0))
|
||||
{
|
||||
hash->free=0; /* Allow call to hash_free */
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
hash->key_offset=key_offset;
|
||||
hash->key_length=key_length;
|
||||
hash->blength=1;
|
||||
hash->current_record= NO_RECORD; /* For the future */
|
||||
hash->get_key=get_key;
|
||||
hash->free=free_element;
|
||||
hash->flags=flags;
|
||||
if (flags & HASH_CASE_INSENSITIVE)
|
||||
hash->calc_hashnr=calc_hashnr_caseup;
|
||||
else
|
||||
hash->calc_hashnr=calc_hashnr;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
void hash_free(HASH *hash)
|
||||
{
|
||||
DBUG_ENTER("hash_free");
|
||||
if (hash->free)
|
||||
{
|
||||
uint i,records;
|
||||
HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*);
|
||||
for (i=0,records=hash->records ; i < records ; i++)
|
||||
(*hash->free)(data[i].data);
|
||||
hash->free=0;
|
||||
}
|
||||
delete_dynamic(&hash->array);
|
||||
hash->records=0;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
/* some helper functions */
|
||||
|
||||
/*
|
||||
This function is char* instead of uchar* as HPUX11 compiler can't
|
||||
handle inline functions that are not defined as native types
|
||||
*/
|
||||
|
||||
static inline char*
|
||||
hash_key(HASH *hash,const uchar *record,uint *length,my_bool first)
|
||||
{
|
||||
if (hash->get_key)
|
||||
return (*hash->get_key)(record,(uint *)length,first);
|
||||
*length=hash->key_length;
|
||||
return (uchar*) record+hash->key_offset;
|
||||
}
|
||||
|
||||
/* Calculate pos according to keys */
|
||||
|
||||
static uint hash_mask(uint hashnr,uint buffmax,uint maxlength)
|
||||
{
|
||||
if ((hashnr & (buffmax-1)) < maxlength) return (hashnr & (buffmax-1));
|
||||
return (hashnr & ((buffmax >> 1) -1));
|
||||
}
|
||||
|
||||
static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax,
|
||||
uint maxlength)
|
||||
{
|
||||
uint length;
|
||||
uchar *key= (uchar*) hash_key(hash,pos->data,&length,0);
|
||||
return hash_mask((*hash->calc_hashnr)(key,length),buffmax,maxlength);
|
||||
}
|
||||
|
||||
#ifndef NEW_HASH_FUNCTION
|
||||
|
||||
/* Calc hashvalue for a key */
|
||||
|
||||
static uint calc_hashnr(const uchar *key,uint length)
|
||||
{
|
||||
register uint nr=1, nr2=4;
|
||||
while (length--)
|
||||
{
|
||||
nr^= (((nr & 63)+nr2)*((uint) (uchar) *key++))+ (nr << 8);
|
||||
nr2+=3;
|
||||
}
|
||||
return((uint) nr);
|
||||
}
|
||||
|
||||
/* Calc hashvalue for a key, case indepenently */
|
||||
|
||||
static uint calc_hashnr_caseup(const uchar *key,uint length)
|
||||
{
|
||||
register uint nr=1, nr2=4;
|
||||
while (length--)
|
||||
{
|
||||
nr^= (((nr & 63)+nr2)*((uint) (uchar) toupper(*key++)))+ (nr << 8);
|
||||
nr2+=3;
|
||||
}
|
||||
return((uint) nr);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Fowler/Noll/Vo hash
|
||||
*
|
||||
* The basis of the hash algorithm was taken from an idea sent by email to the
|
||||
* IEEE Posix P1003.2 mailing list from Phong Vo (kpv@research.att.com) and
|
||||
* Glenn Fowler (gsf@research.att.com). Landon Curt Noll (chongo@toad.com)
|
||||
* later improved on their algorithm.
|
||||
*
|
||||
* The magic is in the interesting relationship between the special prime
|
||||
* 16777619 (2^24 + 403) and 2^32 and 2^8.
|
||||
*
|
||||
* This hash produces the fewest collisions of any function that we've seen so
|
||||
* far, and works well on both numbers and strings.
|
||||
*/
|
||||
|
||||
uint calc_hashnr(const uchar *key, uint len)
|
||||
{
|
||||
const uchar *end=key+len;
|
||||
uint hash;
|
||||
for (hash = 0; key < end; key++)
|
||||
{
|
||||
hash *= 16777619;
|
||||
hash ^= (uint) *(uchar*) key;
|
||||
}
|
||||
return (hash);
|
||||
}
|
||||
|
||||
uint calc_hashnr_caseup(const uchar *key, uint len)
|
||||
{
|
||||
const uchar *end=key+len;
|
||||
uint hash;
|
||||
for (hash = 0; key < end; key++)
|
||||
{
|
||||
hash *= 16777619;
|
||||
hash ^= (uint) (uchar) toupper(*key);
|
||||
}
|
||||
return (hash);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __SUNPRO_C /* SUNPRO can't handle this */
|
||||
static inline
|
||||
#endif
|
||||
unsigned int rec_hashnr(HASH *hash,const uchar *record)
|
||||
{
|
||||
uint length;
|
||||
uchar *key= (uchar*) hash_key(hash,record,&length,0);
|
||||
return (*hash->calc_hashnr)(key,length);
|
||||
}
|
||||
|
||||
|
||||
/* Search after a record based on a key */
|
||||
/* Sets info->current_ptr to found record */
|
||||
|
||||
gptr hash_search(HASH *hash,const uchar *key,uint length)
|
||||
{
|
||||
HASH_LINK *pos;
|
||||
uint flag,idx;
|
||||
DBUG_ENTER("hash_search");
|
||||
|
||||
flag=1;
|
||||
if (hash->records)
|
||||
{
|
||||
idx=hash_mask((*hash->calc_hashnr)(key,length ? length :
|
||||
hash->key_length),
|
||||
hash->blength,hash->records);
|
||||
do
|
||||
{
|
||||
pos= dynamic_element(&hash->array,idx,HASH_LINK*);
|
||||
if (!hashcmp(hash,pos,key,length))
|
||||
{
|
||||
DBUG_PRINT("exit",("found key at %d",idx));
|
||||
hash->current_record= idx;
|
||||
DBUG_RETURN (pos->data);
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
flag=0; /* Reset flag */
|
||||
if (hash_rec_mask(hash,pos,hash->blength,hash->records) != idx)
|
||||
break; /* Wrong link */
|
||||
}
|
||||
}
|
||||
while ((idx=pos->next) != NO_RECORD);
|
||||
}
|
||||
hash->current_record= NO_RECORD;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
/* Get next record with identical key */
|
||||
/* Can only be called if previous calls was hash_search */
|
||||
|
||||
gptr hash_next(HASH *hash,const uchar *key,uint length)
|
||||
{
|
||||
HASH_LINK *pos;
|
||||
uint idx;
|
||||
|
||||
if (hash->current_record != NO_RECORD)
|
||||
{
|
||||
HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*);
|
||||
for (idx=data[hash->current_record].next; idx != NO_RECORD ; idx=pos->next)
|
||||
{
|
||||
pos=data+idx;
|
||||
if (!hashcmp(hash,pos,key,length))
|
||||
{
|
||||
hash->current_record= idx;
|
||||
return pos->data;
|
||||
}
|
||||
}
|
||||
hash->current_record=NO_RECORD;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Change link from pos to new_link */
|
||||
|
||||
static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink)
|
||||
{
|
||||
HASH_LINK *old_link;
|
||||
do
|
||||
{
|
||||
old_link=array+next_link;
|
||||
}
|
||||
while ((next_link=old_link->next) != find);
|
||||
old_link->next= newlink;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Compare a key in a record to a whole key. Return 0 if identical */
|
||||
|
||||
static int hashcmp(HASH *hash,HASH_LINK *pos,const uchar *key,uint length)
|
||||
{
|
||||
uint rec_keylength;
|
||||
uchar *rec_key= (uchar*) hash_key(hash,pos->data,&rec_keylength,1);
|
||||
return (length && length != rec_keylength) ||
|
||||
memcmp(rec_key,key,rec_keylength);
|
||||
}
|
||||
|
||||
|
||||
/* Write a hash-key to the hash-index */
|
||||
|
||||
my_bool hash_insert(HASH *info,const uchar *record)
|
||||
{
|
||||
int flag;
|
||||
uint halfbuff,hash_nr,first_index,idx;
|
||||
uchar *ptr_to_rec,*ptr_to_rec2;
|
||||
HASH_LINK *data,*empty,*gpos,*gpos2,*pos;
|
||||
|
||||
LINT_INIT(gpos); LINT_INIT(gpos2);
|
||||
LINT_INIT(ptr_to_rec); LINT_INIT(ptr_to_rec2);
|
||||
|
||||
flag=0;
|
||||
if (!(empty=(HASH_LINK*) alloc_dynamic(&info->array)))
|
||||
return(TRUE); /* No more memory */
|
||||
|
||||
info->current_record= NO_RECORD;
|
||||
data=dynamic_element(&info->array,0,HASH_LINK*);
|
||||
halfbuff= info->blength >> 1;
|
||||
|
||||
idx=first_index=info->records-halfbuff;
|
||||
if (idx != info->records) /* If some records */
|
||||
{
|
||||
do
|
||||
{
|
||||
pos=data+idx;
|
||||
hash_nr=rec_hashnr(info,pos->data);
|
||||
if (flag == 0) /* First loop; Check if ok */
|
||||
if (hash_mask(hash_nr,info->blength,info->records) != first_index)
|
||||
break;
|
||||
if (!(hash_nr & halfbuff))
|
||||
{ /* Key will not move */
|
||||
if (!(flag & LOWFIND))
|
||||
{
|
||||
if (flag & HIGHFIND)
|
||||
{
|
||||
flag=LOWFIND | HIGHFIND;
|
||||
/* key shall be moved to the current empty position */
|
||||
gpos=empty;
|
||||
ptr_to_rec=pos->data;
|
||||
empty=pos; /* This place is now free */
|
||||
}
|
||||
else
|
||||
{
|
||||
flag=LOWFIND | LOWUSED; /* key isn't changed */
|
||||
gpos=pos;
|
||||
ptr_to_rec=pos->data;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(flag & LOWUSED))
|
||||
{
|
||||
/* Change link of previous LOW-key */
|
||||
gpos->data=ptr_to_rec;
|
||||
gpos->next=(uint) (pos-data);
|
||||
flag= (flag & HIGHFIND) | (LOWFIND | LOWUSED);
|
||||
}
|
||||
gpos=pos;
|
||||
ptr_to_rec=pos->data;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* key will be moved */
|
||||
if (!(flag & HIGHFIND))
|
||||
{
|
||||
flag= (flag & LOWFIND) | HIGHFIND;
|
||||
/* key shall be moved to the last (empty) position */
|
||||
gpos2 = empty; empty=pos;
|
||||
ptr_to_rec2=pos->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(flag & HIGHUSED))
|
||||
{
|
||||
/* Change link of previous hash-key and save */
|
||||
gpos2->data=ptr_to_rec2;
|
||||
gpos2->next=(uint) (pos-data);
|
||||
flag= (flag & LOWFIND) | (HIGHFIND | HIGHUSED);
|
||||
}
|
||||
gpos2=pos;
|
||||
ptr_to_rec2=pos->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
while ((idx=pos->next) != NO_RECORD);
|
||||
|
||||
if ((flag & (LOWFIND | LOWUSED)) == LOWFIND)
|
||||
{
|
||||
gpos->data=ptr_to_rec;
|
||||
gpos->next=NO_RECORD;
|
||||
}
|
||||
if ((flag & (HIGHFIND | HIGHUSED)) == HIGHFIND)
|
||||
{
|
||||
gpos2->data=ptr_to_rec2;
|
||||
gpos2->next=NO_RECORD;
|
||||
}
|
||||
}
|
||||
/* Check if we are at the empty position */
|
||||
|
||||
idx=hash_mask(rec_hashnr(info,record),info->blength,info->records+1);
|
||||
pos=data+idx;
|
||||
if (pos == empty)
|
||||
{
|
||||
pos->data=(uchar*) record;
|
||||
pos->next=NO_RECORD;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check if more records in same hash-nr family */
|
||||
empty[0]=pos[0];
|
||||
gpos=data+hash_rec_mask(info,pos,info->blength,info->records+1);
|
||||
if (pos == gpos)
|
||||
{
|
||||
pos->data=(uchar*) record;
|
||||
pos->next=(uint) (empty - data);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos->data=(uchar*) record;
|
||||
pos->next=NO_RECORD;
|
||||
movelink(data,(uint) (pos-data),(uint) (gpos-data),(uint) (empty-data));
|
||||
}
|
||||
}
|
||||
if (++info->records == info->blength)
|
||||
info->blength+= info->blength;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
** Remove one record from hash-table. The record with the same record
|
||||
** ptr is removed.
|
||||
** if there is a free-function it's called for record if found
|
||||
******************************************************************************/
|
||||
|
||||
my_bool hash_delete(HASH *hash,uchar *record)
|
||||
{
|
||||
uint blength,pos2,pos_hashnr,lastpos_hashnr,idx,empty_index;
|
||||
HASH_LINK *data,*lastpos,*gpos,*pos,*pos3,*empty;
|
||||
DBUG_ENTER("hash_delete");
|
||||
if (!hash->records)
|
||||
DBUG_RETURN(1);
|
||||
|
||||
blength=hash->blength;
|
||||
data=dynamic_element(&hash->array,0,HASH_LINK*);
|
||||
/* Search after record with key */
|
||||
pos=data+ hash_mask(rec_hashnr(hash,record),blength,hash->records);
|
||||
gpos = 0;
|
||||
|
||||
while (pos->data != record)
|
||||
{
|
||||
gpos=pos;
|
||||
if (pos->next == NO_RECORD)
|
||||
DBUG_RETURN(1); /* Key not found */
|
||||
pos=data+pos->next;
|
||||
}
|
||||
|
||||
if ( --(hash->records) < hash->blength >> 1) hash->blength>>=1;
|
||||
hash->current_record= NO_RECORD;
|
||||
lastpos=data+hash->records;
|
||||
|
||||
/* Remove link to record */
|
||||
empty=pos; empty_index=(uint) (empty-data);
|
||||
if (gpos)
|
||||
gpos->next=pos->next; /* unlink current ptr */
|
||||
else if (pos->next != NO_RECORD)
|
||||
{
|
||||
empty=data+(empty_index=pos->next);
|
||||
pos->data=empty->data;
|
||||
pos->next=empty->next;
|
||||
}
|
||||
|
||||
if (empty == lastpos) /* last key at wrong pos or no next link */
|
||||
goto exit;
|
||||
|
||||
/* Move the last key (lastpos) */
|
||||
lastpos_hashnr=rec_hashnr(hash,lastpos->data);
|
||||
/* pos is where lastpos should be */
|
||||
pos=data+hash_mask(lastpos_hashnr,hash->blength,hash->records);
|
||||
if (pos == empty) /* Move to empty position. */
|
||||
{
|
||||
empty[0]=lastpos[0];
|
||||
goto exit;
|
||||
}
|
||||
pos_hashnr=rec_hashnr(hash,pos->data);
|
||||
/* pos3 is where the pos should be */
|
||||
pos3= data+hash_mask(pos_hashnr,hash->blength,hash->records);
|
||||
if (pos != pos3)
|
||||
{ /* pos is on wrong posit */
|
||||
empty[0]=pos[0]; /* Save it here */
|
||||
pos[0]=lastpos[0]; /* This should be here */
|
||||
movelink(data,(uint) (pos-data),(uint) (pos3-data),empty_index);
|
||||
goto exit;
|
||||
}
|
||||
pos2= hash_mask(lastpos_hashnr,blength,hash->records+1);
|
||||
if (pos2 == hash_mask(pos_hashnr,blength,hash->records+1))
|
||||
{ /* Identical key-positions */
|
||||
if (pos2 != hash->records)
|
||||
{
|
||||
empty[0]=lastpos[0];
|
||||
movelink(data,(uint) (lastpos-data),(uint) (pos-data),empty_index);
|
||||
goto exit;
|
||||
}
|
||||
idx= (uint) (pos-data); /* Link pos->next after lastpos */
|
||||
}
|
||||
else idx= NO_RECORD; /* Different positions merge */
|
||||
|
||||
empty[0]=lastpos[0];
|
||||
movelink(data,idx,empty_index,pos->next);
|
||||
pos->next=empty_index;
|
||||
|
||||
exit:
|
||||
VOID(pop_dynamic(&hash->array));
|
||||
if (hash->free)
|
||||
(*hash->free)((uchar*) record);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
/*
|
||||
Update keys when record has changed.
|
||||
This is much more efficent than using a delete & insert.
|
||||
*/
|
||||
|
||||
my_bool hash_update(HASH *hash,uchar *record,uchar *old_key,uint old_key_length)
|
||||
{
|
||||
uint idx,new_index,new_pos_index,blength,records,empty;
|
||||
HASH_LINK org_link,*data,*previous,*pos;
|
||||
DBUG_ENTER("hash_update");
|
||||
|
||||
data=dynamic_element(&hash->array,0,HASH_LINK*);
|
||||
blength=hash->blength; records=hash->records;
|
||||
|
||||
/* Search after record with key */
|
||||
|
||||
idx=hash_mask((*hash->calc_hashnr)(old_key,(old_key_length ?
|
||||
old_key_length :
|
||||
hash->key_length)),
|
||||
blength,records);
|
||||
new_index=hash_mask(rec_hashnr(hash,record),blength,records);
|
||||
if (idx == new_index)
|
||||
DBUG_RETURN(0); /* Nothing to do (No record check) */
|
||||
previous=0;
|
||||
for (;;)
|
||||
{
|
||||
|
||||
if ((pos= data+idx)->data == record)
|
||||
break;
|
||||
previous=pos;
|
||||
if ((idx=pos->next) == NO_RECORD)
|
||||
DBUG_RETURN(1); /* Not found in links */
|
||||
}
|
||||
hash->current_record= NO_RECORD;
|
||||
org_link= *pos;
|
||||
empty=idx;
|
||||
|
||||
/* Relink record from current chain */
|
||||
|
||||
if (!previous)
|
||||
{
|
||||
if (pos->next != NO_RECORD)
|
||||
{
|
||||
empty=pos->next;
|
||||
*pos= data[pos->next];
|
||||
}
|
||||
}
|
||||
else
|
||||
previous->next=pos->next; /* unlink pos */
|
||||
|
||||
/* Move data to correct position */
|
||||
pos=data+new_index;
|
||||
new_pos_index=hash_rec_mask(hash,pos,blength,records);
|
||||
if (new_index != new_pos_index)
|
||||
{ /* Other record in wrong position */
|
||||
data[empty] = *pos;
|
||||
movelink(data,new_index,new_pos_index,empty);
|
||||
org_link.next=NO_RECORD;
|
||||
data[new_index]= org_link;
|
||||
}
|
||||
else
|
||||
{ /* Link in chain at right position */
|
||||
org_link.next=data[new_index].next;
|
||||
data[empty]=org_link;
|
||||
data[new_index].next=empty;
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
uchar *hash_element(HASH *hash,uint idx)
|
||||
{
|
||||
if (idx < hash->records)
|
||||
return dynamic_element(&hash->array,idx,HASH_LINK*)->data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
|
||||
my_bool hash_check(HASH *hash)
|
||||
{
|
||||
int error;
|
||||
uint i,rec_link,found,max_links,seek,links,idx;
|
||||
uint records,blength;
|
||||
HASH_LINK *data,*hash_info;
|
||||
|
||||
records=hash->records; blength=hash->blength;
|
||||
data=dynamic_element(&hash->array,0,HASH_LINK*);
|
||||
error=0;
|
||||
|
||||
for (i=found=max_links=seek=0 ; i < records ; i++)
|
||||
{
|
||||
if (hash_rec_mask(hash,data+i,blength,records) == i)
|
||||
{
|
||||
found++; seek++; links=1;
|
||||
for (idx=data[i].next ;
|
||||
idx != NO_RECORD && found < records + 1;
|
||||
idx=hash_info->next)
|
||||
{
|
||||
if (idx >= records)
|
||||
{
|
||||
DBUG_PRINT("error",
|
||||
("Found pointer outside array to %d from link starting at %d",
|
||||
idx,i));
|
||||
error=1;
|
||||
}
|
||||
hash_info=data+idx;
|
||||
seek+= ++links;
|
||||
if ((rec_link=hash_rec_mask(hash,hash_info,blength,records)) != i)
|
||||
{
|
||||
DBUG_PRINT("error",
|
||||
("Record in wrong link at %d: Start %d Record: %lx Record-link %d", idx,i,hash_info->data,rec_link));
|
||||
error=1;
|
||||
}
|
||||
else
|
||||
found++;
|
||||
}
|
||||
if (links > max_links) max_links=links;
|
||||
}
|
||||
}
|
||||
if (found != records)
|
||||
{
|
||||
DBUG_PRINT("error",("Found %ld of %ld records"));
|
||||
error=1;
|
||||
}
|
||||
if (records)
|
||||
DBUG_PRINT("info",
|
||||
("records: %ld seeks: %d max links: %d hitrate: %.2f",
|
||||
records,seek,max_links,(float) seek / (float) records));
|
||||
return error;
|
||||
}
|
||||
#endif
|
153
module/Vendor/MDBC/libmariadb/int2str.c
vendored
Normal file
153
module/Vendor/MDBC/libmariadb/int2str.c
vendored
Normal file
@ -0,0 +1,153 @@
|
||||
/* 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 */
|
||||
|
||||
/*
|
||||
Defines: int2str(), itoa(), ltoa()
|
||||
|
||||
int2str(dst, radix, val)
|
||||
converts the (long) integer "val" to character form and moves it to
|
||||
the destination string "dst" followed by a terminating NUL. The
|
||||
result is normally a pointer to this NUL character, but if the radix
|
||||
is dud the result will be NullS and nothing will be changed.
|
||||
|
||||
If radix is -2..-36, val is taken to be SIGNED.
|
||||
If radix is 2.. 36, val is taken to be UNSIGNED.
|
||||
That is, val is signed if and only if radix is. You will normally
|
||||
use radix -10 only through itoa and ltoa, for radix 2, 8, or 16
|
||||
unsigned is what you generally want.
|
||||
|
||||
_dig_vec is public just in case someone has a use for it.
|
||||
The definitions of itoa and ltoa are actually macros in m_string.h,
|
||||
but this is where the code is.
|
||||
|
||||
Note: The standard itoa() returns a pointer to the argument, when int2str
|
||||
returns the pointer to the end-null.
|
||||
itoa assumes that 10 -base numbers are allways signed and other arn't.
|
||||
*/
|
||||
|
||||
#include <my_global.h>
|
||||
#include "m_string.h"
|
||||
|
||||
char NEAR _dig_vec[] =
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
|
||||
char *int2str(register long int val, register char *dst, register int radix)
|
||||
{
|
||||
char buffer[65];
|
||||
register char *p;
|
||||
long int new_val;
|
||||
|
||||
if (radix < 0) {
|
||||
if (radix < -36 || radix > -2) return NullS;
|
||||
if (val < 0) {
|
||||
*dst++ = '-';
|
||||
val = -val;
|
||||
}
|
||||
radix = -radix;
|
||||
} else {
|
||||
if (radix > 36 || radix < 2) return NullS;
|
||||
}
|
||||
/* The slightly contorted code which follows is due to the
|
||||
fact that few machines directly support unsigned long / and %.
|
||||
Certainly the VAX C compiler generates a subroutine call. In
|
||||
the interests of efficiency (hollow laugh) I let this happen
|
||||
for the first digit only; after that "val" will be in range so
|
||||
that signed integer division will do. Sorry 'bout that.
|
||||
CHECK THE CODE PRODUCED BY YOUR C COMPILER. The first % and /
|
||||
should be unsigned, the second % and / signed, but C compilers
|
||||
tend to be extraordinarily sensitive to minor details of style.
|
||||
This works on a VAX, that's all I claim for it.
|
||||
*/
|
||||
p = &buffer[sizeof(buffer)-1];
|
||||
*p = '\0';
|
||||
new_val=(ulong) val / (ulong) radix;
|
||||
*--p = _dig_vec[(uchar) ((ulong) val- (ulong) new_val*(ulong) radix)];
|
||||
val = new_val;
|
||||
#ifdef HAVE_LDIV
|
||||
while (val != 0)
|
||||
{
|
||||
ldiv_t res;
|
||||
res=ldiv(val,radix);
|
||||
*--p = _dig_vec[res.rem];
|
||||
val= res.quot;
|
||||
}
|
||||
#else
|
||||
while (val != 0)
|
||||
{
|
||||
new_val=val/radix;
|
||||
*--p = _dig_vec[(uchar) (val-new_val*radix)];
|
||||
val= new_val;
|
||||
}
|
||||
#endif
|
||||
while ((*dst++ = *p++) != 0) ;
|
||||
return dst-1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This is a faster version of the above optimized for the normal case of
|
||||
radix 10 / -10
|
||||
*/
|
||||
|
||||
char *int10_to_str(long int val, char *dst, int radix)
|
||||
{
|
||||
char buffer[65];
|
||||
register char *p;
|
||||
long int new_val;
|
||||
unsigned long int uval= (unsigned long int)val;
|
||||
|
||||
if (radix < 0 && val < 0) /* -10 */
|
||||
{
|
||||
*dst++ = '-';
|
||||
uval = (unsigned long int)0-uval;
|
||||
}
|
||||
|
||||
p = &buffer[sizeof(buffer)-1];
|
||||
*p = '\0';
|
||||
new_val= (long)(uval / 10);
|
||||
*--p = '0'+ (char)(uval - (unsigned long)new_val * 10);
|
||||
val = new_val;
|
||||
|
||||
while (val != 0)
|
||||
{
|
||||
new_val=val/10;
|
||||
*--p = '0' + (char) (val-new_val*10);
|
||||
val= new_val;
|
||||
}
|
||||
while ((*dst++ = *p++) != 0) ;
|
||||
return dst-1;
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_MY_ITOA
|
||||
|
||||
/* Change to less general itoa interface */
|
||||
|
||||
char *my_itoa(int val, char *dst, int radix)
|
||||
{
|
||||
VOID(int2str((long) val,dst,(radix == 10 ? -10 : radix)));
|
||||
return dst;
|
||||
}
|
||||
|
||||
char *my_ltoa(long int val, char *dst, int radix)
|
||||
{
|
||||
VOID(int2str((long) val,dst,(radix == 10 ? -10 : radix)));
|
||||
return dst;
|
||||
}
|
||||
|
||||
#endif
|
34
module/Vendor/MDBC/libmariadb/is_prefix.c
vendored
Normal file
34
module/Vendor/MDBC/libmariadb/is_prefix.c
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/* 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 */
|
||||
|
||||
/* File : is_prefix.c
|
||||
Author : Michael Widenius
|
||||
Defines: is_prefix()
|
||||
|
||||
is_prefix(s, t) returns 1 if s starts with t.
|
||||
A empty t is allways a prefix.
|
||||
*/
|
||||
|
||||
#include <my_global.h>
|
||||
#include "m_string.h"
|
||||
|
||||
int is_prefix(register const char *s, register const char *t)
|
||||
{
|
||||
while (*t)
|
||||
if (*s++ != *t++) return 0;
|
||||
return 1; /* WRONG */
|
||||
}
|
3728
module/Vendor/MDBC/libmariadb/libmariadb.c
vendored
Normal file
3728
module/Vendor/MDBC/libmariadb/libmariadb.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
116
module/Vendor/MDBC/libmariadb/list.c
vendored
Normal file
116
module/Vendor/MDBC/libmariadb/list.c
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
/* 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 */
|
||||
|
||||
/*
|
||||
Code for handling dubble-linked lists in C
|
||||
*/
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#include <my_list.h>
|
||||
|
||||
|
||||
|
||||
/* Add a element to start of list */
|
||||
|
||||
LIST *list_add(LIST *root, LIST *element)
|
||||
{
|
||||
DBUG_ENTER("list_add");
|
||||
DBUG_PRINT("enter",("root: %lx element: %lx", root, element));
|
||||
if (root)
|
||||
{
|
||||
if (root->prev) /* If add in mid of list */
|
||||
root->prev->next= element;
|
||||
element->prev=root->prev;
|
||||
root->prev=element;
|
||||
}
|
||||
else
|
||||
element->prev=0;
|
||||
element->next=root;
|
||||
DBUG_RETURN(element); /* New root */
|
||||
}
|
||||
|
||||
|
||||
LIST *list_delete(LIST *root, LIST *element)
|
||||
{
|
||||
if (element->prev)
|
||||
element->prev->next=element->next;
|
||||
else
|
||||
root=element->next;
|
||||
if (element->next)
|
||||
element->next->prev=element->prev;
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
void list_free(LIST *root, unsigned int free_data)
|
||||
{
|
||||
LIST *next;
|
||||
while (root)
|
||||
{
|
||||
next=root->next;
|
||||
if (free_data)
|
||||
my_free(root->data);
|
||||
my_free(root);
|
||||
root=next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LIST *list_cons(void *data, LIST *list)
|
||||
{
|
||||
LIST *new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
|
||||
if (!new_charset)
|
||||
return 0;
|
||||
new_charset->data=data;
|
||||
return list_add(list,new_charset);
|
||||
}
|
||||
|
||||
|
||||
LIST *list_reverse(LIST *root)
|
||||
{
|
||||
LIST *last;
|
||||
|
||||
last=root;
|
||||
while (root)
|
||||
{
|
||||
last=root;
|
||||
root=root->next;
|
||||
last->next=last->prev;
|
||||
last->prev=root;
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
uint list_length(LIST *list)
|
||||
{
|
||||
uint count;
|
||||
for (count=0 ; list ; list=list->next, count++) ;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
int list_walk(LIST *list, list_walk_action action, gptr argument)
|
||||
{
|
||||
int error=0;
|
||||
while (list)
|
||||
{
|
||||
if ((error = (*action)(list->data,argument)))
|
||||
return error;
|
||||
list=rest(list);
|
||||
}
|
||||
return 0;
|
||||
}
|
36
module/Vendor/MDBC/libmariadb/llstr.c
vendored
Normal file
36
module/Vendor/MDBC/libmariadb/llstr.c
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/* 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 */
|
||||
|
||||
/*
|
||||
Defines: llstr();
|
||||
|
||||
llstr(value, buff);
|
||||
|
||||
This function saves a longlong value in a buffer and returns the pointer to
|
||||
the buffer. This is useful when trying to portable print longlong
|
||||
variables with printf() as there is no usable printf() standard one can use.
|
||||
*/
|
||||
|
||||
|
||||
#include <my_global.h>
|
||||
#include "m_string.h"
|
||||
|
||||
char *llstr(longlong value,char *buff)
|
||||
{
|
||||
longlong2str(value,buff,-10);
|
||||
return buff;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user