From: Sergei Golubchik Date: June 4 2009 2:13pm Subject: Re: About definition of I_S tables List-Archive: http://lists.mysql.com/internals/36836 Message-Id: <20090604141346.GA12255@janus.mylan> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi, scut_tang! On Jun 04, scut_tang wrote: > >Yes, but I think it would be easier to go just a bit deeper. That is to > >keep open_table() and open_table_from_share() as is, and implement the > >function to create a TABLE_SHARE without an frm file. When TABLE_SHARE > >exists, open_table_from_share() will work normally, no need to modify > >it. > >And the simplest way to create a custom TABLE_SHARE, I suppose, is a > >table discovery - ha_create_table_from_engine() -> ha_discover(). > > I browse those function source code today. They drive me crazy. > What do "Try to discover table from engine", "table exist in handler" and > "table in engine" mean? Could you give some example? > I know MySQL server will reach ha_create_table_from_engine(), when a > query as "SELECT * FROM Whatever.none". Whatever.none is not exist. > The function will return a result means table did not exist. In what > situation, it will return table created ok? > > Could you say something more about ha_discover() in detail? Sure. "Table discovery" is a mechanism for a server to, well, discover tables that already exist in the engine. Originally it was developed for NDB. Indeed, in the cluster environment there could be many MySQL daemons connected to one cluster. And a table created from one of these daemons should automatically be visible in all others. This is implemented via "table discovery" - when a server doesn't find an frm file for a table it asks the engine "does this table exists in the engine?", and the engine can answer "yes, here's an frm file for this table". It's transparent for the end user, it looks like the table always existed. But discovery is more useful than just for the Cluster. For example, if there would be an engine that reads XLS files, with the table discovery one can just copy an XLS file into MySQL datadir, and start SELECT'ing from it. Without discovery one would have to do CREATE TABLE with exactly the same structure as the table in the XLS file has, to create a matching frm file. With discovery such an frm file can be created automatically. Similarly, I suggest that we take use of this feature and allow the server to "discover" I_S tables automatically. There are few methods in the handlerton that are used for discovery. The main is discover(), but there are also find_files() and table_exists_in_engine(). Regards / Mit vielen Grüßen, Sergei -- __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Sergei Golubchik / /|_/ / // /\ \/ /_/ / /__ Principal Software Engineer/Server Architect /_/ /_/\_, /___/\___\_\___/ Sun Microsystems GmbH, HRB München 161028 <___/ Sonnenallee 1, 85551 Kirchheim-Heimstetten Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel Vorsitzender des Aufsichtsrates: Martin Häring