Skip to content

Commit

Permalink
Merge pull request #972 from minichate/backport-sql-mode-timezone
Browse files Browse the repository at this point in the history
Backport sql_mode and time_zone to 1.3.x
  • Loading branch information
renecannao authored Mar 28, 2017
2 parents 10bf524 + 8f6c52a commit dba6db1
Show file tree
Hide file tree
Showing 7 changed files with 675 additions and 1 deletion.
24 changes: 24 additions & 0 deletions include/MySQL_Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ class MySQL_Session_userinfo {
bool set_schemaname(char *, int);
};
*/

// these structs will be used for various regex hardcoded
// their initial use will be for sql_log_bin , sql_mode and time_zone
// issues #509 , #815 and #816
class Session_Regex {
private:
void *opt;
void *re;
char *s;
public:
Session_Regex(char *p);
~Session_Regex();
bool match(char *m);
};

class Query_Info {
public:
SQP_par_t QueryParserArgs;
Expand Down Expand Up @@ -84,7 +99,13 @@ class MySQL_Session
bool handler_again___verify_init_connect();
bool handler_again___verify_backend_autocommit();
bool handler_again___verify_backend_user_schema();
bool handler_again___verify_backend_sql_log_bin();
bool handler_again___verify_backend_sql_mode();
bool handler_again___verify_backend_time_zone();
bool handler_again___status_SETTING_INIT_CONNECT(int *);
bool handler_again___status_SETTING_SQL_LOG_BIN(int *);
bool handler_again___status_SETTING_SQL_MODE(int *);
bool handler_again___status_SETTING_TIME_ZONE(int *);
bool handler_again___status_CHANGING_SCHEMA(int *);
bool handler_again___status_CONNECTING_SERVER(int *);
bool handler_again___status_CHANGING_USER_SERVER(int *);
Expand All @@ -100,6 +121,9 @@ class MySQL_Session
//this pointer is always initialized inside handler().
// it is an attempt to start simplifying the complexing of handler()
PtrSize_t *pktH;

Session_Regex **match_regexes;

public:
void * operator new(size_t);
void operator delete(void *);
Expand Down
5 changes: 5 additions & 0 deletions include/MySQL_Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#define ADMIN_HOSTGROUP -2
#define STATS_HOSTGROUP -3

#define MYSQL_DEFAULT_SQL_MODE ""
#define MYSQL_DEFAULT_TIME_ZONE "SYSTEM"


static unsigned int near_pow_2 (unsigned int n) {
unsigned int i = 1;
Expand Down Expand Up @@ -342,6 +345,8 @@ class MySQL_Threads_Handler
int query_processor_iterations;
int long_query_time;
char *init_connect;
char *default_sql_mode;
char *default_time_zone;
#ifdef DEBUG
bool session_debug;
#endif /* DEBUG */
Expand Down
8 changes: 8 additions & 0 deletions include/mysql_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define STATUS_MYSQL_CONNECTION_LOCK_TABLES 0x00000010
#define STATUS_MYSQL_CONNECTION_TEMPORARY_TABLE 0x00000020
#define STATUS_MYSQL_CONNECTION_GET_LOCK 0x00000040
#define STATUS_MYSQL_CONNECTION_SQL_LOG_BIN0 0x00000100
#define STATUS_MYSQL_CONNECTION_FOUND_ROWS 0x00000080

class MySQL_Connection_userinfo {
Expand Down Expand Up @@ -38,6 +39,10 @@ class MySQL_Connection {
public:
struct {
char *server_version;
char *sql_mode;
char *time_zone;
uint32_t sql_mode_int;
uint32_t time_zone_int;
uint32_t max_allowed_pkt;
uint32_t server_capabilities;
unsigned int compression_min_length;
Expand All @@ -46,6 +51,7 @@ class MySQL_Connection {
uint8_t protocol_version;
uint8_t charset;
int8_t last_set_autocommit;
uint8_t sql_log_bin;
bool autocommit;
} options;
struct {
Expand Down Expand Up @@ -93,6 +99,7 @@ class MySQL_Connection {
bool set_autocommit(bool);
uint8_t set_charset(uint8_t);

void set_status_sql_log_bin0(bool);
void set_status_transaction(bool);
void set_status_compression(bool);
void set_status_get_lock(bool);
Expand All @@ -108,6 +115,7 @@ class MySQL_Connection {
bool get_status_temporary_table();
bool get_status_prepared_statement();
bool get_status_user_variable();
bool get_status_sql_log_bin0();
bool get_status_found_rows();
void connect_start();
void connect_cont(short event);
Expand Down
7 changes: 7 additions & 0 deletions include/proxysql_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ enum session_status {
CHANGING_USER_CLIENT,
CHANGING_USER_SERVER,
SETTING_INIT_CONNECT,
SETTING_SQL_LOG_BIN,
SETTING_SQL_MODE,
SETTING_TIME_ZONE,
FAST_FORWARD,
PROCESSING_STMT_PREPARE,
PROCESSING_STMT_EXECUTE,
Expand Down Expand Up @@ -781,6 +784,8 @@ MySQL_HostGroups_Manager *MyHGM;
__thread char *mysql_thread___default_schema;
__thread char *mysql_thread___server_version;
__thread char *mysql_thread___init_connect;
__thread char *mysql_thread___default_sql_mode;
__thread char *mysql_thread___default_time_zone;
__thread int mysql_thread___max_allowed_packet;
__thread int mysql_thread___max_transaction_time;
__thread int mysql_thread___threshold_query_length;
Expand Down Expand Up @@ -872,6 +877,8 @@ extern MySQL_HostGroups_Manager *MyHGM;
extern __thread char *mysql_thread___default_schema;
extern __thread char *mysql_thread___server_version;
extern __thread char *mysql_thread___init_connect;
extern __thread char *mysql_thread___default_sql_mode;
extern __thread char *mysql_thread___default_time_zone;
extern __thread int mysql_thread___max_allowed_packet;
extern __thread int mysql_thread___max_transaction_time;
extern __thread int mysql_thread___threshold_query_length;
Expand Down
Loading

0 comments on commit dba6db1

Please sign in to comment.