View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0037645 | FPC | Database | public | 2020-08-27 03:15 | 2020-11-24 10:11 |
Reporter | Luiz Americo | Assigned To | Michael Van Canneyt | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | i386 | OS | Windows | ||
Product Version | 3.3.1 | ||||
Fixed in Version | 3.3.1 | ||||
Summary | 0037645: SqlDb: Calling TSQLQuery.Prepare directly, opening, closing and re opening does not work with IBConnection | ||||
Description | When TSQLQuery.Prepare is called directly, query is open, closed and re opened, it does not work with IBConnection. This use case is tested in TTestTSQLQuery.TestPrepareCount2 from DBTestFramework Below is a patch that disposes cursor memory on UnPrepareStatement instead of FreeFldBuffers, making the cursor memory allocation balanced between PrepareStatement and UnPrepareStatement. This fixes the access violation, but now fails with another error: TIBConnection : Fetch : -Dynamic SQL Error -SQL error code = -502 -Attempt to reopen an open cursor Exception class: EIBDatabaseError at $006B6208 TIBCONNECTION__CHECKERROR, line 195 of D:/repositories/fpc-playground/packages/fcl-db/src/sqldb/interbase/ibconnection.pp | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 47400 | ||||
FPCOldBugId | |||||
FPCTarget | 3.2.2 | ||||
Attached Files |
|
parent of | 0038124 | assigned | Michael Van Canneyt | Regression after r47400: Firebird cannot CREATE or ALTER TABLE anymore |
related to | 0031231 | resolved | Michael Van Canneyt | procedure TCustomSQLQuery.Prepare does not work |
Not all the children of this issue are yet resolved or closed. |
|
ibconnection-prepare-crash.diff (1,014 bytes)
diff --git packages/fcl-db/src/sqldb/interbase/ibconnection.pp packages/fcl-db/src/sqldb/interbase/ibconnection.pp index 51127ab83..7926f2b4c 100644 --- packages/fcl-db/src/sqldb/interbase/ibconnection.pp +++ packages/fcl-db/src/sqldb/interbase/ibconnection.pp @@ -899,6 +899,7 @@ procedure TIBConnection.UnPrepareStatement(cursor : TSQLCursor); begin with cursor as TIBcursor do + begin if assigned(StatementHandle) Then begin if isc_dsql_free_statement(@Status[0], @StatementHandle, DSQL_Drop) <> 0 then @@ -906,6 +907,9 @@ begin StatementHandle := nil; FPrepared := False; end; + FreeSQLDABuffer(SQLDA); + FreeSQLDABuffer(in_SQLDA); + end; end; procedure TIBConnection.FreeSQLDABuffer(var aSQLDA : PXSQLDA); @@ -949,8 +953,6 @@ procedure TIBConnection.FreeFldBuffers(cursor : TSQLCursor); begin with cursor as TIBCursor do begin - FreeSQLDABuffer(SQLDA); - FreeSQLDABuffer(in_SQLDA); SetLength(FieldBinding,0); end; end; |
|
Fixed. Your patch was partially correct. Turns out you need to create a cursor within firebird when using prepared queries. We never noticed because we closed the statement when closing the dataset prior to the prepare fixes... Thanks for reporting and for the patch. |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-08-27 03:15 | Luiz Americo | New Issue | |
2020-08-27 03:15 | Luiz Americo | File Added: ibconnection-prepare-crash.diff | |
2020-08-27 09:07 | Michael Van Canneyt | Assigned To | => Michael Van Canneyt |
2020-08-27 09:07 | Michael Van Canneyt | Status | new => assigned |
2020-11-12 16:01 | Michael Van Canneyt | Status | assigned => resolved |
2020-11-12 16:01 | Michael Van Canneyt | Resolution | open => fixed |
2020-11-12 16:01 | Michael Van Canneyt | Fixed in Version | => 3.3.1 |
2020-11-12 16:01 | Michael Van Canneyt | Fixed in Revision | => 47400 |
2020-11-12 16:01 | Michael Van Canneyt | FPCTarget | => 3.2.2 |
2020-11-12 16:01 | Michael Van Canneyt | Note Added: 0126862 | |
2020-11-14 00:34 | Michael Van Canneyt | Relationship added | related to 0031231 |
2020-11-24 10:11 | Ondrej Pokorny | Relationship added | parent of 0038124 |