Commit Graph

16 Commits

Author SHA1 Message Date
Kevin Locke
debe87c368 WIP: Partial support for prefix indexing
[Work In Progress] MySQL performs prefix indexing on a few columns.
PostgreSQL lacks support for prefix indexing (although it does support
expression indexing, which can be used to similar effect), which results
in the following error message:

Error running :
ALTER TABLE wp_comments ADD KEY comment_author_email (comment_author_email(10))
---- converted to ----
CREATE INDEX wp_comments_comment_author_email ON wp_comments (comment_author_email(10)
----> ERROR:  syntax error at end of input
LINE 1: ...omment_author_email ON wp_comments (comment_author_email(10)

Since the prefix indexing does not currently appear to be advantageous
(other than working around MySQL row index size limitations), convert
these to full-column indexes.

FIXME:  SHOW INDEX needs to be updated so that it returns the requested
prefix length in order to avoid attempted index recreation during schema
upgrades.  This could be accomplished by storing the length as a comment
or some other ancillary metadata.  This is not implemented yet.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2015-06-06 21:48:28 -06:00
Kevin Locke
b4b346f694 Fix row order in SHOW INDEX query
The order of rows returned from SHOW INDEX is significant, and it is
used to determine the column order in multi-column indexes.  Update the
query to return rows in the expected order to avoid errors during
upgrade (e.g. in wp_term_taxonomy_term_id_taxonomy where the column
order is not alphabetical).

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2015-06-06 21:48:28 -06:00
Kevin Locke
83e5074461 Add support for sql_mode variable
This appears as both "SELECT @@SESSION.sql_mode" checked from wp-db.php
in Wordpress core during startup and as "SHOW VARIABLES LIKE 'sql_mode'"
in several extensions (all-in-one-seo-pack, flash-album-gallery, and
nextgen-gallery on my system).  Support both by returning the empty
string, which reports the default MySQL behavior (and avoids attempts to
change the mode, since all current code expects this).

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2015-06-06 21:48:28 -06:00
Kevin Locke
6aea521bf2 Rework SHOW COLUMNS/INDEX/TABLE support
Wordpress 4 makes use of SHOW COLUMNS and SHOW TABLES in addition to
SHOW INDEX, both with and without the FULL modifier.  Implement support
for these statements using queries against INFORMATION_SCHEMA.

Some of these queries use lower-case versions of these statements,
such as "show tables like 'wp_flag_pictures'", so we make sure to
recognize both the upper- and lower-case versions.

This is based, in part, on the work of raptorz in the support forum at
https://wordpress.org/support/topic/upgrade-to-wp421-fail?replies=3#post-6886123

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2015-06-06 21:47:30 -06:00
Kevin Locke
f97491346b Rewrite default '0000-00-00 00:00:00' to now()
The current rewriting changes "default '0000-00-00 00:00:00'" when it
appears in CREATE TABLE statements, but does not handle the case that a
column default value is modified.  This results in errors such as the
following during schema upgrade:

Error running :
ALTER TABLE wp_users ALTER COLUMN user_registered SET DEFAULT '0000-00-00 00:00:00'
---- converted to ----
ALTER TABLE wp_users ALTER COLUMN user_registered SET DEFAULT '0000-00-00 00:00:00'
----> ERROR:  date/time field value out of range: "0000-00-00 00:00:00"

Apply the conversion to ALTER TABLE statements as well.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2015-06-03 00:51:25 -06:00
hawk__
bb14143c77 Added a handle for DROP TABLE to remove sequences that are linked with the dropped table
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@546567 b8457f37-d9ea-0310-8a92-e5e31aec5664
2012-05-20 12:57:04 +00:00
hawk__
70b7af7142 Added a filter for 'CREATE TABLE IF NOT EXISTS'
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@545542 b8457f37-d9ea-0310-8a92-e5e31aec5664
2012-05-17 20:13:57 +00:00
hawk__
7692aa54c4 Corrected a typo and added a WPMU required translation
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@544612 b8457f37-d9ea-0310-8a92-e5e31aec5664
2012-05-15 19:17:23 +00:00
hawk__
fb9bcadebd Added some column types conversion for WPMU support
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@429285 b8457f37-d9ea-0310-8a92-e5e31aec5664
2011-08-27 00:36:48 +00:00
hawk__
0dbc95e1a1 Added "ADD COLUMN" support to the "ALTER TABLE" handling code
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@429284 b8457f37-d9ea-0310-8a92-e5e31aec5664
2011-08-27 00:35:29 +00:00
hawk__
5644761e17 Improved SHOW INDEX for upgrades to detect indices correctly and so don't try to recreate them
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@429283 b8457f37-d9ea-0310-8a92-e5e31aec5664
2011-08-27 00:34:15 +00:00
hawk__
ac496694fe Improved INDEX creation support
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@429262 b8457f37-d9ea-0310-8a92-e5e31aec5664
2011-08-26 21:59:01 +00:00
hawk__
57879ef3ba Removed all references to ZdMultilang hacks
Added YEAR and MONTH to 'INTERVAL...' handling
Added a handle for correct counting of users and roles

git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@428351 b8457f37-d9ea-0310-8a92-e5e31aec5664
2011-08-24 20:57:55 +00:00
hawk__
bd2a5978df Disabled all ZdMultilang support Hacks
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@423850 b8457f37-d9ea-0310-8a92-e5e31aec5664
2011-08-15 15:58:27 +00:00
hawk__
1a05e62dac The required handling code wasn't loaded in some cases when a plugin created his own tables in the database
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@418968 b8457f37-d9ea-0310-8a92-e5e31aec5664
2011-08-03 21:30:21 +00:00
hawk__
89313aaf10 Moved parts required only when installing/upgrading from driver_pgsql.php to driver_pgsql_install.php, loaded when required
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@195579 b8457f37-d9ea-0310-8a92-e5e31aec5664
2010-01-19 22:56:00 +00:00