It is about "MySQL plugin interface: syntax extensions for CREATE
TABLE" and for them who writes thier own engines.
If you have some ideas or you see something wrong please say ASAP.
Syntax will looks like this:
CREATE TABLE table(
id INT ENGINE_OPTIONS(OPT1=123, OPT2='someval',OPT3=aflag),
INDEX USING BTREE (id)
) ENGINE = MEMORY
ENGINE_OPTIONS(loc1='/mnt/d1/bigdat/mine',loc2=/mnt/d2/bigdata/mine') ;
But we do not discuss syntax now but interface between plugin and MySQL:
-----------------------------------------------------------------
Proposed Implementation:
Plugin supply 3 my_getopt-like list of parameters (for table/keys/fields)
where offset from beginning of some descriptor structure mentioned for writing
parsed result or default value in, Also it provide sizes of 3 structures (for
table/keys/fields).
MySQL server during parsing CREATE/ALTER statement or FRM file (actually
just after parsing but it is not visible for plugin) allocates 1 structure of
given size for table and 2 arrayes for fields and keys and fill them according
to descriptor arrays (with default value or found value).
Parser match keys (enums/sets) case insensitively and use system_charset for
this task.
If parser meets unrecognised key it issue error/warning/nothing (depend on
where it happened see following section)
If parser meets unrecognised value (for enum/set or numeric value aout of range
or without numbers) it fill structure with default value and issue
error/warning/nothing (depend on where it happened see following section).
Error/warning regulation:
- opening table (reading frm) does not issue warnings nor errors.
- keys which come from parser (CREATE TABLE and ALTER TABLE when we change the
parameters) issue errors (by default) or warnings (depend on SQL mode)
- other ALTER TABLE changes (where the options come from frm) like changing
engine or replication of CREATE/ALTER on slave issue warnings on incorrect key
or its value.
Internally (not visible for plugin) after parsing CREATE/ALTER TABLE or reading
FRM the set of key/value represented as lists of structures which contains
LEX_STRING of key and value. The lists connected to table, field or key
descriptor. In frm we store total number of parameters and length of whole
parameters block, for every parameter we store type (table/key/field), key and
value as string with length and number of key/field if it is key/field
parameter.
KNOWN PROBLEMS:
1. Mistyping in parameter name or value will lead only to warning.
Solution: Use SQL mode with strict parameter check (As we decided it will be default).
2. Accidentally equally named parameters which mean different in different
engines and be used when engine changed.
Solution: recommend engine writers prefix the key with engine name or some
common name for group of engines if they want to share parameters.
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Oleksandr Byelkin <sanja@stripped>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer
/_/ /_/\_, /___/\___\_\___/ Lugansk, Ukraine
<___/ www.mysql.com