?

Log in

No account? Create an account

Engine Discovery

« previous entry | next entry »
Jul. 16th, 2007 | 08:07 am

(I am writing this as a note to myself, more then as a note to
others...)

The MySQL Engine API supports a concept of "discovery". Discovery
allows an engine to say "yes this table exists, and here is the
definition".

To implement this, you need to create the following function in your
engine:

int archive_discover(handlerton *hton, THD* thd, const char *db,
const char *name,
const void** frmblob,
uint* frmlen);

This is a function for the handlerton, and is not a method of the
handler class.

Table discovery flow of execution is simple. Whenever a table is
opened, MySQL looks for a corresponding table or view definition. If
neither exists then the discovery functions are called for each of
the engines that have registered a discovery function. In the
discovery an engine can return either 1 if the table is not found, or
zero if it is found.

The engine must return the binary form of the table (aka the FRM).
The server will take responsibility for the memory associated with
the frm. The limitation to this is that you must have an FRM in the
first place.

Link | Leave a comment |

Comments {5}

(no subject)

from: jamesd
date: Jul. 16th, 2007 10:09 pm (UTC)
Link

MySQL also needs to do ask efficiently, perhaps hashed remembrance of last engine to have the table, configured to be efficient up to at least 200,000 tables in use, better 500,000. Maybe fallback to most commonly used engine as first fallback. My assumption is that table discovery is an inefficient process for a significant number of engines, possibly involving disk or remote network access.

Reply | Thread

Brian "Krow" Aker

(no subject)

from: krow
date: Jul. 17th, 2007 12:14 am (UTC)
Link

The table definition cache was created to solve the problem you describe. Discovery is dynamic, how many applications do dynamic? Not many at all.

Reply | Parent | Thread

(no subject)

from: jamesd
date: Jul. 17th, 2007 12:38 am (UTC)
Link

Yes, dynamic is very good.

Reply | Parent | Thread

Re: Engine Discovery

from: paul_mccullagh
date: Jul. 17th, 2007 09:20 am (UTC)
Link

Hi Brian,

Thanks for the note to yourself, I was just looking for this stuff. I have a couple of questions:

How would you recommend generating the FRM data?

The discovery method suggests that such tables will not be displayed by SHOW TABLES. Is this the case?

Reply | Thread

Brian "Krow" Aker

Re: Engine Discovery

from: krow
date: Jul. 17th, 2007 05:12 pm (UTC)
Link

These tables won't show up in "show tables" unless they have already been discovered.

Generating an FRM is hard... to date no one has done it. I suspect its possible, but I have never written the code to do it. I have hypothesized that it would be possible just to issue a "CREATE TEMP table" type SQL, and snag the FRM from it.

Reply | Parent | Thread