Bug 68726

Summary: IndexedDB: Null key path gets stored as empty string key path
Product: WebKit Reporter: Joshua Bell <jsbell>
Component: New BugsAssignee: Joshua Bell <jsbell>
Status: RESOLVED FIXED    
Severity: Normal CC: dglazkov, dgrogan, hans, tony, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Joshua Bell 2011-09-23 13:49:22 PDT
IndexedDB: Null key path gets stored as empty string key path
Comment 1 Joshua Bell 2011-09-23 13:52:37 PDT
Created attachment 108530 [details]
Patch
Comment 2 Joshua Bell 2011-09-23 13:53:59 PDT
Chromium issue is http://code.google.com/p/chromium/issues/detail?id=90635

Tests to detect regressions across browser sessions will be added on the chromium side.
Comment 3 WebKit Review Bot 2011-09-23 14:25:20 PDT
Comment on attachment 108530 [details]
Patch

Attachment 108530 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9831049
Comment 4 Hans Wennborg 2011-09-23 14:33:03 PDT
Thanks! It will be very nice to get this landed.

The storage/indexeddb/migrate-basics.html layout test failed when I tried this locally.
Comment 5 Joshua Bell 2011-09-23 16:41:56 PDT
Created attachment 108558 [details]
Patch
Comment 6 Joshua Bell 2011-09-23 16:45:37 PDT
Hooray for tests. Ensure we don't try and decode a stop key. Passes the storage layout tests now
Comment 7 WebKit Review Bot 2011-09-23 17:19:59 PDT
Comment on attachment 108558 [details]
Patch

Attachment 108558 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9831125
Comment 8 David Grogan 2011-09-23 17:31:12 PDT
From that bot:
Source/WebCore/storage/IDBLevelDBBackingStore.cpp:225: error: unused variable 'p'
Comment 9 Hans Wennborg 2011-09-26 08:41:48 PDT
Comment on attachment 108558 [details]
Patch

Looks good, just a couple of nits.

View in context: https://bugs.webkit.org/attachment.cgi?id=108558&action=review

> Source/WebCore/storage/IDBLevelDBBackingStore.cpp:226
> +    ASSERT(p);

you want ASSERT_UNUSED(p, p);

> Source/WebCore/storage/IDBLevelDBBackingStore.cpp:291
> +            hasKeyPath = *it->value().begin();

This works, but I would feel safer if we had specific encode/decode functions for bools. Would you like to add a FIXME about that?

> Source/WebCore/storage/IDBLevelDBBackingStore.cpp:409
> +    if (!deleteRange(m_currentTransaction.get(), ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, 0), ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, INT64_MAX)))

We try to avoid using INT64_MAX in this file by calling various *encodeMaxKey functions instead. You can add a ObjectStoreMetaDataKey::encodeMaxKey(int databaseId, int objectStoreId) function.
Comment 10 Joshua Bell 2011-09-26 09:47:01 PDT
Created attachment 108681 [details]
Patch
Comment 11 Hans Wennborg 2011-09-26 09:53:00 PDT
(In reply to comment #10)
> Created an attachment (id=108681) [details]
> Patch

LGTM
Comment 12 Joshua Bell 2011-09-26 10:21:24 PDT
Comment on attachment 108681 [details]
Patch

Tony, can you please review?
Comment 13 Tony Chang 2011-09-26 10:28:26 PDT
Comment on attachment 108681 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=108681&action=review

> Source/WebCore/storage/IDBLevelDBBackingStore.cpp:215
> +bool checkObjectStoreAndMetaDataType(const LevelDBIterator* it, const Vector<char>& stopKey, int64_t objectStoreId, int64_t metaDataType)

Nit: Should this function be static?
Comment 14 Joshua Bell 2011-09-26 10:53:36 PDT
Created attachment 108687 [details]
Patch
Comment 15 Joshua Bell 2011-09-26 10:54:28 PDT
Comment on attachment 108687 [details]
Patch

Good call on static function
Comment 16 WebKit Review Bot 2011-09-26 15:21:29 PDT
Comment on attachment 108687 [details]
Patch

Clearing flags on attachment: 108687

Committed r96007: <http://trac.webkit.org/changeset/96007>
Comment 17 WebKit Review Bot 2011-09-26 15:21:34 PDT
All reviewed patches have been landed.  Closing bug.