Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-13406

ADD INDEX syntax may cause an error in earlier MySQL versions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.1.3-RC1
    • 3.1.2, 3.2.0-dev
    • Update system
    • None

      Currently there's no space between the index name and columns list when generating ADD INDEX sql query for MySQL DBMSes
      https://github.com/phpbb/phpbb/blob/develop/phpBB/phpbb/db/tools.php#L2178

      $statements[] = 'ALTER TABLE ' . $table_name . ' ADD INDEX ' . $index_name . '(' . implode(', ', $column) . ')';
      

      This may cause errors on earlier MySQL versions like 3.23 (which is supported by phpBB 3.1) like

      SQL ERROR [ mysql ]

      You have an error in your SQL syntax near 'user(user_id, notification_read)' at line 1 [1064]

      SQL

      ALTER TABLE phpbb3_notifications ADD INDEX user(user_id, notification_read)

      Adding a space solves the issue.

            nickvergessen Joas Schilling
            rxu rxu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: