Re: [sqlite] sqlite3_transfer_bindings obsolete?

2008-05-19 Thread Ralf Junker

>> Drat.  It doesn't look like there's a way to see what's already been
>> bound to a statement either, correct?

See this thread for a previous disuccsion of the problem:

http://www.mail-archive.com/sqlite-users@sqlite.org/msg28610.html

Ralf 

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_transfer_bindings obsolete?

2008-05-17 Thread Dan

On May 18, 2008, at 12:01 AM, Shawn Wilsher wrote:

> On Sat, May 17, 2008 at 10:13 AM, Dan <[EMAIL PROTECTED]> wrote:
>> How are you going to 'clone' the statement objects to pass to
>> the second database handle?
> Our wrapper around the statement object already stores the string of
> the sql statement, so that part is easy.  Looks like we'll have to
> keep track of bound parameters as well now.

By recompiling it for the new connection. Fair enough. If you use
sqlite3_prepare_v2() to create a statement, you could also use
sqlite3_sql() to retrieve the original text of the SQL in utf-8
encoding:

   const char *sqlite3_sql(sqlite3_stmt *pStmt);

Dan.


> Cheers,
>
> Shawn Wilsher
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_transfer_bindings obsolete?

2008-05-17 Thread Shawn Wilsher
On Sat, May 17, 2008 at 10:13 AM, Dan <[EMAIL PROTECTED]> wrote:
> How are you going to 'clone' the statement objects to pass to
> the second database handle?
Our wrapper around the statement object already stores the string of
the sql statement, so that part is easy.  Looks like we'll have to
keep track of bound parameters as well now.

Cheers,

Shawn Wilsher
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_transfer_bindings obsolete?

2008-05-17 Thread Dan

On May 17, 2008, at 7:59 PM, Shawn Wilsher wrote:

> On Sat, May 17, 2008 at 2:39 AM, Dan <[EMAIL PROTECTED]> wrote:
>>> And a fun follow-up question.  Will sqlite3_transfer_bindings  
>>> transfer
>>> bindings across connection objects if the two statements are for two
>>> different connections to the same database?
>>
>> No. It will return SQLITE_MISUSE.
> Drat.  It doesn't look like there's a way to see what's already been
> bound to a statement either, correct?

Not easily done at the moment.

How are you going to 'clone' the statement objects to pass to
the second database handle?

Dan.

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_transfer_bindings obsolete?

2008-05-17 Thread Shawn Wilsher
On Sat, May 17, 2008 at 2:39 AM, Dan <[EMAIL PROTECTED]> wrote:
>> And a fun follow-up question.  Will sqlite3_transfer_bindings transfer
>> bindings across connection objects if the two statements are for two
>> different connections to the same database?
>
> No. It will return SQLITE_MISUSE.
Drat.  It doesn't look like there's a way to see what's already been
bound to a statement either, correct?

Cheers,

Shawn
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_transfer_bindings obsolete?

2008-05-17 Thread Dan

On May 17, 2008, at 2:51 AM, Shawn Wilsher wrote:

> And a fun follow-up question.  Will sqlite3_transfer_bindings transfer
> bindings across connection objects if the two statements are for two
> different connections to the same database?

No. It will return SQLITE_MISUSE.

Dan.



>
> Cheers,
>
> Shawn
>
> On Tue, May 13, 2008 at 2:05 PM, Shawn Wilsher  
> <[EMAIL PROTECTED]> wrote:
>> I was looking through the documentation and was wondering why
>> sqlite3_transfer_bindings has been marked as obsolete.  It's  
>> something
>> that we use currently in our code, and I was looking to use it again
>> for something new.  Is there a new way to accomplish the same thing
>> that this function does?  What was the rational for removing it.
>>
>> If you need a use case for why Mozilla needs it, I'd be happy to  
>> oblige.
>>
>> Cheers,
>>
>> Shawn Wilsher
>> Mozilla Developer
>>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_transfer_bindings obsolete?

2008-05-16 Thread Shawn Wilsher
And a fun follow-up question.  Will sqlite3_transfer_bindings transfer
bindings across connection objects if the two statements are for two
different connections to the same database?

Cheers,

Shawn

On Tue, May 13, 2008 at 2:05 PM, Shawn Wilsher <[EMAIL PROTECTED]> wrote:
> I was looking through the documentation and was wondering why
> sqlite3_transfer_bindings has been marked as obsolete.  It's something
> that we use currently in our code, and I was looking to use it again
> for something new.  Is there a new way to accomplish the same thing
> that this function does?  What was the rational for removing it.
>
> If you need a use case for why Mozilla needs it, I'd be happy to oblige.
>
> Cheers,
>
> Shawn Wilsher
> Mozilla Developer
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_transfer_bindings obsolete?

