MDEV-4438 - Spider storage engine

This commit is contained in:
Sergey Vojtovich 2013-06-27 15:18:48 +04:00
parent 107acbb9e4
commit 0b116de7c5
452 changed files with 158438 additions and 1 deletions

View File

@ -81,3 +81,4 @@ usr/share/mysql/mysql_performance_tables.sql
usr/share/mysql/mysql_test_data_timezone.sql
@CASSANDRA_DEB_FILES@
@OQGRAPH_DEB_FILES@
@SPIDER_DEB_FILES@

View File

@ -83,3 +83,4 @@ usr/share/mysql/mysql_performance_tables.sql
usr/share/mysql/mysql_test_data_timezone.sql
@CASSANDRA_DEB_FILES@
@OQGRAPH_DEB_FILES@
@SPIDER_DEB_FILES@

View File

@ -377,7 +377,7 @@ sub main {
# directly before it executes them, like "make test-force-pl" in RPM builds.
mtr_report("Logging: $0 ", join(" ", @ARGV));
$DEFAULT_SUITES.=",sequence,sql_discovery" if $source_dist;
$DEFAULT_SUITES.=",sequence,sql_discovery,spider,spider/bg" if $source_dist;
command_line_setup();

View File

@ -0,0 +1,45 @@
SET(SPIDER_SOURCES
spd_param.cc spd_sys_table.cc spd_trx.cc spd_db_conn.cc spd_conn.cc
spd_table.cc spd_direct_sql.cc spd_udf.cc spd_ping_table.cc
spd_copy_tables.cc spd_i_s.cc spd_malloc.cc ha_spider.cc spd_udf.def
spd_db_mysql.cc spd_db_handlersocket.cc spd_db_oracle.cc
hs_client/config.cpp hs_client/escape.cpp hs_client/fatal.cpp
hs_client/hstcpcli.cpp hs_client/socket.cpp hs_client/string_util.cpp
)
IF(DEFINED ENV{ORACLE_HOME})
SET(ORACLE_HOME $ENV{ORACLE_HOME})
FIND_PATH(ORACLE_INCLUDE_DIR oci.h PATHS ${ORACLE_HOME}/rdbms/public)
SET(ORACLE_OCI_LIB_NAME clntsh)
SET(ORACLE_LIB_DIR ${ORACLE_HOME}/lib)
FIND_LIBRARY(ORACLE_OCI_LIBRARY NAMES ${ORACLE_OCI_LIB_NAME} PATHS ${ORACLE_LIB_DIR})
ENDIF()
IF(EXISTS ${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake)
SET(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi")
SET(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /MAP /MAPINFO:EXPORTS")
INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/regex)
MYSQL_STORAGE_ENGINE(SPIDER)
ELSE()
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/storage/spider/hs_client
${ORACLE_INCLUDE_DIR})
SET(SPIDER_DEB_FILES "usr/lib/mysql/plugin/ha_spider.so" PARENT_SCOPE)
MYSQL_ADD_PLUGIN(spider ${SPIDER_SOURCES} STORAGE_ENGINE MODULE_ONLY MODULE_OUTPUT_NAME "ha_spider")
ENDIF()
IF(ORACLE_INCLUDE_DIR AND ORACLE_OCI_LIBRARY)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_ORACLE_OCI -DLINUX -D_GNU_SOURCE -D_REENTRANT")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_ORACLE_OCI -DLINUX -D_GNU_SOURCE -D_REENTRANT")
TARGET_LINK_LIBRARIES (spider ${ORACLE_OCI_LIBRARY})
ENDIF()

View File

@ -0,0 +1,89 @@
HAVE_HANDLERSOCKET = "-DHAVE_HANDLERSOCKET"
pkgplugindir = $(pkglibdir)/plugin
INCLUDES = -I$(SPD_MYSQL_INC)$(top_srcdir)/include \
-I$(SPD_MYSQL_INC)$(top_srcdir)/regex \
-I$(SPD_MYSQL_INC)$(top_srcdir)/sql \
-I$(SPD_MYSQL_INC)$(top_srcdir)/extra/yassl/include \
-I./hs_client \
$(MYSQL_INCLUDE_PATH) \
$(HANDLERSOCKET_INCLUDE_PATH)
noinst_HEADERS = ha_spider.h spd_conn.h spd_db_conn.h \
spd_db_include.h spd_err.h spd_sys_table.h \
spd_table.h spd_trx.h spd_include.h spd_param.h \
spd_direct_sql.h spd_udf.h spd_ping_table.h \
spd_copy_tables.h spd_malloc.h \
spd_db_mysql.h spd_db_handlersocket.h \
hs_client/allocator.hpp hs_client/config.hpp \
hs_client/mutex.hpp hs_client/string_util.hpp \
hs_client/auto_addrinfo.hpp hs_client/escape.hpp \
hs_client/socket.hpp hs_client/thread.hpp \
hs_client/auto_file.hpp hs_client/fatal.hpp \
hs_client/string_buffer.hpp hs_client/util.hpp \
hs_client/auto_ptrcontainer.hpp \
hs_client/hstcpcli.hpp hs_client/string_ref.hpp \
hs_client/hs_compat.h
lib_LTLIBRARIES = $(PLUGIN_SPIDER_LTLIBRARIES_TARGET)
EXTRA_LTLIBRARIES = ha_spider.la
pkgplugin_LTLIBRARIES = @plugin_spider_shared_target@
ha_spider_la_LDFLAGS = -shared -module -rpath $(pkgplugindir)
ha_spider_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN \
$(HAVE_HANDLERSOCKET)
ha_spider_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN \
$(HAVE_HANDLERSOCKET)
ha_spider_la_SOURCES = \
spd_param.cc \
spd_sys_table.cc \
spd_trx.cc \
spd_db_conn.cc \
spd_conn.cc \
spd_table.cc \
spd_direct_sql.cc \
spd_udf.cc \
spd_ping_table.cc \
spd_copy_tables.cc \
spd_i_s.cc \
spd_malloc.cc \
ha_spider.cc \
spd_db_mysql.cc \
spd_db_handlersocket.cc \
hs_client/config.cpp \
hs_client/escape.cpp \
hs_client/fatal.cpp \
hs_client/hstcpcli.cpp \
hs_client/socket.cpp \
hs_client/string_util.cpp
lib_LIBRARIES = $(PLUGIN_SPIDER_LIBRARIES_TARGET)
EXTRA_LIBRARIES = libspider.a
noinst_LIBRARIES = @plugin_spider_static_target@
libspider_a_CXXFLAGS = $(AM_CXXFLAGS) $(HAVE_HANDLERSOCKET)
libspider_a_CFLAGS = $(AM_CFLAGS) $(HAVE_HANDLERSOCKET)
libspider_a_SOURCES = \
spd_param.cc \
spd_sys_table.cc \
spd_trx.cc \
spd_db_conn.cc \
spd_conn.cc \
spd_table.cc \
spd_direct_sql.cc \
spd_udf.cc \
spd_ping_table.cc \
spd_copy_tables.cc \
spd_i_s.cc \
spd_malloc.cc \
ha_spider.cc \
spd_db_mysql.cc \
spd_db_handlersocket.cc \
hs_client/config.cpp \
hs_client/escape.cpp \
hs_client/fatal.cpp \
hs_client/hstcpcli.cpp \
hs_client/socket.cpp \
hs_client/string_util.cpp
EXTRA_DIST = plug.in
# Don't update the files from bitkeeper
%::SCCS/s.%

View File

@ -0,0 +1,95 @@
AC_INIT([spider_engine], [1.0], [kentokushiba@gmail.com])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_TYPE_SIZE_T
AC_DEFUN([MYSQL_PATH_TEST],[
AC_MSG_CHECKING([mysql source path])
AC_ARG_WITH([mysql],
[AS_HELP_STRING([--with-mysql=PATH],[mysql source directory PATH])],
[
if test \
-f $withval/include/mysql/plugin.h -a \
-f $withval/include/mysql.h -a \
-f $withval/include/errmsg.h -a \
\( -f $withval/sql/mysql_priv.h -o -f $withval/sql/sql_priv.h \) ;
then
SPD_MYSQL_INC="$withval/"
AC_MSG_RESULT([yes])
plugin_spider_shared_target=""
AC_SUBST(plugin_spider_shared_target)
plugin_spider_static_target=""
AC_SUBST(plugin_spider_static_target)
PLUGIN_SPIDER_LTLIBRARIES_TARGET="ha_spider.la"
AC_SUBST(PLUGIN_SPIDER_LTLIBRARIES_TARGET)
PLUGIN_SPIDER_LIBRARIES_TARGET="libspider.a"
AC_SUBST(PLUGIN_SPIDER_LIBRARIES_TARGET)
LIBTOOL="$LIBTOOL --preserve-dup-deps"
AC_SUBST(LIBTOOL)
else
AC_MSG_ERROR([Can't find header files. Please check --with-mysql=PATH option])
fi
],
[
if test \
-f ../../include/mysql/plugin.h -a \
-f ../../include/mysql.h -a \
-f ../../include/errmsg.h -a \
\( -f ../../sql/mysql_priv.h -o ../../sql/sql_priv.h \) ;
then
SPD_MYSQL_INC="../../"
AC_MSG_RESULT([no])
else
AC_MSG_ERROR([Can't find header files. Please set --with-mysql=PATH option])
fi
]
)
])
MYSQL_PATH_TEST
AC_SUBST(SPD_MYSQL_INC)
AC_DEFUN([MYSQL_INCLUDE_PATH_TEST],[
AC_MSG_CHECKING([mysql include path])
AC_ARG_WITH([mysql-include],
[AS_HELP_STRING([--with-mysql-include=PATH],[mysql include directory PATH])],
[
if test \
-f $withval/mysql_version.h -a \
-f $withval/my_config.h ;
then
MYSQL_INCLUDE_PATH="-I $withval/"
AC_MSG_RESULT([yes])
else
AC_MSG_ERROR([Can't find "my_config.h". Please check --with-mysql-include=PATH option])
fi
],
[
if test \
-f ../../include/mysql_version.h -a \
-f ../../include/my_config.h ;
then
MYSQL_INCLUDE_PATH="-I ../../include/"
AC_MSG_RESULT([no])
else
AC_MSG_ERROR([Can't find "my_config.h". Please set --with-mysql-include=PATH option])
fi
]
)
])
MYSQL_INCLUDE_PATH_TEST
AC_SUBST(MYSQL_INCLUDE_PATH)
CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti"
AC_CHECK_FUNCS([memset strchr strncasecmp])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

13545
storage/spider/ha_spider.cc Normal file

File diff suppressed because it is too large Load Diff

1014
storage/spider/ha_spider.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_ALLOCATOR_HPP
#define DENA_ALLOCATOR_HPP
#if 0
extern "C" {
#include <tlsf.h>
};
#define DENA_MALLOC(x) tlsf_malloc(x)
#define DENA_REALLOC(x, y) tlsf_realloc(x, y)
#define DENA_FREE(x) tlsf_free(x)
#define DENA_NEWCHAR(x) static_cast<char *>(tlsf_malloc(x))
#define DENA_DELETE(x) tlsf_free(x)
#endif
#if 1
#define DENA_MALLOC(x) malloc(x)
#define DENA_REALLOC(x, y) realloc(x, y)
#define DENA_FREE(x) free(x)
#define DENA_NEWCHAR(x) (new char[x])
#define DENA_DELETE(x) (delete [] x)
#endif
#if 1
#define DENA_ALLOCA_ALLOCATE(typ, len) \
static_cast<typ *>(alloca((len) * sizeof(typ)))
#define DENA_ALLOCA_FREE(x)
#else
#define DENA_ALLOCA_ALLOCATE(typ, len) \
static_cast<typ *>(malloc((len) * sizeof(typ)))
#define DENA_ALLOCA_FREE(x) free(x)
#endif
#endif

View File

@ -0,0 +1,49 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_AUTO_ADDRINFO_HPP
#define DENA_AUTO_ADDRINFO_HPP
#ifndef __WIN__
#include <netdb.h>
#endif
#include "util.hpp"
namespace dena {
struct auto_addrinfo : private noncopyable {
auto_addrinfo() : addr(0) { }
~auto_addrinfo() {
reset();
}
void reset(addrinfo *a = 0) {
if (addr != 0) {
freeaddrinfo(addr);
}
addr = a;
}
const addrinfo *get() const { return addr; }
int resolve(const char *node, const char *service, int flags = 0,
int family = AF_UNSPEC, int socktype = SOCK_STREAM, int protocol = 0) {
reset();
addrinfo hints;
hints.ai_flags = flags;
hints.ai_family = family;
hints.ai_socktype = socktype;
hints.ai_protocol = protocol;
return getaddrinfo(node, service, &hints, &addr);
}
private:
addrinfo *addr;
};
};
#endif

View File

@ -0,0 +1,67 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_AUTO_FILE_HPP
#define DENA_AUTO_FILE_HPP
/*
#ifndef __WIN__
#include <dirent.h>
#endif
*/
#include "util.hpp"
namespace dena {
struct auto_file : private noncopyable {
auto_file() : fd(-1) { }
~auto_file() {
reset();
}
int get() const { return fd; }
int close() {
if (fd < 0) {
return 0;
}
const int r = ::close(fd);
fd = -1;
return r;
}
void reset(int x = -1) {
if (fd >= 0) {
this->close();
}
fd = x;
}
private:
int fd;
};
/*
struct auto_dir : private noncopyable {
auto_dir() : dp(0) { }
~auto_dir() {
reset();
}
DIR *get() const { return dp; }
void reset(DIR *d = 0) {
if (dp != 0) {
closedir(dp);
}
dp = d;
}
private:
DIR *dp;
};
*/
};
#endif

View File

@ -0,0 +1,70 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_AUTO_PTRCONTAINER_HPP
#define DENA_AUTO_PTRCONTAINER_HPP
namespace dena {
/*
template <typename Tcnt>
struct auto_ptrcontainer {
typedef Tcnt container_type;
typedef typename container_type::value_type value_type;
typedef typename container_type::pointer pointer;
typedef typename container_type::reference reference;
typedef typename container_type::const_reference const_reference;
typedef typename container_type::size_type size_type;
typedef typename container_type::difference_type difference_type;
typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
typedef typename container_type::reverse_iterator reverse_iterator;
typedef typename container_type::const_reverse_iterator
const_reverse_iterator;
iterator begin() { return cnt.begin(); }
const_iterator begin() const { return cnt.begin(); }
iterator end() { return cnt.end(); }
const_iterator end() const { return cnt.end(); }
reverse_iterator rbegin() { return cnt.rbegin(); }
reverse_iterator rend() { return cnt.rend(); }
const_reverse_iterator rbegin() const { return cnt.rbegin(); }
const_reverse_iterator rend() const { return cnt.rend(); }
size_type size() const { return cnt.size(); }
size_type max_size() const { return cnt.max_size(); }
bool empty() const { return cnt.empty(); }
reference front() { return cnt.front(); }
const_reference front() const { cnt.front(); }
reference back() { return cnt.back(); }
const_reference back() const { cnt.back(); }
void swap(auto_ptrcontainer& x) { cnt.swap(x.cnt); }
~auto_ptrcontainer() {
for (iterator i = begin(); i != end(); ++i) {
delete *i;
}
}
template <typename Tap> void push_back_ptr(Tap& ap) {
cnt.push_back(ap.get());
ap.release();
}
void erase_ptr(iterator i) {
delete *i;
cnt.erase(i);
}
reference operator [](size_type n) { return cnt[n]; }
const_reference operator [](size_type n) const { return cnt[n]; }
void clear() { cnt.clear(); }
private:
Tcnt cnt;
};
*/
};
#endif

View File

@ -0,0 +1,291 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include "mysql_version.h"
#if MYSQL_VERSION_ID < 50500
#include "mysql_priv.h"
#include <mysql/plugin.h>
#else
#include "sql_priv.h"
#include "probes_mysql.h"
#endif
#include "config.hpp"
namespace dena {
unsigned int verbose_level = 0;
uchar *
conf_get_key(
conf_param *param,
size_t *length,
my_bool not_used __attribute__ ((unused))
) {
*length = param->key.length();
return (uchar*) param->key.ptr();
}
config::config()
{
if (my_hash_init(&conf_hash, &my_charset_bin, 32, 0, 0,
(my_hash_get_key) conf_get_key, 0, 0))
init = FALSE;
else
init = TRUE;
return;
}
config::~config()
{
if (init)
{
conf_param *param;
while ((param = (conf_param *) my_hash_element(&conf_hash, 0)))
{
my_hash_delete(&conf_hash, (uchar*) param);
delete param;
}
my_hash_free(&conf_hash);
}
}
conf_param *
config::find(const String& key) const
{
if (init)
return (conf_param *) my_hash_search(&conf_hash, (const uchar*) key.ptr(),
key.length());
else
return NULL;
}
conf_param *
config::find(const char *key) const
{
if (init)
return (conf_param *) my_hash_search(&conf_hash, (const uchar*) key,
strlen(key));
else
return NULL;
}
String
config::get_str(const String& key, const String& def) const
{
DENA_VERBOSE(30, list_all_params());
conf_param *param = find(key);
if (!param) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(default)\n", key.ptr(),
def.ptr()));
return def;
}
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", key.ptr(),
param->val.ptr()));
return param->val;
}
String
config::get_str(const char *key, const char *def) const
{
DENA_VERBOSE(30, list_all_params());
conf_param *param = find(key);
if (!param) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(default)\n", key, def));
return String(def, strlen(def), &my_charset_bin);
}
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n",
key, param->val.ptr()));
return param->val;
}
long long
config::get_int(const String& key, long long def) const
{
int err;
DENA_VERBOSE(30, list_all_params());
conf_param *param = find(key);
if (!param) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(default)\n", key.ptr(),
def));
return def;
}
const long long r = my_strtoll10(param->val.ptr(), (char**) NULL, &err);
if (err) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(err)\n", key.ptr(),
def));
return def;
}
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld\n", key.ptr(), r));
return r;
}
long long
config::get_int(const char *key, long long def) const
{
int err;
DENA_VERBOSE(30, list_all_params());
conf_param *param = find(key);
if (!param) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(default)\n", key, def));
return def;
}
const long long r = my_strtoll10(param->val.ptr(), (char**) NULL, &err);
if (err) {
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(err)\n", key, def));
return def;
}
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld\n", key, r));
return r;
}
bool
config::replace(const char *key, const char *val)
{
uint32 val_len = strlen(val);
conf_param *param = find(key);
if (!param) {
/* create */
if (!(param = new conf_param()))
return TRUE;
uint32 key_len = strlen(key);
if (
param->key.reserve(key_len + 1) ||
param->val.reserve(val_len + 1)
) {
delete param;
return TRUE;
}
param->key.q_append(key, key_len);
param->val.q_append(val, val_len);
param->key.c_ptr_safe();
param->val.c_ptr_safe();
if (my_hash_insert(&conf_hash, (uchar*) param))
{
delete param;
return TRUE;
}
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(create)\n",
param->key.ptr(), param->val.ptr()));
return FALSE;
}
/* replace */
param->val.length(0);
if (param->val.reserve(val_len + 1))
return TRUE;
param->val.q_append(val, val_len);
param->val.c_ptr_safe();
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(replace)\n",
param->key.ptr(), param->val.ptr()));
return FALSE;
}
bool
config::replace(const char *key, long long val)
{
char val_str[22];
sprintf(val_str, "%lld", val);
return replace(key, val_str);
}
bool
config::compare(const char *key, const char *val)
{
conf_param *param = find(key);
if (!param)
return FALSE;
return !strcmp(param->val.ptr(), val);
}
void
config::list_all_params() const
{
conf_param *param;
DENA_VERBOSE(10, fprintf(stderr, "list_all_params start\n"));
for(ulong i = 0; i < conf_hash.records; i++)
{
if ((param = (conf_param *) my_hash_element((HASH *) &conf_hash, i)))
{
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n",
param->key.ptr(), param->val.ptr()));
}
}
DENA_VERBOSE(10, fprintf(stderr, "list_all_params end\n"));
}
config&
config::operator =(const config& x)
{
DENA_VERBOSE(10, fprintf(stderr, "config operator = start"));
if (this != &x && init && x.init) {
conf_param *param, *new_param;
for(ulong i = 0; i < x.conf_hash.records; i++)
{
if (
(param = (conf_param *) my_hash_element((HASH *) &x.conf_hash, i)) &&
(new_param = new conf_param())
) {
if (
!new_param->key.copy(param->key) &&
!new_param->val.copy(param->val)
) {
new_param->key.c_ptr_safe();
new_param->val.c_ptr_safe();
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n",
new_param->key.ptr(), new_param->val.ptr()));
if (my_hash_insert(&conf_hash, (uchar*) new_param))
delete new_param;
} else
delete new_param;
}
}
}
DENA_VERBOSE(10, fprintf(stderr, "config operator = end %p", this));
return *this;
}
void
parse_args(int argc, char **argv, config& conf)
{
conf_param *param;
for (int i = 1; i < argc; ++i) {
const char *const arg = argv[i];
const char *const eq = strchr(arg, '=');
if (eq == 0) {
continue;
}
if (!(param = new conf_param()))
continue;
uint32 key_len = eq - arg;
uint32 val_len = strlen(eq + 1);
if (
param->key.reserve(key_len + 1) ||
param->val.reserve(val_len + 1)
) {
delete param;
continue;
}
param->key.q_append(arg, key_len);
param->val.q_append(eq + 1, val_len);
param->key.c_ptr_safe();
param->val.c_ptr_safe();
if (my_hash_insert(&conf.conf_hash, (uchar*) param))
{
delete param;
continue;
}
}
param = conf.find("verbose");
if (param) {
verbose_level = atoi(param->val.c_ptr());
}
}
};

View File

@ -0,0 +1,81 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_CONFIG_HPP
#define DENA_CONFIG_HPP
#include "mysql_version.h"
#if MYSQL_VERSION_ID < 50500
#include "mysql_priv.h"
#include <mysql/plugin.h>
#else
#include "sql_priv.h"
#include "probes_mysql.h"
#include "sql_class.h"
#endif
#define DENA_VERBOSE(lv, x) if (dena::verbose_level >= (lv)) { (x); }
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
#define INFO_KIND_HS_RET_FIELDS 1
#define INFO_KIND_HS_APPEND_STRING_REF 3
#define INFO_KIND_HS_CLEAR_STRING_REF 4
#define INFO_KIND_HS_INCREMENT_BEGIN 5
#define INFO_KIND_HS_INCREMENT_END 6
#define INFO_KIND_HS_DECREMENT_BEGIN 7
#define INFO_KIND_HS_DECREMENT_END 8
#endif
namespace dena {
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
struct uint32_info {
size_t info_size;
uint32 *info;
};
#endif
struct conf_param {
String key;
String val;
};
uchar *conf_get_key(
conf_param *share,
size_t *length,
my_bool not_used __attribute__ ((unused))
);
struct config {
bool init;
HASH conf_hash;
config();
~config();
conf_param *find(const String& key) const;
conf_param *find(const char *key) const;
String get_str(const String& key, const String& def =
String("", &my_charset_bin)) const;
String get_str(const char *key, const char *def = "") const;
long long get_int(const String& key, long long def = 0) const;
long long get_int(const char *key, long long def = 0) const;
bool replace(const char *key, const char *val);
bool replace(const char *key, long long val);
bool compare(const char *key, const char *val);
void list_all_params() const;
config& operator =(const config& x);
};
void parse_args(int argc, char **argv, config& conf);
extern unsigned int verbose_level;
};
#endif

View File

@ -0,0 +1,127 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#include "mysql_version.h"
#include "hs_compat.h"
#include "escape.hpp"
#include "string_buffer.hpp"
#include "fatal.hpp"
#include "string_util.hpp"
#define DBG_OP(x)
#define DBG_BUF(x)
namespace dena {
enum special_char_t {
special_char_escape_prefix = 0x01, /* SOH */
special_char_noescape_min = 0x10, /* DLE */
special_char_escape_shift = 0x40, /* '@' */
};
void
escape_string(char *& wp, const char *start, const char *finish)
{
while (start != finish) {
const unsigned char c = *start;
if (c >= special_char_noescape_min) {
wp[0] = c; /* no need to escape */
} else {
wp[0] = special_char_escape_prefix;
++wp;
wp[0] = c + special_char_escape_shift;
}
++start;
++wp;
}
}
void
escape_string(string_buffer& ar, const char *start, const char *finish)
{
const size_t buflen = (finish - start) * 2;
char *const wp_begin = ar.make_space(buflen);
char *wp = wp_begin;
escape_string(wp, start, finish);
ar.space_wrote(wp - wp_begin);
}
bool
unescape_string(char *& wp, const char *start, const char *finish)
{
/* works even if wp == start */
while (start != finish) {
const unsigned char c = *start;
if (c != special_char_escape_prefix) {
wp[0] = c;
} else if (start + 1 != finish) {
++start;
const unsigned char cn = *start;
if (cn < special_char_escape_shift) {
return false;
}
wp[0] = cn - special_char_escape_shift;
} else {
return false;
}
++start;
++wp;
}
return true;
}
bool
unescape_string(string_buffer& ar, const char *start, const char *finish)
{
const size_t buflen = finish - start;
char *const wp_begin = ar.make_space(buflen);
char *wp = wp_begin;
const bool r = unescape_string(wp, start, finish);
ar.space_wrote(wp - wp_begin);
return r;
}
uint32
read_ui32(char *& start, char *finish)
{
char *const n_begin = start;
read_token(start, finish);
char *const n_end = start;
uint32 v = 0;
for (char *p = n_begin; p != n_end; ++p) {
const char ch = p[0];
if (ch >= '0' && ch <= '9') {
v *= 10;
v += (ch - '0');
}
}
return v;
}
void
write_ui32(string_buffer& buf, uint32 v)
{
char *wp = buf.make_space(12);
int len = snprintf(wp, 12, "%u", v);
if (len > 0) {
buf.space_wrote(len);
}
}
void
write_ui64(string_buffer& buf, uint64 v)
{
char *wp = buf.make_space(22);
int len = snprintf(wp, 22, "%llu", static_cast<unsigned long long>(v));
if (len > 0) {
buf.space_wrote(len);
}
}
};

View File

@ -0,0 +1,64 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#include "string_buffer.hpp"
#include "string_ref.hpp"
#include "string_util.hpp"
#ifndef DENA_ESCAPE_HPP
#define DENA_ESCAPE_HPP
namespace dena {
void escape_string(char *& wp, const char *start, const char *finish);
void escape_string(string_buffer& ar, const char *start, const char *finish);
bool unescape_string(char *& wp, const char *start, const char *finish);
/* unescaped_string() works even if wp == start */
bool unescape_string(string_buffer& ar, const char *start, const char *finish);
uint32 read_ui32(char *& start, char *finish);
void write_ui32(string_buffer& buf, uint32 v);
void write_ui64(string_buffer& buf, uint64 v);
inline bool
is_null_expression(const char *start, const char *finish)
{
return (finish == start + 1 && start[0] == 0);
}
inline void
read_token(char *& start, char *finish)
{
char *const p = memchr_char(start, '\t', finish - start);
if (p == 0) {
start = finish;
} else {
start = p;
}
}
inline void
skip_token_delim_fold(char *& start, char *finish)
{
while (start != finish && start[0] == '\t') {
++start;
}
}
inline void
skip_one(char *& start, char *finish)
{
if (start != finish) {
++start;
}
}
};
#endif

View File

@ -0,0 +1,68 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include "mysql_version.h"
#if MYSQL_VERSION_ID < 50500
#include "mysql_priv.h"
#include <mysql/plugin.h>
#else
#include "sql_priv.h"
#include "probes_mysql.h"
#endif
#include "fatal.hpp"
namespace dena {
/*
const int opt_syslog = LOG_ERR | LOG_PID | LOG_CONS;
*/
void
fatal_exit(const String& message)
{
fprintf(stderr, "FATAL_EXIT: %s\n", message.ptr());
/*
syslog(opt_syslog, "FATAL_EXIT: %s", message.ptr());
*/
_exit(1);
}
void
fatal_exit(const char *message)
{
fprintf(stderr, "FATAL_EXIT: %s\n", message);
/*
syslog(opt_syslog, "FATAL_EXIT: %s", message);
*/
_exit(1);
}
void
fatal_abort(const String& message)
{
fprintf(stderr, "FATAL_COREDUMP: %s\n", message.ptr());
/*
syslog(opt_syslog, "FATAL_COREDUMP: %s", message.ptr());
*/
abort();
}
void
fatal_abort(const char *message)
{
fprintf(stderr, "FATAL_COREDUMP: %s\n", message);
/*
syslog(opt_syslog, "FATAL_COREDUMP: %s", message);
*/
abort();
}
};

View File

@ -0,0 +1,33 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_FATAL_HPP
#define DENA_FATAL_HPP
#include "mysql_version.h"
#if MYSQL_VERSION_ID < 50500
#include "mysql_priv.h"
#include <mysql/plugin.h>
#else
#include "sql_priv.h"
#include "probes_mysql.h"
#include "sql_class.h"
#endif
namespace dena {
void fatal_exit(const String& message);
void fatal_exit(const char *message);
void fatal_abort(const String& message);
void fatal_abort(const char *message);
};
#endif

View File

@ -0,0 +1,31 @@
/* Copyright (C) 2013 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef HS_COMPAT_H
#define HS_COMPAT_H
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \
my_init_dynamic_array2(A, B, C, D, E, F)
#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \
init_alloc_root(A, B, C, D)
#else
#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \
my_init_dynamic_array2(A, B, C, D, E)
#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \
init_alloc_root(A, B, C)
#endif
#endif

View File

@ -0,0 +1,643 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include "mysql_version.h"
#include "hs_compat.h"
#if MYSQL_VERSION_ID < 50500
#include "mysql_priv.h"
#include <mysql/plugin.h>
#else
#include "sql_priv.h"
#include "probes_mysql.h"
#include "sql_class.h"
#endif
#include "hstcpcli.hpp"
#include "auto_file.hpp"
#include "string_util.hpp"
#include "auto_addrinfo.hpp"
#include "escape.hpp"
#include "util.hpp"
/* TODO */
#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
#endif
#define DBG(x)
namespace dena {
hstresult::hstresult()
{
SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16,
MYF(MY_WME));
}
hstresult::~hstresult()
{
delete_dynamic(&flds);
}
struct hstcpcli : public hstcpcli_i, private noncopyable {
hstcpcli(const socket_args& args);
virtual ~hstcpcli();
virtual void close();
virtual int reconnect();
virtual bool stable_point();
virtual void request_buf_open_index(size_t pst_id, const char *dbn,
const char *tbl, const char *idx, const char *retflds, const char *filflds);
virtual void request_buf_auth(const char *secret, const char *typ);
virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op,
const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip,
const string_ref& mod_op, const string_ref *mvs, size_t mvslen,
const hstcpcli_filter *fils, size_t filslen, int invalues_keypart,
const string_ref *invalues, size_t invalueslen);
virtual size_t request_buf_append(const char *start, const char *finish);
virtual void request_reset();
virtual int request_send();
virtual int response_recv(size_t& num_flds_r);
virtual int get_result(hstresult& result);
virtual const string_ref *get_next_row();
virtual const string_ref *get_next_row_from_result(hstresult& result);
virtual void response_buf_remove();
virtual int get_error_code();
virtual String& get_error();
virtual void clear_error();
virtual int set_timeout(int send_timeout, int recv_timeout);
virtual size_t get_num_req_bufd() { return num_req_bufd; }
virtual size_t get_num_req_sent() { return num_req_sent; }
virtual size_t get_num_req_rcvd() { return num_req_rcvd; }
virtual size_t get_response_end_offset() { return response_end_offset; }
virtual const char *get_readbuf_begin() { return readbuf.begin(); }
virtual const char *get_readbuf_end() { return readbuf.end(); }
virtual void write_error_to_log(const char *func_name, const char *file_name,
ulong line_no);
private:
int read_more();
int set_error(int code, const String& str);
int set_error(int code, const char *str);
private:
auto_file fd;
socket_args sargs;
string_buffer readbuf;
string_buffer writebuf;
size_t response_end_offset; /* incl newline */
size_t cur_row_offset;
size_t num_flds;
size_t num_req_bufd; /* buffered but not yet sent */
size_t num_req_sent; /* sent but not yet received */
size_t num_req_rcvd; /* received but not yet removed */
int error_code;
String error_str;
DYNAMIC_ARRAY flds;
int errno_buf;
};
hstcpcli::hstcpcli(const socket_args& args)
: sargs(args), response_end_offset(0), cur_row_offset(0), num_flds(0),
num_req_bufd(0), num_req_sent(0), num_req_rcvd(0), error_code(0), errno_buf(0)
{
String err;
SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16, MYF(MY_WME));
if (socket_connect(fd, sargs, err) != 0) {
set_error(-1, err);
}
}
hstcpcli::~hstcpcli()
{
delete_dynamic(&flds);
}
void
hstcpcli::close()
{
fd.close();
readbuf.clear();
writebuf.clear();
response_end_offset = 0;
cur_row_offset = 0;
num_flds = 0;
num_req_bufd = 0;
num_req_sent = 0;
num_req_rcvd = 0;
}
int
hstcpcli::reconnect()
{
clear_error();
close();
String err;
if (socket_connect(fd, sargs, err) != 0) {
set_error(-1, err);
}
return error_code;
}
int
hstcpcli::set_timeout(int send_timeout, int recv_timeout)
{
String err;
sargs.send_timeout = send_timeout;
sargs.recv_timeout = recv_timeout;
if (socket_set_timeout(fd, sargs, err) != 0) {
set_error(-1, err);
}
return error_code;
}
bool
hstcpcli::stable_point()
{
/* returns true if cli can send a new request */
return fd.get() >= 0 && num_req_bufd == 0 && num_req_sent == 0 &&
num_req_rcvd == 0 && response_end_offset == 0;
}
int
hstcpcli::get_error_code()
{
return error_code;
}
String&
hstcpcli::get_error()
{
return error_str;
}
int
hstcpcli::read_more()
{
const size_t block_size = 4096; // FIXME
char *const wp = readbuf.make_space(block_size);
int rlen;
errno = 0;
while ((rlen = read(fd.get(), wp, block_size)) <= 0) {
errno_buf = errno;
if (rlen < 0) {
if (errno == EINTR || errno == EAGAIN)
{
errno = 0;
continue;
}
error_str = String("read: failed", &my_charset_bin);
} else {
error_str = String("read: eof", &my_charset_bin);
}
return rlen;
}
readbuf.space_wrote(rlen);
return rlen;
}
void
hstcpcli::clear_error()
{
DBG(fprintf(stderr, "CLEAR_ERROR: %d\n", error_code));
error_code = 0;
error_str.length(0);
}
int
hstcpcli::set_error(int code, const String& str)
{
DBG(fprintf(stderr, "SET_ERROR: %d\n", code));
error_code = code;
error_str = str;
return error_code;
}
int
hstcpcli::set_error(int code, const char *str)
{
uint32 str_len = strlen(str);
DBG(fprintf(stderr, "SET_ERROR: %d\n", code));
error_code = code;
error_str.length(0);
if (error_str.reserve(str_len + 1))
return 0;
error_str.q_append(str, str_len);
error_str.c_ptr_safe();
return error_code;
}
void
hstcpcli::request_buf_open_index(size_t pst_id, const char *dbn,
const char *tbl, const char *idx, const char *retflds, const char *filflds)
{
/*
if (num_req_sent > 0 || num_req_rcvd > 0) {
*/
if (num_req_rcvd > 0) {
close();
set_error(-1, "request_buf_open_index: protocol out of sync");
return;
}
const string_ref dbn_ref(dbn, strlen(dbn));
const string_ref tbl_ref(tbl, strlen(tbl));
const string_ref idx_ref(idx, strlen(idx));
const string_ref rfs_ref(retflds, strlen(retflds));
writebuf.append_literal("P\t");
append_uint32(writebuf, pst_id); // FIXME size_t ?
writebuf.append_literal("\t");
writebuf.append(dbn_ref.begin(), dbn_ref.end());
writebuf.append_literal("\t");
writebuf.append(tbl_ref.begin(), tbl_ref.end());
writebuf.append_literal("\t");
writebuf.append(idx_ref.begin(), idx_ref.end());
writebuf.append_literal("\t");
writebuf.append(rfs_ref.begin(), rfs_ref.end());
if (filflds != 0) {
const string_ref fls_ref(filflds, strlen(filflds));
writebuf.append_literal("\t");
writebuf.append(fls_ref.begin(), fls_ref.end());
}
writebuf.append_literal("\n");
++num_req_bufd;
}
void
hstcpcli::request_buf_auth(const char *secret, const char *typ)
{
/*
if (num_req_sent > 0 || num_req_rcvd > 0) {
*/
if (num_req_rcvd > 0) {
close();
set_error(-1, "request_buf_auth: protocol out of sync");
return;
}
if (typ == 0) {
typ = "1";
}
const string_ref typ_ref(typ, strlen(typ));
const string_ref secret_ref(secret, strlen(secret));
writebuf.append_literal("A\t");
writebuf.append(typ_ref.begin(), typ_ref.end());
writebuf.append_literal("\t");
writebuf.append(secret_ref.begin(), secret_ref.end());
writebuf.append_literal("\n");
++num_req_bufd;
}
namespace {
void
append_delim_value(string_buffer& buf, const char *start, const char *finish)
{
if (start == 0) {
/* null */
const char t[] = "\t\0";
buf.append(t, t + 2);
} else {
/* non-null */
buf.append_literal("\t");
escape_string(buf, start, finish);
}
}
};
void
hstcpcli::request_buf_exec_generic(size_t pst_id, const string_ref& op,
const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip,
const string_ref& mod_op, const string_ref *mvs, size_t mvslen,
const hstcpcli_filter *fils, size_t filslen, int invalues_keypart,
const string_ref *invalues, size_t invalueslen)
{
/*
if (num_req_sent > 0 || num_req_rcvd > 0) {
*/
if (num_req_rcvd > 0) {
close();
set_error(-1, "request_buf_exec_generic: protocol out of sync");
return;
}
append_uint32(writebuf, pst_id); // FIXME size_t ?
writebuf.append_literal("\t");
writebuf.append(op.begin(), op.end());
writebuf.append_literal("\t");
append_uint32(writebuf, kvslen); // FIXME size_t ?
for (size_t i = 0; i < kvslen; ++i) {
const string_ref& kv = kvs[i];
append_delim_value(writebuf, kv.begin(), kv.end());
}
if (limit != 0 || skip != 0 || invalues_keypart >= 0 ||
mod_op.size() != 0 || filslen != 0) {
/* has more option */
writebuf.append_literal("\t");
append_uint32(writebuf, limit); // FIXME size_t ?
if (skip != 0 || invalues_keypart >= 0 ||
mod_op.size() != 0 || filslen != 0) {
writebuf.append_literal("\t");
append_uint32(writebuf, skip); // FIXME size_t ?
}
if (invalues_keypart >= 0) {
writebuf.append_literal("\t@\t");
append_uint32(writebuf, invalues_keypart);
writebuf.append_literal("\t");
append_uint32(writebuf, invalueslen);
for (size_t i = 0; i < invalueslen; ++i) {
const string_ref& s = invalues[i];
append_delim_value(writebuf, s.begin(), s.end());
}
}
for (size_t i = 0; i < filslen; ++i) {
const hstcpcli_filter& f = fils[i];
writebuf.append_literal("\t");
writebuf.append(f.filter_type.begin(), f.filter_type.end());
writebuf.append_literal("\t");
writebuf.append(f.op.begin(), f.op.end());
writebuf.append_literal("\t");
append_uint32(writebuf, f.ff_offset);
append_delim_value(writebuf, f.val.begin(), f.val.end());
}
if (mod_op.size() != 0) {
writebuf.append_literal("\t");
writebuf.append(mod_op.begin(), mod_op.end());
for (size_t i = 0; i < mvslen; ++i) {
const string_ref& mv = mvs[i];
append_delim_value(writebuf, mv.begin(), mv.end());
}
}
}
writebuf.append_literal("\n");
++num_req_bufd;
}
size_t
hstcpcli::request_buf_append(const char *start, const char *finish)
{
/*
if (num_req_sent > 0 || num_req_rcvd > 0) {
*/
if (num_req_rcvd > 0) {
close();
set_error(-1, "request_buf_append: protocol out of sync");
return 0;
}
const char *nl = start;
size_t num_req = 0;
while ((nl = memchr_char(nl, '\n', finish - nl))) {
if (nl == finish)
break;
num_req++;
nl++;
}
num_req++;
writebuf.append(start, finish);
if (*(finish - 1) != '\n')
writebuf.append_literal("\n");
num_req_bufd += num_req;
return num_req;
}
void
hstcpcli::request_reset()
{
if (num_req_bufd) {
writebuf.erase_front(writebuf.size());
num_req_bufd = 0;
}
}
int
hstcpcli::request_send()
{
if (error_code < 0) {
return error_code;
}
clear_error();
if (fd.get() < 0) {
close();
return set_error(-1, "write: closed");
}
/*
if (num_req_bufd == 0 || num_req_sent > 0 || num_req_rcvd > 0) {
*/
if (num_req_bufd == 0 || num_req_rcvd > 0) {
close();
return set_error(-1, "request_send: protocol out of sync");
}
const size_t wrlen = writebuf.size();
const ssize_t r = send(fd.get(), writebuf.begin(), wrlen, MSG_NOSIGNAL);
if (r <= 0) {
close();
return set_error(-1, r < 0 ? "write: failed" : "write: eof");
}
writebuf.erase_front(r);
if (static_cast<size_t>(r) != wrlen) {
close();
return set_error(-1, "write: incomplete");
}
num_req_sent += num_req_bufd;
num_req_bufd = 0;
DBG(fprintf(stderr, "REQSEND 0\n"));
return 0;
}
int
hstcpcli::response_recv(size_t& num_flds_r)
{
if (error_code < 0) {
return error_code;
}
clear_error();
if (num_req_bufd > 0 || num_req_sent == 0 || num_req_rcvd > 0 ||
response_end_offset != 0) {
close();
return set_error(-1, "response_recv: protocol out of sync");
}
cur_row_offset = 0;
num_flds_r = num_flds = 0;
if (fd.get() < 0) {
return set_error(-1, "read: closed");
}
size_t offset = 0;
while (true) {
const char *const lbegin = readbuf.begin() + offset;
const char *const lend = readbuf.end();
if (lbegin < lend)
{
const char *const nl = memchr_char(lbegin, '\n', lend - lbegin);
if (nl != 0) {
offset += (nl + 1) - lbegin;
break;
}
offset += lend - lbegin;
}
if (read_more() <= 0) {
close();
error_code = -1;
return error_code;
}
}
response_end_offset = offset;
--num_req_sent;
++num_req_rcvd;
char *start = readbuf.begin();
char *const finish = start + response_end_offset - 1;
const size_t resp_code = read_ui32(start, finish);
skip_one(start, finish);
num_flds_r = num_flds = read_ui32(start, finish);
if (resp_code != 0) {
skip_one(start, finish);
char *const err_begin = start;
read_token(start, finish);
char *const err_end = start;
String e = String(err_begin, err_end - err_begin, &my_charset_bin);
if (!e.length()) {
e = String("unknown_error", &my_charset_bin);
}
return set_error(resp_code, e);
}
cur_row_offset = start - readbuf.begin();
DBG(fprintf(stderr, "[%s] ro=%zu eol=%zu\n",
String(readbuf.begin(), readbuf.begin() + response_end_offset)
.c_str(),
cur_row_offset, response_end_offset));
DBG(fprintf(stderr, "RES 0\n"));
if (flds.max_element < num_flds)
{
if (allocate_dynamic(&flds, num_flds))
return set_error(-1, "out of memory");
}
flds.elements = num_flds;
return 0;
}
int
hstcpcli::get_result(hstresult& result)
{
/*
readbuf.swap(result.readbuf);
*/
char *const wp = result.readbuf.make_space(response_end_offset);
memcpy(wp, readbuf.begin(), response_end_offset);
result.readbuf.space_wrote(response_end_offset);
result.response_end_offset = response_end_offset;
result.num_flds = num_flds;
result.cur_row_offset = cur_row_offset;
if (result.flds.max_element < num_flds)
{
if (allocate_dynamic(&result.flds, num_flds))
return set_error(-1, "out of memory");
}
result.flds.elements = num_flds;
return 0;
}
const string_ref *
hstcpcli::get_next_row()
{
if (num_flds == 0 || flds.elements < num_flds) {
DBG(fprintf(stderr, "GNR NF 0\n"));
return 0;
}
char *start = readbuf.begin() + cur_row_offset;
char *const finish = readbuf.begin() + response_end_offset - 1;
if (start >= finish) { /* start[0] == nl */
DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish));
return 0;
}
for (size_t i = 0; i < num_flds; ++i) {
skip_one(start, finish);
char *const fld_begin = start;
read_token(start, finish);
char *const fld_end = start;
char *wp = fld_begin;
if (is_null_expression(fld_begin, fld_end)) {
/* null */
((string_ref *) flds.buffer)[i] = string_ref();
} else {
unescape_string(wp, fld_begin, fld_end); /* in-place */
((string_ref *) flds.buffer)[i] = string_ref(fld_begin, wp);
}
}
cur_row_offset = start - readbuf.begin();
return (string_ref *) flds.buffer;
}
const string_ref *
hstcpcli::get_next_row_from_result(hstresult& result)
{
if (result.num_flds == 0 || result.flds.elements < result.num_flds) {
DBG(fprintf(stderr, "GNR NF 0\n"));
return 0;
}
char *start = result.readbuf.begin() + result.cur_row_offset;
char *const finish = result.readbuf.begin() + result.response_end_offset - 1;
if (start >= finish) { /* start[0] == nl */
DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish));
return 0;
}
for (size_t i = 0; i < result.num_flds; ++i) {
skip_one(start, finish);
char *const fld_begin = start;
read_token(start, finish);
char *const fld_end = start;
char *wp = fld_begin;
if (is_null_expression(fld_begin, fld_end)) {
/* null */
((string_ref *) result.flds.buffer)[i] = string_ref();
} else {
unescape_string(wp, fld_begin, fld_end); /* in-place */
((string_ref *) result.flds.buffer)[i] = string_ref(fld_begin, wp);
}
}
result.cur_row_offset = start - result.readbuf.begin();
return (string_ref *) result.flds.buffer;
}
void
hstcpcli::response_buf_remove()
{
if (response_end_offset == 0) {
close();
set_error(-1, "response_buf_remove: protocol out of sync");
return;
}
readbuf.erase_front(response_end_offset);
response_end_offset = 0;
--num_req_rcvd;
cur_row_offset = 0;
num_flds = 0;
}
void
hstcpcli::write_error_to_log(
const char *func_name,
const char *file_name,
ulong line_no
) {
if (errno_buf) {
time_t cur_time = (time_t) time((time_t*) 0);
struct tm lt;
struct tm *l_time = localtime_r(&cur_time, &lt);
fprintf(stderr,
"%04d%02d%02d %02d:%02d:%02d [ERROR] hstcpcli: [%d][%s]"
" [%s][%s][%lu] errno=%d\n",
l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday,
l_time->tm_hour, l_time->tm_min, l_time->tm_sec,
error_code, error_str.c_ptr_safe(),
func_name, file_name, line_no, errno_buf);
}
}
hstcpcli_ptr
hstcpcli_i::create(const socket_args& args)
{
return hstcpcli_ptr(new hstcpcli(args));
}
};

