| 1 | /* |
| 2 | A temporary header to resolve WebScaleSQL vs MariaDB differences |
| 3 | when porting MyRocks to MariaDB. |
| 4 | */ |
| 5 | #ifndef RDB_MARIADB_SERVER_PORT_H |
| 6 | #define RDB_MARIADB_SERVER_PORT_H |
| 7 | |
| 8 | #include "my_global.h" /* ulonglong */ |
| 9 | #include "atomic_stat.h" |
| 10 | #include "my_pthread.h" |
| 11 | #include <mysql/psi/mysql_table.h> |
| 12 | #include <mysql/psi/mysql_thread.h> |
| 13 | |
| 14 | /* |
| 15 | Code that is on SQL layer in facebook/mysql-5.6, |
| 16 | but is part of the storage engine in MariaRocks |
| 17 | */ |
| 18 | #include <regex> |
| 19 | |
| 20 | class Regex_list_handler |
| 21 | { |
| 22 | private: |
| 23 | #if defined(HAVE_PSI_INTERFACE) |
| 24 | const PSI_rwlock_key& m_key; |
| 25 | #endif |
| 26 | |
| 27 | char m_delimiter; |
| 28 | std::string m_bad_pattern_str; |
| 29 | const std::regex* m_pattern; |
| 30 | |
| 31 | mutable mysql_rwlock_t m_rwlock; |
| 32 | |
| 33 | Regex_list_handler(const Regex_list_handler& other)= delete; |
| 34 | Regex_list_handler& operator=(const Regex_list_handler& other)= delete; |
| 35 | |
| 36 | public: |
| 37 | #if defined(HAVE_PSI_INTERFACE) |
| 38 | Regex_list_handler(const PSI_rwlock_key& key, |
| 39 | char delimiter= ',') : |
| 40 | m_key(key), |
| 41 | #else |
| 42 | Regex_list_handler(char delimiter= ',') : |
| 43 | #endif |
| 44 | m_delimiter(delimiter), |
| 45 | m_bad_pattern_str("" ), |
| 46 | m_pattern(nullptr) |
| 47 | { |
| 48 | mysql_rwlock_init(key, &m_rwlock); |
| 49 | } |
| 50 | |
| 51 | ~Regex_list_handler() |
| 52 | { |
| 53 | mysql_rwlock_destroy(&m_rwlock); |
| 54 | delete m_pattern; |
| 55 | } |
| 56 | |
| 57 | // Set the list of patterns |
| 58 | bool set_patterns(const std::string& patterns); |
| 59 | |
| 60 | // See if a string matches at least one pattern |
| 61 | bool matches(const std::string& str) const; |
| 62 | |
| 63 | // See the list of bad patterns |
| 64 | const std::string& bad_pattern() const |
| 65 | { |
| 66 | return m_bad_pattern_str; |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | void warn_about_bad_patterns(const Regex_list_handler* regex_list_handler, |
| 71 | const char *name); |
| 72 | |
| 73 | void print_keydup_error(TABLE *table, KEY *key, myf errflag, |
| 74 | const THD *thd, const char *org_table_name=NULL); |
| 75 | |
| 76 | #endif |
| 77 | |