~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/table.cc

Merged changes from codestyle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
                              uint types, char **names);
37
37
static uint find_field(Field **fields, uchar *record, uint start, uint length);
38
38
 
39
 
inline bool is_system_table_name(const char *name, uint length);
40
 
 
41
39
/**************************************************************************
42
40
  Object_creation_ctx implementation.
43
41
**************************************************************************/
146
144
    return TABLE_CATEGORY_INFORMATION;
147
145
  }
148
146
 
149
 
  if ((db->length == MYSQL_SCHEMA_NAME.length) &&
150
 
      (my_strcasecmp(system_charset_info,
151
 
                    MYSQL_SCHEMA_NAME.str,
152
 
                    db->str) == 0))
153
 
  {
154
 
    if (is_system_table_name(name->str, name->length))
155
 
    {
156
 
      return TABLE_CATEGORY_SYSTEM;
157
 
    }
158
 
  }
159
 
 
160
147
  return TABLE_CATEGORY_USER;
161
148
}
162
149
 
344
331
  DBUG_VOID_RETURN;
345
332
}
346
333
 
347
 
 
348
 
/**
349
 
  Return TRUE if a table name matches one of the system table names.
350
 
  Currently these are:
351
 
 
352
 
  help_category, help_keyword, help_relation, help_topic,
353
 
  proc, event
354
 
  time_zone, time_zone_leap_second, time_zone_name, time_zone_transition,
355
 
  time_zone_transition_type
356
 
 
357
 
  This function trades accuracy for speed, so may return false
358
 
  positives. Presumably mysql.* database is for internal purposes only
359
 
  and should not contain user tables.
360
 
*/
361
 
 
362
 
inline bool is_system_table_name(const char *name, uint length)
363
 
{
364
 
  CHARSET_INFO *ci= system_charset_info;
365
 
 
366
 
  return (
367
 
          /* mysql.proc table */
368
 
          (
369
 
           length == 4 &&
370
 
           my_tolower(ci, name[0]) == 'p' && 
371
 
           my_tolower(ci, name[1]) == 'r' &&
372
 
           my_tolower(ci, name[2]) == 'o' &&
373
 
           my_tolower(ci, name[3]) == 'c'
374
 
          ) ||
375
 
 
376
 
          /* one of mysql.help* tables */
377
 
          (
378
 
           length > 4 &&
379
 
           my_tolower(ci, name[0]) == 'h' &&
380
 
           my_tolower(ci, name[1]) == 'e' &&
381
 
           my_tolower(ci, name[2]) == 'l' &&
382
 
           my_tolower(ci, name[3]) == 'p'
383
 
          ) ||
384
 
 
385
 
          /* one of mysql.time_zone* tables */
386
 
          (
387
 
           my_tolower(ci, name[0]) == 't' &&
388
 
           my_tolower(ci, name[1]) == 'i' &&
389
 
           my_tolower(ci, name[2]) == 'm' &&
390
 
           my_tolower(ci, name[3]) == 'e'
391
 
          )
392
 
          );
393
 
}
394
 
 
395
 
 
396
334
/*
397
335
  Read table definition from a binary / text based .frm file
398
336
  
517
455
    *root_ptr= old_root;
518
456
    error_given= 1;
519
457
  }
 
458
  else
 
459
    assert(1);
520
460
 
521
461
  share->table_category= get_table_category(& share->db, & share->table_name);
522
462
 
591
531
  if (share->frm_version == FRM_VER_TRUE_VARCHAR -1 && head[33] == 5)
592
532
    share->frm_version= FRM_VER_TRUE_VARCHAR;
593
533
 
594
 
  legacy_db_type= (enum legacy_db_type) (uint) *(head+3);
 
534
  legacy_db_type= DB_TYPE_FIRST_DYNAMIC;
595
535
  DBUG_ASSERT(share->db_plugin == NULL);
596
536
  /*
597
537
    if the storage engine is dynamic, no point in resolving it by its
679
619
      keyinfo->block_size= uint2korr(strpos+6);
680
620
      strpos+=8;
681
621
    }
682
 
    else
683
 
    {
684
 
      keyinfo->flags=    ((uint) strpos[0]) ^ HA_NOSAME;
685
 
      keyinfo->key_length= (uint) uint2korr(strpos+1);
686
 
      keyinfo->key_parts=  (uint) strpos[3];
687
 
      keyinfo->algorithm= HA_KEY_ALG_UNDEF;
688
 
      strpos+=4;
689
 
    }
690
622
 
691
623
    keyinfo->key_part=   key_part;
692
624
    keyinfo->rec_per_key= rec_per_key;
1154
1086
    reg_field->flags|= ((uint)column_format << COLUMN_FORMAT_FLAGS);
1155
1087
    reg_field->field_index= i;
1156
1088
    reg_field->comment=comment;
1157
 
    if (field_type == MYSQL_TYPE_BIT && !f_bit_as_char(pack_flag))
1158
 
    {
1159
 
      if ((null_bit_pos+= field_length & 7) > 7)
1160
 
      {
1161
 
        null_pos++;
1162
 
        null_bit_pos-= 8;
1163
 
      }
1164
 
    }
1165
1089
    if (!(reg_field->flags & NOT_NULL_FLAG))
1166
1090
    {
1167
1091
      if (!(null_bit_pos= (null_bit_pos + 1) & 7))
1251
1175
          keyinfo->extra_length+=HA_KEY_BLOB_LENGTH;
1252
1176
          key_part->store_length+=HA_KEY_BLOB_LENGTH;
1253
1177
          keyinfo->key_length+= HA_KEY_BLOB_LENGTH;
1254
 
          /*
1255
 
            Mark that there may be many matching values for one key
1256
 
            combination ('a', 'a ', 'a  '...)
1257
 
          */
1258
 
          if (!(field->flags & BINARY_FLAG))
1259
 
            keyinfo->flags|= HA_END_SPACE_KEY;
1260
1178
        }
1261
 
        if (field->type() == MYSQL_TYPE_BIT)
1262
 
          key_part->key_part_flag|= HA_BIT_PART;
1263
 
 
1264
1179
        if (i == 0 && key != primary_key)
1265
1180
          field->flags |= (((keyinfo->flags & HA_NOSAME) &&
1266
1181
                           (keyinfo->key_parts == 1)) ?
1978
1893
    char tmp[10];
1979
1894
    if (!csname || csname[0] =='?')
1980
1895
    {
1981
 
      my_snprintf(tmp, sizeof(tmp), "#%d", errarg);
 
1896
      snprintf(tmp, sizeof(tmp), "#%d", errarg);
1982
1897
      csname= tmp;
1983
1898
    }
1984
1899
    my_printf_error(ER_UNKNOWN_COLLATION,