~drizzle-trunk/drizzle/development

1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
1
/*
2
 * Drizzle Client & Protocol Library
3
 *
4
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
5
 * All rights reserved.
6
 *
1971.2.1 by kalebral at gmail
update files that did not have license or had incorrect license structure
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions are
9
 * met:
10
 *
11
 *     * Redistributions of source code must retain the above copyright
12
 * notice, this list of conditions and the following disclaimer.
13
 *
14
 *     * Redistributions in binary form must reproduce the above
15
 * copyright notice, this list of conditions and the following disclaimer
16
 * in the documentation and/or other materials provided with the
17
 * distribution.
18
 *
19
 *     * The names of its contributors may not be used to endorse or
20
 * promote products derived from this software without specific prior
21
 * written permission.
22
 *
23
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
 *
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
35
 */
36
37
#include <errno.h>
38
#include <stdio.h>
39
#include <stdlib.h>
40
#include <unistd.h>
41
2449.1.2 by Brian Aker
Additional fixes for libdrizzle.
42
#include <libdrizzle-2.0/drizzle_client.h>
43
#include <libdrizzle-2.0/drizzle_server.h>
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
44
45
#define DRIZZLE_RETURN_CHECK(__ret, __function, __drizzle) \
46
{ \
47
  if ((__ret) != DRIZZLE_RETURN_OK) \
48
    DRIZZLE_RETURN_ERROR(__function, __drizzle) \
49
}
50
51
#define DRIZZLE_RETURN_ERROR(__function, __drizzle) \
52
{ \
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
53
  fprintf(stderr, __function ":%s\n", drizzle_error(__drizzle)); \
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
54
  return; \
55
}
56
2463.1.5 by Brian Aker
Move result over to being behind API.
57
static void proxy(drizzle_st *drizzle,
58
                  drizzle_con_st *server,
59
                  drizzle_con_st *client,
60
                  drizzle_column_st *column);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
