MySQL  8.0.19
Source Code Documentation
test_sql_replication.cc File Reference
#include <fcntl.h>
#include <mysql/plugin.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <mysql/components/my_service.h>
#include <mysql/components/services/log_builtins.h>
#include <mysqld_error.h>
#include "m_string.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_sys.h"
#include "mysql_com.h"
#include "template_utils.h"

Classes

struct  st_test_statement
 
struct  st_send_field_n
 
struct  st_plugin_ctx
 
struct  test_thread_context
 

Macros

#define LOG_COMPONENT_TAG   "test_sql_replication"
 
#define STRING_BUFFER_SIZE   512
 
#define WRITE_STR(format)
 
#define WRITE_VAL(format, value)
 
#define WRITE_VAL2(format, value1, value2)
 
#define WRITE_SEP()   my_write(outfile, pointer_cast<const uchar *>(sep), strlen(sep), MYF(0))
 
#define SIZEOF_SQL_STR_VALUE   256
 
#define ff2s_check_flag(X)
 
#define FLAG_DELIMITER   " "
 

Functions

static int sql_start_result_metadata (void *ctx, uint num_cols, uint, const CHARSET_INFO *resultcs)
 
static int sql_field_metadata (void *ctx, struct st_send_field *field, const CHARSET_INFO *)
 
static int sql_end_result_metadata (void *ctx, uint server_status, uint warn_count)
 
static int sql_start_row (void *ctx)
 
static int sql_end_row (void *ctx)
 
static void sql_abort_row (void *)
 
static ulong sql_get_client_capabilities (void *)
 
static int sql_get_null (void *ctx)
 
static int sql_get_integer (void *ctx, longlong value)
 
static int sql_get_longlong (void *ctx, longlong value, uint is_unsigned)
 
static const char * test_decimal_as_string (char *buff, const decimal_t *val, int *length)
 
static int sql_get_decimal (void *ctx, const decimal_t *value)
 
static int sql_get_double (void *ctx, double value, uint32)
 
static int sql_get_date (void *ctx, const MYSQL_TIME *value)
 
static int sql_get_time (void *ctx, const MYSQL_TIME *value, uint)
 
static int sql_get_datetime (void *ctx, const MYSQL_TIME *value, uint)
 
static int sql_get_string (void *ctx, const char *const value, size_t length, const CHARSET_INFO *const)
 
static void sql_handle_ok (void *ctx, uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *const message)
 
static void sql_handle_error (void *ctx, uint sql_errno, const char *const err_msg, const char *const sqlstate)
 
static void sql_shutdown (void *, int)
 
static const char * fieldtype2str (enum enum_field_types type)
 
static char * fieldflags2str (uint f)
 
static void dump_meta_field (st_send_field_n field)
 
static void dump_cs_info (const CHARSET_INFO *cs)
 
static void dump_decoded_server_status (const char *prefix, uint server_status)
 
static void dump_meta_info (struct st_plugin_ctx *ctx)
 
static void dump_result_set (struct st_plugin_ctx *ctx)
 
static void dump_closing_ok (struct st_plugin_ctx *ctx)
 
static void set_query_in_com_data (const char *query, union COM_DATA *cmd)
 
static void run_statement (MYSQL_SESSION session, const char *query, struct st_plugin_ctx *ctx, bool generates_result_set, void *p)
 
static void change_current_db (MYSQL_SESSION session, const char *db, struct st_plugin_ctx *ctx, void *p)
 
static void test_selects (MYSQL_SESSION session, void *p)
 
static void test_sql (void *p)
 
static void * test_sql_threaded_wrapper (void *param)
 
static void create_log_file (const char *log_name)
 
static void test_in_spawned_thread (void *p, void(*test_function)(void *))
 
static int test_sql_service_plugin_init (void *p)
 
static int test_sql_service_plugin_deinit (void *p)
 
 mysql_declare_plugin (test_daemon)
 

Variables

static const char * log_filename = "test_sql_replication"
 
static struct st_test_statement test_query_plan []
 
static const char * sep
 
static const mysql_service_registry_treg_srv = nullptr
 
const mysql_service_log_builtins_tlog_bi = nullptr
 accessor built-ins More...
 
const mysql_service_log_builtins_string_tlog_bs = nullptr
 string built-ins More...
 
static File outfile
 
const struct st_command_service_cbs protocol_callbacks
 
static struct st_mysql_daemon test_sql_service_plugin
 
 mysql_declare_plugin_end
 

Macro Definition Documentation

◆ ff2s_check_flag

