drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzle_plugin Namespace Reference

Namespaces

namespace  json_server

Classes

class  FilteredReplicator
class  AnalysisTableTool
struct  server_function_context
class  StatsTableTool
class  MySQLPassword
class  ProtocolCounters
class  ListenMySQLProtocol
class  ClientMySQLProtocol
class  NET
struct  st_drizzleclient_options
class  Vio
 Virtual I/O layer, only used with TCP/IP sockets at the moment. More...

Typedefs

typedef drizzled::constrained_check< uint32_t, 300, 1 > timeout_constraint
typedef drizzled::constrained_check< uint32_t, 300, 1 > retry_constraint
typedef drizzled::constrained_check< uint32_t, 1048576, 1024, 1024 > buffer_constraint

Enumerations

enum  CR_CLIENT_ERRORS {
  CR_ERROR_FIRST =2000 , CR_UNKNOWN_ERROR =2000 , CR_SOCKET_CREATE_ERROR =2001 , CR_CONNECTION_ERROR =2002 ,
  CR_CONN_HOST_ERROR =2003 , CR_IPSOCK_ERROR =2004 , CR_UNKNOWN_HOST =2005 , CR_SERVER_GONE_ERROR =2006 ,
  CR_VERSION_ERROR =2007 , CR_OUT_OF_MEMORY =2008 , CR_WRONG_HOST_INFO =2009 , CR_LOCALHOST_CONNECTION =2010 ,
  CR_TCP_CONNECTION =2011 , CR_SERVER_HANDSHAKE_ERR =2012 , CR_SERVER_LOST =2013 , CR_COMMANDS_OUT_OF_SYNC =2014 ,
  CR_NAMEDPIPE_CONNECTION =2015 , CR_NAMEDPIPEWAIT_ERROR =2016 , CR_NAMEDPIPEOPEN_ERROR =2017 , CR_NAMEDPIPESETSTATE_ERROR =2018 ,
  CR_CANT_READ_CHARSET =2019 , CR_NET_PACKET_TOO_LARGE =2020 , CR_EMBEDDED_CONNECTION =2021 , CR_PROBE_SLAVE_STATUS =2022 ,
  CR_PROBE_SLAVE_HOSTS =2023 , CR_PROBE_SLAVE_CONNECT =2024 , CR_PROBE_MASTER_CONNECT =2025 , CR_SSL_CONNECTION_ERROR =2026 ,
  CR_MALFORMED_PACKET =2027 , CR_NULL_POINTER =2029 , CR_NO_PREPARE_STMT =2030 , CR_PARAMS_NOT_BOUND =2031 ,
  CR_DATA_TRUNCATED =2032 , CR_NO_PARAMETERS_EXISTS =2033 , CR_INVALID_PARAMETER_NO =2034 , CR_INVALID_BUFFER_USE =2035 ,
  CR_UNSUPPORTED_PARAM_TYPE =2036 , CR_CONN_UNKNOW_PROTOCOL =2047 , CR_INVALID_CONN_HANDLE =2048 , CR_SECURE_AUTH =2049 ,
  CR_FETCH_CANCELED =2050 , CR_NO_DATA =2051 , CR_NO_STMT_METADATA =2052 , CR_NO_RESULT_SET =2053 ,
  CR_NOT_IMPLEMENTED =2054 , CR_SERVER_LOST_INITIAL_COMM_WAIT =2055 , CR_SERVER_LOST_INITIAL_COMM_READ =2056 , CR_SERVER_LOST_SEND_AUTH =2057 ,
  CR_SERVER_LOST_READ_AUTH =2058 , CR_SERVER_LOST_SETTING_DB =2059 , CR_STMT_CLOSED =2060 , CR_NET_UNCOMPRESS_ERROR = 2061 ,
  CR_NET_READ_ERROR = 2062 , CR_NET_READ_INTERRUPTED = 2063 , CR_NET_ERROR_ON_WRITE = 2064 , CR_NET_WRITE_INTERRUPTED = 2065 ,
  CR_ERROR_LAST =2065
}
enum  drizzle_option {
  DRIZZLE_OPT_CONNECT_TIMEOUT , DRIZZLE_OPT_COMPRESS , DRIZZLE_OPT_NAMED_PIPE , DRIZZLE_INIT_COMMAND ,
  DRIZZLE_READ_DEFAULT_FILE , DRIZZLE_READ_DEFAULT_GROUP , DRIZZLE_OPT_PROTOCOL , DRIZZLE_SHARED_MEMORY_BASE_NAME ,
  DRIZZLE_OPT_READ_TIMEOUT , DRIZZLE_OPT_WRITE_TIMEOUT , DRIZZLE_OPT_USE_RESULT , DRIZZLE_OPT_USE_REMOTE_CONNECTION ,
  DRIZZLE_OPT_GUESS_CONNECTION , DRIZZLE_SET_CLIENT_IP , DRIZZLE_SECURE_AUTH , DRIZZLE_REPORT_DATA_TRUNCATION ,
  DRIZZLE_OPT_RECONNECT , DRIZZLE_OPT_SSL_VERIFY_SERVER_CERT
}
enum  mysql_column_type {
  DRIZZLE_COLUMN_TYPE_TINY = 1 , DRIZZLE_COLUMN_TYPE_LONG = 3 , DRIZZLE_COLUMN_TYPE_DOUBLE = 5 , DRIZZLE_COLUMN_TYPE_NULL = 6 ,
  DRIZZLE_COLUMN_TYPE_TIMESTAMP = 7 , DRIZZLE_COLUMN_TYPE_LONGLONG = 8 , DRIZZLE_COLUMN_TYPE_DATE = 10 , DRIZZLE_COLUMN_TYPE_TIME = 11 ,
  DRIZZLE_COLUMN_TYPE_DATETIME = 12 , DRIZZLE_COLUMN_TYPE_VARCHAR = 15 , DRIZZLE_COLUMN_TYPE_NEWDECIMAL = 246 , DRIZZLE_COLUMN_TYPE_ENUM = 247 ,
  DRIZZLE_COLUMN_TYPE_BLOB = 252
}

