Bug 153800 - Modern IDB: storage/indexeddb/cursor-primary-key-order.html fails with SQLite backend
Summary: Modern IDB: storage/indexeddb/cursor-primary-key-order.html fails with SQLite...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: Safari 9
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brady Eidson
URL:
Keywords:
Depends on:
Blocks: 149117 153021
  Show dependency treegraph
 
Reported: 2016-02-02 13:40 PST by Brady Eidson
Modified: 2016-02-02 16:12 PST (History)
4 users (show)

See Also:


Attachments
Patch v1 (9.78 KB, patch)
2016-02-02 14:45 PST, Brady Eidson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brady Eidson 2016-02-02 13:40:10 PST
Modern IDB: storage/indexeddb/cursor-primary-key-order.html fails with SQLite backend

An Index cursor gets integers out of order. It should go:
-Inf, -2, -1, 0, 1, 2, Inf
...But instead it goes:
0, 1, 2, Inf, -1, -2, -Inf

I've hard coded some debugging into SQLiteIDBCursor and found that, indeed, just stepping the cursor statement over and over does, in fact, give the out of order results.

This is either a bug in our key comparator, a bug in some SQL queries, or a bug in SQLite.
Comment 1 Brady Eidson 2016-02-02 13:44:33 PST
It's the statement creating the index record table.

It's currently:
CREATE TABLE IndexRecords (indexID INTEGER NOT NULL ON CONFLICT FAIL, objectStoreID INTEGER NOT NULL ON CONFLICT FAIL, key TEXT COLLATE IDBKEY NOT NULL ON CONFLICT FAIL, value NOT NULL ON CONFLICT FAIL);

It needs to be:
CREATE TABLE IndexRecords (indexID INTEGER NOT NULL ON CONFLICT FAIL, objectStoreID INTEGER NOT NULL ON CONFLICT FAIL, key TEXT COLLATE IDBKEY NOT NULL ON CONFLICT FAIL, value TEXT COLLATE IDBKEY NOT NULL ON CONFLICT FAIL);

Note the value (which is an IDBKey into the object store) needs IDBKey collation for sorting upon insertion.
Comment 2 Brady Eidson 2016-02-02 14:45:09 PST
Created attachment 270520 [details]
Patch v1
Comment 3 WebKit Commit Bot 2016-02-02 16:12:30 PST
Comment on attachment 270520 [details]
Patch v1

Clearing flags on attachment: 270520

Committed r196038: <http://trac.webkit.org/changeset/196038>
Comment 4 WebKit Commit Bot 2016-02-02 16:12:33 PST
All reviewed patches have been landed.  Closing bug.