<commit_before>/* -*- c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
  Copyright(C) 2010 <NAME>
  Copyright(C) 2010-2012 <NAME>
  Copyright(C) 2011-2012 <NAME> <<EMAIL>>

  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
*/

#ifndef _ha_mroonga_hpp
#define _ha_mroonga_hpp

#ifdef USE_PRAGMA_INTERFACE
#pragma interface
#endif

#ifdef __cplusplus
extern "C" {
#endif

#include <groonga.h>
#include "mrn_sys.hpp"
#include "mrn_mysql_compat.h"

#if (MYSQL_VERSION_ID >= 50603) || \
    (MYSQL_VERSION_ID >= 50513 && MYSQL_VERSION_ID < 50600) || \
    (MYSQL_VERSION_ID >= 50158 && MYSQL_VERSION_ID < 50500)
#  define MRN_HANDLER_CLONE_NEED_NAME 1
#endif

#if (MYSQL_VERSION_ID >= 50514 && MYSQL_VERSION_ID < 50600)
#  define MRN_HANDLER_HAVE_FINAL_ADD_INDEX 1
#endif

#if (MYSQL_VERSION_ID >= 50603) || \
    (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50209)
#  define MRN_HANDLER_HAVE_HA_RND_NEXT 1
#  define MRN_HANDLER_HAVE_HA_RND_POS 1
#  define MRN_HANDLER_HAVE_HA_INDEX_READ_MAP 1
#  define MRN_HANDLER_HAVE_HA_INDEX_READ_IDX_MAP 1
#  define MRN_HANDLER_HAVE_HA_INDEX_NEXT 1
#  define MRN_HANDLER_HAVE_HA_INDEX_PREV 1
#  define MRN_HANDLER_HAVE_HA_INDEX_FIRST 1
#  define MRN_HANDLER_HAVE_HA_INDEX_LAST 1
#  define MRN_HANDLER_HAVE_HA_INDEX_NEXT_SAME 1
#endif

#if (MYSQL_VERSION_ID >= 50604) || \
    (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50302)
#  define MRN_HANDLER_HAVE_HA_CLOSE 1
#  define MRN_HANDLER_HAVE_MULTI_RANGE_READ 1
#endif

#if (MYSQL_VERSION_ID >= 50607)
// TODO
#  define MRN_HANDLER_HAVE_CHECK_IF_SUPPORTED_INPLACE_ALTER 1
#  define MRN_HANDLER_HAVE_HA_PREPARE_INPLACE_ALTER_TABLE 1
#  define MRN_HANDLER_HAVE_HA_INPLACE_ALTER_TABLE 1
#  define MRN_HANDLER_HAVE_HA_COMMIT_INPLACE_ALTER_TABLE 1
#endif

#ifndef MRN_MARIADB_P
#  define MRN_HANDLER_HAVE_INDEX_READ_LAST_MAP
#endif

#if (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50302)
#  define MRN_HANDLER_HAVE_MULTI_RANGE_READ_INFO_KEY_PARTS
#endif

#if MYSQL_VERSION_ID >= 50500
#  define MRN_HANDLER_HAVE_TRUNCATE
#  define MRN_HANDLER_HAVE_GET_PARENT_FOREIGN_KEY_LIST
#endif

#if (MYSQL_VERSION_ID < 50600)
#  define MRN_HANDLER_HAVE_GET_TABLESPACE_NAME 1
#endif

#if MYSQL_VERSION_ID >= 50500
#  define MRN_TABLE_LIST_INIT_REQUIRE_ALIAS
#endif

#ifdef BIG_TABLES
#  define MRN_HA_ROWS_FORMAT "llu"
#else
#  define MRN_HA_ROWS_FORMAT "lu"
#endif

#if (MYSQL_VERSION_ID < 50519) || \
    defined(MRN_MARIADB_P) || \
    (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID < 50604)
#  define MRN_NEED_FREE_STRING_MEMALLOC_PLUGIN_VAR
#endif

#if MYSQL_VERSION_ID >= 50500
#  define MRN_HAVE_HA_EXTRA_ADD_CHILDREN_LIST
#  define MRN_HAVE_HA_EXTRA_IS_ATTACHED_CHILDREN
#endif

#ifdef MRN_MARIADB_P
#  define MRN_HAVE_HA_EXTRA_DETACH_CHILD
#  define MRN_HAVE_HA_EXTRA_PREPARE_FOR_FORCED_CLOSE
#endif

#if MYSQL_VERSION_ID >= 50607
#  define MRN_HAVE_HA_EXTRA_EXPORT
#endif

#if MYSQL_VERSION_ID >= 50604
#  define MRN_TIMESTAMP_USE_TIMEVAL
#elif defined(MRN_MARIADB_P)
#  define MRN_TIMESTAMP_USE_MY_TIME_T
#else
#  define MRN_TIMESTAMP_USE_LONG
#endif

#if MYSQL_VERSION_ID < 50600 && !defined(MRN_MARIADB_P)
#  define MRN_FIELD_STORE_TIME_NEED_TYPE
#endif

#if MYSQL_VERSION_ID < 50500
#  define MRN_HAVE_TL_WRITE_ALLOW_READ
#endif

#if (defined(MRN_MARIADB_P) && \
     ((MYSQL_VERSION_ID >= 50306 && MYSQL_VERSION_ID < 50500) || \
      MYSQL_VERSION_ID >= 50523))
