~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/unireg.cc

  • Committer: Stewart Smith
  • Date: 2009-02-09 04:15:24 UTC
  • mto: (859.1.1 nofrm)
  • mto: This revision was merged to the branch mainline in revision 864.
  • Revision ID: stewart@flamingspork.com-20090209041524-mmngaan4s2oibkxt
Read (nearly the whole) index information (key and key parts) out of the proto, not FRM.

Update the table.proto to reflect in server structures and possible values.
Biggest change is IndexPart now references fieldnr and not an embedded field.
This is because we need to set the fieldnr in server and I couldn't find a way to get this info out of protobuf.

Also add an assert in the proto writing part to make sure we handle all possible index flags.

Increasingly we abort() on old FRM file formats as I remove FRM code piece by piece.

Show diffs side-by-side

added added

removed removed

Lines of Context:
592
592
 
593
593
    idx->set_name(key_info[i].name);
594
594
 
 
595
    idx->set_key_length(key_info[i].key_length);
 
596
 
595
597
    if(is_primary_key_name(key_info[i].name))
596
598
      idx->set_is_primary(true);
597
599
    else
608
610
      break;
609
611
 
610
612
    case HA_KEY_ALG_RTREE:
 
613
      idx->set_type(drizzle::Table::Index::RTREE);
611
614
    case HA_KEY_ALG_FULLTEXT:
 
615
      idx->set_type(drizzle::Table::Index::FULLTEXT);
612
616
    case HA_KEY_ALG_UNDEF:
613
617
      idx->set_type(drizzle::Table::Index::UNKNOWN_INDEX);
614
618
      break;
623
627
    else
624
628
      idx->set_is_unique(false);
625
629
 
626
 
    /* FIXME: block_size ? */
 
630
    drizzle::Table::Index::IndexOptions *index_options= idx->mutable_options();
 
631
 
 
632
    if(key_info[i].flags & HA_USES_BLOCK_SIZE)
 
633
      index_options->set_key_block_size(key_info[i].block_size);
 
634
 
 
635
    if(key_info[i].flags & HA_PACK_KEY)
 
636
      index_options->set_pack_key(true);
 
637
 
 
638
    if(key_info[i].flags & HA_BINARY_PACK_KEY)
 
639
      index_options->set_binary_pack_key(true);
 
640
 
 
641
    if(key_info[i].flags & HA_VAR_LENGTH_PART)
 
642
      index_options->set_var_length_key(true);
 
643
 
 
644
    if(key_info[i].flags & HA_NULL_PART_KEY)
 
645
      index_options->set_null_part_key(true);
 
646
 
 
647
    if(key_info[i].flags & HA_KEY_HAS_PART_KEY_SEG)
 
648
      index_options->set_has_partial_segments(true);
 
649
 
 
650
    if(key_info[i].flags & HA_GENERATED_KEY)
 
651
      index_options->set_auto_generated_key(true);
 
652
 
 
653
    if (key_info[i].flags & HA_USES_COMMENT)
 
654
      idx->set_comment(key_info[i].comment.str);
 
655
 
 
656
    if(key_info[i].flags & ~(HA_NOSAME | HA_PACK_KEY | HA_USES_BLOCK_SIZE | HA_BINARY_PACK_KEY | HA_VAR_LENGTH_PART | HA_NULL_PART_KEY | HA_KEY_HAS_PART_KEY_SEG | HA_GENERATED_KEY | HA_USES_COMMENT))
 
657
      abort(); // Invalid (unknown) index flag.
627
658
 
628
659
    for(unsigned int j=0; j< key_info[i].key_parts; j++)
629
660
    {
630
661
      drizzle::Table::Index::IndexPart *idxpart;
631
 
      drizzle::Table::Field *field;
632
662
 
633
663
      idxpart= idx->add_index_part();
634
664
 
635
 
      field= idxpart->mutable_field();
636
 
      *field= table_proto->field(key_info[i].key_part[j].fieldnr);
 
665
      idxpart->set_fieldnr(key_info[i].key_part[j].fieldnr+1);
637
666
 
638
667
      idxpart->set_compare_length(key_info[i].key_part[j].length);
639
668
    }
640
 
 
641
 
    if (key_info[i].flags & HA_USES_COMMENT)
642
 
      idx->set_comment(key_info[i].comment.str);
643
669
  }
644
670
}
645
671