Functions

static int init (drizzled::module::Context &context)
static int filtered_schemas_validate (Session *, set_var *var)
static int filtered_tables_validate (Session *, set_var *var)
static int init (module::Context &context)
static void init_options (drizzled::module::option_context &context)
static int init (drizzled::module::Context &context)
static void init_options (drizzled::module::option_context &context)
memcached_return server_function (const memcached_st *ptr, memcached_server_st *server, void *context)
static int init (drizzled::module::Context &context)
static void init_options (drizzled::module::option_context &context)
static bool net_write_buff (NET *, const void *, uint32_t len)
static int drizzleclient_net_real_write (NET *net, const unsigned char *packet, size_t len)
static bool drizzleclient_net_realloc (NET *net, size_t length)
static bool drizzleclient_net_write (NET *net, const void *packet0, size_t len)
static bool drizzleclient_net_write_command (NET *net, unsigned char command, const unsigned char *header, size_t head_len, const unsigned char *packet, size_t len)
static uint32_t my_real_read (NET *net, size_t *complen)
static uint32_t drizzleclient_net_read (NET *net)
bool update_file (Session *, set_var *var)
 Update query_log_file (query_log->sysvar_file).
void update_file_enabled (Session *, sql_var_t)
 Update query_log_file_enabled (query_log->sysvar_file_enabled).
static void init_options (drizzled::module::option_context &context)
 Initialize query-log command line options.
static int init (drizzled::module::Context &context)
 Add query_log plugin to Drizzle and initalize query_log system variables.

Variables

static string sysvar_filtered_replicator_sch_filters
static string sysvar_filtered_replicator_tab_filters
static FilteredReplicator * filtered_replicator = NULL
static AnalysisTableTool * analysis_table_tool
static StatsTableTool * stats_table_tool
static std::string sysvar_memcached_servers
const char * MySQLPasswordName = "mysql_password"
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC = 1024
static port_constraint port
static timeout_constraint connect_timeout
static timeout_constraint read_timeout
static timeout_constraint write_timeout
static retry_constraint retry_count
static buffer_constraint buffer_length
static uint32_t random_seed1
static uint32_t random_seed2
static const uint32_t random_max = 0x3FFFFFFF
static const double random_max_double = (double)0x3FFFFFFF
static drizzled::plugin::QueryLog * query_log = NULL
static QueryLoggerFile * logger_file = NULL
const char * default_file = "drizzled-queries.log"
 Default query log file.

Detailed Description

Drizzle Plugin Namespace

Typedef Documentation