View File

@ -0,0 +1,93 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_HSTCPCLI_HPP
#define DENA_HSTCPCLI_HPP
#define HANDLERSOCKET_MYSQL_UTIL 1
#include "mysql_version.h"
#if MYSQL_VERSION_ID < 50500
#include "mysql_priv.h"
#include <mysql/plugin.h>
#else
#include "sql_priv.h"
#include "probes_mysql.h"
#endif
#include "config.hpp"
#include "socket.hpp"
#include "string_ref.hpp"
#include "string_buffer.hpp"
namespace dena {
struct hstcpcli_filter {
string_ref filter_type;
string_ref op;
size_t ff_offset;
string_ref val;
hstcpcli_filter() : ff_offset(0) { }
};
struct hstcpcli_i;
typedef hstcpcli_i *hstcpcli_ptr;
struct hstresult {
hstresult();
virtual ~hstresult();
string_buffer readbuf;
size_t response_end_offset;
size_t num_flds;
size_t cur_row_offset;
DYNAMIC_ARRAY flds;
};
struct hstcpcli_i {
virtual ~hstcpcli_i() { }
virtual void close() = 0;
virtual int reconnect() = 0;
virtual bool stable_point() = 0;
virtual void request_buf_auth(const char *secret, const char *typ) = 0;
virtual void request_buf_open_index(size_t pst_id, const char *dbn,
const char *tbl, const char *idx, const char *retflds,
const char *filflds = 0) = 0;
virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op,
const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip,
const string_ref& mod_op, const string_ref *mvs, size_t mvslen,
const hstcpcli_filter *fils = 0, size_t filslen = 0,
int invalues_keypart = -1, const string_ref *invalues = 0,
size_t invalueslen = 0) = 0; // FIXME: too long
virtual size_t request_buf_append(const char *start, const char *finish) = 0;
virtual void request_reset() = 0;
virtual int request_send() = 0;
virtual int response_recv(size_t& num_flds_r) = 0;
virtual int get_result(hstresult& result) = 0;
virtual const string_ref *get_next_row() = 0;
virtual const string_ref *get_next_row_from_result(hstresult& result) = 0;
virtual void response_buf_remove() = 0;
virtual int get_error_code() = 0;
virtual String& get_error() = 0;
virtual void clear_error() = 0;
virtual int set_timeout(int send_timeout, int recv_timeout) = 0;
virtual size_t get_num_req_bufd() = 0;
virtual size_t get_num_req_sent() = 0;
virtual size_t get_num_req_rcvd() = 0;
virtual size_t get_response_end_offset() = 0;
virtual const char *get_readbuf_begin() = 0;
virtual const char *get_readbuf_end() = 0;
virtual void write_error_to_log(const char *func_name, const char *file_name,
ulong line_no) = 0;
static hstcpcli_ptr create(const socket_args& args);
};
};
#endif

View File

@ -0,0 +1,48 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_MUTEX_HPP
#define DENA_MUTEX_HPP
#include "fatal.hpp"
#include "util.hpp"
namespace dena {
struct condition;
struct mutex : private noncopyable {
friend struct condition;
mutex() {
if (pthread_mutex_init(&mtx, 0) != 0) {
fatal_abort("pthread_mutex_init");
}
}
~mutex() {
if (pthread_mutex_destroy(&mtx) != 0) {
fatal_abort("pthread_mutex_destroy");
}
}
void lock() const {
if (pthread_mutex_lock(&mtx) != 0) {
fatal_abort("pthread_mutex_lock");
}
}
void unlock() const {
if (pthread_mutex_unlock(&mtx) != 0) {
fatal_abort("pthread_mutex_unlock");
}
}
private:
mutable pthread_mutex_t mtx;
};
};
#endif

View File

@ -0,0 +1,310 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef __WIN__
#include <sys/un.h>
#endif
#include "mysql_version.h"
#include "hs_compat.h"
#if MYSQL_VERSION_ID < 50500
#include "mysql_priv.h"
#include <mysql/plugin.h>
#else
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
#include <my_global.h>
#endif
#include "sql_priv.h"
#include "probes_mysql.h"
#endif
#include "socket.hpp"
#include "string_util.hpp"
#include "fatal.hpp"
/*
struct sockaddr_un {
short sun_family;
char sun_path[108];
};
*/
namespace dena {
void
ignore_sigpipe()
{
#if defined(SIGPIPE) && !defined(__WIN__)
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
fatal_abort("SIGPIPE SIG_IGN");
}
#endif
}
void
socket_args::set(const config& conf)
{
timeout = (int) conf.get_int("timeout", 600);
listen_backlog = (int) conf.get_int("listen_backlog", 256);
String node = conf.get_str("host", "");
String port = conf.get_str("port", "");
if (node.length() || port.length()) {
if (family == AF_UNIX || !strcmp(node.c_ptr(), "/")) {
set_unix_domain(port.c_ptr());
} else {
const char *nd = !node.length() ? 0 : node.c_ptr();
if (resolve(nd, port.c_ptr()) != 0) {
String message("getaddrinfo failed: ", &my_charset_bin);
message.reserve(node.length() + sizeof(":") - 1 + port.length());
message.append(node);
message.q_append(":", sizeof(":") - 1);
message.append(port);
fatal_exit(message);
}
}
}
sndbuf = (int) conf.get_int("sndbuf", 0);
rcvbuf = (int) conf.get_int("rcvbuf", 0);
}
void
socket_args::set_unix_domain(const char *path)
{
#ifndef __WIN__
family = AF_UNIX;
addr = sockaddr_storage();
addrlen = sizeof(sockaddr_un);
sockaddr_un *const ap = reinterpret_cast<sockaddr_un *>(&addr);
ap->sun_family = AF_UNIX;
strncpy(ap->sun_path, path, sizeof(ap->sun_path) - 1);
#endif
}
int
socket_args::resolve(const char *node, const char *service)
{
const int flags = (node == 0) ? AI_PASSIVE : 0;
auto_addrinfo ai;
addr = sockaddr_storage();
addrlen = 0;
const int r = ai.resolve(node, service, flags, family, socktype, protocol);
if (r != 0) {
return r;
}
memcpy(&addr, ai.get()->ai_addr, ai.get()->ai_addrlen);
addrlen = ai.get()->ai_addrlen;
return 0;
}
int
socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r)
{
if (!args.nonblocking) {
#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO)
if (args.recv_timeout != 0) {
#ifndef __WIN__
struct timeval tv;
tv.tv_sec = args.recv_timeout;
tv.tv_usec = 0;
#else
int tv = args.recv_timeout * 1000;
#endif
if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO,
#ifndef __WIN__
(const void *) &tv,
#else
(const char *) &tv,
#endif
sizeof(tv)) != 0) {
return errno_string("setsockopt SO_RCVTIMEO", errno, err_r);
}
}
if (args.send_timeout != 0) {
#ifndef __WIN__
struct timeval tv;
tv.tv_sec = args.send_timeout;
tv.tv_usec = 0;
#else
int tv = args.send_timeout * 1000;
#endif
if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO,
#ifndef __WIN__
(const void *) &tv,
#else
(const char *) &tv,
#endif
sizeof(tv)) != 0) {
return errno_string("setsockopt SO_SNDTIMEO", errno, err_r);
}
}
#endif
}
return 0;
}
int
socket_set_options(auto_file& fd, const socket_args& args, String& err_r)
{
if (args.timeout != 0 && !args.nonblocking) {
#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO)
#ifndef __WIN__
struct timeval tv;
tv.tv_sec = args.timeout;
tv.tv_usec = 0;
#else
int tv = args.timeout * 1000;
#endif
if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO,
#ifndef __WIN__
(const void *) &tv,
#else
(const char *) &tv,
#endif
sizeof(tv)) != 0) {
return errno_string("setsockopt SO_RCVTIMEO", errno, err_r);
}
#ifndef __WIN__
tv.tv_sec = args.timeout;
tv.tv_usec = 0;
#else
tv = args.timeout * 1000;
#endif
if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO,
#ifndef __WIN__
(const void *) &tv,
#else
(const char *) &tv,
#endif
sizeof(tv)) != 0) {
return errno_string("setsockopt SO_RCVTIMEO", errno, err_r);
}
#endif
}
#ifndef __WIN__
if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) {
return errno_string("fcntl O_NONBLOCK", errno, err_r);
}
#endif
if (args.sndbuf != 0) {
const int v = args.sndbuf;
if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDBUF,
#ifndef __WIN__
(const void *) &v,
#else
(const char *) &v,
#endif
sizeof(v)) != 0) {
return errno_string("setsockopt SO_SNDBUF", errno, err_r);
}
}
if (args.rcvbuf != 0) {
const int v = args.rcvbuf;
if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVBUF,
#ifndef __WIN__
(const void *) &v,
#else
(const char *) &v,
#endif
sizeof(v)) != 0) {
return errno_string("setsockopt SO_RCVBUF", errno, err_r);
}
}
return 0;
}
int
socket_open(auto_file& fd, const socket_args& args, String& err_r)
{
fd.reset(socket(args.family, args.socktype, args.protocol));
if (fd.get() < 0) {
return errno_string("socket", errno, err_r);
}
return socket_set_options(fd, args, err_r);
}
int
socket_connect(auto_file& fd, const socket_args& args, String& err_r)
{
int r = 0;
if ((r = socket_open(fd, args, err_r)) != 0) {
return r;
}
if (connect(fd.get(), reinterpret_cast<const sockaddr *>(&args.addr),
args.addrlen) != 0) {
if (!args.nonblocking
#ifndef __WIN__
|| errno != EINPROGRESS
#endif
) {
return errno_string("connect", errno, err_r);
}
}
return 0;
}
int
socket_bind(auto_file& fd, const socket_args& args, String& err_r)
{
fd.reset(socket(args.family, args.socktype, args.protocol));
if (fd.get() < 0) {
return errno_string("socket", errno, err_r);
}
if (args.reuseaddr) {
#ifndef __WIN__
if (args.family == AF_UNIX) {
const sockaddr_un *const ap =
reinterpret_cast<const sockaddr_un *>(&args.addr);
if (unlink(ap->sun_path) != 0 && errno != ENOENT) {
return errno_string("unlink uds", errno, err_r);
}
} else {
#endif
int v = 1;
if (setsockopt(fd.get(), SOL_SOCKET, SO_REUSEADDR,
#ifndef __WIN__
(const void *) &v,
#else
(const char *) &v,
#endif
sizeof(v)) != 0) {
return errno_string("setsockopt SO_REUSEADDR", errno, err_r);
}
#ifndef __WIN__
}
#endif
}
if (bind(fd.get(), reinterpret_cast<const sockaddr *>(&args.addr),
args.addrlen) != 0) {
return errno_string("bind", errno, err_r);
}
if (listen(fd.get(), args.listen_backlog) != 0) {
return errno_string("listen", errno, err_r);
}
#ifndef __WIN__
if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) {
return errno_string("fcntl O_NONBLOCK", errno, err_r);
}
#endif
return 0;
}
int
socket_accept(int listen_fd, auto_file& fd, const socket_args& args,
sockaddr_storage& addr_r, socklen_t& addrlen_r, String& err_r)
{
fd.reset(accept(listen_fd, reinterpret_cast<sockaddr *>(&addr_r),
&addrlen_r));
if (fd.get() < 0) {
return errno_string("accept", errno, err_r);
}
return socket_set_options(fd, args, err_r);
}
};

View File

@ -0,0 +1,62 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_SOCKET_HPP
#define DENA_SOCKET_HPP
#include "mysql_version.h"
#if MYSQL_VERSION_ID < 50500
#include "mysql_priv.h"
#include <mysql/plugin.h>
#else
#include "sql_priv.h"
#include "probes_mysql.h"
#endif
#include "auto_addrinfo.hpp"
#include "auto_file.hpp"
#include "config.hpp"
namespace dena {
struct socket_args {
sockaddr_storage addr;
socklen_t addrlen;
int family;
int socktype;
int protocol;
int timeout;
int send_timeout;
int recv_timeout;
int listen_backlog;
bool reuseaddr;
bool nonblocking;
bool use_epoll;
int sndbuf;
int rcvbuf;
socket_args() : addr(), addrlen(0), family(AF_INET), socktype(SOCK_STREAM),
protocol(0), timeout(600), send_timeout(600), recv_timeout(600),
listen_backlog(256), reuseaddr(true), nonblocking(false), use_epoll(false),
sndbuf(0), rcvbuf(0) { }
void set(const config& conf);
void set_unix_domain(const char *path);
int resolve(const char *node, const char *service);
};
void ignore_sigpipe();
int socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r);
int socket_bind(auto_file& fd, const socket_args& args, String& err_r);
int socket_connect(auto_file& fd, const socket_args& args, String& err_r);
int socket_accept(int listen_fd, auto_file& fd, const socket_args& args,
sockaddr_storage& addr_r, socklen_t& addrlen_r, String& err_r);
};
#endif

View File

