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

MySQL error codes #904

Closed
robocoder opened this issue Aug 5, 2009 · 4 comments
Closed

MySQL error codes #904

robocoder opened this issue Aug 5, 2009 · 4 comments
Assignees
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Milestone

Comments

@robocoder
Copy link
Contributor

Checking for MySQL error codes (via preg_match) are sprinkled in places in the code. (i.e., core/Updater.php, core/Updates/*.php, Dashboard.php, ExampleFeedburner.php, Installation/Controller.php, LanguagesManager.php)

To assist the non-MySQL Piwik ports, we should switch the detection to SQL codes, e.g.,

  • '/1146/' becomes '/[42S02]/'
  • '/1054/' becomes '/]42S22]/'

Throwing custom exceptions would be a nice-to-have, e.g.,

  • Piwik_Db_TableNotFound
  • Piwik_Db_ColumnNotFound
@robocoder
Copy link
Contributor Author

It looks like the 5 character SQLSTATE isn't as "standard" as documented, e.g., for "table already exists", MySQL uses 1050 and 42S01, while Postgresql uses 42P07 (referencing klando's changes).

Should tackle this in conjunction with #425.

@robocoder
Copy link
Contributor Author

Should also abstract the error code detection (e.g., preg_match) to a method call as some database servers use variable length error codes (e.g., mssql, http://technet.microsoft.com/en-us/library/cc917589.aspx).

@robocoder
Copy link
Contributor Author

For completeness, postgresql error codes are defined here (http://developer.postgresql.org/pgdocs/postgres/errcodes-appendix.html).

@robocoder
Copy link
Contributor Author

In [1473]:

fixes #904 - MySQL error codes; unsupported adapters can map these to driver-specific SQLSTATE
fixes #980 - Piwik Installation support for "MySQL Improved" (mysqli) extension
fixes #984 - Set client connection charset to utf8.

Fixed tracker profiling data not recorded until after report generated.

More refactoring and database abstraction:

  • Installation gets a list of adapters instead of hardcoding in the plugin
  • checking for database-specific system requirements deferred to the adapter
  • error detection moved to adapter but we still use MySQL error codes rather than defining new constants

Note: unit tests don't run with MYSQLI -- Zend Framework's Mysqli adapater doesn't support prepare() yet

@robocoder robocoder added this to the Piwik 0.4.4 milestone Jul 8, 2014
@robocoder robocoder self-assigned this Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

1 participant