Flyway: StringIndexOutOfBoundsException

Created on 25 Jun 2013  路  4Comments  路  Source: flyway/flyway

_Original author: [email protected] (December 26, 2012 20:43:55)_

I have db update with hude imports:
NSERT INTO CITY (ID, LATITUDE, LONGITUDE, COUNTRY_CODE, NAME_RU, NAME_EN, STATE) VALUES
.....

When i try to update, i get:
[ERROR] java.lang.StringIndexOutOfBoundsException: String index out of range: 7759
[ERROR] com.googlecode.flyway.core.api.FlywayException: Migration to version 123 failed! Please restore backups and roll back database and code!

_Original issue: http://code.google.com/p/flyway/issues/detail?id=401_

duplicate bug

Most helpful comment

_From [email protected] on January 07, 2013 14:28:30_
I found the reason. There are such strings in flyway source (SqlStatementBuilder class):
private static String stripDelimiter(String sql, Delimiter delimiter) {
return sql.substring(0, sql.toUpperCase().lastIndexOf(delimiter.getDelimiter().toUpperCase()));
}
I hade strange letters in my sql. For example, there was this word: Kre脽berg. You can see letter 脽. Mayby, in upper case it has length more than in lower case, so it was is impossible to get substring

All 4 comments

_From axel.fontaine.[email protected] on December 27, 2012 12:34:27_
Hi Dmitriy,

Could you post the complete statement producing the problem as well as the DB (+ version) you use?

Thanks
Axel

_From [email protected] on January 07, 2013 13:22:30_
Mysql 5.5

I can't find the sql with witch I got the error, but using sql
INSERT INTO CITY (ID, LATITUDE, LONGITUDE, COUNTRY_CODE, NAME_RU, NAME_EN) VALUES
(133733,36.76901,3.04416, 'DZ', '袗谢卸懈褉', 'Algiers');
INSERT INTO CITY (ID, LATITUDE, LONGITUDE, COUNTRY_CODE, NAME_RU, NAME_EN) VALUES
(133734,17.46594,106.5984, 'VN', '袛芯薪谐褏芯泄', 'Dong Hoi');
and so on I got
[ERROR] java.lang.StringIndexOutOfBoundsException: String index out of range: 145

_From [email protected] on January 07, 2013 14:28:30_
I found the reason. There are such strings in flyway source (SqlStatementBuilder class):
private static String stripDelimiter(String sql, Delimiter delimiter) {
return sql.substring(0, sql.toUpperCase().lastIndexOf(delimiter.getDelimiter().toUpperCase()));
}
I hade strange letters in my sql. For example, there was this word: Kre脽berg. You can see letter 脽. Mayby, in upper case it has length more than in lower case, so it was is impossible to get substring

_This issue is a duplicate of #384_

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fstokke picture fstokke  路  3Comments

berlin-ab picture berlin-ab  路  3Comments

expeditioneer picture expeditioneer  路  4Comments

ssonnenberg picture ssonnenberg  路  3Comments

axelfontaine picture axelfontaine  路  4Comments