#  define MRN_HANDLER_AUTO_REPAIR_HAVE_ERROR
#endif

#if MYSQL_VERSION_ID >= 50604
#  define MRN_JOIN_TAB_HAVE_CONDITION
#endif

#if MYSQL_VERSION_ID >= 50607
#  define MRN_ITEM_HAVE_ITEM_NAME
#endif

#if MYSQL_VERSION_ID < 50600
#  define MRN_RBR_UPDATE_NEED_ALL_COLUMNS
#endif

#if MYSQL_VERSION_ID >= 50500
#  define MRN_ROW_BASED_CHECK_IS_METHOD
#  define MRN_OPTION_BITS_IS_UNDER_VARIABLES
#endif

#if MYSQL_VERSION_ID >= 50600
#  define MRN_HAVE_HA_REBIND_PSI
#endif

#if MYSQL_VERSION_ID >= 50500
#  define MRN_GET_ERROR_MESSAGE current_thd->stmt_da->message()
#else
#  define MRN_GET_ERROR_MESSAGE current_thd->main_da.message()
#endif

#if defined(_WIN32) || defined(_WIN64)
#  define MRN_API __declspec(dllexport)
#else
#  define MRN_API
#endif

class ha_mroonga;

/* structs */
struct st_mrn_ft_info
{
  struct _ft_vft *please;
  grn_ctx *ctx;
  grn_obj *table;
  grn_obj *result;
  grn_obj *score_column;
  grn_obj key;
  grn_obj score;
  uint active_index;
  KEY *key_info;
  KEY *primary_key_info;
  ha_mroonga *mroonga;<commit_msg>mysql56: use THD::get_stmd_da() to get the current statement<commit_after>/* -*- c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
  Copyright(C) 2010 <NAME>
  Copyright(C) 2010-2012 <NAME>
  Copyright(C) 2011-2012 <NAME> <<EMAIL>>

  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
*/

#ifndef _ha_mroonga_hpp
#define _ha_mroonga_hpp

#ifdef USE_PRAGMA_INTERFACE
#pragma interface
#endif

#ifdef __cplusplus
extern "C" {
#endif

#include <groonga.h>
#include "mrn_sys.hpp"
#include "mrn_mysql_compat.h"

#if (MYSQL_VERSION_ID >= 50603) || \
    (MYSQL_VERSION_ID >= 50513 && MYSQL_VERSION_ID < 50600) || \
    (MYSQL_VERSION_ID >= 50158 && MYSQL_VERSION_ID < 50500)
#  define MRN_HANDLER_CLONE_NEED_NAME 1
#endif

#if (MYSQL_VERSION_ID >= 50514 && MYSQL_VERSION_ID < 50600)
#  define MRN_HANDLER_HAVE_FINAL_ADD_INDEX 1
#endif

#if (MYSQL_VERSION_ID >= 50603) || \
    (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50209)
#  define MRN_HANDLER_HAVE_HA_RND_NEXT 1
#  define MRN_HANDLER_HAVE_HA_RND_POS 1
#  define MRN_HANDLER_HAVE_HA_INDEX_READ_MAP 1
#  define MRN_HANDLER_HAVE_HA_INDEX_READ_IDX_MAP 1
#  define MRN_HANDLER_HAVE_HA_INDEX_NEXT 1
#  define MRN_HANDLER_HAVE_HA_INDEX_PREV 1
#  define MRN_HANDLER_HAVE_HA_INDEX_FIRST 1
#  define MRN_HANDLER_HAVE_HA_INDEX_LAST 1
#  define MRN_HANDLER_HAVE_HA_INDEX_NEXT_SAME 1
#endif

#if (MYSQL_VERSION_ID >= 50604) || \
    (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50302)
#  define MRN_HANDLER_HAVE_HA_CLOSE 1
#  define MRN_HANDLER_HAVE_MULTI_RANGE_READ 1
#endif

#if (MYSQL_VERSION_ID >= 50607)
// TODO
#  define MRN_HANDLER_HAVE_CHECK_IF_SUPPORTED_INPLACE_ALTER 1
#  define MRN_HANDLER_HAVE_HA_PREPARE_INPLACE_ALTER_TABLE 1
#  define MRN_HANDLER_HAVE_HA_INPLACE_ALTER_TABLE 1
#  define MRN_HANDLER_HAVE_HA_COMMIT_INPLACE_ALTER_TABLE 1
#endif

#ifndef MRN_MARIADB_P
#  define MRN_HANDLER_HAVE_INDEX_READ_LAST_MAP
#endif

#if (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50302)
#  define MRN_HANDLER_HAVE_MULTI_RANGE_READ_INFO_KEY_PARTS
#endif

#if MYSQL_VERSION_ID >= 50500
#  define MRN_HANDLER_HAVE_TRUNCATE
#  define MRN_HANDLER_HAVE_GET_PARENT_FOREIGN_KEY_LIST
#endif

#if (MYSQL_VERSION_ID < 50600)
#  define MRN_HANDLER_HAVE_GET_TABLESPACE_NAME 1
#endif

#if MYSQL_VERSION_ID >= 50500
#  define MRN_TABLE_LIST_INIT_REQUIRE_ALIAS
#endif

#ifdef BIG_TABLES
#  define MRN_HA_ROWS_FORMAT "llu"
#else
#  define MRN_HA_ROWS_FORMAT "lu"
#endif

#if (MYSQL_VERSION_ID < 50519) || \
    defined(MRN_MARIADB_P) || \
    (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID < 50604)
#  define MRN_NEED_FREE_STRING_MEMALLOC_PLUGIN_VAR
#endif

#if MYSQL_VERSION_ID >= 50500
#  define MRN_HAVE_HA_EXTRA_ADD_CHILDREN_LIST
#  define MRN_HAVE_HA_EXTRA_IS_ATTACHED_CHILDREN
#endif

#ifdef MRN_MARIADB_P
#  define MRN_HAVE_HA_EXTRA_DETACH_CHILD
#  define MRN_HAVE_HA_EXTRA_PREPARE_FOR_FORCED_CLOSE
#endif

#if MYSQL_VERSION_ID >= 50607
#  define MRN_HAVE_HA_EXTRA_EXPORT
#endif

#if MYSQL_VERSION_ID >= 50604
#  define MRN_TIMESTAMP_USE_TIMEVAL
#elif defined(MRN_MARIADB_P)
#  define MRN_TIMESTAMP_USE_MY_TIME_T
#else
#  define MRN_TIMESTAMP_USE_LONG
#endif

#if MYSQL_VERSION_ID < 50600 && !defined(MRN_MARIADB_P)
#  define MRN_FIELD_STORE_TIME_NEED_TYPE
#endif

#if MYSQL_VERSION_ID < 50500
#  define MRN_HAVE_TL_WRITE_ALLOW_READ
#endif

#if (defined(MRN_MARIADB_P) && \
     ((MYSQL_VERSION_ID >= 50306 && MYSQL_VERSION_ID < 50500) || \
      MYSQL_VERSION_ID >= 50523))
#  define MRN_HANDLER_AUTO_REPAIR_HAVE_ERROR
#endif

#if MYSQL_VERSION_ID >= 50604
#  define MRN_JOIN_TAB_HAVE_CONDITION
#endif

#if MYSQL_VERSION_ID >= 50607
#  define MRN_ITEM_HAVE_ITEM_NAME
#endif

#if MYSQL_VERSION_ID < 50600
#  define MRN_RBR_UPDATE_NEED_ALL_COLUMNS
#endif

#if MYSQL_VERSION_ID >= 50500
#  define MRN_ROW_BASED_CHECK_IS_METHOD
#  define MRN_OPTION_BITS_IS_UNDER_VARIABLES
#endif

#if MYSQL_VERSION_ID >= 50600
#  define MRN_HAVE_HA_REBIND_PSI
#endif

#if MYSQL_VERSION_ID >= 50607
#  define MRN_GET_ERROR_MESSAGE current_thd->get_stmt_da()->message()
#else
#  if MYSQL_VERSION_ID >= 50500
#    define MRN_GET_ERROR_MESSAGE current_thd->stmt_da->message()
#  else
#    define MRN_GET_ERROR_MESSAGE current_thd->main_da.message()
#  endif
#endif

#if defined(_WIN32) || defined(_WIN64)
#  define MRN_API __declspec(dllexport)
#else
#  define MRN_API
#endif

class ha_mroonga;

/* structs */
struct st_mrn_ft_info
{
  struct _ft_vft *please;
  grn_ctx *ctx;
  grn_obj *table;
  grn_obj *result;
  grn_obj *score_column;
  grn_obj key;
  grn_obj score;
  uint active_index;
  KEY *key_info;
  KEY *primary_key_info;
  ha_mroonga *mroonga;
{'fraction_non_alphanumeric': 0.07631885182311869, 'fraction_numerical': 0.0441233514352211, 'mean_word_length': 5.675080906148867, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 68, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2794884', 'n_tokens_mistral': 4693, 'n_tokens_neox': 4308, 'n_words': 878}