Page MenuHomePhabricator

Create Database fails with a AphrontQueryException 1064
Closed, ResolvedPublic

Description

Hi,

I'm trying to create a new install of Phabricator, and have hit the following problem at running ./phabricator/bin/storage upgrade for the first time. I ran the "Make mysql secure" script. I've got the webserver running, and also set the mysql.pass as advised on the first landing page (I didn't set any of the other three items, as the defaults looked correct).

On reconnecting to the webserver, the instruction was to run "storage upgrade", but I hit the issue below. mysql server version is 5.1.73

./phabricator/bin/storage upgrade --user root --password <snip>
Before running storage upgrades, you should take down the Phabricator web
interface and stop any running Phabricator daemons (you can disable this
warning with --force).

    Are you ready to continue? [y/N] y

Applying patch 'phabricator:db.dashboard'
[2014-10-06 13:31:45] EXCEPTION: (AphrontQueryException) #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 'binary' at line 1 at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:308]
  #0 AphrontBaseMySQLDatabaseConnection::throwQueryCodeException(integer, string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:275]
  #1 AphrontBaseMySQLDatabaseConnection::throwQueryException(mysqli) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:181]
  #2 AphrontBaseMySQLDatabaseConnection::executeRawQuery(string) called at [<phutil>/src/xsprintf/queryfx.php:6]
  #3 queryfx(AphrontMySQLiDatabaseConnection, string, string, string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:119]
  #4 PhabricatorStorageManagementAPI::createDatabase(string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:169]
  #5 PhabricatorStorageManagementAPI::applyPatch(PhabricatorStoragePatch) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementUpgradeWorkflow.php:168]
  #6 PhabricatorStorageManagementUpgradeWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:394]
  #7 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:290]
  #8 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/sql/manage_storage.php:163]

Event Timeline

andrew.grant raised the priority of this task from to Needs Triage.
andrew.grant updated the task description. (Show Details)
andrew.grant added a project: Phabricator.
andrew.grant added a subscriber: andrew.grant.

At a guess...

It looks like binary isn't in single quotes when it is called in createDatabase in PhabricatorStorageManagementAPI.php(119)

From the mysql log:

7 Query     CREATE DATABASE IF NOT EXISTS `phabricator_dashboard` COLLATE binary

workaround:
Manually changed line 241 in PhabricatorStorageManagementAPI.php
from

$collate_text = 'binary';

to

$collate_text = '\'binary\'';
chad triaged this task as High priority.Oct 6 2014, 3:44 PM
chad added a project: High Support Impact.
chad added subscribers: btrahan, epriestley.
chad added a subscriber: r8j3.

Just wanted to say I am having the same issue on an existing Phabricator install.

Applying patch 'phabricator:db.almanac'...
[2014-10-06 10:48:42] EXCEPTION: (AphrontQueryException) #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 'binary' at line 1 at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:308]
#0 AphrontBaseMySQLDatabaseConnection::throwQueryCodeException(integer, string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:275]
#1 AphrontBaseMySQLDatabaseConnection::throwQueryException(mysqli) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:181]
#2 AphrontBaseMySQLDatabaseConnection::executeRawQuery(string) called at [<phutil>/src/xsprintf/queryfx.php:6]
#3 queryfx(AphrontMySQLiDatabaseConnection, string, string, string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:119]
#4 PhabricatorStorageManagementAPI::createDatabase(string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:169]
#5 PhabricatorStorageManagementAPI::applyPatch(PhabricatorStoragePatch) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementUpgradeWorkflow.php:168]
#6 PhabricatorStorageManagementUpgradeWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:394]
#7 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:290]
#8 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/sql/manage_storage.php:163]

Support Impact storage upgrade is broken on old MySQL and installs attempting to upgrade will be left in a nonworking state.

(This doesn't technically get harder to fix over time.)

Is the proposed fix correct? (Binary just needs to be quoted? ...and that will still work in newer sql?) I'd implement it slightly differently with the wonders of qsprintf

I believe using %T instead of %Q probably fixes this.