Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
MariaRocks port: fix rocksdb.collation, rocksdb.collation_exception
- port Regex_list_handler from facebook/mysql-5.6/sql/handler.cc put it into a separate file in storage/rocksdb directory - Adjust the build process so that the main library is build with Regex_list_handler (which has dependencies on the server), while RocksDB tools are built without it. - Un-comment @@rdb_collation_exceptions handling in ha_rocksdb.cc - Also adjust rocksdb_set_collation_exception_list() to free the old variable value and alloc the new one.
- Loading branch information
Showing
6 changed files
with
193 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#include <my_config.h> | ||
|
||
|
||
/* MySQL includes */ | ||
#include "./debug_sync.h" | ||
#include "./my_bit.h" | ||
#include "./my_stacktrace.h" | ||
#include "./sql_table.h" | ||
#include "./my_global.h" | ||
#include "./log.h" | ||
#include <mysys_err.h> | ||
#include <mysql/psi/mysql_table.h> | ||
#ifdef MARIAROCKS_NOT_YET | ||
#include <mysql/thread_pool_priv.h> | ||
#endif | ||
|
||
#include <string> | ||
|
||
/* MyRocks includes */ | ||
#include "./rdb_threads.h" | ||
|
||
#include "rdb_mariadb_server_port.h" | ||
|
||
void warn_about_bad_patterns(const Regex_list_handler* regex_list_handler, | ||
const char *name) | ||
{ | ||
// There was some invalid regular expression data in the patterns supplied | ||
|
||
// NO_LINT_DEBUG | ||
sql_print_warning("Invalid pattern in %s: %s", name, | ||
regex_list_handler->bad_pattern().c_str()); | ||
} | ||
|
||
|
||
/* | ||
Set the patterns string. If there are invalid regex patterns they will | ||
be stored in m_bad_patterns and the result will be false, otherwise the | ||
result will be true. | ||
*/ | ||
bool Regex_list_handler::set_patterns(const std::string& pattern_str) | ||
{ | ||
bool pattern_valid= true; | ||
|
||
// Create a normalized version of the pattern string with all delimiters | ||
// replaced by the '|' character | ||
std::string norm_pattern= pattern_str; | ||
std::replace(norm_pattern.begin(), norm_pattern.end(), m_delimiter, '|'); | ||
|
||
// Make sure no one else is accessing the list while we are changing it. | ||
mysql_rwlock_wrlock(&m_rwlock); | ||
|
||
// Clear out any old error information | ||
m_bad_pattern_str.clear(); | ||
|
||
try | ||
{ | ||
// Replace all delimiters with the '|' operator and create the regex | ||
// Note that this means the delimiter can not be part of a regular | ||
// expression. This is currently not a problem as we are using the comma | ||
// character as a delimiter and commas are not valid in table names. | ||
const std::regex* pattern= new std::regex(norm_pattern); | ||
|
||
// Free any existing regex information and setup the new one | ||
delete m_pattern; | ||
m_pattern= pattern; | ||
} | ||
catch (const std::regex_error& e) | ||
{ | ||
// This pattern is invalid. | ||
pattern_valid= false; | ||
|
||
// Put the bad pattern into a member variable so it can be retrieved later. | ||
m_bad_pattern_str= pattern_str; | ||
} | ||
|
||
// Release the lock | ||
mysql_rwlock_unlock(&m_rwlock); | ||
|
||
return pattern_valid; | ||
} | ||
|
||
bool Regex_list_handler::matches(const std::string& str) const | ||
{ | ||
DBUG_ASSERT(m_pattern != nullptr); | ||
|
||
// Make sure no one else changes the list while we are accessing it. | ||
mysql_rwlock_rdlock(&m_rwlock); | ||
|
||
// See if the table name matches the regex we have created | ||
bool found= std::regex_match(str, *m_pattern); | ||
|
||
// Release the lock | ||
mysql_rwlock_unlock(&m_rwlock); | ||
|
||
return found; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
A temporary header to resolve WebScaleSQL vs MariaDB differences | ||
when porting MyRocks to MariaDB. | ||
*/ | ||
#ifndef RDB_MARIADB_SERVER_PORT_H | ||
#define RDB_MARIADB_SERVER_PORT_H | ||
|
||
#include "my_global.h" /* ulonglong */ | ||
#include "atomic_stat.h" | ||
#include "my_pthread.h" | ||
#include <mysql/psi/mysql_table.h> | ||
#include <mysql/psi/mysql_thread.h> | ||
|
||
/* | ||
Code that is on SQL layer in facebook/mysql-5.6, | ||
but is part of the storage engine in MariaRocks | ||
*/ | ||
#include <regex> | ||
|
||
class Regex_list_handler | ||
{ | ||
private: | ||
#if defined(HAVE_PSI_INTERFACE) | ||
const PSI_rwlock_key& m_key; | ||
#endif | ||
|
||
char m_delimiter; | ||
std::string m_bad_pattern_str; | ||
const std::regex* m_pattern; | ||
|
||
mutable mysql_rwlock_t m_rwlock; | ||
|
||
Regex_list_handler(const Regex_list_handler& other)= delete; | ||
Regex_list_handler& operator=(const Regex_list_handler& other)= delete; | ||
|
||
public: | ||
#if defined(HAVE_PSI_INTERFACE) | ||
Regex_list_handler(const PSI_rwlock_key& key, | ||
char delimiter= ',') : | ||
m_key(key), | ||
#else | ||
Regex_list_handler(char delimiter= ',') : | ||
#endif | ||
m_delimiter(delimiter), | ||
m_bad_pattern_str(""), | ||
m_pattern(nullptr) | ||
{ | ||
mysql_rwlock_init(key, &m_rwlock); | ||
} | ||
|
||
~Regex_list_handler() | ||
{ | ||
mysql_rwlock_destroy(&m_rwlock); | ||
delete m_pattern; | ||
} | ||
|
||
// Set the list of patterns | ||
bool set_patterns(const std::string& patterns); | ||
|
||
// See if a string matches at least one pattern | ||
bool matches(const std::string& str) const; | ||
|
||
// See the list of bad patterns | ||
const std::string& bad_pattern() const | ||
{ | ||
return m_bad_pattern_str; | ||
} | ||
}; | ||
|
||
void warn_about_bad_patterns(const Regex_list_handler* regex_list_handler, | ||
const char *name); | ||
|
||
#endif |