berlindb / core

All of the required core code
MIT License
252 stars 27 forks source link

Table: research IF (NOT) EXISTS #105

Open JJJ opened 3 years ago

JJJ commented 3 years ago

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: