1 | |
2 | // vim:sw=2:ai |
3 | |
4 | /* |
5 | * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. |
6 | * Copyright (C) 2011 Kentoku SHIBA |
7 | * See COPYRIGHT.txt for details. |
8 | */ |
9 | |
10 | #ifndef DENA_HSTCPCLI_HPP |
11 | #define DENA_HSTCPCLI_HPP |
12 | |
13 | #define HANDLERSOCKET_MYSQL_UTIL 1 |
14 | |
15 | #include "mysql_version.h" |
16 | #if MYSQL_VERSION_ID < 50500 |
17 | #include "mysql_priv.h" |
18 | #include <mysql/plugin.h> |
19 | #else |
20 | #include "sql_priv.h" |
21 | #include "probes_mysql.h" |
22 | #endif |
23 | |
24 | #include "config.hpp" |
25 | #include "socket.hpp" |
26 | #include "string_ref.hpp" |
27 | #include "string_buffer.hpp" |
28 | |
29 | namespace dena { |
30 | |
31 | struct hstcpcli_filter { |
32 | string_ref filter_type; |
33 | string_ref op; |
34 | size_t ff_offset; |
35 | string_ref val; |
36 | hstcpcli_filter() : ff_offset(0) { } |
37 | }; |
38 | |
39 | struct hstcpcli_i; |
40 | typedef hstcpcli_i *hstcpcli_ptr; |
41 | |
42 | struct hstresult { |
43 | hstresult(); |
44 | virtual ~hstresult(); |
45 | string_buffer readbuf; |
46 | size_t response_end_offset; |
47 | size_t num_flds; |
48 | size_t cur_row_offset; |
49 | DYNAMIC_ARRAY flds; |
50 | }; |
51 | |
52 | struct hstcpcli_i { |
53 | virtual ~hstcpcli_i() { } |
54 | virtual void close() = 0; |
55 | virtual int reconnect() = 0; |
56 | virtual bool stable_point() = 0; |
57 | virtual void request_buf_auth(const char *secret, const char *typ) = 0; |
58 | virtual void request_buf_open_index(size_t pst_id, const char *dbn, |
59 | const char *tbl, const char *idx, const char *retflds, |
60 | const char *filflds = 0) = 0; |
61 | virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op, |
62 | const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip, |
63 | const string_ref& mod_op, const string_ref *mvs, size_t mvslen, |
64 | const hstcpcli_filter *fils = 0, size_t filslen = 0, |
65 | int invalues_keypart = -1, const string_ref *invalues = 0, |
66 | size_t invalueslen = 0) = 0; // FIXME: too long |
67 | virtual size_t request_buf_append(const char *start, const char *finish) = 0; |
68 | virtual void request_reset() = 0; |
69 | virtual int request_send() = 0; |
70 | virtual int response_recv(size_t& num_flds_r) = 0; |
71 | virtual int get_result(hstresult& result) = 0; |
72 | virtual const string_ref *get_next_row() = 0; |
73 | virtual const string_ref *get_next_row_from_result(hstresult& result) = 0; |
74 | virtual void response_buf_remove() = 0; |
75 | virtual int get_error_code() = 0; |
76 | virtual String& get_error() = 0; |
77 | virtual void clear_error() = 0; |
78 | virtual int set_timeout(int send_timeout, int recv_timeout) = 0; |
79 | virtual size_t get_num_req_bufd() = 0; |
80 | virtual size_t get_num_req_sent() = 0; |
81 | virtual size_t get_num_req_rcvd() = 0; |
82 | virtual size_t get_response_end_offset() = 0; |
83 | virtual const char *get_readbuf_begin() = 0; |
84 | virtual const char *get_readbuf_end() = 0; |
85 | virtual const char *get_writebuf_begin() = 0; |
86 | virtual size_t get_writebuf_size() = 0; |
87 | virtual void write_error_to_log(const char *func_name, const char *file_name, |
88 | ulong line_no) = 0; |
89 | static hstcpcli_ptr create(const socket_args& args); |
90 | }; |
91 | |
92 | }; |
93 | |
94 | #endif |
95 | |
96 | |