1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include "libdrizzle_priv.h"
23
#include <libdrizzle/libdrizzle.h>
24
#include <libdrizzle/pack.h>
25
#include <libdrizzle/errmsg.h>
1
/* Copyright (C) 2000-2004 DRIZZLE AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation.
7
There are special exceptions to the terms and conditions of the GPL as it
8
is applied to this software. View the full text of the exception in file
9
EXCEPTIONS-CLIENT in the directory of this software distribution.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
20
#include <drizzled/global.h>
21
#include "libdrizzle.h"
26
23
#include <sys/stat.h>
27
24
#include <signal.h>
75
72
uint32_t net_buffer_length= 8192;
76
73
uint32_t max_allowed_packet= 1024L*1024L*1024L;
78
unsigned int drizzle_port=0;
76
#define SOCKET_ERROR -1
79
If allowed through some configuration, then this needs to
82
#define MAX_LONG_DATA_LENGTH 8192
83
#define unsigned_field(A) ((A)->flags & UNSIGNED_FLAG)
83
86
static DRIZZLE_PARAMETERS drizzle_internal_parameters=
173
166
/* Add character set number. */
174
167
if (drizzle->server_capabilities & CLIENT_SECURE_CONNECTION)
176
int2store(end, (uint16_t) 45); // utf8mb4 number from mystrings/ctype-utf8.c
169
int2store(end, (ushort) 45); // utf8mb4 number from mystrings/ctype-utf8.c
180
173
/* Write authentication package */
181
(void)simple_command(drizzle,COM_CHANGE_USER, (unsigned char*) buff, (uint32_t) (end-buff), 1);
174
(void)simple_command(drizzle,COM_CHANGE_USER, (uchar*) buff, (uint32_t) (end-buff), 1);
183
176
rc= (*drizzle->methods->read_change_user_result)(drizzle);
215
208
drizzle_query(DRIZZLE *drizzle, const char *query)
217
return drizzle_real_query(drizzle,query, (uint32_t) strlen(query));
210
return drizzle_real_query(drizzle,query, (uint) strlen(query));
296
289
if (!(query= cli_read_rows(drizzle,(DRIZZLE_FIELD*) 0, 8)))
299
drizzle->field_count= (uint32_t) query->rows;
292
drizzle->field_count= (uint) query->rows;
300
293
return unpack_fields(query, drizzle->field_count, 1);
319
312
end= strncpy(end+1, wild ? wild : "", 128) + 128;
321
314
free_old_query(drizzle);
322
if (simple_command(drizzle, COM_FIELD_LIST, (unsigned char*) buff,
315
if (simple_command(drizzle, COM_FIELD_LIST, (uchar*) buff,
323
316
(uint32_t) (end-buff), 1) ||
324
317
!(fields= (*drizzle->methods->list_fields)(drizzle)))
343
336
drizzle_list_processes(DRIZZLE *drizzle)
345
338
DRIZZLE_DATA *fields;
346
uint32_t field_count;
349
342
if (simple_command(drizzle,COM_PROCESS_INFO,0,0,0))
351
344
free_old_query(drizzle);
352
pos=(unsigned char*) drizzle->net.read_pos;
353
field_count=(uint32_t) net_field_length(&pos);
345
pos=(uchar*) drizzle->net.read_pos;
346
field_count=(uint) net_field_length(&pos);
354
347
if (!(fields = (*drizzle->methods->read_rows)(drizzle,(DRIZZLE_FIELD*) 0, 7)))
356
349
if (!(drizzle->fields=unpack_fields(fields, field_count, 0)))
365
drizzle_shutdown(DRIZZLE *drizzle)
358
drizzle_shutdown(DRIZZLE *drizzle, enum drizzle_enum_shutdown_level shutdown_level)
367
return(simple_command(drizzle, COM_SHUTDOWN, 0, 0, 0));
361
level[0]= (uchar) shutdown_level;
362
return(simple_command(drizzle, COM_SHUTDOWN, level, 1, 0));
372
drizzle_refresh(DRIZZLE *drizzle, uint32_t options)
367
drizzle_refresh(DRIZZLE *drizzle,uint options)
374
unsigned char bits[1];
375
bits[0]= (unsigned char) options;
370
bits[0]= (uchar) options;
376
371
return(simple_command(drizzle, COM_REFRESH, bits, 1, 0));
390
385
drizzle_set_server_option(DRIZZLE *drizzle, enum enum_drizzle_set_option option)
392
unsigned char buff[2];
393
int2store(buff, (uint32_t) option);
388
int2store(buff, (uint) option);
394
389
return(simple_command(drizzle, COM_SET_OPTION, buff, sizeof(buff), 0));
400
395
drizzle->net.read_pos[drizzle->packet_length]=0; /* End of stat string */
401
396
if (!drizzle->net.read_pos[0])
403
drizzle_set_error(drizzle, CR_WRONG_HOST_INFO, sqlstate_get_unknown());
398
set_drizzle_error(drizzle, CR_WRONG_HOST_INFO, unknown_sqlstate);
404
399
return drizzle->net.last_error;
406
401
return (char*) drizzle->net.read_pos;
522
517
void my_net_local_init(NET *net)
524
net->max_packet= (uint32_t) net_buffer_length;
519
net->max_packet= (uint) net_buffer_length;
525
520
my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
526
521
my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
527
522
net->retry_count= 1;
528
net->max_packet_size= (net_buffer_length > max_allowed_packet) ?
529
net_buffer_length : max_allowed_packet;
523
net->max_packet_size= max(net_buffer_length, max_allowed_packet);
706
700
if (drizzle->status != DRIZZLE_STATUS_READY)
708
drizzle_set_error(drizzle, CR_COMMANDS_OUT_OF_SYNC, sqlstate_get_unknown());
702
set_drizzle_error(drizzle, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);