Drizzled Public API Documentation

drizzle_plugin Namespace Reference

Namespaces

 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
}
 

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). More...
 
void update_file_enabled (Session *, sql_var_t)
 Update query_log_file_enabled (query_log->sysvar_file_enabled). More...
 
static void init_options (drizzled::module::option_context &context)
 Initialize query-log command line options. More...
 
static int init (drizzled::module::Context &context)
 Add query_log plugin to Drizzle and initalize query_log system variables. More...
 

Variables

static string sysvar_filtered_replicator_sch_filters
 
static string sysvar_filtered_replicator_tab_filters
 
static FilteredReplicatorfiltered_replicator = NULL
 
static AnalysisTableToolanalysis_table_tool
 
static StatsTableToolstats_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::QueryLogquery_log = NULL
 
static QueryLoggerFilelogger_file = NULL
 
const char * default_file = "drizzled-queries.log"
 Default query log file. More...
 

Detailed Description

Drizzle Plugin Namespace

Function Documentation

static 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.

References my_real_read().

static 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.

References drizzle_plugin::Vio::blocking(), drizzle_plugin::Vio::get_errno(), drizzle_plugin::Vio::should_retry(), and drizzle_plugin::Vio::write().

Referenced by net_write_buff().

static 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.

Referenced by my_real_read().

static 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.

References net_write_buff().

static 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 libdrizzle can easy 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.

References net_write_buff().

static 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.

static 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 module.cc.

References QueryLoggerFile::openLogFile(), query_log, drizzled::plugin::QueryLog::sysvar_enabled, update_file(), and update_file_enabled().

static 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 module.cc.

References default_file, init_options(), and query_log.

Referenced by init_options().

static 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.

References drizzleclient_net_realloc(), drizzle_plugin::Vio::get_errno(), drizzle_plugin::Vio::get_fd(), drizzle_plugin::Vio::read(), drizzle_plugin::Vio::should_retry(), and drizzle_plugin::Vio::was_interrupted().

Referenced by drizzleclient_net_read().

static 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.

References drizzleclient_net_real_write().

Referenced by drizzleclient_net_write(), and drizzleclient_net_write_command().

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.

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 module.cc.

References QueryLoggerFile::openLogFile(), query_log, drizzled::Item::str_value, and update_file().

Referenced by init(), and update_file().

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 module.cc.

References QueryLoggerFile::closeLogFile(), QueryLoggerFile::openLogFile(), query_log, and update_file_enabled().

Referenced by init(), and update_file_enabled().

Variable Documentation

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

Default query log file.

Sensible defaults.

Definition at line 60 of file module.cc.

Referenced by init_options().

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 module.cc.

Referenced by init(), init_options(), update_file(), and update_file_enabled().