Browse Source

* Do not use an old connection handle when the connection is reconnected, bug #16438 + test

git-svn-id: trunk@15349 -
joost 15 years ago
parent
commit
25fd20f055

+ 2 - 1
packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

@@ -279,7 +279,6 @@ Var
 
 begin
   Res:= TSQLite3Cursor.create;
-  Res.fhandle:=self.fhandle;
   Result:=Res;
 end;
 
@@ -291,6 +290,7 @@ end;
 procedure TSQLite3Connection.PrepareStatement(cursor: TSQLCursor;
                ATransaction: TSQLTransaction; buf: string; AParams: TParams);
 begin
+  TSQLite3Cursor(cursor).fhandle:=self.fhandle;
   TSQLite3Cursor(cursor).Prepare(Buf,AParams);
 end;
 
@@ -298,6 +298,7 @@ procedure TSQLite3Connection.UnPrepareStatement(cursor: TSQLCursor);
 
 begin
   TSQLite3Cursor(cursor).UnPrepare;
+  TSQLite3Cursor(cursor).fhandle:=nil;
 end;
 
 

+ 16 - 0
packages/fcl-db/tests/testfieldtypes.pas

@@ -88,6 +88,7 @@ type
     procedure TestAggregates;
 
     procedure TestStringLargerThen8192;
+    procedure TestQueryAfterReconnect; // bug 16438
 
     // SchemaType tests
     procedure TestTableNames;
@@ -930,6 +931,21 @@ begin
     inherited RunTest;
 end;
 
+procedure TTestFieldTypes.TestQueryAfterReconnect;
+var DS: TDataset;
+begin
+  ds := DBConnector.GetNDataset(true,5);
+  with ds do
+    begin
+    open;
+    close;
+    TSQLDBConnector(DBConnector).Connection.Close;
+    TSQLDBConnector(DBConnector).Connection.Open;
+    open;
+    close;
+    end;
+end;
+
 procedure TTestFieldTypes.TestLocateNull;
 var DS: TCustomBufDataset;
 begin