@ -0,0 +1,146 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_STRING_BUFFER_HPP
#define DENA_STRING_BUFFER_HPP
/*
#include <stdlib.h>
#include <string.h>
*/
#include "util.hpp"
#include "allocator.hpp"
#include "fatal.hpp"
namespace dena {
struct string_buffer : private noncopyable {
string_buffer() : buffer(0), begin_offset(0), end_offset(0), alloc_size(0) { }
~string_buffer() {
real_free();
}
void real_free() {
if (alloc_size) {
DENA_FREE(buffer);
buffer = 0;
begin_offset = 0;
end_offset = 0;
alloc_size = 0;
}
}
size_t real_size() {
return alloc_size;
}
const char *begin() const {
return buffer + begin_offset;
}
const char *end() const {
return buffer + end_offset;
}
char *begin() {
return buffer + begin_offset;
}
char *end() {
return buffer + end_offset;
}
size_t size() const {
return end_offset - begin_offset;
}
void clear() {
begin_offset = end_offset = 0;
}
void resize(size_t len) {
if (size() < len) {
reserve(len);
memset(buffer + end_offset, 0, len - size());
}
end_offset = begin_offset + len;
}
void reserve(size_t len) {
if (alloc_size >= begin_offset + len) {
return;
}
size_t asz = alloc_size;
while (asz < begin_offset + len) {
if (asz == 0) {
asz = 16;
}
const size_t asz_n = asz << 1;
if (asz_n < asz) {
fatal_abort("string_buffer::resize() overflow");
}
asz = asz_n;
}
void *const p = DENA_REALLOC(buffer, asz);
if (p == 0) {
fatal_abort("string_buffer::resize() realloc");
}
buffer = static_cast<char *>(p);
alloc_size = asz;
}
void erase_front(size_t len) {
if (len >= size()) {
clear();
} else {
begin_offset += len;
}
}
char *make_space(size_t len) {
reserve(size() + len);
return buffer + end_offset;
}
void space_wrote(size_t len) {
len = len < alloc_size - end_offset ? len : alloc_size - end_offset;
end_offset += len;
}
template <size_t N>
void append_literal(const char (& str)[N]) {
append(str, str + N - 1);
}
void append(const char *start, const char *finish) {
const size_t len = finish - start;
reserve(size() + len);
memcpy(buffer + end_offset, start, len);
end_offset += len;
}
void append_2(const char *s1, const char *f1, const char *s2,
const char *f2) {
const size_t l1 = f1 - s1;
const size_t l2 = f2 - s2;
reserve(end_offset + l1 + l2);
memcpy(buffer + end_offset, s1, l1);
memcpy(buffer + end_offset + l1, s2, l2);
end_offset += l1 + l2;
}
void swap(string_buffer& sb) {
char *tmp_buffer = buffer;
size_t tmp_begin_offset = begin_offset;
size_t tmp_end_offset = end_offset;
size_t tmp_alloc_size = alloc_size;
buffer = sb.buffer;
begin_offset = sb.begin_offset;
end_offset = sb.end_offset;
alloc_size = sb.alloc_size;
sb.buffer = tmp_buffer;
sb.begin_offset = tmp_begin_offset;
sb.end_offset = tmp_end_offset;
sb.alloc_size = tmp_alloc_size;
}
private:
char *buffer;
size_t begin_offset;
size_t end_offset;
size_t alloc_size;
};
};
#endif

View File

@ -0,0 +1,106 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_STRING_REF_HPP
#define DENA_STRING_REF_HPP
namespace dena {
struct string_wref {
typedef char value_type;
char *begin() const { return start; }
char *end() const { return start + length; }
size_t size() const { return length; }
private:
char *start;
size_t length;
public:
string_wref(char *s = 0, size_t len = 0) : start(s), length(len) { }
};
struct string_ref {
typedef const char value_type;
const char *begin() const { return start; }
const char *end() const { return start + length; }
size_t size() const { return length; }
void set(const char *s, size_t len) { start = s; length = len; }
void set(const char *s, const char *f) { start = s; length = f - s; }
private:
const char *start;
size_t length;
public:
string_ref(const char *s = 0, size_t len = 0) : start(s), length(len) { }
string_ref(const char *s, const char *f) : start(s), length(f - s) { }
string_ref(const string_wref& w) : start(w.begin()), length(w.size()) { }
};
template <size_t N> inline bool
operator ==(const string_ref& x, const char (& y)[N]) {
return (x.size() == N - 1) && (::memcmp(x.begin(), y, N - 1) == 0);
}
inline bool
operator ==(const string_ref& x, const string_ref& y) {
return (x.size() == y.size()) &&
(::memcmp(x.begin(), y.begin(), x.size()) == 0);
}
inline bool
operator !=(const string_ref& x, const string_ref& y) {
return (x.size() != y.size()) ||
(::memcmp(x.begin(), y.begin(), x.size()) != 0);
}
struct string_ref_list_wrap {
string_ref_list_wrap() {
if (SPD_INIT_DYNAMIC_ARRAY2(&string_ref_list, sizeof(string_ref),
NULL, 16, 16, MYF(MY_WME)))
string_ref_list_init = FALSE;
else
string_ref_list_init = TRUE;
}
virtual ~string_ref_list_wrap() {
if (string_ref_list_init) delete_dynamic(&string_ref_list); }
void clear() {
if (string_ref_list_init) string_ref_list.elements = 0; }
void push_back(string_ref &e) {
if (string_ref_list_init) insert_dynamic(&string_ref_list, (uchar*) &e);
return; }
size_t size() {
return string_ref_list_init ? string_ref_list.elements : 0; }
bool resize(size_t new_size) {
if (string_ref_list_init) {
if (string_ref_list.max_element < new_size && allocate_dynamic(
&string_ref_list, new_size)) return TRUE;
string_ref_list.elements = new_size;
return FALSE;
}
return TRUE;
}
bool empty() {
return string_ref_list_init ? string_ref_list.elements ?
FALSE : TRUE : TRUE; }
string_ref &operator [](size_t n) {
return ((string_ref *) (string_ref_list.buffer +
string_ref_list.size_of_element * n))[0]; }
bool string_ref_list_init;
DYNAMIC_ARRAY string_ref_list;
};
inline String *
q_append_str(String *str, const char *p) {
uint32 p_len = strlen(p);
if (str->reserve(p_len)) return NULL;
str->q_append(p, p_len); return str;
}
};
#endif

View File

@ -0,0 +1,206 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#include "mysql_version.h"
#include "hs_compat.h"
#if MYSQL_VERSION_ID < 50500
#include "mysql_priv.h"
#include <mysql/plugin.h>
#else
#include "sql_priv.h"
#include "probes_mysql.h"
#endif
#include "string_util.hpp"
namespace dena {
string_wref
get_token(char *& wp, char *wp_end, char delim)
{
char *const wp_begin = wp;
char *const p = memchr_char(wp_begin, delim, wp_end - wp_begin);
if (p == 0) {
wp = wp_end;
return string_wref(wp_begin, wp_end - wp_begin);
}
wp = p + 1;
return string_wref(wp_begin, p - wp_begin);
}
uint32
atoi_uint32_nocheck(const char *start, const char *finish)
{
uint32 v = 0;
for (; start != finish; ++start) {
const char c = *start;
if (c < '0' || c > '9') {
break;
}
v *= 10;
v += (uint32) (c - '0');
}
return v;
}
long long
atoll_nocheck(const char *start, const char *finish)
{
long long v = 0;
bool negative = false;
if (start != finish) {
if (start[0] == '-') {
++start;
negative = true;
} else if (start[0] == '+') {
++start;
}
}
for (; start != finish; ++start) {
const char c = *start;
if (c < '0' || c > '9') {
break;
}
v *= 10;
if (negative) {
v -= (long long) (c - '0');
} else {
v += (long long) (c - '0');
}
}
return v;
}
void
append_uint32(string_buffer& buf, uint32 v)
{
char *const wp = buf.make_space(64);
const int len = snprintf(wp, 64, "%lu", static_cast<unsigned long>(v));
if (len > 0) {
buf.space_wrote(len);
}
}
/*
String *
to_stdstring(uint32 v)
{
char buf[64];
int str_len;
String *str;
str_len = snprintf(buf, sizeof(buf), "%lu", static_cast<unsigned long>(v));
if ((str = new String(str_len + 1)))
str->q_append(buf, str_len);
return str;
}
*/
int
errno_string(const char *s, int en, String& err_r)
{
char buf[64];
int str_len;
str_len = snprintf(buf, sizeof(buf), "%s: %d", s, en);
if (!err_r.reserve(str_len + 1))
err_r.q_append(buf, str_len);
return en;
}
size_t
split(char delim, const string_ref& buf, string_ref *parts,
size_t parts_len)
{
size_t i = 0;
const char *start = buf.begin();
const char *const finish = buf.end();
for (i = 0; i < parts_len; ++i) {
const char *const p = memchr_char(start, delim, finish - start);
if (p == 0) {
parts[i] = string_ref(start, finish - start);
++i;
break;
}
parts[i] = string_ref(start, p - start);
start = p + 1;
}
const size_t r = i;
for (; i < parts_len; ++i) {
parts[i] = string_ref();
}
return r;
}
size_t
split(char delim, const string_wref& buf, string_wref *parts,
size_t parts_len)
{
size_t i = 0;
char *start = buf.begin();
char *const finish = buf.end();
for (i = 0; i < parts_len; ++i) {
char *const p = memchr_char(start, delim, finish - start);
if (p == 0) {
parts[i] = string_wref(start, finish - start);
++i;
break;
}
parts[i] = string_wref(start, p - start);
start = p + 1;
}
const size_t r = i;
for (; i < parts_len; ++i) {
parts[i] = string_wref();
}
return r;
}
size_t
split(char delim, const string_ref& buf, DYNAMIC_ARRAY& parts_r)
{
size_t i = 0;
const char *start = buf.begin();
const char *finish = buf.end();
while (true) {
const char *p = memchr_char(start, delim, finish - start);
if (p == 0) {
string_ref param(start, finish - start);
insert_dynamic(&parts_r, (uchar *) &param);
break;
}
string_ref param(start, p - start);
insert_dynamic(&parts_r, (uchar *) &param);
start = p + 1;
}
const size_t r = i;
return r;
}
size_t
split(char delim, const string_wref& buf, DYNAMIC_ARRAY& parts_r)
{
size_t i = 0;
char *start = buf.begin();
char *finish = buf.end();
while (true) {
char *p = memchr_char(start, delim, finish - start);
if (p == 0) {
string_wref param(start, finish - start);
insert_dynamic(&parts_r, (uchar *) &param);
break;
}
string_wref param(start, p - start);
insert_dynamic(&parts_r, (uchar *) &param);
start = p + 1;
}
const size_t r = i;
return r;
}
};

View File

@ -0,0 +1,51 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_STRING_UTIL_HPP
#define DENA_STRING_UTIL_HPP
#include "string_buffer.hpp"
#include "string_ref.hpp"
namespace dena {
inline const char *
memchr_char(const char *s, int c, size_t n)
{
return static_cast<const char *>(memchr(s, c, n));
}
inline char *
memchr_char(char *s, int c, size_t n)
{
return static_cast<char *>(memchr(s, c, n));
}
string_wref get_token(char *& wp, char *wp_end, char delim);
uint32 atoi_uint32_nocheck(const char *start, const char *finish);
/*
String *to_stdstring(uint32 v);
*/
void append_uint32(string_buffer& buf, uint32 v);
long long atoll_nocheck(const char *start, const char *finish);
int errno_string(const char *s, int en, String& err_r);
size_t split(char delim, const string_ref& buf, string_ref *parts,
size_t parts_len);
size_t split(char delim, const string_wref& buf, string_wref *parts,
size_t parts_len);
size_t split(char delim, const string_ref& buf,
DYNAMIC_ARRAY& parts_r);
size_t split(char delim, const string_wref& buf,
DYNAMIC_ARRAY& parts_r);
};
#endif

View File

@ -0,0 +1,84 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved.
* Copyright (C) 2011 Kentoku SHIBA
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_THREAD_HPP
#define DENA_THREAD_HPP
#include "fatal.hpp"
namespace dena {
/*
template <typename T>
struct thread : private noncopyable {
template <typename Ta> thread(const Ta& arg, size_t stack_sz = 256 * 1024)
: obj(arg), thr(0), need_join(false), stack_size(stack_sz) { }
template <typename Ta0, typename Ta1> thread(const Ta0& a0,
volatile Ta1& a1, size_t stack_sz = 256 * 1024)
: obj(a0, a1), thr(0), need_join(false), stack_size(stack_sz) { }
~thread() {
join();
}
void start() {
if (!start_nothrow()) {
fatal_abort("thread::start");
}
}
bool start_nothrow() {
if (need_join) {
return need_join;
}
void *const arg = this;
pthread_attr_t attr;
if (pthread_attr_init(&attr) != 0) {
fatal_abort("pthread_attr_init");
}
if (pthread_attr_setstacksize(&attr, stack_size) != 0) {
fatal_abort("pthread_attr_setstacksize");
}
const int r = pthread_create(&thr, &attr, thread_main, arg);
if (pthread_attr_destroy(&attr) != 0) {
fatal_abort("pthread_attr_destroy");
}
if (r != 0) {
return need_join;
}
need_join = true;
return need_join;
}
void join() {
if (!need_join) {
return;
}
int e = 0;
if ((e = pthread_join(thr, 0)) != 0) {
fatal_abort("pthread_join");
}
need_join = false;
}
T& operator *() { return obj; }
T *operator ->() { return &obj; }
private:
static void *thread_main(void *arg) {
thread *p = static_cast<thread *>(arg);
p->obj();
return 0;
}
private:
T obj;
pthread_t thr;
bool need_join;
size_t stack_size;
};
*/
};
#endif

View File

@ -0,0 +1,25 @@
// vim:sw=2:ai
/*
* Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#ifndef DENA_UTIL_HPP
#define DENA_UTIL_HPP
namespace dena {
/* boost::noncopyable */
struct noncopyable {
noncopyable() { }
private:
noncopyable(const noncopyable&);
noncopyable& operator =(const noncopyable&);
};
};
#endif

View File

@ -0,0 +1 @@
--source ../../include/deinit_spider.inc

View File

@ -0,0 +1 @@
--source ../../include/deinit_spider.inc

View File

@ -0,0 +1 @@
--source ../../include/deinit_spider.inc

View File

@ -0,0 +1 @@
--source ../../include/deinit_spider.inc

View File

@ -0,0 +1,8 @@
let $CHILD2_1_HA_AS_DROP_TABLES=
$CHILD2_1_DROP_TABLES;
let $CHILD2_1_HA_AS_CREATE_TABLES=
$CHILD2_1_CREATE_TABLES;
let $CHILD2_1_HA_AS_DROP_TABLES2=
$CHILD2_1_DROP_TABLES2;
let $CHILD2_1_HA_AS_CREATE_TABLES2=
$CHILD2_1_CREATE_TABLES2;

View File

@ -0,0 +1,4 @@
let $CHILD2_2_HA_DROP_TABLES=
$CHILD2_2_DROP_TABLES;
let $CHILD2_2_HA_CREATE_TABLES=
$CHILD2_2_CREATE_TABLES;

View File

@ -0,0 +1,4 @@
let $CHILD2_3_HA_DROP_TABLES=
$CHILD2_3_DROP_TABLES;
let $CHILD2_3_HA_CREATE_TABLES=
$CHILD2_3_CREATE_TABLES;

View File

@ -0,0 +1,140 @@
--let $CHILD3_1_ENGINE_TYPE=Spider
--let $CHILD3_1_ENGINE=ENGINE=Spider
--source ../../include/init_spider.inc
eval INSERT INTO mysql.spider_link_mon_servers
(db_name, table_name, link_id, sid, server, scheme, host, port, socket,
username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key,
ssl_verify_server_cert, default_file, default_group) VALUES
('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL);
let $CHILD3_1_CHECK_LINK_STATUS=
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
let $CHILD3_1_CHECK_LINK_FAILED_LOG=
SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
let $CHILD3_1_SET_RECOVERY_STATUS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2", lst "0 2"';
let $CHILD3_1_SET_OK_STATUS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2", lst "0 1"';
let $CHILD3_1_SET_OK_STATUS_AS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2", lst "1 0"';
let $CHILD3_1_DROP_TABLES_HA_2_1=
DROP TABLE IF EXISTS ta_l;
if ($VERSION_COMPILE_OS_WIN)
{
let $CHILD3_1_CREATE_TABLES_HA_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_1_ENGINE $CHILD3_1_CHARSET
COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2"';
let $CHILD3_1_CREATE_TABLES_HA_AS_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_1_ENGINE $CHILD3_1_CHARSET
COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2"';
}
if (!$VERSION_COMPILE_OS_WIN)
{
let $CHILD3_1_CREATE_TABLES_HA_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_1_ENGINE $CHILD3_1_CHARSET
COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2"';
let $CHILD3_1_CREATE_TABLES_HA_AS_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_1_ENGINE $CHILD3_1_CHARSET
COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2"';
}
let $CHILD3_1_DROP_TABLES_HA_P_2_1=
DROP TABLE IF EXISTS ta_l2;
let $CHILD3_1_CREATE_TABLES_HA_P_2_1=
CREATE TABLE ta_l2 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_1_ENGINE $CHILD3_1_CHARSET
COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"'
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001"'
);
let $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1=
CREATE TABLE ta_l2 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_1_ENGINE $CHILD3_1_CHARSET
COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001"'
);
let $CHILD3_1_SET_RECOVERY_STATUS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 2"'
);
let $CHILD3_1_SET_OK_STATUS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 1"'
);
let $CHILD3_1_SET_OK_STATUS_AS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "1 0"'
);

View File

@ -0,0 +1,140 @@
--let $CHILD3_2_ENGINE_TYPE=Spider
--let $CHILD3_2_ENGINE=ENGINE=Spider
--source ../../include/init_spider.inc
eval INSERT INTO mysql.spider_link_mon_servers
(db_name, table_name, link_id, sid, server, scheme, host, port, socket,
username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key,
ssl_verify_server_cert, default_file, default_group) VALUES
('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL);
let $CHILD3_2_CHECK_LINK_STATUS=
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
let $CHILD3_2_CHECK_LINK_FAILED_LOG=
SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
let $CHILD3_2_SET_RECOVERY_STATUS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2", lst "0 2"';
let $CHILD3_2_SET_OK_STATUS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2", lst "0 1"';
let $CHILD3_2_SET_OK_STATUS_AS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2", lst "1 0"';
let $CHILD3_2_DROP_TABLES_HA_2_1=
DROP TABLE IF EXISTS ta_l;
if ($VERSION_COMPILE_OS_WIN)
{
let $CHILD3_2_CREATE_TABLES_HA_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_2_ENGINE $CHILD3_2_CHARSET
COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2"';
let $CHILD3_2_CREATE_TABLES_HA_AS_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_2_ENGINE $CHILD3_2_CHARSET
COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2"';
}
if (!$VERSION_COMPILE_OS_WIN)
{
let $CHILD3_2_CREATE_TABLES_HA_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_2_ENGINE $CHILD3_2_CHARSET
COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2"';
let $CHILD3_2_CREATE_TABLES_HA_AS_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_2_ENGINE $CHILD3_2_CHARSET
COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2"';
}
let $CHILD3_2_DROP_TABLES_HA_P_2_1=
DROP TABLE IF EXISTS ta_l2;
let $CHILD3_2_CREATE_TABLES_HA_P_2_1=
CREATE TABLE ta_l2 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_2_ENGINE $CHILD3_2_CHARSET
COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"'
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001"'
);
let $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1=
CREATE TABLE ta_l2 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_2_ENGINE $CHILD3_2_CHARSET
COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001"'
);
let $CHILD3_2_SET_RECOVERY_STATUS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 2"'
);
let $CHILD3_2_SET_OK_STATUS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 1"'
);
let $CHILD3_2_SET_OK_STATUS_AS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "1 0"'
);

View File

@ -0,0 +1,140 @@
--let $CHILD3_3_ENGINE_TYPE=Spider
--let $CHILD3_3_ENGINE=ENGINE=Spider
--source ../../include/init_spider.inc
eval INSERT INTO mysql.spider_link_mon_servers
(db_name, table_name, link_id, sid, server, scheme, host, port, socket,
username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key,
ssl_verify_server_cert, default_file, default_group) VALUES
('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL);
let $CHILD3_3_CHECK_LINK_STATUS=
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
let $CHILD3_3_CHECK_LINK_FAILED_LOG=
SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
let $CHILD3_3_SET_RECOVERY_STATUS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2", lst "0 2"';
let $CHILD3_3_SET_OK_STATUS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2", lst "0 1"';
let $CHILD3_3_SET_OK_STATUS_AS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2", lst "1 0"';
let $CHILD3_3_DROP_TABLES_HA_2_1=
DROP TABLE IF EXISTS ta_l;
if ($VERSION_COMPILE_OS_WIN)
{
let $CHILD3_3_CREATE_TABLES_HA_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_3_ENGINE $CHILD3_3_CHARSET
COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2"';
let $CHILD3_3_CREATE_TABLES_HA_AS_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_3_ENGINE $CHILD3_3_CHARSET
COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2"';
}
if (!$VERSION_COMPILE_OS_WIN)
{
let $CHILD3_3_CREATE_TABLES_HA_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_3_ENGINE $CHILD3_3_CHARSET
COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2"';
let $CHILD3_3_CREATE_TABLES_HA_AS_2_1=
CREATE TABLE ta_l (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_3_ENGINE $CHILD3_3_CHARSET
COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2"';
}
let $CHILD3_3_DROP_TABLES_HA_P_2_1=
DROP TABLE IF EXISTS ta_l2;
let $CHILD3_3_CREATE_TABLES_HA_P_2_1=
CREATE TABLE ta_l2 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_3_ENGINE $CHILD3_3_CHARSET
COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"'
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001"'
);
let $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1=
CREATE TABLE ta_l2 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD3_3_ENGINE $CHILD3_3_CHARSET
COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001"'
);
let $CHILD3_3_SET_RECOVERY_STATUS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 2"'
);
let $CHILD3_3_SET_OK_STATUS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 1"'
);
let $CHILD3_3_SET_OK_STATUS_AS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "1 0"'
);

