Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-13406

ADD INDEX syntax may cause an error in earlier MySQL versions

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 3.1.2, 3.2.0-dev
    • 3.1.3-RC1
    • Update system
    • None

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: