~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-1.0/t/client_server.c

  • Committer: Mark Atwood
  • Date: 2011-12-14 18:12:05 UTC
  • mfrom: (2465.1.4 drizzle)
  • Revision ID: me@mark.atwood.name-20111214181205-tkz0lq9c4c0ptrwo
mergeĀ lp:~brianaker/drizzle/fix-localhost

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Drizzle Client & Protocol Library
 
3
 *
 
4
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
 
5
 * All rights reserved.
 
6
 *
 
7
 * Use and distribution licensed under the BSD license.  See
 
8
 * the COPYING file in this directory for full text.
 
9
 */
 
10
 
 
11
/**
 
12
 * @file
 
13
 * @brief Tests for drizzle_st Structures
 
14
 */
 
15
 
 
16
#include <libdrizzle-1.0/t/common.h>
 
17
 
 
18
#include <assert.h>
 
19
#include <unistd.h>
 
20
 
 
21
#define DRIZZLE_TEST_HOST "localhost"
 
22
#define DRIZZLE_TEST_PORT 12399
 
23
 
 
24
typedef enum
 
25
{
 
26
  SERVER_STATE_START,
 
27
  SERVER_STATE_HANDSHAKE_WRITE,
 
28
  SERVER_STATE_HANDSHAKE_READ,
 
29
  SERVER_STATE_HANDSHAKE_RESULT,
 
30
  SERVER_STATE_COMMAND_BUFFER,
 
31
  SERVER_STATE_RESULT_HEADER,
 
32
  SERVER_STATE_RESULT_COLUMN_1,
 
33
  SERVER_STATE_RESULT_COLUMN_2,
 
34
  SERVER_STATE_RESULT_COLUMN_EOF,
 
35
  SERVER_STATE_RESULT_ROW_1,
 
36
  SERVER_STATE_RESULT_ROW_1_FIELD_1,
 
37
  SERVER_STATE_RESULT_ROW_1_FIELD_2,
 
38
  SERVER_STATE_RESULT_ROW_EOF,
 
39
  SERVER_STATE_DONE
 
40
} server_state_t;
 
41
 
 
42
typedef struct
 
43
{
 
44
  server_state_t state;
 
45
  drizzle_result_st result;
 
46
  drizzle_column_st column;
 
47
  drizzle_command_t command;
 
48
  char *data;
 
49
  size_t total;
 
50
} server_state_st;
 
51
 
 
52
typedef enum
 
53
{
 
54
  CLIENT_STATE_START,
 
55
  CLIENT_STATE_RESULT,
 
56
  CLIENT_STATE_DONE
 
57
} client_state_t;
 
58
 
 
59
typedef struct
 
60
{
 
61
  client_state_t state;
 
62
  drizzle_result_st result;
 
63
} client_state_st;
 
64
 
 
65
static void _server(drizzle_con_st *con, server_state_st *state);
 
66
static void _client(drizzle_con_st *con, client_state_st *state);
 
67
 
 
68
int main(void)
 
