Skip to content

Commit

Permalink
Merge pull request #4516 from sysown/v2.x_240421
Browse files Browse the repository at this point in the history
Various code split for more readibility
  • Loading branch information
renecannao authored Apr 23, 2024
2 parents dd13f0f + 229b5d7 commit 57bf59a
Show file tree
Hide file tree
Showing 31 changed files with 3,157 additions and 3,440 deletions.
27 changes: 27 additions & 0 deletions include/GTID_Server_Data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef CLASS_GTID_Server_Data_H
#define CLASS_GTID_Server_Data_H
class GTID_Server_Data {
public:
char *address;
uint16_t port;
uint16_t mysql_port;
char *data;
size_t len;
size_t size;
size_t pos;
struct ev_io *w;
char uuid_server[64];
unsigned long long events_read;
gtid_set_t gtid_executed;
bool active;
GTID_Server_Data(struct ev_io *_w, char *_address, uint16_t _port, uint16_t _mysql_port);
void resize(size_t _s);
~GTID_Server_Data();
bool readall();
bool writeout();
bool read_next_gtid();
bool gtid_exists(char *gtid_uuid, uint64_t gtid_trxid);
void read_all_gtids();
void dump();
};
#endif // CLASS_GTID_Server_Data_H
5 changes: 4 additions & 1 deletion include/MySQL_HostGroups_Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class MyHGC;
std::string gtid_executed_to_string(gtid_set_t& gtid_executed);
void addGtid(const gtid_t& gtid, gtid_set_t& gtid_executed);

#include "GTID_Server_Data.h"

/*
class GTID_Server_Data {
public:
char *address;
Expand All @@ -154,7 +157,7 @@ class GTID_Server_Data {
void read_all_gtids();
void dump();
};

*/


