~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/table.cc

  • Committer: Brian Aker
  • Date: 2008-07-07 15:28:30 UTC
  • Revision ID: brian@tangent.org-20080707152830-pvzbyczztrrjzin4
Small cleanups

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;