69
{
 
70
  close(STDOUT_FILENO);
 
71
 
 
72
  drizzle_st drizzle;
 
73
  drizzle_con_st listen_con;
 
74
  drizzle_con_st client;
 
75
  drizzle_con_st server;
 
76
  drizzle_return_t ret;
 
77
  bool server_accepted = false;
 
78
  server_state_st server_state;
 
79
  client_state_st client_state;
 
80
 
 
81
  drizzle_test("drizzle_create");
 
82
  if (drizzle_create(&drizzle) == NULL)
 
83
    drizzle_test_error("returned NULL");
 
84
 
 
85
  drizzle_test("drizzle_con_add_tcp_listen");
 
86
  if (drizzle_con_add_tcp_listen(&drizzle, &listen_con, DRIZZLE_TEST_HOST,
 
87
                                 DRIZZLE_TEST_PORT, 1,
 
88
                                 DRIZZLE_CON_NONE) == NULL)
 
89
  {
 
90
    drizzle_test_error("returned NULL");
 
91
  }
 
92
 
 
93
  drizzle_test("drizzle_con_listen");
 
94
  ret= drizzle_con_listen(&listen_con);
 
95
  if (ret != DRIZZLE_RETURN_OK)
 
96
    drizzle_test_error("returned %s (%d)", drizzle_error(&drizzle), ret);
 
97
 
 
98
  drizzle_test("drizzle_con_add_tcp");
 
99
  if (drizzle_con_add_tcp(&drizzle, &client, DRIZZLE_TEST_HOST,
 
100
                          DRIZZLE_TEST_PORT, NULL, NULL, NULL,
 
101
                          DRIZZLE_CON_NONE) == NULL)
 
102
  {
 
103
    drizzle_test_error("returned NULL");
 
104
  }
 
105
 
 
106
  drizzle_test("drizzle_add_options");
 
107
  drizzle_add_options(&drizzle, DRIZZLE_NON_BLOCKING);
 
108
 
 
109
  server_state.state= SERVER_STATE_START;
 
110
  client_state.state= CLIENT_STATE_START;
 
111
 
 
112
  while (true)
 
113
  {
 
114
    if (!server_accepted)
 
115
    {
 
116
      drizzle_test("drizzle_con_accept");
 
117
      (void)drizzle_con_accept(&drizzle, &server, &ret);
 
118
      if (ret == DRIZZLE_RETURN_OK)
 
119
        server_accepted = true;
 
120
      else if (ret != DRIZZLE_RETURN_IO_WAIT)
 
121
        drizzle_test_error("returned %s (%d)", drizzle_error(&drizzle), ret);
 
122
    }
 
123
 
 
124
    if (server_accepted)
 
125
      _server(&server, &server_state);
 
126
 
 
127
    _client(&client, &client_state);
 
128
 
 
129
    if (server_state.state == SERVER_STATE_DONE &&
 
130
        client_state.state == CLIENT_STATE_DONE)
 
131
    {
 
132
      break;
 
133
    }
 
134
 
 
135
    drizzle_test("drizzle_con_wait");
 
136
    ret= drizzle_con_wait(&drizzle);
 
137
    if (ret != DRIZZLE_RETURN_OK)
 
138
      drizzle_test_error("returned %s (%d)", drizzle_error(&drizzle), ret);
 
139
  }
 
140
 
 
141
  if (server_accepted)
 
142
  {
 
143
    drizzle_test("drizzle_con_free");
 
144
    drizzle_con_free(&server);
 
145
  }
 
146
 
 
147
  drizzle_test("drizzle_con_free");
 
148
  drizzle_con_free(&client);
 
149
 
 
150
  drizzle_test("drizzle_con_free");
 
151
  drizzle_con_free(&listen_con);
 
152
 
 
153
  drizzle_test("drizzle_free");
 
154
  drizzle_free(&drizzle);
 
155
 
 
156
  return 0;
 
157
}
 
158
 
 
159
static void _server(drizzle_con_st *con, server_state_st *state)
 
