Commit d08b7ed5 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'Kentoku:10.0' into 10.0

parents 5dcb111c d4dd936b
......@@ -20,24 +20,35 @@
cmake_minimum_required(VERSION 2.6)
project(mroonga)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
set(MRN_BUNDLED FALSE)
else()
set(MRN_BUNDLED TRUE)
endif()
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
if(BIG_ENDIAN)
message(STATUS "Mroonga is not supported on big-endian")
return()
endif()
if(MSVC)
if(MSVC_VERSION LESS 1600)
message(STATUS "Mroonga supports only MSVC 2010 or later")
set(MRN_BIG_ENDIAN_NOT_SUPPORTED_MESSAGE
"Mroonga doesn't support on big-endian")
if(MRN_BUNDLED)
message(STATUS ${MRN_BIG_ENDIAN_NOT_SUPPORTED_MESSAGE})
return()
else()
message(FATAL_ERROR ${MRN_BIG_ENDIAN_NOT_SUPPORTED_MESSAGE})
endif()
endif()
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
set(MRN_BUNDLED FALSE)
else()
set(MRN_BUNDLED TRUE)
if(MSVC)
if(MSVC_VERSION LESS 1800)
set(MRN_OLD_MSVC_MESSAGE "Mroonga supports only MSVC 2013 or later")
if(MRN_BUNDLED)
message(STATUS ${MRN_OLD_MSVC_MESSAGE})
return()
else()
message(FATAL_ERROR ${MRN_OLD_MSVC_MESSAGE})
endif()
endif()
endif()
if(MRN_BUNDLED)
......@@ -46,11 +57,6 @@ if(MRN_BUNDLED)
endif()
endif()
IF(HAVE_WVLA)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-vla")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-vla")
ENDIF()
set(MRN_BUNDLED_GROONGA_RELATIVE_DIR "vendor/groonga")
set(MRN_BUNDLED_GROONGA_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/${MRN_BUNDLED_GROONGA_RELATIVE_DIR}")
......@@ -184,6 +190,12 @@ else()
endif()
find_path(MYSQL_CONFIG "${MYSQL_CONFIG}")
if(EXISTS "${MYSQL_SOURCE_DIR}/storage/maria")
set(MYSQL_VARIANT "MariaDB")
else()
set(MYSQL_VARIANT "MySQL")
endif()
if(EXISTS "${MYSQL_SOURCE_DIR}/pcre")
set(MYSQL_REGEX_INCLUDE_DIR "${MYSQL_SOURCE_DIR}/pcre")
else()
......@@ -196,12 +208,24 @@ else()
set(MYSQL_RAPIDJSON_INCLUDE_DIR)
endif()
if(EXISTS "${MYSQL_SOURCE_DIR}/libbinlogevents")
set(MYSQL_LIBBINLOGEVENTS_EXPORT_DIR
"${MYSQL_SOURCE_DIR}/libbinlogevents/export")
set(MYSQL_LIBBINLOGEVENTS_INCLUDE_DIR
"${MYSQL_SOURCE_DIR}/libbinlogevents/include")
else()
set(MYSQL_LIBBINLOGEVENTS_EXPORT_DIR)
set(MYSQL_LIBBINLOGEVENTS_INCLUDE_DIR)
endif()
set(MYSQL_INCLUDE_DIRS
"${MYSQL_BUILD_DIR}/include"
"${MYSQL_SOURCE_DIR}/sql"
"${MYSQL_SOURCE_DIR}/include"
"${MYSQL_REGEX_INCLUDE_DIR}"
"${MYSQL_RAPIDJSON_INCLUDE_DIR}"
"${MYSQL_LIBBINLOGEVENTS_EXPORT_DIR}"
"${MYSQL_LIBBINLOGEVENTS_INCLUDE_DIR}"
"${MYSQL_SOURCE_DIR}")
if(MRN_BUNDLED)
......@@ -261,6 +285,9 @@ else()
pkg_check_modules(GROONGA REQUIRED "groonga >= ${REQUIRED_GROONGA_VERSION}")
pkg_check_modules(GROONGA_NORMALIZER_MYSQL
"groonga-normalizer-mysql >= ${REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION}")
set(MRN_LIBRARY_DIRS
${MRN_LIBRARY_DIRS}
${GROONGA_LIBRARY_DIRS})
endif()
include_directories(
......@@ -337,8 +364,12 @@ else()
mrn_build_flag("-Wno-strict-aliasing")
mrn_build_flag("-Wno-deprecated")
mrn_check_cxxflag("-fno-implicit-templates")
mrn_check_cxxflag("-fno-exceptions")
mrn_check_cxxflag("-fno-rtti")
if(("${MYSQL_VARIANT}" STREQUAL "MariaDB") OR
("${MYSQL_VARIANT}" STREQUAL "MySQL" AND
${MYSQL_VERSION} VERSION_LESS "5.7.0"))
mrn_check_cxxflag("-fno-exceptions")
mrn_check_cxxflag("-fno-rtti")
endif()
mrn_check_cxxflag("-felide-constructors")
endif()
set_source_files_properties(${MRN_SOURCES} PROPERTIES
......
This diff is collapsed.
......@@ -40,7 +40,6 @@ SUBDIRS = \
EXTRA_DIST = \
AUTHORS \
gpg_uid \
plug.in \
CMakeLists.txt
installcheck-local: install
......
......@@ -2,14 +2,17 @@ version: "{build}"
clone_depth: 10
install:
- cd ..
- choco install curl 7zip.commandline
- curl -O http://mirror.jmu.edu/pub/mariadb/mariadb-10.0.16/source/mariadb-10.0.16.tar.gz
- 7z x mariadb-10.0.16.tar.gz
- 7z x mariadb-10.0.16.tar > nul
- cd mariadb-10.0.16
- choco install -y curl 7zip.commandline
- curl -O http://mirror.jmu.edu/pub/mariadb/mariadb-10.0.17/source/mariadb-10.0.17.tar.gz
- 7z x mariadb-10.0.17.tar.gz
- 7z x mariadb-10.0.17.tar > nul
- cd mariadb-10.0.17
- rmdir /S /Q storage\mroonga\
- move ..\mroonga storage\mroonga
- git clone --quiet --depth 1 https://github.com/groonga/groonga.git ..\groonga
- cd ..\groonga
- git submodule update --init
- cd ..\mariadb-10.0.17
- rmdir /S /Q ..\groonga\test\
- mkdir storage\mroonga\vendor
- move ..\groonga storage\mroonga\vendor\groonga
......
......@@ -184,6 +184,10 @@ AC_DEFUN([CONFIG_OPTION_MYSQL],[
mysql_regex_include_dir="$ac_mysql_source_dir/regex"
fi
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$mysql_regex_include_dir"
if test -d "$ac_mysql_source_dir/libbinlogevents"; then
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/libbinlogevents/export"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/libbinlogevents/include"
fi
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir"
MYSQL_INCLUDES="$MYSQL_INCLUDES $($ac_mysql_config --include)"
AC_SUBST(MYSQL_INCLUDES)
......@@ -191,8 +195,19 @@ AC_DEFUN([CONFIG_OPTION_MYSQL],[
MYSQL_VERSION="$($ac_mysql_config --version)"
AC_SUBST(MYSQL_VERSION)
MYSQL_MAJOR_MINOR_VERSION=["$(echo $MYSQL_VERSION | sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*[a-z]*\)[.0-9a-z-]*$/\1.\2/')"]
MYSQL_CXXFLAGS="-fno-implicit-templates -felide-constructors"
case "$MYSQL_MAJOR_MINOR_VERSION" in
5.7)
:
;;
*)
MYSQL_CXXFLAGS="$MYSQL_CXXFLAGS -fno-exceptions -fno-rtti"
;;
esac
if test "${with_libmysqlservices_compat}" = "no"; then
MYSQL_MAJOR_MINOR_VERSION=["$(echo $MYSQL_VERSION | sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*[a-z]*\)$/\1.\2/')"]
case "$MYSQL_MAJOR_MINOR_VERSION" in
5.1)
MYSQL_LIBS=""
......@@ -451,7 +466,7 @@ AC_SUBST(DOCUMENT_VERSION)
AC_SUBST(DOCUMENT_VERSION_FULL)
CFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti -felide-constructors"
CXXFLAGS="$CXXFLAGS $MYSQL_CXXFLAGS"
AC_CONFIG_FILES([
Makefile
......@@ -489,6 +504,7 @@ AC_OUTPUT([
packages/rpm/centos/mysql55-mroonga.spec
packages/rpm/centos/mysql56-community-mroonga.spec
packages/rpm/centos/mariadb-mroonga.spec
packages/rpm/centos/percona-server-56-mroonga.spec
packages/yum/env.sh
data/install.sql
])
This diff is collapsed.
......@@ -98,7 +98,13 @@ extern "C" {
# define MRN_TABLE_LIST_INIT_REQUIRE_ALIAS
#endif
#ifdef BIG_TABLES
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_BIG_TABLES
#elif defined(BIG_TABLES)
# define MRN_BIG_TABLES
#endif
#ifdef MRN_BIG_TABLES
# define MRN_HA_ROWS_FORMAT "llu"
#else
# define MRN_HA_ROWS_FORMAT "lu"
......@@ -145,6 +151,14 @@ extern "C" {
# define MRN_HAVE_TL_WRITE_ALLOW_READ
#endif
#if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P)
# define MRN_HAVE_TL_WRITE_DELAYED
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_HAVE_TL_WRITE_CONCURRENT_DEFAULT
#endif
#if (defined(MRN_MARIADB_P) && \
((MYSQL_VERSION_ID >= 50306 && MYSQL_VERSION_ID < 50500) || \
MYSQL_VERSION_ID >= 50523))
......@@ -179,6 +193,44 @@ extern "C" {
# define MRN_HAVE_TDC_LOCK_TABLE_SHARE
#endif
#ifdef MRN_MARIADB_P
# if MYSQL_VERSION_ID >= 50542 && MYSQL_VERSION_ID < 100000
# define MRN_SUPPORT_THDVAR_SET
# elif MYSQL_VERSION_ID >= 100017
# define MRN_SUPPORT_THDVAR_SET
# endif
#else
# define MRN_SUPPORT_THDVAR_SET
#endif
#ifdef MRN_MARIADB_P
# if MYSQL_VERSION_ID < 100000
# define MRN_SUPPORT_PARTITION
# endif
#else
# define MRN_SUPPORT_PARTITION
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_FLUSH_LOGS_HAVE_BINLOG_GROUP_FLUSH
#endif
#if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P)
# define MRN_HAVE_HTON_ALTER_TABLE_FLAGS
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_FOREIGN_KEY_USE_CONST_STRING
#endif
#if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P)
# define MRN_HANDLER_IS_FATAL_ERROR_HAVE_FLAGS
#endif
#if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P)
# define MRN_HANDLER_HAVE_RESET_AUTO_INCREMENT
#endif
class ha_mroonga;
/* structs */
......@@ -448,7 +500,7 @@ public:
bool check_and_repair(THD *thd);
int analyze(THD* thd, HA_CHECK_OPT* check_opt);
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
bool is_fatal_error(int error_num, uint flags);
bool is_fatal_error(int error_num, uint flags=0);
bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
uint table_changes);
#ifdef MRN_HANDLER_HAVE_CHECK_IF_SUPPORTED_INPLACE_ALTER
......@@ -474,7 +526,9 @@ public:
void restore_auto_increment(ulonglong prev_insert_id);
void release_auto_increment();
int check_for_upgrade(HA_CHECK_OPT *check_opt);
#ifdef MRN_HANDLER_HAVE_RESET_AUTO_INCREMENT
int reset_auto_increment(ulonglong value);
#endif
bool was_semi_consistent_read();
void try_semi_consistent_read(bool yes);
void unlock_row();
......@@ -556,6 +610,7 @@ private:
int drop_index(MRN_SHARE *target_share, uint key_index);
grn_obj *find_tokenizer(const char *name, int name_length);
grn_obj *find_normalizer(KEY *key_info);
bool find_index_column_flags(KEY *key_info, grn_obj_flags *index_column_flags);
bool find_token_filters(KEY *key_info, grn_obj *token_filters);
bool find_token_filters_put(grn_obj *token_filters,
const char *token_filter_name,
......@@ -579,6 +634,7 @@ private:
void check_count_skip(key_part_map start_key_part_map,
key_part_map end_key_part_map, bool fulltext);
bool is_grn_zero_column_value(grn_obj *column, grn_obj *value);
bool is_primary_key_field(Field *field) const;
void check_fast_order_limit(grn_table_sort_key **sort_keys, int *n_sort_keys,
longlong *limit);
......@@ -1040,6 +1096,7 @@ private:
int wrapper_fill_indexes(THD *thd, KEY *key_info,
grn_obj **index_columns, uint n_keys);
int wrapper_recreate_indexes(THD *thd);
int storage_recreate_indexes(THD *thd);
int wrapper_repair(THD* thd, HA_CHECK_OPT* check_opt);
int storage_repair(THD* thd, HA_CHECK_OPT* check_opt);
bool wrapper_check_and_repair(THD *thd);
......@@ -1131,8 +1188,10 @@ private:
void storage_release_auto_increment();
int wrapper_check_for_upgrade(HA_CHECK_OPT *check_opt);
int storage_check_for_upgrade(HA_CHECK_OPT *check_opt);
#ifdef MRN_HANDLER_HAVE_RESET_AUTO_INCREMENT
int wrapper_reset_auto_increment(ulonglong value);
int storage_reset_auto_increment(ulonglong value);
#endif
bool wrapper_was_semi_consistent_read();
bool storage_was_semi_consistent_read();
void wrapper_try_semi_consistent_read(bool yes);
......
......@@ -24,4 +24,8 @@ libmrn_need_mysql_la_SOURCES = \
mrn_time_converter.cpp \
mrn_time_converter.hpp \
mrn_database_manager.cpp \
mrn_database_manager.hpp
mrn_database_manager.hpp \
mrn_value_decoder.cpp \
mrn_value_decoder.hpp \
mrn_database_repairer.cpp \
mrn_database_repairer.hpp
......@@ -23,6 +23,8 @@
#include <groonga.h>
#include <mrn_mysql_compat.h>
#include <item_cmpfunc.h>
namespace mrn {
class ConditionConverter {
public:
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
#include <mrn_constants.hpp>
#include "mrn_database_repairer.hpp"
#include "mrn_path_mapper.hpp"
// for debug
#define MRN_CLASS_NAME "mrn::DatabaseRepairer"
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#ifndef WIN32
# include <dirent.h>
#endif
namespace mrn {
DatabaseRepairer::DatabaseRepairer(grn_ctx *ctx, THD *thd)
: ctx_(ctx),
thd_(thd),
base_directory_(NULL),
base_directory_buffer_(),
path_prefix_(NULL),
path_prefix_buffer_(),
path_prefix_length_(0),
mrn_db_file_suffix_length_(strlen(MRN_DB_FILE_SUFFIX)) {
}
DatabaseRepairer::~DatabaseRepairer() {
}
bool DatabaseRepairer::is_crashed(void) {
MRN_DBUG_ENTER_METHOD();
bool is_crashed = false;
each_database(&DatabaseRepairer::is_crashed_body, &is_crashed);
DBUG_RETURN(is_crashed);
}
bool DatabaseRepairer::repair(void) {
MRN_DBUG_ENTER_METHOD();
bool succeeded = true;
each_database(&DatabaseRepairer::repair_body, &succeeded);
DBUG_RETURN(succeeded);
}
void DatabaseRepairer::each_database(EachBodyFunc each_body_func,
void *user_data) {
MRN_DBUG_ENTER_METHOD();
detect_paths();
#ifdef WIN32
WIN32_FIND_DATA data;
HANDLE finder = FindFirstFile(base_directory_, &data);
if (finder == INVALID_HANDLE_VALUE) {
DBUG_VOID_RETURN;
}
do {
each_database_body(data.cFileName, each_body_func, user_data);
} while (FindNextFile(finder, &data) != 0);
FindClose(finder);
#else
DIR *dir = opendir(base_directory_);
if (!dir) {
DBUG_VOID_RETURN;
}
while (struct dirent *entry = readdir(dir)) {
each_database_body(entry->d_name, each_body_func, user_data);
}
closedir(dir);
#endif
DBUG_VOID_RETURN;
}
void DatabaseRepairer::each_database_body(const char *base_path,
EachBodyFunc each_body_func,
void *user_data) {
MRN_DBUG_ENTER_METHOD();
if (path_prefix_length_ > 0 &&
strncmp(base_path, path_prefix_, path_prefix_length_) != 0) {
DBUG_VOID_RETURN;
}
size_t path_length = strlen(base_path);
if (path_length <= mrn_db_file_suffix_length_) {
DBUG_VOID_RETURN;
}
if (strncmp(base_path + (path_length - mrn_db_file_suffix_length_),
MRN_DB_FILE_SUFFIX, mrn_db_file_suffix_length_) != 0) {
DBUG_VOID_RETURN;
}
char db_path[MRN_MAX_PATH_SIZE];
snprintf(db_path, MRN_MAX_PATH_SIZE,
"%s%c%s", base_directory_, FN_LIBCHAR, base_path);
grn_obj *db = grn_db_open(ctx_, db_path);
if (!db) {
DBUG_VOID_RETURN;
}
(this->*each_body_func)(db, db_path, user_data);
grn_obj_close(ctx_, db);
DBUG_VOID_RETURN;
}
void DatabaseRepairer::detect_paths(void) {
MRN_DBUG_ENTER_METHOD();
const char *raw_path_prefix = mrn::PathMapper::default_path_prefix;
if (!raw_path_prefix) {
base_directory_ = ".";
path_prefix_ = NULL;
DBUG_VOID_RETURN;
}
strcpy(base_directory_buffer_, raw_path_prefix);
size_t raw_path_prefix_length = strlen(raw_path_prefix);
size_t separator_position = raw_path_prefix_length;
for (; separator_position > 0; separator_position--) {
if (base_directory_buffer_[separator_position] == FN_LIBCHAR ||
base_directory_buffer_[separator_position] == FN_LIBCHAR2) {
break;
}
}
if (separator_position == 0 ||
separator_position == raw_path_prefix_length) {
base_directory_ = ".";
} else {
base_directory_buffer_[separator_position] = '\0';
base_directory_ = base_directory_buffer_;
strcpy(path_prefix_buffer_, raw_path_prefix + separator_position + 1);
path_prefix_ = path_prefix_buffer_;
path_prefix_length_ = strlen(path_prefix_);
}
DBUG_VOID_RETURN;
}
void DatabaseRepairer::is_crashed_body(grn_obj *db,
const char *db_path,
void *user_data) {
MRN_DBUG_ENTER_METHOD();
bool *is_crashed = static_cast<bool *>(user_data);
if (grn_obj_is_locked(ctx_, db)) {
*is_crashed = true;
DBUG_VOID_RETURN;
}
grn_table_cursor *cursor;
cursor = grn_table_cursor_open(ctx_, db,
NULL, 0,
NULL, 0,
0, -1, GRN_CURSOR_BY_ID);
if (!cursor) {
*is_crashed = true;
DBUG_VOID_RETURN;
}
grn_id id;
while ((id = grn_table_cursor_next(ctx_, cursor)) != GRN_ID_NIL) {
grn_obj *object = grn_ctx_at(ctx_, id);
if (!object) {
continue;
}
switch (object->header.type) {
case GRN_TABLE_HASH_KEY :
case GRN_TABLE_PAT_KEY:
case GRN_TABLE_DAT_KEY:
case GRN_TABLE_NO_KEY:
case GRN_COLUMN_FIX_SIZE:
case GRN_COLUMN_VAR_SIZE:
case GRN_COLUMN_INDEX:
grn_obj_is_locked(ctx_, object);
*is_crashed = true;
break;
default:
break;
}
grn_obj_unlink(ctx_, object);
if (*is_crashed) {
break;
}
}
grn_table_cursor_close(ctx_, cursor);
DBUG_VOID_RETURN;
}
void DatabaseRepairer::repair_body(grn_obj *db,
const char *db_path,
void *user_data) {
MRN_DBUG_ENTER_METHOD();
bool *succeeded = static_cast<bool *>(user_data);
if (grn_db_recover(ctx_, db) != GRN_SUCCESS) {
push_warning_printf(thd_,
Sql_condition::WARN_LEVEL_WARN,
ER_NOT_KEYFILE,
"mroonga: repair: "
"Failed to recover database: <%s>: <%s>",
db_path, ctx_->errbuf);
*succeeded = false;
}
DBUG_VOID_RETURN;
}
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MRN_DATABASE_REPAIRER_HPP_
#define MRN_DATABASE_REPAIRER_HPP_
#include <groonga.h>
namespace mrn {
class DatabaseRepairer {
public:
DatabaseRepairer(grn_ctx *ctx, THD *thd);
~DatabaseRepairer(void);
bool is_crashed(void);
bool repair(void);
private:
grn_ctx *ctx_;
THD *thd_;
const char *base_directory_;
char base_directory_buffer_[MRN_MAX_PATH_SIZE];
const char *path_prefix_;
char path_prefix_buffer_[MRN_MAX_PATH_SIZE];
size_t path_prefix_length_;
size_t mrn_db_file_suffix_length_;
typedef void (DatabaseRepairer::*EachBodyFunc)(grn_obj *db,
const char *db_path,
void *user_data);
void each_database(EachBodyFunc each_body_func, void *user_data);
void each_database_body(const char *base_path,
EachBodyFunc each_body_func,
void *user_data);
void detect_paths(void);
void is_crashed_body(grn_obj *db, const char *db_path, void *user_data);
void repair_body(grn_obj *db, const char *db_path, void *user_data);
};
}
#endif /* MRN_DATABASE_REPAIRER_HPP_ */
......@@ -18,6 +18,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <mrn_mysql.h>
#include <mrn_err.h>
#include "mrn_encoding.hpp"
......
......@@ -17,6 +17,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <mrn_mysql.h>
#include "mrn_field_normalizer.hpp"
#include "mrn_encoding.hpp"
......@@ -114,6 +116,9 @@ namespace mrn {
} else if ((strcmp(charset_info->name, "utf8_unicode_ci") == 0) ||
(strcmp(charset_info->name, "utf8mb4_unicode_ci") == 0)) {
normalizer_name = "NormalizerMySQLUnicodeCI";
} else if ((strcmp(charset_info->name, "utf8_unicode_520_ci") == 0) ||
(strcmp(charset_info->name, "utf8mb4_unicode_520_ci") == 0)) {
normalizer_name = "NormalizerMySQLUnicode520CI";
}
grn_obj *normalizer = NULL;
......@@ -128,7 +133,7 @@ namespace mrn {
normalizer_name,
charset_info->name,
default_normalizer_name);
push_warning(thread_, Sql_condition::WARN_LEVEL_WARN,
push_warning(thread_, MRN_SEVERITY_WARNING,
HA_ERR_UNSUPPORTED, error_message);
}
}
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012-2014 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2012-2015 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2013 Kentoku SHIBA
This library is free software; you can redistribute it and/or
......@@ -23,6 +23,7 @@
#include "mrn_multiple_column_key_codec.hpp"
#include "mrn_field_normalizer.hpp"
#include "mrn_smart_grn_obj.hpp"
#include "mrn_value_decoder.hpp"
// for debug
#define MRN_CLASS_NAME "mrn::MultipleColumnKeyCodec"
......@@ -121,14 +122,14 @@ namespace mrn {
case TYPE_FLOAT:
{
float value;
float4get(value, current_mysql_key);
value_decoder::decode(&value, current_mysql_key);
encode_float(value, data_size, current_grn_key);
}
break;
case TYPE_DOUBLE:
{
double value;
float8get(value, current_mysql_key);
value_decoder::decode(&value, current_mysql_key);
encode_double(value, data_size, current_grn_key);
}
break;
......@@ -523,7 +524,7 @@ namespace mrn {
new_blob_data_length = normalized_length;
} else {
push_warning_printf(thread_,
Sql_condition::WARN_LEVEL_WARN,
MRN_SEVERITY_WARNING,
WARN_DATA_TRUNCATED,
"normalized data truncated "
"for multiple column index: "
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2013 Kentoku SHIBA
Copyright(C) 2011-2013 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -21,6 +21,7 @@
#include "mrn_parameters_parser.hpp"
#include <mrn_mysql_compat.h>
#include <mrn_variables.hpp>
namespace mrn {
class Parameter {
......@@ -30,8 +31,8 @@ namespace mrn {
Parameter(const char *key, unsigned int key_length,
const char *value, unsigned int value_length)
: key_(my_strndup(key, key_length, MYF(0))),
value_(my_strndup(value, value_length, MYF(0))) {
: key_(mrn_my_strndup(key, key_length, MYF(0))),
value_(mrn_my_strndup(value, value_length, MYF(0))) {
};
~Parameter() {
if (key_) {
......
......@@ -29,16 +29,17 @@ namespace mrn {
char *PathMapper::default_path_prefix = NULL;
char *PathMapper::default_mysql_data_home_path = NULL;
PathMapper::PathMapper(const char *mysql_path,
PathMapper::PathMapper(const char *original_mysql_path,
const char *path_prefix,
const char *mysql_data_home_path)
: mysql_path_(mysql_path),
: original_mysql_path_(original_mysql_path),
path_prefix_(path_prefix),
mysql_data_home_path_(mysql_data_home_path) {
db_path_[0] = '\0';
db_name_[0] = '\0';
table_name_[0] = '\0';
mysql_table_name_[0] = '\0';
mysql_path_[0] = '\0';
}
/**
......@@ -52,22 +53,25 @@ namespace mrn {
return db_path_;
}
if (mysql_path_[0] == FN_CURLIB && mysql_path_[1] == FN_LIBCHAR) {
if (original_mysql_path_[0] == FN_CURLIB &&
original_mysql_path_[1] == FN_LIBCHAR) {
if (path_prefix_) {
strcpy(db_path_, path_prefix_);
}
int i = 2, j = strlen(db_path_), len;
len = strlen(mysql_path_);
while (mysql_path_[i] != FN_LIBCHAR && i < len) {
db_path_[j++] = mysql_path_[i++];
len = strlen(original_mysql_path_);
while (original_mysql_path_[i] != FN_LIBCHAR && i < len) {
db_path_[j++] = original_mysql_path_[i++];
}
db_path_[j] = '\0';
} else if (mysql_data_home_path_) {
int len = strlen(mysql_path_);
int len = strlen(original_mysql_path_);
int mysql_data_home_len = strlen(mysql_data_home_path_);
if (len > mysql_data_home_len &&
!strncmp(mysql_path_, mysql_data_home_path_, mysql_data_home_len)) {
!strncmp(original_mysql_path_,
mysql_data_home_path_,
mysql_data_home_len)) {
int i = mysql_data_home_len, j;
if (path_prefix_ && path_prefix_[0] == FN_LIBCHAR) {
strcpy(db_path_, path_prefix_);
......@@ -87,19 +91,19 @@ namespace mrn {
}
}
while (mysql_path_[i] != FN_LIBCHAR && i < len) {
db_path_[j++] = mysql_path_[i++];
while (original_mysql_path_[i] != FN_LIBCHAR && i < len) {
db_path_[j++] = original_mysql_path_[i++];
}
if (i == len) {
memcpy(db_path_, mysql_path_, len);
memcpy(db_path_, original_mysql_path_, len);
} else {
db_path_[j] = '\0';
}
} else {
strcpy(db_path_, mysql_path_);
strcpy(db_path_, original_mysql_path_);
}
} else {
strcpy(db_path_, mysql_path_);
strcpy(db_path_, original_mysql_path_);
}
strcat(db_path_, MRN_DB_FILE_SUFFIX);
return db_path_;
......@@ -116,32 +120,35 @@ namespace mrn {
return db_name_;
}
if (mysql_path_[0] == FN_CURLIB && mysql_path_[1] == FN_LIBCHAR) {
if (original_mysql_path_[0] == FN_CURLIB &&
original_mysql_path_[1] == FN_LIBCHAR) {
int i = 2, j = 0, len;
len = strlen(mysql_path_);
while (mysql_path_[i] != FN_LIBCHAR && i < len) {
db_name_[j++] = mysql_path_[i++];
len = strlen(original_mysql_path_);
while (original_mysql_path_[i] != FN_LIBCHAR && i < len) {
db_name_[j++] = original_mysql_path_[i++];
}
db_name_[j] = '\0';
} else if (mysql_data_home_path_) {
int len = strlen(mysql_path_);
int len = strlen(original_mysql_path_);
int mysql_data_home_len = strlen(mysql_data_home_path_);
if (len > mysql_data_home_len &&
!strncmp(mysql_path_, mysql_data_home_path_, mysql_data_home_len)) {
!strncmp(original_mysql_path_,
mysql_data_home_path_,
mysql_data_home_len)) {
int i = mysql_data_home_len, j = 0;
while (mysql_path_[i] != FN_LIBCHAR && i < len) {
db_name_[j++] = mysql_path_[i++];
while (original_mysql_path_[i] != FN_LIBCHAR && i < len) {
db_name_[j++] = original_mysql_path_[i++];
}
if (i == len) {
memcpy(db_name_, mysql_path_, len);
memcpy(db_name_, original_mysql_path_, len);
} else {
db_name_[j] = '\0';
}
} else {
strcpy(db_name_, mysql_path_);
strcpy(db_name_, original_mysql_path_);
}
} else {
strcpy(db_name_, mysql_path_);
strcpy(db_name_, original_mysql_path_);
}
return db_name_;
}
......@@ -154,10 +161,10 @@ namespace mrn {
return table_name_;
}
int len = strlen(mysql_path_);
int len = strlen(original_mysql_path_);
int i = len, j = 0;
for (; mysql_path_[--i] != FN_LIBCHAR ;) {}
if (mysql_path_[i + 1] == '_') {
for (; original_mysql_path_[--i] != FN_LIBCHAR ;) {}
if (original_mysql_path_[i + 1] == '_') {
table_name_[j++] = '@';
table_name_[j++] = '0';
table_name_[j++] = '0';
......@@ -166,7 +173,7 @@ namespace mrn {
i++;
}
for (; i < len ;) {
table_name_[j++] = mysql_path_[++i];
table_name_[j++] = original_mysql_path_[++i];
}
table_name_[j] = '\0';
return table_name_;
......@@ -180,16 +187,39 @@ namespace mrn {
return mysql_table_name_;
}
int len = strlen(mysql_path_);
int len = strlen(original_mysql_path_);
int i = len, j = 0;
for (; mysql_path_[--i] != FN_LIBCHAR ;) {}
for (; original_mysql_path_[--i] != FN_LIBCHAR ;) {}
for (; i < len ;) {
if (len - i - 1 >= 3 && strncmp(mysql_path_ + i + 1, "#P#", 3) == 0) {
if (len - i - 1 >= 3 &&
strncmp(original_mysql_path_ + i + 1, "#P#", 3) == 0) {
break;
}
mysql_table_name_[j++] = mysql_path_[++i];
mysql_table_name_[j++] = original_mysql_path_[++i];
}
mysql_table_name_[j] = '\0';
return mysql_table_name_;
}
/**
* "./${db}/${table}" ==> "./${db}/${table}"
* "./${db}/${table}#P#xxx" ==> "./${db}/${table}"
*/
const char *PathMapper::mysql_path() {
if (mysql_path_[0] != '\0') {
return mysql_path_;
}
int i;
int len = strlen(original_mysql_path_);
for (i = 0; i < len; i++) {
if (len - i >= 3 &&
strncmp(original_mysql_path_ + i, "#P#", 3) == 0) {
break;
}
mysql_path_[i] = original_mysql_path_[i];
}
mysql_path_[i] = '\0';
return mysql_path_;
}
}
......@@ -2,7 +2,7 @@
/*
Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -30,21 +30,23 @@ namespace mrn {
static char *default_path_prefix;
static char *default_mysql_data_home_path;
PathMapper(const char *mysql_path,
PathMapper(const char *original_mysql_path,
const char *path_prefix=default_path_prefix,
const char *mysql_data_home_path=default_mysql_data_home_path);
const char *db_path();
const char *db_name();
const char *table_name();
const char *mysql_table_name();
const char *mysql_path();
private:
const char *mysql_path_;
const char *original_mysql_path_;
const char *path_prefix_;
const char *mysql_data_home_path_;
char db_path_[MRN_MAX_PATH_SIZE];
char db_name_[MRN_MAX_PATH_SIZE];
char table_name_[MRN_MAX_PATH_SIZE];
char mysql_table_name_[MRN_MAX_PATH_SIZE];
char mysql_path_[MRN_MAX_PATH_SIZE];
};
}
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "mrn_value_decoder.hpp"
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_DEST_IS_POINTER
#endif
namespace mrn {
namespace value_decoder {
void decode(uint16 *dest, const uchar *source) {
MRN_DBUG_ENTER_FUNCTION();
#ifdef MRN_DEST_IS_POINTER
ushortget(dest, source);
#else
uint16 value;
ushortget(value, source);
*dest = value;
#endif
DBUG_VOID_RETURN;
};
void decode(float *dest, const uchar *source) {
MRN_DBUG_ENTER_FUNCTION();
#ifdef MRN_DEST_IS_POINTER
float4get(dest, source);
#else
float value;
float4get(value, source);
*dest = value;
#endif
DBUG_VOID_RETURN;
};
void decode(double *dest, const uchar *source) {
MRN_DBUG_ENTER_FUNCTION();
#ifdef MRN_DEST_IS_POINTER
float8get(dest, source);
#else
double value;
float8get(value, source);
*dest = value;
#endif
DBUG_VOID_RETURN;
}
}
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MRN_VALUE_DECODER_HPP_
#define MRN_VALUE_DECODER_HPP_
#include <mrn_mysql.h>
namespace mrn {
namespace value_decoder {
void decode(uint16 *dest, const uchar *source);
void decode(float *dest, const uchar *source);
void decode(double *dest, const uchar *source);
}
}
#endif // MRN_VALUE_DECODER_HPP_
......@@ -22,6 +22,8 @@
#ifndef MRN_CONSTANTS_HPP_
#define MRN_CONSTANTS_HPP_
#include <limits.h>
#include <groonga.h>
#define MRN_BUFFER_SIZE 1024
......
......@@ -34,5 +34,8 @@
#define ER_MRN_INVALID_COLUMN_FLAG_NUM 16507
#define ER_MRN_INVALID_COLUMN_FLAG_STR \
"The column flag '%-.64s' is invalid. '%-64s' is used instead"
#define ER_MRN_INVALID_INDEX_FLAG_NUM 16508
#define ER_MRN_INVALID_INDEX_FLAG_STR \
"The index flag '%-.64s' is invalid. It is ignored"
#endif /* MRN_ERR_H_ */
......@@ -47,7 +47,7 @@
# include <mysql_priv.h>
# include <mysql/plugin.h>
#else
# include <sql_priv.h>
# include <sql_const.h>
# include <sql_class.h>
# include <probes_mysql.h>
# include <sql_partition.h>
......@@ -58,12 +58,6 @@
# define MRN_MARIADB_P 1
#endif
#if MYSQL_VERSION_ID >= 50607
# if !defined(MRN_MARIADB_P)
# define MRN_HAVE_SQL_OPTIMIZER_H
# endif
#endif
#define MRN_MESSAGE_BUFFER_SIZE 1024
#define MRN_DBUG_ENTER_FUNCTION() DBUG_ENTER(__FUNCTION__)
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2014 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -61,26 +61,34 @@
# define KEY_N_KEY_PARTS(key) (key)->key_parts
#endif
#if MYSQL_VERSION_ID < 100000 || !defined(MRN_MARIADB_P)
# define init_alloc_root(PTR, SZ1, SZ2, FLAG) init_alloc_root(PTR, SZ1, SZ2)
#if defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100000
# define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \
init_alloc_root(PTR, SZ1, SZ2, FLAG)
#elif MYSQL_VERSION_ID >= 50706
# define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \
init_alloc_root(mrn_memory_key, PTR, SZ1, SZ2)
#else
# define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \
init_alloc_root(PTR, SZ1, SZ2)
#endif
#if MYSQL_VERSION_ID < 100002 || !defined(MRN_MARIADB_P)
# define GTS_TABLE 0
#endif
/* For MySQL 5.1. MySQL 5.1 doesn't have FN_LIBCHAR2. */
#ifndef FN_LIBCHAR2
# define FN_LIBCHAR2 FN_LIBCHAR
#endif
#if MYSQL_VERSION_ID >= 50607
# if MYSQL_VERSION_ID >= 100007 && defined(MRN_MARIADB_P)
# define MRN_GET_ERROR_MESSAGE thd_get_error_message(current_thd)
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) thd_get_error_row(thd)
# else
# define MRN_GET_ERROR_MESSAGE current_thd->get_stmt_da()->message()
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) thd->get_stmt_da()->current_row_for_warning()
# if MYSQL_VERSION_ID >= 50706
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) \
thd->get_stmt_da()->current_row_for_condition()
# else
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) \
thd->get_stmt_da()->current_row_for_warning()
# endif
# endif
#else
# if MYSQL_VERSION_ID >= 50500
......@@ -96,7 +104,7 @@
# define MRN_ITEM_HAVE_ITEM_NAME
#endif
#if MYSQL_VERSION_ID >= 50500 && MYSQL_VERSION_ID < 50700
#if MYSQL_VERSION_ID >= 50500 && MYSQL_VERSION_ID < 100000
# define MRN_HAVE_TABLE_DEF_CACHE
#endif
......@@ -131,4 +139,82 @@
# define MRN_USE_MYSQL_DATA_HOME
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_SEVERITY_WARNING Sql_condition::SL_WARNING
#else
# define MRN_SEVERITY_WARNING Sql_condition::WARN_LEVEL_WARN
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_HAVE_PSI_MEMORY_KEY
#endif
#ifdef MRN_HAVE_PSI_MEMORY_KEY
# define mrn_my_malloc(size, flags) \
my_malloc(mrn_memory_key, size, flags)
# define mrn_my_strdup(string, flags) \
my_strdup(mrn_memory_key, string, flags)
# define mrn_my_strndup(string, size, flags) \
my_strndup(mrn_memory_key, string, size, flags)
# define mrn_my_multi_malloc(flags, ...) \
my_multi_malloc(mrn_memory_key, flags, __VA_ARGS__)
#else
# define mrn_my_malloc(size, flags) my_malloc(size, flags)
# define mrn_my_strdup(string, flags) my_strdup(string, flags)
# define mrn_my_strndup(string, size, flags) \
my_strndup(string, size, flags)
# define mrn_my_multi_malloc(flags, ...) \
my_multi_malloc(flags, __VA_ARGS__)
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_STRING_FREE(string) string.mem_free();
#else
# define MRN_STRING_FREE(string) string.free();
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_THD_DB_PATH(thd) ((thd)->db().str)
#else
# define MRN_THD_DB_PATH(thd) ((thd)->db)
#endif
#ifndef INT_MAX64
# define INT_MAX64 LONGLONG_MAX
#endif
#ifdef UINT_MAX
# define UINT_MAX64 UINT_MAX
#else
# define UINT_MAX64 LONGLONG_MAX
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define mrn_my_stpmov(dst, src) my_stpmov(dst, src)
#else
# define mrn_my_stpmov(dst, src) strmov(dst, src)
#endif
#if MYSQL_VERSION_ID >= 50607
# if !defined(MRN_MARIADB_P)
# define MRN_HAVE_SQL_OPTIMIZER_H
# endif
#endif
#if MYSQL_VERSION_ID >= 50600 && !defined(MRN_MARIADB_P)
# define MRN_HAVE_BINLOG_H
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_HAVE_SPATIAL
#elif defined(HAVE_SPATIAL)
# define MRN_HAVE_SPATIAL
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_FORMAT_STRING_LENGTH "zu"
#else
# define MRN_FORMAT_STRING_LENGTH "u"
#endif
#endif /* MRN_MYSQL_COMPAT_H_ */
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2013 Kentoku SHIBA
Copyright(C) 2011-2014 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -24,9 +24,15 @@
# include <sql_servers.h>
# include <sql_base.h>
#endif
#ifdef WITH_PARTITION_STORAGE_ENGINE
# include <partition_info.h>
#endif
#include <sql_plugin.h>
#include "mrn_err.h"
#include "mrn_table.hpp"
#include "mrn_mysql_compat.h"
#include "mrn_variables.hpp"
#include <mrn_lock.hpp>
#if MYSQL_VERSION_ID >= 50603 && !defined(MRN_MARIADB_P)
......@@ -35,6 +41,12 @@
# define MRN_HA_RESOLVE_BY_NAME(name) ha_resolve_by_name(NULL, (name))
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_PLUGIN_DATA(plugin, type) plugin_data<type>(plugin)
#else
# define MRN_PLUGIN_DATA(plugin, type) plugin_data(plugin, type)
#endif
#define LEX_STRING_IS_EMPTY(string) \
((string).length == 0 || !(string).str || (string).str[0] == '\0')
......@@ -47,23 +59,23 @@
extern HASH *mrn_table_def_cache;
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_PSI_INTERFACE
#ifdef WIN32
# ifdef MRN_TABLE_SHARE_HAVE_LOCK_SHARE
# ifdef WIN32
# ifdef MRN_TABLE_SHARE_HAVE_LOCK_SHARE
extern PSI_mutex_key *mrn_table_share_lock_share;
# endif
# ifdef MRN_TABLE_SHARE_HAVE_LOCK_HA_DATA
# endif
# ifdef MRN_TABLE_SHARE_HAVE_LOCK_HA_DATA
extern PSI_mutex_key *mrn_table_share_lock_ha_data;
# endif
# endif
#endif
extern PSI_mutex_key mrn_share_mutex_key;
extern PSI_mutex_key mrn_long_term_share_auto_inc_mutex_key;
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern HASH mrn_open_tables;
extern mysql_mutex_t mrn_open_tables_mutex;
extern HASH mrn_long_term_share;
......@@ -135,7 +147,7 @@ static char *mrn_get_string_between_quote(const char *ptr)
DBUG_RETURN(NULL);
size_t length = end_ptr - start_ptr;
char *extracted_string = (char *)my_malloc(length + 1, MYF(MY_WME));
char *extracted_string = (char *)mrn_my_malloc(length + 1, MYF(MY_WME));
if (esc_flg) {
size_t extracted_index = 0;
const char *current_ptr = start_ptr;
......@@ -372,9 +384,9 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table)
}
{
params_string = my_strndup(params_string_value,
params_string_length,
MYF(MY_WME));
params_string = mrn_my_strndup(params_string_value,
params_string_length,
MYF(MY_WME));
if (!params_string) {
error = HA_ERR_OUT_OF_MEM;
goto error;
......@@ -437,9 +449,9 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table)
{
share->engine_length = strlen(mrn_default_wrapper_engine);
if (
!(share->engine = my_strndup(mrn_default_wrapper_engine,
share->engine_length,
MYF(MY_WME)))
!(share->engine = mrn_my_strndup(mrn_default_wrapper_engine,
share->engine_length,
MYF(MY_WME)))
) {
error = HA_ERR_OUT_OF_MEM;
goto error;
......@@ -471,7 +483,7 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table)
error = ER_UNKNOWN_STORAGE_ENGINE;
goto error;
}
share->hton = plugin_data(share->plugin, handlerton *);
share->hton = MRN_PLUGIN_DATA(share->plugin, handlerton *);
share->wrapper_mode = TRUE;
}
}
......@@ -507,7 +519,7 @@ int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i)
my_free(share->key_parser[i]);
}
if (
!(share->key_parser[i] = my_strdup(mrn_default_parser, MYF(MY_WME)))
!(share->key_parser[i] = mrn_my_strdup(mrn_default_parser, MYF(MY_WME)))
) {
error = HA_ERR_OUT_OF_MEM;
goto error;
......@@ -517,9 +529,9 @@ int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i)
}
DBUG_PRINT("info", ("mroonga create comment string"));
if (
!(param_string = my_strndup(key_info->comment.str,
key_info->comment.length,
MYF(MY_WME)))
!(param_string = mrn_my_strndup(key_info->comment.str,
key_info->comment.length,
MYF(MY_WME)))
) {
error = HA_ERR_OUT_OF_MEM;
goto error_alloc_param_string;
......@@ -569,7 +581,7 @@ int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i)
#endif
if (!share->key_parser[i]) {
if (
!(share->key_parser[i] = my_strdup(mrn_default_parser, MYF(MY_WME)))
!(share->key_parser[i] = mrn_my_strdup(mrn_default_parser, MYF(MY_WME)))
) {
error = HA_ERR_OUT_OF_MEM;
goto error;
......@@ -630,9 +642,9 @@ int mrn_add_column_param(MRN_SHARE *share, Field *field, int i)
DBUG_PRINT("info", ("mroonga create comment string"));
if (
!(param_string = my_strndup(field->comment.str,
field->comment.length,
MYF(MY_WME)))
!(param_string = mrn_my_strndup(field->comment.str,
field->comment.length,
MYF(MY_WME)))
) {
error = HA_ERR_OUT_OF_MEM;
goto error_alloc_param_string;
......@@ -768,7 +780,7 @@ MRN_LONG_TERM_SHARE *mrn_get_long_term_share(const char *table_name,
table_name_length)))
{
if (!(long_term_share = (MRN_LONG_TERM_SHARE *)
my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
mrn_my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
&long_term_share, sizeof(*long_term_share),
&tmp_name, table_name_length + 1,
NullS))
......@@ -817,7 +829,7 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error)
(uchar*) table_name, length)))
{
if (!(share = (MRN_SHARE *)
my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
mrn_my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
&share, sizeof(*share),
&tmp_name, length + 1,
&index_table, sizeof(char *) * table->s->keys,
......@@ -847,7 +859,7 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error)
share->col_flags_length = col_flags_length;
share->col_type = col_type;
share->col_type_length = col_type_length;
strmov(share->table_name, table_name);
mrn_my_stpmov(share->table_name, table_name);
share->table_share = table->s;
if (
......@@ -1033,7 +1045,7 @@ TABLE_SHARE *mrn_create_tmp_table_share(TABLE_LIST *table_list, const char *path
share->tmp_table = INTERNAL_TMP_TABLE; // TODO: is this right?
share->path.str = (char *) path;
share->path.length = strlen(share->path.str);
share->normalized_path.str = my_strdup(path, MYF(MY_WME));
share->normalized_path.str = mrn_my_strdup(path, MYF(MY_WME));
share->normalized_path.length = strlen(share->normalized_path.str);
if (open_table_def(thd, share, GTS_TABLE))
{
......@@ -1060,7 +1072,7 @@ KEY *mrn_create_key_info_for_table(MRN_SHARE *share, TABLE *table, int *error)
if (share->wrap_keys)
{
if (!(wrap_key_info = (KEY *)
my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
mrn_my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
&wrap_key_info, sizeof(*wrap_key_info) * share->wrap_keys,
NullS))
) {
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MRN_VARIABLES_HPP_
#define MRN_VARIABLES_HPP_
#include "mrn_mysql_compat.h"
#ifdef MRN_HAVE_PSI_MEMORY_KEY
extern PSI_memory_key mrn_memory_key;
#endif
#endif /* MRN_VARIABLES_HPP_ */
# Copyright(C) 2012-2013 Kouhei Sutou <kou@clear-code.com>
# Copyright(C) 2012-2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
......@@ -20,9 +20,11 @@ let $version_major_minor =
let $version_55 = `SELECT $version_major_minor = 5.5`;
let $version_56 = `SELECT $version_major_minor = 5.6`;
let $version_57 = `SELECT $version_major_minor = 5.7`;
let $version_100 = `SELECT $version_major_minor = 10.0`;
let $version_55_or_later = `SELECT $version_major_minor >= 5.5`;
let $version_56_or_later = `SELECT $version_major_minor >= 5.6`;
let $version_57_or_later = `SELECT $version_major_minor >= 5.7`;
let $version_100_or_later = `SELECT $version_major_minor >= 10.0`;
--enable_query_log
# Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
if (!$version_57) {
skip This test is for MySQL version 5.7.x;
}
# Copyright(C) 2012-2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
--source ../../include/mroonga/check_mariadb.inc
if ($version_100_or_later) {
if ($mariadb) {
skip This test is not for MariaDB 10.x;
}
}
# Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
--source ../../include/mroonga/check_mariadb.inc
if ($version_57) {
if (!$mariadb) {
skip This test is not for MySQL 5.7.x;
}
}
......@@ -2,8 +2,8 @@ CREATE TABLE tags (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
) DEFAULT CHARSET=utf8;
ALTER TABLE tags ADD COLUMN name VARCHAR(64) COMMENT 'flags "COLUMN_VECTOR"';
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create tags TABLE_PAT_KEY UInt32
column_create tags id COLUMN_SCALAR UInt32
column_create tags name COLUMN_VECTOR ShortText
......
......@@ -5,12 +5,14 @@ CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY
) DEFAULT CHARSET=utf8;
ALTER TABLE bugs ADD COLUMN name VARCHAR(64) COMMENT 'type "tags"';
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create tags TABLE_PAT_KEY UInt32
column_create tags id COLUMN_SCALAR UInt32
table_create bugs TABLE_PAT_KEY UInt32
column_create bugs id COLUMN_SCALAR UInt32
column_create bugs name COLUMN_SCALAR tags
DROP TABLE bugs;
DROP TABLE tags;
......@@ -5,15 +5,13 @@ SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
table_create memos TABLE_NO_KEY
column_create memos content COLUMN_SCALAR ShortText
ALTER TABLE memos ADD FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"';
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create memos TABLE_NO_KEY
column_create memos content COLUMN_SCALAR ShortText
table_create memos-content TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord
column_create memos-content index COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
DROP TABLE IF EXISTS ids;
CREATE TABLE ids (
id INT NOT NULL
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO ids VALUES (1);
INSERT INTO ids VALUES (2);
ALTER TABLE ids ADD PRIMARY KEY (id);
SHOW CREATE TABLE ids;
Table Create Table
ids CREATE TABLE `ids` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
SELECT * FROM ids WHERE id = 2;
id
2
DROP TABLE ids;
......@@ -10,23 +10,39 @@ id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI
column_create terms is_stop_word COLUMN_SCALAR Int8
column_create terms term COLUMN_SCALAR ShortText
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
column_create terms content COLUMN_INDEX|WITH_POSITION memos content
ALTER TABLE terms COMMENT='default_tokenizer "TokenBigram", token_filters "TokenFilterStopWord"';
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord
column_create terms is_stop_word COLUMN_SCALAR Int8
column_create terms term COLUMN_SCALAR ShortText
ALTER TABLE memos DISABLE KEYS;
ALTER TABLE memos ENABLE KEYS;
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord
column_create terms is_stop_word COLUMN_SCALAR Int8
column_create terms term COLUMN_SCALAR ShortText
column_create terms content COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
DROP TABLE terms;
......@@ -8,20 +8,24 @@ id int PRIMARY KEY,
content text NOT NULL,
FULLTEXT INDEX content_index (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
column_create terms term COLUMN_SCALAR ShortText
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
column_create terms content_index COLUMN_INDEX|WITH_POSITION memos content
ALTER TABLE memos DISABLE KEYS;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
column_create terms term COLUMN_SCALAR ShortText
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
DROP TABLE memos, terms;
DROP TABLE memos;
DROP TABLE terms;
DROP TABLE IF EXISTS ids;
CREATE TABLE ids (
id INT PRIMARY KEY
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO ids VALUES (1);
INSERT INTO ids VALUES (2);
ALTER TABLE ids DROP PRIMARY KEY;
SHOW CREATE TABLE ids;
Table Create Table
ids CREATE TABLE `ids` (
`id` int(11) NOT NULL
) ENGINE=Mroonga DEFAULT CHARSET=utf8
SELECT * FROM ids WHERE id = 2;
id
2
DROP TABLE ids;
......@@ -9,20 +9,24 @@ content text NOT NULL,
FULLTEXT INDEX content_index (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
ALTER TABLE memos DISABLE KEYS;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
column_create terms term COLUMN_SCALAR ShortText
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
ALTER TABLE memos ENABLE KEYS;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
column_create terms term COLUMN_SCALAR ShortText
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
column_create terms content_index COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos, terms;
DROP TABLE memos;
DROP TABLE terms;
......@@ -6,115 +6,115 @@ location GEOMETRY NOT NULL
);
INSERT INTO shops (name, location)
VALUES ('nezu-no-taiyaki',
GeomFromText('POINT(139.762573 35.720253)'));
ST_GeomFromText('POINT(139.762573 35.720253)'));
INSERT INTO shops (name, location)
VALUES ('taiyaki-kataoka',
GeomFromText('POINT(139.715591 35.712521)'));
ST_GeomFromText('POINT(139.715591 35.712521)'));
INSERT INTO shops (name, location)
VALUES ('soba-taiyaki-ku',
GeomFromText('POINT(139.659088 35.683712)'));
ST_GeomFromText('POINT(139.659088 35.683712)'));
INSERT INTO shops (name, location)
VALUES ('kuruma',
GeomFromText('POINT(139.706207 35.721516)'));
ST_GeomFromText('POINT(139.706207 35.721516)'));
INSERT INTO shops (name, location)
VALUES ('hirose-ya',
GeomFromText('POINT(139.685608 35.714844)'));
ST_GeomFromText('POINT(139.685608 35.714844)'));
INSERT INTO shops (name, location)
VALUES ('sazare',
GeomFromText('POINT(139.685043 35.714653)'));
ST_GeomFromText('POINT(139.685043 35.714653)'));
INSERT INTO shops (name, location)
VALUES ('omede-taiyaki',
GeomFromText('POINT(139.817154 35.700516)'));
ST_GeomFromText('POINT(139.817154 35.700516)'));
INSERT INTO shops (name, location)
VALUES ('onaga-ya',
GeomFromText('POINT(139.81105 35.698254)'));
ST_GeomFromText('POINT(139.81105 35.698254)'));
INSERT INTO shops (name, location)
VALUES ('shiro-ya',
GeomFromText('POINT(139.638611 35.705517)'));
ST_GeomFromText('POINT(139.638611 35.705517)'));
INSERT INTO shops (name, location)
VALUES ('fuji-ya',
GeomFromText('POINT(139.637115 35.703938)'));
ST_GeomFromText('POINT(139.637115 35.703938)'));
INSERT INTO shops (name, location)
VALUES ('miyoshi',
GeomFromText('POINT(139.537323 35.644539)'));
ST_GeomFromText('POINT(139.537323 35.644539)'));
INSERT INTO shops (name, location)
VALUES ('juju-ya',
GeomFromText('POINT(139.695755 35.628922)'));
ST_GeomFromText('POINT(139.695755 35.628922)'));
INSERT INTO shops (name, location)
VALUES ('tatsumi-ya',
GeomFromText('POINT(139.638657 35.665501)'));
ST_GeomFromText('POINT(139.638657 35.665501)'));
INSERT INTO shops (name, location)
VALUES ('tetsuji',
GeomFromText('POINT(139.76857 35.680912)'));
ST_GeomFromText('POINT(139.76857 35.680912)'));
INSERT INTO shops (name, location)
VALUES ('gazuma-ya',
GeomFromText('POINT(139.647598 35.700817)'));
ST_GeomFromText('POINT(139.647598 35.700817)'));
INSERT INTO shops (name, location)
VALUES ('honma-mon',
GeomFromText('POINT(139.652573 35.722736)'));
ST_GeomFromText('POINT(139.652573 35.722736)'));
INSERT INTO shops (name, location)
VALUES ('naniwa-ya',
GeomFromText('POINT(139.796234 35.730061)'));
ST_GeomFromText('POINT(139.796234 35.730061)'));
INSERT INTO shops (name, location)
VALUES ('kuro-dai',
GeomFromText('POINT(139.704834 35.650345)'));
ST_GeomFromText('POINT(139.704834 35.650345)'));
INSERT INTO shops (name, location)
VALUES ('daruma',
GeomFromText('POINT(139.770599 35.681461)'));
ST_GeomFromText('POINT(139.770599 35.681461)'));
INSERT INTO shops (name, location)
VALUES ('yanagi-ya',
GeomFromText('POINT(139.783981 35.685341)'));
ST_GeomFromText('POINT(139.783981 35.685341)'));
INSERT INTO shops (name, location)
VALUES ('sharaku',
GeomFromText('POINT(139.794846 35.716969)'));
ST_GeomFromText('POINT(139.794846 35.716969)'));
INSERT INTO shops (name, location)
VALUES ('takane',
GeomFromText('POINT(139.560913 35.698601)'));
ST_GeomFromText('POINT(139.560913 35.698601)'));
INSERT INTO shops (name, location)
VALUES ('chiyoda',
GeomFromText('POINT(139.652817 35.642601)'));
ST_GeomFromText('POINT(139.652817 35.642601)'));
INSERT INTO shops (name, location)
VALUES ('da-ka-po',
GeomFromText('POINT(139.727356 35.627346)'));
ST_GeomFromText('POINT(139.727356 35.627346)'));
INSERT INTO shops (name, location)
VALUES ('matsushima-ya',
GeomFromText('POINT(139.737381 35.640556)'));
ST_GeomFromText('POINT(139.737381 35.640556)'));
INSERT INTO shops (name, location)
VALUES ('kazuya',
GeomFromText('POINT(139.760895 35.673508)'));
ST_GeomFromText('POINT(139.760895 35.673508)'));
INSERT INTO shops (name, location)
VALUES ('furuya-kogane-an',
GeomFromText('POINT(139.676071 35.680603)'));
ST_GeomFromText('POINT(139.676071 35.680603)'));
INSERT INTO shops (name, location)
VALUES ('hachi-no-ie',
GeomFromText('POINT(139.668106 35.608021)'));
ST_GeomFromText('POINT(139.668106 35.608021)'));
INSERT INTO shops (name, location)
VALUES ('azuki-chan',
GeomFromText('POINT(139.673203 35.64151)'));
ST_GeomFromText('POINT(139.673203 35.64151)'));
INSERT INTO shops (name, location)
VALUES ('kuriko-an',
GeomFromText('POINT(139.796829 35.712013)'));
ST_GeomFromText('POINT(139.796829 35.712013)'));
INSERT INTO shops (name, location)
VALUES ('yume-no-aru-machi-no-taiyaki-ya-san',
GeomFromText('POINT(139.712524 35.616199)'));
ST_GeomFromText('POINT(139.712524 35.616199)'));
INSERT INTO shops (name, location)
VALUES ('naze-ya',
GeomFromText('POINT(139.665833 35.609039)'));
ST_GeomFromText('POINT(139.665833 35.609039)'));
INSERT INTO shops (name, location)
VALUES ('sanoki-ya',
GeomFromText('POINT(139.770721 35.66592)'));
ST_GeomFromText('POINT(139.770721 35.66592)'));
INSERT INTO shops (name, location)
VALUES ('shigeta',
GeomFromText('POINT(139.780273 35.672626)'));
ST_GeomFromText('POINT(139.780273 35.672626)'));
INSERT INTO shops (name, location)
VALUES ('nishimi-ya',
GeomFromText('POINT(139.774628 35.671825)'));
ST_GeomFromText('POINT(139.774628 35.671825)'));
INSERT INTO shops (name, location)
VALUES ('hiiragi',
GeomFromText('POINT(139.711517 35.647701)'));
ST_GeomFromText('POINT(139.711517 35.647701)'));
ALTER TABLE shops ADD SPATIAL KEY location_index (location);
SELECT id, name, AsText(location) AS location_text FROM shops
WHERE MBRContains(GeomFromText('LineString(139.7727 35.6684, 139.7038 35.7121)'), location)
SELECT id, name, ST_AsText(location) AS location_text FROM shops
WHERE MBRContains(ST_GeomFromText('LineString(139.7727 35.6684, 139.7038 35.7121)'), location)
ORDER BY id;
id name location_text
14 tetsuji POINT(139.76857 35.680911944444446)
......
DROP TABLE IF EXISTS diaries;
SET NAMES utf8mb4;
CREATE TABLE diaries (
content varchar(256) COLLATE utf8mb4_unicode_520_ci,
FULLTEXT INDEX (content)
) DEFAULT CHARSET=utf8mb4;
INSERT INTO diaries VALUES ("Je suis un garçon.");
SELECT * FROM diaries WHERE MATCH (content) AGAINST ("+garcon" IN BOOLEAN MODE);
content
Je suis un garçon.
DROP TABLE diaries;
DROP TABLE IF EXISTS diaries;
SET NAMES utf8mb4;
CREATE TABLE diaries (
content varchar(256) COLLATE utf8mb4_unicode_520_ci,
FULLTEXT INDEX (content)
) DEFAULT CHARSET=utf8mb4;
INSERT INTO diaries VALUES ("ひらがなとカタカナを覚えました。");
SELECT * FROM diaries
WHERE MATCH (content) AGAINST ("+かたかな" IN BOOLEAN MODE);
content
ひらがなとカタカナを覚えました。
DROP TABLE diaries;
......@@ -12,26 +12,17 @@ tags TEXT COMMENT 'flags "COLUMN_VECTOR", type "tags"',
FULLTEXT INDEX bugs_tags_index (tags) COMMENT 'table "tags"'
) DEFAULT CHARSET=utf8;
INSERT INTO bugs (id, tags) VALUES (1, "Linux MySQL groonga");
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no --dump_records no");
mroonga_command("dump --dump_plugins no --dump_records no")
table_create tags TABLE_PAT_KEY ShortText --default_tokenizer TokenDelimit
column_create tags name COLUMN_SCALAR ShortText
table_create bugs TABLE_PAT_KEY UInt32
column_create bugs id COLUMN_SCALAR UInt32
column_create bugs tags COLUMN_VECTOR tags
column_create tags bugs_tags_index COLUMN_INDEX|WITH_POSITION bugs tags
load --table tags
[
["_key","name"],
["Linux",""],
["MySQL",""],
["groonga",""]
]
load --table bugs
[
["_key","id","tags"],
[1,1,["Linux","MySQL","groonga"]]
]
SELECT *, MATCH (tags) AGAINST ("+MySQL" IN BOOLEAN MODE) AS score
FROM bugs
WHERE MATCH (tags) AGAINST ("+MySQL" IN BOOLEAN MODE);
......
......@@ -13,28 +13,17 @@ INDEX bugs_priority_index (priority) COMMENT 'table "priorities"'
INSERT INTO bugs (id, priority) VALUES (1, 10);
INSERT INTO bugs (id, priority) VALUES (2, 3);
INSERT INTO bugs (id, priority) VALUES (3, -2);
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no --dump_records no");
mroonga_command("dump --dump_plugins no --dump_records no")
table_create priorities TABLE_PAT_KEY Int32
column_create priorities id COLUMN_SCALAR Int32
table_create bugs TABLE_PAT_KEY UInt32
column_create bugs id COLUMN_SCALAR UInt32
column_create bugs priority COLUMN_SCALAR priorities
column_create priorities bugs_priority_index COLUMN_INDEX|WITH_POSITION bugs priority
load --table priorities
[
["_key","id"],
[-2,0],
[3,0],
[10,0]
]
load --table bugs
[
["_key","id","priority"],
[1,1,10],
[2,2,3],
[3,3,-2]
]
SELECT *
FROM bugs
WHERE priority = 3;
......
......@@ -3,8 +3,8 @@ name VARCHAR(64) PRIMARY KEY
) DEFAULT CHARSET=utf8
COLLATE=utf8_bin
COMMENT='default_tokenizer "TokenDelimit"';
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create tags TABLE_PAT_KEY ShortText --default_tokenizer TokenDelimit
column_create tags name COLUMN_SCALAR ShortText
DROP TABLE tags;
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'index_flags "NONE"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump --dump_plugins no --dump_schema no");
mroonga_command("dump --dump_plugins no --dump_schema no")
column_create memos-content index COLUMN_INDEX memos content
DROP TABLE memos;
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'index_flags "WITH_POSITION|WITH_WEIGHT"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump --dump_plugins no --dump_schema no");
mroonga_command("dump --dump_plugins no --dump_schema no")
column_create memos-content index COLUMN_INDEX|WITH_WEIGHT|WITH_POSITION memos content
DROP TABLE memos;
DROP TABLE IF EXISTS memos;
DROP TABLE IF EXISTS terms;
SET NAMES utf8;
CREATE TABLE terms (
term VARCHAR(64) NOT NULL,
PRIMARY KEY (term) USING HASH
) COMMENT='default_tokenizer "TokenBigram", normalizer "NormalizerAuto"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
INSERT INTO memos VALUES (1, "1日の消費㌍は約2000㌔㌍");
SELECT * FROM memos
WHERE MATCH (content) AGAINST ("+カロリー" IN BOOLEAN MODE);
id content
1 1日の消費㌍は約2000㌔㌍
DROP TABLE memos;
DROP TABLE terms;
......@@ -5,12 +5,14 @@ CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY,
tag VARCHAR(64) COMMENT 'type "tags"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create tags TABLE_PAT_KEY ShortText
column_create tags name COLUMN_SCALAR ShortText
table_create bugs TABLE_PAT_KEY UInt32
column_create bugs id COLUMN_SCALAR UInt32
column_create bugs tag COLUMN_SCALAR tags
DROP TABLE bugs;
DROP TABLE tags;
......@@ -6,10 +6,12 @@ CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord,TokenFilterStopWord"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create memos TABLE_NO_KEY
column_create memos content COLUMN_SCALAR ShortText
table_create memos-content TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord,TokenFilterStopWord
column_create memos-content index COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
......@@ -6,10 +6,12 @@ CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create memos TABLE_NO_KEY
column_create memos content COLUMN_SCALAR ShortText
table_create memos-content TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord
column_create memos-content index COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
......@@ -10,14 +10,16 @@ id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord,TokenFilterStopWord
column_create terms is_stop_word COLUMN_SCALAR Int8
column_create terms term COLUMN_SCALAR ShortText
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
column_create terms content COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
DROP TABLE terms;
......@@ -10,14 +10,16 @@ id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord
column_create terms is_stop_word COLUMN_SCALAR Int8
column_create terms term COLUMN_SCALAR ShortText
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
column_create terms content COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
DROP TABLE terms;
......@@ -2,8 +2,8 @@ CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY,
tags TEXT COMMENT 'flags "COLUMN_VECTOR"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create bugs TABLE_PAT_KEY UInt32
column_create bugs id COLUMN_SCALAR UInt32
column_create bugs tags COLUMN_VECTOR LongText
......
DROP TABLE IF EXISTS memos;
SET NAMES utf8;
CREATE TABLE memos (
id INT PRIMARY KEY,
title VARCHAR(255),
content TEXT,
FULLTEXT INDEX (title, content)
) DEFAULT CHARSET=utf8;
INSERT INTO memos VALUES(1, "Groonga", "Groonga is fast.");
INSERT INTO memos VALUES(2, "Mroonga", "Mroonga is also fast.");
INSERT INTO memos VALUES(3, "Rroonga", "Rroonga is also fast.");
SELECT *,
MATCH(title, content)
AGAINST("*W1:10,2:2DOR Groonga Mroonga" in BOOLEAN MODE) AS score
FROM memos
WHERE MATCH(title, content)
AGAINST("*W1:10,2:2DOR Groonga Mroonga" in BOOLEAN MODE);
id title content score
1 Groonga Groonga is fast. 12
2 Mroonga Mroonga is also fast. 12
DROP TABLE memos;
......@@ -43,24 +43,4 @@ select * from t2 where c2>"s" order by c1 asc;
c1 c2
4 sa si su se so
5 ta ti ii ii to
select * from t1 where match(c2) against("ii") order by match(c2) against("ii") desc;
c1 c2
3 aa ii ii ii oo
5 ta ti ii ii to
1 aa ii uu ee oo
select * from t2 where match(c2) against("ii") order by match(c2) against("ii") asc;
c1 c2
1 aa ii uu ee oo
5 ta ti ii ii to
3 aa ii ii ii oo
select c1,c2,match(c2) against("ii") from t1 where match(c2) against("ii");
c1 c2 match(c2) against("ii")
1 aa ii uu ee oo 174763
3 aa ii ii ii oo 524289
5 ta ti ii ii to 349526
select c1,c2,match(c2) against("ii") from t2 where match(c2) against("ii");
c1 c2 match(c2) against("ii")
1 aa ii uu ee oo 174763
3 aa ii ii ii oo 524289
5 ta ti ii ii to 349526
drop table t1,t2;
DROP TABLE IF EXISTS logs;
SET NAMES UTF8;
CREATE TABLE logs(
message TEXT,
FULLTEXT KEY (message)
) DEFAULT CHARSET=utf8;
INSERT INTO logs VALUES("Error Error Error");
INSERT INTO logs VALUES("Warning Warning Warning");
INSERT INTO logs VALUES("Error Error");
INSERT INTO logs VALUES("Warning Warning");
INSERT INTO logs VALUES("Error");
INSERT INTO logs VALUES("Warning");
INSERT INTO logs VALUES("Error Error Error Error");
INSERT INTO logs VALUES("Warning Warning Warning Warning");
SELECT * FROM logs;
message
Error Error Error
Warning Warning Warning
Error Error
Warning Warning
Error
Warning
Error Error Error Error
Warning Warning Warning Warning
SELECT *, MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE) AS score
FROM logs
WHERE MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE)
ORDER BY MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE) ASC;
message score
Error 174763
Error Error 349526
Error Error Error 524289
Error Error Error Error 699052
DROP TABLE logs;
DROP TABLE IF EXISTS logs;
SET NAMES UTF8;
CREATE TABLE logs(
message TEXT,
FULLTEXT KEY (message)
) DEFAULT CHARSET=utf8;
INSERT INTO logs VALUES("Error Error Error");
INSERT INTO logs VALUES("Warning Warning Warning");
INSERT INTO logs VALUES("Error Error");
INSERT INTO logs VALUES("Warning Warning");
INSERT INTO logs VALUES("Error");
INSERT INTO logs VALUES("Warning");
INSERT INTO logs VALUES("Error Error Error Error");
INSERT INTO logs VALUES("Warning Warning Warning Warning");
SELECT * FROM logs;
message
Error Error Error
Warning Warning Warning
Error Error
Warning Warning
Error
Warning
Error Error Error Error
Warning Warning Warning Warning
SELECT *, MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE) AS score
FROM logs
WHERE MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE)
ORDER BY MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE) DESC;
message score
Error Error Error Error 699052
Error Error Error 524289
Error Error 349526
Error 174763
DROP TABLE logs;
DROP TABLE IF EXISTS logs;
SET NAMES UTF8;
CREATE TABLE logs(
message TEXT,
FULLTEXT KEY (message)
) DEFAULT CHARSET=utf8;
INSERT INTO logs VALUES("Error Error Error");
INSERT INTO logs VALUES("Warning Warning Warning");
INSERT INTO logs VALUES("Error Error");
INSERT INTO logs VALUES("Warning Warning");
INSERT INTO logs VALUES("Error");
INSERT INTO logs VALUES("Warning");
INSERT INTO logs VALUES("Error Error Error Error");
INSERT INTO logs VALUES("Warning Warning Warning Warning");
SELECT * FROM logs;
message
Error Error Error
Warning Warning Warning
Error Error
Warning Warning
Error
Warning
Error Error Error Error
Warning Warning Warning Warning
SELECT *, MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE) AS score
FROM logs
WHERE MATCH(message) AGAINST("Error Warning" IN NATURAL LANGUAGE MODE)
ORDER BY MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE);
message score
Error 174763
Error Error 349526
Error Error Error 524289
Error Error Error Error 699052
DROP TABLE logs;
DROP TABLE IF EXISTS logs;
SET NAMES UTF8;
CREATE TABLE logs(
message TEXT,
host TEXT,
FULLTEXT KEY (message),
FULLTEXT KEY (host)
) DEFAULT CHARSET=utf8;
INSERT INTO logs VALUES("Error Error Error", "host1");
INSERT INTO logs VALUES("Warning Warning Warning", "host1");
INSERT INTO logs VALUES("Error Error", "host2");
INSERT INTO logs VALUES("Warning Warning", "host2");
INSERT INTO logs VALUES("Error", "host2");
INSERT INTO logs VALUES("Warning", "host2");
INSERT INTO logs VALUES("Error Error Error Error", "host2");
INSERT INTO logs VALUES("Warning Warning Warning Warning", "host2");
SELECT * FROM logs;
message host
Error Error Error host1
Warning Warning Warning host1
Error Error host2
Warning Warning host2
Error host2
Warning host2
Error Error Error Error host2
Warning Warning Warning Warning host2
SELECT *, MATCH(host) AGAINST("host2" IN NATURAL LANGUAGE MODE) AS score
FROM logs
WHERE MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE)
ORDER BY MATCH(host) AGAINST("host2" IN NATURAL LANGUAGE MODE);
message host score
Error Error Error host1 0
Error Error host2 116509
Error host2 116509
Error Error Error Error host2 116509
DROP TABLE logs;
DROP TABLE IF EXISTS logs;
SET NAMES UTF8;
CREATE TABLE logs(
message TEXT,
FULLTEXT KEY (message)
) DEFAULT CHARSET=utf8;
INSERT INTO logs VALUES("Error Error Error");
INSERT INTO logs VALUES("Warning Warning Warning");
INSERT INTO logs VALUES("Error Error");
INSERT INTO logs VALUES("Warning Warning");
INSERT INTO logs VALUES("Error");
INSERT INTO logs VALUES("Warning");
INSERT INTO logs VALUES("Error Error Error Error");
INSERT INTO logs VALUES("Warning Warning Warning Warning");
SELECT * FROM logs;
message
Error Error Error
Warning Warning Warning
Error Error
Warning Warning
Error
Warning
Error Error Error Error
Warning Warning Warning Warning
SELECT *, MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE) AS score
FROM logs
ORDER BY MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE);
message score
Warning Warning Warning 0
Warning Warning 0
Warning 0
Warning Warning Warning Warning 0
Error 174763
Error Error 349526
Error Error Error 524289
Error Error Error Error 699052
DROP TABLE logs;
DROP TABLE IF EXISTS logs;
SET NAMES UTF8;
CREATE TABLE logs(
message TEXT,
FULLTEXT KEY (message)
) DEFAULT CHARSET=utf8;
INSERT INTO logs VALUES("Error Error Error");
INSERT INTO logs VALUES("Warning Warning Warning");
INSERT INTO logs VALUES("Error Error");
INSERT INTO logs VALUES("Warning Warning");
INSERT INTO logs VALUES("Error");
INSERT INTO logs VALUES("Warning");
INSERT INTO logs VALUES("Error Error Error Error");
INSERT INTO logs VALUES("Warning Warning Warning Warning");
SELECT * FROM logs;
message
Error Error Error
Warning Warning Warning
Error Error
Warning Warning
Error
Warning
Error Error Error Error
Warning Warning Warning Warning
SELECT *, MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE) AS score
FROM logs
WHERE MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE)
ORDER BY MATCH(message) AGAINST("Error" IN NATURAL LANGUAGE MODE);
message score
Error 174763
Error Error 349526
Error Error Error 524289
Error Error Error Error 699052
DROP TABLE logs;
......@@ -6,8 +6,8 @@ INSERT INTO shops VALUES (NULL), (NULL);
Warnings:
Warning 1048 Column 'location' cannot be null
Warning 1048 Column 'location' cannot be null
SELECT AsText(location) FROM shops;
AsText(location)
SELECT ST_AsText(location) FROM shops;
ST_AsText(location)
POINT(0 0)
POINT(0 0)
DROP TABLE shops;
DROP TABLE IF EXISTS shops;
CREATE TABLE shops (
location GEOMETRY NOT NULL
);
SET SESSION sql_mode = '';
INSERT INTO shops VALUES (NULL), (NULL);
Warnings:
Warning 1048 Column 'location' cannot be null
SET SESSION sql_mode = default;
SELECT ST_AsText(location) FROM shops;
ST_AsText(location)
POINT(0 0)
POINT(0 0)
DROP TABLE shops;
......@@ -16,113 +16,113 @@ shops CREATE TABLE `shops` (
) ENGINE=Mroonga DEFAULT CHARSET=latin1
INSERT INTO shops (name, location)
VALUES ('nezu-no-taiyaki',
GeomFromText('POINT(139.762573 35.720253)'));
ST_GeomFromText('POINT(139.762573 35.720253)'));
INSERT INTO shops (name, location)
VALUES ('taiyaki-kataoka',
GeomFromText('POINT(139.715591 35.712521)'));
ST_GeomFromText('POINT(139.715591 35.712521)'));
INSERT INTO shops (name, location)
VALUES ('soba-taiyaki-ku',
GeomFromText('POINT(139.659088 35.683712)'));
ST_GeomFromText('POINT(139.659088 35.683712)'));
INSERT INTO shops (name, location)
VALUES ('kuruma',
GeomFromText('POINT(139.706207 35.721516)'));
ST_GeomFromText('POINT(139.706207 35.721516)'));
INSERT INTO shops (name, location)
VALUES ('hirose-ya',
GeomFromText('POINT(139.685608 35.714844)'));
ST_GeomFromText('POINT(139.685608 35.714844)'));
INSERT INTO shops (name, location)
VALUES ('sazare',
GeomFromText('POINT(139.685043 35.714653)'));
ST_GeomFromText('POINT(139.685043 35.714653)'));
INSERT INTO shops (name, location)
VALUES ('omede-taiyaki',
GeomFromText('POINT(139.817154 35.700516)'));
ST_GeomFromText('POINT(139.817154 35.700516)'));
INSERT INTO shops (name, location)
VALUES ('onaga-ya',
GeomFromText('POINT(139.81105 35.698254)'));
ST_GeomFromText('POINT(139.81105 35.698254)'));
INSERT INTO shops (name, location)
VALUES ('shiro-ya',
GeomFromText('POINT(139.638611 35.705517)'));
ST_GeomFromText('POINT(139.638611 35.705517)'));
INSERT INTO shops (name, location)
VALUES ('fuji-ya',
GeomFromText('POINT(139.637115 35.703938)'));
ST_GeomFromText('POINT(139.637115 35.703938)'));
INSERT INTO shops (name, location)
VALUES ('miyoshi',
GeomFromText('POINT(139.537323 35.644539)'));
ST_GeomFromText('POINT(139.537323 35.644539)'));
INSERT INTO shops (name, location)
VALUES ('juju-ya',
GeomFromText('POINT(139.695755 35.628922)'));
ST_GeomFromText('POINT(139.695755 35.628922)'));
INSERT INTO shops (name, location)
VALUES ('tatsumi-ya',
GeomFromText('POINT(139.638657 35.665501)'));
ST_GeomFromText('POINT(139.638657 35.665501)'));
INSERT INTO shops (name, location)
VALUES ('tetsuji',
GeomFromText('POINT(139.76857 35.680912)'));
ST_GeomFromText('POINT(139.76857 35.680912)'));
INSERT INTO shops (name, location)
VALUES ('gazuma-ya',
GeomFromText('POINT(139.647598 35.700817)'));
ST_GeomFromText('POINT(139.647598 35.700817)'));
INSERT INTO shops (name, location)
VALUES ('honma-mon',
GeomFromText('POINT(139.652573 35.722736)'));
ST_GeomFromText('POINT(139.652573 35.722736)'));
INSERT INTO shops (name, location)
VALUES ('naniwa-ya',
GeomFromText('POINT(139.796234 35.730061)'));
ST_GeomFromText('POINT(139.796234 35.730061)'));
INSERT INTO shops (name, location)
VALUES ('kuro-dai',
GeomFromText('POINT(139.704834 35.650345)'));
ST_GeomFromText('POINT(139.704834 35.650345)'));
INSERT INTO shops (name, location)
VALUES ('daruma',
GeomFromText('POINT(139.770599 35.681461)'));
ST_GeomFromText('POINT(139.770599 35.681461)'));
INSERT INTO shops (name, location)
VALUES ('yanagi-ya',
GeomFromText('POINT(139.783981 35.685341)'));
ST_GeomFromText('POINT(139.783981 35.685341)'));
INSERT INTO shops (name, location)
VALUES ('sharaku',
GeomFromText('POINT(139.794846 35.716969)'));
ST_GeomFromText('POINT(139.794846 35.716969)'));
INSERT INTO shops (name, location)
VALUES ('takane',
GeomFromText('POINT(139.560913 35.698601)'));
ST_GeomFromText('POINT(139.560913 35.698601)'));
INSERT INTO shops (name, location)
VALUES ('chiyoda',
GeomFromText('POINT(139.652817 35.642601)'));
ST_GeomFromText('POINT(139.652817 35.642601)'));
INSERT INTO shops (name, location)
VALUES ('da-ka-po',
GeomFromText('POINT(139.727356 35.627346)'));
ST_GeomFromText('POINT(139.727356 35.627346)'));
INSERT INTO shops (name, location)
VALUES ('matsushima-ya',
GeomFromText('POINT(139.737381 35.640556)'));
ST_GeomFromText('POINT(139.737381 35.640556)'));
INSERT INTO shops (name, location)
VALUES ('kazuya',
GeomFromText('POINT(139.760895 35.673508)'));
ST_GeomFromText('POINT(139.760895 35.673508)'));
INSERT INTO shops (name, location)
VALUES ('furuya-kogane-an',
GeomFromText('POINT(139.676071 35.680603)'));
ST_GeomFromText('POINT(139.676071 35.680603)'));
INSERT INTO shops (name, location)
VALUES ('hachi-no-ie',
GeomFromText('POINT(139.668106 35.608021)'));
ST_GeomFromText('POINT(139.668106 35.608021)'));
INSERT INTO shops (name, location)
VALUES ('azuki-chan',
GeomFromText('POINT(139.673203 35.64151)'));
ST_GeomFromText('POINT(139.673203 35.64151)'));
INSERT INTO shops (name, location)
VALUES ('kuriko-an',
GeomFromText('POINT(139.796829 35.712013)'));
ST_GeomFromText('POINT(139.796829 35.712013)'));
INSERT INTO shops (name, location)
VALUES ('yume-no-aru-machi-no-taiyaki-ya-san',
GeomFromText('POINT(139.712524 35.616199)'));
ST_GeomFromText('POINT(139.712524 35.616199)'));
INSERT INTO shops (name, location)
VALUES ('naze-ya',
GeomFromText('POINT(139.665833 35.609039)'));
ST_GeomFromText('POINT(139.665833 35.609039)'));
INSERT INTO shops (name, location)
VALUES ('sanoki-ya',
GeomFromText('POINT(139.770721 35.66592)'));
ST_GeomFromText('POINT(139.770721 35.66592)'));
INSERT INTO shops (name, location)
VALUES ('shigeta',
GeomFromText('POINT(139.780273 35.672626)'));
ST_GeomFromText('POINT(139.780273 35.672626)'));
INSERT INTO shops (name, location)
VALUES ('nishimi-ya',
GeomFromText('POINT(139.774628 35.671825)'));
ST_GeomFromText('POINT(139.774628 35.671825)'));
INSERT INTO shops (name, location)
VALUES ('hiiragi',
GeomFromText('POINT(139.711517 35.647701)'));
SELECT id, name, AsText(location) AS location_text FROM shops;
ST_GeomFromText('POINT(139.711517 35.647701)'));
SELECT id, name, ST_AsText(location) AS location_text FROM shops;
id name location_text
1 nezu-no-taiyaki POINT(139.76257305555555 35.72025305555556)
2 taiyaki-kataoka POINT(139.7155911111111 35.712521111111116)
......@@ -160,8 +160,8 @@ id name location_text
34 shigeta POINT(139.78027305555557 35.67262611111111)
35 nishimi-ya POINT(139.77462805555555 35.671825)
36 hiiragi POINT(139.71151694444444 35.64770111111111)
SELECT id, name, AsText(location) AS location_text FROM shops
WHERE MBRContains(GeomFromText('LineString(139.7727 35.6684, 139.7038 35.7121)'), location)
SELECT id, name, ST_AsText(location) AS location_text FROM shops
WHERE MBRContains(ST_GeomFromText('LineString(139.7727 35.6684, 139.7038 35.7121)'), location)
ORDER BY id;
id name location_text
14 tetsuji POINT(139.76857 35.680911944444446)
......
DROP TABLE IF EXISTS ids;
SET NAMES UTF8;
CREATE TABLE ids (
id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT,
value INT(10),
INDEX (value)
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO ids VALUES(1, 50);
INSERT INTO ids VALUES(2, 70);
INSERT INTO ids VALUES(3, 30);
INSERT INTO ids VALUES(4, 90);
INSERT INTO ids VALUES(5, 10);
SELECT id, value FROM ids WHERE value > 10 ORDER BY value ASC LIMIT 3;
id value
3 30
1 50
2 70
DROP TABLE ids;
DROP TABLE IF EXISTS ids;
SET NAMES UTF8;
CREATE TABLE ids (
id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT,
value INT(10),
INDEX (value)
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO ids VALUES(1, 50);
INSERT INTO ids VALUES(2, 70);
INSERT INTO ids VALUES(3, 30);
INSERT INTO ids VALUES(4, 90);
INSERT INTO ids VALUES(5, 10);
SELECT id, value FROM ids WHERE value > 10 ORDER BY value DESC LIMIT 3;
id value
4 90
2 70
1 50
DROP TABLE ids;
DROP TABLE IF EXISTS ids;
SET NAMES UTF8;
CREATE TABLE ids (
id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT,
value INT(10),
INDEX (value)
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO ids VALUES(1, 50);
INSERT INTO ids VALUES(2, 70);
INSERT INTO ids VALUES(3, 30);
INSERT INTO ids VALUES(4, 90);
INSERT INTO ids VALUES(5, 10);
SELECT id, value FROM ids WHERE value >= 30 ORDER BY value ASC LIMIT 3;
id value
3 30
1 50
2 70
DROP TABLE ids;
DROP TABLE IF EXISTS ids;
SET NAMES UTF8;
CREATE TABLE ids (
id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT,
value INT(10),
INDEX (value)
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO ids VALUES(1, 50);
INSERT INTO ids VALUES(2, 70);
INSERT INTO ids VALUES(3, 30);
INSERT INTO ids VALUES(4, 90);
INSERT INTO ids VALUES(5, 10);
SELECT id, value FROM ids WHERE value >= 30 ORDER BY value DESC LIMIT 3;
id value
4 90
2 70
1 50
DROP TABLE ids;
DROP TABLE IF EXISTS ids;
SET NAMES UTF8;
CREATE TABLE ids (
id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT,
value INT(10),
INDEX (value)
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO ids VALUES(1, 50);
INSERT INTO ids VALUES(2, 70);
INSERT INTO ids VALUES(3, 30);
INSERT INTO ids VALUES(4, 90);
INSERT INTO ids VALUES(5, 10);
SELECT id, value FROM ids WHERE value < 90 ORDER BY value ASC LIMIT 3;
id value
5 10
3 30
1 50
DROP TABLE ids;
DROP TABLE IF EXISTS ids;
SET NAMES UTF8;
CREATE TABLE ids (
id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT,
value INT(10),
INDEX (value)
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO ids VALUES(1, 50);
INSERT INTO ids VALUES(2, 70);
INSERT INTO ids VALUES(3, 30);
INSERT INTO ids VALUES(4, 90);
INSERT INTO ids VALUES(5, 10);
SELECT id, value FROM ids WHERE value < 90 ORDER BY value DESC LIMIT 3;
id value
2 70
1 50
3 30
DROP TABLE ids;
DROP TABLE IF EXISTS ids;
SET NAMES UTF8;
CREATE TABLE ids (
id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT,
value INT(10),
INDEX (value)
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO ids VALUES(1, 50);
INSERT INTO ids VALUES(2, 70);
INSERT INTO ids VALUES(3, 30);
INSERT INTO ids VALUES(4, 90);
INSERT INTO ids VALUES(5, 10);
SELECT id, value FROM ids WHERE value <= 70 ORDER BY value ASC LIMIT 3;
id value
5 10
3 30
1 50
DROP TABLE ids;
DROP TABLE IF EXISTS ids;
SET NAMES UTF8;
CREATE TABLE ids (
id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT,
value INT(10),
INDEX (value)
) ENGINE=Mroonga DEFAULT CHARSET=utf8;
INSERT INTO ids VALUES(1, 50);
INSERT INTO ids VALUES(2, 70);
INSERT INTO ids VALUES(3, 30);
INSERT INTO ids VALUES(4, 90);
INSERT INTO ids VALUES(5, 10);
SELECT id, value FROM ids WHERE value <= 70 ORDER BY value DESC LIMIT 3;
id value
2 70
1 50
3 30
DROP TABLE ids;
select PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_TYPE
from information_schema.plugins where plugin_name = "Mroonga";
PLUGIN_NAME PLUGIN_VERSION PLUGIN_TYPE
Mroonga 5.0 STORAGE ENGINE
DROP TABLE IF EXISTS ids;
FLUSH STATUS;
SET NAMES utf8mb4;
CREATE TABLE ids (
id int PRIMARY KEY,
text varchar(32),
FULLTEXT INDEX (text)
) DEFAULT CHARSET=utf8mb4;
INSERT INTO ids VALUES (1, 'first');
SELECT * FROM ids
WHERE MATCH(text) AGAINST('+first' IN BOOLEAN MODE)
ORDER BY id, id
LIMIT 1;
id text
1 first
SHOW STATUS LIKE 'mroonga_fast_order_limit';
Variable_name Value
Mroonga_fast_order_limit 1
DROP TABLE ids;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment