=== modified file 'sql/sql_parse.cc' --- sql/sql_parse.cc 2009-04-22 22:12:25 +0000 +++ sql/sql_parse.cc 2009-04-28 02:34:05 +0000 @@ -41,6 +41,8 @@ #include "../storage/maria/ha_maria.h" #endif +#include "si_objects.h" + /** @defgroup Runtime_Environment Runtime Environment @{ @@ -4119,6 +4121,56 @@ end_with_restore_list: break; case SQLCOM_BEGIN: + { + // Use si_objects so that table share is stored in the cache. + + String db_name("db1",system_charset_info); + obs::Obj_iterator *it= obs::get_db_tables(thd, &db_name); + DBUG_ASSERT(it); + obs::Obj *t; + + while (t= it->next()) + { + String buf; + + fprintf(stderr,"xx: serializing table %s\n", t->get_name()->ptr()); + t->serialize(thd, &buf); + delete t; + } + + delete it; + + // Now open and scan the table. + + TABLE_LIST tl; + + tl.init_one_table("db1",3,"t1",2,"t1",TL_READ); + tl.mdl_request= MDL_request::create(0, tl.db, tl.table_name, thd->mem_root); + + fprintf(stderr,"xx: openning table t1\n"); + flush_tables(); + int res= open_and_lock_tables(thd, &tl); + DBUG_ASSERT(!res); + + handler *hdl= tl.table->file; + + fprintf(stderr,"xx: scanning table t1\n"); + + hdl->ha_rnd_init(1); + + res= hdl->rnd_next(tl.table->record[0]); + DBUG_ASSERT(res >= 0); + fprintf(stderr,"xx: rnd_next() should return %d and returned %d\n", + HA_ERR_END_OF_FILE, res); + DBUG_ASSERT(res == HA_ERR_END_OF_FILE); + + hdl->ha_rnd_end(); + + close_thread_tables(thd); + + my_ok(thd); + break; + } DEBUG_SYNC(thd, "before_begin_trans"); if (trans_begin(thd, lex->start_transaction_opt)) goto error;