You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-07 03:22:57 +03:00
Merge pull request #1075 from pleblanc1976/2020-3-1.4-to-1.5
2020 3 1.4 to 1.5
This commit is contained in:
@@ -52,7 +52,7 @@ install(FILES syscatalog_mysql.sql
|
||||
calshowprocesslist.sql
|
||||
columnstore_info.sql
|
||||
DESTINATION ${ENGINE_SUPPORTDIR} COMPONENT columnstore-engine)
|
||||
install(PROGRAMS install_mcs_mysql.sh mysql-Columnstore
|
||||
install(PROGRAMS install_mcs_mysql.sh
|
||||
DESTINATION ${ENGINE_SBINDIR} COMPONENT columnstore-engine)
|
||||
|
||||
install(FILES columnstore.cnf
|
||||
|
@@ -30,14 +30,14 @@
|
||||
#define COLUMNSTORE_MATURITY MariaDB_PLUGIN_MATURITY_STABLE
|
||||
#endif
|
||||
|
||||
static handler* calpont_create_handler(handlerton* hton,
|
||||
TABLE_SHARE* table,
|
||||
MEM_ROOT* mem_root);
|
||||
static handler* mcs_create_handler(handlerton* hton,
|
||||
TABLE_SHARE* table,
|
||||
MEM_ROOT* mem_root);
|
||||
|
||||
static int calpont_commit(handlerton* hton, THD* thd, bool all);
|
||||
static int mcs_commit(handlerton* hton, THD* thd, bool all);
|
||||
|
||||
static int calpont_rollback(handlerton* hton, THD* thd, bool all);
|
||||
static int calpont_close_connection ( handlerton* hton, THD* thd );
|
||||
static int mcs_rollback(handlerton* hton, THD* thd, bool all);
|
||||
static int mcs_close_connection(handlerton* hton, THD* thd );
|
||||
handlerton* mcs_hton;
|
||||
char cs_version[25];
|
||||
char cs_commit_hash[41]; // a commit hash is 40 characters
|
||||
@@ -59,11 +59,11 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* sel);
|
||||
Hash used to track the number of open tables; variable for example share
|
||||
methods
|
||||
*/
|
||||
static HASH calpont_open_tables;
|
||||
static HASH mcs_open_tables;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
/* The mutex used to init the hash; variable for example share methods */
|
||||
pthread_mutex_t calpont_mutex;
|
||||
pthread_mutex_t mcs_mutex;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_ENTER
|
||||
@@ -79,20 +79,20 @@ pthread_mutex_t calpont_mutex;
|
||||
Function we use in the creation of our hash to get key.
|
||||
*/
|
||||
|
||||
static uchar* calpont_get_key(COLUMNSTORE_SHARE* share, size_t* length,
|
||||
my_bool not_used __attribute__((unused)))
|
||||
static uchar* mcs_get_key(COLUMNSTORE_SHARE* share, size_t* length,
|
||||
my_bool not_used __attribute__((unused)))
|
||||
{
|
||||
*length = share->table_name_length;
|
||||
return (uchar*) share->table_name;
|
||||
}
|
||||
|
||||
// This one is unused
|
||||
int calpont_discover(handlerton* hton, THD* thd, TABLE_SHARE* share)
|
||||
int mcs_discover(handlerton* hton, THD* thd, TABLE_SHARE* share)
|
||||
{
|
||||
DBUG_ENTER("calpont_discover");
|
||||
DBUG_PRINT("calpont_discover", ("db: '%s' name: '%s'", share->db.str, share->table_name.str));
|
||||
DBUG_ENTER("mcs_discover");
|
||||
DBUG_PRINT("mcs_discover", ("db: '%s' name: '%s'", share->db.str, share->table_name.str));
|
||||
#ifdef INFINIDB_DEBUG
|
||||
fprintf(stderr, "calpont_discover()\n");
|
||||
fprintf(stderr, "mcs_discover()\n");
|
||||
#endif
|
||||
|
||||
uchar* frm_data = NULL;
|
||||
@@ -114,8 +114,8 @@ int calpont_discover(handlerton* hton, THD* thd, TABLE_SHARE* share)
|
||||
}
|
||||
|
||||
// This f() is also unused
|
||||
int calpont_discover_existence(handlerton* hton, const char* db,
|
||||
const char* table_name)
|
||||
int mcs_discover_existence(handlerton* hton, const char* db,
|
||||
const char* table_name)
|
||||
{
|
||||
return ha_mcs_impl_discover_existence(db, table_name);
|
||||
}
|
||||
@@ -144,18 +144,18 @@ static int columnstore_init_func(void* p)
|
||||
|
||||
mcs_hton = (handlerton*)p;
|
||||
#ifndef _MSC_VER
|
||||
(void) pthread_mutex_init(&calpont_mutex, MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&mcs_mutex, MY_MUTEX_INIT_FAST);
|
||||
#endif
|
||||
(void) my_hash_init(&calpont_open_tables, system_charset_info, 32, 0, 0,
|
||||
(my_hash_get_key) calpont_get_key, 0, 0);
|
||||
(void) my_hash_init(&mcs_open_tables, system_charset_info, 32, 0, 0,
|
||||
(my_hash_get_key) mcs_get_key, 0, 0);
|
||||
|
||||
mcs_hton->create = calpont_create_handler;
|
||||
mcs_hton->create = mcs_create_handler;
|
||||
mcs_hton->flags = HTON_CAN_RECREATE;
|
||||
// mcs_hton->discover_table= calpont_discover;
|
||||
// mcs_hton->discover_table_existence= calpont_discover_existence;
|
||||
mcs_hton->commit = calpont_commit;
|
||||
mcs_hton->rollback = calpont_rollback;
|
||||
mcs_hton->close_connection = calpont_close_connection;
|
||||
// mcs_hton->discover_table = mcs_discover;
|
||||
// mcs_hton->discover_table_existence = mcs_discover_existence;
|
||||
mcs_hton->commit = mcs_commit;
|
||||
mcs_hton->rollback = mcs_rollback;
|
||||
mcs_hton->close_connection = mcs_close_connection;
|
||||
mcs_hton->create_group_by = create_columnstore_group_by_handler;
|
||||
mcs_hton->create_derived = create_columnstore_derived_handler;
|
||||
mcs_hton->create_select = create_columnstore_select_handler;
|
||||
@@ -165,37 +165,64 @@ static int columnstore_init_func(void* p)
|
||||
|
||||
static int columnstore_done_func(void* p)
|
||||
{
|
||||
DBUG_ENTER("calpont_done_func");
|
||||
DBUG_ENTER("columnstore_done_func");
|
||||
|
||||
my_hash_free(&calpont_open_tables);
|
||||
my_hash_free(&mcs_open_tables);
|
||||
#ifndef _MSC_VER
|
||||
pthread_mutex_destroy(&calpont_mutex);
|
||||
pthread_mutex_destroy(&mcs_mutex);
|
||||
#endif
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
static handler* calpont_create_handler(handlerton* hton,
|
||||
TABLE_SHARE* table,
|
||||
MEM_ROOT* mem_root)
|
||||
static handler* mcs_create_handler(handlerton* hton,
|
||||
TABLE_SHARE* table,
|
||||
MEM_ROOT* mem_root)
|
||||
{
|
||||
return new (mem_root) ha_mcs(hton, table);
|
||||
}
|
||||
|
||||
static int calpont_commit(handlerton* hton, THD* thd, bool all)
|
||||
static int mcs_commit(handlerton* hton, THD* thd, bool all)
|
||||
{
|
||||
int rc = ha_mcs_impl_commit( hton, thd, all);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_commit(hton, thd, all);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int calpont_rollback(handlerton* hton, THD* thd, bool all)
|
||||
static int mcs_rollback(handlerton* hton, THD* thd, bool all)
|
||||
{
|
||||
int rc = ha_mcs_impl_rollback( hton, thd, all);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_rollback(hton, thd, all);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int calpont_close_connection ( handlerton* hton, THD* thd )
|
||||
static int mcs_close_connection(handlerton* hton, THD* thd)
|
||||
{
|
||||
int rc = ha_mcs_impl_close_connection( hton, thd);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_close_connection(hton, thd);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -256,7 +283,16 @@ int ha_mcs::open(const char* name, int mode, uint32_t test_if_locked)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::open");
|
||||
|
||||
int rc = ha_mcs_impl_open(name, mode, test_if_locked);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_open(name, mode, test_if_locked);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
@@ -282,7 +318,16 @@ int ha_mcs::close(void)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::close");
|
||||
|
||||
int rc = ha_mcs_impl_close();
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_close();
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
@@ -303,7 +348,16 @@ int ha_mcs::close(void)
|
||||
int ha_mcs::write_row(const uchar* buf)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::write_row");
|
||||
int rc = ha_mcs_impl_write_row(buf, table);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_write_row(buf, table);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
@@ -311,14 +365,30 @@ int ha_mcs::write_row(const uchar* buf)
|
||||
void ha_mcs::start_bulk_insert(ha_rows rows, uint flags)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::start_bulk_insert");
|
||||
ha_mcs_impl_start_bulk_insert(rows, table);
|
||||
try
|
||||
{
|
||||
ha_mcs_impl_start_bulk_insert(rows, table);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
int ha_mcs::end_bulk_insert()
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::end_bulk_insert");
|
||||
int rc = ha_mcs_impl_end_bulk_insert(false, table);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_end_bulk_insert(false, table);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
@@ -339,7 +409,16 @@ int ha_mcs::update_row(const uchar* old_data, uchar* new_data)
|
||||
{
|
||||
|
||||
DBUG_ENTER("ha_mcs::update_row");
|
||||
int rc = ha_mcs_impl_update_row();
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_update_row();
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
@@ -365,15 +444,33 @@ int ha_mcs::direct_update_rows_init(List<Item> *update_fields)
|
||||
int ha_mcs::direct_update_rows(ha_rows *update_rows)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::direct_update_rows");
|
||||
int rc = ha_mcs_impl_direct_update_delete_rows(false, update_rows);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_direct_update_delete_rows(false, update_rows);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
int ha_mcs::direct_update_rows(ha_rows *update_rows, ha_rows *found_rows)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::direct_update_rows");
|
||||
int rc = ha_mcs_impl_direct_update_delete_rows(false, update_rows);
|
||||
*found_rows = *update_rows;
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_direct_update_delete_rows(false, update_rows);
|
||||
*found_rows = *update_rows;
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
@@ -386,7 +483,16 @@ int ha_mcs::direct_delete_rows_init()
|
||||
int ha_mcs::direct_delete_rows(ha_rows *deleted_rows)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::direct_delete_rows");
|
||||
int rc = ha_mcs_impl_direct_update_delete_rows(true, deleted_rows);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_direct_update_delete_rows(true, deleted_rows);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
/**
|
||||
@@ -412,7 +518,16 @@ int ha_mcs::direct_delete_rows(ha_rows *deleted_rows)
|
||||
int ha_mcs::delete_row(const uchar* buf)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::delete_row");
|
||||
int rc = ha_mcs_impl_delete_row();
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_delete_row();
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
@@ -511,7 +626,15 @@ int ha_mcs::rnd_init(bool scan)
|
||||
int rc = 0;
|
||||
if(scan)
|
||||
{
|
||||
rc = ha_mcs_impl_rnd_init(table);
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_rnd_init(table);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
DBUG_RETURN(rc);
|
||||
@@ -521,7 +644,16 @@ int ha_mcs::rnd_end()
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::rnd_end");
|
||||
|
||||
int rc = ha_mcs_impl_rnd_end(table);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_rnd_end(table);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
@@ -545,7 +677,16 @@ int ha_mcs::rnd_next(uchar* buf)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::rnd_next");
|
||||
|
||||
int rc = ha_mcs_impl_rnd_next(buf, table);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_rnd_next(buf, table);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
@@ -601,7 +742,16 @@ void ha_mcs::position(const uchar* record)
|
||||
int ha_mcs::rnd_pos(uchar* buf, uchar* pos)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::rnd_pos");
|
||||
int rc = ha_mcs_impl_rnd_pos(buf, pos);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_rnd_pos(buf, pos);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
@@ -754,11 +904,20 @@ int ha_mcs::external_lock(THD* thd, int lock_type)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::external_lock");
|
||||
|
||||
//@Bug 2526 Only register the transaction when autocommit is off
|
||||
if ((thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
|
||||
trans_register_ha( thd, true, mcs_hton);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
//@Bug 2526 Only register the transaction when autocommit is off
|
||||
if ((thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
|
||||
trans_register_ha( thd, true, mcs_hton);
|
||||
|
||||
int rc = ha_mcs_impl_external_lock(thd, table, lock_type);
|
||||
rc = ha_mcs_impl_external_lock(thd, table, lock_type);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
@@ -839,7 +998,17 @@ int ha_mcs::delete_table(const char* name)
|
||||
DBUG_ENTER("ha_mcs::delete_table");
|
||||
/* This is not implemented but we want someone to be able that it works. */
|
||||
|
||||
int rc = ha_mcs_impl_delete_table(name);
|
||||
int rc;
|
||||
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_delete_table(name);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
@@ -862,7 +1031,16 @@ int ha_mcs::delete_table(const char* name)
|
||||
int ha_mcs::rename_table(const char* from, const char* to)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::rename_table ");
|
||||
int rc = ha_mcs_impl_rename_table(from, to);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_rename_table(from, to);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
@@ -912,14 +1090,32 @@ int ha_mcs::create(const char* name, TABLE* table_arg,
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::create");
|
||||
|
||||
int rc = ha_mcs_impl_create(name, table_arg, create_info);
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
rc = ha_mcs_impl_create(name, table_arg, create_info);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
rc = ER_INTERNAL_ERROR;
|
||||
}
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
const COND* ha_mcs::cond_push(const COND* cond)
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::cond_push");
|
||||
DBUG_RETURN(ha_mcs_impl_cond_push(const_cast<COND*>(cond), table));
|
||||
COND* ret_cond = NULL;
|
||||
try
|
||||
{
|
||||
ret_cond = ha_mcs_impl_cond_push(const_cast<COND*>(cond), table);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
}
|
||||
DBUG_RETURN(ret_cond);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -28,7 +28,7 @@ extern handlerton* mcs_hton;
|
||||
COLUMNSTORE_SHARE is a structure that will be shared among all open handlers.
|
||||
This example implements the minimum of what you will probably need.
|
||||
*/
|
||||
typedef struct st_calpont_share
|
||||
typedef struct st_mcs_share
|
||||
{
|
||||
char* table_name;
|
||||
uint32_t table_name_length, use_count;
|
||||
|
@@ -294,13 +294,24 @@ extern "C"
|
||||
|
||||
try
|
||||
{
|
||||
oam.getSystemStatus(systemstatus);
|
||||
|
||||
if (systemstatus.SystemOpState == ACTIVE
|
||||
&& dbrm.getSystemReady()
|
||||
&& dbrm.getSystemQueryReady())
|
||||
if (getenv("SKIP_OAM_INIT"))
|
||||
{
|
||||
return 1;
|
||||
if (dbrm.getSystemReady()
|
||||
&& dbrm.getSystemQueryReady())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oam.getSystemStatus(systemstatus);
|
||||
|
||||
if (systemstatus.SystemOpState == ACTIVE
|
||||
&& dbrm.getSystemReady()
|
||||
&& dbrm.getSystemQueryReady())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
|
@@ -390,32 +390,6 @@ bool validateNextValue( int type, int64_t value )
|
||||
return validValue;
|
||||
}
|
||||
|
||||
static void decode_objectname(char *buf, const char *path, size_t buf_size)
|
||||
{
|
||||
size_t new_path_len = filename_to_tablename(path, buf, buf_size);
|
||||
buf[new_path_len] = '\0';
|
||||
}
|
||||
|
||||
static void decode_file_path(const char *path, char *decoded_dbname,
|
||||
char *decoded_tbname)
|
||||
{
|
||||
// The format cont ains './' in the beginning of a path.
|
||||
char *dbname_start = (char*) path + 2;
|
||||
char *dbname_end = dbname_start;
|
||||
while (*dbname_end != '/')
|
||||
dbname_end++;
|
||||
|
||||
int cnt = dbname_end - dbname_start;
|
||||
char *dbname = (char *)my_alloca(cnt + 1);
|
||||
memcpy(dbname, dbname_start, cnt);
|
||||
dbname[cnt] = '\0';
|
||||
decode_objectname(decoded_dbname, dbname, FN_REFLEN);
|
||||
my_afree(dbname);
|
||||
|
||||
char *tbname_start = dbname_end + 1;
|
||||
decode_objectname(decoded_tbname, tbname_start, FN_REFLEN);
|
||||
}
|
||||
|
||||
bool anyRowInTable(string& schema, string& tableName, int sessionID)
|
||||
{
|
||||
//find a column in the table
|
||||
@@ -914,18 +888,6 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
|
||||
{
|
||||
CreateTableStatement* createTable = dynamic_cast <CreateTableStatement*> ( &stmt );
|
||||
|
||||
//@Bug 5767. To handle key words inside `` for a tablename.
|
||||
if (!(boost::iequals(schema, createTable->fTableDef->fQualifiedName->fSchema)) || !(boost::iequals(table, createTable->fTableDef->fQualifiedName->fName)))
|
||||
{
|
||||
rc = 1;
|
||||
thd->get_stmt_da()->set_overwrite_status(true);
|
||||
|
||||
thd->raise_error_printf(ER_CHECK_NOT_IMPLEMENTED, (IDBErrorInfo::instance()->errorMsg(ERR_CREATE_DATATYPE_NOT_SUPPORT)).c_str());
|
||||
ci->alterTableState = cal_connection_info::NOT_ALTER;
|
||||
ci->isAlter = false;
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool matchedCol = false;
|
||||
bool isFirstTimestamp = true;
|
||||
|
||||
@@ -2400,14 +2362,10 @@ int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* crea
|
||||
return 1;
|
||||
}
|
||||
|
||||
// @bug 3908. error out primary key for now.
|
||||
// Send notice if primary key specified that it is not supported
|
||||
if (table_arg->key_info && table_arg->key_info->name.length && string(table_arg->key_info->name.str) == "PRIMARY")
|
||||
{
|
||||
string emsg = logging::IDBErrorInfo::instance()->errorMsg(ERR_CONSTRAINTS);
|
||||
setError(thd, ER_CHECK_NOT_IMPLEMENTED, emsg);
|
||||
ci.alterTableState = cal_connection_info::NOT_ALTER;
|
||||
ci.isAlter = false;
|
||||
return 1;
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, WARN_OPTION_IGNORED, "INDEXES");
|
||||
}
|
||||
|
||||
int compressiontype = get_compression_type(thd);
|
||||
@@ -2452,22 +2410,25 @@ int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* crea
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if this is a "CREATE TABLE ... LIKE " statement.
|
||||
// Check if this is one of
|
||||
// * "CREATE TABLE ... LIKE "
|
||||
// * "ALTER TABLE ... ENGINE=Columnstore"
|
||||
// * "CREATE TABLE ... AS ..."
|
||||
// If so generate a full create table statement using the properties of
|
||||
// the source table. Note that source table has to be a columnstore table and
|
||||
// we only check for currently supported options.
|
||||
//
|
||||
|
||||
if (thd->lex->create_info.like())
|
||||
if ((thd->lex->sql_command == SQLCOM_CREATE_TABLE && thd->lex->used_tables) ||
|
||||
(thd->lex->sql_command == SQLCOM_ALTER_TABLE && create_info->used_fields & HA_CREATE_USED_ENGINE) ||
|
||||
(thd->lex->create_info.like()))
|
||||
{
|
||||
TABLE_SHARE *share = table_arg->s;
|
||||
my_bitmap_map *old_map; // To save the read_set
|
||||
char datatype_buf[MAX_FIELD_WIDTH], def_value_buf[MAX_FIELD_WIDTH];
|
||||
String datatype, def_value;
|
||||
ostringstream oss;
|
||||
string tbl_name (name+2);
|
||||
std::replace(tbl_name.begin(), tbl_name.end(), '/', '.');
|
||||
string tbl_name = string(share->db.str) + "." + string(share->table_name.str);
|
||||
|
||||
// Save the current read_set map and mark it for read
|
||||
old_map= tmp_use_all_columns(table_arg, table_arg->read_set);
|
||||
@@ -2505,10 +2466,18 @@ int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* crea
|
||||
|
||||
// Process table level options
|
||||
|
||||
/* TODO: uncomment when we support AUTO_INCREMENT
|
||||
if (create_info->auto_increment_value > 1)
|
||||
{
|
||||
oss << " AUTO_INCREMENT=" << create_info->auto_increment_value;
|
||||
}
|
||||
*/
|
||||
|
||||
if (create_info->auto_increment_value > 1)
|
||||
{
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, WARN_OPTION_IGNORED, "AUTO INCREMENT");
|
||||
}
|
||||
|
||||
|
||||
if (share->table_charset)
|
||||
{
|
||||
@@ -2539,7 +2508,7 @@ int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* crea
|
||||
|
||||
oss << ";";
|
||||
stmt = oss.str();
|
||||
|
||||
|
||||
tmp_restore_column_map(table_arg->read_set, old_map);
|
||||
}
|
||||
|
||||
@@ -2600,7 +2569,7 @@ int ha_mcs_impl_delete_table_(const char* db, const char* name, cal_connection_i
|
||||
|
||||
string emsg;
|
||||
|
||||
if (thd->lex->sql_command == SQLCOM_DROP_DB)
|
||||
if ((thd->lex->sql_command == SQLCOM_DROP_DB) || (thd->lex->sql_command == SQLCOM_ALTER_TABLE))
|
||||
{
|
||||
std::string tableName(name);
|
||||
tableName.erase(0, tableName.rfind("/") + 1);
|
||||
@@ -2627,19 +2596,28 @@ int ha_mcs_impl_rename_table_(const char* from, const char* to, cal_connection_i
|
||||
THD* thd = current_thd;
|
||||
string emsg;
|
||||
|
||||
string dbFrom, tblFrom, dbTo, tblTo;
|
||||
char decodedDbFrom[FN_REFLEN];
|
||||
char decodedTblFrom[FN_REFLEN];
|
||||
char decodedDbTo[FN_REFLEN];
|
||||
char decodedTblTo[FN_REFLEN];
|
||||
decode_file_path(from, decodedDbFrom, decodedTblFrom);
|
||||
decode_file_path(to, decodedDbTo, decodedTblTo);
|
||||
string stmt;
|
||||
string tblFrom (from+2);
|
||||
size_t pos = tblFrom.find("/");
|
||||
std::string dbFrom = tblFrom.substr(0, pos);
|
||||
tblFrom = tblFrom.erase(0, pos + 1);
|
||||
|
||||
string tblTo (to+2);
|
||||
pos = tblTo.find("/");
|
||||
std::string dbTo = tblTo.substr(0, pos);
|
||||
tblTo = tblTo.erase(0, pos + 1);
|
||||
|
||||
string stmt;
|
||||
|
||||
if (thd->slave_thread && !get_replication_slave(thd))
|
||||
return 0;
|
||||
|
||||
// This is a temporary table rename, we don't use the temporary table name
|
||||
// so this is a NULL op
|
||||
if (tblFrom.compare(0, 4, "#sql") == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//@bug 5660. Error out REAL DDL/DML on slave node.
|
||||
// When the statement gets here, it's NOT SSO or RESTRICT
|
||||
if (ci.isSlaveNode)
|
||||
@@ -2649,24 +2627,21 @@ int ha_mcs_impl_rename_table_(const char* from, const char* to, cal_connection_i
|
||||
return 1;
|
||||
}
|
||||
|
||||
// User moves tables b/w namespaces.
|
||||
size_t tblFromLength= strlen(decodedTblFrom);
|
||||
if (!memcmp(decodedTblFrom, decodedTblTo, tblFromLength))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
stmt.assign("alter table `");
|
||||
stmt.append(decodedTblFrom);
|
||||
stmt.assign("alter table `");
|
||||
stmt.append(dbFrom);
|
||||
stmt.append("`.`");
|
||||
stmt.append(tblFrom);
|
||||
stmt.append("` rename to `");
|
||||
stmt.append(decodedTblTo);
|
||||
stmt.append(dbTo);
|
||||
stmt.append("`.`");
|
||||
stmt.append(tblTo);
|
||||
stmt.append("`;");
|
||||
|
||||
string db;
|
||||
if (thd->db.length)
|
||||
db = thd->db.str;
|
||||
else
|
||||
db.assign(decodedDbFrom);
|
||||
db.assign(dbFrom);
|
||||
|
||||
int rc = ProcessDDLStatement(stmt, db, "", tid2sid(thd->thread_id), emsg);
|
||||
|
||||
|
@@ -3306,6 +3306,11 @@ ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupp
|
||||
case Item::WINDOW_FUNC_ITEM:
|
||||
return buildWindowFunctionColumn(*(ref->ref), gwi, nonSupport);
|
||||
|
||||
case Item::SUBSELECT_ITEM:
|
||||
gwi.fatalParseError = true;
|
||||
gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_SELECT_SUB);
|
||||
break;
|
||||
|
||||
default:
|
||||
gwi.fatalParseError = true;
|
||||
gwi.parseErrorText = "Unknown REF item";
|
||||
@@ -4559,10 +4564,9 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
|
||||
if (gwi.clauseType == SELECT)
|
||||
gwi.aggOnSelect = true;
|
||||
|
||||
// N.B. argument_count() is the # of formal parms to the agg fcn. InifniDB only supports 1 argument
|
||||
// TODO: Support more than one parm
|
||||
#if 0
|
||||
|
||||
// Argument_count() is the # of formal parms to the agg fcn. Columnstore
|
||||
// only supports 1 argument except UDAnF and GROUP_CONCAT
|
||||
// TODO: Support more than one parm for COUNT(DISTINCT)
|
||||
if (isp->argument_count() != 1 && isp->sum_func() != Item_sum::GROUP_CONCAT_FUNC
|
||||
&& isp->sum_func() != Item_sum::UDF_SUM_FUNC)
|
||||
{
|
||||
@@ -4571,7 +4575,6 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
AggregateColumn* ac = NULL;
|
||||
|
||||
if (isp->sum_func() == Item_sum::GROUP_CONCAT_FUNC)
|
||||
@@ -7560,6 +7563,11 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
|
||||
{
|
||||
gwi.fatalParseError = true;
|
||||
}
|
||||
else if ((ord_item->type() == Item::FUNC_ITEM) && (((Item_func*)ord_item)->functype() == Item_func::COLLATE_FUNC))
|
||||
{
|
||||
push_warning(gwi.thd, Sql_condition::WARN_LEVEL_NOTE, WARN_OPTION_IGNORED, "COLLATE is ignored in ColumnStore");
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = buildReturnedColumn(ord_item, gwi, gwi.fatalParseError);
|
||||
|
@@ -2361,8 +2361,11 @@ int ha_mcs_impl_rnd_init(TABLE* table)
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE )
|
||||
// If ALTER TABLE and not ENGINE= we don't need rnd_init (gets us in a bad state)
|
||||
if ((thd->lex->sql_command == SQLCOM_ALTER_TABLE) && !(thd->lex->create_info.used_fields & HA_CREATE_USED_ENGINE))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Update and delete code
|
||||
if ( ((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI))
|
||||
|
@@ -42,6 +42,26 @@ void disable_indices_for_CEJ(THD *thd_)
|
||||
}
|
||||
}
|
||||
|
||||
bool optimize_unflattened_subqueries_(SELECT_LEX *select_lex)
|
||||
{
|
||||
bool result = false;
|
||||
TABLE_LIST *tbl;
|
||||
List_iterator_fast<TABLE_LIST> li(select_lex->leaf_tables);
|
||||
while (!result && (tbl= li++))
|
||||
{
|
||||
if (tbl->is_view_or_derived())
|
||||
{
|
||||
SELECT_LEX *dsl = tbl->derived->first_select();
|
||||
result = optimize_unflattened_subqueries_(dsl);
|
||||
}
|
||||
}
|
||||
|
||||
result = (!result) ?
|
||||
select_lex->optimize_unflattened_subqueries(false) : true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void mutate_optimizer_flags(THD *thd_)
|
||||
{
|
||||
// MCOL-2178 Disable all optimizer flags as it was in the fork.
|
||||
@@ -775,7 +795,9 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
|
||||
}
|
||||
|
||||
COND *conds = simplify_joins_(join, select_lex->join_list, join->conds, TRUE, FALSE);
|
||||
select_lex->optimize_unflattened_subqueries(false);
|
||||
// MCOL-3747 IN-TO-EXISTS rewrite inside MDB didn't add
|
||||
// an equi-JOIN condition.
|
||||
optimize_unflattened_subqueries_(select_lex);
|
||||
|
||||
if (conds)
|
||||
{
|
||||
@@ -817,8 +839,13 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
|
||||
{
|
||||
handler= new ha_columnstore_select_handler(thd, select_lex);
|
||||
mcs_handler_info mhi= mcs_handler_info(reinterpret_cast<void*>(handler), SELECT);
|
||||
// this::table is the place for the result set
|
||||
int rc= ha_cs_impl_pushdown_init(&mhi, handler->table);
|
||||
// handler::table is the place for the result set
|
||||
int rc= 0;
|
||||
// Skip execution for EXPLAIN queries
|
||||
if (!thd->lex->describe)
|
||||
{
|
||||
rc= ha_cs_impl_pushdown_init(&mhi, handler->table);
|
||||
}
|
||||
|
||||
// Return SH even if init fails b/c CS changed SELECT_LEX structures
|
||||
// with simplify_joins_()
|
||||
|
@@ -93,7 +93,19 @@ static int generate_result(BRM::OID_t oid, BRM::DBRM* emp, TABLE* table, THD* th
|
||||
char oidDirName[WriteEngine::FILE_NAME_SIZE];
|
||||
char fullFileName[WriteEngine::FILE_NAME_SIZE];
|
||||
char dbDir[WriteEngine::MAX_DB_DIR_LEVEL][WriteEngine::MAX_DB_DIR_NAME_SIZE];
|
||||
config::Config* config = config::Config::makeConfig();
|
||||
|
||||
config::Config* config;
|
||||
|
||||
try
|
||||
{
|
||||
config = config::Config::makeConfig();
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
|
||||
return ER_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
WriteEngine::Config we_config;
|
||||
off_t fileSize = 0;
|
||||
off_t compressedFileSize = 0;
|
||||
|
@@ -1,486 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
|
||||
# This file is public domain and comes with NO WARRANTY of any kind
|
||||
|
||||
# MySQL daemon start/stop script.
|
||||
|
||||
# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
|
||||
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
|
||||
# When this is done the mysql server will be started when the machine is
|
||||
# started and shut down when the systems goes down.
|
||||
|
||||
# Comments to support chkconfig on RedHat Linux
|
||||
# chkconfig: 2345 64 36
|
||||
# description: A very fast and reliable SQL database engine.
|
||||
|
||||
# Comments to support LSB init script conventions
|
||||
### BEGIN INIT INFO
|
||||
# Provides: mysql
|
||||
# Required-Start: $local_fs $network $remote_fs
|
||||
# Should-Start: ypbind nscd ldap ntpd xntpd
|
||||
# Required-Stop: $local_fs $network $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: start and stop MySQL
|
||||
# Description: MySQL is a very fast and reliable SQL database engine.
|
||||
### END INIT INFO
|
||||
|
||||
# If you install MySQL on some other places than /usr/local/mariadb/columnstore/mysql, then you
|
||||
# have to do one of the following things for this script to work:
|
||||
#
|
||||
# - Run this script from within the MySQL installation directory
|
||||
# - Create a /etc/my.cnf file with the following information:
|
||||
# [mysqld]
|
||||
# basedir=<path-to-mysql-installation-directory>
|
||||
# - Add the above to any other configuration file (for example ~/.my.ini)
|
||||
# and copy my_print_defaults to /usr/bin
|
||||
# - Add the path to the mysql-installation-directory to the basedir variable
|
||||
# below.
|
||||
#
|
||||
# If you want to affect other MySQL variables, you should make your changes
|
||||
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
|
||||
|
||||
# If you change base dir, you must also change datadir. These may get
|
||||
# overwritten by settings in the MySQL configuration files.
|
||||
|
||||
|
||||
# Source function library.
|
||||
if [ -f /etc/init.d/functions ]; then
|
||||
. /etc/init.d/functions
|
||||
fi
|
||||
|
||||
# Default value, in seconds, afterwhich the script should timeout waiting
|
||||
# for server start.
|
||||
# Value here is overriden by value in my.cnf.
|
||||
# 0 means don't wait at all
|
||||
# Negative numbers mean to wait indefinitely
|
||||
service_startup_timeout=90
|
||||
user=`whoami 2>/dev/null`
|
||||
|
||||
# Lock directory
|
||||
lockdir=/var/lock/subsys
|
||||
|
||||
lock_file_path="$lockdir/mysql-Columnstore"
|
||||
|
||||
# The following variables are only set for letting mysql.server find things.
|
||||
|
||||
# Set some defaults
|
||||
mysqld_pid_file_path=
|
||||
if test -z "$basedir"
|
||||
then
|
||||
basedir=/usr
|
||||
bindir=/usr/bin
|
||||
if test -z "$datadir"
|
||||
then
|
||||
datadir=/var/lib/mysql
|
||||
fi
|
||||
sbindir=/usr/bin
|
||||
bindir=/usr/bin
|
||||
else
|
||||
bindir="$basedir/bin"
|
||||
if test -z "$datadir"
|
||||
then
|
||||
datadir="$basedir/data"
|
||||
fi
|
||||
sbindir="$basedir/sbin"
|
||||
if test -f "$basedir/sbin/mysqld"
|
||||
then
|
||||
bindir="$basedir/bin"
|
||||
else
|
||||
bindir="$basedir/bin"
|
||||
fi
|
||||
fi
|
||||
|
||||
# datadir_set is used to determine if datadir was set (and so should be
|
||||
# *not* set inside of the --basedir= handler.)
|
||||
datadir_set=
|
||||
|
||||
#
|
||||
# Use LSB init script functions for printing messages, if possible
|
||||
#
|
||||
lsb_functions="/lib/lsb/init-functions"
|
||||
if test -f $lsb_functions ; then
|
||||
. $lsb_functions >/dev/null 2>&1
|
||||
else
|
||||
# Include non-LSB RedHat init functions to make systemctl redirect work
|
||||
init_functions="/etc/init.d/functions"
|
||||
if test -f $init_functions; then
|
||||
. $init_functions >/dev/null 2>&1
|
||||
fi
|
||||
log_success_msg()
|
||||
{
|
||||
echo " SUCCESS! $@"
|
||||
}
|
||||
log_failure_msg()
|
||||
{
|
||||
echo " ERROR! $@"
|
||||
}
|
||||
fi
|
||||
|
||||
PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin"
|
||||
export PATH
|
||||
|
||||
mode=$1 # start or stop
|
||||
|
||||
[ $# -ge 1 ] && shift
|
||||
|
||||
case `echo "testing\c"`,`echo -n testing` in
|
||||
*c*,-n*) echo_n= echo_c= ;;
|
||||
*c*,*) echo_n=-n echo_c= ;;
|
||||
*) echo_n= echo_c='\c' ;;
|
||||
esac
|
||||
|
||||
parse_server_arguments() {
|
||||
for arg do
|
||||
case "$arg" in
|
||||
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'`
|
||||
bindir="$basedir/bin"
|
||||
if test -z "$datadir_set"; then
|
||||
datadir="$basedir/data"
|
||||
fi
|
||||
sbindir="$basedir/sbin"
|
||||
if test -f "$basedir/sbin/mysqld"
|
||||
then
|
||||
bindir="$basedir/bin"
|
||||
else
|
||||
bindir="$basedir/bin"
|
||||
fi
|
||||
#bindir="$basedir/bin"
|
||||
;;
|
||||
--datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'`
|
||||
datadir_set=1
|
||||
;;
|
||||
--log-basename=*|--hostname=*|--loose-log-basename=*)
|
||||
mysqld_pid_file_path=`echo "$arg.pid" | sed -e 's/^[^=]*=//'`
|
||||
;;
|
||||
--pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
||||
--service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Get arguments from the my.cnf file,
|
||||
# the only group, which is read from now on is [mysqld]
|
||||
if test -x ./bin/my_print_defaults
|
||||
then
|
||||
print_defaults="./bin/my_print_defaults"
|
||||
elif test -x $bindir/my_print_defaults
|
||||
then
|
||||
print_defaults="$bindir/my_print_defaults"
|
||||
elif test -x $bindir/mysql_print_defaults
|
||||
then
|
||||
print_defaults="$bindir/mysql_print_defaults"
|
||||
else
|
||||
# Try to find basedir in /etc/my.cnf
|
||||
conf=/etc/my.cnf
|
||||
print_defaults=
|
||||
if test -r $conf
|
||||
then
|
||||
subpat='^[^=]*basedir[^=]*=\(.*\)$'
|
||||
dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf`
|
||||
for d in $dirs
|
||||
do
|
||||
d=`echo $d | sed -e 's/[ ]//g'`
|
||||
if test -x "$d/bin/my_print_defaults"
|
||||
then
|
||||
print_defaults="$d/bin/my_print_defaults"
|
||||
break
|
||||
fi
|
||||
if test -x "$d/bin/mysql_print_defaults"
|
||||
then
|
||||
print_defaults="$d/bin/mysql_print_defaults"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Hope it's in the PATH ... but I doubt it
|
||||
test -z "$print_defaults" && print_defaults="my_print_defaults"
|
||||
fi
|
||||
|
||||
#
|
||||
# Read defaults file from 'basedir'. If there is no defaults file there
|
||||
# check if it's in the old (depricated) place (datadir) and read it from there
|
||||
#
|
||||
|
||||
extra_args=""
|
||||
if test -r "$basedir/my.cnf"
|
||||
then
|
||||
extra_args="-e $basedir/my.cnf"
|
||||
else
|
||||
if test -r "$datadir/my.cnf"
|
||||
then
|
||||
extra_args="-e $datadir/my.cnf"
|
||||
fi
|
||||
fi
|
||||
|
||||
parse_server_arguments `$print_defaults $extra_args --mysqld mysql.server`
|
||||
parse_server_arguments "$@"
|
||||
|
||||
# wait for the pid file to disappear
|
||||
wait_for_gone () {
|
||||
pid="$1" # process ID of the program operating on the pid-file
|
||||
pid_file_path="$2" # path to the PID file.
|
||||
|
||||
i=0
|
||||
crash_protection="by checking again"
|
||||
|
||||
while test $i -ne $service_startup_timeout ; do
|
||||
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
: # the server still runs
|
||||
else
|
||||
if test ! -s "$pid_file_path"; then
|
||||
# no server process and no pid-file? great, we're done!
|
||||
log_success_msg
|
||||
return 0
|
||||
fi
|
||||
|
||||
# pid-file exists, the server process doesn't.
|
||||
# it must've crashed, and mysqld_safe will restart it
|
||||
if test -n "$crash_protection"; then
|
||||
crash_protection=""
|
||||
sleep 5
|
||||
continue # Check again.
|
||||
fi
|
||||
|
||||
kill_by_pid
|
||||
# Cannot help it
|
||||
log_failure_msg "The server quit without updating PID file ($pid_file_path)."
|
||||
return 1 # not waiting any more.
|
||||
fi
|
||||
|
||||
echo $echo_n ".$echo_c"
|
||||
i=`expr $i + 1`
|
||||
sleep 1
|
||||
|
||||
done
|
||||
|
||||
log_failure_msg
|
||||
kill_by_pid
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
wait_for_ready () {
|
||||
|
||||
i=0
|
||||
while test $i -ne $service_startup_timeout ; do
|
||||
|
||||
if $bindir/mysqladmin ping >/dev/null 2>&1; then
|
||||
log_success_msg
|
||||
return 0
|
||||
elif kill -0 $! 2>/dev/null ; then
|
||||
: # mysqld_safe is still running
|
||||
else
|
||||
# mysqld_safe is no longer running, abort the wait loop
|
||||
break
|
||||
fi
|
||||
|
||||
echo $echo_n ".$echo_c"
|
||||
i=`expr $i + 1`
|
||||
sleep 1
|
||||
|
||||
done
|
||||
|
||||
log_failure_msg
|
||||
return 1
|
||||
}
|
||||
#
|
||||
# Set pid file if not given
|
||||
#
|
||||
if test -z "$mysqld_pid_file_path"
|
||||
then
|
||||
mysqld_pid_file_path=$datadir/`hostname`.pid
|
||||
else
|
||||
case "$mysqld_pid_file_path" in
|
||||
/* ) ;;
|
||||
* ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# source other config files
|
||||
[ -f /etc/default/mysql ] && . /etc/default/mysql
|
||||
[ -f /etc/sysconfig/mysql ] && . /etc/sysconfig/mysql
|
||||
[ -f /etc/conf.d/mysql ] && . /etc/conf.d/mysql
|
||||
|
||||
kill_by_pid() {
|
||||
# let's see if we can kill the 2 mysql procs by hand
|
||||
# get the our mysql from ps
|
||||
eval $(ps -ef | grep "bin/mysqld" | grep -v grep | head -1 | awk '{printf "pid=%d\n", $2}')
|
||||
|
||||
if [ -n "$pid" ]; then
|
||||
ppid=$(ps -o ppid= -p $pid)
|
||||
kill -9 $ppid
|
||||
sleep 1
|
||||
kill -9 $pid
|
||||
echo $echo_n "Force shutting down (no/bad pid file)"
|
||||
log_success_msg
|
||||
exit 0
|
||||
fi
|
||||
return
|
||||
}
|
||||
|
||||
case "$mode" in
|
||||
'start')
|
||||
# Start daemon
|
||||
|
||||
# Safeguard (relative paths, core dumps..)
|
||||
cd $basedir
|
||||
|
||||
echo $echo_n "Starting MySQL"
|
||||
if test -x $bindir/mysqld_safe
|
||||
then
|
||||
# Give extra arguments to mysqld with the my.cnf file. This script
|
||||
# may be overwritten at next upgrade.
|
||||
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" >/dev/null 2>&1 &
|
||||
wait_for_ready; return_value=$?
|
||||
|
||||
# Make lock for RedHat / SuSE
|
||||
if test -w "$lockdir"
|
||||
then
|
||||
touch "$lock_file_path"
|
||||
fi
|
||||
|
||||
exit $return_value
|
||||
else
|
||||
log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
|
||||
fi
|
||||
;;
|
||||
|
||||
'stop')
|
||||
# Stop daemon. We use a signal here to avoid having to know the
|
||||
# root password.
|
||||
|
||||
if test -s "$mysqld_pid_file_path"
|
||||
then
|
||||
mysqld_pid=`cat "$mysqld_pid_file_path"`
|
||||
|
||||
if (kill -0 $mysqld_pid 2>/dev/null)
|
||||
then
|
||||
echo $echo_n "Shutting down MySQL"
|
||||
kill $mysqld_pid
|
||||
# mysqld should remove the pid file when it exits, so wait for it.
|
||||
wait_for_gone $mysqld_pid "$mysqld_pid_file_path"; return_value=$?
|
||||
else
|
||||
log_failure_msg "MySQL server process #$mysqld_pid is not running!"
|
||||
kill_by_pid
|
||||
rm "$mysqld_pid_file_path"
|
||||
fi
|
||||
|
||||
# Delete lock for RedHat / SuSE
|
||||
if test -f "$lock_file_path"
|
||||
then
|
||||
rm -f "$lock_file_path"
|
||||
fi
|
||||
exit $return_value
|
||||
else
|
||||
kill_by_pid
|
||||
log_failure_msg "MySQL server PID file could not be found!"
|
||||
fi
|
||||
;;
|
||||
|
||||
'restart')
|
||||
# Stop the service and regardless of whether it was
|
||||
# running or not, start it again.
|
||||
if $0 stop "$@"; then
|
||||
if ! $0 start "$@"; then
|
||||
log_failure_msg "Failed to restart server."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log_failure_msg "Failed to stop running server, so refusing to try to start."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
'reload'|'force-reload')
|
||||
if test -s "$mysqld_pid_file_path" ; then
|
||||
read mysqld_pid < "$mysqld_pid_file_path"
|
||||
kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
|
||||
touch "$mysqld_pid_file_path"
|
||||
else
|
||||
log_failure_msg "MySQL PID file could not be found!"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
'status')
|
||||
# First, check to see if pid file exists
|
||||
if test -s "$mysqld_pid_file_path" ; then
|
||||
read mysqld_pid < "$mysqld_pid_file_path"
|
||||
if kill -0 $mysqld_pid 2>/dev/null ; then
|
||||
log_success_msg "MySQL running ($mysqld_pid)"
|
||||
exit 0
|
||||
else
|
||||
log_failure_msg "MySQL is not running, but PID file exists"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Try to find appropriate mysqld process
|
||||
mysqld_pid=`pidof $bindir/mysqld`
|
||||
|
||||
# test if multiple pids exist
|
||||
pid_count=`echo $mysqld_pid | wc -w`
|
||||
if test $pid_count -gt 1 ; then
|
||||
log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)"
|
||||
exit 5
|
||||
elif test -z $mysqld_pid ; then
|
||||
if test -f "$lock_file_path" ; then
|
||||
log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists"
|
||||
exit 2
|
||||
fi
|
||||
log_failure_msg "MySQL is not running"
|
||||
exit 3
|
||||
else
|
||||
log_failure_msg "MySQL is running but PID file could not be found"
|
||||
exit 4
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
'configtest')
|
||||
# Safeguard (relative paths, core dumps..)
|
||||
cd $basedir
|
||||
echo $echo_n "Testing MySQL configuration syntax"
|
||||
daemon=$bindir/mysqld
|
||||
if test -x $bindir/mysqld
|
||||
then
|
||||
daemon=$bindir/mysqld
|
||||
elif test -x $sbindir/mysqld
|
||||
then
|
||||
daemon=$sbindir/mysqld
|
||||
elif test -x `which mysqld`
|
||||
then
|
||||
daemon=`which mysqld`
|
||||
else
|
||||
log_failure_msg "Unable to locate the mysqld binary!"
|
||||
exit 1
|
||||
fi
|
||||
help_out=`$daemon --help 2>&1`; r=$?
|
||||
if test "$r" != 0 ; then
|
||||
log_failure_msg "$help_out"
|
||||
log_failure_msg "There are syntax errors in the server configuration. Please fix them!"
|
||||
else
|
||||
log_success_msg "Syntax OK"
|
||||
fi
|
||||
exit $r
|
||||
;;
|
||||
'bootstrap')
|
||||
if test "$_use_systemctl" == 1 ; then
|
||||
log_failure_msg "Please use galera_new_cluster to start the mariadb service with --wsrep-new-cluster"
|
||||
exit 1
|
||||
fi
|
||||
# Bootstrap the cluster, start the first node
|
||||
# that initiate the cluster
|
||||
echo $echo_n "Bootstrapping the cluster.. "
|
||||
$0 start $other_args --wsrep-new-cluster
|
||||
exit $?
|
||||
;;
|
||||
*)
|
||||
# usage
|
||||
basename=`basename "$0"`
|
||||
echo "Usage: $basename {start|stop|restart|reload|force-reload|status|configtest|bootstrap} [ MySQL server options ]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user