~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Brian Aker
  • Date: 2011-01-08 10:35:13 UTC
  • mfrom: (2057.2.9 timestamp)
  • Revision ID: brian@tangent.org-20110108103513-3wuo8tsyajjcxjrg
Merge in fractional seconds to timestamp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
472
472
    sql_field->length= 8; // Unireg field length
473
473
    (*blob_columns)++;
474
474
    break;
475
 
  case DRIZZLE_TYPE_VARCHAR:
476
 
    break;
 
475
 
477
476
  case DRIZZLE_TYPE_ENUM:
478
 
    if (check_duplicates_in_interval("ENUM",
479
 
                                     sql_field->field_name,
480
 
                                     sql_field->interval,
481
 
                                     sql_field->charset,
482
 
                                     &dup_val_count))
483
 
      return 1;
484
 
    break;
485
 
  case DRIZZLE_TYPE_DATE:  // Rest of string types
486
 
  case DRIZZLE_TYPE_TIME:
487
 
  case DRIZZLE_TYPE_DATETIME:
488
 
  case DRIZZLE_TYPE_NULL:
489
 
    break;
490
 
  case DRIZZLE_TYPE_DECIMAL:
491
 
    break;
 
477
    {
 
478
      if (check_duplicates_in_interval("ENUM",
 
479
                                       sql_field->field_name,
 
480
                                       sql_field->interval,
 
481
                                       sql_field->charset,
 
482
                                       &dup_val_count))
 
483
      {
 
484
        return 1;
 
485
      }
 
486
    }
 
487
    break;
 
488
 
 
489
  case DRIZZLE_TYPE_MICROTIME:
492
490
  case DRIZZLE_TYPE_TIMESTAMP:
493
491
    /* We should replace old TIMESTAMP fields with their newer analogs */
494
492
    if (sql_field->unireg_check == Field::TIMESTAMP_OLD_FIELD)
504
502
      }
505
503
    }
506
504
    else if (sql_field->unireg_check != Field::NONE)
 
505
    {
507
506
      (*timestamps_with_niladic)++;
 
507
    }
508
508
 
509
509
    (*timestamps)++;
510
 
    /* fall-through */
511
 
  default:
 
510
 
 
511
    break;
 
512
 
 
513
  case DRIZZLE_TYPE_BOOLEAN:
 
514
  case DRIZZLE_TYPE_DATE:  // Rest of string types
 
515
  case DRIZZLE_TYPE_DATETIME:
 
516
  case DRIZZLE_TYPE_DECIMAL:
 
517
  case DRIZZLE_TYPE_DOUBLE:
 
518
  case DRIZZLE_TYPE_LONG:
 
519
  case DRIZZLE_TYPE_LONGLONG:
 
520
  case DRIZZLE_TYPE_NULL:
 
521
  case DRIZZLE_TYPE_TIME:
 
522
  case DRIZZLE_TYPE_UUID:
 
523
  case DRIZZLE_TYPE_VARCHAR:
512
524
    break;
513
525
  }
514
526
 
532
544
  KeyInfo               *key_info;
533
545
  KeyPartInfo *key_part_info;
534
546
  int           timestamps= 0, timestamps_with_niladic= 0;
535
 
  int           field_no,dup_no;
 
547
  int           dup_no;
536
548
  int           select_field_pos,auto_increment=0;
537
549
  List_iterator<CreateField> it(alter_info->create_list);
538
550
  List_iterator<CreateField> it2(alter_info->create_list);
544
556
  null_fields=blob_columns=0;
545
557
  max_key_length= engine->max_key_length();
546
558
 
547
 
  for (field_no=0; (sql_field=it++) ; field_no++)
 
559
  for (int32_t field_no=0; (sql_field=it++) ; field_no++)
548
560
  {
549
561
    const CHARSET_INFO *save_cs;
550
562
 
554
566
      executing a prepared statement for the second time.
555
567
    */
556
568
    sql_field->length= sql_field->char_length;
 
569
 
557
570
    if (!sql_field->charset)
558
571
      sql_field->charset= create_info->default_table_charset;
 
572
 
559
573
    /*
560
574
      table_charset is set in ALTER Table if we want change character set
561
575
      for all varchar/char columns.
753
767
    if (not create_proto.engine().name().compare("MyISAM") &&
754
768
        ((sql_field->flags & BLOB_FLAG) ||
755
769
         (sql_field->sql_type == DRIZZLE_TYPE_VARCHAR)))
 
770
    {
756
771
      (*db_options)|= HA_OPTION_PACK_RECORD;
 
772
    }
 
773
 
757
774
    it2.rewind();
758
775
  }
759
776
 
977
994
             my_strcasecmp(system_charset_info,
978
995
                           column->field_name.str,
979
996
                           sql_field->field_name))
 
997
      {
980
998
        field++;
 
999
      }
 
1000
 
981
1001
      if (!sql_field)
982
1002
      {
983
1003
        my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str);
984
1004
        return(true);
985
1005
      }
 
1006
 
986
1007
      while ((dup_column= cols2++) != column)
987
1008
      {
988
1009
        if (!my_strcasecmp(system_charset_info,
1015
1036
            return true;
1016
1037
          }
1017
1038
        }
 
1039
 
1018
1040
        if (! (sql_field->flags & NOT_NULL_FLAG))
1019
1041
        {
1020
1042
          if (key->type == Key::PRIMARY)
1041
1063
            }
1042
1064
          }
1043
1065
        }
 
1066
 
1044
1067
        if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
1045
1068
        {
1046
1069
          if (column_nr == 0 || (engine->check_flag(HTON_BIT_AUTO_PART_KEY)))
1165
1188
        key_info->name=(char*) key_name;
1166
1189
      }
1167
1190
    }
 
1191
 
1168
1192
    if (!key_info->name || check_column_name(key_info->name))
1169
1193
    {
1170
1194
      my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key_info->name);
1171
1195
      return(true);
1172
1196
    }
 
1197
 
1173
1198
    if (!(key_info->flags & HA_NULL_PART_KEY))
 
1199
    {
1174
1200
      unique_key=1;
 
1201
    }
 
1202
 
1175
1203
    key_info->key_length=(uint16_t) key_length;
 
1204
 
1176
1205
    if (key_length > max_key_length)
1177
1206
    {
1178
1207
      my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length);
1179
1208
      return(true);
1180
1209
    }
 
1210
 
1181
1211
    key_info++;
1182
1212
  }
 
1213
 
1183
1214
  if (!unique_key && !primary_key &&
1184
1215
      (engine->check_flag(HTON_BIT_REQUIRE_PRIMARY_KEY)))
1185
1216
  {
1186
1217
    my_message(ER_REQUIRES_PRIMARY_KEY, ER(ER_REQUIRES_PRIMARY_KEY), MYF(0));
1187
1218
    return(true);
1188
1219
  }
 
1220
 
1189
1221
  if (auto_increment > 0)
1190
1222
  {
1191
1223
    my_message(ER_WRONG_AUTO_KEY, ER(ER_WRONG_AUTO_KEY), MYF(0));