Skip to content

Commit f1fdf3c

Browse files
Jean-Baptiste QueruAndroid Code Review
authored andcommitted
Merge "Call register_localized_collators() with the current locale."
2 parents c2da11d + 5763c1f commit f1fdf3c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/jni/android_database_SQLiteDatabase.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static void native_setLocale(JNIEnv* env, jobject object, jstring localeString,
262262
goto done;
263263
}
264264

265-
dbLocale = (rowCount >= 1) ? meta[1 * colCount + 0] : NULL;
265+
dbLocale = (rowCount >= 1) ? meta[colCount] : NULL;
266266

267267
if (dbLocale != NULL && !strcmp(dbLocale, locale8)) {
268268
// database locale is the same as the desired locale; set up the collators and go
@@ -273,7 +273,8 @@ static void native_setLocale(JNIEnv* env, jobject object, jstring localeString,
273273

274274
if ((flags & OPEN_READONLY)) {
275275
// read-only database, so we're going to have to put up with whatever we got
276-
err = register_localized_collators(handle, dbLocale ? dbLocale : locale8, UTF16_STORAGE);
276+
// For registering new index. Not for modifing the read-only database.
277+
err = register_localized_collators(handle, locale8, UTF16_STORAGE);
277278
if (err != SQLITE_OK) throw_sqlite3_exception(env, handle);
278279
goto done;
279280
}
@@ -286,7 +287,7 @@ static void native_setLocale(JNIEnv* env, jobject object, jstring localeString,
286287
goto done;
287288
}
288289

289-
err = register_localized_collators(handle, dbLocale ? dbLocale : locale8, UTF16_STORAGE);
290+
err = register_localized_collators(handle, locale8, UTF16_STORAGE);
290291
if (err != SQLITE_OK) {
291292
LOGE("register_localized_collators() failed setting locale\n");
292293
throw_sqlite3_exception(env, handle);

0 commit comments

Comments
 (0)