Create table with engine=OQGRAPH should check that the DATA_TABLE exists with the given origid, destid and if specified, weightid fields.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OQGRAPH |
Fix Committed
|
Undecided
|
Andrew McDonnell |
Bug Description
Currently it is possible to CREATE a ENGINE=OQGRAPH with a non-existent DATA_TABLE, or with ORIGID, DESTID or WEIGH attribute values for which a column does not exist in DATA_TABLE.
The 'table' created with ENGINE=OQGRAPH should be considered analogous to a VIEW, such that when it is created the relevant underlying table and columns should exist.
Example:
> describe tol;
+------
| Field | Type | Null | Key | Default | Extra |
+------
| id | int(10) unsigned | NO | PRI | 0 | |
| parent | int(10) unsigned | YES | | NULL | |
| position | int(11) | YES | | NULL | |
| name | varchar(100) | YES | MUL | NULL | |
| description | varchar(200) | YES | | NULL | |
+------
> CREATE TABLE tol_tree (
wrong SMALLINT
) ENGINE=OQGRAPH data_table='bad' origid='id' destid='id';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') ENGINE=OQGRAPH data_table='tol' origid='id' destid='id'' at line 5
The above is the correct behaviour, which already happens if the structure is invalid.
> CREATE TABLE tol_tree (
latch SMALLINT UNSIGNED NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
) ENGINE=OQGRAPH data_table='bad' origid='id' destid='id';
Query OK, 0 rows affected (0.05 sec)
However, having a wrong attribute is not currently detected.
(CONFIRMED --> As per https:/
This is reflected by errors when attempting to SELECT from the OQGRAPH table, but as discussed, should be avoided in the first place by checking at construction.