Strange SQLite error 14 (unable to open database file)

Issue #39 invalid
Former user created an issue

Originally reported on Google Code with ID 39 ``` I used the procedure described by http://code.google.com/p/sqlite4java/issues/detail?id=29 and I am able to run this sqlite wrapper on Android. Which is good!

However, I am having a very strange (to me at least) problem.

My test involves identical databases with BLOB content.... there are 2 attached DBs with the same structure ... they have a table named "media" with just 2 fields, name (text) and content (BLOB). The BLOB content is 1MB worth of binary data.

The 2 tables have one row each only.

The query is very simple:

SELECT * FROM main.media WHERE main.media.name='1024k_02_0.in' UNION SELECT * FROM attached_1.media WHERE attached_1.media.name='1024k_22_1.in'

where "attached_1" is the alias I used when attaching the second database to the main one.

I'm doing SQLiteConnection.prepare() then I'm calling step() from the resulted SQLiteStatement that's all.

Strangely, step() returns a vague error [14] "unable to open database file".

If I repeat the same thing using the sqlite3 tool via adb shell, it works fine (no errors).

The exact same code runs fine on Linux. The exact same code runs fine if the BLOB content stored by the database tables is less than 1MB (works with no errors if it's 200KB or so).

I am using the 2 attached databases in other queries and they all work okay. The problem is when the query uses the tables that have the large BLOB content. ```

Reported by `robert.csiki` on 2012-02-23 00:46:57

Comments (3)

  1. Former user Account Deleted

    ``` Here's the error

    com.almworks.sqlite4java.SQLiteException: [14] DB[3] step() [SELECT * FROM main.media WHERE main.media.name='1024k_0_0.in' UNION SELECT * FROM attached_1.media WHERE attached_1.media.name='1024k_0_1.in']DB[3][C] [unable to open database file] at com.almworks.sqlite4java.SQLiteConnection.throwResult(SQLiteConnection.java:1248) at com.almworks.sqlite4java.SQLiteConnection$BaseController.throwResult(SQLiteConnection.java:1501) at com.almworks.sqlite4java.SQLiteStatement.stepResult(SQLiteStatement.java:1231) at com.almworks.sqlite4java.SQLiteStatement.step(SQLiteStatement.java:302) ....................................... ```

    Reported by `robert.csiki` on 2012-02-23 01:04:54

  2. Former user Account Deleted

    ``` Ok I suspect this needs rejected/closed. The problem seems to be outside of sqlite4java's territory. I apologize for that! ```

    Reported by `robert.csiki` on 2012-02-23 22:51:11

  3. Igor Sereda

    ``` Robert, no worries. Thanks for the update.

    Since SQLite opens database file every time a transaction starts, it may fail if the file is locked somehow. You can reduce the risk by combining several selects into one transaction with BEGIN statement.

    Igor ```

    Reported by `sereda` on 2012-02-24 08:54:54 - Status changed: `Invalid` - Labels added: Type-Other - Labels removed: Type-Defect

  4. Log in to comment