Drop MySQL function nextval_project_id

When we got rid of the project_id column we also had to get rid
of the MySQL function which can be used to generate values for it.

Change-Id: Ic84d5e8b482dbccdef28fb3739ff7f5cc72b8bdd
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2010-01-14 07:58:59 -08:00
parent 534f060aa6
commit 9ec7c70d17
2 changed files with 7 additions and 13 deletions

View File

@ -2,18 +2,6 @@
--
delimiter //
CREATE FUNCTION nextval_project_id ()
RETURNS BIGINT
LANGUAGE SQL
NOT DETERMINISTIC
MODIFIES SQL DATA
BEGIN
INSERT INTO project_id (s) VALUES (NULL);
DELETE FROM project_id WHERE s = LAST_INSERT_ID();
RETURN LAST_INSERT_ID();
END;
//
CREATE FUNCTION nextval_account_id ()
RETURNS BIGINT
LANGUAGE SQL

View File

@ -19,6 +19,7 @@ import com.google.gerrit.reviewdb.ReviewDb;
import com.google.gerrit.reviewdb.SystemConfig;
import com.google.gwtorm.client.OrmException;
import com.google.gwtorm.jdbc.JdbcSchema;
import com.google.gwtorm.schema.sql.DialectMySQL;
import com.google.inject.Inject;
import com.google.inject.Provider;
@ -35,9 +36,10 @@ class Schema_21 extends SchemaVersion {
@Override
protected void migrateData(ReviewDb db) throws OrmException, SQLException {
JdbcSchema jdbc = (JdbcSchema) db;
SystemConfig sc = db.systemConfig().get(new SystemConfig.Key());
Statement s = ((JdbcSchema) db).getConnection().createStatement();
Statement s = jdbc.getConnection().createStatement();
try {
ResultSet r;
@ -50,6 +52,10 @@ class Schema_21 extends SchemaVersion {
} finally {
r.close();
}
if (jdbc.getDialect() instanceof DialectMySQL) {
s.execute("DROP FUNCTION nextval_project_id");
}
} finally {
s.close();
}