26
26
#include <sys/stat.h>
27
27
#include <mysys/mysys_err.h>
28
28
#include <drizzled/error.h>
29
#include <drizzled/gettext.h>
29
30
#include <drizzled/query_id.h>
30
31
#include <drizzled/data_home.h>
31
32
#include <drizzled/sql_base.h>
1842
1843
temporary_tables= NULL;
1847
unlink from session->temporary tables and close temporary table
1850
void Session::close_temporary_table(Table *table,
1851
bool free_share, bool delete_table)
1855
table->prev->next= table->next;
1856
if (table->prev->next)
1857
table->next->prev= table->prev;
1861
/* removing the item from the list */
1862
assert(table == temporary_tables);
1864
slave must reset its temporary list pointer to zero to exclude
1865
passing non-zero value to end_slave via rli->save_temporary_tables
1866
when no temp tables opened, see an invariant below.
1868
temporary_tables= table->next;
1869
if (temporary_tables)
1870
table->next->prev= NULL;
1872
close_temporary(table, free_share, delete_table);
1876
Close and delete a temporary table
1879
This dosn't unlink table from session->temporary
1880
If this is needed, use close_temporary_table()
1883
void Session::close_temporary(Table *table, bool free_share, bool delete_table)
1885
StorageEngine *table_type= table->s->db_type();
1887
table->free_io_cache();
1888
table->closefrm(false);
1891
rm_temporary_table(table_type, table->s->path.str);
1895
table->s->free_table_share();
1896
/* This makes me sad, but we're allocating it via malloc */
1846
1901
/** Clear most status variables. */
1847
1902
extern time_t flush_status_time;
2018
2073
close_thread_tables();
2021
int Session::open_and_lock_tables(TableList *tables)
2076
bool Session::openTablesLock(TableList *tables)
2023
2078
uint32_t counter;
2024
2079
bool need_reopen;
2028
if (open_tables_from_list(&tables, &counter, 0))
2083
if (open_tables_from_list(&tables, &counter))
2031
if (!lock_tables(this, tables, counter, &need_reopen))
2086
if (!lock_tables(tables, counter, &need_reopen))
2033
2088
if (!need_reopen)
2035
2090
close_tables_for_reopen(&tables);
2037
2092
if ((mysql_handle_derived(lex, &mysql_derived_prepare) ||
2038
2093
(fill_derived_tables() &&
2039
2094
mysql_handle_derived(lex, &mysql_derived_filling))))
2040
return 1; /* purecov: inspected */
2095
return true; /* purecov: inspected */
2045
bool Session::open_normal_and_derived_tables(TableList *tables, uint32_t flags)
2100
bool Session::openTables(TableList *tables, uint32_t flags)
2047
2102
uint32_t counter;
2048
2103
bool ret= fill_derived_tables();
2052
2107
return true; /* purecov: inspected */
2111
bool Session::rm_temporary_table(StorageEngine *base, char *path)
2117
if (delete_table_proto_file(path))
2118
error=1; /* purecov: inspected */
2120
if (base->deleteTable(this, path))
2123
errmsg_printf(ERRMSG_LVL_WARN, _("Could not remove temporary table: '%s', error: %d"),