Re: [sqlite] Do I need to use sqlite3_close after a failed sqlite3_open?

2007-01-30 Thread Roger Binns
Jay Sprenkle wrote:
> On 1/24/07, Jef Driesen <[EMAIL PROTECTED]> wrote:
>>
>> Do I need to use sqlite3_close if the call to sqlite3_open indicated an
>> error? The documentation for sqlite3_open says "An sqlite3* handle is
>> returned in *ppDb, even if an error occurs." So I assumed the answer is
>> yes.
> 
> I never do, since if open fails I assumed the handle wasn't valid.
> It almost never happens so the consequences of being wrong are pretty
> small.

Memory is allocated for an error message.  sqlite_close will free that :-)

Roger

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Do I need to use sqlite3_close after a failed sqlite3_open?

2007-01-26 Thread Jef Driesen

[EMAIL PROTECTED] wrote:

"Jef Driesen" <[EMAIL PROTECTED]> wrote:
I did. sqlite3_close is called automatically for SQLITE_NOMEM, but not for 
other cases. So I guess sqlite3_close is still needed. But then it 
shouldn't return an error, or am I wrong?


I don't think any error other than SQLITE_NOMEM is possible for
sqlite3_open().  Are you seeing some other kind of error come up?


I get SQLITE_CANTOPEN for a non-existing file (and no write permissions
to create it). Using sqlite3_close immediately afterwards returns the
same value. And sqlite3_errcode returns SQLITE_MISUSE.

I think this indicates there is definitely something wrong here. Either
the documentation is incorrect (with regards to the usage of
sqlite3_close after a failed sqlite3_open), or there is a bug in
sqlite3_open/close.

I'm using sqlite version 3.3.5 (Ubuntu Edgy package) if that matters.

_
Did you know that Windows Live Messenger is accesible on your mobile as from 
now? http://get.live.com/messenger/mobile



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Do I need to use sqlite3_close after a failed sqlite3_open?

2007-01-26 Thread drh
"Jef Driesen" <[EMAIL PROTECTED]> wrote:
> 
> I did. sqlite3_close is called automatically for SQLITE_NOMEM, but not for 
> other cases. So I guess sqlite3_close is still needed. But then it shouldn't 
> return an error, or am I wrong?
> 

I don't think any error other than SQLITE_NOMEM is possible for
sqlite3_open().  Are you seeing some other kind of error come up?
--
D. Richard Hipp  <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Do I need to use sqlite3_close after a failed sqlite3_open?

2007-01-26 Thread Jef Driesen

Jay Sprenkle wrote:

On 1/24/07, Jef Driesen <[EMAIL PROTECTED]> wrote:


Do I need to use sqlite3_close if the call to sqlite3_open indicated an
error? The documentation for sqlite3_open says "An sqlite3* handle is
returned in *ppDb, even if an error occurs." So I assumed the answer is
yes.



I never do, since if open fails I assumed the handle wasn't valid.



Almost never is still possible...

It almost never happens so the consequences of being wrong are pretty 
small.

Did you look at the source for sqlite_open()?


I did. sqlite3_close is called automatically for SQLITE_NOMEM, but not for 
other cases. So I guess sqlite3_close is still needed. But then it shouldn't 
return an error, or am I wrong?


_
All things trendy for Windows Live Messenger ... 
http://entertainment.msn.be/funwithmessenger



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Do I need to use sqlite3_close after a failed sqlite3_open?

2007-01-24 Thread Jay Sprenkle

On 1/24/07, Jef Driesen <[EMAIL PROTECTED]> wrote:


Do I need to use sqlite3_close if the call to sqlite3_open indicated an
error? The documentation for sqlite3_open says "An sqlite3* handle is
returned in *ppDb, even if an error occurs." So I assumed the answer is
yes.




I never do, since if open fails I assumed the handle wasn't valid.
It almost never happens so the consequences of being wrong are pretty small.
Did you look at the source for sqlite_open()?


--
--
The PixAddixImage Collector suite:
http://groups-beta.google.com/group/pixaddix

SqliteImporter and SqliteReplicator: Command line utilities for Sqlite
http://www.reddawn.net/~jsprenkl/Sqlite

Cthulhu Bucks!
http://www.cthulhubucks.com


[sqlite] Do I need to use sqlite3_close after a failed sqlite3_open?

2007-01-24 Thread Jef Driesen

Do I need to use sqlite3_close if the call to sqlite3_open indicated an
error? The documentation for sqlite3_open says "An sqlite3* handle is
returned in *ppDb, even if an error occurs." So I assumed the answer is yes.

But if I try this code (on a non-existing file and no write permissions):

int rc_o = sqlite3_open (filename, &db);
if (rc_o != SQLITE_OK) {
printf("ERROR: %i, %i, %s\n",
   rc_o, sqlite3_errcode(db), sqlite3_errmsg(db));
int rc_c = sqlite3_close (db);
if (rc_c != SQLITE_OK) {
   printf("ERROR: %i, %i, %s\n",
  rc_c, sqlite3_errcode(db), sqlite3_errmsg(db));
}
}

I get:

ERROR: SQLITE_CANTOPEN, SQLITE_CANTOPEN, unable to open database file
ERROR: SQLITE_CANTOPEN, SQLITE_MISUSE, library routine called out of
sequence

Shouldn't sqlite3_close return SQLITE_OK?

And why is the rc_c different from the return value of the
sqlite3_errcode function? Isn't that function supposed to return the
error code of the last sqlite3_* function? Which is sqlite3_close in my
code.

_
Who is the sweetheart of the Japanese and always holds something in his 
hands? Live Search knows! How about you? 
http://search.live.com/images/results.aspx?q=Manneken%20pis&FORM=QBIR



-
To unsubscribe, send email to [EMAIL PROTECTED]
-