◆ buffer_constraint

typedef drizzled::constrained_check<uint32_t, 1048576, 1024, 1024> drizzle_plugin::buffer_constraint

Definition at line 46 of file mysql_protocol.h.

◆ retry_constraint

typedef drizzled::constrained_check<uint32_t, 300, 1> drizzle_plugin::retry_constraint

Definition at line 45 of file mysql_protocol.h.

◆ timeout_constraint

typedef drizzled::constrained_check<uint32_t, 300, 1> drizzle_plugin::timeout_constraint

Definition at line 44 of file mysql_protocol.h.

Enumeration Type Documentation

◆ CR_CLIENT_ERRORS

enum drizzle_plugin::CR_CLIENT_ERRORS

Definition at line 26 of file mysql_protocol/errmsg.h.

◆ drizzle_option

enum drizzle_plugin::drizzle_option

Definition at line 25 of file options.h.

◆ mysql_column_type

enum drizzle_plugin::mysql_column_type

Definition at line 27 of file wire_types.h.

Function Documentation

◆ drizzleclient_net_read()

uint32_t drizzle_plugin::drizzleclient_net_read ( NET * net)
static

Read a packet from the client/server and return it without the internal package header.

If the packet is the first packet of a multi-packet packet (which is indicated by the length of the packet = 0xffffff) then all sub packets are read and concatenated.

If the packet was compressed, its uncompressed and the length of the uncompressed packet is returned.

Returns
The function returns the length of the found packet or packet_error. net->read_pos points to the read data.

Definition at line 572 of file net_serv.cc.

◆ drizzleclient_net_real_write()

int drizzle_plugin::drizzleclient_net_real_write ( NET * net,
const unsigned char * packet,
size_t len )
static

Read and write one packet using timeouts. If needed, the packet is compressed before sending.

Todo
  • TODO is it needed to set this variable if we have no socket

Definition at line 344 of file net_serv.cc.

◆ drizzleclient_net_realloc()

bool drizzle_plugin::drizzleclient_net_realloc ( NET * net,
size_t length )
static

Realloc the packet buffer.

Definition at line 114 of file net_serv.cc.

◆ drizzleclient_net_write()

bool drizzle_plugin::drizzleclient_net_write ( NET * net,
const void * packet0,
size_t len )
static

Write a logical packet with packet header.

Format: Packet length (3 bytes), packet number(1 byte) When compression is used a 3 byte compression length is added

Note
If compression is used the original package is modified!

Definition at line 165 of file net_serv.cc.

◆ drizzleclient_net_write_command()

bool drizzle_plugin::drizzleclient_net_write_command ( NET * net,
unsigned char command,
const unsigned char * header,
size_t head_len,
const unsigned char * packet,
size_t len )
static

Send a command to the server.

The reason for having both header and packet is so that the peer can easily add a header to a special command (like prepared statements) without having to re-alloc the string.

As the command is part of the first data packet, we have to do some data juggling to put the command in there, without having to create a new packet.

This function will split big packets into sub-packets if needed. (Each sub packet can only be 2^24 bytes)

Parameters
netNET handler
commandCommand in MySQL server (enum enum_server_command)
headerHeader to write after command
head_lenLength of header
packetQuery or parameter to query
lenLength of packet
Return values
0ok
1error

Definition at line 220 of file net_serv.cc.

◆ filtered_schemas_validate()

int drizzle_plugin::filtered_schemas_validate ( Session * ,
set_var * var )
static

Definition at line 505 of file filtered_replicator.cc.

◆ filtered_tables_validate()

int drizzle_plugin::filtered_tables_validate ( Session * ,
set_var * var )
static

Definition at line 517 of file filtered_replicator.cc.

◆ init() [1/5]

int drizzle_plugin::init ( drizzled::module::Context & context)
static

Definition at line 27 of file error_dictionary/dictionary.cc.

◆ init() [2/5]

int drizzle_plugin::init ( drizzled::module::Context & context)
static

Initialize the memcached stats plugin.

Parameters
[in]registrythe drizzled::plugin::Registry singleton
Returns
false on success; true on failure.

Definition at line 66 of file memcached_stats.cc.

◆ init() [3/5]

int drizzle_plugin::init ( drizzled::module::Context & context)
static

Definition at line 901 of file mysql_protocol.cc.

◆ init() [4/5]

