354
354
drizzle_column_st *drizzle_column_create(drizzle_result_st *result,
355
355
drizzle_column_st *column)
362
357
if (column == NULL)
364
column= new (std::nothrow) drizzle_column_st;
371
column->result= result;
359
column= new drizzle_column_st;
360
column->result = result;
372
361
/* SET BELOW: column->next */
374
column->options.is_allocated= true;
375
column->catalog[0]= '\0';
376
column->schema[0]= '\0';
377
column->table[0]= '\0';
378
column->orig_table[0]= '\0';
379
column->name[0]= '\0';
380
column->orig_name[0]= '\0';
384
column->type= static_cast<drizzle_column_type_t>(0);
385
column->flags= drizzle_column_flags_t();
363
column->options= DRIZZLE_COLUMN_ALLOCATED;
364
column->catalog[0] = '\0';
365
column->db[0] = '\0';
366
column->table[0] = '\0';
367
column->orig_table[0] = '\0';
368
column->name[0] = '\0';
369
column->orig_name[0] = '\0';
372
column->max_size = 0;
373
column->type = static_cast<drizzle_column_type_t>(0);
374
column->flags = drizzle_column_flags_t();
375
column->decimals = 0;
387
376
/* UNSET: column->default_value */
388
column->default_value_size= 0;
377
column->default_value_size = 0;
392
382
column->result = result;
393
383
/* SET BELOW: column->next */
394
384
column->prev = NULL;
395
column->options.is_allocated= false;
385
column->options= drizzle_column_options_t();
396
386
column->catalog[0] = '\0';
397
column->schema[0] = '\0';
387
column->db[0] = '\0';
398
388
column->table[0] = '\0';
399
389
column->orig_table[0] = '\0';
400
390
column->name[0] = '\0';
422
412
void drizzle_column_free(drizzle_column_st *column)
429
414
if (column->result->column_list == column)
431
415
column->result->column_list= column->next;
434
416
if (column->prev)
436
417
column->prev->next= column->next;
439
418
if (column->next)
441
419
column->next->prev= column->prev;
444
if (column->options.is_allocated)
421
if (column->options & DRIZZLE_COLUMN_ALLOCATED)
450
425
drizzle_result_st *drizzle_column_drizzle_result(drizzle_column_st *column)
457
427
return column->result;
460
430
const char *drizzle_column_catalog(drizzle_column_st *column)
467
432
return column->catalog;
470
const char *drizzle_column_shema(drizzle_column_st *column)
477
return column->schema;
480
435
const char *drizzle_column_db(drizzle_column_st *column)
482
return drizzle_column_shema(column);
485
440
const char *drizzle_column_table(drizzle_column_st *column)
492
442
return column->table;
495
445
const char *drizzle_column_orig_table(drizzle_column_st *column)
502
447
return column->orig_table;
505
450
const char *drizzle_column_name(drizzle_column_st *column)
512
452
return column->name;
515
455
const char *drizzle_column_orig_name(drizzle_column_st *column)
522
457
return column->orig_name;
525
460
drizzle_charset_t drizzle_column_charset(drizzle_column_st *column)
532
462
return column->charset;
535
465
uint32_t drizzle_column_size(drizzle_column_st *column)
542
467
return column->size;
545
470
size_t drizzle_column_max_size(drizzle_column_st *column)
552
472
return column->max_size;
555
475
void drizzle_column_set_max_size(drizzle_column_st *column, size_t size)
562
477
column->max_size= size;
565
480
drizzle_column_type_t drizzle_column_type(drizzle_column_st *column)
569
return drizzle_column_type_t();
572
482
return column->type;
575
drizzle_column_type_drizzle_t drizzle_column_type_drizzle(drizzle_column_st *column)
485
drizzle_column_type_drizzle_t
486
drizzle_column_type_drizzle(drizzle_column_st *column)
579
return drizzle_column_type_drizzle_t();
582
488
return _column_type_drizzle_map_from[column->type];
585
491
int drizzle_column_flags(drizzle_column_st *column)
592
493
return column->flags;
595
496
uint8_t drizzle_column_decimals(drizzle_column_st *column)
602
498
return column->decimals;
627
519
drizzle_state_push(result->con, drizzle_state_column_read);
628
520
drizzle_state_push(result->con, drizzle_state_packet_read);
630
drizzle_return_t ret= drizzle_state_loop(result->con);
522
ret= drizzle_state_loop(result->con);
631
523
result->options&= ~DRIZZLE_RESULT_SKIP_COLUMN;
635
527
drizzle_return_t drizzle_column_skip_all(drizzle_result_st *result)
639
return DRIZZLE_RETURN_INVALID_ARGUMENT;
529
drizzle_return_t ret;
642
for (uint16_t it= 1; it <= result->column_count; it++)
532
for (it= 1; it <= result->column_count; it++)
644
drizzle_return_t ret= drizzle_column_skip(result);
534
ret= drizzle_column_skip(result);
645
535
if (ret != DRIZZLE_RETURN_OK)
651
539
return DRIZZLE_RETURN_OK;
689
567
return DRIZZLE_RETURN_OK;
692
result->column_buffer= new (std::nothrow) drizzle_column_st[result->column_count];
694
if (result->column_buffer == NULL)
696
return DRIZZLE_RETURN_MEMORY;
570
result->column_buffer= new drizzle_column_st[result->column_count];
700
573
/* No while body, just keep calling to buffer columns. */
715
588
drizzle_column_st *drizzle_column_next(drizzle_result_st *result)
722
590
if (result->column_current == result->column_count)
727
593
result->column_current++;
728
594
return &(result->column_buffer[result->column_current - 1]);
740
606
void drizzle_column_seek(drizzle_result_st *result, uint16_t column)
747
608
if (column <= result->column_count)
749
609
result->column_current= column;
753
drizzle_column_st *drizzle_column_index(drizzle_result_st *result, uint16_t column)
612
drizzle_column_st *drizzle_column_index(drizzle_result_st *result,
760
615
if (column >= result->column_count)
765
618
return &(result->column_buffer[column]);
768
621
uint16_t drizzle_column_current(drizzle_result_st *result)
775
623
return result->column_current;
782
630
drizzle_return_t drizzle_column_write(drizzle_result_st *result,
783
631
drizzle_column_st *column)
787
return DRIZZLE_RETURN_INVALID_ARGUMENT;
790
633
if (drizzle_state_none(result->con))
792
635
result->column= column;
818
void drizzle_column_set_schema(drizzle_column_st *column, const char *schema)
654
void drizzle_column_set_db(drizzle_column_st *column, const char *db)
827
column->schema[0]= 0;
831
strncpy(column->schema, schema, DRIZZLE_MAX_DB_SIZE);
832
column->schema[DRIZZLE_MAX_DB_SIZE - 1]= 0;
660
strncpy(column->db, db, DRIZZLE_MAX_DB_SIZE);
661
column->db[DRIZZLE_MAX_DB_SIZE - 1]= 0;
836
void drizzle_column_set_db(drizzle_column_st *column, const char *schema)
838
drizzle_column_set_schema(column, schema);
842
665
void drizzle_column_set_table(drizzle_column_st *column, const char *table)
849
667
if (table == NULL)
851
668
column->table[0]= 0;
855
671
strncpy(column->table, table, DRIZZLE_MAX_TABLE_SIZE);
910
711
void drizzle_column_set_charset(drizzle_column_st *column,
911
712
drizzle_charset_t charset)
918
714
column->charset= charset;
921
717
void drizzle_column_set_size(drizzle_column_st *column, uint32_t size)
928
719
column->size= size;
931
722
void drizzle_column_set_type(drizzle_column_st *column,
932
723
drizzle_column_type_t type)
939
725
column->type= type;
942
728
void drizzle_column_set_flags(drizzle_column_st *column,
950
731
column->flags= flags;
953
734
void drizzle_column_set_decimals(drizzle_column_st *column, uint8_t decimals)
960
736
column->decimals= decimals;
964
740
const uint8_t *default_value,
972
743
if (default_value == NULL)
974
744
column->default_value[0]= 0;
978
747
if (size < DRIZZLE_MAX_DEFAULT_VALUE_SIZE)
1045
809
/* These functions can only fail if they need to read data, but we know we
1046
810
buffered the entire packet, so ignore returns. */
1047
811
(void)drizzle_unpack_string(con, column->catalog, DRIZZLE_MAX_CATALOG_SIZE);
1048
(void)drizzle_unpack_string(con, column->schema, DRIZZLE_MAX_DB_SIZE);
812
(void)drizzle_unpack_string(con, column->db, DRIZZLE_MAX_DB_SIZE);
1049
813
(void)drizzle_unpack_string(con, column->table, DRIZZLE_MAX_TABLE_SIZE);
1050
814
(void)drizzle_unpack_string(con, column->orig_table,
1051
815
DRIZZLE_MAX_TABLE_SIZE);
1104
868
drizzle_return_t drizzle_state_column_write(drizzle_con_st *con)
1108
return DRIZZLE_RETURN_INVALID_ARGUMENT;
1111
870
uint8_t *start= con->buffer_ptr + con->buffer_size;
1113
872
drizzle_column_st *column= con->result->column;
1117
876
/* Calculate max packet size. */
1118
877
con->packet_size= 9 + strlen(column->catalog)
1119
+ 9 + strlen(column->schema)
878
+ 9 + strlen(column->db)
1120
879
+ 9 + strlen(column->table)
1121
880
+ 9 + strlen(column->orig_table)
1122
881
+ 9 + strlen(column->name)
1155
914
ptr= drizzle_pack_string(column->catalog, ptr);
1156
ptr= drizzle_pack_string(column->schema, ptr);
915
ptr= drizzle_pack_string(column->db, ptr);
1157
916
ptr= drizzle_pack_string(column->table, ptr);
1158
917
ptr= drizzle_pack_string(column->orig_table, ptr);
1159
918
ptr= drizzle_pack_string(column->name, ptr);