244
244
/* Handshake packets. */
245
245
ret= drizzle_handshake_server_read(client);
246
DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_server_read", drizzle)
246
DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_server_read", drizzle);
248
248
drizzle_con_copy_handshake(server, client);
250
250
ret= drizzle_handshake_server_write(server);
251
DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_server_write", drizzle)
251
DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_server_write", drizzle);
253
253
ret= drizzle_handshake_client_read(server);
254
DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_client_read", drizzle)
254
DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_client_read", drizzle);
256
256
drizzle_con_copy_handshake(client, server);
258
258
ret= drizzle_handshake_client_write(client);
259
DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_client_write", drizzle)
259
DRIZZLE_RETURN_CHECK(ret, "drizzle_handshake_client_write", drizzle);
261
(void)drizzle_result_read(client, client_result, &ret);
262
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_read", drizzle)
261
drizzle_result_st *client_result= drizzle_result_read(client, NULL, &ret);
262
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_read", drizzle);
264
264
drizzle_con_set_status(server, drizzle_con_status(client));
266
if (drizzle_result_clone(server, server_result, client_result) == NULL)
267
DRIZZLE_RETURN_ERROR("drizzle_result_clone", drizzle)
266
drizzle_result_st *server_result;
267
if ((server_result= drizzle_result_clone(server, client_result)) == NULL)
269
DRIZZLE_RETURN_ERROR("drizzle_result_clone", drizzle);
269
272
ret= drizzle_result_write(server, server_result, true);
270
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle)
273
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
272
275
if (drizzle_result_error_code(client_result) != 0 ||
273
276
drizzle_result_eof(client_result))
289
data= (uint8_t *)drizzle_con_command_read(server, &command, &offset, &size, &total,
292
data= (uint8_t *)drizzle_con_command_read(server, &command, &offset, &size, &total, &ret);
291
293
if (ret == DRIZZLE_RETURN_LOST_CONNECTION)
294
DRIZZLE_RETURN_CHECK(ret, "drizzle_con_command_read", drizzle)
296
(void)drizzle_con_command_write(client, NULL, command, data, size, total,
298
DRIZZLE_RETURN_CHECK(ret, "drizzle_con_command_write", drizzle)
298
DRIZZLE_RETURN_CHECK(ret, "drizzle_con_command_read", drizzle);
300
(void)drizzle_con_command_write(client, NULL, command, data, size, total, &ret);
301
DRIZZLE_RETURN_CHECK(ret, "drizzle_con_command_write", drizzle);
300
303
if ((offset + size) == total)
304
307
if (command == DRIZZLE_COMMAND_QUIT)
306
311
else if (command == DRIZZLE_COMMAND_FIELD_LIST)
308
if (drizzle_result_create(client, client_result) == NULL)
313
if ((client_result= drizzle_result_create(client)) == NULL)
309
315
DRIZZLE_RETURN_ERROR("drizzle_result_create", drizzle)
311
if (drizzle_result_create(server, server_result) == NULL)
312
DRIZZLE_RETURN_ERROR("drizzle_result_create", drizzle)
318
if ((server_result= drizzle_result_create(server)) == NULL)
320
DRIZZLE_RETURN_ERROR("drizzle_result_create", drizzle);
316
325
(void)drizzle_result_read(client, client_result, &ret);
317
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_read", drizzle)
326
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_read", drizzle);
319
328
drizzle_con_set_status(server, drizzle_con_status(client));
320
if (drizzle_result_clone(server, server_result, client_result) == NULL)
321
DRIZZLE_RETURN_ERROR("drizzle_result_clone", drizzle)
329
if ((server_result= drizzle_result_clone(server, client_result)) == NULL)
331
DRIZZLE_RETURN_ERROR("drizzle_result_clone", drizzle);
323
334
if (drizzle_result_column_count(client_result) == 0)
325
336
/* Simple result with no column, row, or field data. */
326
337
ret= drizzle_result_write(server, server_result, true);
327
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle)
338
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
332
343
ret= drizzle_result_write(server, server_result, false);
333
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle)
344
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
339
350
if (drizzle_column_read(client_result, column, &ret) == NULL)
341
DRIZZLE_RETURN_CHECK(ret, "drizzle_column_read", drizzle)
352
DRIZZLE_RETURN_CHECK(ret, "drizzle_column_read", drizzle);
345
DRIZZLE_RETURN_CHECK(ret, "drizzle_column_read", drizzle)
356
DRIZZLE_RETURN_CHECK(ret, "drizzle_column_read", drizzle);
347
358
ret= drizzle_column_write(server_result, column);
348
DRIZZLE_RETURN_CHECK(ret, "drizzle_column_write", drizzle)
359
DRIZZLE_RETURN_CHECK(ret, "drizzle_column_write", drizzle);
350
361
drizzle_column_free(column);
356
367
if (command == DRIZZLE_COMMAND_FIELD_LIST)
358
369
ret= drizzle_result_write(server, server_result, true);
359
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle)
370
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
364
375
ret= drizzle_result_write(server, server_result, false);
365
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle)
376
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);
371
382
row= drizzle_row_read(client_result, &ret);
372
DRIZZLE_RETURN_CHECK(ret, "drizzle_row_read", drizzle)
383
DRIZZLE_RETURN_CHECK(ret, "drizzle_row_read", drizzle);
398
DRIZZLE_RETURN_CHECK(ret, "drizzle_field_read", drizzle)
410
DRIZZLE_RETURN_CHECK(ret, "drizzle_field_read", drizzle);
400
413
ret= drizzle_field_write(server_result, field, size, total);
401
DRIZZLE_RETURN_CHECK(ret, "drizzle_field_write", drizzle)
414
DRIZZLE_RETURN_CHECK(ret, "drizzle_field_write", drizzle);
405
418
ret= drizzle_result_write(server, server_result, true);
406
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle)
419
DRIZZLE_RETURN_CHECK(ret, "drizzle_result_write", drizzle);