class MySrvConnList {
Expand Down
25 changes: 25 additions & 0 deletions include/MySQL_Prepared_Stmt_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef CLASS_MySQL_Prepared_Stmt_info_H
#define CLASS_MySQL_Prepared_Stmt_info_H
class MySQL_Prepared_Stmt_info {
public:
uint32_t statement_id;
uint16_t num_columns;
uint16_t num_params;
uint16_t warning_count;
uint16_t pending_num_columns;
uint16_t pending_num_params;
MySQL_Prepared_Stmt_info(unsigned char *pkt, unsigned int length) {
pkt += 5;
statement_id = CPY4(pkt);
pkt += sizeof(uint32_t);
num_columns = CPY2(pkt);
pkt += sizeof(uint16_t);
num_params = CPY2(pkt);
pkt += sizeof(uint16_t);
pkt++; // reserved_1
warning_count = CPY2(pkt);
pending_num_columns=num_columns;
pending_num_params=num_params;
}
};
#endif // CLASS_MySQL_Prepared_Stmt_info_H
11 changes: 1 addition & 10 deletions include/MySQL_Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "proxysql.h"
#include "cpp.h"
#include "MySQL_Variables.h"
#include "MySQL_Prepared_Stmt_info.h"

#define RESULTSET_BUFLEN 16300

Expand Down Expand Up @@ -70,16 +71,6 @@ class MySQL_ResultSet {
unsigned long long current_size();
};

class MySQL_Prepared_Stmt_info {
public:
uint32_t statement_id;
uint16_t num_columns;
uint16_t num_params;
uint16_t warning_count;
uint16_t pending_num_columns;
uint16_t pending_num_params;
MySQL_Prepared_Stmt_info(unsigned char *, unsigned int);
};

uint8_t mysql_decode_length(unsigned char *ptr, uint64_t *len);

Expand Down
22 changes: 22 additions & 0 deletions include/MySQL_encode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef CLASS_MySQL_encode_H
#define CLASS_MySQL_encode_H
#ifdef DEBUG
void __dump_pkt(const char *func, unsigned char *_ptr, unsigned int len);
#endif // DEBUG
char *sha1_pass_hex(char *sha1_pass);
double proxy_my_rnd(struct rand_struct *rand_st);
void proxy_create_random_string(char *_to, uint length, struct rand_struct *rand_st);
int write_encoded_length(unsigned char *p, uint64_t val, uint8_t len, char prefix);
int write_encoded_length_and_string(unsigned char *p, uint64_t val, uint8_t len, char prefix, char *string);
void proxy_compute_sha1_hash_multi(uint8_t *digest, const char *buf1, int len1, const char *buf2, int len2);
void proxy_compute_sha1_hash(uint8_t *digest, const char *buf, int len);
void proxy_compute_two_stage_sha1_hash(const char *password, size_t pass_len, uint8_t *hash_stage1, uint8_t *hash_stage2);
void proxy_my_crypt(char *to, const uint8_t *s1, const uint8_t *s2, uint len);
unsigned char decode_char(char x);
void unhex_pass(uint8_t *out, const char *in);
void proxy_scramble(char *to, const char *message, const char *password);
bool proxy_scramble_sha1(char *pass_reply, const char *message, const char *sha1_sha1_pass, char *sha1_pass);
unsigned int CPY3(unsigned char *ptr);
uint64_t CPY8(unsigned char *ptr);
uint8_t mysql_encode_length(uint64_t len, char *hd);
#endif // CLASS_MySQL_encode_H
22 changes: 22 additions & 0 deletions include/QP_rule_text.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef CLASS_QR_RULE_H
#define CLASS_QR_RULE_H

#define QP_RE_MOD_CASELESS 1
#define QP_RE_MOD_GLOBAL 2

class QP_rule_text_hitsonly {
public:
char **pta;
QP_rule_text_hitsonly(QP_rule_t *QPr);
~QP_rule_text_hitsonly();
};

class QP_rule_text {
public:
char **pta;
int num_fields;
QP_rule_text(QP_rule_t *QPr);
~QP_rule_text();
};

#endif // CLASS_QR_RULE_H
3 changes: 0 additions & 3 deletions include/c_tokenizer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* c_tokenizer.h */
// some code borrowed from http://www.cplusplus.com/faq/sequences/strings/split/

#pragma once
#ifndef C_TOKENIZER_H
Expand Down Expand Up @@ -34,7 +32,6 @@ const char* free_tokenizer( tokenizer_t* tokenizer );
const char* tokenize( tokenizer_t* tokenizer );
char * mysql_query_digest_first_stage(const char* const q, int q_len, char** const fst_cmnt, char* const buf);
char * mysql_query_digest_second_stage(const char* const q, int q_len, char** const fst_cmnt, char* const buf);
char * mysql_query_digest_and_first_comment(char *s , int len , char **first_comment, char *buf);
char * mysql_query_digest_and_first_comment_2(const char* const q, int q_len, char** const fst_cmnt, char* const buf);
char * mysql_query_digest_and_first_comment_one_it(char *s , int len , char **first_comment, char *buf);
char * mysql_query_strip_comments(char *s , int len);
Expand Down
2 changes: 2 additions & 0 deletions include/proxysql_admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include "ProxySQL_RESTAPI_Server.hpp"

#include "proxysql_typedefs.h"

typedef struct { uint32_t hash; uint32_t key; } t_symstruct;
class ProxySQL_Config;
class ProxySQL_Restapi;
Expand Down
5 changes: 5 additions & 0 deletions include/proxysql_typedefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifndef PROXYSQL_COMMON_TYPEDEF
#define PROXYSQL_COMMON_TYPEDEF
typedef std::unordered_map<std::uint64_t, void *> umap_query_digest;
typedef std::unordered_map<std::uint64_t, char *> umap_query_digest_text;
#endif // PROXYSQL_COMMON_TYPEDEF
4 changes: 1 addition & 3 deletions include/query_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include "khash.h"
KHASH_MAP_INIT_STR(khStrInt, int)

typedef std::unordered_map<std::uint64_t, void *> umap_query_digest;
typedef std::unordered_map<std::uint64_t, char *> umap_query_digest_text;

#include "proxysql_typedefs.h"

#define WUS_NOT_FOUND 0 // couldn't find any filter
#define WUS_OFF 1 // allow the query
Expand Down
Loading

0 comments on commit 57bf59a

Please sign in to comment.