~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/client.c

  • Committer: Monty Taylor
  • Date: 2008-09-15 00:46:33 UTC
  • mfrom: (383.1.55 client-split)
  • Revision ID: monty@inaugust.com-20080915004633-fmjw27fi41cxs35w
Merged from client-split.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    drizzle_connect()
31
31
  - Support for reading local file with LOAD DATA LOCAL
32
32
  - SHARED memory handling
33
 
  - Protection against sigpipe
34
33
  - Prepared statements
35
34
 
36
35
  - Things that only works for the server
44
43
 
45
44
#include <drizzled/global.h>
46
45
 
47
 
#include "drizzle.h"
 
46
#include "libdrizzle.h"
48
47
 
49
48
#include <sys/poll.h>
50
49
#include <sys/ioctl.h>
85
84
 
86
85
#define CONNECT_TIMEOUT 0
87
86
 
88
 
#include "client_settings.h"
89
87
#include <drizzled/version.h>
90
88
#include <libdrizzle/sql_common.h>
91
89
#include <libdrizzle/gettext.h>
 
90
#include "local_infile.h"
 
91
 
 
92
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG |  \
 
93
                             CLIENT_TRANSACTIONS |                      \
 
94
                             CLIENT_SECURE_CONNECTION)
92
95
 
93
96
uint    drizzle_port=0;
94
 
char    *drizzle_unix_port= 0;
95
97
const char  *unknown_sqlstate= "HY000";
96
98
const char  *not_error_sqlstate= "00000";
97
99
const char  *cant_connect_sqlstate= "08001";
290
292
{
291
293
  NET *net= &drizzle->net;
292
294
  uint32_t len=0;
293
 
  init_sigpipe_variables
294
295
 
295
 
  /* Don't give sigpipe errors if the client doesn't want them */
296
 
  set_sigpipe(drizzle);
297
296
  if (net->vio != 0)
298
297
    len=my_net_read(net);
299
 
  reset_sigpipe(drizzle);
300
298
 
301
299
  if (len == packet_error || len == 0)
302
300
  {
380
378
{
381
379
  NET *net= &drizzle->net;
382
380
  bool result= 1;
383
 
  init_sigpipe_variables
384
381
  bool stmt_skip= false;
385
382
 
386
 
  /* Don't give sigpipe errors if the client doesn't want them */
387
 
  set_sigpipe(drizzle);
388
 
 
389
383
  if (drizzle->net.vio == 0)
390
384
  {            /* Do reconnect if possible */
391
385
    if (drizzle_reconnect(drizzle) || stmt_skip)
431
425
    result= ((drizzle->packet_length=cli_safe_read(drizzle)) == packet_error ?
432
426
       1 : 0);
433
427
end:
434
 
  reset_sigpipe(drizzle);
435
428
  return(result);
436
429
}
437
430
 
492
485
  int save_errno= errno;
493
486
  if (drizzle->net.vio != 0)
494
487
  {
495
 
    init_sigpipe_variables
496
 
    set_sigpipe(drizzle);
497
488
    vio_delete(drizzle->net.vio);
498
 
    reset_sigpipe(drizzle);
499
489
    drizzle->net.vio= 0;          /* Marker */
500
490
  }
501
491
  net_end(&drizzle->net);
606
596
    field->flags=  uint2korr(pos+7);
607
597
    field->decimals=  (uint) pos[9];
608
598
 
609
 
    if (INTERNAL_NUM_FIELD(field))
 
599
    /* Test if field is Internal Number Format */
 
600
    if (((field->type <= DRIZZLE_TYPE_LONGLONG) &&
 
601
         (field->type != DRIZZLE_TYPE_TIMESTAMP)) ||
 
602
        (field->length == 14) ||
 
603
        (field->length == 8))
610
604
      field->flags|= NUM_FLAG;
611
605
    if (default_value && row->data[7])
612
606
    {
899
893
  cli_read_rows,                               /* read_rows */
900
894
  cli_use_result,                              /* use_result */
901
895
  cli_fetch_lengths,                           /* fetch_lengths */
902
 
  cli_flush_use_result,                         /* flush_use_result */
903
 
#ifndef DRIZZLE_SERVER
904
 
  cli_list_fields,                            /* list_fields */
 
896
  cli_flush_use_result,                        /* flush_use_result */
 
897
  cli_list_fields,                             /* list_fields */
905
898
  cli_unbuffered_fetch,                        /* unbuffered_fetch */
906
899
  cli_read_statistics,                         /* read_statistics */
907
900
  cli_read_query_result,                       /* next_result */
908
901
  cli_read_change_user_result,                 /* read_change_user_result */
909
 
#else
910
 
  0,0,0,0,0
911
 
#endif
912
902
};
913
903
 
914
904
 
923
913
  char          *end,*host_info=NULL;
924
914
  uint32_t         pkt_length;
925
915
  NET           *net= &drizzle->net;
926
 
  init_sigpipe_variables
927
916
 
928
 
  /* Don't give sigpipe errors if the client doesn't want them */
929
 
  set_sigpipe(drizzle);
930
917
  drizzle->methods= &client_methods;
931
918
  net->vio = 0;        /* If something goes wrong */
932
919
  drizzle->client_flag=0;      /* For handshake */
956
943
  /*
957
944
    Part 0: Grab a socket and connect it to the server
958
945
  */
959
 
  if (!net->vio &&
960
 
      (!drizzle->options.protocol ||
961
 
       drizzle->options.protocol == DRIZZLE_PROTOCOL_TCP))
 
946
  if (!net->vio)
962
947
  {
963
948
    struct addrinfo *res_lst, hints, *t_res;
964
949
    int gai_errno;
1211
1196
  }
1212
1197
 
1213
1198
 
1214
 
  reset_sigpipe(drizzle);
1215
1199
  return(drizzle);
1216
1200
 
1217
1201
error:
1218
 
  reset_sigpipe(drizzle);
1219
1202
  {
1220
1203
    /* Free alloced memory */
1221
1204
    end_server(drizzle);
1364
1347
  if ((length = cli_safe_read(drizzle)) == packet_error)
1365
1348
    return(1);
1366
1349
  free_old_query(drizzle);    /* Free old result */
1367
 
#ifdef DRIZZLE_CLIENT      /* Avoid warn of unused labels*/
1368
1350
get_info:
1369
 
#endif
1370
1351
  pos=(uchar*) drizzle->net.read_pos;
1371
1352
  if ((field_count= net_field_length(&pos)) == 0)
1372
1353
  {
1380
1361
      drizzle->info=(char*) pos;
1381
1362
    return(0);
1382
1363
  }
1383
 
#ifdef DRIZZLE_CLIENT
1384
1364
  if (field_count == NULL_LENGTH)    /* LOAD DATA LOCAL INFILE */
1385
1365
  {
1386
1366
    int error;
1396
1376
      return(1);
1397
1377
    goto get_info;        /* Get info packet */
1398
1378
  }
1399
 
#endif
1400
1379
  if (!(drizzle->server_status & SERVER_STATUS_AUTOCOMMIT))
1401
1380
    drizzle->server_status|= SERVER_STATUS_IN_TRANS;
1402
1381
 
1627
1606
    drizzle->options.my_cnf_group=strdup(arg);
1628
1607
    break;
1629
1608
  case DRIZZLE_OPT_PROTOCOL:
1630
 
    drizzle->options.protocol= *(const uint*) arg;
1631
1609
    break;
1632
1610
  case DRIZZLE_OPT_USE_REMOTE_CONNECTION:
1633
1611
  case DRIZZLE_OPT_GUESS_CONNECTION: