Commit 5af7ca80 authored by unknown's avatar unknown
Browse files

Changes in get_table_type() and mysql_frm_type(). The main problem was

that in mysql_rm_table_part2_with_lock() previously we needed to open
same file twice. Now once is enough.


sql/mysql_priv.h:
  Merged functions get_table_type() and mysql_frm_type() into one,
  using the name from latter one.
sql/sql_base.cc:
  Changed get_table_type() to mysql_frm_type()
sql/sql_delete.cc:
  Changed get_table_type() to mysql_frm_type()
sql/sql_rename.cc:
  Changed get_table_type() to mysql_frm_type()
sql/sql_show.cc:
  Changed get_table_type() to mysql_frm_type()
sql/sql_table.cc:
  Changed get_table_type() to mysql_frm_type()
sql/sql_view.cc:
  Merged code from get_table_type() and mysql_frm_type() into the latter one.
sql/sql_view.h:
  Function prototype changes.
sql/table.cc:
  No longer needed.
parent abd77bc5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -1295,7 +1295,6 @@ int openfrm(THD *thd, const char *name,const char *alias,uint filestat,
int readfrm(const char *name, const void** data, uint* length);
int writefrm(const char* name, const void* data, uint len);
int closefrm(TABLE *table);
db_type get_table_type(THD *thd, const char *name);
int read_string(File file, gptr *to, uint length);
void free_blobs(TABLE *table);
int set_zone(int nr,int min_zone,int max_zone);
+2 −1
Original line number Diff line number Diff line
@@ -1193,10 +1193,11 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
    */
    {
      char path[FN_REFLEN];
      db_type not_used;
      strxnmov(path, FN_REFLEN, mysql_data_home, "/", table_list->db, "/",
               table_list->table_name, reg_ext, NullS);
      (void) unpack_filename(path, path);
      if (mysql_frm_type(path) == FRMTYPE_VIEW)
      if (mysql_frm_type(thd, path, &not_used) == FRMTYPE_VIEW)
      {
        TABLE tab;// will not be used (because it's VIEW) but have to be passed
        table= &tab;
+2 −1
Original line number Diff line number Diff line
@@ -830,7 +830,8 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
  if (!dont_send_ok)
  {
    db_type table_type;
    if ((table_type=get_table_type(thd, path)) == DB_TYPE_UNKNOWN)
    mysql_frm_type(thd, path, &table_type);
    if (table_type == DB_TYPE_UNKNOWN)
    {
      my_error(ER_NO_SUCH_TABLE, MYF(0),
               table_list->db, table_list->table_name);
+4 −3
Original line number Diff line number Diff line
@@ -134,6 +134,8 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
{
  TABLE_LIST *ren_table,*new_table;
  frm_type_enum frm_type;
  db_type table_type;

  DBUG_ENTER("rename_tables");

  for (ren_table= table_list; ren_table; ren_table= new_table->next_local)
@@ -166,13 +168,12 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
	    reg_ext);
    unpack_filename(name, name);

    frm_type= mysql_frm_type(name);
    frm_type= mysql_frm_type(thd, name, &table_type);
    switch (frm_type)
    {
      case FRMTYPE_TABLE:
      {
        db_type table_type;
        if ((table_type= get_table_type(thd, name)) == DB_TYPE_UNKNOWN) 
        if (table_type == DB_TYPE_UNKNOWN) 
          my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
        else
          rc= mysql_rename_table(table_type, ren_table->db, old_alias,
+2 −1
Original line number Diff line number Diff line
@@ -2003,6 +2003,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
  Security_context *sctx= thd->security_ctx;
  uint derived_tables= lex->derived_tables; 
  int error= 1;
  db_type not_used;
  Open_tables_state open_tables_state_backup;
  DBUG_ENTER("get_all_tables");

@@ -2114,7 +2115,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
              else
              {
                my_snprintf(end, len, "/%s%s", file_name, reg_ext);
                switch (mysql_frm_type(path)) {
                switch (mysql_frm_type(thd, path, &not_used)) {
                case FRMTYPE_ERROR:
                  table->field[3]->store("ERROR", 5, system_charset_info);
                  break;
Loading