Skip to content

Commit

Permalink
Refactor mysql server for runtime (#274)
Browse files Browse the repository at this point in the history
* feat(docs): add version v0.2.0 docs
Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* feat(pisa-proxy, runtime): refactor mysql handle_command

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* feat(pisa-proxy, runtime): add handshake

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, protocol): fix ServerHandshakeCodec args

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, protocol): fix encode, auth error

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* feat(pisa-proxy, protocol): add session trait

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, protocol): fix com_execute, remove println

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* feat(pisa-proxy, protocol): add autocommit to session

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, protocol): add session set_db in handle int db

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, runtime): reafctor server complete

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* chore(pisa-proxy, runtime): add comments, remove unused code

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* chore(pisa-proxy, protocol): add comments

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* feat(pisa-proxy, runtime): refactor mysql handle_command

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* feat(pisa-proxy, runtime): add handshake

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, protocol): fix ServerHandshakeCodec args

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, protocol): fix encode, auth error

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* feat(pisa-proxy, protocol): add session trait

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, protocol): fix com_execute, remove println

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* feat(pisa-proxy, protocol): add autocommit to session

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, runtime): reafctor server complete

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, protocol): add session set_db in handle int db

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* chore(pisa-proxy, runtime): add comments, remove unused code

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* fix(pisa-proxy, chore): fix conflicts for rebase

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* chore(pisa-proxy, protocol): remove unused enum

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* chore(docs): reset doc

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

* chore(docs): fix space

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>

Signed-off-by: xuanyuan300 <xuanyuan300@gmail.com>
  • Loading branch information
xuanyuan300 authored Aug 25, 2022
1 parent 29f2e9c commit 906d394
Show file tree
Hide file tree
Showing 17 changed files with 1,001 additions and 1,241 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,4 @@ spec:
- ^select
target: read
type: regex
```
```
2 changes: 1 addition & 1 deletion pisa-proxy/protocol/mysql/src/client/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ mod test {
use super::{handshake, ClientAuth};
use crate::client::{
codec::ClientCodec,
stream::{LocalStream, StreamWrapper},
stream::LocalStream,
};

#[test]
Expand Down
1 change: 1 addition & 0 deletions pisa-proxy/protocol/mysql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub mod row;
pub mod server;
pub mod util;
mod value;
pub mod session;

#[macro_use]
extern crate lazy_static;
87 changes: 86 additions & 1 deletion pisa-proxy/protocol/mysql/src/mysql_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,91 @@ iota! {
,COM_RESET_CONNECTION
}

#[allow(non_camel_case_types)]
#[derive(Debug)]
#[repr(u8)]
pub enum ComType {
SLEEP,
QUIT,
INIT_DB,
QUERY,
FIELD_LIST,
CREATE_DB,
DROP_DB,
REFRESH,
SHUTDOWN,
STATISTICS,
PROCESS_INFO,
CONNECT,
PROCESS_KILL,
DEBUG,
PING,
TIME,
DELAYED_INSERT,
CHANGE_USER,
BINLOG_DUMP,
TABLE_DUMP,
CONNECT_OUT,
REGISTER_SLAVE,
STMT_PREPARE,
STMT_EXECUTE,
STMT_SEND_LONG_DATA,
STMT_CLOSE,
STMT_RESET,
SET_OPTION,
STMT_FETCH,
DAEMON,
BINLOG_DUMP_GTID,
RESET_CONNECTION,
}

impl From<u8> for ComType {
#[inline]
fn from(t: u8) -> ComType {
unsafe { std::mem::transmute::<u8, ComType>(t) }
}
}

impl AsRef<str> for ComType {
#[inline]
fn as_ref(&self) -> &str {
match self {
Self::SLEEP => "sleep",
Self::QUIT => "quit",
Self::INIT_DB => "init_db",
Self::QUERY => "query",
Self::FIELD_LIST => "field_list",
Self::CREATE_DB => "create_db",
Self::DROP_DB => "drop_db",
Self::REFRESH => "refresh",
Self::SHUTDOWN => "shutdown",
Self::STATISTICS => "statistics",
Self::PROCESS_INFO => "process_info",
Self::CONNECT => "connect",
Self::PROCESS_KILL => "process_kill",
Self::DEBUG => "debug",
Self::PING => "ping",
Self::TIME => "time",
Self::DELAYED_INSERT => "delayed_insert",
Self::CHANGE_USER => "change_user",
Self::BINLOG_DUMP => "binlog_dump",
Self::TABLE_DUMP => "table_dump",
Self::CONNECT_OUT => "connect_out",
Self::REGISTER_SLAVE => "register_slave",
Self::STMT_PREPARE => "stmt_prepare",
Self::STMT_EXECUTE => "stmt_execute",
Self::STMT_SEND_LONG_DATA => "stmt_send_long_data",
Self::STMT_CLOSE => "stmt_close",
Self::STMT_RESET => "stmt_reset",
Self::SET_OPTION => "set_option",
Self::STMT_FETCH => "stmt_fetch",
Self::DAEMON => "daemon",
Self::BINLOG_DUMP_GTID => "binlog_dump_gtid",
Self::RESET_CONNECTION => "reset_connection",
}
}
}

iota! {
pub const CLIENT_LONG_PASSWORD: u32 = 1 << iota;
,CLIENT_FOUND_ROWS
Expand Down Expand Up @@ -308,4 +393,4 @@ mod test {

assert_eq!(column_flag.as_ref(), "enum");
}
}
}
Loading

0 comments on commit 906d394

Please sign in to comment.