687
687
/* Change database if necessary */
688
688
if (in_db && in_db[0])
690
if (mysql_change_db(this, in_db))
690
SchemaIdentifier identifier(in_db);
691
if (mysql_change_db(this, identifier))
692
693
/* mysql_change_db() has pushed the error message. */
1146
#define NEED_ESCAPING(x) ((int) (unsigned char) (x) == escape_char || \
1147
(enclosed ? (int) (unsigned char) (x) == field_sep_char \
1148
: (int) (unsigned char) (x) == field_term_char) || \
1149
(int) (unsigned char) (x) == line_sep_char || \
1152
1146
bool select_export::send_data(List<Item> &items)
1154
1148
char buff[MAX_FIELD_WIDTH],null_buff[2],space[MAX_FIELD_WIDTH];
1265
1259
assert before the loop makes that sure.
1268
if ((NEED_ESCAPING(*pos) ||
1262
if ((needs_escaping(*pos, enclosed) ||
1269
1263
(check_second_byte &&
1270
1264
my_mbcharlen(character_set_client, (unsigned char) *pos) == 2 &&
1271
1265
pos + 1 < end &&
1272
NEED_ESCAPING(pos[1]))) &&
1266
needs_escaping(pos[1], enclosed))) &&
1274
1268
Don't escape field_term_char by doubling - doubling is only
1275
1269
valid for ENCLOSED BY characters:
1623
1617
set_open_tables_state(backup);
1626
bool Session::set_db(const char *new_db, size_t length)
1620
bool Session::set_db(const std::string &new_db)
1628
1622
/* Do not reallocate memory if current chunk is big enough. */
1623
if (new_db.length())
1796
1790
if (temporary_tables)
1797
1791
table->next->prev= NULL;
1799
close_temporary(table);
1803
Close and delete a temporary table
1797
Close and drop a temporary table
1806
1800
This dosn't unlink table from session->temporary
1807
1801
If this is needed, use close_temporary_table()
1810
void Session::close_temporary(Table *table)
1804
void Session::nukeTable(Table *table)
1812
1806
plugin::StorageEngine *table_type= table->s->db_type();
1814
1808
table->free_io_cache();
1815
1809
table->closefrm(false);
1817
rm_temporary_table(table_type, table->s->path.str);
1811
TableIdentifier identifier(table->s->getSchemaName(), table->s->table_name.str, table->s->path.str);
1812
rm_temporary_table(table_type, identifier);
1819
1814
table->s->free_table_share();
2006
2001
if (open_tables_from_list(&tables, &counter))
2009
if (!lock_tables(tables, counter, &need_reopen))
2004
if (not lock_tables(tables, counter, &need_reopen))
2006
if (not need_reopen)
2013
2008
close_tables_for_reopen(&tables);
2034
2029
bool Session::rm_temporary_table(TableIdentifier &identifier)
2036
if (not plugin::StorageEngine::dropTable(*this, identifier))
2031
if (plugin::StorageEngine::dropTable(*this, identifier))
2038
2033
errmsg_printf(ERRMSG_LVL_WARN, _("Could not remove temporary table: '%s', error: %d"),
2039
identifier.getPath().c_str(), errno);
2034
identifier.getSQLPath().c_str(), errno);
2035
dumpTemporaryTableNames("rm_temporary_table()");
2047
bool Session::rm_temporary_table(plugin::StorageEngine *base, const char *path)
2043
bool Session::rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier)
2050
TableIdentifier dummy(path);
2054
if (delete_table_proto_file(path))
2057
if (base->doDropTable(*this, dummy))
2047
if (plugin::StorageEngine::dropTable(*this, *base, identifier))
2060
2049
errmsg_printf(ERRMSG_LVL_WARN, _("Could not remove temporary table: '%s', error: %d"),
2050
identifier.getSQLPath().c_str(), errno);
2051
dumpTemporaryTableNames("rm_temporary_table()");
2060
@note this will be removed, I am looking through Hudson to see if it is finding
2061
any tables that are missed during cleanup.
2063
void Session::dumpTemporaryTableNames(const char *foo)
2067
if (not temporary_tables)
2070
cerr << "Begin Run: " << foo << "\n";
2071
for (table= temporary_tables; table; table= table->next)
2073
bool have_proto= false;
2075
message::Table *proto= table->s->getTableProto();
2076
if (table->s->getTableProto())
2079
const char *answer= have_proto ? "true" : "false";
2083
cerr << "\tTable Name " << table->s->getSchemaName() << "." << table->s->table_name.str << " : " << answer << "\n";
2084
cerr << "\t\t Proto " << proto->schema() << " " << proto->name() << "\n";
2087
cerr << "\tTabl;e Name " << table->s->getSchemaName() << "." << table->s->table_name.str << " : " << answer << "\n";
2066
2091
bool Session::storeTableMessage(TableIdentifier &identifier, message::Table &table_message)