--- Zbigniew Baniewski <[EMAIL PROTECTED]> wrote:
> > Your trace seems to indicate it has 20 or so open
> > connections to the same database file in the same process.
>
> I think, at last I've traced the problem:
>
> One of the scripts doesn't make use out of database contents at all. But at
> the beginning there was a simple check for database file presence, just to
> let the user know, if there (from any reason) could be dbfile missing:
>
> if ($dbhandle = sqlite_open("/path/to/database/dbfile.db", 0666,
> $sqliteerror)) {
> $result = sqlite_unbuffered_query($dbhandle, 'select something from
> some_table');
> sqlite_close($dbhandle);
> } else {
> die($sqliteerror);
> }
>
>
> Yes, the "$result = ..." line can be omitted (it is now, anyway...), because
> a successfull opening a database file is enough to check, whether the file
> is present, or not (although without SELECT it may be any other database
> file, with quite different tables).
>
> My problem was caused by the fact, that there was a "SELECT" query, but
> $result handle hasn't been processed any further. After commenting out the
> "$result = ..." line there are no more "persistent" open database connections.
>
>
> And the question: is it normal behaviour - or is it a bug in PHP-module?
> I've got a feeling, that after "sqlite_close($dbhandle)" there should be
> assumption, that the script will not use database anymore (until ev. next
> "sqlite_open"), so all ev. other handles related to database contents should
> be immediately removed.
You are not checking the return code of the sqlite3 connection close.
sqlite3_close can fail with:
SQLITE_MISUSE
SQLITE_BUSY -> "Unable to close due to unfinalised statements"
SQLITE_ERROR
see http://sqlite.org/capi3ref.html#sqlite3_close
I have no idea if the PHP sqlite3 wrapper propogates these errors, as
the return code of sqlite3_close is not examined (see PHP wrapper below).
Perhaps PHP somehow calls sqlite3_errcode() - who knows. It's a question
for the PHP people.
static int sqlite_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
{
pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
if (H) {
pdo_sqlite_error_info *einfo = &H->einfo;
pdo_sqlite_cleanup_callbacks(H TSRMLS_CC);
if (H->db) {
sqlite3_close(H->db);
H->db = NULL;
}
if (einfo->errmsg) {
pefree(einfo->errmsg, dbh->is_persistent);
einfo->errmsg = NULL;
}
pefree(H, dbh->is_persistent);
dbh->driver_data = NULL;
}
return 0;
}
____________________________________________________________________________________
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------