~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzleclient/client.c

  • Committer: Brian Aker
  • Date: 2009-02-05 10:38:55 UTC
  • Revision ID: brian@tangent.org-20090205103855-wajzccrbu7zbvmh4
Reworked some classes out of session.h
Also updated ignore file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
/*
21
 
  This file is included by both libdrizzle.c (the DRIZZLE client C API)
 
21
  This file is included by both libdrizzleclient.c (the DRIZZLE client C API)
22
22
  and the drizzled server to connect to another DRIZZLE server.
23
23
 
24
24
  The differences for the two cases are:
29
29
  - Support for reading local file with LOAD DATA LOCAL
30
30
  - SHARED memory handling
31
31
  - Prepared statements
32
 
 
 
32
 
33
33
  - Things that only works for the server
34
34
  - Alarm handling on connect
35
 
 
 
35
 
36
36
  In all other cases, the code should be idential for the client and
37
37
  server.
38
38
*/
39
39
 
 
40
 
 
41
#include "libdrizzle_priv.h"
 
42
#include "net_serv.h"
 
43
#include "pack.h"
 
44
#include "errmsg.h"
 
45
#include "local_infile.h"
 
46
#include "drizzle_methods.h"
 
47
 
40
48
#include <stdarg.h>
41
 
 
42
 
#include <libdrizzle/libdrizzle.h>
43
 
#include <libdrizzle/net_serv.h>
44
 
#include "libdrizzle_priv.h"
45
 
 
46
49
#include <sys/poll.h>
47
50
#include <sys/ioctl.h>
48
51
 
52
55
#undef max_allowed_packet
53
56
#undef net_buffer_length
54
57
 
55
 
#include <libdrizzle/errmsg.h>
56
 
#include <vio/violite.h>
57
58
 
58
59
#include <sys/stat.h>
59
60
#include <signal.h>
76
77
#include <sys/un.h>
77
78
 
78
79
#include <errno.h>
79
 
#define SOCKET_ERROR -1
80
 
 
81
 
 
82
 
#include <drizzled/version.h>
83
 
#include <libdrizzle/sql_common.h>
84
 
#include <libdrizzle/gettext.h>
85
 
#include "local_infile.h"
86
 
 
87
 
 
88
 
 
89
 
 
90
 
 
91
 
 
 
80
 
 
81
 
 
82
#include <drizzled/gettext.h>
92
83
 
93
84
 
94
85
#if defined(HAVE_GETPWUID) && defined(NO_GETPWUID_DECL)
97
88
#endif
98
89
 
99
90
 
100
 
 
101
91
/*****************************************************************************
102
92
  Read a packet from server. Give error message if socket was down
103
93
  or packet is an error message
104
94
*****************************************************************************/
 
95
safe_read_error_hook_func safe_read_error_hook= NULL;
105
96
 
106
97
uint32_t cli_safe_read(DRIZZLE *drizzle)
107
98
{
113
104
 
114
105
  if (len == packet_error || len == 0)
115
106
  {
116
 
#ifdef DRIZZLE_SERVER
117
 
    if (net->vio && vio_was_interrupted(net->vio))
118
 
      return (packet_error);
119
 
#endif /*DRIZZLE_SERVER*/
 
107
    if (safe_read_error_hook != NULL)
 
108
      if (safe_read_error_hook(net))
 
109
        return (packet_error);
120
110
    drizzle_disconnect(drizzle);
121
111
    drizzle_set_error(drizzle, net->last_errno == CR_NET_PACKET_TOO_LARGE ?
122
112
                      CR_NET_PACKET_TOO_LARGE : CR_SERVER_LOST,
133
123
      len-=2;
134
124
      if (pos[0] == '#')
135
125
      {
136
 
        strncpy(net->sqlstate, pos+1, SQLSTATE_LENGTH);
137
 
        pos+= SQLSTATE_LENGTH+1;
 
126
        strncpy(net->sqlstate, pos+1, LIBDRIZZLE_SQLSTATE_LENGTH);
 
127
        pos+= LIBDRIZZLE_SQLSTATE_LENGTH+1;
138
128
      }
139
129
      else
140
130
      {
587
577
 
588
578
  EXAMPLE
589
579
    4.1.0-alfa ->  40100
590
 
 
 
580
 
591
581
  NOTES
592
582
    We will ensure that a newer server always has a bigger number.
593
583