Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.5
Description
Other IF EXISTS syntaxs return a Note. E.g:
|
MariaDB [test]> ALTER TABLE IF EXISTS non_exists FORCE;
|
Query OK, 0 rows affected, 1 warning (7.918 sec)
|
|
MariaDB [test]> show warnings;
|
+-------+------+---------------------------------------+
|
| Level | Code | Message |
|
+-------+------+---------------------------------------+
|
| Error | 1146 | Table 'test.non_exists' doesn't exist |
|
+-------+------+---------------------------------------+
|
1 row in set (0.000 sec)
|
|
MariaDB [test]> show tables;
|
+----------------+
|
| Tables_in_test |
|
+----------------+
|
| v2 |
|
+----------------+
|
1 row in set (0.001 sec)
|
|
MariaDB [test]> create table if not exists v2 (yo int);
|
Query OK, 0 rows affected, 1 warning (0.000 sec)
|
|
MariaDB [test]> show warnings;
|
+-------+------+---------------------------+
|
| Level | Code | Message |
|
+-------+------+---------------------------+
|
| Note | 1050 | Table 'v2' already exists |
|
+-------+------+--------------------------
|
Cause mysql_alter_table just clears the error:
sql/sql_table.cc |
9645 error= open_tables(thd, &table_list, &tables_opened, 0,
|
9646 &alter_prelocking_strategy);
|
9647 thd->open_options&= ~HA_OPEN_FOR_ALTER;
|
9648
|
9649 if (unlikely(error))
|
9650 {
|
9651 if (if_exists)
|
(gdb) list
|
9652 {
|
9653 int tmp_errno= thd->get_stmt_da()->sql_errno();
|
9654 if (tmp_errno == ER_NO_SUCH_TABLE)
|
9655 {
|
9656 /*
|
9657 ALTER TABLE IF EXISTS was used on not existing table
|
9658 We have to log the query on a slave as the table may be a shared one
|
9659 from the master and we need to ensure that the next slave can see
|
9660 the statement as this slave may not have the table shared
|
9661 */
|
(gdb) list
|
9662 thd->clear_error();
|
9663 DBUG_RETURN(log_and_ok(thd));
|
9664 }
|
Compared to adding a handler like sql/sql_sequence.cc: Sql_cmd_alter_sequence::execute:
if (if_exists()) |
thd->push_internal_handler(&no_such_table_handler);
|
error= open_and_lock_tables(thd, first_table, FALSE, 0);
|
if (if_exists()) |
{
|
trapped_errors= no_such_table_handler.safely_trapped_errors();
|
thd->pop_internal_handler();
|
}
|