61
62
int main(int argc, char *argv[])
63
{
64
  int c;
65
  uint32_t count= 0;
66
  const char *server_host= NULL;
67
  const char *client_host= NULL;
68
  bool server_mysql= false;
69
  bool client_mysql= false;
70
  in_port_t server_port= 0;
71
  in_port_t client_port= 0;
72
  drizzle_verbose_t verbose= DRIZZLE_VERBOSE_NEVER;
73
  drizzle_return_t ret;
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
74
  drizzle_st *drizzle;
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
75
  drizzle_result_st client_result;
76
  drizzle_column_st column;
77
78
  while((c = getopt(argc, argv, "c:h:H:mMp:P:v")) != -1)
79
  {
80
    switch(c)
81
    {
82
    case 'c':
83
      count= (uint32_t)atoi(optarg);
84
      break;
85
86
    case 'h':
87
      server_host= optarg;
88
      break;
89
90
    case 'H':
91
      client_host= optarg;
92
      break;
93
94
    case 'm':
95
      server_mysql= true;
96
      break;
97
98
    case 'M':
99
      client_mysql= true;
100
      break;
101
102
    case 'p':
103
      server_port= (in_port_t)atoi(optarg);
104
      break;
105
106
    case 'P':
107
      client_port= (in_port_t)atoi(optarg);
108
      break;
109
110
    case 'v':
1992.6.2 by Monty Taylor
Cleaned up for additional gcc 4.5 warnings.
111
      switch(verbose)
112
      {
113
      case DRIZZLE_VERBOSE_NEVER:
114
        verbose= DRIZZLE_VERBOSE_FATAL;
115
        break;
116
      case DRIZZLE_VERBOSE_FATAL:
117
        verbose= DRIZZLE_VERBOSE_ERROR;
118
        break;
119
      case DRIZZLE_VERBOSE_ERROR:
120
        verbose= DRIZZLE_VERBOSE_INFO;
121
        break;
122
      case DRIZZLE_VERBOSE_INFO:
123
        verbose= DRIZZLE_VERBOSE_DEBUG;
124
        break;
125
      case DRIZZLE_VERBOSE_DEBUG:
126
        verbose= DRIZZLE_VERBOSE_CRAZY;
127
        break;
128
      case DRIZZLE_VERBOSE_CRAZY:
129
      case DRIZZLE_VERBOSE_MAX:
130
        break;
131
      }
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
132
      break;
133
134
    default:
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
135
      fprintf(stderr, "\nusage: %s [-c <count>] [-h <host>] [-H <host>] [-m] [-M] "
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
136
             "[-p <port>] [-p <port>] [-v]\n", argv[0]);
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
137
      fprintf(stderr, "\t-c <count> - Number of connections to accept before exiting\n");
138
      fprintf(stderr, "\t-h <host>  - Host to listen on\n");
139
      fprintf(stderr, "\t-H <host>  - Host to connect to\n");
140
      fprintf(stderr, "\t-m         - Use MySQL protocol for incoming connections\n");
141
      fprintf(stderr, "\t-M         - Use MySQL protocol for outgoing connectionsn\n");
142
      fprintf(stderr, "\t-p <port>  - Port to listen on\n");
143
      fprintf(stderr, "\t-P <port>  - Port to connect to\n");
144
      fprintf(stderr, "\t-v         - Increase verbosity level\n");
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
145
      return 1;
146
    }
147
  }
148
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
149
  if ((drizzle= drizzle_create()) == NULL)
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
150
  {
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
151
    fprintf(stderr, "drizzle_create:NULL\n");
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
152
    return 1;
153
  }
154
2463.1.3 by Brian Aker
Redo the way options are handled.
155
  drizzle_set_option(drizzle, DRIZZLE_FREE_OBJECTS, true);
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
156
  drizzle_set_verbose(drizzle, verbose);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
157
2463.1.4 by Brian Aker
Remove con from being passed object.
158
  drizzle_con_st *con_listen;
159
  if ((con_listen= drizzle_con_create(drizzle)) == NULL)
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
160
  {
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
161
    fprintf(stderr, "drizzle_con_create:NULL\n");
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
162
    return 1;
163
  }
164
1929.1.32 by Stewart Smith
fix excessive stack usage in examples/proxy.c:
165
  drizzle_con_add_options(con_listen, DRIZZLE_CON_LISTEN);
166
  drizzle_con_set_tcp(con_listen, server_host, server_port);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
167
168
  if (server_mysql)
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
169
  {
1929.1.32 by Stewart Smith
fix excessive stack usage in examples/proxy.c:
170
    drizzle_con_add_options(con_listen, DRIZZLE_CON_MYSQL);
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
171
  }
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
172
1929.1.32 by Stewart Smith
fix excessive stack usage in examples/proxy.c:
173
  if (drizzle_con_listen(con_listen) != DRIZZLE_RETURN_OK)
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
174
  {
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
175
    fprintf(stderr, "drizzle_con_listen:%s\n", drizzle_error(drizzle));
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
176
    return 1;
177
  }
178
179
  while (1)
180
  {
2463.1.4 by Brian Aker
Remove con from being passed object.
181
    drizzle_con_st *server= drizzle_con_accept(drizzle, &ret);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
182
    if (ret != DRIZZLE_RETURN_OK)
183
    {
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
184
      fprintf(stderr, "drizzle_con_accept:%s\n", drizzle_error(drizzle));
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
185
      return 1;
186
    }
187
2463.1.4 by Brian Aker
Remove con from being passed object.
188
    drizzle_con_st *client;
189
    if ((client= drizzle_con_create(drizzle)) == NULL)
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
190
    {
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
191
      fprintf(stderr, "drizzle_con_create:NULL\n");
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
192
      return 1;
193
    }
194
1929.1.32 by Stewart Smith
fix excessive stack usage in examples/proxy.c:
195
    drizzle_con_add_options(client,
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
196
                            DRIZZLE_CON_RAW_PACKET | DRIZZLE_CON_RAW_SCRAMBLE);
197
    if (client_mysql)
2463.1.4 by Brian Aker
Remove con from being passed object.
198
    {
1929.1.32 by Stewart Smith
fix excessive stack usage in examples/proxy.c:
199
      drizzle_con_add_options(client, DRIZZLE_CON_MYSQL);
2463.1.4 by Brian Aker
Remove con from being passed object.
200
    }
1929.1.32 by Stewart Smith
fix excessive stack usage in examples/proxy.c:
201
    drizzle_con_set_tcp(client, client_host, client_port);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
202
1929.1.32 by Stewart Smith
fix excessive stack usage in examples/proxy.c:
203
    ret= drizzle_con_connect(client);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
204
    if (ret != DRIZZLE_RETURN_OK)
205
    {
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
206
      fprintf(stderr, "drizzle_con_connect:%s\n", drizzle_error(drizzle));
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
207
      return 1;
208
    }
209
2463.1.5 by Brian Aker
Move result over to being behind API.
210
    proxy(drizzle, server, client, &column);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
211
1929.1.32 by Stewart Smith
fix excessive stack usage in examples/proxy.c:
212
    drizzle_con_free(client);
213
    drizzle_con_free(server);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
214
215
    if (count > 0)
216
    {
217
      count--;
218
219
      if (count == 0)
220
        break;
221
    }
222
  }
223
1929.1.32 by Stewart Smith
fix excessive stack usage in examples/proxy.c:
224
  drizzle_con_free(con_listen);
2463.1.2 by Brian Aker
First pass, drizzle_create() no longer takes an argument. This means that we can now change drizzle_st without being concerned about ABI.
225
  drizzle_free(drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
226
227
  return 0;
228
}
229
230
static void proxy(drizzle_st *drizzle, drizzle_con_st *server,
2463.1.5 by Brian Aker
Move result over to being behind API.
231
                  drizzle_con_st *client,
232
                  drizzle_column_st *column)
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
233
{
234
  drizzle_return_t ret;
235
  drizzle_command_t command;
1992.6.2 by Monty Taylor
Cleaned up for additional gcc 4.5 warnings.
236
  uint8_t *data;
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
237
  size_t offset;
238
  size_t size;
239
  size_t total;
240
  uint64_t row;
241
  bool row_break;
242
  drizzle_field_t field;
243
244
  /* Handshake packets. */
245
  ret= drizzle_handshake_server_read(client);
2463.1.5 by Brian Aker
Move result over to being behind API.
246
  DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_server_read", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
247
248
  drizzle_con_copy_handshake(server, client);
249
250
  ret= drizzle_handshake_server_write(server);
2463.1.5 by Brian Aker
Move result over to being behind API.
251
  DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_server_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
252
253
  ret= drizzle_handshake_client_read(server);
2463.1.5 by Brian Aker
Move result over to being behind API.
254
  DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_client_read", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
255
256
  drizzle_con_copy_handshake(client, server);
257
258
  ret= drizzle_handshake_client_write(client);
2463.1.5 by Brian Aker
Move result over to being behind API.
259
  DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_client_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
260
2463.1.5 by Brian Aker
Move result over to being behind API.
261
  drizzle_result_st *client_result= drizzle_result_read(client, NULL, &ret);
262
  DRIZZLE_RETURN_CHECK(ret, "drizzle_result_read", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
263
264
  drizzle_con_set_status(server, drizzle_con_status(client));
265
2463.1.5 by Brian Aker
Move result over to being behind API.
266
  drizzle_result_st *server_result;
267
  if ((server_result= drizzle_result_clone(server, client_result)) == NULL)
268
  {
269
    DRIZZLE_RETURN_ERROR("drizzle_result_clone", drizzle);
270
  }
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
271
272
  ret= drizzle_result_write(server, server_result, true);
2463.1.5 by Brian Aker
Move result over to being behind API.
273
  DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
274
275
  if (drizzle_result_error_code(client_result) != 0 ||
276
      drizzle_result_eof(client_result))
277
  {
278
    /* There was a handshake or authentication error. */
279
    return;
280
  }
281
282
  drizzle_con_add_options(client, DRIZZLE_CON_READY);
283
284
  /* Command loop. */
285
  while (1)
286
  {
287
    drizzle_result_free(server_result);
288
    drizzle_result_free(client_result);
289
290
    while (1)
291
    {
2463.1.5 by Brian Aker
Move result over to being behind API.
292
      data= (uint8_t *)drizzle_con_command_read(server, &command, &offset, &size, &total, &ret);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
293
      if (ret == DRIZZLE_RETURN_LOST_CONNECTION)
2463.1.5 by Brian Aker
Move result over to being behind API.
294
      {
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
295
        return;
2463.1.5 by Brian Aker
Move result over to being behind API.
296
      }
297
298
      DRIZZLE_RETURN_CHECK(ret, "drizzle_con_command_read", drizzle);
299
300
      (void)drizzle_con_command_write(client, NULL, command, data, size, total, &ret);
301
      DRIZZLE_RETURN_CHECK(ret, "drizzle_con_command_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
302
303
      if ((offset + size) == total)
304
        break;
305
    }
306
307
    if (command == DRIZZLE_COMMAND_QUIT)
2463.1.5 by Brian Aker
Move result over to being behind API.
308
    {
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
309
      return;
2463.1.5 by Brian Aker
Move result over to being behind API.
310
    }
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
311
    else if (command == DRIZZLE_COMMAND_FIELD_LIST)
312
    {
2463.1.5 by Brian Aker
Move result over to being behind API.
313
      if ((client_result= drizzle_result_create(client)) == NULL)
314
      {
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
315
        DRIZZLE_RETURN_ERROR("drizzle_result_create", drizzle)
2463.1.5 by Brian Aker
Move result over to being behind API.
316
      }
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
317
2463.1.5 by Brian Aker
Move result over to being behind API.
318
      if ((server_result= drizzle_result_create(server)) == NULL)
319
      {
320
        DRIZZLE_RETURN_ERROR("drizzle_result_create", drizzle);
321
      }
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
322
    }
323
    else
324
    {
325
      (void)drizzle_result_read(client, client_result, &ret);
2463.1.5 by Brian Aker
Move result over to being behind API.
326
      DRIZZLE_RETURN_CHECK(ret, "drizzle_result_read", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
327
328
      drizzle_con_set_status(server, drizzle_con_status(client));
2463.1.5 by Brian Aker
Move result over to being behind API.
329
      if ((server_result= drizzle_result_clone(server, client_result)) == NULL)
330
      {
331
        DRIZZLE_RETURN_ERROR("drizzle_result_clone", drizzle);
332
      }
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
333
334
      if (drizzle_result_column_count(client_result) == 0)
335
      {
336
        /* Simple result with no column, row, or field data. */
337
        ret= drizzle_result_write(server, server_result, true);
2463.1.5 by Brian Aker
Move result over to being behind API.
338
        DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
339
340
        continue;
341
      }
342
343
      ret= drizzle_result_write(server, server_result, false);
2463.1.5 by Brian Aker
Move result over to being behind API.
344
      DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
345
    }
346
347
    /* Columns. */
348
    while (1)
349
    {
350
      if (drizzle_column_read(client_result, column, &ret) == NULL)
351
      {
2463.1.5 by Brian Aker
Move result over to being behind API.
352
        DRIZZLE_RETURN_CHECK(ret, "drizzle_column_read", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
353
        break;
354
      }
355
2463.1.5 by Brian Aker
Move result over to being behind API.
356
      DRIZZLE_RETURN_CHECK(ret, "drizzle_column_read", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
357
358
      ret= drizzle_column_write(server_result, column);
2463.1.5 by Brian Aker
Move result over to being behind API.
359
      DRIZZLE_RETURN_CHECK(ret, "drizzle_column_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
360
361
      drizzle_column_free(column);
362
    }
363
364
    drizzle_con_set_status(server, drizzle_con_status(client));
365
    drizzle_result_set_eof(server_result, true);
366
367
    if (command == DRIZZLE_COMMAND_FIELD_LIST)
368
    {
369
      ret= drizzle_result_write(server, server_result, true);
2463.1.5 by Brian Aker
Move result over to being behind API.
370
      DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
371
      continue;
372
    }
373
    else
374
    {
375
      ret= drizzle_result_write(server, server_result, false);
2463.1.5 by Brian Aker
Move result over to being behind API.
376
      DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
377
    }
378
379
    /* Rows. */
380
    while (1)
381
    {
382
      row= drizzle_row_read(client_result, &ret);
2463.1.5 by Brian Aker
Move result over to being behind API.
383
      DRIZZLE_RETURN_CHECK(ret, "drizzle_row_read", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
384
385
      if (row == 0)
386
        break;
387
388
      drizzle_result_set_row_size(server_result,
389
                                  drizzle_result_row_size(client_result));
390
391
      ret= drizzle_row_write(server_result);
2463.1.5 by Brian Aker
Move result over to being behind API.
392
      DRIZZLE_RETURN_CHECK(ret, "drizzle_row_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
393
394
      /* Fields. */
395
      row_break= false;
396
      while (row_break == false)
397
      {
398
        field= drizzle_field_read(client_result, &offset, &size, &total, &ret);
399
        if (ret == DRIZZLE_RETURN_ROW_END)
400
          break;
401
        else if (ret == DRIZZLE_RETURN_ROW_BREAK)
402
        {
403
          if (size == 0)
404
            break;
405
406
          row_break= true;
407
        }
408
        else
2463.1.5 by Brian Aker
Move result over to being behind API.
409
        {
410
          DRIZZLE_RETURN_CHECK(ret, "drizzle_field_read", drizzle);
411
        }
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
412
413
        ret= drizzle_field_write(server_result, field, size, total);
2463.1.5 by Brian Aker
Move result over to being behind API.
414
        DRIZZLE_RETURN_CHECK(ret, "drizzle_field_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
415
      }
416
    }
417
418
    ret= drizzle_result_write(server, server_result, true);
2463.1.5 by Brian Aker
Move result over to being behind API.
419
    DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
420
  }
421
}