~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Monty Taylor
  • Date: 2009-01-28 04:37:46 UTC
  • mto: (779.7.3 devel)
  • mto: This revision was merged to the branch mainline in revision 816.
  • Revision ID: mordred@inaugust.com-20090128043746-d2yukekishwn3ftm
TurnedĀ onĀ -Wshadow.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2686
2686
    sql_type.length(0);
2687
2687
    if (i < s->fields)
2688
2688
    {
2689
 
      Field *field= this->field[i];
 
2689
      Field *cur_field= this->field[i];
2690
2690
 
2691
 
      if (strncmp(field->field_name, table_def->name.str,
 
2691
      if (strncmp(cur_field->field_name, table_def->name.str,
2692
2692
                  table_def->name.length))
2693
2693
      {
2694
2694
        /*
2699
2699
        errmsg_printf(ERRMSG_LVL_ERROR, _("Incorrect definition of table %s.%s: "
2700
2700
                        "expected column '%s' at position %d, found '%s'."),
2701
2701
                        s->db.str, alias, table_def->name.str, i,
2702
 
                        field->field_name);
 
2702
                        cur_field->field_name);
2703
2703
      }
2704
 
      field->sql_type(sql_type);
 
2704
      cur_field->sql_type(sql_type);
2705
2705
      /*
2706
2706
        Generally, if column types don't match, then something is
2707
2707
        wrong.
2722
2722
      if (strncmp(sql_type.c_ptr_safe(), table_def->type.str,
2723
2723
                  table_def->type.length - 1))
2724
2724
      {
2725
 
        errmsg_printf(ERRMSG_LVL_ERROR, _("Incorrect definition of table %s.%s: "
 
2725
        errmsg_printf(ERRMSG_LVL_ERROR,
 
2726
                      _("Incorrect definition of table %s.%s: "
2726
2727
                        "expected column '%s' at position %d to have type "
2727
 
                        "%s, found type %s."), s->db.str, alias,
2728
 
                        table_def->name.str, i, table_def->type.str,
2729
 
                        sql_type.c_ptr_safe());
 
2728
                        "%s, found type %s."),
 
2729
                      s->db.str, alias,
 
2730
                      table_def->name.str, i, table_def->type.str,
 
2731
                      sql_type.c_ptr_safe());
2730
2732
        error= true;
2731
2733
      }
2732
 
      else if (table_def->cset.str && !field->has_charset())
 
2734
      else if (table_def->cset.str && !cur_field->has_charset())
2733
2735
      {
2734
 
        errmsg_printf(ERRMSG_LVL_ERROR, _("Incorrect definition of table %s.%s: "
 
2736
        errmsg_printf(ERRMSG_LVL_ERROR,
 
2737
                      _("Incorrect definition of table %s.%s: "
2735
2738
                        "expected the type of column '%s' at position %d "
2736
2739
                        "to have character set '%s' but the type has no "
2737
 
                        "character set."), s->db.str, alias,
2738
 
                        table_def->name.str, i, table_def->cset.str);
 
2740
                        "character set."),
 
2741
                      s->db.str, alias,
 
2742
                      table_def->name.str, i, table_def->cset.str);
2739
2743
        error= true;
2740
2744
      }
2741
2745
      else if (table_def->cset.str &&
2742
 
               strcmp(field->charset()->csname, table_def->cset.str))
 
2746
               strcmp(cur_field->charset()->csname, table_def->cset.str))
2743
2747
      {
2744
 
        errmsg_printf(ERRMSG_LVL_ERROR, _("Incorrect definition of table %s.%s: "
 
2748
        errmsg_printf(ERRMSG_LVL_ERROR,
 
2749
                      _("Incorrect definition of table %s.%s: "
2745
2750
                        "expected the type of column '%s' at position %d "
2746
2751
                        "to have character set '%s' but found "
2747
 
                        "character set '%s'."), s->db.str, alias,
2748
 
                        table_def->name.str, i, table_def->cset.str,
2749
 
                        field->charset()->csname);
 
2752
                        "character set '%s'."),
 
2753
                      s->db.str, alias,
 
2754
                      table_def->name.str, i, table_def->cset.str,
 
2755
                      cur_field->charset()->csname);
2750
2756
        error= true;
2751
2757
      }
2752
2758
    }
2753
2759
    else
2754
2760
    {
2755
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Incorrect definition of table %s.%s: "
 
2761
      errmsg_printf(ERRMSG_LVL_ERROR,
 
2762
                    _("Incorrect definition of table %s.%s: "
2756
2763
                      "expected column '%s' at position %d to have type %s "
2757
2764
                      " but the column is not found."),
2758
 
                      s->db.str, alias,
2759
 
                      table_def->name.str, i, table_def->type.str);
 
2765
                    s->db.str, alias,
 
2766
                    table_def->name.str, i, table_def->type.str);
2760
2767
      error= true;
2761
2768
    }
2762
2769
  }
4573
4580
    }
4574
4581
    for (uint32_t i=0; i < keyinfo->key_parts ; i++,seg++)
4575
4582
    {
4576
 
      Field *field=keyinfo->key_part[i].field;
 
4583
      Field *key_field=keyinfo->key_part[i].field;
4577
4584
      seg->flag=     0;
4578
 
      seg->language= field->charset()->number;
 
4585
      seg->language= key_field->charset()->number;
4579
4586
      seg->length=   keyinfo->key_part[i].length;
4580
4587
      seg->start=    keyinfo->key_part[i].offset;
4581
 
      if (field->flags & BLOB_FLAG)
 
4588
      if (key_field->flags & BLOB_FLAG)
4582
4589
      {
4583
4590
        seg->type=
4584
4591
        ((keyinfo->key_part[i].key_type & FIELDFLAG_BINARY) ?
4585
4592
         HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2);
4586
 
        seg->bit_start= (uint8_t)(field->pack_length() - share->blob_ptr_size);
 
4593
        seg->bit_start= (uint8_t)(key_field->pack_length()
 
4594
                                  - share->blob_ptr_size);
4587
4595
        seg->flag= HA_BLOB_PART;
4588
4596
        seg->length=0;                  // Whole blob in unique constraint
4589
4597
      }
4591
4599
      {
4592
4600
        seg->type= keyinfo->key_part[i].type;
4593
4601
      }
4594
 
      if (!(field->flags & NOT_NULL_FLAG))
 
4602
      if (!(key_field->flags & NOT_NULL_FLAG))
4595
4603
      {
4596
 
        seg->null_bit= field->null_bit;
4597
 
        seg->null_pos= (uint) (field->null_ptr - (unsigned char*) record[0]);
 
4604
        seg->null_bit= key_field->null_bit;
 
4605
        seg->null_pos= (uint) (key_field->null_ptr - (unsigned char*) record[0]);
4598
4606
        /*
4599
4607
          We are using a GROUP BY on something that contains NULL
4600
4608
          In this case we have to tell MyISAM that two NULL should