109
void write_bin_log(Session *session, const std::string &query)
111
TransactionServices &transaction_services= TransactionServices::singleton();
112
transaction_services.rawStatement(*session, query);
106
void write_bin_log(Session *session,
109
TransactionServices &transaction_services= TransactionServices::singleton();
110
transaction_services.rawStatement(session, query);
114
/* Should should be refactored to go away */
115
void write_bin_log_drop_table(Session *session, bool if_exists, const char *db_name, const char *table_name)
117
TransactionServices &transaction_services= TransactionServices::singleton();
121
built_query.append("DROP TABLE IF EXISTS ");
123
built_query.append("DROP TABLE ");
125
built_query.append("`");
126
if (session->db.empty() || strcmp(db_name, session->db.c_str()) != 0)
128
built_query.append(db_name);
129
built_query.append("`.`");
132
built_query.append(table_name);
133
built_query.append("`");
134
transaction_services.rawStatement(session, built_query);
116
138
Execute the drop of a normal or temporary table
141
mysql_rm_table_part2()
120
142
session Thread Cursor
121
143
tables Tables to drop
122
144
if_exists If set, don't give an error if table doesn't exists.
123
145
In this case we give an warning of level 'NOTE'
124
146
drop_temporary Only drop temporary tables
127
149
When logging to the binary log, we should log
128
150
tmp_tables and transactional tables as separate statements if we
129
151
are in a transaction; This is needed to get these tables into the
139
161
-1 Thread was killed
142
int rm_table_part2(Session *session, TableList *tables, bool if_exists,
164
int mysql_rm_table_part2(Session *session, TableList *tables, bool if_exists,
145
167
TableList *table;
146
168
String wrong_tables;
148
170
bool foreign_key_error= false;
152
boost::mutex::scoped_lock scopedLock(table::Cache::singleton().mutex());
154
if (not drop_temporary && session->lock_table_names_exclusively(tables))
159
/* Don't give warnings for not found errors, as we already generate notes */
160
session->no_warnings_for_error= 1;
162
for (table= tables; table; table= table->next_local)
164
identifier::Table tmp_identifier(table->getSchemaName(), table->getTableName());
166
error= session->drop_temporary_table(tmp_identifier);
170
// removed temporary table
172
pthread_mutex_lock(&LOCK_open); /* Part 2 of rm a table */
175
If we have the table in the definition cache, we don't have to check the
176
.frm cursor to find if the table is a normal table (not view) and what
180
for (table= tables; table; table= table->next_local)
182
TableIdentifier identifier(table->db, table->table_name);
184
table->db_type= NULL;
186
if ((share= TableShare::getShare(identifier)))
188
table->db_type= share->db_type();
192
if (not drop_temporary && lock_table_names_exclusively(session, tables))
194
pthread_mutex_unlock(&LOCK_open);
198
/* Don't give warnings for not found errors, as we already generate notes */
199
session->no_warnings_for_error= 1;
201
for (table= tables; table; table= table->next_local)
205
error= session->drop_temporary_table(table);
209
// removed temporary table
213
goto err_with_placeholders;
215
// temporary table not found
219
if (drop_temporary == false)
222
abort_locked_tables(session, db, table->table_name);
223
remove_table_from_cache(session, db, table->table_name,
224
RTFC_WAIT_OTHER_THREAD_FLAG |
225
RTFC_CHECK_KILLED_FLAG);
227
If the table was used in lock tables, remember it so that
228
unlock_table_names can free it
230
if ((locked_table= drop_locked_tables(session, db, table->table_name)))
231
table->table= locked_table;
236
goto err_with_placeholders;
239
TableIdentifier identifier(db, table->table_name, table->internal_tmp_table ? message::Table::INTERNAL : message::Table::STANDARD);
241
if (drop_temporary || not plugin::StorageEngine::doesTableExist(*session, identifier))
243
// Table was not found on disk and table can't be created from engine
245
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
246
ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
176
// temporary table not found
253
error= plugin::StorageEngine::dropTable(*session, identifier);
255
if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) && if_exists)
180
if (drop_temporary == false)
183
abort_locked_tables(session, tmp_identifier);
184
table::Cache::singleton().removeTable(session, tmp_identifier,
185
RTFC_WAIT_OTHER_THREAD_FLAG |
186
RTFC_CHECK_KILLED_FLAG);
188
If the table was used in lock tables, remember it so that
189
unlock_table_names can free it
191
if ((locked_table= drop_locked_tables(session, tmp_identifier)))
192
table->table= locked_table;
194
if (session->getKilled())
200
identifier::Table identifier(table->getSchemaName(), table->getTableName(), table->getInternalTmpTable() ? message::Table::INTERNAL : message::Table::STANDARD);
202
if (drop_temporary || not plugin::StorageEngine::doesTableExist(*session, identifier))
204
// Table was not found on disk and table can't be created from engine
206
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
207
ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
208
table->getTableName());
216
drizzled::error_t local_error;
218
/* Generate transaction event ONLY when we successfully drop */
219
if (plugin::StorageEngine::dropTable(*session, identifier, local_error))
221
TransactionServices &transaction_services= TransactionServices::singleton();
222
transaction_services.dropTable(*session, identifier, if_exists);
226
if (local_error == HA_ERR_NO_SUCH_TABLE and if_exists)
229
session->clear_error();
232
if (local_error == HA_ERR_ROW_IS_REFERENCED)
234
/* the table is referenced by a foreign key constraint */
235
foreign_key_error= true;
243
if (wrong_tables.length())
244
wrong_tables.append(',');
245
wrong_tables.append(String(table->getTableName(), system_charset_info));
249
tables->unlock_table_names();
258
session->clear_error();
261
if (error == HA_ERR_ROW_IS_REFERENCED)
263
/* the table is referenced by a foreign key constraint */
264
foreign_key_error= true;
268
if (error == 0 || (if_exists && foreign_key_error == false))
270
TransactionServices &transaction_services= TransactionServices::singleton();
271
transaction_services.dropTable(session, string(db), string(table->table_name), if_exists);
276
if (wrong_tables.length())
277
wrong_tables.append(',');
278
wrong_tables.append(String(table->table_name,system_charset_info));
282
It's safe to unlock LOCK_open: we have an exclusive lock
285
pthread_mutex_unlock(&LOCK_open);
253
288
if (wrong_tables.length())
493
522
(*timestamps_with_niladic)++;
497
525
sql_field->unireg_check= Field::NONE;
500
527
else if (sql_field->unireg_check != Field::NONE)
502
528
(*timestamps_with_niladic)++;
509
case DRIZZLE_TYPE_BOOLEAN:
510
case DRIZZLE_TYPE_DATE: // Rest of string types
511
case DRIZZLE_TYPE_DATETIME:
512
case DRIZZLE_TYPE_DECIMAL:
513
case DRIZZLE_TYPE_DOUBLE:
514
case DRIZZLE_TYPE_LONG:
515
case DRIZZLE_TYPE_LONGLONG:
516
case DRIZZLE_TYPE_NULL:
517
case DRIZZLE_TYPE_TIME:
518
case DRIZZLE_TYPE_UUID:
519
case DRIZZLE_TYPE_VARCHAR:
533
sql_field->pack_flag=(0 |
534
f_settype((uint32_t) sql_field->sql_type));
526
static int prepare_create_table(Session *session,
527
HA_CREATE_INFO *create_info,
528
message::Table &create_proto,
529
AlterInfo *alter_info,
531
uint32_t *db_options,
532
KeyInfo **key_info_buffer,
534
int select_field_count)
540
static int mysql_prepare_create_table(Session *session,
541
HA_CREATE_INFO *create_info,
542
message::Table &create_proto,
543
AlterInfo *alter_info,
545
uint32_t *db_options,
546
KEY **key_info_buffer,
548
int select_field_count)
536
550
const char *key_name;
537
551
CreateField *sql_field,*dup_field;
538
552
uint field,null_fields,blob_columns,max_key_length;
539
553
ulong record_offset= 0;
541
KeyPartInfo *key_part_info;
555
KEY_PART_INFO *key_part_info;
542
556
int timestamps= 0, timestamps_with_niladic= 0;
544
558
int select_field_pos,auto_increment=0;
545
559
List_iterator<CreateField> it(alter_info->create_list);
546
560
List_iterator<CreateField> it2(alter_info->create_list);
1449
1438
assert(identifier.getTableName() == table_proto.name());
1450
1439
db_options= create_info->table_options;
1441
if (create_info->row_type == ROW_TYPE_DYNAMIC)
1442
db_options|=HA_OPTION_PACK_RECORD;
1452
1444
set_table_default_charset(create_info, identifier.getSchemaName().c_str());
1454
1446
/* Build a Table object to pass down to the engine, and the do the actual create. */
1455
if (not prepare_create_table(session, create_info, table_proto, alter_info,
1458
&key_info_buffer, &key_count,
1459
select_field_count))
1447
if (not mysql_prepare_create_table(session, create_info, table_proto, alter_info,
1450
&key_info_buffer, &key_count,
1451
select_field_count))
1461
boost_unique_lock_t lock(table::Cache::singleton().mutex()); /* CREATE TABLE (some confussion on naming, double check) */
1453
pthread_mutex_lock(&LOCK_open); /* CREATE TABLE (some confussion on naming, double check) */
1462
1454
error= locked_create_event(session,
1828
1818
char buff[FN_REFLEN + DRIZZLE_ERRMSG_SIZE];
1829
1819
uint32_t length;
1830
session->getClient()->store(table_name);
1831
session->getClient()->store(operator_name);
1832
session->getClient()->store(STRING_WITH_LEN("error"));
1820
session->client->store(table_name);
1821
session->client->store(operator_name);
1822
session->client->store(STRING_WITH_LEN("error"));
1833
1823
length= snprintf(buff, sizeof(buff), ER(ER_OPEN_AS_READONLY),
1835
session->getClient()->store(buff, length);
1836
transaction_services.autocommitOrRollback(*session, false);
1825
session->client->store(buff, length);
1826
transaction_services.autocommitOrRollback(session, false);
1837
1827
session->endTransaction(COMMIT);
1838
1828
session->close_thread_tables();
1839
1829
lex->reset_query_tables_list(false);
1840
1830
table->table=0; // For query cache
1841
if (session->getClient()->flush())
1831
if (session->client->flush())
1846
1836
/* Close all instances of the table to allow repair to rename files */
1847
if (lock_type == TL_WRITE && table->table->getShare()->getVersion())
1837
if (lock_type == TL_WRITE && table->table->s->version)
1849
table::Cache::singleton().mutex().lock(); /* Lock type is TL_WRITE and we lock to repair the table */
1850
const char *old_message=session->enter_cond(COND_refresh, table::Cache::singleton().mutex(),
1851
"Waiting to get writelock");
1852
session->abortLock(table->table);
1853
identifier::Table identifier(table->table->getShare()->getSchemaName(), table->table->getShare()->getTableName());
1854
table::Cache::singleton().removeTable(session, identifier, RTFC_WAIT_OTHER_THREAD_FLAG | RTFC_CHECK_KILLED_FLAG);
1839
pthread_mutex_lock(&LOCK_open); /* Lock type is TL_WRITE and we lock to repair the table */
1840
const char *old_message=session->enter_cond(&COND_refresh, &LOCK_open,
1841
"Waiting to get writelock");
1842
mysql_lock_abort(session,table->table);
1843
remove_table_from_cache(session, table->table->s->getSchemaName(),
1844
table->table->s->table_name.str,
1845
RTFC_WAIT_OTHER_THREAD_FLAG |
1846
RTFC_CHECK_KILLED_FLAG);
1855
1847
session->exit_cond(old_message);
1856
if (session->getKilled())
1848
if (session->killed)
1858
1850
open_for_modify= 0;
1888
1880
char buf[ERRMSGSIZE+20];
1889
1881
uint32_t length=snprintf(buf, ERRMSGSIZE,
1890
1882
ER(ER_CHECK_NOT_IMPLEMENTED), operator_name);
1891
session->getClient()->store(STRING_WITH_LEN("note"));
1892
session->getClient()->store(buf, length);
1883
session->client->store(STRING_WITH_LEN("note"));
1884
session->client->store(buf, length);
1896
1888
case HA_ADMIN_OK:
1897
session->getClient()->store(STRING_WITH_LEN("status"));
1898
session->getClient()->store(STRING_WITH_LEN("OK"));
1889
session->client->store(STRING_WITH_LEN("status"));
1890
session->client->store(STRING_WITH_LEN("OK"));
1901
1893
case HA_ADMIN_FAILED:
1902
session->getClient()->store(STRING_WITH_LEN("status"));
1903
session->getClient()->store(STRING_WITH_LEN("Operation failed"));
1894
session->client->store(STRING_WITH_LEN("status"));
1895
session->client->store(STRING_WITH_LEN("Operation failed"));
1906
1898
case HA_ADMIN_REJECT:
1907
session->getClient()->store(STRING_WITH_LEN("status"));
1908
session->getClient()->store(STRING_WITH_LEN("Operation need committed state"));
1899
session->client->store(STRING_WITH_LEN("status"));
1900
session->client->store(STRING_WITH_LEN("Operation need committed state"));
1909
1901
open_for_modify= false;
1912
1904
case HA_ADMIN_ALREADY_DONE:
1913
session->getClient()->store(STRING_WITH_LEN("status"));
1914
session->getClient()->store(STRING_WITH_LEN("Table is already up to date"));
1905
session->client->store(STRING_WITH_LEN("status"));
1906
session->client->store(STRING_WITH_LEN("Table is already up to date"));
1917
1909
case HA_ADMIN_CORRUPT:
1918
session->getClient()->store(STRING_WITH_LEN("error"));
1919
session->getClient()->store(STRING_WITH_LEN("Corrupt"));
1910
session->client->store(STRING_WITH_LEN("error"));
1911
session->client->store(STRING_WITH_LEN("Corrupt"));
1923
1915
case HA_ADMIN_INVALID:
1924
session->getClient()->store(STRING_WITH_LEN("error"));
1925
session->getClient()->store(STRING_WITH_LEN("Invalid argument"));
1916
session->client->store(STRING_WITH_LEN("error"));
1917
session->client->store(STRING_WITH_LEN("Invalid argument"));
1928
1920
default: // Probably HA_ADMIN_INTERNAL_ERROR
1940
1932
if (table->table)
1942
1934
if (fatal_error)
1944
table->table->getMutableShare()->resetVersion(); // Force close of table
1935
table->table->s->version=0; // Force close of table
1946
1936
else if (open_for_modify)
1948
if (table->table->getShare()->getType())
1938
if (table->table->s->tmp_table)
1950
1939
table->table->cursor->info(HA_STATUS_CONST);
1954
boost::unique_lock<boost::mutex> lock(table::Cache::singleton().mutex());
1955
identifier::Table identifier(table->table->getShare()->getSchemaName(), table->table->getShare()->getTableName());
1956
table::Cache::singleton().removeTable(session, identifier, RTFC_NO_FLAG);
1942
pthread_mutex_lock(&LOCK_open);
1943
remove_table_from_cache(session, table->table->s->getSchemaName(),
1944
table->table->s->table_name.str, RTFC_NO_FLAG);
1945
pthread_mutex_unlock(&LOCK_open);
1960
transaction_services.autocommitOrRollback(*session, false);
1949
transaction_services.autocommitOrRollback(session, false);
1961
1950
session->endTransaction(COMMIT);
1962
1951
session->close_thread_tables();
1963
1952
table->table=0; // For query cache
1964
if (session->getClient()->flush())
1953
if (session->client->flush())
1970
We have to write the query before we unlock the named table.
1972
Since temporary tables are not replicated under row-based
1973
replication, CREATE TABLE ... LIKE ... needs special
1974
treatement. We have four cases to consider, according to the
1975
following decision table:
1977
==== ========= ========= ==============================
1978
Case Target Source Write to binary log
1979
==== ========= ========= ==============================
1980
1 normal normal Original statement
1981
2 normal temporary Generated statement
1982
3 temporary normal Nothing
1983
4 temporary temporary Nothing
1984
==== ========= ========= ==============================
1986
static bool replicateCreateTableLike(Session *session, TableList *table, Table *name_lock,
1987
bool is_src_table_tmp, bool is_if_not_exists)
1989
if (is_src_table_tmp)
1992
String query(buf, sizeof(buf), system_charset_info);
1993
query.length(0); // Have to zero it since constructor doesn't
1997
Here we open the destination table, on which we already have
1998
name-lock. This is needed for store_create_info() to work.
1999
The table will be closed by unlink_open_table() at the end
2002
table->table= name_lock;
2003
pthread_mutex_lock(&LOCK_open); /* Open new table we have just acquired */
2004
if (session->reopen_name_locked_table(table, false))
2006
pthread_mutex_unlock(&LOCK_open);
2009
pthread_mutex_unlock(&LOCK_open);
2011
int result= store_create_info(table, &query, is_if_not_exists);
2013
assert(result == 0); // store_create_info() always return 0
2014
write_bin_log(session, query.ptr());
2018
write_bin_log(session, session->query.c_str());
1981
2025
Create a new table by copying from source table
1983
2027
Altough exclusive name-lock on target table protects us from concurrent
1984
2028
DML and DDL operations on it we still want to wrap .FRM creation and call
1985
2029
to plugin::StorageEngine::createTable() in critical section protected by
1986
table::Cache::singleton().mutex() in order to provide minimal atomicity against operations which
2030
LOCK_open in order to provide minimal atomicity against operations which
1987
2031
disregard name-locks, like I_S implementation, for example. This is a
1988
2032
temporary and should not be copied. Instead we should fix our code to
1989
2033
always honor name-locks.
1991
Also some engines (e.g. NDB cluster) require that table::Cache::singleton().mutex() should be held
2035
Also some engines (e.g. NDB cluster) require that LOCK_open should be held
1992
2036
during the call to plugin::StorageEngine::createTable().
1993
2037
See bug #28614 for more info.
1995
static bool create_table_wrapper(Session &session,
1996
const message::Table& create_table_proto,
1997
identifier::Table::const_reference destination_identifier,
1998
identifier::Table::const_reference source_identifier,
2039
static bool create_table_wrapper(Session &session, const message::Table& create_table_proto,
2040
TableIdentifier &destination_identifier,
2041
TableIdentifier &src_table,
1999
2042
bool is_engine_set)
2001
// We require an additional table message because during parsing we used
2002
// a "new" message and it will not have all of the information that the
2003
// source table message would have.
2004
message::Table new_table_message;
2005
drizzled::error_t error;
2007
message::table::shared_ptr source_table_message= plugin::StorageEngine::getTableMessage(session, source_identifier, error);
2009
if (not source_table_message)
2011
my_error(ER_TABLE_UNKNOWN, source_identifier);
2015
new_table_message.CopyFrom(*source_table_message);
2044
int protoerr= EEXIST;
2045
message::Table new_proto;
2046
message::Table src_proto;
2048
protoerr= plugin::StorageEngine::getTableDefinition(session,
2051
new_proto.CopyFrom(src_proto);
2017
2053
if (destination_identifier.isTmp())
2019
new_table_message.set_type(message::Table::TEMPORARY);
2055
new_proto.set_type(message::Table::TEMPORARY);
2023
new_table_message.set_type(message::Table::STANDARD);
2059
new_proto.set_type(message::Table::STANDARD);
2026
2062
if (is_engine_set)
2028
new_table_message.mutable_engine()->set_name(create_table_proto.engine().name());
2064
message::Table::StorageEngine *protoengine;
2066
protoengine= new_proto.mutable_engine();
2067
protoengine->set_name(create_table_proto.engine().name());
2031
2070
{ // We now do a selective copy of elements on to the new table.
2032
new_table_message.set_name(create_table_proto.name());
2033
new_table_message.set_schema(create_table_proto.schema());
2034
new_table_message.set_catalog(create_table_proto.catalog());
2071
new_proto.set_name(create_table_proto.name());
2072
new_proto.set_schema(create_table_proto.schema());
2073
new_proto.set_catalog(create_table_proto.catalog());
2037
/* Fix names of foreign keys being added */
2038
for (int32_t j= 0; j < new_table_message.fk_constraint_size(); j++)
2076
if (protoerr && protoerr != EEXIST)
2040
if (new_table_message.fk_constraint(j).has_name())
2042
std::string name(new_table_message.name());
2045
name.append("_ibfk_");
2046
snprintf(number, sizeof(number), "%d", j+1);
2047
name.append(number);
2049
message::Table::ForeignKeyConstraint *pfkey= new_table_message.mutable_fk_constraint(j);
2050
pfkey->set_name(name);
2078
if (errno == ENOENT)
2079
my_error(ER_BAD_DB_ERROR,MYF(0), destination_identifier.getSchemaName().c_str());
2081
my_error(ER_CANT_CREATE_FILE, MYF(0), destination_identifier.getPath().c_str(), errno);
2055
2087
As mysql_truncate don't work on a new table at this stage of
2056
creation, instead create the table directly (for both normal and temporary tables).
2088
creation, instead create the table directly (for both normal
2089
and temporary tables).
2058
bool success= plugin::StorageEngine::createTable(session,
2059
destination_identifier,
2062
if (success && not destination_identifier.isTmp())
2064
TransactionServices &transaction_services= TransactionServices::singleton();
2065
transaction_services.createTable(session, new_table_message);
2091
int err= plugin::StorageEngine::createTable(session,
2092
destination_identifier,
2095
return err ? false : true;
2072
2099
Create a table identical to the specified table
2102
mysql_create_like_table()
2076
2103
session Thread object
2077
2104
table Table list element for target table
2078
2105
src_table Table list element for source table
2086
bool create_like_table(Session* session,
2087
identifier::Table::const_reference destination_identifier,
2088
identifier::Table::const_reference source_identifier,
2089
message::Table &create_table_proto,
2090
bool is_if_not_exists,
2113
bool mysql_create_like_table(Session* session,
2114
TableIdentifier &destination_identifier,
2115
TableList* table, TableList* src_table,
2116
message::Table &create_table_proto,
2117
bool is_if_not_exists,
2120
Table *name_lock= 0;
2121
char *db= table->db;
2122
char *table_name= table->table_name;
2093
2123
bool res= true;
2094
bool table_exists= false;
2128
By opening source table we guarantee that it exists and no concurrent
2129
DDL operation will mess with it. Later we also take an exclusive
2130
name-lock on target table name, which makes copying of .frm cursor,
2131
call to plugin::StorageEngine::createTable() and binlogging atomic
2132
against concurrent DML and DDL operations on target table.
2133
Thus by holding both these "locks" we ensure that our statement is
2134
properly isolated from all concurrent operations which matter.
2136
if (session->open_tables_from_list(&src_table, ¬_used))
2139
TableIdentifier src_identifier(src_table->table->s->getSchemaName(),
2140
src_table->table->s->table_name.str, src_table->table->s->tmp_table);
2097
2145
Check that destination tables does not exist. Note that its name
2098
2146
was already checked when it was added to the table list.
2100
For temporary tables we don't aim to grab locks.
2148
bool table_exists= false;
2102
2149
if (destination_identifier.isTmp())
2104
if (session->find_temporary_table(destination_identifier))
2151
if (session->find_temporary_table(db, table_name))
2106
2153
table_exists= true;
2110
bool was_created= create_table_wrapper(*session,
2112
destination_identifier,
2115
if (not was_created) // This is pretty paranoid, but we assume something might not clean up after itself
2117
(void) session->rm_temporary_table(destination_identifier, true);
2119
else if (not session->open_temporary_table(destination_identifier))
2121
// We created, but we can't open... also, a hack.
2122
(void) session->rm_temporary_table(destination_identifier, true);
2130
else // Standard table which will require locks.
2132
Table *name_lock= 0;
2134
if (session->lock_table_name_if_not_cached(destination_identifier, &name_lock))
2158
if (session->lock_table_name_if_not_cached(db, table_name, &name_lock))
2138
boost_unique_lock_t lock(table::Cache::singleton().mutex()); /* unlink open tables for create table like*/
2162
pthread_mutex_lock(&LOCK_open); /* unlink open tables for create table like*/
2139
2163
session->unlink_open_table(name_lock);
2164
pthread_mutex_unlock(&LOCK_open);
2185
2184
char warn_buff[DRIZZLE_ERRMSG_SIZE];
2186
2185
snprintf(warn_buff, sizeof(warn_buff),
2187
ER(ER_TABLE_EXISTS_ERROR), destination_identifier.getTableName().c_str());
2186
ER(ER_TABLE_EXISTS_ERROR), table_name);
2188
2187
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
2189
ER_TABLE_EXISTS_ERROR, warn_buff);
2193
my_error(ER_TABLE_EXISTS_ERROR, destination_identifier);
2188
ER_TABLE_EXISTS_ERROR,warn_buff);
2193
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name);
2196
else // Otherwise we create the table
2198
pthread_mutex_lock(&LOCK_open); /* We lock for CREATE TABLE LIKE to copy table definition */
2199
was_created= create_table_wrapper(*session, create_table_proto, destination_identifier,
2200
src_identifier, is_engine_set);
2201
pthread_mutex_unlock(&LOCK_open);
2203
// So we blew the creation of the table, and we scramble to clean up
2204
// anything that might have been created (read... it is a hack)
2205
if (not was_created)
2207
if (destination_identifier.isTmp())
2209
(void) session->rm_temporary_table(destination_identifier);
2213
quick_rm_table(*session, destination_identifier);
2216
else if (destination_identifier.isTmp() && not session->open_temporary_table(destination_identifier))
2218
// We created, but we can't open... also, a hack.
2219
(void) session->rm_temporary_table(destination_identifier);
2223
if (not destination_identifier.isTmp())
2225
bool rc= replicateCreateTableLike(session, table, name_lock, (src_table->table->s->tmp_table), is_if_not_exists);
2235
pthread_mutex_lock(&LOCK_open); /* unlink open tables for create table like*/
2236
session->unlink_open_table(name_lock);
2237
pthread_mutex_unlock(&LOCK_open);
2202
bool analyze_table(Session* session, TableList* tables, HA_CHECK_OPT* check_opt)
2244
bool mysql_analyze_table(Session* session, TableList* tables, HA_CHECK_OPT* check_opt)
2204
2246
thr_lock_type lock_type = TL_READ_NO_INSERT;
2206
return(admin_table(session, tables, check_opt,
2248
return(mysql_admin_table(session, tables, check_opt,
2207
2249
"analyze", lock_type, true,
2208
2250
&Cursor::ha_analyze));
2212
bool check_table(Session* session, TableList* tables,HA_CHECK_OPT* check_opt)
2254
bool mysql_check_table(Session* session, TableList* tables,HA_CHECK_OPT* check_opt)
2214
2256
thr_lock_type lock_type = TL_READ_NO_INSERT;
2216
return(admin_table(session, tables, check_opt,
2258
return(mysql_admin_table(session, tables, check_opt,
2217
2259
"check", lock_type,
2219
2261
&Cursor::ha_check));