~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-1.0/column.cc

Fix merge issues with 1.0 CC fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
356
356
{
357
357
  if (column == NULL)
358
358
  {
359
 
    column= malloc(sizeof(drizzle_column_st));
 
359
    column= new (std::nothrow) (drizzle_column_st);
360
360
    if (column == NULL)
361
361
    {
362
362
      drizzle_set_error(result->con->drizzle, "drizzle_column_create",
377
377
    column->charset = 0;
378
378
    column->size = 0;
379
379
    column->max_size = 0;
380
 
    column->type = 0;
381
 
    column->flags = 0;
 
380
    column->type = drizzle_column_type_t();
 
381
    column->flags = drizzle_column_flags_t();
382
382
    column->decimals = 0;
383
383
    /* UNSET: column->default_value */
384
384
    column->default_value_size = 0;
389
389
    column->result = result;
390
390
    /* SET BELOW: column->next */
391
391
    column->prev = NULL;
392
 
    column->options= 0;
 
392
    column->options= drizzle_column_options_t();
393
393
    column->catalog[0] = '\0';
394
394
    column->db[0] = '\0';
395
395
    column->table[0] = '\0';
399
399
    column->charset = 0;
400
400
    column->size = 0;
401
401
    column->max_size = 0;
402
 
    column->type = 0;
403
 
    column->flags = 0;
 
402
    column->type = drizzle_column_type_t();
 
403
    column->flags = drizzle_column_flags_t();
404
404
    column->decimals = 0;
405
405
    /* UNSET: column->default_value */
406
406
    column->default_value_size = 0;
426
426
    column->next->prev= column->prev;
427
427
 
428
428
  if (column->options & DRIZZLE_COLUMN_ALLOCATED)
429
 
    free(column);
 
429
  {
 
430
    delete [] column;
 
431
  }
430
432
}
431
433
 
432
434
drizzle_result_st *drizzle_column_drizzle_result(drizzle_column_st *column)
497
499
 
498
500
drizzle_column_flags_t drizzle_column_flags(drizzle_column_st *column)
499
501
{
500
 
  return column->flags;
 
502
  return drizzle_column_flags_t(column->flags);
501
503
}
502
504
 
503
505
uint8_t drizzle_column_decimals(drizzle_column_st *column)
521
523
  drizzle_return_t ret;
522
524
  if (drizzle_state_none(result->con))
523
525
  {
524
 
    result->options|= DRIZZLE_RESULT_SKIP_COLUMN;
 
526
    result->options|= int(DRIZZLE_RESULT_SKIP_COLUMN);
525
527
 
526
528
    drizzle_state_push(result->con, drizzle_state_column_read);
527
529
    drizzle_state_push(result->con, drizzle_state_packet_read);
528
530
  }
529
531
  ret= drizzle_state_loop(result->con);
530
 
  result->options&= ~DRIZZLE_RESULT_SKIP_COLUMN;
 
532
  result->options&= ~int(DRIZZLE_RESULT_SKIP_COLUMN);
531
533
  return ret;
532
534
}
533
535
 
570
572
  {
571
573
    if (result->column_count == 0)
572
574
    {
573
 
      result->options|= DRIZZLE_RESULT_BUFFER_COLUMN;
 
575
      result->options|= int(DRIZZLE_RESULT_BUFFER_COLUMN);
574
576
      return DRIZZLE_RETURN_OK;
575
577
    }
576
578
 
577
 
    result->column_buffer= malloc(sizeof(drizzle_column_st) *
578
 
                                  result->column_count);
 
579
    result->column_buffer= new (std::nothrow) drizzle_column_st[result->column_count];
579
580
    if (result->column_buffer == NULL)
580
581
    {
581
 
      drizzle_set_error(result->con->drizzle, "drizzle_column_buffer",
582
 
                        "malloc");
 
582
      drizzle_set_error(result->con->drizzle, __func__, "malloc");
 
583
 
583
584
      return DRIZZLE_RETURN_MEMORY;
584
585
    }
585
586
  }
795
796
    /* EOF packet marking end of columns. */
796
797
    con->result->column= NULL;
797
798
    con->result->warning_count= drizzle_get_byte2(con->buffer_ptr + 1);
798
 
    con->status= drizzle_get_byte2(con->buffer_ptr + 3);
 
799
    con->status= drizzle_con_status_t(drizzle_get_byte2(con->buffer_ptr + 3));
799
800
    con->buffer_ptr+= 5;
800
801
    con->buffer_size-= 5;
801
802
 
835
836
    column->size= drizzle_get_byte4(con->buffer_ptr + 3);
836
837
 
837
838
    if (con->options & DRIZZLE_CON_MYSQL)
838
 
      column->type= con->buffer_ptr[7];
 
839
    {
 
840
      column->type= drizzle_column_type_t(con->buffer_ptr[7]);
 
841
    }
839
842
    else
840
843
    {
841
 
      drizzle_type= con->buffer_ptr[7];
 
844
      drizzle_type= drizzle_column_type_drizzle_t(con->buffer_ptr[7]);
842
845
      if (drizzle_type >= DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX)
843
846
        drizzle_type= DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX;
844
847
      column->type= _column_type_drizzle_map_to[drizzle_type];
845
848
    }
846
849
 
847
 
    column->flags= drizzle_get_byte2(con->buffer_ptr + 8);
 
850
    column->flags= drizzle_column_flags_t(drizzle_get_byte2(con->buffer_ptr + 8));
848
851
    if (column->type <= DRIZZLE_COLUMN_TYPE_INT24 &&
849
852
        column->type != DRIZZLE_COLUMN_TYPE_TIMESTAMP)
850
853
    {
851
 
      column->flags|= DRIZZLE_COLUMN_FLAGS_NUM;
 
854
      column->flags|= int(DRIZZLE_COLUMN_FLAGS_NUM);
852
855
    }
853
856
 
854
857
    column->decimals= con->buffer_ptr[10];