[Webkit-unassigned] [Bug 45926] New: JSDatabase ResultSet.rows.item(pos) throws exception, but it should return null

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Sep 16 15:38:52 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=45926

           Summary: JSDatabase ResultSet.rows.item(pos) throws exception,
                    but it should return null
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Macintosh Intel
        OS/Version: Mac OS X 10.6
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: WebCore JavaScript
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: matt at re-entry.ca


A SQL query ResultSet rows object gives one access to the result rows of a query.  The way to access a particular row is by using this call:

    var aRow = resultSet.rows.item(rowPos);

If the rowPos indicates a row that is not in the row list, the method should return null.  For instance, if there are 5 rows but I ask for rows.item(10) I should get null.

Instead, I get an error: "INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value."

This is according to the Web SQL Database spec (http://dev.w3.org/html5/webdatabase/#sqlresultsetrowlist).

WHY THIS IS IMPORTANT

The only way to safely iterate a resultset is like this:

var len = resultSet.rows.length;
for (int i = 0; i < len; i++) {
    var aRow = resultSet.rows.item(i);
    //process the row
}

Not bad, but rows.length should be avoided, as an implementation may need to scan the entire resultSet; if the resultSet is large, it can cause memory troubles, slowdowns, etc.  If the implementation of rows.item() is lazy, then length() need never be called.

The safer way to iterate is to do this:

var i = -1;
while ((aRow = resultSet.rows.item(++i)) != null) {
    //process the row
}

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list