View File

@ -0,0 +1,105 @@
eval INSERT INTO mysql.spider_link_mon_servers
(db_name, table_name, link_id, sid, server, scheme, host, port, socket,
username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key,
ssl_verify_server_cert, default_file, default_group) VALUES
('%auto_test_local%', '%ta_l%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
('%auto_test_local%', '%ta_l%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
('%auto_test_local%', '%ta_l%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL);
let $MASTER_1_CHECK_LINK_STATUS=
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
let $MASTER_1_CHECK_LINK_FAILED_LOG=
SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
let $MASTER_1_SET_RECOVERY_STATUS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2", lst "0 2"';
let $MASTER_1_SET_OK_STATUS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2", lst "0 1"';
let $MASTER_1_SET_OK_STATUS_AS_2_1=
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2", lst "1 0"';
let $MASTER_1_COPY_TABLES_2_1=
SELECT spider_copy_tables('ta_l', '0', '1');
if ($VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT_HA_2_1=
COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2"';
let $MASTER_1_COMMENT_HA_AS_2_1=
COMMENT='port "$CHILD2_1_MYPORT $CHILD2_2_MYPORT", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2"';
}
if (!$VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT_HA_2_1=
COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2",
database "auto_test_remote auto_test_remote2"';
let $MASTER_1_COMMENT_HA_AS_2_1=
COMMENT='socket "$CHILD2_1_MYSOCK $CHILD2_2_MYSOCK", table "ta_r ta_r3"'
CONNECTION='host "localhost", user "root", password "",
msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2"';
}
let $MASTER_1_COMMENT_HA_P_2_1=
COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2"'
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001"'
);
let $MASTER_1_COMMENT_HA_AS_P_2_1=
COMMENT='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001"'
);
let $MASTER_1_SET_RECOVERY_STATUS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 2"'
);
let $MASTER_1_SET_OK_STATUS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 1"'
);
let $MASTER_1_SET_OK_STATUS_AS_P_2_1=
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "1 0"'
);
let $MASTER_1_COPY_TABLES_P_2_1=
SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1');
let $MASTER_1_CHECK_HA_STATUS=
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
let $MASTER_1_CHANGE_HA_MON=
SELECT spider_flush_table_mon_cache();

View File

@ -0,0 +1,24 @@
let $CHILD2_1_HS_DROP_TABLES=
DROP TABLE IF EXISTS hs_r;
let $CHILD2_1_HS_CREATE_TABLES=
CREATE TABLE hs_r (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
d INT DEFAULT 11,
PRIMARY KEY(a)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_HS_SELECT_TABLES=
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r ORDER BY a;
let $CHILD2_1_HS_DROP_TABLES2=
DROP TABLE IF EXISTS hs_r2;
let $CHILD2_1_HS_CREATE_TABLES2=
CREATE TABLE hs_r2 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
d INT DEFAULT 11,
PRIMARY KEY(a)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_HS_SELECT_TABLES2=
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r2 ORDER BY a;

View File

@ -0,0 +1,12 @@
let $CHILD2_2_HS_DROP_TABLES=
DROP TABLE IF EXISTS hs_r3;
let $CHILD2_2_HS_CREATE_TABLES=
CREATE TABLE hs_r3 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
d INT DEFAULT 11,
PRIMARY KEY(a)
) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
let $CHILD2_2_HS_SELECT_TABLES=
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_r3 ORDER BY a;

View File

@ -0,0 +1,12 @@
let $MASTER_1_HS_COMMENT_TMP=
COMMENT='';
let $MASTER_1_HS_COMMENT_2_1=
COMMENT='srv "s_2_1", table "hs_r", uhr "1", uhw "1", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT", hwr "0"';
let $MASTER_1_HS_COMMENT_P_2_1=
COMMENT='uhr "1", uhw "1", hwr "0"'
PARTITION BY RANGE(a) (
PARTITION pt1 VALUES LESS THAN (4)
COMMENT='srv "s_2_1", table "hs_r2", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"',
PARTITION pt2 VALUES LESS THAN MAXVALUE
COMMENT='srv "s_2_2", table "hs_r3", hrp "$CHILD2_2_HSRPORT", hwp "$CHILD2_2_HSWPORT"'
);

View File

@ -0,0 +1,175 @@
let $CHILD2_1_DROP_TABLES=
DROP TABLE IF EXISTS ta_r;
let $CHILD2_1_CREATE_TABLES=
CREATE TABLE ta_r (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a),
KEY idx1(b)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_SELECT_TABLES=
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a;
let $CHILD2_1_DROP_TABLES2=
DROP TABLE IF EXISTS ta_r2;
let $CHILD2_1_CREATE_TABLES2=
CREATE TABLE ta_r2 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_SELECT_TABLES2=
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r2 ORDER BY a;
let $CHILD2_1_DROP_TABLES3=
DROP TABLE IF EXISTS ta_r_no_idx;
let $CHILD2_1_CREATE_TABLES3=
CREATE TABLE ta_r_no_idx (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10'
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_SELECT_TABLES3=
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_no_idx ORDER BY a;
let $CHILD2_1_DROP_TABLES4=
DROP TABLE IF EXISTS ta_r_auto_inc;
let $CHILD2_1_CREATE_TABLES4=
CREATE TABLE ta_r_auto_inc (
a INT AUTO_INCREMENT,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_SELECT_TABLES4=
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_auto_inc
ORDER BY a;
let $CHILD2_1_DROP_TABLES5=
DROP TABLE IF EXISTS ta_r_int;
let $CHILD2_1_CREATE_TABLES5=
CREATE TABLE ta_r_int (
a INT AUTO_INCREMENT,
b INT DEFAULT 10,
c INT DEFAULT 11,
PRIMARY KEY(a),
KEY idx1(b),
KEY idx2(c)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_SELECT_TABLES5=
SELECT a, b, c FROM ta_r_int ORDER BY a;
let $CHILD2_1_DROP_TABLES6=
DROP TABLE IF EXISTS ta_r_3;
let $CHILD2_1_CREATE_TABLES6=
CREATE TABLE ta_r_3 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10'
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_SELECT_TABLES6=
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_3 ORDER BY a;
let $CHILD2_1_DROP_FT_TABLES=
DROP TABLE IF EXISTS ft_r;
let $CHILD2_1_CREATE_FT_TABLES=
CREATE TABLE ft_r (
a INT DEFAULT 0,
b TEXT,
c TEXT,
d TEXT,
PRIMARY KEY(a),
FULLTEXT INDEX ft_idx1(b),
FULLTEXT INDEX ft_idx2(c)
) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET;
let $CHILD2_1_SELECT_FT_TABLES=
SELECT a, b, c, d FROM ft_r ORDER BY a;
let $CHILD2_1_DROP_FT_TABLES2=
DROP TABLE IF EXISTS ft_r2;
let $CHILD2_1_CREATE_FT_TABLES2=
CREATE TABLE ft_r2 (
a INT DEFAULT 0,
b TEXT,
c TEXT,
d TEXT,
PRIMARY KEY(a),
FULLTEXT INDEX ft_idx1(b),
FULLTEXT INDEX ft_idx2(c)
) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET;
let $CHILD2_1_SELECT_FT_TABLES2=
SELECT a, b, c, d FROM ft_r2 ORDER BY a;
let $CHILD2_1_DROP_GM_TABLES=
DROP TABLE IF EXISTS gm_r;
let $CHILD2_1_CREATE_GM_TABLES=
CREATE TABLE gm_r (
a INT DEFAULT 0,
b GEOMETRY NOT NULL,
c GEOMETRY NOT NULL,
PRIMARY KEY(a),
SPATIAL INDEX sp_idx1(b),
SPATIAL INDEX sp_idx2(c)
) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET;
let $CHILD2_1_SELECT_GM_TABLES=
SELECT a, b, c FROM gm_r ORDER BY a;
let $CHILD2_1_DROP_GM_TABLES2=
DROP TABLE IF EXISTS gm_r2;
let $CHILD2_1_CREATE_GM_TABLES2=
CREATE TABLE gm_r2 (
a INT DEFAULT 0,
b GEOMETRY NOT NULL,
c GEOMETRY NOT NULL,
PRIMARY KEY(a),
SPATIAL INDEX sp_idx1(b),
SPATIAL INDEX sp_idx2(c)
) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET;
let $CHILD2_1_SELECT_GM_TABLES2=
SELECT a, b, c FROM gm_r2 ORDER BY a;
let $CHILD2_1_DROP_LOCK_TABLES1=
DROP TABLE IF EXISTS t1_1;
let $CHILD2_1_CREATE_LOCK_TABLES1=
CREATE TABLE t1_1 (
id int(11) NOT NULL,
PRIMARY KEY (id)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_DROP_LOCK_TABLES2=
DROP TABLE IF EXISTS t2_2;
let $CHILD2_1_CREATE_LOCK_TABLES2=
CREATE TABLE t2_2 (
id int(11) NOT NULL,
PRIMARY KEY (id)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_DROP_INCREMENT_TABLES1=
DROP TABLE IF EXISTS t1_1;
let $CHILD2_1_CREATE_INCREMENT_TABLES1=
CREATE TABLE t1_1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_SELECT_INCREMENT_TABLES1=
SELECT id FROM t1_1 ORDER BY id;
let $CHILD2_1_DROP_TEXT_PK_TABLES1=
DROP TABLE IF EXISTS t1;
let $CHILD2_1_CREATE_TEXT_PK_TABLES1=
CREATE TABLE t1 (
a VARCHAR(255),
PRIMARY KEY (a)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET2;
let $CHILD2_1_SELECT_TEXT_PK_TABLES1=
SELECT a FROM t1 ORDER BY a;
let $CHILD2_1_DROP_TEXT_KEY_TABLES1=
DROP TABLE IF EXISTS t1;
let $CHILD2_1_CREATE_TEXT_KEY_TABLES1=
CREATE TABLE t1 (
a VARCHAR(255),
b VARCHAR(255),
c VARCHAR(255),
KEY idx1(a,b),
KEY idx2(b),
PRIMARY KEY(c)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
let $CHILD2_1_SELECT_TEXT_KEY_TABLES1=
SELECT a, b FROM t1 ORDER BY a, b;
let $CHILD2_1_AUTO_INCREMENT_INCREMENT1=
SET GLOBAL AUTO_INCREMENT_INCREMENT = 1;
let $CHILD2_1_AUTO_INCREMENT_INCREMENT2=
SET GLOBAL AUTO_INCREMENT_INCREMENT = 4;
let $CHILD2_1_AUTO_INCREMENT_OFFSET1=
SET GLOBAL AUTO_INCREMENT_OFFSET = 1;
let $CHILD2_1_AUTO_INCREMENT_OFFSET2=
SET GLOBAL AUTO_INCREMENT_OFFSET = 2;

View File

@ -0,0 +1,80 @@
let $CHILD2_2_DROP_TABLES=
DROP TABLE IF EXISTS ta_r3;
let $CHILD2_2_CREATE_TABLES=
CREATE TABLE ta_r3 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
let $CHILD2_2_DROP_TABLES5=
DROP TABLE IF EXISTS ta_r_int;
let $CHILD2_2_CREATE_TABLES5=
CREATE TABLE ta_r_int (
a INT AUTO_INCREMENT,
b INT DEFAULT 10,
c INT DEFAULT 11,
PRIMARY KEY(a),
KEY idx1(b),
KEY idx2(c)
) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
let $CHILD2_2_SELECT_TABLES=
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r3 ORDER BY a;
let $CHILD2_2_DROP_FT_TABLES=
DROP TABLE IF EXISTS ft_r3;
let $CHILD2_2_CREATE_FT_TABLES=
CREATE TABLE ft_r3 (
a INT DEFAULT 0,
b TEXT,
c TEXT,
d TEXT,
PRIMARY KEY(a),
FULLTEXT INDEX ft_idx1(b),
FULLTEXT INDEX ft_idx2(c)
) $CHILD2_2_FT_ENGINE $CHILD2_2_FT_CHARSET;
let $CHILD2_2_SELECT_FT_TABLES=
SELECT a, b, c, d FROM ft_r3 ORDER BY a;
let $CHILD2_2_DROP_GM_TABLES=
DROP TABLE IF EXISTS gm_r3;
let $CHILD2_2_CREATE_GM_TABLES=
CREATE TABLE gm_r3 (
a INT DEFAULT 0,
b GEOMETRY NOT NULL,
c GEOMETRY NOT NULL,
PRIMARY KEY(a),
SPATIAL INDEX sp_idx1(b),
SPATIAL INDEX sp_idx2(c)
) $CHILD2_2_GM_ENGINE $CHILD2_2_GM_CHARSET;
let $CHILD2_2_SELECT_GM_TABLES=
SELECT a, b, c FROM gm_r3 ORDER BY a;
let $CHILD2_2_DROP_LOCK_TABLES1=
DROP TABLE IF EXISTS t1_2;
let $CHILD2_2_CREATE_LOCK_TABLES1=
CREATE TABLE t1_2 (
id int(11) NOT NULL,
PRIMARY KEY (id)
) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
let $CHILD2_2_DROP_LOCK_TABLES2=
DROP TABLE IF EXISTS t2_1;
let $CHILD2_2_CREATE_LOCK_TABLES2=
CREATE TABLE t2_1 (
id int(11) NOT NULL,
PRIMARY KEY (id)
) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
let $CHILD2_2_DROP_INCREMENT_TABLES1=
DROP TABLE IF EXISTS t1_2;
let $CHILD2_2_CREATE_INCREMENT_TABLES1=
CREATE TABLE t1_2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
let $CHILD2_2_SELECT_INCREMENT_TABLES1=
SELECT id FROM t1_2 ORDER BY id;
let $CHILD2_2_AUTO_INCREMENT_INCREMENT1=
SET GLOBAL AUTO_INCREMENT_INCREMENT = 1;
let $CHILD2_2_AUTO_INCREMENT_INCREMENT2=
SET GLOBAL AUTO_INCREMENT_INCREMENT = 4;
let $CHILD2_2_AUTO_INCREMENT_OFFSET1=
SET GLOBAL AUTO_INCREMENT_OFFSET = 1;
let $CHILD2_2_AUTO_INCREMENT_OFFSET2=
SET GLOBAL AUTO_INCREMENT_OFFSET = 3;

View File

@ -0,0 +1,11 @@
let $CHILD2_3_DROP_TABLES=
DROP TABLE IF EXISTS ta_r4;
let $CHILD2_3_CREATE_TABLES=
CREATE TABLE ta_r4 (
a INT DEFAULT 10,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) $CHILD2_3_ENGINE $CHILD2_3_CHARSET;
let $CHILD2_3_SELECT_TABLES=
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r4 ORDER BY a;

View File

@ -0,0 +1,194 @@
--source ../../include/init_spider.inc
SET spider_internal_sql_log_off= 0;
SET spider_bgs_mode= 1;
SET spider_bgs_first_read= 2;
SET spider_bgs_second_read= 2;
SET spider_split_read= 2;
SET spider_conn_recycle_mode= 2;
SET spider_multi_split_read= 1;
SET spider_reset_sql_alloc= 0;
SET spider_bulk_update_size= 40;
SET spider_direct_order_limit= 10000;
if ($VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT_2_1=
COMMENT='database "auto_test_remote", table "ta_r"'
CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root",
password ""';
}
if (!$VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT_2_1=
COMMENT='database "auto_test_remote", table "ta_r"'
CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root",
password ""';
}
if ($VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT2_2_1=
COMMENT='database "auto_test_remote", table "ta_r_no_idx"'
CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root",
password "", prt "2000000"';
}
if (!$VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT2_2_1=
COMMENT='database "auto_test_remote", table "ta_r_no_idx"'
CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root",
password "", prt "2000000"';
}
let $MASTER_1_COMMENT_P_2_1=
COMMENT='table "ta_r3"'
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1", table "ta_r2",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_2", priority "1000001"'
);
let $MASTER_1_COMMENT2_P_2_1=
COMMENT='table "ta_r3"'
PARTITION BY RANGE(a) (
PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1",
table "ta_r2", priority "1000"',
PARTITION pt2 VALUES LESS THAN MAXVALUE
COMMENT='srv "s_2_2", priority "1000001"'
);
if ($VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT3_2_1=
COMMENT='database "auto_test_remote", table "ta_r_auto_inc"'
CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root",
password ""';
}
if (!$VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT3_2_1=
COMMENT='database "auto_test_remote", table "ta_r_auto_inc"'
CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root",
password ""';
}
let $MASTER_1_COMMENT3_P_2_1=
COMMENT='table "ta_r_int"'
PARTITION BY LIST(MOD(a, 2)) (
PARTITION pt1 VALUES IN (0)
COMMENT='srv "s_2_1", priority "1000"',
PARTITION pt2 VALUES IN (1)
COMMENT='srv "s_2_2", priority "1000001"'
);
if ($VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT4_2_1=
COMMENT='database "auto_test_remote", table "ta_r_int"'
CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root",
password ""';
}
if (!$VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT4_2_1=
COMMENT='database "auto_test_remote", table "ta_r_int"'
CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root",
password ""';
}
if ($VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT5_2_1=
COMMENT='database "auto_test_remote", table "ta_r_3"'
CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root",
password ""';
}
if (!$VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT5_2_1=
COMMENT='database "auto_test_remote", table "ta_r_3"'
CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root",
password ""';
}
if ($VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT_FT_2_1=
COMMENT='database "auto_test_remote", table "ft_r"'
CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root",
password ""';
}
if (!$VERSION_COMPILE_OS_WIN)
{
let $MASTER_1_COMMENT_FT_2_1=
COMMENT='database "auto_test_remote", table "ft_r"'
CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root",
password ""';
}
let $MASTER_1_COMMENT2_FT_P_2_1=
COMMENT='table "ft_r3"'
PARTITION BY RANGE(a) (
PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1",
table "ft_r2", priority "1000"',
PARTITION pt2 VALUES LESS THAN MAXVALUE
COMMENT='srv "s_2_2", priority "1000001"'
);
let $MASTER_1_COMMENT_GM_2_1=
COMMENT='srv "s_2_1", table "gm_r"';
let $MASTER_1_COMMENT2_GM_P_2_1=
COMMENT='table "gm_r3"'
PARTITION BY RANGE(a) (
PARTITION pt1 VALUES LESS THAN (4) COMMENT='srv "s_2_1",
table "gm_r2", priority "1000"',
PARTITION pt2 VALUES LESS THAN MAXVALUE
COMMENT='srv "s_2_2", priority "1000001"'
);
let $MASTER_1_COMMENT_LOCK1=
COMMENT 'tbl "t1_1 t1_2", srv "s_2_1 s_2_2"';
let $MASTER_1_COMMENT_LOCK2=
COMMENT 'tbl "t2_1 t2_2", srv "s_2_2 s_2_1"';
let $MASTER_1_COMMENT_INCREMENT1_1=
COMMENT 'aim "1", tbl "t1_1", srv "s_2_1"';
let $MASTER_1_COMMENT_INCREMENT1_P_1=
COMMENT 'aim "1"'
PARTITION BY LIST(MOD(id, 2)) (
PARTITION pt1 VALUES IN (0)
COMMENT='tbl "t1_1", srv "s_2_1"',
PARTITION pt2 VALUES IN (1)
COMMENT='tbl "t1_2", srv "s_2_2"'
);
let $MASTER_1_COMMENT_READONLY1_1=
COMMENT 'read_only_mode "1", tbl "t1_1", srv "s_2_1"';
let $MASTER_1_COMMENT_ERROR_MODE1_1=
COMMENT 'erm "1", ewm "1", tbl "ter1_1", srv "s_2_1"';
let $MASTER_1_COMMENT_TEXT_PK1_1=
COMMENT 'tbl "t1", srv "s_2_1"';
let $MASTER_1_COMMENT_TEXT_KEY1_1=
COMMENT 'tbl "t1", srv "s_2_1"';
let $MASTER_1_CHECK_DIRECT_UPDATE_STATUS=
SHOW STATUS LIKE 'Spider_direct_update';
let $MASTER_1_CHECK_DIRECT_DELETE_STATUS=
SHOW STATUS LIKE 'Spider_direct_delete';
let $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS=
SHOW STATUS LIKE 'Spider_direct_order_limit';
let $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS=
SHOW STATUS LIKE 'Spider_direct_aggregate';
let $MASTER_1_AUTO_INCREMENT_INCREMENT1=
SET SESSION AUTO_INCREMENT_INCREMENT = 1 $STR_SEMICOLON
SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 1', '',
'srv "s_2_1"') $STR_SEMICOLON
SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 1', '',
'srv "s_2_2"');
let $MASTER_1_AUTO_INCREMENT_INCREMENT2=
SET SESSION AUTO_INCREMENT_INCREMENT = 777 $STR_SEMICOLON
SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_1"') $STR_SEMICOLON
SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_2"');
let $MASTER_1_AUTO_INCREMENT_OFFSET1=
SET SESSION AUTO_INCREMENT_OFFSET = 1 $STR_SEMICOLON
SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 1', '',
'srv "s_2_1"') $STR_SEMICOLON
SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 1', '',
'srv "s_2_2"');
let $MASTER_1_AUTO_INCREMENT_OFFSET2=
SET SESSION AUTO_INCREMENT_OFFSET = 777 $STR_SEMICOLON
SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
'srv "s_2_1"') $STR_SEMICOLON
SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
'srv "s_2_2"');
let $MASTER_1_AUTO_INCREMENT_OFFSET3=
SET SESSION AUTO_INCREMENT_OFFSET = 1;
let $MASTER_1_AUTO_INCREMENT_OFFSET4=
SET SESSION AUTO_INCREMENT_OFFSET = 777;

