--- ./mysql-5.1.30/sql/sql_insert.cc.ccorig Fri Nov 14 11:37:20 2008 +++ ./mysql-5.1.30/sql/sql_insert.cc Fri Dec 5 14:59:07 2008 @@ -3473,35 +3473,12 @@ } DBUG_RETURN(table); } -int -select_create::prepare(List &values, SELECT_LEX_UNIT *u) -{ - MYSQL_LOCK *extra_lock= NULL; - DBUG_ENTER("select_create::prepare"); - - TABLEOP_HOOKS *hook_ptr= NULL; - /* - For row-based replication, the CREATE-SELECT statement is written - in two pieces: the first one contain the CREATE TABLE statement - necessary to create the table and the second part contain the rows - that should go into the table. - - For non-temporary tables, the start of the CREATE-SELECT - implicitly commits the previous transaction, and all events - forming the statement will be stored the transaction cache. At end - of the statement, the entire statement is committed as a - transaction, and all events are written to the binary log. - - On the master, the table is locked for the duration of the - statement, but since the CREATE part is replicated as a simple - statement, there is no way to lock the table for accesses on the - slave. Hence, we have to hold on to the CREATE part of the - statement until the statement has finished. - */ + // dt: we need to move MY_HOOLS class declaration outside of + // select_create::prepare() because otherwise it breaks linking class MY_HOOKS : public TABLEOP_HOOKS { public: MY_HOOKS(select_create *x, TABLE_LIST *create_table, TABLE_LIST *select_tables) : ptr(x), all_tables(*create_table) @@ -3527,10 +3504,39 @@ } select_create *ptr; TABLE_LIST all_tables; }; + + + + +int +select_create::prepare(List &values, SELECT_LEX_UNIT *u) +{ + MYSQL_LOCK *extra_lock= NULL; + DBUG_ENTER("select_create::prepare"); + + TABLEOP_HOOKS *hook_ptr= NULL; + /* + For row-based replication, the CREATE-SELECT statement is written + in two pieces: the first one contain the CREATE TABLE statement + necessary to create the table and the second part contain the rows + that should go into the table. + + For non-temporary tables, the start of the CREATE-SELECT + implicitly commits the previous transaction, and all events + forming the statement will be stored the transaction cache. At end + of the statement, the entire statement is committed as a + transaction, and all events are written to the binary log. + + On the master, the table is locked for the duration of the + statement, but since the CREATE part is replicated as a simple + statement, there is no way to lock the table for accesses on the + slave. Hence, we have to hold on to the CREATE part of the + statement until the statement has finished. + */ MY_HOOKS hooks(this, create_table, select_tables); hook_ptr= &hooks; unit= u;