~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Brian Aker
  • Date: 2009-12-01 02:39:03 UTC
  • mfrom: (1234.1.4 push)
  • Revision ID: brian@gaz-20091201023903-1id5z7xnup695jaq
Merge of Brian + Jay test fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
695
695
    sql_field     field to prepare for packing
696
696
    blob_columns  count for BLOBs
697
697
    timestamps    count for timestamps
698
 
    table_flags   table flags
699
698
 
700
699
  DESCRIPTION
701
700
    This function prepares a CreateField instance.
707
706
*/
708
707
int prepare_create_field(CreateField *sql_field,
709
708
                         uint32_t *blob_columns,
710
 
                         int *timestamps, int *timestamps_with_niladic,
711
 
                         int64_t )
 
709
                         int *timestamps,
 
710
                         int *timestamps_with_niladic)
712
711
{
713
712
  unsigned int dup_val_count;
714
713
 
795
794
 
796
795
  select_field_pos= alter_info->create_list.elements - select_field_count;
797
796
  null_fields=blob_columns=0;
798
 
  max_key_length= cursor->max_key_length();
 
797
  max_key_length= cursor->getEngine()->max_key_length();
799
798
 
800
799
  for (field_no=0; (sql_field=it++) ; field_no++)
801
800
  {
1018
1017
    assert(sql_field->charset != 0);
1019
1018
 
1020
1019
    if (prepare_create_field(sql_field, &blob_columns,
1021
 
                             &timestamps, &timestamps_with_niladic,
1022
 
                             cursor->ha_table_flags()))
 
1020
                             &timestamps, &timestamps_with_niladic))
1023
1021
      return(true);
1024
1022
    sql_field->offset= record_offset;
1025
1023
    if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
1037
1035
    return(true);
1038
1036
  }
1039
1037
  if (auto_increment &&
1040
 
      (cursor->ha_table_flags() & HA_NO_AUTO_INCREMENT))
 
1038
      (cursor->getEngine()->check_flag(HTON_BIT_NO_AUTO_INCREMENT)))
1041
1039
  {
1042
1040
    my_message(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT,
1043
1041
               ER(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT), MYF(0));
1044
1042
    return(true);
1045
1043
  }
1046
1044
 
1047
 
  if (blob_columns && (cursor->ha_table_flags() & HA_NO_BLOBS))
 
1045
  if (blob_columns && (cursor->getEngine()->check_flag(HTON_BIT_NO_BLOBS)))
1048
1046
  {
1049
1047
    my_message(ER_TABLE_CANT_HANDLE_BLOB, ER(ER_TABLE_CANT_HANDLE_BLOB),
1050
1048
               MYF(0));
1085
1083
      continue;
1086
1084
    }
1087
1085
    (*key_count)++;
1088
 
    tmp=cursor->max_key_parts();
 
1086
    tmp=cursor->getEngine()->max_key_parts();
1089
1087
    if (key->columns.elements > tmp)
1090
1088
    {
1091
1089
      my_error(ER_TOO_MANY_KEY_PARTS,MYF(0),tmp);
1134
1132
      return(true);
1135
1133
    }
1136
1134
  }
1137
 
  tmp=cursor->max_keys();
 
1135
  tmp=cursor->getEngine()->max_keys();
1138
1136
  if (*key_count > tmp)
1139
1137
  {
1140
1138
    my_error(ER_TOO_MANY_KEYS,MYF(0),tmp);
1239
1237
      while ((dup_column= cols2++) != column)
1240
1238
      {
1241
1239
        if (!my_strcasecmp(system_charset_info,
1242
 
                           column->field_name.str, dup_column->field_name.str))
 
1240
                           column->field_name.str, dup_column->field_name.str))
