17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_PLUGIN_PROTOCOL_H
21
#define DRIZZLED_PLUGIN_PROTOCOL_H
20
#ifndef DRIZZLED_PLUGIN_CLIENT_H
21
#define DRIZZLED_PLUGIN_CLIENT_H
23
23
#include <drizzled/sql_list.h>
24
24
#include <drizzled/item.h>
35
* This class allows new client sources to be written. This could be through
36
* network protocols, in-process threads, or any other client source that can
37
* provide commands and handle result sets. The current implementation is
38
* file-descriptor based, so for non-fd client sources (like from another
39
* thread), derived classes will need to use a pipe() for event notifications.
41
virtual ~Protocol() {}
51
* Get attached session from the client object.
52
* @retval Session object that is attached, NULL if none.
54
virtual Session *getSession(void)
60
* Attach session to the client object.
61
* @param[in] session_arg Session object to attach, or NULL to clear.
43
63
virtual void setSession(Session *session_arg)
45
65
session= session_arg;
48
virtual Session *getSession(void)
53
virtual bool isConnected()= 0;
54
virtual void setError(char error)= 0;
55
virtual bool haveError(void)= 0;
56
virtual bool wasAborted(void)= 0;
57
virtual bool haveMoreData(void)= 0;
69
* Get file descriptor associated with client object.
70
* @retval File descriptor that is attached, -1 if none.
72
virtual int getFileDescriptor(void)= 0;
75
* Check to see if the client is currently connected.
76
* @retval Boolean value representing connected state.
78
virtual bool isConnected(void)= 0;
81
* Check to see if the client is actively reading.
82
* @retval Boolean value representing reading state.
58
84
virtual bool isReading(void)= 0;
87
* Check to see if the client is actively writing.
88
* @retval Boolean value representing writing state.
59
90
virtual bool isWriting(void)= 0;
60
virtual bool setFileDescriptor(int fd)=0;
61
virtual int fileDescriptor(void)=0;
62
virtual bool authenticate(void)=0;
63
virtual bool readCommand(char **packet, uint32_t *packet_length)=0;
64
virtual void sendOK()= 0;
65
virtual void sendEOF()= 0;
66
virtual void sendError(uint32_t sql_errno, const char *err)=0;
67
virtual void close()= 0;
68
virtual void forceClose()= 0;
69
virtual void prepareForResend()= 0;
70
virtual void free()= 0;
71
virtual bool write()= 0;
93
* Flush all data that has been buffered with store() methods.
94
* @retval Boolean indicating success or failure.
96
virtual bool flush(void)= 0;
99
* Close the client object.
101
virtual void close(void)= 0;
104
* Perform handshake and authorize client if needed.
106
virtual bool authenticate(void)= 0;
109
* Read command from client.
111
virtual bool readCommand(char **packet, uint32_t *packet_length)= 0;
113
/* Send responses. */
114
virtual void sendOK(void)= 0;
115
virtual void sendEOF(void)= 0;
116
virtual void sendError(uint32_t sql_errno, const char *err)= 0;
119
* Send field list for result set.
73
121
virtual bool sendFields(List<Item> *list)= 0;
123
/* Send result fields in various forms. */
75
124
virtual bool store(Field *from)= 0;
76
125
virtual bool store(void)= 0;
77
126
virtual bool store(int32_t from)= 0;
87
136
return store(from, strlen(from));
89
138
virtual bool store(const char *from, size_t length)= 0;
140
/* Try to remove these. */
141
virtual bool haveMoreData(void)= 0;
142
virtual bool haveError(void)= 0;
143
virtual bool wasAborted(void)= 0;
92
146
} /* end namespace drizzled::plugin */
93
147
} /* end namespace drizzled */
95
#endif /* DRIZZLED_PLUGIN_PROTOCOL_H */
149
#endif /* DRIZZLED_PLUGIN_CLIENT_H */