#define ff2s_check_flag (   X)
Value:
if (f & X##_FLAG) { \
s = my_stpcpy(s, #X " "); \
f &= ~X##_FLAG; \
}

◆ FLAG_DELIMITER

#define FLAG_DELIMITER   " "

◆ LOG_COMPONENT_TAG

#define LOG_COMPONENT_TAG   "test_sql_replication"

◆ SIZEOF_SQL_STR_VALUE

#define SIZEOF_SQL_STR_VALUE   256

◆ STRING_BUFFER_SIZE

#define STRING_BUFFER_SIZE   512

◆ WRITE_SEP

#define WRITE_SEP ( )    my_write(outfile, pointer_cast<const uchar *>(sep), strlen(sep), MYF(0))

◆ WRITE_STR

#define WRITE_STR (   format)
Value:
{ \
const size_t blen = snprintf(buffer, sizeof(buffer), "%s", (format)); \
my_write(outfile, (uchar *)buffer, blen, MYF(0)); \
/*pctx->log.append(buffer, blen); */ \
}

◆ WRITE_VAL

#define WRITE_VAL (   format,
  value 
)
Value:
{ \
const size_t blen = snprintf(buffer, sizeof(buffer), (format), (value)); \
my_write(outfile, (uchar *)buffer, blen, MYF(0)); \
/* pctx->log.append(buffer, blen); */ \
}

◆ WRITE_VAL2

#define WRITE_VAL2 (   format,
  value1,
  value2 
)
Value:
{ \
const size_t blen = \
snprintf(buffer, sizeof(buffer), (format), (value1), (value2)); \
my_write(outfile, (uchar *)buffer, blen, MYF(0)); \
/* pctx->log.append(buffer, blen); */ \
}

Function Documentation

◆ change_current_db()

static void change_current_db ( MYSQL_SESSION  session,
const char *  db,
struct st_plugin_ctx ctx,
void *  p 
)
static

◆ create_log_file()

static void create_log_file ( const char *  log_name)
static

◆ dump_closing_ok()

static void dump_closing_ok ( struct st_plugin_ctx ctx)
static

◆ dump_cs_info()

static void dump_cs_info ( const CHARSET_INFO cs)
static

◆ dump_decoded_server_status()

static void dump_decoded_server_status ( const char *  prefix,
uint  server_status 
)
static

◆ dump_meta_field()

static void dump_meta_field ( st_send_field_n  field)
static

◆ dump_meta_info()

static void dump_meta_info ( struct st_plugin_ctx ctx)
static

◆ dump_result_set()

static void dump_result_set ( struct st_plugin_ctx ctx)
static

◆ fieldflags2str()

static char* fieldflags2str ( uint  f)
static

◆ fieldtype2str()

static const char* fieldtype2str ( enum enum_field_types  type)
static

◆ mysql_declare_plugin()

mysql_declare_plugin ( test_daemon  )

◆ run_statement()

static void run_statement ( MYSQL_SESSION  session,
const char *  query,
struct st_plugin_ctx ctx,
bool  generates_result_set,
void *  p 
)
static

◆ set_query_in_com_data()

static void set_query_in_com_data ( const char *  query,
union COM_DATA cmd 
)
static

◆ sql_abort_row()

static void sql_abort_row ( void *  )
static

◆ sql_end_result_metadata()

static int sql_end_result_metadata ( void *  ctx,
uint  server_status,
uint  warn_count 
)
static

◆ sql_end_row()

static int sql_end_row ( void *  ctx)
static

◆ sql_field_metadata()

static int sql_field_metadata ( void *  ctx,
struct st_send_field field,
const CHARSET_INFO  
)
static

◆ sql_get_client_capabilities()

static ulong sql_get_client_capabilities ( void *  )
static

◆ sql_get_date()

static int sql_get_date ( void *  ctx,
const MYSQL_TIME value 
)
static

◆ sql_get_datetime()

static int sql_get_datetime ( void *  ctx,
const MYSQL_TIME value,
uint   
)
static

◆ sql_get_decimal()

static int sql_get_decimal ( void *  ctx,
const decimal_t value 
)
static

◆ sql_get_double()

static int sql_get_double ( void *  ctx,
double  value,
uint32   
)
static

◆ sql_get_integer()

static int sql_get_integer ( void *  ctx,
longlong  value 
)
static

◆ sql_get_longlong()

static int sql_get_longlong ( void *  ctx,
longlong  value,
uint  is_unsigned 
)
static

◆ sql_get_null()

static int sql_get_null ( void *  ctx)
static

◆ sql_get_string()

static int sql_get_string ( void *  ctx,
const char *const  value,
size_t  length,
const CHARSET_INFO * const   
)
static

◆ sql_get_time()

static int sql_get_time ( void *  ctx,
const MYSQL_TIME value,
uint   
)
static

◆ sql_handle_error()

static void sql_handle_error ( void *  ctx,
uint  sql_errno,
const char *const  err_msg,
const char *const  sqlstate 
)
static

◆ sql_handle_ok()

static void sql_handle_ok ( void *  ctx,
uint  server_status,
uint  statement_warn_count,
ulonglong  affected_rows,
ulonglong  last_insert_id,
const char *const  message 
)
static

◆ sql_shutdown()

static void sql_shutdown ( void *  ,
int   
)
static

◆ sql_start_result_metadata()

static int sql_start_result_metadata ( void *  ctx,
uint  num_cols,
uint  ,
const CHARSET_INFO resultcs 
)
static

◆ sql_start_row()

static int sql_start_row ( void *  ctx)
static

◆ test_decimal_as_string()