View File

@ -0,0 +1,10 @@
let $SLAVE1_1_COMMENT_INCREMENT1_1=
COMMENT '';
let $SLAVE1_1_COMMENT_INCREMENT1_P_1=
COMMENT ''
PARTITION BY LIST(MOD(id, 2)) (
PARTITION pt1 VALUES IN (0)
COMMENT='',
PARTITION pt2 VALUES IN (1)
COMMENT=''
);

View File

@ -0,0 +1,176 @@
# Use default setting for mysqld processes
!include include/default_mysqld.cnf
[mysqld.1.1]
loose_handlersocket_port= 20000
loose_handlersocket_port_wr= 20001
loose_handlersocket_threads= 2
loose_handlersocket_threads_wr= 1
loose_handlersocket_support_merge_table= 0
loose_handlersocket_direct_update_mode= 2
loose_handlersocket_unlimited_boundary= 65536
loose_handlersocket_bulk_insert= 0
loose_handlersocket_bulk_insert_timeout= 0
loose_handlersocket_general_log= 1
loose_handlersocket_timeout= 30
loose_handlersocket_close_table_interval=2
open_files_limit= 4096
loose_partition= 1
[mysqld.2.1]
loose_handlersocket_port= 20002
loose_handlersocket_port_wr= 20003
loose_handlersocket_threads= 2
loose_handlersocket_threads_wr= 1
loose_handlersocket_support_merge_table= 0
loose_handlersocket_direct_update_mode= 2
loose_handlersocket_unlimited_boundary= 65536
loose_handlersocket_bulk_insert= 0
loose_handlersocket_bulk_insert_timeout= 0
loose_handlersocket_general_log= 1
loose_handlersocket_timeout= 30
loose_handlersocket_close_table_interval=2
open_files_limit= 4096
[mysqld.2.2]
loose_handlersocket_port= 20004
loose_handlersocket_port_wr= 20005
loose_handlersocket_threads= 2
loose_handlersocket_threads_wr= 1
loose_handlersocket_support_merge_table= 0
loose_handlersocket_direct_update_mode= 2
loose_handlersocket_unlimited_boundary= 65536
loose_handlersocket_bulk_insert= 0
loose_handlersocket_bulk_insert_timeout= 0
loose_handlersocket_general_log= 1
loose_handlersocket_timeout= 30
loose_handlersocket_close_table_interval=2
open_files_limit= 4096
[mysqld.2.3]
[mysqld.3.1]
loose_partition= 1
[mysqld.3.2]
loose_partition= 1
[mysqld.3.3]
loose_partition= 1
[mysqld.4.1]
loose_partition= 1
[ENV]
USE_GEOMETRY_TEST= 1
USE_FULLTEXT_TEST= 1
USE_HA_TEST= 1
USE_GENERAL_LOG= 1
USE_REPLICATION= 1
MASTER_1_MYPORT= @mysqld.1.1.port
MASTER_1_HSRPORT= 20000
MASTER_1_HSWPORT= 20001
MASTER_1_MYSOCK= @mysqld.1.1.socket
MASTER_1_ENGINE_TYPE= Spider
#MASTER_1_ENGINE_TYPE= MyISAM
MASTER_1_ENGINE= ENGINE=Spider
MASTER_1_CHARSET= DEFAULT CHARSET=utf8
MASTER_1_ENGINE2= ENGINE=MyISAM
MASTER_1_CHARSET2= DEFAULT CHARSET=utf8
MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
SLAVE1_1_MYPORT= @mysqld.4.1.port
SLAVE1_1_MYSOCK= @mysqld.4.1.socket
SLAVE1_1_ENGINE_TYPE= MyISAM
SLAVE1_1_ENGINE= ENGINE=MyISAM
SLAVE1_1_CHARSET= DEFAULT CHARSET=utf8
USE_CHILD_GROUP2= 1
OUTPUT_CHILD_GROUP2= 0
CHILD2_1_MYPORT= @mysqld.2.1.port
CHILD2_1_HSRPORT= 20002
CHILD2_1_HSWPORT= 20003
CHILD2_1_MYSOCK= @mysqld.2.1.socket
CHILD2_1_ENGINE_TYPE= InnoDB
CHILD2_1_ENGINE= ENGINE=InnoDB
CHILD2_1_CHARSET= DEFAULT CHARSET=utf8
CHILD2_1_CHARSET2= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
CHILD2_2_MYPORT= @mysqld.2.2.port
CHILD2_2_HSRPORT= 20004
CHILD2_2_HSWPORT= 20005
CHILD2_2_MYSOCK= @mysqld.2.2.socket
CHILD2_2_ENGINE_TYPE= InnoDB
CHILD2_2_ENGINE= ENGINE=InnoDB
CHILD2_2_CHARSET= DEFAULT CHARSET=utf8
CHILD2_3_MYPORT= @mysqld.2.3.port
CHILD2_3_MYSOCK= @mysqld.2.3.socket
CHILD2_3_ENGINE_TYPE= InnoDB
CHILD2_3_ENGINE= ENGINE=InnoDB
CHILD2_3_CHARSET= DEFAULT CHARSET=utf8
CHILD2_1_FT_MYPORT= @mysqld.1.1.port
CHILD2_1_FT_MYSOCK= @mysqld.1.1.socket
CHILD2_1_FT_ENGINE_TYPE= MyISAM
CHILD2_1_FT_ENGINE= ENGINE=MyISAM
CHILD2_1_FT_CHARSET= DEFAULT CHARSET=utf8
CHILD2_2_FT_MYPORT= @mysqld.2.2.port
CHILD2_2_FT_MYSOCK= @mysqld.2.2.socket
CHILD2_2_FT_ENGINE_TYPE= MyISAM
CHILD2_2_FT_ENGINE= ENGINE=MyISAM
CHILD2_2_FT_CHARSET= DEFAULT CHARSET=utf8
CHILD2_1_GM_MYPORT= @mysqld.2.1.port
CHILD2_1_GM_MYSOCK= @mysqld.2.1.socket
CHILD2_1_GM_ENGINE_TYPE= MyISAM
CHILD2_1_GM_ENGINE= ENGINE=MyISAM
CHILD2_1_GM_CHARSET= DEFAULT CHARSET=utf8
CHILD2_2_GM_MYPORT= @mysqld.2.2.port
CHILD2_2_GM_MYSOCK= @mysqld.2.2.socket
CHILD2_2_GM_ENGINE_TYPE= MyISAM
CHILD2_2_GM_ENGINE= ENGINE=MyISAM
CHILD2_2_GM_CHARSET= DEFAULT CHARSET=utf8
USE_CHILD_GROUP3= 1
OUTPUT_CHILD_GROUP3= 0
CHILD3_1_MYPORT= @mysqld.3.1.port
CHILD3_1_MYSOCK= @mysqld.3.1.socket
CHILD3_1_ENGINE_TYPE= InnoDB
CHILD3_1_ENGINE= ENGINE=InnoDB
CHILD3_1_CHARSET= DEFAULT CHARSET=utf8
CHILD3_2_MYPORT= @mysqld.3.2.port
CHILD3_2_MYSOCK= @mysqld.3.2.socket
CHILD3_2_ENGINE_TYPE= InnoDB
CHILD3_2_ENGINE= ENGINE=InnoDB
CHILD3_2_CHARSET= DEFAULT CHARSET=utf8
CHILD3_3_MYPORT= @mysqld.3.3.port
CHILD3_3_MYSOCK= @mysqld.3.3.socket
CHILD3_3_ENGINE_TYPE= InnoDB
CHILD3_3_ENGINE= ENGINE=InnoDB
CHILD3_3_CHARSET= DEFAULT CHARSET=utf8
STR_SEMICOLON= ;
#The followings are setted in include/init_xxx.inc files
#MASTER_1_COMMENT_2_1
#MASTER_1_COMMENT2_2_1
#MASTER_1_COMMENT3_2_1
#MASTER_1_COMMENT4_2_1
#MASTER_1_COMMENT5_2_1
#MASTER_1_COMMENT_P_2_1
#CHILD2_1_DROP_TABLES
#CHILD2_1_CREATE_TABLES
#CHILD2_1_SELECT_TABLES
#CHILD2_1_DROP_TABLES2
#CHILD2_1_CREATE_TABLES2
#CHILD2_1_SELECT_TABLES2
#CHILD2_1_DROP_TABLES3
#CHILD2_1_CREATE_TABLES3
#CHILD2_1_SELECT_TABLES3
#CHILD2_1_DROP_TABLES4
#CHILD2_1_CREATE_TABLES4
#CHILD2_1_SELECT_TABLES4
#CHILD2_1_DROP_TABLES5
#CHILD2_1_CREATE_TABLES5
#CHILD2_1_SELECT_TABLES5
#CHILD2_1_DROP_TABLES6
#CHILD2_1_CREATE_TABLES6
#CHILD2_1_SELECT_TABLES6
#CHILD2_2_DROP_TABLES
#CHILD2_2_CREATE_TABLES
#CHILD2_2_SELECT_TABLES

View File

@ -0,0 +1,701 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
SELECT 1;
1
1
create table select test
DROP TABLE IF EXISTS tb_l;
CREATE TABLE tb_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE2 MASTER_1_CHARSET2
INSERT INTO tb_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
SELECT a, b, c FROM tb_l
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
create table ignore select test
DROP TABLE IF EXISTS ta_l;
DROP TABLE IF EXISTS tb_l;
CREATE TABLE tb_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE2 MASTER_1_CHARSET2
INSERT INTO tb_l (a, b, c) VALUES
(1, 'f', '2008-07-01 10:21:39'),
(2, 'g', '2000-02-01 00:00:00'),
(3, 'j', '2007-05-04 20:03:11'),
(4, 'i', '2003-10-30 05:01:03'),
(5, 'h', '2001-10-31 23:59:59');
CREATE TABLE ta_l (
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
IGNORE SELECT a, b, c FROM tb_l
Warnings:
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
Warning 1062 Duplicate entry '2' for key 'PRIMARY'
Warning 1062 Duplicate entry '3' for key 'PRIMARY'
Warning 1062 Duplicate entry '4' for key 'PRIMARY'
Warning 1062 Duplicate entry '5' for key 'PRIMARY'
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
create table ignore select test
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
REPLACE SELECT a, b, c FROM tb_l
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
create table with partition and select test
CREATE TABLE ta_l2 (
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1
SELECT a, b, c FROM tb_l
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
create no index table
DROP TABLE IF EXISTS ta_l_no_idx;
CREATE TABLE ta_l_no_idx
MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1
SELECT a, b, c FROM tb_l
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select table
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select table shared mode
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a
LOCK IN SHARE MODE;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select table for update
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a
FOR UPDATE;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select table join
SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b
WHERE a.a = b.a ORDER BY a.a;
a b date_format(b.c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select table straight_join
SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s')
FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a;
a b date_format(b.c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select sql_small_result
SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select sql_big_result
SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select sql_buffer_result
SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select sql_cache
SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select sql_no_cache
SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select sql_calc_found_rows
SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
ORDER BY a LIMIT 4;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
SELECT found_rows();
found_rows()
5
select high_priority
SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select distinct
SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select count
SELECT count(*) FROM ta_l ORDER BY a;
count(*)
5
select table join not use index
SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE
EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a;
a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
select using pushdown
SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE
a.b = 'g' ORDER BY a.a;
a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
2 g 2000-02-01 00:00:00
select using index and pushdown
SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE
a.a > 0 AND a.b = 'g' ORDER BY a.a;
a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
2 g 2000-02-01 00:00:00
select partition using pushdown
SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
a.b = 'g' ORDER BY a.a;
a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
2 g 2000-02-01 00:00:00
select partition using index pushdown
SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
a.a > 0 AND a.b = 'g' ORDER BY a.a;
a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
2 g 2000-02-01 00:00:00
insert
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
2 e 2008-01-01 23:59:59
insert select
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
insert select a
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1),
'e', '2008-01-01 23:59:59');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 e 2008-01-01 23:59:59
insert low_priority
TRUNCATE TABLE ta_l;
INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
2 e 2008-01-01 23:59:59
insert high_priority
TRUNCATE TABLE ta_l;
INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e',
'2008-01-01 23:59:59');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
2 e 2008-01-01 23:59:59
insert ignore
INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01');
Warnings:
Warning 1062 Duplicate entry '2' for key 'PRIMARY'
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
2 e 2008-01-01 23:59:59
insert update (insert)
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE
KEY UPDATE b = 'f', c = '2005-08-08 11:11:11';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
2 e 2008-01-01 23:59:59
insert update (update)
INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE
KEY UPDATE b = 'f', c = '2005-08-08 11:11:11';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
2 f 2005-08-08 11:11:11
replace
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59');
REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
2 f 2008-02-02 02:02:02
replace select
REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
replace select a
REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1),
'e', '2008-01-01 23:59:59');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 e 2008-01-01 23:59:59
2 g 2000-02-01 00:00:00
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
replace low_priority
REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g',
'2009-03-03 03:03:03');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 e 2008-01-01 23:59:59
2 g 2000-02-01 00:00:00
3 g 2009-03-03 03:03:03
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
update
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
(2, 'e', '2008-01-01 23:59:59');
UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 e 2008-01-01 23:59:59
2 f 2008-02-02 02:02:02
update select
UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM
tb_l);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 g 2009-03-03 03:03:03
2 g 2009-03-03 03:03:03
update select a
UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM
tb_l ORDER BY a LIMIT 1);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 h 2010-04-04 04:04:04
2 g 2009-03-03 03:03:03
update join
UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
update join a
UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE
a.a = b.a;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 g 2009-03-03 03:03:03
2 g 2009-03-03 03:03:03
update low_priority
UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 g 2009-03-03 03:03:03
2 f 2008-02-02 02:02:02
update ignore
UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 g 2009-03-03 03:03:03
2 f 2008-02-02 02:02:02
update pushdown
update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 g 2009-03-03 03:03:03
2 j 2009-03-03 03:03:03
update index pushdown
UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 g 2009-03-03 03:03:03
2 g 2009-03-03 03:03:03
update partition pushdown
UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 e 2009-03-03 03:03:03
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
update partition index pushdown
UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
2 g 2000-02-01 00:00:00
3 j 2009-03-03 03:03:03
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
delete
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
(10, 'j', '2008-01-01 23:59:59');
DELETE FROM ta_l WHERE a = 2;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 e 2008-01-01 23:59:59
3 e 2008-01-01 23:59:59
4 e 2008-01-01 23:59:59
5 e 2008-01-01 23:59:59
6 e 2008-01-01 23:59:59
7 e 2008-01-01 23:59:59
8 e 2008-01-01 23:59:59
9 e 2008-01-01 23:59:59
10 j 2008-01-01 23:59:59
delete all
DELETE FROM ta_l;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
delete select
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
(10, 'j', '2008-01-01 23:59:59');
DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
6 e 2008-01-01 23:59:59
7 e 2008-01-01 23:59:59
8 e 2008-01-01 23:59:59
9 e 2008-01-01 23:59:59
10 j 2008-01-01 23:59:59
delete select a
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
(10, 'j', '2008-01-01 23:59:59');
DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
2 e 2008-01-01 23:59:59
3 e 2008-01-01 23:59:59
4 e 2008-01-01 23:59:59
5 e 2008-01-01 23:59:59
6 e 2008-01-01 23:59:59
7 e 2008-01-01 23:59:59
8 e 2008-01-01 23:59:59
9 e 2008-01-01 23:59:59
10 j 2008-01-01 23:59:59
delete join
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
(10, 'j', '2008-01-01 23:59:59');
DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
6 e 2008-01-01 23:59:59
7 e 2008-01-01 23:59:59
8 e 2008-01-01 23:59:59
9 e 2008-01-01 23:59:59
10 j 2008-01-01 23:59:59
delete low_priority
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
(10, 'j', '2008-01-01 23:59:59');
DELETE LOW_PRIORITY FROM ta_l WHERE a = 2;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 e 2008-01-01 23:59:59
3 e 2008-01-01 23:59:59
4 e 2008-01-01 23:59:59
5 e 2008-01-01 23:59:59
6 e 2008-01-01 23:59:59
7 e 2008-01-01 23:59:59
8 e 2008-01-01 23:59:59
9 e 2008-01-01 23:59:59
10 j 2008-01-01 23:59:59
delete ignore
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
(10, 'j', '2008-01-01 23:59:59');
DELETE IGNORE FROM ta_l WHERE a = 2;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 e 2008-01-01 23:59:59
3 e 2008-01-01 23:59:59
4 e 2008-01-01 23:59:59
5 e 2008-01-01 23:59:59
6 e 2008-01-01 23:59:59
7 e 2008-01-01 23:59:59
8 e 2008-01-01 23:59:59
9 e 2008-01-01 23:59:59
10 j 2008-01-01 23:59:59
delete quick
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
(10, 'j', '2008-01-01 23:59:59');
DELETE QUICK FROM ta_l WHERE a = 2;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 e 2008-01-01 23:59:59
3 e 2008-01-01 23:59:59
4 e 2008-01-01 23:59:59
5 e 2008-01-01 23:59:59
6 e 2008-01-01 23:59:59
7 e 2008-01-01 23:59:59
8 e 2008-01-01 23:59:59
9 e 2008-01-01 23:59:59
10 j 2008-01-01 23:59:59
delete pushdown
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
(10, 'j', '2008-01-01 23:59:59');
DELETE FROM ta_l WHERE b = 'e';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
10 j 2008-01-01 23:59:59
delete index pushdown
TRUNCATE TABLE ta_l;
INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
(10, 'j', '2008-01-01 23:59:59');
DELETE FROM ta_l WHERE a > 0 AND b = 'e';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
10 j 2008-01-01 23:59:59
delete partition pushdown
TRUNCATE TABLE ta_l2;
INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
DELETE FROM ta_l2 WHERE b = 'g';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
delete partition index pushdown
TRUNCATE TABLE ta_l2;
INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
DELETE FROM ta_l2 WHERE a > 0 AND b = 'g';
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 f 2008-07-01 10:21:39
3 j 2007-05-04 20:03:11
4 i 2003-10-30 05:01:03
5 h 2001-10-31 23:59:59
truncate
TRUNCATE TABLE ta_l;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
deinit
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test

View File

