Re: Detailed review of 4.12. Client-side database storage

On Tue, 18 Sep 2007, Mihai Sucan wrote:
> 
> I have reviewed section 4.12. "Client-side database storage" [1]. Here 
> are my comments:

Thanks for the feedback.


> 1. In section 4.12.2. "Executing SQL statements" [2]:
> 
> "Big Issue: There are two major missing features here: One: [...]. Two:
> there's no session-specific API, so if you have two windows open at once, you
> can't interact with the site doing two separate sessions unless the site goes
> out of its way to track sessions itself, detecting when new tabs are opened,
> etc. sessionStorage[] handles it, why doesn't this? [...]"
> 
> Given there's sessionStorage, it wouldn't really be a big deal for a web 
> application to "go out of its way to track sessions itself" - since 
> sessionStorage allows this quite nicely and easily.

Fair enough.

We need to work out what our story is with sessionStorage and 
globalStorage, by the way. Having both them and the SQL storage API seems 
like overkill and bloat.


> However, I was thinking: maybe UAs could allow the CREATE TEMPORARY 
> TABLE syntax (see the MySQL documentation [3]). The temporary tables 
> would be removed when the user terminates the session.
> 
> This should be good enough for session-related SQL needs.

That could work, though I'd feel better if we didn't have to futz in the 
SQL layer at this point.


> 2. The section 4.12.2 needs further clarification and details. Based on 
> the following questions:
> 
> How are the "?" chars supposed to be replaced with the given arguments? 
> What kind of escaping is supposed to be expected?
> 
> executeSql("INSERT INTO `flowers` (`name`, `color`) VALUES (?, ?)", "lily",
> "white");
> executeSql("INSERT INTO `flowers` (`name`, `color`) VALUES ('?', '?')",
> "lily", "white");
> 
> ... both cases could be expected in the wild. What to expect from each 
> example? I suppose the first example works as intended (a new row with 
> the given arguments is added). The second example will simply add a new 
> row with the '?' value for both fields. If this is the supposed 
> behavior, then the UA has "context-awareness": I cannot do things like:
> 
> executeSql("INSERT INTO `flowers` (`?`, `?`) VALUES ('?', '?')", "name", 
> "lily", "color", "white");
> 
> I cannot treat executeSql in a similar fashion to the sprintf() function 
> [4] - albeit this would be a much more simpler function.

I've tried to clarify this. could you let me know if that's any better?


> Can binary data be stored in the database? Is the UA supposed to do 
> proper "escaping" for binary data arguments?

I'm not sure I follow. Could you elaborate?


> Also, regarding the SQL standard: I cannot ask for specifically 
> requiring the implementation of the SQL standard X, Y, nor Z. However, I 
> would suggest that the HTML5 spec *recommends* one SQL standard - like 
> it recommends Ogg support for the <video> element.

In due course I think we'll specifically state what needs to be 
implemented. I'd rather have some implementation experience first, though.


> 3. The ResultSet object [5] has the length attribute [6] which is now 
> defined to tell the number of columns in the current row. This attribute 
> name is quite confusing. I initially expected it tells the number of 
> rows in the ResultSet object.
>
> I would recommend that the "length" attribute be renamed to numCols or 
> numFields.

This is now gone altogether.


> 4. I was surprised to see there's no attribute (or method) to easily and 
> quickly check the number of rows in the ResultSet object. For now, one 
> either has to use COUNT() in a SELECT query, or must iterate over all 
> the rows to count them.
>
> I would recommend defining a new readonly attribute "numRows" which tells the
> number of rows in the ResultSet object.

We now have rows.length.


Thanks for your feedback,
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Friday, 12 October 2007 05:34:45 UTC