~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/unireg.cc

  • Committer: Brian Aker
  • Date: 2009-02-19 16:31:51 UTC
  • mfrom: (869.1.24 nofrm)
  • Revision ID: brian@tangent.org-20090219163151-vozxh7g5vgqbvd8a
Merge from Stewart

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
static bool pack_header(unsigned char *forminfo,
49
49
                        List<Create_field> &create_fields,
50
50
                        uint32_t info_length, uint32_t screens,
51
 
                        uint32_t table_options,
52
51
                        ulong data_offset, handler *file);
53
52
static uint32_t get_interval_id(uint32_t *int_count,
54
53
                                List<Create_field> &create_fields,
167
166
 
168
167
  error= pack_header(forminfo,
169
168
                     create_fields,info_length,
170
 
                     screens, create_info->table_options,
 
169
                     screens,
171
170
                     data_offset, db_file);
172
171
 
173
172
  session->pop_internal_handler();
183
182
      return(1);
184
183
    if (pack_header(forminfo,
185
184
                    create_fields,info_length,
186
 
                    screens, create_info->table_options, data_offset, db_file))
 
185
                    screens, data_offset, db_file))
187
186
    {
188
187
      free(screen_buff);
189
188
      return(1);
404
403
  while ((field_arg= it++))
405
404
  {
406
405
    drizzle::Table::Field *attribute;
407
 
    //drizzle::Table::Field::FieldConstraints *constraints;
408
406
 
409
407
    attribute= table_proto->add_field();
410
408
    attribute->set_name(field_arg->field_name);
411
409
 
 
410
    if(f_maybe_null(field_arg->pack_flag))
 
411
    {
 
412
      drizzle::Table::Field::FieldConstraints *constraints;
 
413
 
 
414
      constraints= attribute->mutable_constraints();
 
415
      constraints->set_is_nullable(true);
 
416
    }
 
417
 
412
418
    switch (field_arg->sql_type) {
413
419
    case DRIZZLE_TYPE_TINY:
414
420
      attribute->set_type(drizzle::Table::Field::TINYINT);
442
448
 
443
449
        string_field_options= attribute->mutable_string_options();
444
450
        attribute->set_type(drizzle::Table::Field::VARCHAR);
445
 
        string_field_options->set_length(field_arg->char_length);
 
451
        string_field_options->set_length(field_arg->length
 
452
                                         / field_arg->charset->mbmaxlen);
446
453
        string_field_options->set_collation_id(field_arg->charset->number);
447
454
        string_field_options->set_collation(field_arg->charset->name);
448
455
 
551
558
           || field_arg->unireg_check == Field::TIMESTAMP_UN_FIELD
552
559
           || field_arg->unireg_check == Field::TIMESTAMP_DNUN_FIELD);
553
560
 
554
 
    /* Fuck me. seriously, wtf */
555
 
    ulong data_offset= (create_info->null_bits + 7)/8;
556
 
    attribute->set_recpos(field_arg->offset+1 + (uint)data_offset);
557
 
 
558
 
    /* Because:
559
 
       - flag should never mean flag
560
 
       - unireg_check/unireg_type should exist
561
 
       - and field length should be specified for fixed sized types.
562
 
 
563
 
       NOT.
564
 
 
565
 
       These should all die a horrible death. A freeze-ray is too good for them.
566
 
       A death-ray is way better.
567
 
    */
568
 
    attribute->set_pack_flag(field_arg->pack_flag);
569
 
    attribute->set_field_length(field_arg->length);
570
 
    attribute->set_interval_nr(field_arg->interval_id);
571
561
  }
572
562
 
573
563
  if (create_info->used_fields & HA_CREATE_USED_PACK_KEYS)
631
621
    abort();
632
622
  }
633
623
 
 
624
  table_options->set_pack_record(create_info->table_options
 
625
                                 & HA_OPTION_PACK_RECORD);
 
626
 
634
627
  if (create_info->comment.length)
635
628
    table_options->set_comment(create_info->comment.str);
636
629
 
1043
1036
 
1044
1037
static bool pack_header(unsigned char *forminfo,
1045
1038
                        List<Create_field> &create_fields,
1046
 
                        uint32_t info_length, uint32_t screens, uint32_t table_options,
 
1039
                        uint32_t info_length, uint32_t screens,
1047
1040
                        ulong data_offset, handler *file)
1048
1041
{
1049
1042
  uint32_t length,int_count,int_length, int_parts;
1178
1171
    my_error(ER_TOO_BIG_ROWSIZE, MYF(0), (uint) file->max_record_length());
1179
1172
    return(1);
1180
1173
  }
1181
 
  /* Hack to avoid bugs with small static rows in MySQL */
1182
 
  reclength=cmax((ulong)file->min_record_length(table_options),reclength);
 
1174
 
1183
1175
  if (info_length+(ulong) create_fields.elements*FCOMP+288+
1184
1176
      n_length+int_length+com_length+vcol_info_length > 65535L ||
1185
1177
      int_count > 255)