@ -0,0 +1,132 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
SELECT 1;
1
1
create table select test
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
INSERT INTO ta_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
direct_aggregating test
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 0
SELECT COUNT(*) FROM ta_l;
COUNT(*)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 1
SELECT MAX(a) FROM ta_l;
MAX(a)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 1
SELECT MIN(a) FROM ta_l;
MIN(a)
1
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 1
SELECT MAX(a) FROM ta_l WHERE a < 5;
MAX(a)
4
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 1
SELECT MIN(a) FROM ta_l WHERE a > 1;
MIN(a)
2
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 1
with partition test
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 1
SELECT COUNT(*) FROM ta_l2;
COUNT(*)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 3
SELECT MAX(a) FROM ta_l2;
MAX(a)
5
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 3
SELECT MIN(a) FROM ta_l2;
MIN(a)
1
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 3
SELECT MAX(a) FROM ta_l2 WHERE a < 5;
MAX(a)
4
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 3
SELECT MIN(a) FROM ta_l2 WHERE a > 1;
MIN(a)
2
SHOW STATUS LIKE 'Spider_direct_aggregate';
Variable_name Value
Spider_direct_aggregate 3
deinit
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test

View File

@ -0,0 +1,226 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
SELECT 1;
1
1
create table select test
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
INSERT INTO ta_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
direct_updating test
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
update all rows with function
UPDATE ta_l SET c = ADDDATE(c, 1);
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 e 2007-06-05 20:03:11
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by primary key
UPDATE ta_l SET b = 'x' WHERE a = 3;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2007-06-05 20:03:11
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by a column without index
UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x';
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2011-10-17 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by primary key with order and limit
UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
delete by primary key with order and limit
DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1;
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
delete by a column without index
DELETE FROM ta_l WHERE b = 'c';
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
delete by primary key
DELETE FROM ta_l WHERE a = 3;
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
4 d 2003-12-01 05:01:03
with partition test
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
update all rows with function
UPDATE ta_l2 SET c = ADDDATE(c, 1);
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 e 2007-06-05 20:03:11
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by primary key
UPDATE ta_l2 SET b = 'x' WHERE a = 3;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2007-06-05 20:03:11
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by a column without index
UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x';
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2011-10-17 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
update by primary key with order and limit
UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
SHOW STATUS LIKE 'Spider_direct_update';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
2 b 2000-01-02 00:00:00
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
delete by primary key with order and limit
DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1;
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
5 c 2002-01-01 23:59:59
delete by a column without index
DELETE FROM ta_l2 WHERE b = 'c';
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
3 x 2011-10-18 00:00:00
4 d 2003-12-01 05:01:03
delete by primary key
DELETE FROM ta_l2 WHERE a = 3;
SHOW STATUS LIKE 'Spider_direct_delete';
Variable_name Value
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-02 10:21:39
4 d 2003-12-01 05:01:03
deinit
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test

View File

@ -0,0 +1,149 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
SELECT 1;
1
1
in()
CREATE TABLE t1 (
a VARCHAR(255),
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1
insert into t1 values ('1');
insert into t1 select a + 1 from t1;
insert into t1 select a + 2 from t1;
insert into t1 select a + 4 from t1;
insert into t1 select a + 8 from t1;
insert into t1 select a + 16 from t1;
insert into t1 select a + 32 from t1;
insert into t1 select a + 64 from t1;
insert into t1 select a + 128 from t1;
insert into t1 select a + 256 from t1;
insert into t1 select a + 512 from t1;
flush tables;
select a from t1 where a in ('15', '120');
a
120
15
date_sub()
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
INSERT INTO ta_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2007-08-01 10:21:39
2 b 1999-01-01 00:00:00
3 e 2006-06-04 20:03:11
4 d 2002-11-30 05:01:03
5 c 2000-12-31 23:59:59
UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2007-11-01 10:21:39
2 b 1999-04-01 00:00:00
3 e 2006-09-04 20:03:11
4 d 2003-02-28 05:01:03
5 c 2001-03-31 23:59:59
UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2007-10-01 10:21:39
2 b 1999-03-01 00:00:00
3 e 2006-08-04 20:03:11
4 d 2003-01-28 05:01:03
5 c 2001-02-28 23:59:59
UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2007-10-08 10:21:39
2 b 1999-03-08 00:00:00
3 e 2006-08-11 20:03:11
4 d 2003-02-04 05:01:03
5 c 2001-03-07 23:59:59
UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2007-10-07 10:21:39
2 b 1999-03-07 00:00:00
3 e 2006-08-10 20:03:11
4 d 2003-02-03 05:01:03
5 c 2001-03-06 23:59:59
UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2007-10-07 11:21:39
2 b 1999-03-07 01:00:00
3 e 2006-08-10 21:03:11
4 d 2003-02-03 06:01:03
5 c 2001-03-07 00:59:59
UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2007-10-07 11:20:39
2 b 1999-03-07 00:59:00
3 e 2006-08-10 21:02:11
4 d 2003-02-03 06:00:03
5 c 2001-03-07 00:58:59
UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2007-10-07 11:20:40
2 b 1999-03-07 00:59:01
3 e 2006-08-10 21:02:12
4 d 2003-02-03 06:00:04
5 c 2001-03-07 00:59:00
deinit
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test

View File

@ -0,0 +1,431 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
DROP DATABASE IF EXISTS auto_test_remote3;
CREATE DATABASE auto_test_remote3;
USE auto_test_remote3;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
test select 1
SELECT 1;
1
1
create table test
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1
INSERT INTO ta_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
select test
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
fail-over test
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 0
Spider_mon_table_cache_version_req 1
INSERT INTO ta_l (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
ERROR HY000: Table 'auto_test_remote2.ta_r3' get a problem
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l 0 1
auto_test_local ta_l 1 3
SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
db_name table_name link_id
auto_test_local ta_l 1
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 1
Spider_mon_table_cache_version_req 1
INSERT INTO ta_l (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
6 e 2011-05-05 20:04:05
recovery test
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "5", mkd "2",
database "auto_test_remote auto_test_remote2", lst "0 2"';
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l 0 1
auto_test_local ta_l 1 2
SELECT spider_copy_tables('ta_l', '0', '1');
spider_copy_tables('ta_l', '0', '1')
1
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "5", mkd "2",
database "auto_test_remote auto_test_remote2", lst "0 1"';
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l 0 1
auto_test_local ta_l 1 1
INSERT INTO ta_l (a, b, c) VALUES
(8, 'g', '2011-05-05 21:33:30');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
6 e 2011-05-05 20:04:05
8 g 2011-05-05 21:33:30
DROP TABLE ta_l;
SELECT spider_flush_table_mon_cache();
spider_flush_table_mon_cache()
1
create table with partition test
DROP TABLE IF EXISTS ta_l2;
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1
INSERT INTO ta_l2 (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
select test
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
fail-over test
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 1
Spider_mon_table_cache_version_req 2
INSERT INTO ta_l2 (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
ERROR HY000: Table 'auto_test_remote3.ta_r4' get a problem
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l2#P#pt1 0 1
auto_test_local ta_l2#P#pt1 1 1
auto_test_local ta_l2#P#pt2 0 1
auto_test_local ta_l2#P#pt2 1 3
SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
db_name table_name link_id
auto_test_local ta_l 1
auto_test_local ta_l2#P#pt2 1
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 2
Spider_mon_table_cache_version_req 2
INSERT INTO ta_l2 (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
6 e 2011-05-05 20:04:05
recovery test
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 2"'
);
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l2#P#pt1 0 1
auto_test_local ta_l2#P#pt1 1 1
auto_test_local ta_l2#P#pt2 0 1
auto_test_local ta_l2#P#pt2 1 2
SELECT spider_copy_tables('ta_l2#P#pt2', '0', '1');
spider_copy_tables('ta_l2#P#pt2', '0', '1')
1
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "0 1"'
);
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l2#P#pt1 0 1
auto_test_local ta_l2#P#pt1 1 1
auto_test_local ta_l2#P#pt2 0 1
auto_test_local ta_l2#P#pt2 1 1
INSERT INTO ta_l2 (a, b, c) VALUES
(8, 'g', '2011-05-05 21:33:30'),
(9, 'h', '2011-05-05 22:32:10');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
6 e 2011-05-05 20:04:05
8 g 2011-05-05 21:33:30
9 h 2011-05-05 22:32:10
DROP TABLE ta_l2;
active standby test
create table test
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1
INSERT INTO ta_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
select test
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
fail-over test
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 2
Spider_mon_table_cache_version_req 2
INSERT INTO ta_l (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
ERROR HY000: Table 'auto_test_remote.ta_r' get a problem
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l 0 3
auto_test_local ta_l 1 1
SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
db_name table_name link_id
auto_test_local ta_l 1
auto_test_local ta_l2#P#pt2 1
auto_test_local ta_l 0
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 2
Spider_mon_table_cache_version_req 2
INSERT INTO ta_l (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
6 e 2011-05-05 20:04:05
recovery test
ALTER TABLE ta_l
CONNECTION='host "localhost", user "root", password "",
msi "5", mkd "2", alc "1",
database "auto_test_remote auto_test_remote2", lst "1 0"';
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l 0 1
auto_test_local ta_l 1 1
INSERT INTO ta_l (a, b, c) VALUES
(8, 'g', '2011-05-05 21:33:30');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
8 g 2011-05-05 21:33:30
DROP TABLE ta_l;
SELECT spider_flush_table_mon_cache();
spider_flush_table_mon_cache()
1
create table with partition test
DROP TABLE IF EXISTS ta_l2;
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1
INSERT INTO ta_l2 (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
select test
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
fail-over test
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 2
Spider_mon_table_cache_version_req 3
INSERT INTO ta_l2 (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
ERROR HY000: Table 'auto_test_remote.ta_r2' get a problem
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l2#P#pt1 0 1
auto_test_local ta_l2#P#pt1 1 1
auto_test_local ta_l2#P#pt2 0 3
auto_test_local ta_l2#P#pt2 1 1
SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
db_name table_name link_id
auto_test_local ta_l 1
auto_test_local ta_l2#P#pt2 1
auto_test_local ta_l 0
auto_test_local ta_l2#P#pt2 0
SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
Variable_name Value
Spider_mon_table_cache_version 3
Spider_mon_table_cache_version_req 3
INSERT INTO ta_l2 (a, b, c) VALUES
(6, 'e', '2011-05-05 20:04:05');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
3 e 2007-06-04 20:03:11
5 c 2001-12-31 23:59:59
6 e 2011-05-05 20:04:05
recovery test
ALTER TABLE ta_l2
PARTITION BY KEY(a) (
PARTITION pt1 COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3",
priority "1000"',
PARTITION pt2 COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4",
priority "1000001", lst "1 0"'
);
SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
ORDER BY db_name, table_name, link_id;
db_name table_name link_id link_status
auto_test_local ta_l2#P#pt1 0 1
auto_test_local ta_l2#P#pt1 1 1
auto_test_local ta_l2#P#pt2 0 1
auto_test_local ta_l2#P#pt2 1 1
INSERT INTO ta_l2 (a, b, c) VALUES
(8, 'g', '2011-05-05 21:33:30'),
(9, 'h', '2011-05-05 22:32:10');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
3 e 2007-06-04 20:03:11
5 c 2001-12-31 23:59:59
8 g 2011-05-05 21:33:30
9 h 2011-05-05 22:32:10
DROP TABLE ta_l2;
deinit
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
DROP DATABASE IF EXISTS auto_test_remote3;
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_local;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test

View File

@ -0,0 +1,371 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
for slave1_1
drop and create databases
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
SELECT 1;
1
1
3.1
auto_increment
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1
MASTER_1_AUTO_INCREMENT_INCREMENT2
MASTER_1_AUTO_INCREMENT_OFFSET2
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_1"')
1
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_2"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
'srv "s_2_1"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
'srv "s_2_2"')
1
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
777
SELECT MAX(id) FROM t1;
MAX(id)
777
INSERT INTO t2 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1554
SELECT MAX(id) FROM t2;
MAX(id)
1554
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
778
SELECT MAX(id) FROM t1;
MAX(id)
1554
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
2331
SELECT MAX(id) FROM t2;
MAX(id)
2331
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1555
SELECT id FROM t1 ORDER BY id;
id
777
778
1554
1555
2331
2332
3109
3886
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3108
SELECT id FROM t2 ORDER BY id;
id
777
778
1554
1555
2331
2332
3108
3109
3885
3886
4662
5439
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
INSERT INTO t1 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
777
SELECT id FROM t1 ORDER BY id;
id
777
1554
2331
3108
INSERT INTO t2 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3885
SELECT id FROM t2 ORDER BY id;
id
777
1554
2331
3108
3885
4662
5439
6216
SET INSERT_ID=5000;
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5000
SELECT MAX(id) FROM t1;
MAX(id)
6216
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
6993
SELECT MAX(id) FROM t2;
MAX(id)
6993
INSERT INTO t1 (id) VALUES (10000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
6993
SELECT MAX(id) FROM t1;
MAX(id)
10000
INSERT INTO t2 (id) VALUES (1000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
6993
SELECT MAX(id) FROM t2;
MAX(id)
10000
SELECT id FROM t1 ORDER BY id;
id
777
1554
2331
3108
5000
10000
auto_increment with partition
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
MASTER_1_AUTO_INCREMENT_INCREMENT2
MASTER_1_AUTO_INCREMENT_OFFSET2
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_1"')
1
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_2"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
'srv "s_2_1"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
'srv "s_2_2"')
1
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
777
SELECT MAX(id) FROM t1;
MAX(id)
777
INSERT INTO t2 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1554
SELECT MAX(id) FROM t2;
MAX(id)
1554
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
778
SELECT MAX(id) FROM t1;
MAX(id)
1554
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
2331
SELECT MAX(id) FROM t2;
MAX(id)
2331
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1555
SELECT id FROM t1 ORDER BY id;
id
777
778
1554
1555
2331
2332
3109
3886
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3108
SELECT id FROM t2 ORDER BY id;
id
777
778
1554
1555
2331
2332
3108
3109
3885
3886
4662
5439
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
INSERT INTO t1 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
777
SELECT id FROM t1 ORDER BY id;
id
777
1554
2331
3108
INSERT INTO t2 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3885
SELECT id FROM t2 ORDER BY id;
id
777
1554
2331
3108
3885
4662
5439
6216
SET INSERT_ID=5000;
MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5000
SELECT MAX(id) FROM t1;
MAX(id)
6216
MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
6993
SELECT MAX(id) FROM t2;
MAX(id)
6993
INSERT INTO t1 (id) VALUES (10000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
6993
SELECT MAX(id) FROM t1;
MAX(id)
10000
INSERT INTO t2 (id) VALUES (1000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
6993
SELECT MAX(id) FROM t2;
MAX(id)
10000
SELECT id FROM t1 ORDER BY id;
id
777
1554
2331
3108
5000
10000
deinit
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
for slave1_1
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test

View File

@ -0,0 +1,692 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
for slave1_1
drop and create databases
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
SELECT 1;
1
1
create table and insert
DROP TABLE IF EXISTS tb_l;
CREATE TABLE tb_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE2 MASTER_1_CHARSET2
INSERT INTO tb_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
INSERT INTO ta_l SELECT a, b, c FROM tb_l;
2.13
select table with "order by desc" and "<"
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
WHERE a < 5 ORDER BY a DESC LIMIT 3;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
4 d 2003-11-30 05:01:03
3 e 2007-06-04 20:03:11
2 b 2000-01-01 00:00:00
select table with "order by desc" and "<="
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
WHERE a <= 5 ORDER BY a DESC LIMIT 3;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
5 c 2001-12-31 23:59:59
4 d 2003-11-30 05:01:03
3 e 2007-06-04 20:03:11
2.14
update table with range scan and split_read
UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-02-02 00:00:00
3 e 2000-02-02 00:00:00
4 d 2000-02-02 00:00:00
5 c 2000-02-02 00:00:00
2.15
select table with range scan
TRUNCATE TABLE ta_l;
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
a int(11) NOT NULL DEFAULT '0',
b char(1) DEFAULT NULL,
c datetime DEFAULT NULL,
PRIMARY KEY (a, b, c)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1
INSERT INTO ta_l SELECT a, b, c FROM tb_l;
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b'
AND c = '2003-11-30 05:01:03';
a b c
4 d 2003-11-30 05:01:03
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b'
AND c = '2003-11-30 05:01:03';
a b c
4 d 2003-11-30 05:01:03
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd'
AND c = '2003-11-30 05:01:03';
a b c
4 d 2003-11-30 05:01:03
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c'
AND c = '2001-12-31 23:59:59';
a b c
5 c 2001-12-31 23:59:59
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd'
AND c = '2003-11-30 05:01:03';
a b c
4 d 2003-11-30 05:01:03
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e'
AND c = '2003-11-30 05:01:03';
a b c
4 d 2003-11-30 05:01:03
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b'
AND c = '2000-01-01 00:00:00';
a b c
2 b 2000-01-01 00:00:00
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b'
AND c = '2000-01-01 00:00:00';
a b c
2 b 2000-01-01 00:00:00
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b'
AND b <= 'd' AND c = '2003-11-30 05:01:03';
a b c
4 d 2003-11-30 05:01:03
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b'
AND b < 'e' AND c = '2003-11-30 05:01:03';
a b c
4 d 2003-11-30 05:01:03
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1
AND b >= 'b' AND c = '2003-11-30 05:01:03';
a b c
4 d 2003-11-30 05:01:03
SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1
AND b >= 'b' AND c = '2000-01-01 00:00:00';
a b c
2 b 2000-01-01 00:00:00
2.16
auto_increment insert with trigger
CREATE TABLE ta_l_auto_inc (
a INT AUTO_INCREMENT,
b CHAR(1) DEFAULT 'c',
c DATETIME DEFAULT '1999-10-10 10:10:10',
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1
CREATE TABLE tc_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE2 MASTER_1_CHARSET2
CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END;;
INSERT INTO ta_l_auto_inc (a, b, c) VALUES
(NULL, 's', '2008-12-31 20:59:59');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 s 2008-12-31 20:59:59
2.17
engine-condition-pushdown with "or" and joining
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l);
a b date_format(c, '%Y-%m-%d %H:%i:%s')
1 a 2008-08-01 10:21:39
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
partition with sort
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1
ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
2 b 2000-01-01 00:00:00
3 e 2007-06-04 20:03:11
4 d 2003-11-30 05:01:03
5 c 2001-12-31 23:59:59
2.23
partition update with moving partition
DROP TABLE IF EXISTS ta_l2;
CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00');
UPDATE ta_l2 SET a = 4 WHERE a = 3;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
4 B 2010-09-26 00:00:00
index merge
CREATE TABLE ta_l_int (
a INT AUTO_INCREMENT,
b INT DEFAULT 10,
c INT DEFAULT 11,
PRIMARY KEY(a),
KEY idx1(b),
KEY idx2(c)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3);
INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2)
WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
a b c
3 4 5
4 5 6
5 6 7
index merge with partition
DROP TABLE IF EXISTS ta_l_int;
CREATE TABLE ta_l_int (
a INT AUTO_INCREMENT,
b INT DEFAULT 10,
c INT DEFAULT 11,
PRIMARY KEY(a),
KEY idx1(b),
KEY idx2(c)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_P_2_1
INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3);
INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2)
WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
a b c
3 4 5
4 5 6
5 6 7
2.24
index scan update without PK
DROP TABLE IF EXISTS ta_l_int;
CREATE TABLE ta_l_int (
a INT NOT NULL,
b INT DEFAULT 10,
c INT DEFAULT 11,
KEY idx1(b),
KEY idx2(c)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
SELECT a, b, c FROM ta_l_int ORDER BY a;
a b c
2 3 4
4 5 6
6 7 8
8 9 10
10 11 12
12 13 14
14 15 16
16 17 18
INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3);
INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3);
UPDATE ta_l_int SET c = 4 WHERE b = 2;
SELECT a, b, c FROM ta_l_int ORDER BY a;
a b c
1 2 4
2 3 4
4 5 6
6 7 8
8 9 10
10 11 12
12 13 14
14 15 16
16 17 18
17 2 4
2.25
direct order limit
SHOW STATUS LIKE 'Spider_direct_order_limit';
Variable_name Value
Spider_direct_order_limit 0
SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3;
a b c
1 2 4
2 3 4
4 5 6
SHOW STATUS LIKE 'Spider_direct_order_limit';
Variable_name Value
Spider_direct_order_limit 0
2.26
lock tables
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1 (
id int(11) NOT NULL,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1
CREATE TABLE t2 (
id int(11) NOT NULL,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2
LOCK TABLES t1 READ, t2 READ;
UNLOCK TABLES;
auto_increment
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1
MASTER_1_AUTO_INCREMENT_INCREMENT2
MASTER_1_AUTO_INCREMENT_OFFSET2
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_1"')
1
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_2"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
'srv "s_2_1"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
'srv "s_2_2"')
1
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
777
SELECT MAX(id) FROM t1;
MAX(id)
777
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1554
SELECT MAX(id) FROM t1;
MAX(id)
1554
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
2331
SELECT MAX(id) FROM t1;
MAX(id)
2331
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3108
SELECT MAX(id) FROM t1;
MAX(id)
3108
INSERT INTO t1 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3885
SELECT id FROM t1 ORDER BY id;
id
777
1554
2331
3108
3885
4662
5439
6216
SET INSERT_ID=5000;
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5000
SELECT MAX(id) FROM t1;
MAX(id)
6216
INSERT INTO t1 (id) VALUES (10000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5000
SELECT MAX(id) FROM t1;
MAX(id)
10000
INSERT INTO t1 (id) VALUES (1000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5000
SELECT MAX(id) FROM t1;
MAX(id)
10000
SELECT id FROM t1 ORDER BY id;
id
777
1000
1554
2331
3108
3885
4662
5000
5439
6216
10000
auto_increment with partition
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
MASTER_1_AUTO_INCREMENT_INCREMENT2
MASTER_1_AUTO_INCREMENT_OFFSET2
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_1"')
1
spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
'srv "s_2_2"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
'srv "s_2_1"')
1
spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
'srv "s_2_2"')
1
CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
777
SELECT MAX(id) FROM t1;
MAX(id)
777
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
1554
SELECT MAX(id) FROM t1;
MAX(id)
1554
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
2331
SELECT MAX(id) FROM t1;
MAX(id)
2331
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3108
SELECT MAX(id) FROM t1;
MAX(id)
3108
INSERT INTO t1 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
3885
SELECT id FROM t1 ORDER BY id;
id
777
1554
2331
3108
3885
4662
5439
6216
SET INSERT_ID=5000;
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5000
SELECT MAX(id) FROM t1;
MAX(id)
6216
INSERT INTO t1 (id) VALUES (10000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5000
SELECT MAX(id) FROM t1;
MAX(id)
10000
INSERT INTO t1 (id) VALUES (1000);
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
5000
SELECT MAX(id) FROM t1;
MAX(id)
10000
SELECT id FROM t1 ORDER BY id;
id
777
1000
1554
2331
3108
3885
4662
5000
5439
6216
10000
read only
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id int(11) NOT NULL,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1
SELECT id FROM t1 ORDER BY id;
id
1000
1554
3108
4662
5000
6216
10000
INSERT INTO t1 (id) VALUES (1);
ERROR HY000: Table 'auto_test_local.t1' is read only
UPDATE t1 SET id = 4 WHERE id = 1000;
ERROR HY000: Table 'auto_test_local.t1' is read only
DELETE FROM t1 WHERE id = 1000;
ERROR HY000: Table 'auto_test_local.t1' is read only
DELETE FROM t1;
ERROR HY000: Table 'auto_test_local.t1' is read only
TRUNCATE t1;
ERROR HY000: Table 'auto_test_local.t1' is read only
2.27
error mode
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id int(11) NOT NULL,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1
SELECT id FROM t1 ORDER BY id;
id
Warnings:
Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist
Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist
INSERT INTO t1 (id) VALUES (1);
Warnings:
Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist
DELETE FROM t1;
Warnings:
Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist
TRUNCATE t1;
Warnings:
Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist
3.0
is null
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a VARCHAR(255),
b VARCHAR(255),
c VARCHAR(255),
KEY idx1(a,b),
KEY idx2(b),
PRIMARY KEY(c)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1
insert into t1 values (null, null, '2048');
insert into t1 values ('1', '1', '1');
insert into t1 select a + 1, b + 1, c + 1 from t1;
insert into t1 select a + 2, b + 2, c + 2 from t1;
insert into t1 select a + 4, b + 4, c + 4 from t1;
insert into t1 select a + 8, b + 8, c + 8 from t1;
insert into t1 select a + 16, b + 16, c + 16 from t1;
insert into t1 select a + 32, b + 32, c + 32 from t1;
insert into t1 select a + 64, b + 64, c + 64 from t1;
insert into t1 select a + 128, b + 128, c + 128 from t1;
insert into t1 select a + 256, b + 256, c + 256 from t1;
insert into t1 select a + 512, b + 512, c + 512 from t1;
flush tables;
select a from t1 where a is null order by a limit 30;
a
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
select b from t1 where b is null order by b limit 30;
b
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
direct_order_limit
TRUNCATE TABLE t1;
insert into t1 values ('1', '1', '1');
insert into t1 select a + 1, b + 1, c + 1 from t1;
insert into t1 select a + 2, b + 2, c + 2 from t1;
insert into t1 select a + 4, b + 4, c + 4 from t1;
insert into t1 select a + 8, b + 8, c + 8 from t1;
insert into t1 select a + 16, b + 16, c + 16 from t1;
insert into t1 select a, b + 32, c + 32 from t1;
insert into t1 select a, b + 64, c + 64 from t1;
insert into t1 select a, b + 128, c + 128 from t1;
flush tables;
select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5;
a b c
10 74 74
10 42 42
10 234 234
10 202 202
10 170 170
select a, c from t1 where a = '10' order by b desc limit 5;
a c
10 74
10 42
10 234
10 202
10 170
deinit
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
for slave1_1
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test

View File

@ -0,0 +1,80 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
test select 1
SELECT 1;
1
1
create table and insert
DROP TABLE IF EXISTS tb_l;
CREATE TABLE tb_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE2 MASTER_1_CHARSET2
INSERT INTO tb_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
DROP TABLE IF EXISTS ta_l;
CREATE TABLE ta_l (
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
INSERT INTO ta_l SELECT a, b, c FROM tb_l;
0.9
create different primary key table
CREATE TABLE ta_l_int (
a INT DEFAULT 10,
b INT AUTO_INCREMENT,
c INT DEFAULT 11,
PRIMARY KEY(b)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
create un-correspond primary key table
DROP TABLE IF EXISTS ta_l_int;
CREATE TABLE ta_l_int (
a INT DEFAULT 10,
b INT DEFAULT 12,
c INT DEFAULT 11,
PRIMARY KEY(c)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
deinit
DROP DATABASE IF EXISTS auto_test_local;
DROP DATABASE IF EXISTS auto_test_remote;
DROP DATABASE IF EXISTS auto_test_remote2;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test

View File

@ -0,0 +1 @@
--loose-innodb

View File

@ -0,0 +1,9 @@
package My::Suite::Spider;
@ISA = qw(My::Suite);
return "No Spider engine" unless $ENV{HA_SPIDER_SO};
return "Not run for embedded server" if $::opt_embedded_server;
bless { };

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
--connect (child2_1, localhost, root, , , $CHILD2_1_MYPORT, $CHILD2_1_MYSOCK)

View File

@ -0,0 +1 @@
--connect (child2_2, localhost, root, , , $CHILD2_2_MYPORT, $CHILD2_2_MYSOCK)

View File

@ -0,0 +1 @@
--connect (child2_3, localhost, root, , , $CHILD2_3_MYPORT, $CHILD2_3_MYSOCK)

View File

@ -0,0 +1 @@
--connect (child3_1, localhost, root, , , $CHILD3_1_MYPORT, $CHILD3_1_MYSOCK)

View File

@ -0,0 +1 @@
--connect (child3_2, localhost, root, , , $CHILD3_2_MYPORT, $CHILD3_2_MYSOCK)

View File

@ -0,0 +1 @@
--connect (child3_3, localhost, root, , , $CHILD3_3_MYPORT, $CHILD3_3_MYSOCK)

View File

@ -0,0 +1 @@
--connect (master_1, localhost, root, , , $MASTER_1_MYPORT, $MASTER_1_MYSOCK)

View File

@ -0,0 +1 @@
--connect (slave1_1, localhost, root, , , $SLAVE1_1_MYPORT, $SLAVE1_1_MYSOCK)

View File

@ -0,0 +1,316 @@
--let $SKIP_REASON=
--disable_warnings
--disable_query_log
--disable_result_log
--source test_init.inc
--enable_result_log
--enable_query_log
--echo
--echo drop and create databases
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
}
--enable_warnings
if ($SKIP_REASON)
{
--echo deinit
--disable_warnings
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
}
--disable_query_log
--disable_result_log
--source test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--skip $SKIP_REASON
}
--echo
--echo test select 1
--connection master_1
SELECT 1;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
SELECT 1;
--connection child2_2
SELECT 1;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo create table select test
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_1_DROP_TABLES;
echo CHILD2_1_CREATE_TABLES;
}
--disable_warnings
eval $CHILD2_1_DROP_TABLES;
--enable_warnings
eval $CHILD2_1_CREATE_TABLES;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
}
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
--disable_warnings
DROP TABLE IF EXISTS ta_l;
--enable_warnings
--disable_query_log
echo CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
eval CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
--enable_query_log
INSERT INTO ta_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
--echo
--echo direct_aggregating test
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
SELECT COUNT(*) FROM ta_l;
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
SELECT MAX(a) FROM ta_l;
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
SELECT MIN(a) FROM ta_l;
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
SELECT MAX(a) FROM ta_l WHERE a < 5;
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
SELECT MIN(a) FROM ta_l WHERE a > 1;
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
}
eval $CHILD2_1_SELECT_TABLES;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo with partition test
if ($HAVE_PARTITION)
{
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_2
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_2_DROP_TABLES;
echo CHILD2_2_CREATE_TABLES;
}
--disable_warnings
eval $CHILD2_2_DROP_TABLES;
--enable_warnings
eval $CHILD2_2_CREATE_TABLES;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
}
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
--connection child2_1
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_1_DROP_TABLES2;
echo CHILD2_1_CREATE_TABLES2;
}
--disable_warnings
eval $CHILD2_1_DROP_TABLES2;
--enable_warnings
eval $CHILD2_1_CREATE_TABLES2;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
}
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
--disable_query_log
echo CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
eval CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
INSERT INTO ta_l2 (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
--enable_query_log
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
SELECT COUNT(*) FROM ta_l2;
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
SELECT MAX(a) FROM ta_l2;
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
SELECT MIN(a) FROM ta_l2;
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
SELECT MAX(a) FROM ta_l2 WHERE a < 5;
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
SELECT MIN(a) FROM ta_l2 WHERE a > 1;
eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_2
if ($USE_GENERAL_LOG)
{
SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
}
eval $CHILD2_2_SELECT_TABLES;
--connection child2_1
if ($USE_GENERAL_LOG)
{
SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
}
eval $CHILD2_1_SELECT_TABLES2;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
}
--echo
--echo deinit
--disable_warnings
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
}
--disable_query_log
--disable_result_log
--source test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--echo
--echo end of test

View File

@ -0,0 +1,354 @@
--let $SKIP_REASON=
--disable_warnings
--disable_query_log
--disable_result_log
--source test_init.inc
--enable_result_log
--enable_query_log
--echo
--echo drop and create databases
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
}
--enable_warnings
if ($SKIP_REASON)
{
--echo deinit
--disable_warnings
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
}
--disable_query_log
--disable_result_log
--source test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--skip $SKIP_REASON
}
--echo
--echo test select 1
--connection master_1
SELECT 1;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
SELECT 1;
--connection child2_2
SELECT 1;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo create table select test
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_1_DROP_TABLES;
echo CHILD2_1_CREATE_TABLES;
}
--disable_warnings
eval $CHILD2_1_DROP_TABLES;
--enable_warnings
eval $CHILD2_1_CREATE_TABLES;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
}
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
--disable_warnings
DROP TABLE IF EXISTS ta_l;
--enable_warnings
--disable_query_log
echo CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
eval CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
--enable_query_log
INSERT INTO ta_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
--echo
--echo direct_updating test
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
--echo update all rows with function
UPDATE ta_l SET c = ADDDATE(c, 1);
eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
--echo update by primary key
UPDATE ta_l SET b = 'x' WHERE a = 3;
eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
--echo update by a column without index
UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x';
eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
--echo update by primary key with order and limit
UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
--echo delete by primary key with order and limit
DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1;
eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
--echo delete by a column without index
DELETE FROM ta_l WHERE b = 'c';
eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
--echo delete by primary key
DELETE FROM ta_l WHERE a = 3;
eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
}
eval $CHILD2_1_SELECT_TABLES;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo with partition test
if ($HAVE_PARTITION)
{
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_2
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_2_DROP_TABLES;
echo CHILD2_2_CREATE_TABLES;
}
--disable_warnings
eval $CHILD2_2_DROP_TABLES;
--enable_warnings
eval $CHILD2_2_CREATE_TABLES;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
}
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
--connection child2_1
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_1_DROP_TABLES2;
echo CHILD2_1_CREATE_TABLES2;
}
--disable_warnings
eval $CHILD2_1_DROP_TABLES2;
--enable_warnings
eval $CHILD2_1_CREATE_TABLES2;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
}
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
--disable_query_log
echo CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
eval CREATE TABLE ta_l2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
INSERT INTO ta_l2 (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
--enable_query_log
eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
--echo update all rows with function
UPDATE ta_l2 SET c = ADDDATE(c, 1);
eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
--echo update by primary key
UPDATE ta_l2 SET b = 'x' WHERE a = 3;
eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
--echo update by a column without index
UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x';
eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
--echo update by primary key with order and limit
UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
--echo delete by primary key with order and limit
DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1;
eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
--echo delete by a column without index
DELETE FROM ta_l2 WHERE b = 'c';
eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
--echo delete by primary key
DELETE FROM ta_l2 WHERE a = 3;
eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_2
if ($USE_GENERAL_LOG)
{
SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
}
eval $CHILD2_2_SELECT_TABLES;
--connection child2_1
if ($USE_GENERAL_LOG)
{
SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
}
eval $CHILD2_1_SELECT_TABLES2;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
}
--echo
--echo deinit
--disable_warnings
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
}
--disable_query_log
--disable_result_log
--source test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--echo
--echo end of test