int drizzle_plugin::init ( drizzled::module::Context & context)
static

Add query_log plugin to Drizzle and initalize query_log system variables.

This is where we plug into Drizzle and register our system variables. Since this is called after init_options(), vm has either values from the command line or defaults. System variables corresponding to command line options use the same public query_log variables so that values from vm (the command line) are automatically reflected in the system variable (SHOW VARIABLES). This also makes changes to certain system variables automatic/instant because when they're updated (e.g. SET GLOBAL query_log_enabled=TRUE|FALSE) Drizzle changes the corresponding public query_log variable. Certain system variables, like query_log_file, require more work to change, so they're handled by update functions like update_file().

Return values
0Success

Definition at line 228 of file plugin/query_log/module.cc.

◆ init() [5/5]

int drizzle_plugin::init ( module::Context & context)
static

Definition at line 529 of file filtered_replicator.cc.

◆ init_options() [1/4]

void drizzle_plugin::init_options ( drizzled::module::option_context & context)
static

Definition at line 555 of file filtered_replicator.cc.

◆ init_options() [2/4]

void drizzle_plugin::init_options ( drizzled::module::option_context & context)
static

Definition at line 83 of file memcached_stats.cc.

◆ init_options() [3/4]

void drizzle_plugin::init_options ( drizzled::module::option_context & context)
static

Definition at line 927 of file mysql_protocol.cc.

◆ init_options() [4/4]

void drizzle_plugin::init_options ( drizzled::module::option_context & context)
static

Initialize query-log command line options.

This function is called first, before init(). We instantiate our one and only QueryLog object (query_log) here so that po (boost::program_options) can store the command line options' values in public query_log variables. This avoids using global variables and keeps (almost) everything encapsulated in query_log.

Definition at line 157 of file plugin/query_log/module.cc.

◆ my_real_read()

uint32_t drizzle_plugin::my_real_read ( NET * net,
size_t * complen )
static

Reads one packet to net->buff + net->where_b. Long packets are handled by drizzleclient_net_read(). This function reallocates the net->buff buffer if necessary.

Returns
Returns length of packet.

Definition at line 460 of file net_serv.cc.

◆ net_write_buff()

bool drizzle_plugin::net_write_buff ( NET * net,
const void * packet0,
uint32_t len )
static

Caching the data in a local buffer before sending it.

Fill up net->buffer and send it to the client when full.

If the rest of the to-be-sent-packet is bigger than buffer, send it in one big block (to avoid copying to internal buffer). If not, copy the rest of the data to the buffer and return without sending data.

Parameters
netNetwork handler
packetPacket to send
lenLength of packet
Note
The cached buffer can be sent as it is with 'drizzleclient_net_flush()'. In this code we have to be careful to not send a packet longer than MAX_PACKET_LENGTH to drizzleclient_net_real_write() if we are using the compressed protocol as we store the length of the compressed packet in 3 bytes.
Return values
0ok
1

Definition at line 284 of file net_serv.cc.

◆ server_function()

memcached_return drizzle_plugin::server_function ( const memcached_st * ptr,
memcached_server_st * server,
void * context )

Definition at line 56 of file stats_table.cc.

◆ update_file()

bool drizzle_plugin::update_file ( Session * ,
set_var * var )

Update query_log_file (query_log->sysvar_file).

Forward declarations. Mac OS X 10.6 with gcc 4.2.1 misses this warning (but still compiles): configure:23893: g++ -c -Werror -pedantic -Wmissing-declarations \ -std=gnu++98 -O0 -DDEBUG conftest.cpp >&5 cc1plus: warnings being treated as errors cc1plus: warning: command line option "-Wmissing-declarations" is valid for C/ObjC but not for C++

When SET GLOBAL query_log_file="new-file.log" is executed by the user, this function is called which checkes that the new file is not NULL or a blank string, then calls logger_file->openLogFile, passing it the new log file name, e.g. "new-file.log". If the new log file is opened, the system variable is updated, else it is not updated and logging continues to the old log file.

Return values
trueError, log file not changed
falseSuccess, log file changed

If the the log file is enabled, then try to open the new log file. If it's not enabled, then just update query_log_file because the user might be trying to: close current log file (SET GLOBAL log_file_enabled=FALSE) switch to new log file (SET GLOBAL log_file="new-file.log") enable new log file (SET GLOBAL log_file_enabled=TRUE) (Maybe they're doing this to rotate the log?) If this is the case, then we don't want to open the new log file before it's enabled, but we also don't want to leave query_log_file set to the old log file name. When the log file is re-enabled later, update_file_enabled() will be called and the new log file will be opened.

