@@ -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