160
{
 
161
  drizzle_return_t ret;
 
162
  const drizzle_field_t const fields[2]=
 
163
  {
 
164
    (const drizzle_field_t)"test_field_1",
 
165
    (const drizzle_field_t)"test_field_2"
 
166
  };
 
167
  const size_t field_sizes[2]= { 12, 12 };
 
168
 
 
169
  switch(state->state)
 
170
  {
 
171
  case SERVER_STATE_START:
 
172
    drizzle_con_set_protocol_version(con, 10);
 
173
    drizzle_con_set_server_version(con, "test_version");
 
174
    drizzle_con_set_thread_id(con, 1);
 
175
    drizzle_con_set_scramble(con, (const uint8_t *)"ABCDEFGHIJKLMNOPQRST");
 
176
    drizzle_con_set_capabilities(con, DRIZZLE_CAPABILITIES_NONE);
 
177
    drizzle_con_set_charset(con, 8);
 
178
    drizzle_con_set_status(con, DRIZZLE_CON_STATUS_NONE);
 
179
    drizzle_con_set_max_packet_size(con, DRIZZLE_MAX_PACKET_SIZE);
 
180
 
 
181
  case SERVER_STATE_HANDSHAKE_WRITE:
 
182
    drizzle_test("drizzle_handshake_server_write");
 
183
    ret= drizzle_handshake_server_write(con);
 
184
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
185
    {
 
186
      state->state = SERVER_STATE_HANDSHAKE_WRITE;
 
187
      return;
 
188
    }
 
189
    else if (ret != DRIZZLE_RETURN_OK)
 
190
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
191
 
 
192
  case SERVER_STATE_HANDSHAKE_READ:
 
193
    drizzle_test("drizzle_handshake_client_read");
 
194
    ret= drizzle_handshake_client_read(con);
 
195
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
196
    {
 
197
      state->state = SERVER_STATE_HANDSHAKE_READ;
 
198
      return;
 
199
    }
 
200
    else if (ret != DRIZZLE_RETURN_OK)
 
201
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
202
 
 
203
    drizzle_test("drizzle_result_create");
 
204
    if (drizzle_result_create(con, &state->result) == NULL)
 
205
      drizzle_test_error("returned %s", drizzle_con_error(con));
 
206
 
 
207
  case SERVER_STATE_HANDSHAKE_RESULT:
 
208
    drizzle_test("drizzle_handshake_result_write");
 
209
    ret= drizzle_result_write(con, &state->result, true);
 
210
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
211
    {
 
212
      state->state = SERVER_STATE_HANDSHAKE_RESULT;
 
213
      return;
 
214
    }
 
215
    else if (ret != DRIZZLE_RETURN_OK)
 
216
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
217
 
 
218
    drizzle_result_free(&state->result);
 
219
 
 
220
  case SERVER_STATE_COMMAND_BUFFER:
 
221
    drizzle_test("drizzle_con_command_buffer");
 
222
    state->data= drizzle_con_command_buffer(con, &state->command, &state->total,
 
223
                                            &ret);
 
224
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
225
    {
 
226
      state->state = SERVER_STATE_COMMAND_BUFFER;
 
227
      return;
 
228
    }
 
229
    else if (ret != DRIZZLE_RETURN_OK)
 
230
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
231
 
 
232
    if (state->command != DRIZZLE_COMMAND_QUERY)
 
233
      drizzle_test_error("command was not a query");
 
234
 
 
235
    if (state->total != 6 && !memcmp(state->data, "SELECT", 6))
 
236
      drizzle_test_error("query doesn't match");
 
237
 
 
238
    if (state->data != NULL)
 
239
    {
 
240
      free(state->data);
 
241
      state->data= NULL;
 
242
    }
 
243
 
 
244
    drizzle_test("drizzle_result_create");
 
245
    if (drizzle_result_create(con, &state->result) == NULL)
 
246
      drizzle_test_error("returned %s", drizzle_con_error(con));
 
247
 
 
248
    drizzle_result_set_column_count(&state->result, 2);
 
249
 
 
250
  case SERVER_STATE_RESULT_HEADER:
 
251
    drizzle_test("drizzle_handshake_result_write");
 
252
    ret= drizzle_result_write(con, &state->result, false);
 
253
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
254
    {
 
255
      state->state = SERVER_STATE_RESULT_HEADER;
 
256
      return;
 
257
    }
 
258
    else if (ret != DRIZZLE_RETURN_OK)
 
259
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
260
 
 
261
    drizzle_test("drizzle_column_create");
 
262
    if (drizzle_column_create(&state->result, &state->column) == NULL)
 
263
      drizzle_test_error("returned %s", drizzle_con_error(con));
 
264
 
 
265
    drizzle_column_set_catalog(&state->column, "test_catalog");
 
266
    drizzle_column_set_db(&state->column, "test_db");
 
267
    drizzle_column_set_table(&state->column, "test_table");
 
268
    drizzle_column_set_orig_table(&state->column, "test_orig_table");
 
269
    drizzle_column_set_name(&state->column, "test_column_1");
 
270
    drizzle_column_set_orig_name(&state->column, "test_orig_column_1");
 
271
    drizzle_column_set_charset(&state->column, 8);
 
272
    drizzle_column_set_size(&state->column, 32);
 
273
    drizzle_column_set_type(&state->column, DRIZZLE_COLUMN_TYPE_VARCHAR);
 
274
    drizzle_column_set_flags(&state->column, DRIZZLE_COLUMN_FLAGS_NONE);
 
275
 
 
276
  case SERVER_STATE_RESULT_COLUMN_1:
 
277
    drizzle_test("drizzle_column_write");
 
278
    ret= drizzle_column_write(&state->result, &state->column);
 
279
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
280
    {
 
281
      state->state = SERVER_STATE_RESULT_COLUMN_1;
 
282
      return;
 
283
    }
 
284
    else if (ret != DRIZZLE_RETURN_OK)
 
285
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
286
 
 
287
    drizzle_column_set_name(&state->column, "test_column_2");
 
288
    drizzle_column_set_orig_name(&state->column, "test_orig_column_2");
 
289
 
 
290
  case SERVER_STATE_RESULT_COLUMN_2:
 
291
    drizzle_test("drizzle_column_write");
 
292
    ret= drizzle_column_write(&state->result, &state->column);
 
293
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
294
    {
 
295
      state->state = SERVER_STATE_RESULT_COLUMN_2;
 
296
      return;
 
297
    }
 
298
    else if (ret != DRIZZLE_RETURN_OK)
 
299
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
300
 
 
301
    drizzle_test("drizzle_column_free");
 
302
    drizzle_column_free(&state->column);
 
303
 
 
304
    drizzle_result_set_eof(&state->result, true);
 
305
 
 
306
  case SERVER_STATE_RESULT_COLUMN_EOF:
 
307
    drizzle_test("drizzle_handshake_result_write");
 
308
    ret= drizzle_result_write(con, &state->result, false);
 
309
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
310
    {
 
311
      state->state = SERVER_STATE_RESULT_COLUMN_EOF;
 
312
      return;
 
313
    }
 
314
    else if (ret != DRIZZLE_RETURN_OK)
 
315
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
316
 
 
317
    drizzle_result_calc_row_size(&state->result, fields, field_sizes);
 
318
 
 
319
  case SERVER_STATE_RESULT_ROW_1:
 
320
    ret= drizzle_row_write(&state->result);
 
321
 
 
322
  case SERVER_STATE_RESULT_ROW_1_FIELD_1:
 
323
    ret= drizzle_field_write(&state->result, fields[0], field_sizes[0],
 
324
                             field_sizes[0]);
 
325
 
 
326
  case SERVER_STATE_RESULT_ROW_1_FIELD_2:
 
327
    ret= drizzle_field_write(&state->result, fields[1], field_sizes[1],
 
328
                             field_sizes[1]);
 
329
 
 
330
  case SERVER_STATE_RESULT_ROW_EOF:
 
331
    drizzle_test("drizzle_handshake_result_write");
 
332
    ret= drizzle_result_write(con, &state->result, true);
 
333
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
334
    {
 
335
      state->state = SERVER_STATE_RESULT_ROW_EOF;
 
336
      return;
 
337
    }
 
338
    else if (ret != DRIZZLE_RETURN_OK)
 
339
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
340
 
 
341
    drizzle_result_free(&state->result);
 
342
 
 
343
    state->state = SERVER_STATE_DONE;
 
344
 
 
345
  case SERVER_STATE_DONE:
 
346
    return;
 
347
 
 
348
  default:
 
349
    drizzle_test_error("invalid server state");
 
350
  }
 
351
}
 
