~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Brian Aker
  • Date: 2009-05-27 21:11:30 UTC
  • mto: This revision was merged to the branch mainline in revision 1040.
  • Revision ID: brian@gaz-20090527211130-10yq3d5gee3pwl9w
Remove lower case filename bits (aka we just lock into the most compatible
method, which is what we have been doing).

Removed a number of dead function endings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
260
260
  post_tmpdir_str << session->thread_id << session->tmp_table++;
261
261
  tmp= post_tmpdir_str.str();
262
262
 
263
 
  if (lower_case_table_names)
264
 
    transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
 
263
  transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
265
264
 
266
265
  path_str << tmp;
267
266
 
390
389
{
391
390
  TableList *table;
392
391
  char path[FN_REFLEN];
393
 
  const char *alias;
394
392
  uint32_t path_length= 0;
395
393
  String wrong_tables;
396
394
  int error= 0;
496
494
        error= -1;
497
495
        goto err_with_placeholders;
498
496
      }
499
 
      alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
500
497
      /* remove .frm file and engine files */
501
 
      path_length= build_table_filename(path, sizeof(path), db, alias, "",
 
498
      path_length= build_table_filename(path, sizeof(path), db, table->table_name, "",
502
499
                                        table->internal_tmp_table ?
503
500
                                        FN_IS_TMP : 0);
504
501
    }
1678
1675
{
1679
1676
  char          path[FN_REFLEN];
1680
1677
  uint32_t          path_length;
1681
 
  const char    *alias;
1682
1678
  uint          db_options, key_count;
1683
1679
  KEY           *key_info_buffer;
1684
1680
  handler       *file;
1696
1692
  db_options= create_info->table_options;
1697
1693
  if (create_info->row_type == ROW_TYPE_DYNAMIC)
1698
1694
    db_options|=HA_OPTION_PACK_RECORD;
1699
 
  alias= table_case_name(create_info, table_name);
1700
1695
  if (!(file= get_new_handler((TableShare*) 0, session->mem_root,
1701
1696
                              create_info->db_type)))
1702
1697
  {
1723
1718
  {
1724
1719
 #ifdef FN_DEVCHAR
1725
1720
    /* check if the table name contains FN_DEVCHAR when defined */
1726
 
    if (strchr(alias, FN_DEVCHAR))
 
1721
    if (strchr(table_name, FN_DEVCHAR))
1727
1722
    {
1728
 
      my_error(ER_WRONG_TABLE_NAME, MYF(0), alias);
 
1723
      my_error(ER_WRONG_TABLE_NAME, MYF(0), table_name);
1729
1724
      return(true);
1730
1725
    }
1731
1726
#endif
1732
 
    path_length= build_table_filename(path, sizeof(path), db, alias, "",
 
1727
    path_length= build_table_filename(path, sizeof(path), db, table_name, "",
1733
1728
                                      internal_tmp_table ? FN_IS_TMP : 0);
1734
1729
  }
1735
1730
 
1742
1737
      create_info->table_existed= 1;            // Mark that table existed
1743
1738
      push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
1744
1739
                          ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
1745
 
                          alias);
 
1740
                          table_name);
1746
1741
      error= 0;
1747
1742
      goto err;
1748
1743
    }
1749
 
    my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alias);
 
1744
    my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name);
1750
1745
    goto err;
1751
1746
  }
1752
1747
 
1769
1764
      Then she could create the table. This case is pretty obscure and
1770
1765
      therefore we don't introduce a new error message only for it.
1771
1766
    */
1772
 
    if (get_cached_table_share(db, alias))
 
1767
    if (get_cached_table_share(db, table_name))
1773
1768
    {
1774
1769
      my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name);
1775
1770
      goto unlock_and_end;
1875
1870
  error= false;
1876
1871
  push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
1877
1872
                      ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
1878
 
                      alias);
 
1873
                      table_name);
1879
1874
  create_info->table_existed= 1;                // Mark that table existed
1880
1875
  goto unlock_and_end;
1881
1876
}
2032
2027
                   const char *new_name, uint32_t flags)
2033
2028
{
2034
2029
  Session *session= current_session;
2035
 
  char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN], lc_to[FN_REFLEN];
 
2030
  char from[FN_REFLEN], to[FN_REFLEN];
2036
2031
  char *from_base= from, *to_base= to;
2037
 
  char tmp_name[NAME_LEN+1];
2038
2032
  handler *file;
2039
2033
  int error=0;
2040
2034
 
2046
2040
  build_table_filename(to, sizeof(to), new_db, new_name, "",
2047
2041
                       flags & FN_TO_IS_TMP);
2048
2042
 
2049
 
  /*
2050
 
    If lower_case_table_names == 2 (case-preserving but case-insensitive
2051
 
    file system) and the storage is not HA_FILE_BASED, we need to provide
2052
 
    a lowercase file name, but we leave the .frm in mixed case.
2053
 
   */
2054
 
  if (lower_case_table_names == 2 && file &&
2055
 
      !(file->ha_table_flags() & HA_FILE_BASED))
