~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Brian Aker
  • Date: 2008-11-21 23:53:09 UTC
  • mfrom: (590.1.8 drizzle-nofrm)
  • Revision ID: brian@tangent.org-20081121235309-77pu95n2pboadtos
Merge in Stewart's work

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
 
  share->frm_version=            FRM_VER_TRUE_VARCHAR;
 
222
 
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
 
 
482
472
  legacy_db_type= DB_TYPE_FIRST_DYNAMIC;
483
473
  assert(share->db_plugin == NULL);
484
474
  /*
1035
1025
  /* Fix key->name and key_part->field */
1036
1026
  if (key_parts)
1037
1027
  {
1038
 
    uint32_t primary_key=(uint) (find_type((char*) primary_key_name,
 
1028
    uint32_t primary_key=(uint) (find_type((char*) "PRIMARY",
1039
1029
                                       &share->keynames, 3) - 1);
1040
1030
    int64_t ha_option= handler_file->ha_table_flags();
1041
1031
    keyinfo= share->key_info;
3560
3550
  return length;
3561
3551
}
3562
3552
 
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
 
 
3605
3553
/****************************************************************************
3606
3554
 Functions for creating temporary tables.
3607
3555
****************************************************************************/