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>
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
20
#include "libdrizzle.h"
21
#include "libdrizzle_priv.h"
22
22
#include "errmsg.h"
23
23
#include <sys/stat.h>
24
24
#include <signal.h>
173
188
/* Write authentication package */
174
(void)simple_command(drizzle,COM_CHANGE_USER, (uchar*) buff, (uint32_t) (end-buff), 1);
189
(void)simple_command(drizzle,COM_CHANGE_USER, (unsigned char*) buff, (uint32_t) (end-buff), 1);
176
191
rc= (*drizzle->methods->read_change_user_result)(drizzle);
312
327
end= strncpy(end+1, wild ? wild : "", 128) + 128;
314
329
free_old_query(drizzle);
315
if (simple_command(drizzle, COM_FIELD_LIST, (uchar*) buff,
330
if (simple_command(drizzle, COM_FIELD_LIST, (unsigned char*) buff,
316
331
(uint32_t) (end-buff), 1) ||
317
332
!(fields= (*drizzle->methods->list_fields)(drizzle)))
338
353
DRIZZLE_DATA *fields;
339
354
uint field_count;
342
357
if (simple_command(drizzle,COM_PROCESS_INFO,0,0,0))
344
359
free_old_query(drizzle);
345
pos=(uchar*) drizzle->net.read_pos;
360
pos=(unsigned char*) drizzle->net.read_pos;
346
361
field_count=(uint) net_field_length(&pos);
347
362
if (!(fields = (*drizzle->methods->read_rows)(drizzle,(DRIZZLE_FIELD*) 0, 7)))
358
373
drizzle_shutdown(DRIZZLE *drizzle, enum drizzle_enum_shutdown_level shutdown_level)
361
level[0]= (uchar) shutdown_level;
375
unsigned char level[1];
376
level[0]= (unsigned char) shutdown_level;
362
377
return(simple_command(drizzle, COM_SHUTDOWN, level, 1, 0));
367
382
drizzle_refresh(DRIZZLE *drizzle,uint options)
370
bits[0]= (uchar) options;
384
unsigned char bits[1];
385
bits[0]= (unsigned char) options;
371
386
return(simple_command(drizzle, COM_REFRESH, bits, 1, 0));
376
391
drizzle_kill(DRIZZLE *drizzle, uint32_t pid)
393
unsigned char buff[4];
379
394
int4store(buff,pid);
380
395
return(simple_command(drizzle,COM_PROCESS_KILL,buff,sizeof(buff),0));
385
400
drizzle_set_server_option(DRIZZLE *drizzle, enum enum_drizzle_set_option option)
402
unsigned char buff[2];
388
403
int2store(buff, (uint) option);
389
404
return(simple_command(drizzle, COM_SET_OPTION, buff, sizeof(buff), 0));
395
410
drizzle->net.read_pos[drizzle->packet_length]=0; /* End of stat string */
396
411
if (!drizzle->net.read_pos[0])
398
set_drizzle_error(drizzle, CR_WRONG_HOST_INFO, unknown_sqlstate);
413
drizzle_set_error(drizzle, CR_WRONG_HOST_INFO, sqlstate_get_unknown());
399
414
return drizzle->net.last_error;
401
416
return (char*) drizzle->net.read_pos;
489
504
const char * drizzle_sqlstate(const DRIZZLE *drizzle)
491
return drizzle ? drizzle->net.sqlstate : cant_connect_sqlstate;
506
return drizzle ? drizzle->net.sqlstate : sqlstate_get_cant_connect();
494
509
uint32_t drizzle_warning_count(const DRIZZLE *drizzle)
520
535
my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
521
536
my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
522
537
net->retry_count= 1;
523
net->max_packet_size= max(net_buffer_length, max_allowed_packet);
538
net->max_packet_size= (net_buffer_length > max_allowed_packet) ?
539
net_buffer_length : max_allowed_packet;
700
716
if (drizzle->status != DRIZZLE_STATUS_READY)
702
set_drizzle_error(drizzle, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
718
drizzle_set_error(drizzle, CR_COMMANDS_OUT_OF_SYNC, sqlstate_get_unknown());