Definition at line 77 of file plugin/query_log/module.cc.

◆ update_file_enabled()

void drizzle_plugin::update_file_enabled ( Session * ,
sql_var_t  )

Update query_log_file_enabled (query_log->sysvar_file_enabled).

When SET GLOBAL query_log_file_enabled=... is executed by the user, this function is called after Drizzle updates the variable with the new value, so in this function we have the new/current value. If the log file is enabled, then open query_log_file (query_log->sysvar_file); else, close the log file.

Definition at line 132 of file plugin/query_log/module.cc.

Variable Documentation

◆ analysis_table_tool

AnalysisTableTool* drizzle_plugin::analysis_table_tool
static

Definition at line 51 of file memcached_stats.cc.

◆ buffer_length

buffer_constraint drizzle_plugin::buffer_length
static

Definition at line 61 of file mysql_protocol.cc.

◆ connect_timeout

timeout_constraint drizzle_plugin::connect_timeout
static

Definition at line 57 of file mysql_protocol.cc.

◆ default_file

const char* drizzle_plugin::default_file = "drizzled-queries.log"

Default query log file.

Sensible defaults.

Definition at line 60 of file plugin/query_log/module.cc.

◆ filtered_replicator

FilteredReplicator* drizzle_plugin::filtered_replicator = NULL
static

Definition at line 503 of file filtered_replicator.cc.

◆ logger_file

QueryLoggerFile* drizzle_plugin::logger_file = NULL
static

Definition at line 55 of file plugin/query_log/module.cc.

◆ MySQLPasswordName

const char * drizzle_plugin::MySQLPasswordName = "mysql_password"

Definition at line 25 of file mysql_password.cc.

◆ PACKET_BUFFER_EXTRA_ALLOC

const unsigned int drizzle_plugin::PACKET_BUFFER_EXTRA_ALLOC = 1024
static

Definition at line 54 of file mysql_protocol.cc.

◆ port

port_constraint drizzle_plugin::port
static

Definition at line 56 of file mysql_protocol.cc.

◆ query_log

drizzled::plugin::QueryLog* drizzle_plugin::query_log = NULL
static

An instance of our class, QueryLog, which implements the query_log plugin, and an instance of the QueryLoggerClass for logging queries to a file. These objects are global so update_file() and update_file_enabled() can access them. They're instantiated in init_options().

Definition at line 54 of file plugin/query_log/module.cc.

◆ random_max

const uint32_t drizzle_plugin::random_max = 0x3FFFFFFF
static

Definition at line 65 of file mysql_protocol.cc.

◆ random_max_double

const double drizzle_plugin::random_max_double = (double)0x3FFFFFFF
static

Definition at line 66 of file mysql_protocol.cc.

◆ random_seed1

uint32_t drizzle_plugin::random_seed1
static

Definition at line 63 of file mysql_protocol.cc.

◆ random_seed2

uint32_t drizzle_plugin::random_seed2
static

Definition at line 64 of file mysql_protocol.cc.

◆ read_timeout

timeout_constraint drizzle_plugin::read_timeout
static

Definition at line 58 of file mysql_protocol.cc.

◆ retry_count

retry_constraint drizzle_plugin::retry_count
static

Definition at line 60 of file mysql_protocol.cc.

◆ stats_table_tool

StatsTableTool* drizzle_plugin::stats_table_tool
static

Definition at line 53 of file memcached_stats.cc.

◆ sysvar_filtered_replicator_sch_filters

string drizzle_plugin::sysvar_filtered_replicator_sch_filters
static

Definition at line 58 of file filtered_replicator.cc.

◆ sysvar_filtered_replicator_tab_filters

string drizzle_plugin::sysvar_filtered_replicator_tab_filters
static

Definition at line 59 of file filtered_replicator.cc.

◆ sysvar_memcached_servers

std::string drizzle_plugin::sysvar_memcached_servers
static

Definition at line 58 of file memcached_stats.cc.

◆ write_timeout

timeout_constraint drizzle_plugin::write_timeout
static

Definition at line 59 of file mysql_protocol.cc.