Bug 151675

Summary: Modern IDB: "prevunique" cursors should point at the lowest primary key that matches, not the highest
Product: WebKit Reporter: Brady Eidson <beidson>
Component: WebCore Misc.Assignee: Brady Eidson <beidson>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, aestes, alecflett, commit-queue, jsbell
Priority: P2    
Version: Safari 9   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 149117, 150882, 151684    
Attachments:
Description Flags
Patch v1
darin: review+, beidson: commit-queue-
Patch for landing none

Description Brady Eidson 2015-11-30 14:30:16 PST
Modern IDB: "prevunique" cursors should point at the lowest primary key that matches, not the highest.

This is so that "nextunique" and "prevunique" both point at the same primary key record for an index entry.
Comment 1 Brady Eidson 2015-11-30 15:43:13 PST
Created attachment 266291 [details]
Patch v1
Comment 2 Darin Adler 2015-11-30 16:00:30 PST
Comment on attachment 266291 [details]
Patch v1

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

> Source/WebCore/Modules/indexeddb/server/IndexValueEntry.cpp:222
> -    auto iterator = std::set<IDBKeyData>::reverse_iterator(m_orderedKeys->upper_bound(key));
> +
> +    std::set<IDBKeyData>::reverse_iterator iterator = std::set<IDBKeyData>::reverse_iterator(m_orderedKeys->upper_bound(key));

Why the change here? Is it useful to repeat std::set<IDBKeyData>::reverse_iterator twice?

> Source/WebCore/Modules/indexeddb/server/IndexValueEntry.h:38
> +enum class CursorDuplicity;

Is this kind of forward declaration of an enum class sufficient? If so, that’s great and I was not aware until now.
Comment 3 Brady Eidson 2015-11-30 16:39:18 PST
(In reply to comment #2)
> Comment on attachment 266291 [details]
> Patch v1
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=266291&action=review
> 
> > Source/WebCore/Modules/indexeddb/server/IndexValueEntry.cpp:222
> > -    auto iterator = std::set<IDBKeyData>::reverse_iterator(m_orderedKeys->upper_bound(key));
> > +
> > +    std::set<IDBKeyData>::reverse_iterator iterator = std::set<IDBKeyData>::reverse_iterator(m_orderedKeys->upper_bound(key));
> 
> Why the change here? Is it useful to repeat
> std::set<IDBKeyData>::reverse_iterator twice?

The patch was more complicated originally and required a fully-typed local variable to play with.

Then it got easier again and I forgot to make it auto.

Will-do!

> 
> > Source/WebCore/Modules/indexeddb/server/IndexValueEntry.h:38
> > +enum class CursorDuplicity;
> 
> Is this kind of forward declaration of an enum class sufficient? If so,
> that’s great and I was not aware until now.

Yes, it is! It's one of the understated great things about enum class!
Comment 4 Brady Eidson 2015-11-30 16:42:06 PST
Created attachment 266300 [details]
Patch for landing
Comment 5 WebKit Commit Bot 2015-11-30 17:28:27 PST
Comment on attachment 266300 [details]
Patch for landing

Clearing flags on attachment: 266300

Committed r192847: <http://trac.webkit.org/changeset/192847>