View File

@ -0,0 +1,276 @@
# This test tests for using functions
--let $SKIP_REASON=
--disable_warnings
--disable_query_log
--disable_result_log
--source test_init.inc
--enable_result_log
--enable_query_log
--echo
--echo drop and create databases
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
}
--enable_warnings
if ($SKIP_REASON)
{
--echo deinit
--disable_warnings
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
}
--disable_query_log
--disable_result_log
--source test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--skip $SKIP_REASON
}
--echo
--echo test select 1
--connection master_1
SELECT 1;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
SELECT 1;
--connection child2_2
SELECT 1;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo in()
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_result_log
}
--disable_query_log
--connection child2_1
if ($OUTPUT_CHILD_GROUP2)
{
echo CHILD2_1_DROP_TEXT_PK_TABLES1;
echo CHILD2_1_CREATE_TEXT_PK_TABLES1;
}
--disable_warnings
eval $CHILD2_1_DROP_TEXT_PK_TABLES1;
--enable_warnings
eval $CHILD2_1_CREATE_TEXT_PK_TABLES1;
--enable_query_log
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_result_log
}
}
--connection master_1
--disable_query_log
echo CREATE TABLE t1 (
a VARCHAR(255),
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1;
eval CREATE TABLE t1 (
a VARCHAR(255),
PRIMARY KEY(a)
) $MASTER_1_ENGINE $MASTER_1_CHARSET3 $MASTER_1_COMMENT_TEXT_PK1_1;
--enable_query_log
insert into t1 values ('1');
insert into t1 select a + 1 from t1;
insert into t1 select a + 2 from t1;
insert into t1 select a + 4 from t1;
insert into t1 select a + 8 from t1;
insert into t1 select a + 16 from t1;
insert into t1 select a + 32 from t1;
insert into t1 select a + 64 from t1;
insert into t1 select a + 128 from t1;
insert into t1 select a + 256 from t1;
insert into t1 select a + 512 from t1;
flush tables;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
select a from t1 where a in ('15', '120');
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
}
eval $CHILD2_1_SELECT_TEXT_PK_TABLES1;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo date_sub()
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_1_DROP_TABLES;
echo CHILD2_1_CREATE_TABLES;
}
--disable_warnings
eval $CHILD2_1_DROP_TABLES;
--enable_warnings
eval $CHILD2_1_CREATE_TABLES;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
}
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
--disable_warnings
DROP TABLE IF EXISTS ta_l;
--enable_warnings
--disable_query_log
echo CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
eval CREATE TABLE ta_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
--enable_query_log
INSERT INTO ta_l (a, b, c) VALUES
(1, 'a', '2008-08-01 10:21:39'),
(2, 'b', '2000-01-01 00:00:00'),
(3, 'e', '2007-06-04 20:03:11'),
(4, 'd', '2003-11-30 05:01:03'),
(5, 'c', '2001-12-31 23:59:59');
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE);
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND);
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
}
eval $CHILD2_1_SELECT_TABLES;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
--echo
--echo deinit
--disable_warnings
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
}
--disable_query_log
--disable_result_log
--source test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--echo
--echo end of test

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
# get connection and exist engine test
--echo for master_1
--connection master_1
--source ../include/ha_deinit_master_1.inc
--echo for child2
if ($USE_CHILD_GROUP2)
{
--echo child2_1
--connection child2_1
--source ../include/ha_deinit_child2_1.inc
--echo child2_2
--connection child2_2
--source ../include/ha_deinit_child2_2.inc
--echo child2_3
--connection child2_3
--source ../include/ha_deinit_child2_3.inc
}
--echo for child3
if ($USE_CHILD_GROUP3)
{
--echo child3_1
--connection child3_1
--source ../include/ha_deinit_child3_1.inc
--echo child3_2
--connection child3_2
--source ../include/ha_deinit_child3_2.inc
--echo child3_3
--connection child3_3
--source ../include/ha_deinit_child3_3.inc
}

View File

@ -0,0 +1,30 @@
# get connection and exist engine test
--echo for master_1
--connection master_1
--source ../include/ha_init_master_1.inc
--echo for child2
if ($USE_CHILD_GROUP2)
{
--echo child2_1
--connection child2_1
--source ../include/ha_init_child2_1.inc
--echo child2_2
--connection child2_2
--source ../include/ha_init_child2_2.inc
--echo child2_3
--connection child2_3
--source ../include/ha_init_child2_3.inc
}
--echo for child3
if ($USE_CHILD_GROUP3)
{
--echo child3_1
--connection child3_1
--source ../include/ha_init_child3_1.inc
--echo child3_2
--connection child3_2
--source ../include/ha_init_child3_2.inc
--echo child3_3
--connection child3_3
--source ../include/ha_init_child3_3.inc
}

View File

@ -0,0 +1,7 @@
if (!`SELECT count(*) FROM information_schema.engines WHERE
(support = 'YES' OR support = 'DEFAULT') AND
engine = '$TEST_ENGINE_TYPE'`)
{
SELECT engine, support FROM information_schema.engines;
--let $SKIP_REASON= "Need $TEST_ENGINE_TYPE engine"
}

View File

@ -0,0 +1,5 @@
if (!`SELECT count(*) FROM mysql.func WHERE name = '$TEST_FUNC_NAME'`)
{
SELECT name FROM mysql.func;
--let $SKIP_REASON= "Need $TEST_FUNC_NAME function"
}

View File

@ -0,0 +1,7 @@
let $HAVE_PARTITION= 0;
if (`SELECT count(*) FROM information_schema.plugins WHERE
plugin_status = 'ACTIVE' AND
plugin_name = 'partition'`)
{
let $HAVE_PARTITION= 1;
}

View File

@ -0,0 +1,2 @@
let $HAVE_TRIGGER= `SELECT COUNT(*) FROM information_schema.tables
WHERE TABLE_SCHEMA = 'information_schema' AND TABLE_NAME = 'TRIGGERS'`;

View File

@ -0,0 +1,17 @@
# get connection and exist engine test
--echo for master_1
--connection master_1
--source ../include/hs_deinit_master_1.inc
--echo for child2
if ($USE_CHILD_GROUP2)
{
--echo child2_1
--connection child2_1
--source ../include/hs_deinit_child2_1.inc
--echo child2_2
--connection child2_2
--source ../include/hs_deinit_child2_2.inc
--echo child2_3
--connection child2_3
--source ../include/hs_deinit_child2_3.inc
}

View File

@ -0,0 +1,17 @@
# get connection and exist engine test
--echo for master_1
--connection master_1
--source ../include/hs_init_master_1.inc
--echo for child2
if ($USE_CHILD_GROUP2)
{
--echo child2_1
--connection child2_1
--source ../include/hs_init_child2_1.inc
--echo child2_2
--connection child2_2
--source ../include/hs_init_child2_2.inc
--echo child2_3
--connection child2_3
--source ../include/hs_init_child2_3.inc
}

Some files were not shown because too many files have changed in this diff Show More