You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-1101. PoC for INFINIDB_VTABLE and thd variables migration to plugin sys variables.
This commit is contained in:
@ -4,6 +4,7 @@ include_directories( ${ENGINE_COMMON_INCLUDES}
|
|||||||
|
|
||||||
|
|
||||||
SET ( libcalmysql_SRCS
|
SET ( libcalmysql_SRCS
|
||||||
|
mcs_sysvars.cpp
|
||||||
ha_calpont.cpp
|
ha_calpont.cpp
|
||||||
ha_calpont_impl.cpp
|
ha_calpont_impl.cpp
|
||||||
ha_calpont_dml.cpp
|
ha_calpont_dml.cpp
|
||||||
|
@ -380,6 +380,7 @@ static int calpont_close_connection ( handlerton* hton, THD* thd )
|
|||||||
|
|
||||||
ha_calpont::ha_calpont(handlerton* hton, TABLE_SHARE* table_arg) :
|
ha_calpont::ha_calpont(handlerton* hton, TABLE_SHARE* table_arg) :
|
||||||
handler(hton, table_arg),
|
handler(hton, table_arg),
|
||||||
|
fe_conn_info(NULL),
|
||||||
int_table_flags(HA_BINLOG_STMT_CAPABLE | HA_BINLOG_ROW_CAPABLE |
|
int_table_flags(HA_BINLOG_STMT_CAPABLE | HA_BINLOG_ROW_CAPABLE |
|
||||||
HA_TABLE_SCAN_ON_INDEX |
|
HA_TABLE_SCAN_ON_INDEX |
|
||||||
HA_CAN_TABLE_CONDITION_PUSHDOWN)
|
HA_CAN_TABLE_CONDITION_PUSHDOWN)
|
||||||
@ -683,7 +684,11 @@ int ha_calpont::rnd_init(bool scan)
|
|||||||
{
|
{
|
||||||
DBUG_ENTER("ha_calpont::rnd_init");
|
DBUG_ENTER("ha_calpont::rnd_init");
|
||||||
|
|
||||||
int rc = ha_calpont_impl_rnd_init(table);
|
// Use global THD*
|
||||||
|
set_original_query(current_thd, current_thd->query_string.str());
|
||||||
|
mcs_handler_info mhi(static_cast<void*>(this), LEGACY);
|
||||||
|
|
||||||
|
int rc = ha_calpont_impl_rnd_init(table, mhi);
|
||||||
|
|
||||||
DBUG_RETURN(rc);
|
DBUG_RETURN(rc);
|
||||||
}
|
}
|
||||||
@ -1101,44 +1106,6 @@ struct st_mysql_storage_engine columnstore_storage_engine =
|
|||||||
struct st_mysql_storage_engine infinidb_storage_engine =
|
struct st_mysql_storage_engine infinidb_storage_engine =
|
||||||
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
|
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
|
||||||
|
|
||||||
#if 0
|
|
||||||
static ulong srv_enum_var = 0;
|
|
||||||
static ulong srv_ulong_var = 0;
|
|
||||||
|
|
||||||
const char* enum_var_names[] =
|
|
||||||
{
|
|
||||||
"e1", "e2", NullS
|
|
||||||
};
|
|
||||||
|
|
||||||
TYPELIB enum_var_typelib =
|
|
||||||
{
|
|
||||||
array_elements(enum_var_names) - 1, "enum_var_typelib",
|
|
||||||
enum_var_names, NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
static MYSQL_SYSVAR_ENUM(
|
|
||||||
enum_var, // name
|
|
||||||
srv_enum_var, // varname
|
|
||||||
PLUGIN_VAR_RQCMDARG, // opt
|
|
||||||
"Sample ENUM system variable.", // comment
|
|
||||||
NULL, // check
|
|
||||||
NULL, // update
|
|
||||||
0, // def
|
|
||||||
&enum_var_typelib); // typelib
|
|
||||||
|
|
||||||
static MYSQL_SYSVAR_ULONG(
|
|
||||||
ulong_var,
|
|
||||||
srv_ulong_var,
|
|
||||||
PLUGIN_VAR_RQCMDARG,
|
|
||||||
"0..1000",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
8,
|
|
||||||
0,
|
|
||||||
1000,
|
|
||||||
0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*@brief check_walk - It traverses filter conditions*/
|
/*@brief check_walk - It traverses filter conditions*/
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* DESCRIPTION:
|
* DESCRIPTION:
|
||||||
@ -1367,15 +1334,55 @@ int ha_calpont_group_by_handler::end_scan()
|
|||||||
|
|
||||||
DBUG_RETURN(rc);
|
DBUG_RETURN(rc);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
// compression_type
|
||||||
|
enum mcs_compression_type_t {
|
||||||
|
NO_COMPRESSION = 0,
|
||||||
|
SNAPPY = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
const char* mcs_compression_type_names[] = {
|
||||||
|
"NO_COMPRESSION",
|
||||||
|
"SNAPPY",
|
||||||
|
NullS
|
||||||
|
};
|
||||||
|
|
||||||
static struct st_mysql_sys_var* calpont_system_variables[] =
|
static TYPELIB mcs_compression_type_names_lib = {
|
||||||
{
|
array_elements(mcs_compression_type_names) - 1,
|
||||||
// MYSQL_SYSVAR(enum_var),
|
"mcs_compression_type_names",
|
||||||
// MYSQL_SYSVAR(ulong_var),
|
mcs_compression_type_names,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static MYSQL_THDVAR_ENUM(
|
||||||
|
compression_type,
|
||||||
|
PLUGIN_VAR_RQCMDARG,
|
||||||
|
"Controls compression type for create tables. Possible values are: "
|
||||||
|
"NO_COMPRESSION segment files aren't compressed; "
|
||||||
|
"SNAPPY segment files are Snappy compressed (default);",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
SNAPPY,
|
||||||
|
&mcs_compression_type_names_lib);
|
||||||
|
|
||||||
|
// original query
|
||||||
|
static MYSQL_THDVAR_STR(
|
||||||
|
original_query,
|
||||||
|
PLUGIN_VAR_MEMALLOC |
|
||||||
|
PLUGIN_VAR_RQCMDARG,
|
||||||
|
"Original query text",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
static struct st_mysql_sys_var* columnstore_system_variables[] =
|
||||||
|
{
|
||||||
|
MYSQL_SYSVAR(compression_type),
|
||||||
|
MYSQL_SYSVAR(original_query),
|
||||||
|
NULL
|
||||||
|
};*/
|
||||||
|
|
||||||
mysql_declare_plugin(columnstore)
|
mysql_declare_plugin(columnstore)
|
||||||
{
|
{
|
||||||
MYSQL_STORAGE_ENGINE_PLUGIN,
|
MYSQL_STORAGE_ENGINE_PLUGIN,
|
||||||
@ -1388,7 +1395,7 @@ mysql_declare_plugin(columnstore)
|
|||||||
columnstore_done_func, /* Plugin Deinit */
|
columnstore_done_func, /* Plugin Deinit */
|
||||||
0x0100 /* 1.0 */,
|
0x0100 /* 1.0 */,
|
||||||
NULL, /* status variables */
|
NULL, /* status variables */
|
||||||
calpont_system_variables, /* system variables */
|
mcs_system_variables, /* system variables */
|
||||||
NULL, /* reserved */
|
NULL, /* reserved */
|
||||||
0 /* config flags */
|
0 /* config flags */
|
||||||
},
|
},
|
||||||
@ -1403,7 +1410,7 @@ mysql_declare_plugin(columnstore)
|
|||||||
infinidb_done_func, /* Plugin Deinit */
|
infinidb_done_func, /* Plugin Deinit */
|
||||||
0x0100 /* 1.0 */,
|
0x0100 /* 1.0 */,
|
||||||
NULL, /* status variables */
|
NULL, /* status variables */
|
||||||
calpont_system_variables, /* system variables */
|
mcs_system_variables, /* system variables */
|
||||||
NULL, /* reserved */
|
NULL, /* reserved */
|
||||||
0 /* config flags */
|
0 /* config flags */
|
||||||
}
|
}
|
||||||
@ -1419,9 +1426,9 @@ maria_declare_plugin(columnstore)
|
|||||||
columnstore_init_func,
|
columnstore_init_func,
|
||||||
columnstore_done_func,
|
columnstore_done_func,
|
||||||
0x0100, /* 1.0 */
|
0x0100, /* 1.0 */
|
||||||
NULL, /* status variables */
|
NULL, /* status variables */
|
||||||
calpont_system_variables, /* system variables */
|
mcs_system_variables, /* system variables */
|
||||||
"1.0", /* string version */
|
"1.0", /* string version */
|
||||||
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
|
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1434,10 +1441,10 @@ maria_declare_plugin(columnstore)
|
|||||||
infinidb_init_func,
|
infinidb_init_func,
|
||||||
infinidb_done_func,
|
infinidb_done_func,
|
||||||
0x0100, /* 1.0 */
|
0x0100, /* 1.0 */
|
||||||
NULL, /* status variables */
|
NULL, /* status variables */
|
||||||
calpont_system_variables, /* system variables */
|
mcs_system_variables, /* system variables */
|
||||||
"1.0", /* string version */
|
"1.0", /* string version */
|
||||||
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
|
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
|
||||||
}
|
}
|
||||||
maria_declare_plugin_end;
|
maria_declare_plugin_end;
|
||||||
|
|
||||||
|
@ -15,35 +15,16 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
MA 02110-1301, USA. */
|
MA 02110-1301, USA. */
|
||||||
/** @file ha_example.h
|
|
||||||
|
|
||||||
@brief
|
|
||||||
The ha_example engine is a stubbed storage engine for example purposes only;
|
|
||||||
it does nothing at this point. Its purpose is to provide a source
|
|
||||||
code illustration of how to begin writing new storage engines; see also
|
|
||||||
/storage/example/ha_example.cc.
|
|
||||||
|
|
||||||
@note
|
|
||||||
Please read ha_example.cc before reading this file.
|
|
||||||
Reminder: The example storage engine implements all methods that are *required*
|
|
||||||
to be implemented. For a full list of all methods that you can implement, see
|
|
||||||
handler.h.
|
|
||||||
|
|
||||||
@see
|
|
||||||
/sql/handler.h and /storage/example/ha_example.cc
|
|
||||||
*/
|
|
||||||
|
|
||||||
// $Id: ha_calpont.h 9210 2013-01-21 14:10:42Z rdempsey $
|
|
||||||
|
|
||||||
#ifndef HA_CALPONT_H__
|
#ifndef HA_CALPONT_H__
|
||||||
#define HA_CALPONT_H__
|
#define HA_CALPONT_H__
|
||||||
#include <my_config.h>
|
#include <my_config.h>
|
||||||
#include "idb_mysql.h"
|
#include "idb_mysql.h"
|
||||||
|
#include "mcs_sysvars.h"
|
||||||
|
|
||||||
extern handlerton* calpont_hton;
|
extern handlerton* calpont_hton;
|
||||||
|
|
||||||
/** @brief
|
/** @brief
|
||||||
EXAMPLE_SHARE is a structure that will be shared among all open handlers.
|
This structure will be shared among all open handlers.
|
||||||
This example implements the minimum of what you will probably need.
|
This example implements the minimum of what you will probably need.
|
||||||
*/
|
*/
|
||||||
typedef struct st_calpont_share
|
typedef struct st_calpont_share
|
||||||
@ -62,6 +43,7 @@ class ha_calpont: public handler
|
|||||||
THR_LOCK_DATA lock; ///< MySQL lock
|
THR_LOCK_DATA lock; ///< MySQL lock
|
||||||
INFINIDB_SHARE* share; ///< Shared lock info
|
INFINIDB_SHARE* share; ///< Shared lock info
|
||||||
ulonglong int_table_flags;
|
ulonglong int_table_flags;
|
||||||
|
void* fe_conn_info;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ha_calpont(handlerton* hton, TABLE_SHARE* table_arg);
|
ha_calpont(handlerton* hton, TABLE_SHARE* table_arg);
|
||||||
|
@ -49,6 +49,7 @@ using namespace std;
|
|||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
|
#include "mcs_sysvars.h"
|
||||||
#include "idb_mysql.h"
|
#include "idb_mysql.h"
|
||||||
|
|
||||||
#include "ha_calpont_impl_if.h"
|
#include "ha_calpont_impl_if.h"
|
||||||
@ -2128,7 +2129,7 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO*
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int compressiontype = thd->variables.infinidb_compression_type;
|
int compressiontype = get_compression_type(thd);
|
||||||
|
|
||||||
if (compressiontype == 1) compressiontype = 2;
|
if (compressiontype == 1) compressiontype = 2;
|
||||||
|
|
||||||
@ -2140,7 +2141,7 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO*
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( compressiontype == MAX_INT )
|
if ( compressiontype == MAX_INT )
|
||||||
compressiontype = thd->variables.infinidb_compression_type;
|
compressiontype = get_compression_type(thd);
|
||||||
else if ( compressiontype < 0 )
|
else if ( compressiontype < 0 )
|
||||||
{
|
{
|
||||||
string emsg = IDBErrorInfo::instance()->errorMsg(ERR_INVALID_COMPRESSION_TYPE);
|
string emsg = IDBErrorInfo::instance()->errorMsg(ERR_INVALID_COMPRESSION_TYPE);
|
||||||
@ -2473,12 +2474,12 @@ extern "C"
|
|||||||
if ( thd->db.length )
|
if ( thd->db.length )
|
||||||
db = thd->db.str;
|
db = thd->db.str;
|
||||||
|
|
||||||
int compressiontype = thd->variables.infinidb_compression_type;
|
int compressiontype = get_compression_type(thd);
|
||||||
|
|
||||||
if (compressiontype == 1) compressiontype = 2;
|
if (compressiontype == 1) compressiontype = 2;
|
||||||
|
|
||||||
if ( compressiontype == MAX_INT )
|
if ( compressiontype == MAX_INT )
|
||||||
compressiontype = thd->variables.infinidb_compression_type;
|
compressiontype = get_compression_type(thd);
|
||||||
|
|
||||||
//hdfs
|
//hdfs
|
||||||
if ((compressiontype == 0) && (useHdfs))
|
if ((compressiontype == 0) && (useHdfs))
|
||||||
|
@ -142,6 +142,7 @@ using namespace funcexp;
|
|||||||
|
|
||||||
#include "installdir.h"
|
#include "installdir.h"
|
||||||
#include "columnstoreversion.h"
|
#include "columnstoreversion.h"
|
||||||
|
#include "mcs_sysvars.h"
|
||||||
|
|
||||||
namespace cal_impl_if
|
namespace cal_impl_if
|
||||||
{
|
{
|
||||||
@ -2767,8 +2768,14 @@ int ha_calpont_impl_discover_existence(const char* schema, const char* name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ha_calpont_impl_rnd_init(TABLE* table)
|
int ha_calpont_impl_rnd_init(TABLE* table, mcs_handler_info hndtl_ptr)
|
||||||
{
|
{
|
||||||
|
ha_calpont* handler;
|
||||||
|
if ( hndtl_ptr.hndl_type == LEGACY )
|
||||||
|
{
|
||||||
|
handler = reinterpret_cast<ha_calpont*>(hndtl_ptr.hndl_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_SETENV
|
#ifdef DEBUG_SETENV
|
||||||
string home(getenv("HOME"));
|
string home(getenv("HOME"));
|
||||||
|
|
||||||
@ -3092,8 +3099,9 @@ int ha_calpont_impl_rnd_init(TABLE* table)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
string query;
|
string query;
|
||||||
query.assign(thd->infinidb_vtable.original_query.ptr(),
|
const char *original_query = get_original_query(current_thd);
|
||||||
thd->infinidb_vtable.original_query.length());
|
query.assign(original_query,
|
||||||
|
strlen(original_query));
|
||||||
csep->data(query);
|
csep->data(query);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -16,12 +16,6 @@
|
|||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
MA 02110-1301, USA. */
|
MA 02110-1301, USA. */
|
||||||
|
|
||||||
/*
|
|
||||||
* $Id: ha_calpont_impl.h 9413 2013-04-22 22:03:42Z zzhu $
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file */
|
|
||||||
|
|
||||||
#ifndef HA_CALPONT_IMPL_H__
|
#ifndef HA_CALPONT_IMPL_H__
|
||||||
#define HA_CALPONT_IMPL_H__
|
#define HA_CALPONT_IMPL_H__
|
||||||
|
|
||||||
@ -33,7 +27,7 @@ extern int ha_calpont_impl_create(const char* name, TABLE* table_arg, HA_CREATE_
|
|||||||
extern int ha_calpont_impl_delete_table(const char* name);
|
extern int ha_calpont_impl_delete_table(const char* name);
|
||||||
extern int ha_calpont_impl_open(const char* name, int mode, uint32_t test_if_locked);
|
extern int ha_calpont_impl_open(const char* name, int mode, uint32_t test_if_locked);
|
||||||
extern int ha_calpont_impl_close(void);
|
extern int ha_calpont_impl_close(void);
|
||||||
extern int ha_calpont_impl_rnd_init(TABLE* table);
|
extern int ha_calpont_impl_rnd_init(TABLE* table, mcs_handler_info hndtl_ptr);
|
||||||
extern int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table);
|
extern int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table);
|
||||||
extern int ha_calpont_impl_rnd_end(TABLE* table);
|
extern int ha_calpont_impl_rnd_end(TABLE* table);
|
||||||
extern int ha_calpont_impl_write_row(uchar* buf, TABLE* table);
|
extern int ha_calpont_impl_write_row(uchar* buf, TABLE* table);
|
||||||
|
@ -321,8 +321,6 @@ struct cal_connection_info
|
|||||||
std::vector <execplan::CalpontSystemCatalog::ColType> columnTypes;
|
std::vector <execplan::CalpontSystemCatalog::ColType> columnTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::tr1::unordered_map<int, cal_connection_info> CalConnMap;
|
|
||||||
|
|
||||||
const std::string infinidb_err_msg = "\nThe query includes syntax that is not supported by MariaDB Columnstore. Use 'show warnings;' to get more information. Review the MariaDB Columnstore Syntax guide for additional information on supported distributed syntax or consider changing the MariaDB Columnstore Operating Mode (infinidb_vtable_mode).";
|
const std::string infinidb_err_msg = "\nThe query includes syntax that is not supported by MariaDB Columnstore. Use 'show warnings;' to get more information. Review the MariaDB Columnstore Syntax guide for additional information on supported distributed syntax or consider changing the MariaDB Columnstore Operating Mode (infinidb_vtable_mode).";
|
||||||
|
|
||||||
int cp_get_plan(THD* thd, execplan::SCSEP& csep);
|
int cp_get_plan(THD* thd, execplan::SCSEP& csep);
|
||||||
|
Reference in New Issue
Block a user