2008-05-13 Thread Shawn Wilsher
We most certainly are using sqlite3_prepare_v2.  This use case is a
bit more exotic.

We are currently working on an async database access API (discussion
thread [1]).  The idea is to have a user prepare and bind parameters
on the calling thread, then clone that statement to send it to the
background thread that will process the results.  Since a statement
object can only be accessed on one thread at a time (at least that's
my understanding of it), the original statement is still usable on the
calling thread (and could be used again immediately even if the other
thread is doing work).

Cheers,

Shawn

[1] 
http://groups.google.com/group/mozilla.dev.planning/browse_thread/thread/045fed0ecba487cc

On Tue, May 13, 2008 at 2:18 PM, D. Richard Hipp <[EMAIL PROTECTED]> wrote:
>
> On May 13, 2008, at 2:05 PM, Shawn Wilsher wrote:
>
>> I was looking through the documentation and was wondering why
>> sqlite3_transfer_bindings has been marked as obsolete.  It's something
>> that we use currently in our code, and I was looking to use it again
>> for something new.  Is there a new way to accomplish the same thing
>> that this function does?  What was the rational for removing it.
>>
>> If you need a use case for why Mozilla needs it, I'd be happy to
>> oblige.
>>
>
>
> We strive to avoid incompatibilities.  So even though
> sqlite3_transfer_bindings() is marked as obsolete, that just means (in
> the words of the documentation) that we are not going to tell you want
> it does.  :-)  It isn't going away.  There are tests in the test suite
> to make sure it works.
>
> sqlite3_transfer_bindings() was intended for use with
> sqlite3_prepare() when sqlite3_step() returns SQLITE_SCHEMA.  After
> the schema error, one creates a new prepared statement from the
> original SQL, uses sqlite3_transfer_bindings() to move the bindings
> from the old prepared statement to the new, finalizes the old prepared
> statement, then retries with the new prepared statement.  But all of
> that was made obsolete by sqlite3_prepare_v2().  Sqlite3_prepare_v2(),
> you will recall, handles the SQLITE_SCHEMA errors automatically so the
> use of sqlite3_transfer_bindings() is no longer required.
>
> I am curious to know what alternative use Mozilla has found for
> sqlite3_transfer_bindings(), though.  You are using
> sqlite3_prepare_v2() in place of sqlite3_prepare() I trust.  You
> should be if you are not since applications that use
> sqlite3_prepare_v2() are less prone to bugs in error handling logic
> (by virtue of the fact that they can essentially ignore SQLITE_SCHEMA).
>
> D. Richard Hipp
> [EMAIL PROTECTED]
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_transfer_bindings obsolete?

2008-05-13 Thread D. Richard Hipp

On May 13, 2008, at 2:05 PM, Shawn Wilsher wrote:

> I was looking through the documentation and was wondering why
> sqlite3_transfer_bindings has been marked as obsolete.  It's something
> that we use currently in our code, and I was looking to use it again
> for something new.  Is there a new way to accomplish the same thing
> that this function does?  What was the rational for removing it.
>
> If you need a use case for why Mozilla needs it, I'd be happy to  
> oblige.
>


We strive to avoid incompatibilities.  So even though  
sqlite3_transfer_bindings() is marked as obsolete, that just means (in  
the words of the documentation) that we are not going to tell you want  
it does.  :-)  It isn't going away.  There are tests in the test suite  
to make sure it works.

sqlite3_transfer_bindings() was intended for use with  
sqlite3_prepare() when sqlite3_step() returns SQLITE_SCHEMA.  After  
the schema error, one creates a new prepared statement from the  
original SQL, uses sqlite3_transfer_bindings() to move the bindings  
from the old prepared statement to the new, finalizes the old prepared  
statement, then retries with the new prepared statement.  But all of  
that was made obsolete by sqlite3_prepare_v2().  Sqlite3_prepare_v2(),  
you will recall, handles the SQLITE_SCHEMA errors automatically so the  
use of sqlite3_transfer_bindings() is no longer required.

I am curious to know what alternative use Mozilla has found for  
sqlite3_transfer_bindings(), though.  You are using  
sqlite3_prepare_v2() in place of sqlite3_prepare() I trust.  You  
should be if you are not since applications that use  
sqlite3_prepare_v2() are less prone to bugs in error handling logic  
(by virtue of the fact that they can essentially ignore SQLITE_SCHEMA).

D. Richard Hipp
[EMAIL PROTECTED]



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users