Commit 6efa5efa authored by Michael Widenius's avatar Michael Widenius

Fixed that rpl_row_create_table can be run with --ps-protocol

As part of the fix we don't anymore generate a create table statement when doing a
CREATE TABLE IF NOT EXISTS table_that_exist LiKE temporary_table
if the 'table_that_exist' existed.

This is because it's not self evident if we should generate a create statement
matching the existing table or the temporary_table. 
The old code generated a table like the existing table in row based replication and like the temporary table
in statement based replication.
It's better to ensure that both cases works the same way.

mysql-test/suite/rpl/r/rpl_row_create_table.result:
  Updated results
  (Now we don't anymore CREATE TABLE IF NOT EXISTS LIKE if the table existed)
sql/sql_base.cc:
  More DBUG_PRINT
sql/sql_error.cc:
  More DBUG_PRINT
sql/sql_table.cc:
  Don't generate a create table statement when doing a
  CREATE TABLE IF NOT EXISTS table_that_exist like temporary_table if the table existed.
parent d12c7adf
...@@ -439,7 +439,6 @@ CREATE TABLE IF NOT EXISTS bug48506_t3 LIKE t7; ...@@ -439,7 +439,6 @@ CREATE TABLE IF NOT EXISTS bug48506_t3 LIKE t7;
CREATE TABLE IF NOT EXISTS bug48506_t4 LIKE t7; CREATE TABLE IF NOT EXISTS bug48506_t4 LIKE t7;
SHOW TABLES LIKE 'bug48506%'; SHOW TABLES LIKE 'bug48506%';
Tables_in_test (bug48506%) Tables_in_test (bug48506%)
bug48506_t4
DROP VIEW IF EXISTS bug48506_t1, bug48506_t2, bug48506_t3; DROP VIEW IF EXISTS bug48506_t1, bug48506_t2, bug48506_t3;
DROP TEMPORARY TABLES t7; DROP TEMPORARY TABLES t7;
DROP TABLES t4, t5; DROP TABLES t4, t5;
......
...@@ -2369,6 +2369,8 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, ...@@ -2369,6 +2369,8 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
{ {
if (share->tdc.flushed) if (share->tdc.flushed)
{ {
DBUG_PRINT("info", ("Found old share version: %lu current: %lu",
share->tdc.version, tdc_refresh_version()));
/* /*
We already have an MDL lock. But we have encountered an old We already have an MDL lock. But we have encountered an old
version of table in the table definition cache which is possible version of table in the table definition cache which is possible
......
...@@ -464,6 +464,7 @@ Diagnostics_area::set_error_status(uint sql_errno, ...@@ -464,6 +464,7 @@ Diagnostics_area::set_error_status(uint sql_errno,
const Sql_condition *error_condition) const Sql_condition *error_condition)
{ {
DBUG_ENTER("set_error_status"); DBUG_ENTER("set_error_status");
DBUG_PRINT("enter", ("error: %d", sql_errno));
/* /*
Only allowed to report error if has not yet reported a success Only allowed to report error if has not yet reported a success
The only exception is when we flush the message to the client, The only exception is when we flush the message to the client,
......
...@@ -5096,6 +5096,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -5096,6 +5096,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
bool is_trans= FALSE; bool is_trans= FALSE;
bool do_logging= FALSE; bool do_logging= FALSE;
uint not_used; uint not_used;
int create_res;
DBUG_ENTER("mysql_create_like_table"); DBUG_ENTER("mysql_create_like_table");
/* /*
...@@ -5171,9 +5172,10 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -5171,9 +5172,10 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
if ((local_create_info.table= thd->lex->query_tables->table)) if ((local_create_info.table= thd->lex->query_tables->table))
pos_in_locked_tables= local_create_info.table->pos_in_locked_tables; pos_in_locked_tables= local_create_info.table->pos_in_locked_tables;
res= (mysql_create_table_no_lock(thd, table->db, table->table_name, res= ((create_res=
mysql_create_table_no_lock(thd, table->db, table->table_name,
&local_create_info, &local_alter_info, &local_create_info, &local_alter_info,
&is_trans, C_ORDINARY_CREATE) > 0); &is_trans, C_ORDINARY_CREATE)) > 0);
/* Remember to log if we deleted something */ /* Remember to log if we deleted something */
do_logging= thd->log_current_statement; do_logging= thd->log_current_statement;
if (res) if (res)
...@@ -5232,7 +5234,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -5232,7 +5234,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
Case Target Source Write to binary log Case Target Source Write to binary log
==== ========= ========= ============================== ==== ========= ========= ==============================
1 normal normal Original statement 1 normal normal Original statement
2 normal temporary Generated statement 2 normal temporary Generated statement if the table
was created.
3 temporary normal Nothing 3 temporary normal Nothing
4 temporary temporary Nothing 4 temporary temporary Nothing
==== ========= ========= ============================== ==== ========= ========= ==============================
...@@ -5247,13 +5250,14 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -5247,13 +5250,14 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN); Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN);
bool new_table= FALSE; // Whether newly created table is open. bool new_table= FALSE; // Whether newly created table is open.
if (create_res != 0)
{
/* /*
The condition avoids a crash as described in BUG#48506. Other Table or view with same name already existed and we where using
binlogging problems related to CREATE TABLE IF NOT EXISTS LIKE IF EXISTS. Continue without logging anything.
when the existing object is a view will be solved by BUG 47442.
*/ */
if (!table->view) goto err;
{ }
if (!table->table) if (!table->table)
{ {
TABLE_LIST::enum_open_strategy save_open_strategy; TABLE_LIST::enum_open_strategy save_open_strategy;
...@@ -5280,7 +5284,6 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -5280,7 +5284,6 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
} }
new_table= TRUE; new_table= TRUE;
} }
}
/* /*
We have to re-test if the table was a view as the view may not We have to re-test if the table was a view as the view may not
have been opened until just above. have been opened until just above.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment