~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Monty Taylor
  • Date: 2008-11-22 08:48:11 UTC
  • mfrom: (574.3.19 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 603.
  • Revision ID: monty@inaugust.com-20081122084811-6crylm9iqj4loyjk
MergedĀ fromĀ Lee.

Show diffs side-by-side

added added

removed removed

Lines of Context:
219
219
  share->path.str=               (char*) path;
220
220
  share->normalized_path.str=    (char*) path;
221
221
  share->path.length= share->normalized_path.length= strlen(path);
222
 
 
 
222
  share->frm_version=            FRM_VER_TRUE_VARCHAR;
223
223
  /*
224
224
    Temporary tables are not replicated, but we set up these fields
225
225
    anyway to be able to catch errors.
469
469
  if (my_read(file,forminfo,288,MYF(MY_NABP)))
470
470
    goto err;
471
471
 
 
472
  share->frm_version= head[2];
 
473
  /*
 
474
    Check if .frm file created by MySQL 5.0. In this case we want to
 
475
    display CHAR fields as CHAR and not as VARCHAR.
 
476
    We do it this way as we want to keep the old frm version to enable
 
477
    MySQL 4.1 to read these files.
 
478
  */
 
479
  if (share->frm_version == FRM_VER_TRUE_VARCHAR -1 && head[33] == 5)
 
480
    share->frm_version= FRM_VER_TRUE_VARCHAR;
 
481
 
472
482
  legacy_db_type= DB_TYPE_FIRST_DYNAMIC;
473
483
  assert(share->db_plugin == NULL);
474
484
  /*
1025
1035
  /* Fix key->name and key_part->field */
1026
1036
  if (key_parts)
1027
1037
  {
1028
 
    uint32_t primary_key=(uint) (find_type((char*) "PRIMARY",
 
1038
    uint32_t primary_key=(uint) (find_type((char*) primary_key_name,
1029
1039
                                       &share->keynames, 3) - 1);
1030
1040
    int64_t ha_option= handler_file->ha_table_flags();
1031
1041
    keyinfo= share->key_info;
3550
3560
  return length;
3551
3561
}
3552
3562
 
 
3563
/*
 
3564
  Check type of .frm if we are not going to parse it
 
3565
 
 
3566
  SYNOPSIS
 
3567
  mysql_frm_type()
 
3568
  path        path to file
 
3569
 
 
3570
  RETURN
 
3571
  false       error
 
3572
  true       table
 
3573
*/
 
3574
 
 
3575
bool mysql_frm_type(Session *, char *path, enum legacy_db_type *dbt)
 
3576
{
 
3577
  File file;
 
3578
  unsigned char header[10];     /* This should be optimized */
 
3579
  int error;
 
3580
 
 
3581
  *dbt= DB_TYPE_UNKNOWN;
 
3582
 
 
3583
  if ((file= open(path, O_RDONLY)) < 0)
 
3584
    return false;
 
3585
  error= my_read(file, (unsigned char*) header, sizeof(header), MYF(MY_NABP));
 
3586
  my_close(file, MYF(MY_WME));
 
3587
 
 
3588
  if (error)
 
3589
    return false;
 
3590
 
 
3591
  /*  
 
3592
    This is just a check for DB_TYPE. We'll return default unknown type
 
3593
    if the following test is true (arg #3). This should not have effect
 
3594
    on return value from this function (default FRMTYPE_TABLE)
 
3595
   */  
 
3596
  if (header[0] != (unsigned char) 254 || header[1] != 1 ||
 
3597
      (header[2] != FRM_VER && header[2] != FRM_VER+1 &&
 
3598
       (header[2] < FRM_VER+3 || header[2] > FRM_VER+4)))
 
3599
    return true;
 
3600
 
 
3601
  *dbt= (enum legacy_db_type) (uint) *(header + 3);
 
3602
  return true;                   // Is probably a .frm table
 
3603
}
 
3604
 
3553
3605
/****************************************************************************
3554
3606
 Functions for creating temporary tables.
3555
3607
****************************************************************************/