352
 
 
353
static void _client(drizzle_con_st *con, client_state_st *state)
 
354
{
 
355
  drizzle_return_t ret;
 
356
  drizzle_column_st *column;
 
357
  drizzle_row_t row;
 
358
  size_t *field_sizes;
 
359
 
 
360
  switch(state->state)
 
361
  {
 
362
  case CLIENT_STATE_START:
 
363
    drizzle_test("drizzle_query_str");
 
364
    (void)drizzle_query_str(con, &state->result, "SELECT", &ret);
 
365
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
366
    {
 
367
      state->state = CLIENT_STATE_START;
 
368
      return;
 
369
    }
 
370
    else if (ret != DRIZZLE_RETURN_OK)
 
371
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
372
 
 
373
  case CLIENT_STATE_RESULT:
 
374
    drizzle_test("drizzle_result_buffer");
 
375
    ret = drizzle_result_buffer(&state->result);
 
376
    if (ret == DRIZZLE_RETURN_IO_WAIT)
 
377
    {
 
378
      state->state = CLIENT_STATE_RESULT;
 
379
      return;
 
380
    }
 
381
    else if (ret != DRIZZLE_RETURN_OK)
 
382
      drizzle_test_error("returned %s (%d)", drizzle_con_error(con), ret);
 
383
 
 
384
    drizzle_test("drizzle_con_protocol_version");
 
385
    if (drizzle_con_protocol_version(con) != 10)
 
386
      drizzle_test_error("no match");
 
387
 
 
388
    drizzle_test("drizzle_con_server_version");
 
389
    if (strcmp(drizzle_con_server_version(con), "test_version"))
 
390
      drizzle_test_error("no match");
 
391
 
 
392
    drizzle_test("drizzle_con_thread_id");
 
393
    if (drizzle_con_thread_id(con) != 1)
 
394
      drizzle_test_error("no match");
 
395
 
 
396
    drizzle_test("drizzle_con_scramble");
 
397
    if (memcmp(drizzle_con_scramble(con), "ABCDEFGHIJKLMNOPQRST",
 
398
               DRIZZLE_MAX_SCRAMBLE_SIZE))
 
399
    {
 
400
      drizzle_test_error("no match");
 
401
    }
 
402
 
 
403
    /* We default to MySQL protocol right now, which sets this flag. */
 
404
    drizzle_test("drizzle_con_capabilities");
 
405
    if (drizzle_con_capabilities(con) != DRIZZLE_CAPABILITIES_PROTOCOL_41)
 
406
      drizzle_test_error("no match");
 
407
 
 
408
    drizzle_test("drizzle_con_charset");
 
409
    if (drizzle_con_charset(con) != 8)
 
410
      drizzle_test_error("no match");
 
411
 
 
412
    drizzle_test("drizzle_con_status");
 
413
    if (drizzle_con_status(con) != DRIZZLE_CON_STATUS_NONE)
 
414
      drizzle_test_error("no match");
 
415
 
 
416
    drizzle_test("drizzle_con_packet_size");
 
417
    if (drizzle_con_max_packet_size(con) != DRIZZLE_MAX_PACKET_SIZE)
 
418
      drizzle_test_error("no match");
 
419
 
 
420
    drizzle_test("drizzle_column_next");
 
421
    column= drizzle_column_next(&state->result);
 
422
    if (column == NULL)
 
423
      drizzle_test_error("column not found");
 
424
 
 
425
    drizzle_test("drizzle_column_drizzle_result");
 
426
    if (drizzle_column_drizzle_result(column) != &state->result)
 
427
      drizzle_test_error("no match");
 
428
 
 
429
    drizzle_test("drizzle_column_catalog");
 
430
    if (strcmp(drizzle_column_catalog(column), "test_catalog"))
 
431
      drizzle_test_error("no match");
 
432
 
 
433
    drizzle_test("drizzle_column_db");
 
434
    if (strcmp(drizzle_column_db(column), "test_db"))
 
435
      drizzle_test_error("no match");
 
436
 
 
437
    drizzle_test("drizzle_column_table");
 
438
    if (strcmp(drizzle_column_table(column), "test_table"))
 
439
      drizzle_test_error("no match");
 
440
 
 
441
    drizzle_test("drizzle_column_orig_table");
 
442
    if (strcmp(drizzle_column_orig_table(column), "test_orig_table"))
 
443
      drizzle_test_error("no match");
 
444
 
 
445
    drizzle_test("drizzle_column_name");
 
446
    if (strcmp(drizzle_column_name(column), "test_column_1"))
 
447
      drizzle_test_error("no match");
 
448
 
 
449
    drizzle_test("drizzle_column_orig_name");
 
450
    if (strcmp(drizzle_column_orig_name(column), "test_orig_column_1"))
 
451
      drizzle_test_error("no match");
 
452
 
 
453
    drizzle_test("drizzle_column_charset");
 
454
    if (drizzle_column_charset(column) != 8)
 
455
      drizzle_test_error("no match");
 
456
 
 
457
    drizzle_test("drizzle_column_size");
 
458
    if (drizzle_column_size(column) != 32)
 
459
      drizzle_test_error("no match");
 
460
 
 
461
    drizzle_test("drizzle_column_max_size");
 
462
    if (drizzle_column_max_size(column) != 12)
 
463
      drizzle_test_error("no match");
 
464
 
 
465
    drizzle_test("drizzle_column_type_drizzle");
 
466
    if (drizzle_column_type_drizzle(column) != DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR)
 
467
      drizzle_test_error("no match");
 
468
 
 
469
    drizzle_test("drizzle_column_flags");
 
470
    if (drizzle_column_flags(column) != DRIZZLE_COLUMN_FLAGS_NONE)
 
471
      drizzle_test_error("no match");
 
472
 
 
473
    drizzle_test("drizzle_column_next");
 
474
    column= drizzle_column_next(&state->result);
 
475
    if (column == NULL)
 
476
      drizzle_test_error("column not found");
 
477
 
 
478
    drizzle_test("drizzle_column_name");
 
479
    if (strcmp(drizzle_column_name(column), "test_column_2"))
 
480
      drizzle_test_error("no match");
 
481
 
 
482
    drizzle_test("drizzle_column_next");
 
483
    column= drizzle_column_next(&state->result);
 
484
    if (column != NULL)
 
485
      drizzle_test_error("column found");
 
486
 
 
487
    drizzle_test("drizzle_column_prev");
 
488
    column= drizzle_column_prev(&state->result);
 
489
    if (column == NULL)
 
490
      drizzle_test_error("column not found");
 
491
 
 
492
    drizzle_test("drizzle_column_name");
 
493
    if (strcmp(drizzle_column_name(column), "test_column_2"))
 
494
      drizzle_test_error("no match");
 
495
 
 
496
    drizzle_test("drizzle_row_next");
 
497
    row= drizzle_row_next(&state->result);
 
498
    if (row == NULL)
 
499
      drizzle_test_error("row not found");
 
500
 
 
501
    if (strcmp(row[0], "test_field_1") || strcmp(row[1], "test_field_2"))
 
502
      drizzle_test_error("no match");
 
503
 
 
504
    drizzle_test("drizzle_row_field_sizes");
 
505
    field_sizes= drizzle_row_field_sizes(&state->result);
 
506
    if (field_sizes[0] != 12 || field_sizes[1] != 12)
 
507
      drizzle_test_error("no match");
 
508
 
 
509
    drizzle_test("drizzle_row_prev");
 
510
    row = drizzle_row_prev(&state->result);
 
511
    if (row == NULL)
 
512
      drizzle_test_error("row not found");
 
513
 
 
514
    if (strcmp(row[0], "test_field_1") || strcmp(row[1], "test_field_2"))
 
515
      drizzle_test_error("no match");
 
516
 
 
517
    drizzle_test("drizzle_row_next");
 
518
    row = drizzle_row_next(&state->result);
 
519
 
 
520
    drizzle_test("drizzle_row_index");
 
521
    row = drizzle_row_index(&state->result, 0);
 
522
    if (row == NULL)
 
523
      drizzle_test_error("row not found");
 
524
 
 
525
    if (strcmp(row[0], "test_field_1") || strcmp(row[1], "test_field_2"))
 
526
      drizzle_test_error("no match");
 
527
 
 
528
    drizzle_test("drizzle_row_index");
 
529
    row = drizzle_row_index(&state->result, 1);
 
530
    if (row != NULL)
 
531
      drizzle_test_error("row found");
 
532
 
 
533
    drizzle_test("drizzle_result_free");
 
534
    drizzle_result_free(&state->result);
 
535
 
 
536
    state->state = CLIENT_STATE_DONE;
 
537
 
 
538
  case CLIENT_STATE_DONE:
 
539
    return;
 
540
 
 
541
  default:
 
542
    drizzle_test_error("invalid client state");
 
543
  }
 
544
}