Fix account_patch_reviews for mysql
Creation of the account_patch_reviews table failed on mysql with the file_name column being set to varchar(4096), see [1]. mysql has a limit of 767 bytes max key length for InnoDb tables. The max key length limit applies to each column in the (primary key) index. MySql uses up to 3 bytes per character when utf8 character set is used. Therefore, the max length of the file_name column is 255 characgters when using utf8 character set. This change sets the file_name column length to 255 when using mysql. The whole "CREATE TABLE ..." statement is extracted into the MysqlAccountPatchReviewStore subclass. This gives more freedom for further mysql specific tuning. Change-Id: If35aff6c8dc515228c770729bfbf3a83e3dcc6bf
This commit is contained in:
parent
03ead35c03
commit
1abb73e39e
@ -27,6 +27,12 @@ To migrate AccountPatchReviewDb:
|
||||
* Migrate data using this command
|
||||
* Start Gerrit
|
||||
|
||||
[NOTE]
|
||||
When using MySQL, the file_name column length in the account_patch_reviews table will be shortened
|
||||
from the standard 4096 characters down to 255 characters. This is due to a
|
||||
link:https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html[MySQL limitation]
|
||||
on the max size of 767 bytes for each column in an index.
|
||||
|
||||
== OPTIONS
|
||||
|
||||
-d::
|
||||
|
@ -181,7 +181,7 @@ public abstract class JdbcAccountPatchReviewStore
|
||||
}
|
||||
}
|
||||
|
||||
private static void doCreateTable(Statement stmt) throws SQLException {
|
||||
protected void doCreateTable(Statement stmt) throws SQLException {
|
||||
stmt.executeUpdate(
|
||||
"CREATE TABLE IF NOT EXISTS account_patch_reviews ("
|
||||
+ "account_id INTEGER DEFAULT 0 NOT NULL, "
|
||||
|
@ -22,6 +22,7 @@ import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
|
||||
@Singleton
|
||||
@ -50,4 +51,17 @@ public class MysqlAccountPatchReviewStore extends JdbcAccountPatchReviewStore {
|
||||
return new OrmException(op + " failure on ACCOUNT_PATCH_REVIEWS", err);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doCreateTable(Statement stmt) throws SQLException {
|
||||
stmt.executeUpdate(
|
||||
"CREATE TABLE IF NOT EXISTS account_patch_reviews ("
|
||||
+ "account_id INTEGER DEFAULT 0 NOT NULL, "
|
||||
+ "change_id INTEGER DEFAULT 0 NOT NULL, "
|
||||
+ "patch_set_id INTEGER DEFAULT 0 NOT NULL, "
|
||||
+ "file_name VARCHAR(255) DEFAULT '' NOT NULL, "
|
||||
+ "CONSTRAINT primary_key_account_patch_reviews "
|
||||
+ "PRIMARY KEY (change_id, patch_set_id, account_id, file_name)"
|
||||
+ ")");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user