Skip to content

Table: research IF (NOT) EXISTS #105

@JJJ

Description

@JJJ

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 EXISTS type 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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions