-
Notifications
You must be signed in to change notification settings - Fork 27
Description
One of the basic ideologies of BerlinDB is to coexist and play nicely in an unpredictable PHP environment.
(Specifically, WordPress, where any combination of plugins and themes may be attempting to perform an unlimited number of operations at any given point in execution.)
Description
Currently, Table operations such as CREATE and DROP trigger a MySQL Error if they fail.
CREATE {$table};
Error Code: 1050. Table ‘$table’ already exists.
DROP {$table};
Error Code: 1051. Unknown table ‘$table’.
Idea
Some Table operations support additional syntax to reduce their failure response to a Warning.
CREATE {$table} IF NOT EXISTS;
0 row(s) affected, 1 warning(s): 1050 Table ‘$table’ already exists.
DROP {$table} IF EXISTS;
0 row(s) affected, 1 warning(s): 1051 Unknown table ‘$table’.
Caveat(s)
The TRUNCATE operation does not support IF EXISTS. See: https://bugs.mysql.com/bug.php?id=61890
The questions to answer here are:
- whether an Error or Warning is more appropriate
- should
IF EXISTStype syntax be flaggable, opt-in, or opt-out - what impact does this have on temporary tables & PHP unit tests (Make BerlinDB easy to be unit tested with WordPress test suite #104)
- what operational gaps exist, that could introduce complexity & confusion, if not all operations are supported (truncate for sure, but which others, and does any benefit outweigh the added code)