Table Discovery
table It is not always necessary in MariaDB to run an explicit CREATE TABLE
for a table to appear. Sometimes a table may already exist in the storage engine, but the server knows nothing about it, because there is no .frm
file for this table. This can happen for various reasons, for example, for a cluster engine the table might have been created in the cluster by another MariaDB server. But no matter what the reason is, there is a mechanism for an engine to tell the server that the table already exists. This mechanism is called table discovery and if an engine wants the server to discover its tables, the engine should support the discovery API.
There are three parts of it.
First, when a server finds that a table (for example, mentioned in the SELECT
query) does not exist, it asks every engine whether it knows anything about this table.
And then it requests the table's .frm
file image from the engine.
Second, there can be a situation when the server thinks that the table exists (it found and successfully read the .frm
file), but from the engine point of view the .frm
file is incorrect. For example, the table was already deleted from the engine, or its definition was modified (again, modified only in the engine). In this case the .frm
file is outdated, and the server needs to re-discover the table.
And third, a user might want to retrieve a list of tables in a specific database. With SHOW TABLES
or by quering INFORMATION_SCHEMA
tables. The user expects to see all tables, but the server cannot discover them one by one, because it doesnt know table names. In this case, the server uses a special discovery method.