← Back to team overview

maria-developers team mailing list archive

Open and close a TABLE_LIST at random place in code

 

Hello.

I need to see a table structure while executing some query (DELETE in my case, but there will be more query types in future). I have a TABLE_LIST which came from a parser. Now I'm opening it with open_table_only_view_structure(), examine table structure and close it, trying to prevent any side effects. And there is a lot of them.

Current code looks like this:

  if (open_tables_only_view_structure(thd, table_list, false))
  {
    return true;
  }

  // examine table structure

  close_mysql_tables(thd);

  for (Sroutine_hash_entry *e = thd->lex->sroutines_list.first;e; e=e->next)
    e->mdl_request.ticket= NULL;

  for (TABLE_LIST *it= table_list; it; it= it->next_global)
  {
    it->table= NULL;
    it->reinit_before_use(thd);
    //it->next_global= NULL;
    it->derived_result= NULL;
    it->derived= NULL;
    it->view= NULL;
    it->view_tables= NULL;
    it->view_sctx= NULL;
    it->file_version= 0;
    it->mariadb_version= 0;
    it->updatable_view= 0;
    it->view_suid= 0;
    it->derived_type= 0;
    it->open_type= OT_BASE_ONLY;
    it->view_creation_ctx= 0;
    //    it->set_table_ref_id(TABLE_REF_NULL, 0);
  }

Is there a way to close a TABLE_LIST gracefully without touching a lot of it's fields? Or even maybe it's possible to open a table in a simpler manner?


-- 
Eugene



Follow ups