Hi!

Voting needed below, please read!

Thanks to all who responded with the valuable feedback. It sounds
like we need to support '?' for other APIs, and I think supporting
both numeric and string IDs will be trivial on top of this. String
IDs generally have a ':' prefix, so we'll stick with that (ie,
':name'). One question is what prefix character to use for numeric IDs,
since I see both '?' and ':' conventions. Which would folks prefer:


1: INSERT INTO foo VALUES(?, ?1)
2: INSERT INTO foo VALUES(?, :1)
3: Some other convention.


Also, should numeric IDs start at 0 or 1?


Next up, I think there is agreement in simplifying the API for passing
values in. We can look at a separate set of functions later for
parsing/reusing prepared statements either on the server or client,
but for now I want to nail down the API to pass in values.

I saw mixed feelings on supporting only string vs a few native types
(for example, int). Only allowing one type simplifies the interface
quite a bit, so for the query:

drizzle_query(drizzle, "INSERT INTO foo VALUES(:name, :age)", values, 2);

Which would folks prefer:

1: String only interface

drizzle_value_st values[2];
values[0].id= "name";
values[0].data= "Eric";
values[0].size= 4;
values[1].id= "age";
values[1].data= "28";
values[1].size= 2;

2: Supports string, ints, other basic types with type safety (enum/union)

drizzle_value_st values[2];
values[0].id= "name";
values[0].type= DRIZZLE_VALUE_STRING;
values[0].data.str.ptr= "Eric";
values[0].data.str.size= 4;
values[1].id= "age";
values[1].type= DRIZZLE_VALUE_INT32;
values[1].data.i32= 28;

3: Supports string, ints, other basic types with no type safety (void *)

drizzle_value_st values[2];
int32_t age= 28;
values[0].id= "name";
values[0].type= DRIZZLE_VALUE_STRING;
values[0].data= "Eric";
values[0].size= 4;
values[1].id= "age";
values[1].type= DRIZZLE_VALUE_INT32;
values[1].data= &age;
values[1].size= 4; /* sizeof(int32_t), could optionally omit and trust enum */

4: Some other convention.


My preference would be 1, but if we do want multiple types, I'd prefer
2 over 3 for the type safety. If 2 is the most popular, looking for
suggestions on better union/struct naming as well. :)

Thanks!
-Eric

On Tue, Oct 13, 2009 at 12:42:52AM -0700, Eric Day wrote:
> Hi!
> 
> We've decided to add the prepared statement API sooner than later,
> and I've been looking into various ways of mapping variables in. There
> are simple '?' with order of appearance determining order into the
> array of vars, there are '$1', '$2', ... which would allow you to
> repeat or do things out of order. Or the SQLite method of '?nnn' or
> ':aaa' and also allow identifies.
> 
> What are folks thoughts on PS APIs? Anything they really love or hate?
> 
> We're also thinking of restricting vars to strings for now, but
> possibly simple INT types. Other types could still be given as vars,
> but they'd just be passed in as strings.
> 
> Thanks!
> -Eric

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to