Page MenuHomePhabricator

MySQL error on SMW_setup.php
Closed, DeclinedPublic

Description

Author: alxndr+wikimedia

Description:
Getting an error when trying to set up SMW on MW 1.15.3 with MySQL 5.0.67:

<code>
php5 SMW_setup.php
X-Powered-By: PHP/5.2.13
Content-type: text/html

Setting up standard database configuration for SMW ...

Selected storage engine is "SMWSQLStore2" (or an extension thereof)

Setting up table [wikiname]_smw_ids ...
A database query syntax error has occurred.
The last attempted database query was:
"CREATE TABLE [dbname].[wikiname]_smw_ids (smw_id INT(8) UNSIGNED NOT NULL KEY AUTO_INCREMENT,smw_namespace INT(11) NOT NULL,smw_title VARBINARY(255) NOT NULL,smw_iw VARCHAR(32) binary,smw_sortkey VARBINARY(255) NOT NULL) ENGINE=InnoDB"
from within function "SMWSQLHelpers::setupTable".
MySQL returned error "1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'KEY AUTO_INCREMENT,smw_namespace INT(11) NOT NULL,smw_title V ([dbserver])"
</code>

I had SMW 1.0 or 1.1 on this wiki ages ago, but disabled it in 2008.


Version: unspecified
Severity: normal
OS: Linux

Details

Reference
bz23701

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:00 PM
bzimport set Reference to bz23701.

The former installation should not be contributing to this problem (the DB tables changed completely). Which version of SMW are you using now?

Closing this bug as WORKSFORME since the described failure could not be reproduced, and since no further information is provided on the problem.

paul.murphy wrote:

This error also happens for me when using MW 1.14.0, PHP 5.1.6, and MySQL 4.0.18-MAX

The issue is that the code in SMW_SQLHelpers.php, SMW_SQLStore2_Queries.php and SMW_SQLStore2.php generates SQL which defines tables as "KEY AUTO_INCREMENT", but this needs to be "PRIMARY KEY AUTO_INCREMENT" for the version of MySQL in use.

I have patched my install with these changes, and both the Admin page interface and running the SMW_setup.php directly now works.

alxndr wrote:

MW 1.17.0, SMW 1.16 alpha (r91713), PHP 5.2.17, MySQL 4.0.27-max-log

When running SMW_setup.php:


Setting up standard database configuration for SMW ...

Selected storage engine is "SMWSQLStore2" (or an extension thereof)

Checking table xxxxx_smw_ids ...

Table not found, now creating...

A database query syntax error has occurred.
The last attempted database query was:
"CREATE TABLE xxxxx.xxxxx_smw_ids (smw_id INT(8) UNSIGNED NOT NULL KEY AUTO_INCREMENT,smw_namespace INT(11) NOT NULL,smw_title VARBINARY(255) NOT NULL,smw_iw VARCHAR(32) binary NOT NULL,smw_subobject VARCHAR(32) binary NOT NULL,smw_sortkey VARBINARY(255) NOT NULL) ENGINE=InnoDB"
from within function "SMWSQLHelpers::createTable".

Database returned error "1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'KEY AUTO_INCREMENT,smw_namespace INT(11) NOT NULL,smw_title V (xxxxx.xxxxx.xxx)"

Paul's fix above worked for me as well, but only includes/storage/SMW_SQLHelpers.php and includes/storage/SMW_SQLStorage2.php needed the tweak (s/(?<!PRIMARY) KEY AUTO/).

alxndr wrote:

Ah, for shame. s/(?<!PRIMARY) KEY AUTO/PRIMARY KEY AUTO/

isj wrote:

Probably similar error with "AUTO_INCREMENT" (wikimedia 1.17) in Drafts extension (http://www.mediawiki.org/wiki/Extension_talk:Drafts). Update script raport an error:
Database returned error "1: near &quot;AUTOINCREMENT&quot;: syntax error"

for proper Draft.sql content:

CREATE TABLE /*_*/drafts (

  • Unique ID for drafts draft_id INTEGER AUTO_INCREMENT, ...

Isn't there something wrong with wikimedia update.php which cause undescore removement from valid sql syntax?

Unknown Object (User) added a comment.Nov 7 2012, 6:34 AM

This bug hasn't seen any update during the last year and it is unknown if this bug still relates the current SMW 1.8/SQLStore3.

Please feel free to reopen this bug again if it applies to SMW 1.8.