~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/vio.c

  • Committer: Stewart Smith
  • Date: 2008-11-21 16:06:07 UTC
  • mto: This revision was merged to the branch mainline in revision 593.
  • Revision ID: stewart@flamingspork.com-20081121160607-n6gdlt013spuo54r
remove mysql_frm_type
and fix engines to return correct value from delete_table when table doesn't exist.
(it should be ENOENT).

Also fix up some tests that manipulated frm files by hand. These tests are no longer valid and will need to be rewritten in the not too distant future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
  the file descriptior.
21
21
*/
22
22
 
23
 
#include "config.h"
24
 
 
25
23
#define DONT_MAP_VIO
26
 
#include "vio.h"
27
 
 
28
 
#include <fcntl.h>
29
 
 
30
 
#include <cstdio>
31
 
#include <cstring>
32
 
#include <cstdlib>
33
 
#include <memory>
34
 
 
35
 
using namespace std;
36
 
 
37
 
namespace drizzle_protocol
38
 
{
 
24
#include <drizzled/global.h>
 
25
#include <libdrizzle/vio.h>
 
26
#include <string.h>
 
27
#include <stdint.h>
39
28
 
40
29
/*
41
30
 * Helper to fill most of the Vio* with defaults.
42
31
 */
43
32
 
44
 
static void drizzleclient_vio_init(Vio* vio, enum enum_vio_type type,
 
33
static void vio_init(Vio* vio, enum enum_vio_type type,
45
34
                     int sd, uint32_t flags)
46
35
{
 
36
#ifndef HAVE_VIO_READ_BUFF
 
37
  flags&= ~VIO_BUFFERED_READ;
 
38
#endif
47
39
  memset(vio, 0, sizeof(*vio));
48
40
  vio->type     = type;
49
41
  vio->sd       = sd;
51
43
      !(vio->read_buffer= (char*)malloc(VIO_READ_BUFFER_SIZE)))
52
44
    flags&= ~VIO_BUFFERED_READ;
53
45
  {
54
 
    vio->viodelete      =drizzleclient_vio_delete;
55
 
    vio->vioerrno       =drizzleclient_vio_errno;
56
 
    vio->read= (flags & VIO_BUFFERED_READ) ? drizzleclient_vio_read_buff : drizzleclient_vio_read;
57
 
    vio->write          =drizzleclient_vio_write;
58
 
    vio->fastsend       =drizzleclient_vio_fastsend;
59
 
    vio->viokeepalive   =drizzleclient_vio_keepalive;
60
 
    vio->should_retry   =drizzleclient_vio_should_retry;
61
 
    vio->was_interrupted=drizzleclient_vio_was_interrupted;
62
 
    vio->vioclose       =drizzleclient_vio_close;
63
 
    vio->peer_addr      =drizzleclient_vio_peer_addr;
64
 
    vio->vioblocking    =drizzleclient_vio_blocking;
65
 
    vio->is_blocking    =drizzleclient_vio_is_blocking;
66
 
    vio->timeout        =drizzleclient_vio_timeout;
 
46
    vio->viodelete      =vio_delete;
 
47
    vio->vioerrno       =vio_errno;
 
48
    vio->read= (flags & VIO_BUFFERED_READ) ? vio_read_buff : vio_read;
 
49
    vio->write          =vio_write;
 
50
    vio->fastsend       =vio_fastsend;
 
51
    vio->viokeepalive   =vio_keepalive;
 
52
    vio->should_retry   =vio_should_retry;
 
53
    vio->was_interrupted=vio_was_interrupted;
 
54
    vio->vioclose       =vio_close;
 
55
    vio->peer_addr      =vio_peer_addr;
 
56
    vio->vioblocking    =vio_blocking;
 
57
    vio->is_blocking    =vio_is_blocking;
 
58
    vio->timeout        =vio_timeout;
67
59
  }
68
60
}
69
61
 
70
62
 
71
63
/* Reset initialized VIO to use with another transport type */
72
64
 
73
 
void drizzleclient_vio_reset(Vio* vio, enum enum_vio_type type,
 
65
void vio_reset(Vio* vio, enum enum_vio_type type,
74
66
               int sd, uint32_t flags)
75
67
{
76
68
  free(vio->read_buffer);
77
 
  drizzleclient_vio_init(vio, type, sd, flags);
 
69
  vio_init(vio, type, sd, flags);
78
70
}
79
71
 
80
72
 
81
73
/* Open the socket or TCP/IP connection and read the fnctl() status */
82
74
 
83
 
Vio *drizzleclient_vio_new(int sd, enum enum_vio_type type, uint32_t flags)
 
75
Vio *vio_new(int sd, enum enum_vio_type type, uint32_t flags)
84
76
{
85
77
  Vio *vio = (Vio*) malloc(sizeof(Vio));
86
78
 
87
79
  if (vio != NULL)
88
80
  {
89
 
    drizzleclient_vio_init(vio, type, sd, flags);
 
81
    vio_init(vio, type, sd, flags);
90
82
    sprintf(vio->desc, "TCP/IP (%d)", vio->sd);
91
83
    /*
92
84
      We call fcntl() to set the flags and then immediately read them back
105
97
}
106
98
 
107
99
 
108
 
void drizzleclient_vio_delete(Vio* vio)
 
100
void vio_delete(Vio* vio)
109
101
{
110
102
  if (!vio)
111
103
    return; /* It must be safe to delete null pointers. */
122
114
  components below it when application finish
123
115
 
124
116
*/
125
 
void drizzleclient_vio_end(void)
126
 
{ }
127
 
 
128
 
} /* namespace drizzle_protocol */
 
117
void vio_end(void)
 
118
{
 
119
}