Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table: research IF (NOT) EXISTS #105

Open
JJJ opened this issue May 25, 2021 · 0 comments
Open

Table: research IF (NOT) EXISTS #105

JJJ opened this issue May 25, 2021 · 0 comments
Labels
component-table The Table class workflow-needs-research Needs to be researched

Comments

@JJJ
Copy link
Collaborator

JJJ commented May 25, 2021

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-table The Table class workflow-needs-research Needs to be researched
Projects
None yet
Development

No branches or pull requests

1 participant