Subject | Prepared statement with transactions leads to a crash in gds32.dll |
---|---|
Author | Stan |
Post date | 2006-11-02T00:15:33Z |
Hi All,
The following code snippet (php, sorry)
causes a crash in gds32.dll whenever I have
a lock-conflict. Debugger is saying that
the crash is an Access Violation inside
isc_dsql_execute2().
If I run this code from 1 client, everything
works, if I run 2, I get a crash every time.
I am using:
Apache 2.0.54
PHP 5.1.6 (CGI)
Windows XP Pro
Firebird 1.5.3
It works fine if I do NOT use prepared statements.
It works fine if I do not use explicit transaction handling,
but very slow...
I think that I am doing something stupid when I encounter a
lock conflict.
In the php logs I get:
-501 Attempt to reclose a closed cursor
and
invalid transaction handle (expecting explicit transaction start)
what am I doing wrong?
also, Why do I ALWAYS get a lock conflict when using prepared
statements even if I only have 2 concurrent clients?
If do NOT use prepared statements, I rarely get lock-conflicts.
I tried using COMMITED|REC_VERSION and COMMITED|REC_NO_VERSION,
exactly the same behavior.
thanks,
stan
Code Snippet:
----------------------------
$db = ibase_connect (...);
$trans = ibase_trans($db, IBASE_WRITE|IBASE_CONCURRENCY|IBASE_WAIT);
$stmt = ibase_prepare($trans, "SELECT id FROM GET_ID(?,?,?)");
foreach($entries as $entry){
$res = ibase_execute( $stmt, $entry[0], $enty[1], $entry[2]);
if( !$res) {
// lock conflict
// commit all changes thus far
ibase_commit($trans);
ibase_free_query($stmt);
// re-start transaction
$trans = ibase_trans($db, IBASE_WRITE|IBASE_CONCURRENCY|IBASE_WAIT);
// re-prepare the statement
$stmt = ibase_prepare($trans, "SELECT id FROM GET_ID(?,?,?)");
// re-run the query, this time it should always succeed
$res = ibase_execute( $stmt, $entry[0], $enty[1], $entry[2]);
assert($res)
// fetch the data ...
}
}
// commit all changes
ibase_commit($trans);
ibase_free_query($stmt);
ibase_close($db);
-----------------------------------------------
The following code snippet (php, sorry)
causes a crash in gds32.dll whenever I have
a lock-conflict. Debugger is saying that
the crash is an Access Violation inside
isc_dsql_execute2().
If I run this code from 1 client, everything
works, if I run 2, I get a crash every time.
I am using:
Apache 2.0.54
PHP 5.1.6 (CGI)
Windows XP Pro
Firebird 1.5.3
It works fine if I do NOT use prepared statements.
It works fine if I do not use explicit transaction handling,
but very slow...
I think that I am doing something stupid when I encounter a
lock conflict.
In the php logs I get:
-501 Attempt to reclose a closed cursor
and
invalid transaction handle (expecting explicit transaction start)
what am I doing wrong?
also, Why do I ALWAYS get a lock conflict when using prepared
statements even if I only have 2 concurrent clients?
If do NOT use prepared statements, I rarely get lock-conflicts.
I tried using COMMITED|REC_VERSION and COMMITED|REC_NO_VERSION,
exactly the same behavior.
thanks,
stan
Code Snippet:
----------------------------
$db = ibase_connect (...);
$trans = ibase_trans($db, IBASE_WRITE|IBASE_CONCURRENCY|IBASE_WAIT);
$stmt = ibase_prepare($trans, "SELECT id FROM GET_ID(?,?,?)");
foreach($entries as $entry){
$res = ibase_execute( $stmt, $entry[0], $enty[1], $entry[2]);
if( !$res) {
// lock conflict
// commit all changes thus far
ibase_commit($trans);
ibase_free_query($stmt);
// re-start transaction
$trans = ibase_trans($db, IBASE_WRITE|IBASE_CONCURRENCY|IBASE_WAIT);
// re-prepare the statement
$stmt = ibase_prepare($trans, "SELECT id FROM GET_ID(?,?,?)");
// re-run the query, this time it should always succeed
$res = ibase_execute( $stmt, $entry[0], $enty[1], $entry[2]);
assert($res)
// fetch the data ...
}
}
// commit all changes
ibase_commit($trans);
ibase_free_query($stmt);
ibase_close($db);
-----------------------------------------------