Closed Bug 1168543 Opened 9 years ago Closed 9 years ago

Storage database cannot be created

Categories

(Firefox for iOS :: Data Storage, defect)

All
iOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
fennec + ---
fxios + ---

People

(Reporter: bnicholson, Assigned: rnewman)

Details

Attachments

(1 file)

47 bytes, text/x-github-pull-request
bnicholson
: review+
Details | Review
No DB storage functions are working: empty top sites panel, no history, can't add bookmarks, etc.

2015-05-26 12:35:55.057 [Debug] [BrowserDB.swift:65] init(files:): Initializing BrowserDB.
2015-05-26 12:35:55.077 [Debug] [BrowserDB.swift:124] createOrUpdate: Create or update tableList version 1.
2015-05-26 12:35:55.101 [Debug] [BrowserDB.swift:78] createTable(_:table:): Try create tableList version 1
2015-05-26 12:35:55.109 [Debug] [BrowserDB.swift:124] createOrUpdate: Create or update favicons version 0.
2015-05-26 12:35:55.111 [Debug] [BrowserDB.swift:78] createTable(_:table:): Try create favicons version 0
2015-05-26 12:35:55.116 [Debug] [BrowserDB.swift:124] createOrUpdate: Create or update BROWSER version 4.
2015-05-26 12:35:55.122 [Debug] [BrowserTable.swift:234] exists: 0 tables exist. Expected 4
2015-05-26 12:35:55.122 [Debug] [BrowserDB.swift:78] createTable(_:table:): Try create BROWSER version 4
SQL error: SQL error or missing database near "WHERE": syntax error for SQL CREATE INDEX IF NOT EXISTS idx_history_should_upload ON history (should_upload) WHERE should_upload = 1.
2015-05-26 12:35:55.136 [Error] [BrowserTable.swift:63] run(_:sql:args:): Error running SQL in BrowserTable. Optional("SQL error or missing database near \"WHERE\": syntax error")
2015-05-26 12:35:55.137 [Error] [BrowserTable.swift:64] run(_:sql:args:): SQL was CREATE INDEX IF NOT EXISTS idx_history_should_upload ON history (should_upload) WHERE should_upload = 1
2015-05-26 12:35:55.137 [Debug] [BrowserDB.swift:81] createTable(_:table:): Creation failed.
2015-05-26 12:35:55.138 [Debug] [BrowserDB.swift:147] createOrUpdate: Couldn't create or update BROWSER.
2015-05-26 12:35:55.138 [Debug] [BrowserDB.swift:148] createOrUpdate: Attempting to move browser.db to another location.
2015-05-26 12:35:55.143 [Debug] [BrowserDB.swift:78] createTable(_:table:): Try create SBQRLO WeSrErRo rv:e rSsQiLo ne r4r
or or missing database near "WHERE": syntax error for SQL CREATE INDEX IF NOT EXISTS idx_history_should_upload ON history (should_upload) WHERE should_upload = 1.
2015-05-26 12:35:55.149 [Error] [BrowserTable.swift:63] run(_:sql:args:): Error running SQL in BrowserTable. Optional("SQL error or missing database near \"WHERE\": syntax error")
2015-05-26 12:35:55.149 [Error] [BrowserTable.swift:64] run(_:sql:args:): SQL was CREATE INDEX IF NOT EXISTS idx_history_should_upload ON history (should_upload) WHERE should_upload = 1
2015-05-26 12:35:55.150 [Debug] [BrowserDB.swift:81] createTable(_:table:): Creation failed.
2015-05-26 12:35:55.302 [Error] [BrowserViewController.swift:1054] tabManager(_:didSelectedTabChange:previous:): Error getting bookmark status: nil.
Call <Client.TabManager: 0x17df4780>
Call <Client.BrowserViewController: 0x183a6200>
2015-05-26 12:35:56.270 [Debug] [Profile.swift:155] onLocationChange: Ignoring navigation for nil.
Error: failed to get data: Error Domain=org.mozilla Code=1 "SQL error or missing database no such table: bookmarks"
This happens even after uninstalling/reinstalling on iPod touch. Can't reproduce in simulator.
We trigger all of the table creation queries sequentially:

    func run(db: SQLiteDBConnection, queries: [String]) -> Bool {
        for sql in queries {
            if !run(db, sql: sql, args: nil) {
                return false
            }
        }
        return true
    }

but apparently the index creation query is actually running first, or in parallel in separate transaction.

Lemme see if I can repro.
Assignee: nobody → rnewman
Status: NEW → ASSIGNED
(this is my assumption because that query itself is well-formed, and we didn't abort due to a prior failure…)
Initial guess was wrong. Current theory: Brian was using iOS 8.1.2, which has a sqlite version < 3.8, which is needed for partial indexes.

http://stackoverflow.com/questions/14288128/what-version-of-sqlite-does-ios-provide

This is easy for us to work around, so let's do that.
Attached file Pull req.
Too lazy to create a parallel PR, sorry!
Attachment #8610795 - Flags: review?(bnicholson)
Comment on attachment 8610795 [details] [review]
Pull req.

Guess that means we need to be careful to check this flag whenever using partial indices. I wish we had a way to test this!
Attachment #8610795 - Flags: review?(bnicholson) → review+
As expected, iOS upgrade fixes the issue.
Bug 1147071 will have us ship our own sql implementation anyway, so this won't be an issue anymore.
433f577
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
tracking-fennec: ? → +
tracking-fxios: --- → +
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: