Bug 143329

Summary: Use constants of sqlite3 directly for status of SQL result in webdatabase
Product: WebKit Reporter: Gyuyoung Kim <gyuyoung.kim>
Component: New BugsAssignee: Gyuyoung Kim <gyuyoung.kim>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, commit-queue, darin, japhet, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Archive of layout-test-results from ews107 for mac-mavericks-wk2
none
Patch
none
Patch
none
Patch none

Description Gyuyoung Kim 2015-04-01 22:49:06 PDT
In webdatabase, it has used constants vairables as well as using SQL constants directly. If SQL constants are changed, we should modify many files. Besides it causes to use if~else statement which consumes more cpu cycles compared to switch~case. This patch introduces SQLResultType eunm type, and use it. Additionally if~else statment is changed by switch~case.
Comment 1 Gyuyoung Kim 2015-04-01 22:56:19 PDT
Created attachment 249963 [details]
Patch
Comment 2 Gyuyoung Kim 2015-04-01 23:27:52 PDT
Created attachment 249964 [details]
Patch
Comment 3 Gyuyoung Kim 2015-04-02 16:18:52 PDT
Created attachment 250016 [details]
Patch
Comment 4 Gyuyoung Kim 2015-04-03 06:23:28 PDT
Created attachment 250067 [details]
Patch
Comment 5 Build Bot 2015-04-03 07:33:39 PDT
Comment on attachment 250067 [details]
Patch

Attachment 250067 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/4584866775564288

New failing tests:
fast/fixed-layout/fixed-layout.html
Comment 6 Build Bot 2015-04-03 07:33:42 PDT
Created attachment 250069 [details]
Archive of layout-test-results from ews107 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 7 Gyuyoung Kim 2015-04-03 08:22:14 PDT
(In reply to comment #5)
> Comment on attachment 250067 [details]
> Patch
> 
> Attachment 250067 [details] did not pass mac-wk2-ews (mac-wk2):
> Output: http://webkit-queues.appspot.com/results/4584866775564288
> 
> New failing tests:
> fast/fixed-layout/fixed-layout.html

Looks unrelated test failure.
Comment 8 Gyuyoung Kim 2015-04-03 08:23:42 PDT
Created attachment 250074 [details]
Patch
Comment 9 Darin Adler 2015-04-03 13:35:19 PDT
Comment on attachment 250074 [details]
Patch

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

I don’t understand why we are defining our own enum. Why not use the SQLite3 constants directly?

> Source/WebCore/platform/sql/SQLiteDatabase.h:48
> +typedef enum {

In C++ preferred syntax is enum X { } rather than typedef enum { } X;

Also, in new code we prefer to use enum class. So this should be:

    enum class SQLResult {
        Done = SQLITE_DONE,
        ...
    }

Then the constants are named SQLResult::Done.
Comment 10 Gyuyoung Kim 2015-04-03 18:44:45 PDT
Created attachment 250113 [details]
Patch
Comment 11 Gyuyoung Kim 2015-04-03 18:47:56 PDT
(In reply to comment #9)
> Comment on attachment 250074 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=250074&action=review
> 
> I don’t understand why we are defining our own enum. Why not use the SQLite3
> constants directly?

As I wrote in ChangeLog, it can cause to modify many files if constants of SQLite3 are changed. However If you think to use the constants directly, I don't object to do it. Updated patch uses the constants directly.
 
> > Source/WebCore/platform/sql/SQLiteDatabase.h:48
> > +typedef enum {
> 
> In C++ preferred syntax is enum X { } rather than typedef enum { } X;
> 
> Also, in new code we prefer to use enum class. So this should be:
> 
>     enum class SQLResult {
>         Done = SQLITE_DONE,
>         ...
>     }
> 
> Then the constants are named SQLResult::Done.

If I change name of type, I had to modify more files which have used existing own constants variables. However new patch just uses SQLite3 constatns directly.
Comment 12 Gyuyoung Kim 2015-04-03 20:19:20 PDT
Created attachment 250117 [details]
Patch
Comment 13 Gyuyoung Kim 2015-04-04 20:07:02 PDT
Darin, I wonder what do you think about updated patch.
Comment 14 WebKit Commit Bot 2015-04-05 13:45:28 PDT
Comment on attachment 250117 [details]
Patch

Clearing flags on attachment: 250117

Committed r182365: <http://trac.webkit.org/changeset/182365>
Comment 15 WebKit Commit Bot 2015-04-05 13:45:33 PDT
All reviewed patches have been landed.  Closing bug.