1243
1241
        {
1244
1242
          my_printf_error(ER_DUP_FIELDNAME,
1245
1243
                          ER(ER_DUP_FIELDNAME),MYF(0),
1257
1255
 
1258
1256
        if (sql_field->sql_type == DRIZZLE_TYPE_BLOB)
1259
1257
        {
1260
 
          if (! (cursor->ha_table_flags() & HA_CAN_INDEX_BLOBS))
 
1258
          if (! (cursor->getEngine()->check_flag(HTON_BIT_CAN_INDEX_BLOBS)))
1261
1259
          {
1262
1260
            my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name.str);
1263
1261
            return true;
1287
1285
          else
1288
1286
          {
1289
1287
            key_info->flags|= HA_NULL_PART_KEY;
1290
 
            if (! (cursor->ha_table_flags() & HA_NULL_IN_KEY))
 
1288
            if (! (cursor->getEngine()->check_flag(HTON_BIT_NULL_IN_KEY)))
1291
1289
            {
1292
1290
              my_error(ER_NULL_COLUMN_IN_INDEX, MYF(0), column->field_name.str);
1293
1291
              return true;
1296
1294
        }
1297
1295
        if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
1298
1296
        {
1299
 
          if (column_nr == 0 || (cursor->ha_table_flags() & HA_AUTO_PART_KEY))
 
1297
          if (column_nr == 0 || (cursor->getEngine()->check_flag(HTON_BIT_AUTO_PART_KEY)))
1300
1298
            auto_increment--;                   // Field is used
1301
1299
        }
1302
1300
      }
1311
1309
        if (sql_field->sql_type == DRIZZLE_TYPE_BLOB)
1312
1310
        {
1313
1311
          if ((length=column->length) > max_key_length ||
1314
 
              length > cursor->max_key_part_length())
 
1312
              length > cursor->getEngine()->max_key_part_length())
1315
1313
          {
1316
 
            length= min(max_key_length, cursor->max_key_part_length());
 
1314
            length= min(max_key_length, cursor->getEngine()->max_key_part_length());
1317
1315
            if (key->type == Key::MULTIPLE)
1318
1316
            {
1319
1317
              /* not a critical problem */
1338
1336
          my_message(ER_WRONG_SUB_KEY, ER(ER_WRONG_SUB_KEY), MYF(0));
1339
1337
          return(true);
1340
1338
        }
1341
 
        else if (!(cursor->ha_table_flags() & HA_NO_PREFIX_CHAR_KEYS))
 
1339
        else if (! (cursor->getEngine()->check_flag(HTON_BIT_NO_PREFIX_CHAR_KEYS)))
 
1340
        {
1342
1341
          length=column->length;
 
1342
        }
1343
1343
      }
1344
1344
      else if (length == 0)
1345
1345
      {
1346
1346
        my_error(ER_WRONG_KEY_COLUMN, MYF(0), column->field_name.str);
1347
1347
          return(true);
1348
1348
      }
1349
 
      if (length > cursor->max_key_part_length())
 
1349
      if (length > cursor->getEngine()->max_key_part_length())
1350
1350
      {
1351
 
        length= cursor->max_key_part_length();
 
1351
        length= cursor->getEngine()->max_key_part_length();
1352
1352
        if (key->type == Key::MULTIPLE)
1353
1353
        {
1354
1354
          /* not a critical problem */
1428
1428
    key_info++;
1429
1429
  }
1430
1430
  if (!unique_key && !primary_key &&
1431
 
      (cursor->ha_table_flags() & HA_REQUIRE_PRIMARY_KEY))
 
1431
      (cursor->getEngine()->check_flag(HTON_BIT_REQUIRE_PRIMARY_KEY)))
1432
1432
  {
1433
1433
    my_message(ER_REQUIRES_PRIMARY_KEY, ER(ER_REQUIRES_PRIMARY_KEY), MYF(0));
1434
1434
    return(true);
2096
2096
      open_for_modify= 0;
2097
2097
    }
2098
2098
 
2099
 
    if (table->table->s->crashed && operator_func == &Cursor::ha_check)
2100
 
    {
2101
 
      session->client->store(table_name);
2102
 
      session->client->store(operator_name);
2103
 
      session->client->store(STRING_WITH_LEN("warning"));
2104
 
      session->client->store(STRING_WITH_LEN("Table is marked as crashed"));
2105
 
      if (session->client->flush())
2106
 
        goto err;
2107
 
    }
2108
 
 
2109
2099
    result_code = (table->table->cursor->*operator_func)(session, check_opt);
2110
2100
 
2111
2101
send_result:
2588
2578
      /**
2589
2579
        @note if the engine keeps a checksum then we return the checksum, otherwise we calculate
2590
2580
      */
2591
 
      if (t->cursor->ha_table_flags() & HA_HAS_CHECKSUM)
2592
 
        session->client->store((uint64_t)t->cursor->checksum());
 
2581
      if (t->cursor->getEngine()->check_flag(HTON_BIT_HAS_CHECKSUM))
 
2582
      {
 
2583
        session->client->store((uint64_t)t->cursor->checksum());
 
2584
      }
2593
2585
      else
2594
2586
      {
2595
2587
        /* calculating table's checksum */