static const char* test_decimal_as_string ( char *  buff,
const decimal_t val,
int *  length 
)
static

◆ test_in_spawned_thread()

static void test_in_spawned_thread ( void *  p,
void(*)(void *)  test_function 
)
static

◆ test_selects()

static void test_selects ( MYSQL_SESSION  session,
void *  p 
)
static

◆ test_sql()

static void test_sql ( void *  p)
static

◆ test_sql_service_plugin_deinit()

static int test_sql_service_plugin_deinit ( void *  p)
static

◆ test_sql_service_plugin_init()

static int test_sql_service_plugin_init ( void *  p)
static

◆ test_sql_threaded_wrapper()

static void* test_sql_threaded_wrapper ( void *  param)
static

Variable Documentation

◆ log_bi

const mysql_service_log_builtins_t* log_bi = nullptr

accessor built-ins

accessor built-ins

◆ log_bs

const mysql_service_log_builtins_string_t* log_bs = nullptr

string built-ins

◆ log_filename

const char* log_filename = "test_sql_replication"
static

◆ mysql_declare_plugin_end

mysql_declare_plugin_end

◆ outfile

File outfile
static

◆ protocol_callbacks

◆ reg_srv

const mysql_service_registry_t* reg_srv = nullptr
static

◆ sep

const char* sep
static
Initial value:
=
"========================================================================"
"\n"

◆ test_query_plan

struct st_test_statement test_query_plan[]
static
Initial value:
= {
{NULL, true, "SELECT 'first complex command' as a"},
{"test", false,
"INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,1), (5,2), (6,3)"},
{"test", true, "SELECT * FROM t1"},
{"test", false, "UPDATE t1 SET c1 = 100 WHERE c2 = 2"},
{"test", true, "SELECT * FROM t1"}}

◆ test_sql_service_plugin

struct st_mysql_daemon test_sql_service_plugin
static
Initial value:
NULL
#define NULL
Definition: types.h:55
sql_start_row
static int sql_start_row(void *ctx)
Definition: test_sql_replication.cc:217
value
const string value("\"Value\"")
X
#define X(b)
Definition: xcom_base.c:5476
sql_get_string
static int sql_get_string(void *ctx, const char *const value, size_t length, const CHARSET_INFO *const)
Definition: test_sql_replication.cc:367
sql_get_datetime
static int sql_get_datetime(void *ctx, const MYSQL_TIME *value, uint)
Definition: test_sql_replication.cc:350
sql_end_row
static int sql_end_row(void *ctx)
Definition: test_sql_replication.cc:224
sql_field_metadata
static int sql_field_metadata(void *ctx, struct st_send_field *field, const CHARSET_INFO *)
Definition: test_sql_replication.cc:176
sql_get_null
static int sql_get_null(void *ctx)
Definition: test_sql_replication.cc:238
sql_get_time
static int sql_get_time(void *ctx, const MYSQL_TIME *value, uint)
Definition: test_sql_replication.cc:333
outfile
static File outfile
Definition: test_sql_replication.cc:94
sql_get_decimal
static int sql_get_decimal(void *ctx, const decimal_t *value)
Definition: test_sql_replication.cc:288
sql_get_longlong
static int sql_get_longlong(void *ctx, longlong value, uint is_unsigned)
Definition: test_sql_replication.cc:265
uchar
unsigned char uchar
Definition: my_inttypes.h:51
sql_shutdown
static void sql_shutdown(void *, int)
Definition: test_sql_replication.cc:408
sql_get_client_capabilities
static ulong sql_get_client_capabilities(void *)
Definition: test_sql_replication.cc:233
sql_abort_row
static void sql_abort_row(void *)
Definition: test_sql_replication.cc:231
sql_get_double
static int sql_get_double(void *ctx, double value, uint32)
Definition: test_sql_replication.cc:302
MYSQL_DAEMON_INTERFACE_VERSION
#define MYSQL_DAEMON_INTERFACE_VERSION
Definition: plugin.h:695
MYF
#define MYF(v)
Definition: my_inttypes.h:96
sql_get_integer
static int sql_get_integer(void *ctx, longlong value)
Definition: test_sql_replication.cc:251
sql_handle_ok
static void sql_handle_ok(void *ctx, uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *const message)
Definition: test_sql_replication.cc:381
sql_end_result_metadata
static int sql_end_result_metadata(void *ctx, uint server_status, uint warn_count)
Definition: test_sql_replication.cc:207
buffer
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
sql_start_result_metadata
static int sql_start_result_metadata(void *ctx, uint num_cols, uint, const CHARSET_INFO *resultcs)
Definition: test_sql_replication.cc:162
sql_get_date
static int sql_get_date(void *ctx, const MYSQL_TIME *value)
Definition: test_sql_replication.cc:317
sql_handle_error
static void sql_handle_error(void *ctx, uint sql_errno, const char *const err_msg, const char *const sqlstate)
Definition: test_sql_replication.cc:396
my_stpcpy
static char * my_stpcpy(char *dst, const char *src)
Copy a string from src to dst until (and including) terminating null byte.
Definition: m_string.h:162