17
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#include <drizzled/gettext.h>
23
Low level functions for storing data to be send to the MySQL client.
24
The actual communction is handled by the net_xxx functions in net_serv.cc
27
#include <drizzled/server_includes.h>
22
28
#include <drizzled/error.h>
23
#include <drizzled/query_id.h>
24
29
#include <drizzled/sql_state.h>
30
#include <drizzled/protocol.h>
25
31
#include <drizzled/session.h>
26
#include "drizzled/internal/my_sys.h"
27
#include "drizzled/internal/m_string.h"
32
#include <drizzled/data_home.h>
31
34
#include "errmsg.h"
32
#include "drizzle_protocol.h"
35
#define PROTOCOL_VERSION 10
39
extern uint32_t global_thread_id;
42
using namespace drizzled;
45
namespace drizzle_protocol
49
static const uint32_t DRIZZLE_TCP_PORT= 4427;
35
#include "oldlibdrizzle.h"
38
Function called by drizzleclient_net_init() to set some check variables
50
41
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
52
static uint32_t connect_timeout;
53
static uint32_t read_timeout;
54
static uint32_t write_timeout;
55
static uint32_t retry_count;
56
static uint32_t buffer_length;
57
static char* bind_address;
59
const char* ListenDrizzleProtocol::getHost(void) const
64
in_port_t ListenDrizzleProtocol::getPort(void) const
70
port= DRIZZLE_TCP_PORT;
72
if ((env = getenv("DRIZZLE_TCP_PORT")))
73
port= (uint32_t) atoi(env);
78
return (in_port_t) port;
81
plugin::Client *ListenDrizzleProtocol::getClient(int fd)
84
new_fd= acceptTcp(fd);
88
return new (nothrow) ClientDrizzleProtocol(new_fd, using_mysql41_protocol);
91
ClientDrizzleProtocol::ClientDrizzleProtocol(int fd, bool using_mysql41_protocol_arg):
92
using_mysql41_protocol(using_mysql41_protocol_arg)
99
if (drizzleclient_net_init_sock(&net, fd, 0, buffer_length))
102
drizzleclient_net_set_read_timeout(&net, read_timeout);
103
drizzleclient_net_set_write_timeout(&net, write_timeout);
104
net.retry_count=retry_count;
107
ClientDrizzleProtocol::~ClientDrizzleProtocol()
110
drizzleclient_vio_close(net.vio);
113
int ClientDrizzleProtocol::getFileDescriptor(void)
115
return drizzleclient_net_get_sd(&net);
118
bool ClientDrizzleProtocol::isConnected()
43
static void write_eof_packet(Session *session, NET *net,
44
uint32_t server_status, uint32_t total_warn_count);
46
bool ProtocolOldLibdrizzle::isConnected()
120
48
return net.vio != 0;
123
bool ClientDrizzleProtocol::isReading(void)
51
void ProtocolOldLibdrizzle::setReadTimeout(uint32_t timeout)
53
drizzleclient_net_set_read_timeout(&net, timeout);
56
void ProtocolOldLibdrizzle::setWriteTimeout(uint32_t timeout)
58
drizzleclient_net_set_write_timeout(&net, timeout);
61
void ProtocolOldLibdrizzle::setRetryCount(uint32_t count)
63
net.retry_count=count;
66
void ProtocolOldLibdrizzle::setError(char error)
71
bool ProtocolOldLibdrizzle::haveError(void)
73
return net.error || net.vio == 0;
76
bool ProtocolOldLibdrizzle::wasAborted(void)
78
return net.error && net.vio != 0;
81
bool ProtocolOldLibdrizzle::haveMoreData(void)
83
return drizzleclient_net_more_data(&net);
86
void ProtocolOldLibdrizzle::enableCompression(void)
91
bool ProtocolOldLibdrizzle::isReading(void)
125
93
return net.reading_or_writing == 1;
128
bool ClientDrizzleProtocol::isWriting(void)
96
bool ProtocolOldLibdrizzle::isWriting(void)
130
98
return net.reading_or_writing == 2;
133
bool ClientDrizzleProtocol::flush()
137
bool ret= drizzleclient_net_write(&net, (unsigned char*) packet.ptr(),
143
void ClientDrizzleProtocol::close(void)
147
drizzleclient_net_close(&net);
148
drizzleclient_net_end(&net);
152
bool ClientDrizzleProtocol::authenticate()
154
bool connection_is_valid;
156
/* Use "connect_timeout" value during connection phase */
157
drizzleclient_net_set_read_timeout(&net, connect_timeout);
158
drizzleclient_net_set_write_timeout(&net, connect_timeout);
160
connection_is_valid= checkConnection();
162
if (connection_is_valid)
166
sendError(session->main_da.sql_errno(), session->main_da.message());
170
/* Connect completed, set read/write timeouts back to default */
171
drizzleclient_net_set_read_timeout(&net, read_timeout);
172
drizzleclient_net_set_write_timeout(&net, write_timeout);
176
bool ClientDrizzleProtocol::readCommand(char **l_packet, uint32_t *packet_length)
179
This thread will do a blocking read from the client which
180
will be interrupted when the next command is received from
181
the client, the connection is closed or "net_wait_timeout"
182
number of seconds has passed
185
/* We can do this much more efficiently with poll timeouts or watcher thread,
186
disabling for now, which means net_wait_timeout == read_timeout. */
187
drizzleclient_net_set_read_timeout(&net,
188
session->variables.net_wait_timeout);
193
*packet_length= drizzleclient_net_read(&net);
194
if (*packet_length == packet_error)
196
/* Check if we can continue without closing the connection */
198
if(net.last_errno== CR_NET_PACKET_TOO_LARGE)
199
my_error(ER_NET_PACKET_TOO_LARGE, MYF(0));
200
if (session->main_da.status() == Diagnostics_area::DA_ERROR)
201
sendError(session->main_da.sql_errno(), session->main_da.message());
206
return false; // We have to close it.
213
*l_packet= (char*) net.read_pos;
216
'packet_length' contains length of data, as it was stored in packet
217
header. In case of malformed header, drizzleclient_net_read returns zero.
218
If packet_length is not zero, drizzleclient_net_read ensures that the returned
219
number of bytes was actually read from network.
220
There is also an extra safety measure in drizzleclient_net_read:
221
it sets packet[packet_length]= 0, but only for non-zero packets.
224
if (*packet_length == 0) /* safety */
226
/* Initialize with COM_SLEEP packet */
227
(*l_packet)[0]= (unsigned char) COM_SLEEP;
230
else if (using_mysql41_protocol)
232
/* Map from MySQL commands to Drizzle commands. */
233
switch ((int)(*l_packet)[0])
237
case 2: /* INIT_DB */
241
case 8: /* SHUTDOWN */
242
(*l_packet)[0]= (unsigned char) COM_SHUTDOWN;
246
(*l_packet)[0]= (unsigned char) COM_SHUTDOWN;
251
/* Just drop connection for MySQL commands we don't support. */
252
(*l_packet)[0]= (unsigned char) COM_QUIT;
258
/* Do not rely on drizzleclient_net_read, extra safety against programming errors. */
259
(*l_packet)[*packet_length]= '\0'; /* safety */
262
/* See comment above. */
263
/* Restore read timeout value */
264
drizzleclient_net_set_read_timeout(&net,
265
session->variables.net_read_timeout);
101
bool ProtocolOldLibdrizzle::netStoreData(const unsigned char *from, size_t length)
103
size_t packet_length= packet->length();
105
The +9 comes from that strings of length longer than 16M require
106
9 bytes to be stored (see drizzleclient_net_store_length).
108
if (packet_length+9+length > packet->alloced_length() &&
109
packet->realloc(packet_length+9+length))
111
unsigned char *to= drizzleclient_net_store_length((unsigned char*) packet->ptr()+packet_length, length);
112
memcpy(to,from,length);
113
packet->length((size_t) (to+length-(unsigned char*) packet->ptr()));
119
netStoreData() - extended version with character set conversion.
121
It is optimized for short strings whose length after
122
conversion is garanteed to be less than 251, which accupies
123
exactly one byte to store length. It allows not to use
124
the "convert" member as a temporary buffer, conversion
125
is done directly to the "packet" member.
126
The limit 251 is good enough to optimize send_fields()
127
because column, table, database names fit into this limit.
130
bool ProtocolOldLibdrizzle::netStoreData(const unsigned char *from, size_t length,
131
const CHARSET_INFO * const from_cs,
132
const CHARSET_INFO * const to_cs)
134
uint32_t dummy_errors;
135
/* Calculate maxumum possible result length */
136
uint32_t conv_length= to_cs->mbmaxlen * length / from_cs->mbminlen;
137
if (conv_length > 250)
140
For strings with conv_length greater than 250 bytes
141
we don't know how many bytes we will need to store length: one or two,
142
because we don't know result length until conversion is done.
143
For example, when converting from utf8 (mbmaxlen=3) to latin1,
144
conv_length=300 means that the result length can vary between 100 to 300.
145
length=100 needs one byte, length=300 needs to bytes.
147
Thus conversion directly to "packet" is not worthy.
148
Let's use "convert" as a temporary buffer.
150
return (convert->copy((const char*) from, length, from_cs,
151
to_cs, &dummy_errors) ||
152
netStoreData((const unsigned char*) convert->ptr(), convert->length()));
155
size_t packet_length= packet->length();
156
size_t new_length= packet_length + conv_length + 1;
158
if (new_length > packet->alloced_length() && packet->realloc(new_length))
161
char *length_pos= (char*) packet->ptr() + packet_length;
162
char *to= length_pos + 1;
164
to+= copy_and_convert(to, conv_length, to_cs,
165
(const char*) from, length, from_cs, &dummy_errors);
167
drizzleclient_net_store_length((unsigned char*) length_pos, to - length_pos - 1);
168
packet->length((uint32_t) (to - packet->ptr()));
272
174
Return ok to the client.
441
382
1 Error (Note that in this case the error is not sent to the
444
bool ClientDrizzleProtocol::sendFields(List<Item> *list)
385
bool ProtocolOldLibdrizzle::sendFields(List<Item> *list, uint32_t flags)
446
387
List_iterator_fast<Item> it(*list);
448
389
unsigned char buff[80];
449
390
String tmp((char*) buff,sizeof(buff),&my_charset_bin);
451
unsigned char *row_pos= drizzleclient_net_store_length(buff, list->elements);
452
(void) drizzleclient_net_write(&net, buff, (size_t) (row_pos-buff));
392
if (flags & SEND_NUM_ROWS)
393
{ // Packet with number of elements
394
unsigned char *pos= drizzleclient_net_store_length(buff, list->elements);
395
(void) drizzleclient_net_write(&net, buff, (size_t) (pos-buff));
454
398
while ((item=it++))
401
const CHARSET_INFO * const cs= system_charset_info;
458
403
item->make_field(&field);
462
if (store(STRING_WITH_LEN("def")) ||
463
store(field.db_name) ||
464
store(field.table_name) ||
465
store(field.org_table_name) ||
466
store(field.col_name) ||
467
store(field.org_col_name) ||
468
packet.realloc(packet.length()+12))
407
if (store(STRING_WITH_LEN("def"), cs) ||
408
store(field.db_name, cs) ||
409
store(field.table_name, cs) ||
410
store(field.org_table_name, cs) ||
411
store(field.col_name, cs) ||
412
store(field.org_col_name, cs) ||
413
packet->realloc(packet->length()+12))
471
416
/* Store fixed length fields */
472
pos= (char*) packet.ptr()+packet.length();
417
pos= (char*) packet->ptr()+packet->length();
473
418
*pos++= 12; // Length of packed fields
475
int2store(pos, field.charsetnr);
476
int4store(pos+2, field.length);
478
if (using_mysql41_protocol)
419
if (item->collation.collation == &my_charset_bin)
480
/* Switch to MySQL field numbering. */
483
case DRIZZLE_TYPE_LONG:
487
case DRIZZLE_TYPE_DOUBLE:
491
case DRIZZLE_TYPE_NULL:
495
case DRIZZLE_TYPE_TIMESTAMP:
499
case DRIZZLE_TYPE_LONGLONG:
503
case DRIZZLE_TYPE_DATETIME:
507
case DRIZZLE_TYPE_DATE:
511
case DRIZZLE_TYPE_VARCHAR:
515
case DRIZZLE_TYPE_DECIMAL:
519
case DRIZZLE_TYPE_ENUM:
523
case DRIZZLE_TYPE_BLOB:
422
int2store(pos, field.charsetnr);
423
int4store(pos+2, field.length);
530
/* Add one to compensate for tinyint removal from enum. */
531
pos[6]= field.type + 1;
427
/* With conversion */
428
uint32_t max_char_len;
429
int2store(pos, cs->number);
431
For TEXT/BLOB columns, field_length describes the maximum data
432
length in bytes. There is no limit to the number of characters
433
that a TEXT column can store, as long as the data fits into
434
the designated space.
435
For the rest of textual columns, field_length is evaluated as
436
char_count * mbmaxlen, where character count is taken from the
437
definition of the column. In other words, the maximum number
438
of characters here is limited by the column definition.
440
max_char_len= field.length / item->collation.collation->mbmaxlen;
441
int4store(pos+2, max_char_len * cs->mbmaxlen);
534
444
int2store(pos+7,field.flags);
535
445
pos[9]= (char) field.decimals;
536
446
pos[10]= 0; // For the future
537
447
pos[11]= 0; // For the future
540
packet.length((uint32_t) (pos - packet.ptr()));
546
Mark the end of meta-data result set, and store session->server_status,
547
to show that there is no cursor.
548
Send no warning information, as it will be sent at statement end.
550
writeEOFPacket(session->server_status, session->total_warn_count);
450
packet->length((uint32_t) (pos - packet->ptr()));
451
if (flags & SEND_DEFAULTS)
452
item->send(this, &tmp); // Send default value
454
break; /* purecov: inspected */
457
if (flags & SEND_EOF)
460
Mark the end of meta-data result set, and store session->server_status,
461
to show that there is no cursor.
462
Send no warning information, as it will be sent at statement end.
464
write_eof_packet(session, &net, session->server_status, session->total_warn_count);
467
field_count= list->elements;
554
471
my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES),
559
bool ClientDrizzleProtocol::store(Field *from)
563
char buff[MAX_FIELD_WIDTH];
564
String str(buff,sizeof(buff), &my_charset_bin);
568
return netStoreData((const unsigned char *)str.ptr(), str.length());
571
bool ClientDrizzleProtocol::store(void)
472
MYF(0)); /* purecov: inspected */
473
return 1; /* purecov: inspected */
477
bool ProtocolOldLibdrizzle::write()
479
return(drizzleclient_net_write(&net, (unsigned char*) packet->ptr(),
483
void ProtocolOldLibdrizzle::free()
489
void ProtocolOldLibdrizzle::setRandom(uint64_t seed1, uint64_t seed2)
491
drizzleclient_randominit(&rand, seed1, seed2);
494
bool ProtocolOldLibdrizzle::setFileDescriptor(int fd)
496
if (drizzleclient_net_init_sock(&net, fd, 0))
501
int ProtocolOldLibdrizzle::fileDescriptor(void)
503
return drizzleclient_net_get_sd(&net);
506
bool ProtocolOldLibdrizzle::authenticate()
508
bool connection_is_valid;
510
/* Use "connect_timeout" value during connection phase */
511
drizzleclient_net_set_read_timeout(&net, connect_timeout);
512
drizzleclient_net_set_write_timeout(&net, connect_timeout);
514
connection_is_valid= checkConnection();
516
if (connection_is_valid)
520
sendError(session->main_da.sql_errno(), session->main_da.message());
524
/* Connect completed, set read/write timeouts back to default */
525
drizzleclient_net_set_read_timeout(&net,
526
session->variables.net_read_timeout);
527
drizzleclient_net_set_write_timeout(&net,
528
session->variables.net_write_timeout);
532
bool ProtocolOldLibdrizzle::readCommand(char **l_packet, uint32_t *packet_length)
535
This thread will do a blocking read from the client which
536
will be interrupted when the next command is received from
537
the client, the connection is closed or "net_wait_timeout"
538
number of seconds has passed
541
/* We can do this much more efficiently with poll timeouts or watcher thread,
542
disabling for now, which means net_wait_timeout == read_timeout. */
543
drizzleclient_net_set_read_timeout(&net,
544
session->variables.net_wait_timeout);
547
session->clear_error();
548
session->main_da.reset_diagnostics_area();
552
*packet_length= drizzleclient_net_read(&net);
553
if (*packet_length == packet_error)
555
/* Check if we can continue without closing the connection */
557
if(net.last_errno== CR_NET_PACKET_TOO_LARGE)
558
my_error(ER_NET_PACKET_TOO_LARGE, MYF(0));
559
if (session->main_da.status() == Diagnostics_area::DA_ERROR)
560
sendError(session->main_da.sql_errno(), session->main_da.message());
562
session->protocol->sendOK();
565
return false; // We have to close it.
572
*l_packet= (char*) net.read_pos;
575
'packet_length' contains length of data, as it was stored in packet
576
header. In case of malformed header, drizzleclient_net_read returns zero.
577
If packet_length is not zero, drizzleclient_net_read ensures that the returned
578
number of bytes was actually read from network.
579
There is also an extra safety measure in drizzleclient_net_read:
580
it sets packet[packet_length]= 0, but only for non-zero packets.
583
if (*packet_length == 0) /* safety */
585
/* Initialize with COM_SLEEP packet */
586
(*l_packet)[0]= (unsigned char) COM_SLEEP;
589
/* Do not rely on drizzleclient_net_read, extra safety against programming errors. */
590
(*l_packet)[*packet_length]= '\0'; /* safety */
593
/* See comment above. */
594
/* Restore read timeout value */
595
drizzleclient_net_set_read_timeout(&net,
596
session->variables.net_read_timeout);
602
void ProtocolOldLibdrizzle::close(void)
606
drizzleclient_net_close(&net);
607
drizzleclient_net_end(&net);
611
void ProtocolOldLibdrizzle::forceClose(void)
614
drizzleclient_vio_close(net.vio);
617
void ProtocolOldLibdrizzle::prepareForResend()
622
bool ProtocolOldLibdrizzle::store(void)
574
625
buff[0]= (char)251;
575
return packet.append(buff, sizeof(buff), PACKET_BUFFER_EXTRA_ALLOC);
578
bool ClientDrizzleProtocol::store(int32_t from)
626
return packet->append(buff, sizeof(buff), PACKET_BUFFER_EXTRA_ALLOC);
631
Auxilary function to convert string to the given character set
632
and store in network buffer.
635
bool ProtocolOldLibdrizzle::storeString(const char *from, size_t length,
636
const CHARSET_INFO * const fromcs,
637
const CHARSET_INFO * const tocs)
639
/* 'tocs' is set 0 when client issues SET character_set_results=NULL */
640
if (tocs && !my_charset_same(fromcs, tocs) &&
641
fromcs != &my_charset_bin &&
642
tocs != &my_charset_bin)
644
/* Store with conversion */
645
return netStoreData((unsigned char*) from, length, fromcs, tocs);
647
/* Store without conversion */
648
return netStoreData((unsigned char*) from, length);
652
bool ProtocolOldLibdrizzle::store(const char *from, size_t length,
653
const CHARSET_INFO * const fromcs)
655
const CHARSET_INFO * const tocs= default_charset_info;
656
return storeString(from, length, fromcs, tocs);
660
bool ProtocolOldLibdrizzle::store(int32_t from)
581
663
return netStoreData((unsigned char*) buff,
582
(size_t) (internal::int10_to_str(from, buff, -10) - buff));
664
(size_t) (int10_to_str(from, buff, -10) - buff));
585
bool ClientDrizzleProtocol::store(uint32_t from)
667
bool ProtocolOldLibdrizzle::store(uint32_t from)
588
670
return netStoreData((unsigned char*) buff,
589
(size_t) (internal::int10_to_str(from, buff, 10) - buff));
671
(size_t) (int10_to_str(from, buff, 10) - buff));
592
bool ClientDrizzleProtocol::store(int64_t from)
674
bool ProtocolOldLibdrizzle::store(int64_t from)
595
677
return netStoreData((unsigned char*) buff,
596
(size_t) (internal::int64_t10_to_str(from, buff, -10) - buff));
678
(size_t) (int64_t10_to_str(from, buff, -10) - buff));
599
bool ClientDrizzleProtocol::store(uint64_t from)
681
bool ProtocolOldLibdrizzle::store(uint64_t from)
602
684
return netStoreData((unsigned char*) buff,
603
(size_t) (internal::int64_t10_to_str(from, buff, 10) - buff));
685
(size_t) (int64_t10_to_str(from, buff, 10) - buff));
606
bool ClientDrizzleProtocol::store(double from, uint32_t decimals, String *buffer)
689
bool ProtocolOldLibdrizzle::store(double from, uint32_t decimals, String *buffer)
608
691
buffer->set_real(from, decimals, session->charset());
609
692
return netStoreData((unsigned char*) buffer->ptr(), buffer->length());
612
bool ClientDrizzleProtocol::store(const char *from, size_t length)
614
return netStoreData((const unsigned char *)from, length);
617
bool ClientDrizzleProtocol::wasAborted(void)
619
return net.error && net.vio != 0;
622
bool ClientDrizzleProtocol::haveMoreData(void)
624
return drizzleclient_net_more_data(&net);
627
bool ClientDrizzleProtocol::haveError(void)
629
return net.error || net.vio == 0;
632
bool ClientDrizzleProtocol::checkConnection(void)
696
bool ProtocolOldLibdrizzle::store(Field *from)
700
char buff[MAX_FIELD_WIDTH];
701
String str(buff,sizeof(buff), &my_charset_bin);
702
const CHARSET_INFO * const tocs= default_charset_info;
706
return storeString(str.ptr(), str.length(), str.charset(), tocs);
712
Second_part format ("%06") needs to change when
713
we support 0-6 decimals for time.
716
bool ProtocolOldLibdrizzle::store(const DRIZZLE_TIME *tm)
722
switch (tm->time_type)
724
case DRIZZLE_TIMESTAMP_DATETIME:
725
length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d",
733
length+= sprintf(buff+length, ".%06d", (int)tm->second_part);
736
case DRIZZLE_TIMESTAMP_DATE:
737
length= sprintf(buff, "%04d-%02d-%02d",
743
case DRIZZLE_TIMESTAMP_TIME:
744
day= (tm->year || tm->month) ? 0 : tm->day;
745
length= sprintf(buff, "%s%02ld:%02d:%02d", tm->neg ? "-" : "",
746
(long) day*24L+(long) tm->hour, (int) tm->minute,
749
length+= sprintf(buff+length, ".%06d", (int)tm->second_part);
752
case DRIZZLE_TIMESTAMP_NONE:
753
case DRIZZLE_TIMESTAMP_ERROR:
759
return netStoreData((unsigned char*) buff, length);
762
bool ProtocolOldLibdrizzle::checkConnection(void)
634
764
uint32_t pkt_len= 0;
767
session->getSecurityContext().setUser(user);
923
session->security_ctx.user.assign(user);
769
925
return session->checkUser(passwd, passwd_len, l_db);
772
bool ClientDrizzleProtocol::netStoreData(const unsigned char *from, size_t length)
774
size_t packet_length= packet.length();
776
The +9 comes from that strings of length longer than 16M require
777
9 bytes to be stored (see drizzleclient_net_store_length).
779
if (packet_length+9+length > packet.alloced_length() &&
780
packet.realloc(packet_length+9+length))
782
unsigned char *to= drizzleclient_net_store_length((unsigned char*) packet.ptr()+packet_length, length);
783
memcpy(to,from,length);
784
packet.length((size_t) (to+length-(unsigned char*) packet.ptr()));
789
Format EOF packet according to the current client and
790
write it to the network output buffer.
793
void ClientDrizzleProtocol::writeEOFPacket(uint32_t server_status,
794
uint32_t total_warn_count)
796
unsigned char buff[5];
798
Don't send warn count during SP execution, as the warn_list
799
is cleared between substatements, and mysqltest gets confused
801
uint32_t tmp= min(total_warn_count, (uint32_t)65535);
802
buff[0]= DRIZZLE_PROTOCOL_NO_MORE_DATA;
803
int2store(buff+1, tmp);
805
The following test should never be true, but it's better to do it
806
because if 'is_fatal_error' is set the server is not going to execute
807
other queries (see the if test in dispatch_command / COM_QUERY)
809
if (session->is_fatal_error)
810
server_status&= ~SERVER_MORE_RESULTS_EXISTS;
811
int2store(buff + 3, server_status);
812
drizzleclient_net_write(&net, buff, 5);
815
static ListenDrizzleProtocol *listen_obj= NULL;
817
static int init(plugin::Context &context)
819
listen_obj= new ListenDrizzleProtocol("drizzle_protocol", false);
820
context.add(listen_obj);
824
static DRIZZLE_SYSVAR_UINT(port, port, PLUGIN_VAR_RQCMDARG,
825
N_("Port number to use for connection or 0 for "
826
"default to, in order of "
827
"preference, drizzle.cnf, $DRIZZLE_TCP_PORT, "
828
"built-in default (4427)."),
829
NULL, NULL, 0, 0, 65535, 0);
830
static DRIZZLE_SYSVAR_UINT(connect_timeout, connect_timeout,
831
PLUGIN_VAR_RQCMDARG, N_("Connect Timeout."),
832
NULL, NULL, 10, 1, 300, 0);
833
static DRIZZLE_SYSVAR_UINT(read_timeout, read_timeout, PLUGIN_VAR_RQCMDARG,
834
N_("Read Timeout."), NULL, NULL, 30, 1, 300, 0);
835
static DRIZZLE_SYSVAR_UINT(write_timeout, write_timeout, PLUGIN_VAR_RQCMDARG,
836
N_("Write Timeout."), NULL, NULL, 60, 1, 300, 0);
837
static DRIZZLE_SYSVAR_UINT(retry_count, retry_count, PLUGIN_VAR_RQCMDARG,
838
N_("Retry Count."), NULL, NULL, 10, 1, 100, 0);
839
static DRIZZLE_SYSVAR_UINT(buffer_length, buffer_length, PLUGIN_VAR_RQCMDARG,
840
N_("Buffer length."), NULL, NULL, 16384, 1024,
842
static DRIZZLE_SYSVAR_STR(bind_address, bind_address, PLUGIN_VAR_READONLY,
843
N_("Address to bind to."), NULL, NULL, NULL);
845
static drizzle_sys_var* sys_variables[]= {
846
DRIZZLE_SYSVAR(port),
847
DRIZZLE_SYSVAR(connect_timeout),
848
DRIZZLE_SYSVAR(read_timeout),
849
DRIZZLE_SYSVAR(write_timeout),
850
DRIZZLE_SYSVAR(retry_count),
851
DRIZZLE_SYSVAR(buffer_length),
852
DRIZZLE_SYSVAR(bind_address),
856
} /* namespace drizzle_protocol */
858
DRIZZLE_PLUGIN(drizzle_protocol::init, drizzle_protocol::sys_variables);
928
static ProtocolFactoryOldLibdrizzle *factory= NULL;
930
static int init(PluginRegistry ®istry)
932
factory= new ProtocolFactoryOldLibdrizzle;
933
registry.add(factory);
937
static int deinit(PluginRegistry ®istry)
941
registry.remove(factory);
947
drizzle_declare_plugin(oldlibdrizzle)
952
"Old libdrizzle Protocol",
954
init, /* Plugin Init */
955
deinit, /* Plugin Deinit */
956
NULL, /* status variables */
957
NULL, /* system variables */
958
NULL /* config options */
960
drizzle_declare_plugin_end;