Skip to content

Commit

Permalink
Merge branch 'v1.4.0' of https://github.com/sysown/proxysql into v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
renecannao committed Dec 20, 2016
2 parents d20e130 + 517bae0 commit b118592
Show file tree
Hide file tree
Showing 43 changed files with 50 additions and 3,410 deletions.
15 changes: 0 additions & 15 deletions include/MySQL_Authentication.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef __CLASS_MYSQL_AUTHENTICATION_H
#define __CLASS_MYSQL_AUTHENTICATION_H

//#include "btree_map.h"
#include "proxysql.h"
#include "cpp.h"

Expand Down Expand Up @@ -30,20 +29,12 @@ typedef struct _account_details_t {
#endif /* DEBUG */
#define MYSQL_AUTHENTICATION_VERSION "0.2.0902" DEB

/*
#define AUTH_TABLE_MYSQL_USERS "CREATE TABLE mysql_users ( username VARCHAR NOT NULL , password VARCHAR , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , use_ssl INT CHECK (use_ssl IN (0,1)) NOT NULL DEFAULT 0, default_hostgroup INT NOT NULL DEFAULT 0, default_schema VARCHAR, schema_locked INT CHECK (schema_locked IN (0,1)) NOT NULL DEFAULT 0, transaction_persistent INT CHECK (transaction_persistent IN (0,1)) NOT NULL DEFAULT 0, fast_forward INT CHECK (fast_forward IN (0,1)) NOT NULL DEFAULT 0, backend INT CHECK (backend IN (0,1)) NOT NULL DEFAULT 1, frontend INT CHECK (frontend IN (0,1)) NOT NULL DEFAULT 1, PRIMARY KEY (username, backend), UNIQUE (username, frontend))"
#define AUTH_TABLE_MYSQL_USERS_INCOMING "CREATE TABLE mysql_users_incoming ( username VARCHAR NOT NULL , password VARCHAR , active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1 , use_ssl INT CHECK (use_ssl IN (0,1)) NOT NULL DEFAULT 0, default_hostgroup INT NOT NULL DEFAULT 0, default_schema VARCHAR, schema_locked INT CHECK (schema_locked IN (0,1)) NOT NULL DEFAULT 0, transaction_persistent INT CHECK (transaction_persistent IN (0,1)) NOT NULL DEFAULT 0, fast_forward INT CHECK (fast_forward IN (0,1)) NOT NULL DEFAULT 0, backend INT CHECK (backend IN (0,1)) NOT NULL DEFAULT 1, frontend INT CHECK (frontend IN (0,1)) NOT NULL DEFAULT 1, PRIMARY KEY (username, backend), UNIQUE (username, frontend))"
*/


//typedef btree::btree_map<uint64_t, account_details_t *> BtMap_auth;
typedef std::unordered_map<uint64_t, account_details_t *> umap_auth;

class PtrArray;

typedef struct _creds_group_t {
rwlock_t lock;
//BtMap_auth bt_map;
umap_auth bt_map;
PtrArray *cred_array;
} creds_group_t;
Expand All @@ -53,8 +44,6 @@ class MySQL_Authentication {
creds_group_t creds_backends;
creds_group_t creds_frontends;
bool _reset(enum cred_username_type usertype);
// SQLite3DB *authdb;
// rwlock_t rwlock;
public:
MySQL_Authentication();
~MySQL_Authentication();
Expand All @@ -69,10 +58,6 @@ class MySQL_Authentication {
void set_all_inactive(enum cred_username_type usertype);
void remove_inactives(enum cred_username_type usertype);
bool set_SHA1(char *username, enum cred_username_type usertype, void *sha_pass);
// void rdlock();
// void rdunlock();
// void wrlock();
// void wrunlock();
};

#endif /* __CLASS_MYSQL_AUTHENTICATION_H */
29 changes: 0 additions & 29 deletions include/MySQL_Data_Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,11 @@ typedef struct _queue_t {
unsigned int head;
unsigned int tail;
unsigned int partial;
//unsigned char *pkt;
PtrSize_t pkt;
mysql_hdr hdr;
} queue_t;


/*
typedef struct _mysql_data_buffer_t {
unsigned char *buffer;
unsigned int size;
unsigned int head;
unsigned int tail;
mysql_hdr hdr;
unsigned int partial;
unsigned char *pkt;
} mysql_data_buffer_t;
*/

// this class avoid copying data
class MyDS_real_query {
public:
Expand Down Expand Up @@ -59,7 +46,6 @@ class MyDS_real_query {
class MySQL_Data_Stream
{
private:
//mysql_data_buffer_t bufferOUT;
int array2buffer();
int buffer2array();
void generate_compressed_packet();
Expand Down Expand Up @@ -137,12 +123,6 @@ class MySQL_Data_Stream

uint8_t pkt_sid;

// struct {
// char *ptr;
// unsigned int size;
// } mysql_real_query;


MySQL_Data_Stream();
~MySQL_Data_Stream();

Expand Down Expand Up @@ -171,13 +151,11 @@ class MySQL_Data_Stream

void unplug_backend();

//int assign_mshge(unsigned int);
int myds_connect(char *, int, int *); // the data stream MUST be initialized

void check_data_flow();
int assign_fd_from_mysql_conn();

//void move_from_OUT_to_OUTpending();
unsigned char * resultset2buffer(bool);
void buffer2resultset(unsigned char *, unsigned int);

Expand Down Expand Up @@ -205,12 +183,5 @@ class MySQL_Data_Stream
}
void free_mysql_real_query();
void reinit_queues();
// void destroy_MySQL_Connection() {
// MySQL_Connection *mc=myconn;
// detach_connection();
// unplug_backend();
// delete mc;
// }

};
#endif /* __CLASS_MYSQL_DATA_STREAM_H */
6 changes: 0 additions & 6 deletions include/MySQL_HostGroups_Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ enum MySerStatus {
MYSQL_SERVER_STATUS_SHUNNED_REPLICATION_LAG
};



class MySrvConnList {
private:
PtrArray *conns;
Expand Down Expand Up @@ -97,7 +95,6 @@ class MySrvC { // MySQL Server Container
bool shunned_and_kill_all_connections; // if a serious failure is detected, this will cause all connections to die even if the server is just shunned
bool use_ssl;
char *comment;
//uint8_t charset;
MySrvConnList *ConnectionsUsed;
MySrvConnList *ConnectionsFree;
MySrvC(char *, uint16_t, unsigned int, enum MySerStatus, unsigned int, unsigned int _max_connections, unsigned int _max_replication_lag, unsigned int _use_ssl, unsigned int _max_latency_ms, char *_comment);
Expand All @@ -110,7 +107,6 @@ class MySrvList { // MySQL Server List
private:
MyHGC *myhgc;
int find_idx(MySrvC *);
// int find_idx(MySQL_Connection *);
public:
PtrArray *servers;
unsigned int cnt();
Expand Down Expand Up @@ -182,8 +178,6 @@ class MySQL_HostGroups_Manager {
wqueue<MySQL_Connection *> queue;
MySQL_HostGroups_Manager();
~MySQL_HostGroups_Manager();
// void rdlock();
// void rdunlock();
void wrlock();
void wrunlock();
bool server_add(unsigned int hid, char *add, uint16_t p=3306, unsigned int _weight=1, enum MySerStatus status=MYSQL_SERVER_STATUS_ONLINE, unsigned int _comp=0, unsigned int _max_connections=100, unsigned int _max_replication_lag=0, unsigned int _use_ssl=0, unsigned int _max_latency_ms=0, char *comment=NULL);
Expand Down
5 changes: 0 additions & 5 deletions include/MySQL_Monitor.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#ifndef __CLASS_MYSQL_MONITOR_H
#define __CLASS_MYSQL_MONITOR_H
//#include <thread>
//#include <list>
//#include "btree_map.h"
#include "proxysql.h"
#include "cpp.h"
#include "thread.h"
Expand Down Expand Up @@ -72,8 +69,6 @@ class WorkItem {

class MySQL_Monitor {
private:
//unsigned int MySQL_Monitor__thread_MySQL_Thread_Variables_version;
//MySQL_Thread *mysql_thr;
std::vector<table_def_t *> *tables_defs_monitor;
void insert_into_tables_defs(std::vector<table_def_t *> *tables_defs, const char *table_name, const char *table_def);
void drop_tables_defs(std::vector<table_def_t *> *tables_defs);
Expand Down
15 changes: 1 addition & 14 deletions include/MySQL_PreparedStatement.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class stmt_execute_metadata_t {
uint16_t num_params;
MYSQL_BIND *binds;
my_bool *is_nulls;
//MySQL_STMT_Global_info *stmt_info;
unsigned long *lengths;
void *pkt;
stmt_execute_metadata_t() {
Expand Down Expand Up @@ -155,14 +154,11 @@ class MySQL_STMTs_meta {
auto s=m.find(global_statement_id);
if (s!=m.end()) { // found
stmt_execute_metadata_t *sem=s->second;
//__sync_fetch_and_sub(&sem->stmt_info->ref_count,1); // decrease reference count
delete sem;
num_entries--;
m.erase(s);
}
}

//bool erase(uint32_t global_statement_id);
};

// class MySQL_STMTs_local associates a global statement ID with a local statement ID for a specific connection
Expand All @@ -185,16 +181,7 @@ class MySQL_STMTs_local {
}
~MySQL_STMTs_local();
void insert(uint32_t global_statement_id, MYSQL_STMT *stmt);
/*
// we declare it here to be inline
void insert(uint32_t global_statement_id, MYSQL_STMT *stmt) {
std::pair<std::map<uint32_t, MYSQL_STMT *>::iterator,bool> ret;
ret=m.insert(std::make_pair(global_statement_id, stmt));
if (ret.second==true) {
num_entries++;
}
}
*/

// we declare it here to be inline
MYSQL_STMT * find(uint32_t global_statement_id) {
auto s=m.find(global_statement_id);
Expand Down
31 changes: 0 additions & 31 deletions include/MySQL_Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,6 @@

#define RESULTSET_BUFLEN 16300

/*
class stmt_execute_metadata_t {
public:
uint32_t stmt_id;
uint8_t flags;
uint16_t num_params;
MYSQL_BIND *binds;
my_bool *is_nulls;
unsigned long *lengths;
void *pkt;
stmt_execute_metadata_t() {
binds=NULL;
is_nulls=NULL;
lengths=NULL;
pkt=NULL;
}
~stmt_execute_metadata_t() {
if (binds)
free(binds);
if (is_nulls)
free(is_nulls);
if (lengths)
free(lengths);
}
};
*/

class MySQL_ResultSet {
private:
public:
Expand Down Expand Up @@ -60,7 +33,6 @@ class MySQL_ResultSet {
unsigned long long current_size();
};


class MySQL_Prepared_Stmt_info {
public:
uint32_t statement_id;
Expand Down Expand Up @@ -90,8 +62,6 @@ class MySQL_Protocol {
}
void init(MySQL_Data_Stream **, MySQL_Connection_userinfo *, MySQL_Session *);
int parse_mysql_pkt(PtrSize_t *, MySQL_Data_Stream *);
// void generate_server_handshake();
// void generate_server_handshake(MySQL_Data_Stream *);

// members get as arguments:
// - a data stream (optionally NULL for some)
Expand Down Expand Up @@ -133,7 +103,6 @@ class MySQL_Protocol {
// prepared statements
bool generate_STMT_PREPARE_RESPONSE(uint8_t sequence_id, MySQL_STMT_Global_info *stmt_info);

//stmt_execute_metadata_t * get_binds_from_pkt(void *ptr, unsigned int size, uint16_t num_params);
stmt_execute_metadata_t * get_binds_from_pkt(void *ptr, unsigned int size, MySQL_STMT_Global_info *stmt_info, stmt_execute_metadata_t **stmt_meta);
};
#endif /* __CLASS_MYSQL_PROTOCOL_H */
24 changes: 0 additions & 24 deletions include/MySQL_Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@
#include "proxysql.h"
#include "cpp.h"

/*
class MySQL_Session_userinfo {
public:
char *username;
char *password;
char *schemaname;
MySQL_Session_userinfo();
~MySQL_Session_userinfo();
void set(char *, char *, char *);
void set(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
Expand All @@ -31,8 +17,6 @@ class Session_Regex {
bool match(char *m);
};



class Query_Info {
public:
SQP_par_t QueryParserArgs;
Expand Down Expand Up @@ -115,11 +99,6 @@ class MySQL_Session
bool handler_again___status_CHANGING_AUTOCOMMIT(int *);


// void return_MySQL_Connection_To_Poll(MySQL_Data_Stream *);


// MySQL_STMT_Manager *Session_STMT_Manager;

//this pointer is always initialized inside handler().
// it is an attempt to start simplifying the complexing of handler()
PtrSize_t *pktH;
Expand Down Expand Up @@ -182,7 +161,6 @@ class MySQL_Session
StmtLongDataHandler *SLDH;

MySQL_Session();
// MySQL_Session(int);
~MySQL_Session();

void set_unhealthy();
Expand All @@ -199,8 +177,6 @@ class MySQL_Session
}
status=e;
}
//MySQL_Protocol myprot_client;
//MySQL_Protocol myprot_server;
int handler();

void (*admin_func) (MySQL_Session *arg, ProxySQL_Admin *, PtrSize_t *pkt);
Expand Down
Loading

0 comments on commit b118592

Please sign in to comment.