~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/unireg.cc

  • Committer: brian
  • Date: 2009-02-26 20:57:39 UTC
  • mfrom: (896.3.16 nofrm896)
  • mto: This revision was merged to the branch mainline in revision 901.
  • Revision ID: brian@bitters-20090226205739-yv4cbwna6myvkq22
Merge of Stewart + Jay's fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
 
103
103
  if (!table->ParseFromZeroCopyStream(input))
104
104
  {
 
105
    delete input;
105
106
    close(fd);
106
107
    return -1;
107
108
  }
108
109
 
 
110
  delete input;
109
111
  close(fd);
110
112
  return 0;
111
113
}
408
410
    attribute= table_proto->add_field();
409
411
    attribute->set_name(field_arg->field_name);
410
412
 
 
413
    attribute->set_pack_flag(field_arg->pack_flag); /* TODO: MUST DIE */
 
414
 
411
415
    if(f_maybe_null(field_arg->pack_flag))
412
416
    {
413
417
      drizzle::Table::Field::FieldConstraints *constraints;
483
487
          set_field_options->add_field_value(src);
484
488
        }
485
489
        set_field_options->set_count_elements(set_field_options->field_value_size());
 
490
        set_field_options->set_collation_id(field_arg->charset->number);
 
491
        set_field_options->set_collation(field_arg->charset->name);
486
492
        break;
487
493
      }
488
494
    case DRIZZLE_TYPE_BLOB:
489
 
      attribute->set_type(drizzle::Table::Field::BLOB);
 
495
      {
 
496
        attribute->set_type(drizzle::Table::Field::BLOB);
 
497
 
 
498
        drizzle::Table::Field::StringFieldOptions *string_field_options;
 
499
 
 
500
        string_field_options= attribute->mutable_string_options();
 
501
        string_field_options->set_collation_id(field_arg->charset->number);
 
502
        string_field_options->set_collation(field_arg->charset->name);
 
503
      }
 
504
 
490
505
      break;
491
506
    default:
492
 
      abort();
 
507
      assert(0); /* Tell us, since this shouldn't happend */
 
508
      return;
493
509
    }
494
510
 
495
511
    if(field_arg->vcol_info)
501
517
      field_options->set_type(attribute->type());
502
518
      attribute->set_type(drizzle::Table::Field::VIRTUAL);
503
519
 
504
 
      field_options->set_expression(field_arg->vcol_info->expr_str.str);
 
520
      string expr(field_arg->vcol_info->expr_str.str,
 
521
                  field_arg->vcol_info->expr_str.length);
 
522
 
 
523
      field_options->set_expression(expr);
505
524
      field_options->set_physically_stored(field_arg->is_stored);
506
525
    }
507
526
 
524
543
      attribute->set_format(drizzle::Table::Field::DynamicFormat);
525
544
      break;
526
545
    default:
527
 
      abort();
 
546
      assert(0); /* Tell us, since this shouldn't happend */
 
547
      return;
528
548
    }
529
549
 
530
550
    if (field_arg->comment.length)
553
573
      field_options->set_update_value("NOW()");
554
574
    }
555
575
 
 
576
    if(field_arg->def)
 
577
    {
 
578
      drizzle::Table::Field::FieldOptions *field_options;
 
579
      field_options= attribute->mutable_options();
 
580
 
 
581
      if(field_arg->def->is_null())
 
582
      {
 
583
        field_options->set_default_null(true);
 
584
      }
 
585
      else
 
586
      {
 
587
        String d;
 
588
        String *default_value= field_arg->def->val_str(&d);
 
589
 
 
590
        if((field_arg->sql_type==DRIZZLE_TYPE_VARCHAR
 
591
            && field_arg->charset==&my_charset_bin)
 
592
           || (field_arg->sql_type==DRIZZLE_TYPE_BLOB
 
593
            && field_arg->charset==&my_charset_bin))
 
594
        {
 
595
          string bin_default;
 
596
          bin_default.assign(default_value->c_ptr(),
 
597
                             default_value->length());
 
598
          field_options->set_default_bin_value(bin_default);
 
599
        }
 
600
        else
 
601
        {
 
602
          field_options->set_default_value(default_value->c_ptr());
 
603
        }
 
604
      }
 
605
    }
 
606
 
 
607
    {
 
608
      drizzle::Table::Field::FieldOptions *field_options;
 
609
      field_options= attribute->mutable_options();
 
610
 
 
611
      field_options->set_length(field_arg->length);
 
612
    }
 
613
 
556
614
    assert(field_arg->unireg_check == Field::NONE
557
615
           || field_arg->unireg_check == Field::NEXT_NUMBER
558
616
           || field_arg->unireg_check == Field::TIMESTAMP_DN_FIELD
742
800
 
743
801
      idxpart= idx->add_index_part();
744
802
 
745
 
      idxpart->set_fieldnr(key_info[i].key_part[j].fieldnr+1);
 
803
      idxpart->set_fieldnr(key_info[i].key_part[j].fieldnr);
746
804
 
747
805
      idxpart->set_compare_length(key_info[i].key_part[j].length);
 
806
 
 
807
      idxpart->set_key_type(key_info[i].key_part[j].key_type);
 
808
 
748
809
    }
749
810
  }
750
811
}
1461
1522
    /*
1462
1523
      regfield don't have to be deleted as it's allocated with sql_alloc()
1463
1524
    */
1464
 
    Field *regfield= make_field(&share,
 
1525
    Field *regfield= make_field(&share, NULL,
1465
1526
                                buff+field->offset + data_offset,
1466
1527
                                field->length,
1467
1528
                                null_pos + null_count / 8,