2056
 
  {
2057
 
    strcpy(tmp_name, old_name);
2058
 
    my_casedn_str(files_charset_info, tmp_name);
2059
 
    build_table_filename(lc_from, sizeof(lc_from), old_db, tmp_name, "",
2060
 
                         flags & FN_FROM_IS_TMP);
2061
 
    from_base= lc_from;
2062
 
 
2063
 
    strcpy(tmp_name, new_name);
2064
 
    my_casedn_str(files_charset_info, tmp_name);
2065
 
    build_table_filename(lc_to, sizeof(lc_to), new_db, tmp_name, "",
2066
 
                         flags & FN_TO_IS_TMP);
2067
 
    to_base= lc_to;
2068
 
  }
2069
2043
  if (!file || !(error=file->ha_rename_table(from_base, to_base)))
2070
2044
  {
2071
2045
    if(!(flags & NO_FRM_RENAME)
3734
3708
    true   Error
3735
3709
*/
3736
3710
 
3737
 
bool mysql_alter_table(Session *session,char *new_db, char *new_name,
 
3711
bool mysql_alter_table(Session *session, char *new_db, char *new_name,
3738
3712
                       HA_CREATE_INFO *create_info,
3739
3713
                       TableList *table_list,
3740
3714
                       Alter_info *alter_info,
3746
3720
  char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN];
3747
3721
  char new_alias_buff[FN_REFLEN], *table_name, *db;
3748
3722
  const char *new_alias;
3749
 
  const char *alias;
3750
3723
  char path[FN_REFLEN];
3751
3724
  ha_rows copied= 0,deleted= 0;
3752
3725
  StorageEngine *old_db_type, *new_db_type, *save_old_db_type;
3765
3738
    later just by comparing the pointers, avoiding the need for strcmp.
3766
3739
  */
3767
3740
  session->set_proc_info("init");
3768
 
  table_name=table_list->table_name;
3769
 
  alias= (lower_case_table_names == 2) ? table_list->alias : table_name;
 
3741
  table_name= table_list->table_name;
3770
3742
  db=table_list->db;
3771
3743
  if (!new_db || !my_strcasecmp(table_alias_charset, new_db, db))
3772
3744
    new_db= db;
3802
3774
  /* Check that we are not trying to rename to an existing table */
3803
3775
  if (new_name)
3804
3776
  {
3805
 
    strcpy(new_name_buff,new_name);
 
3777
    strcpy(new_name_buff, new_name);
3806
3778
    strcpy(new_alias_buff, new_name);
3807
3779
    new_alias= new_alias_buff;
3808
 
    if (lower_case_table_names)
3809
 
    {
3810
 
      if (lower_case_table_names != 2)
3811
 
      {
3812
 
        my_casedn_str(files_charset_info, new_name_buff);
3813
 
        new_alias= new_name;                    // Create lower case table name
3814
 
      }
3815
 
      my_casedn_str(files_charset_info, new_name);
3816
 
    }
 
3780
 
 
3781
    my_casedn_str(files_charset_info, new_name_buff);
 
3782
    new_alias= new_name;                        // Create lower case table name
 
3783
    my_casedn_str(files_charset_info, new_name);
 
3784
 
3817
3785
    if (new_db == db &&
3818
3786
        !my_strcasecmp(table_alias_charset, new_name_buff, table_name))
3819
3787
    {
3856
3824
  }
3857
3825
  else
3858
3826
  {
3859
 
    new_alias= (lower_case_table_names == 2) ? alias : table_name;
 
3827
    new_alias= table_name;
3860
3828
    new_name= table_name;
3861
3829
  }
3862
3830
 
4026
3994
  snprintf(tmp_name, sizeof(tmp_name), "%s-%lx_%"PRIx64, TMP_FILE_PREFIX,
4027
3995
           (unsigned long)current_pid, session->thread_id);
4028
3996
  /* Safety fix for innodb */
4029
 
  if (lower_case_table_names)
4030
 
    my_casedn_str(files_charset_info, tmp_name);
 
3997
  my_casedn_str(files_charset_info, tmp_name);
4031
3998
 
4032
3999
 
4033
4000
  /* Create a temporary table with the new format */
4151
4118
  session->set_proc_info("rename result table");
4152
4119
  snprintf(old_name, sizeof(old_name), "%s2-%lx-%"PRIx64, TMP_FILE_PREFIX,
4153
4120
           (unsigned long)current_pid, session->thread_id);
4154
 
  if (lower_case_table_names)
4155
 
    my_casedn_str(files_charset_info, old_name);
 
4121
  my_casedn_str(files_charset_info, old_name);
4156
4122
 
4157
4123
  wait_while_table_is_used(session, table, HA_EXTRA_PREPARE_FOR_RENAME);
4158
4124
  close_data_files_and_morph_locks(session, db, table_name);
4186
4152
    error=1;
4187
4153
    quick_rm_table(new_db_type, new_db, new_alias, 0);
4188
4154
    quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP);
4189
 
    mysql_rename_table(old_db_type, db, old_name, db, alias,
 
4155
    mysql_rename_table(old_db_type, db, old_name, db, table_name,
4190
4156
                       FN_FROM_IS_TMP);
4191
4157
  }
4192
4158