瀏覽代碼

* Moved some code to avoid problems while handling exceptions

git-svn-id: trunk@12512 -
joost 16 年之前
父節點
當前提交
d6903a4bb6
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      packages/fcl-db/src/sqldb/sqldb.pp

+ 8 - 2
packages/fcl-db/src/sqldb/sqldb.pp

@@ -919,11 +919,17 @@ begin
     if FSQLBuf = '' then
       DatabaseError(SErrNoStatement);
 
+    SQLParser(FSQLBuf);
+
+    // There may no error occur between the allocation of the cursor and
+    // the preparation of the cursor. Because internalclose (which is called in
+    // case of an exception) assumes that allocated cursors are also prepared,
+    // and thus calls unprepare.
+    // A call to unprepare while the cursor is not prepared at all can lead to
+    // unpredictable results.
     if not assigned(fcursor) then
       FCursor := Db.AllocateCursorHandle;
 
-    SQLParser(FSQLBuf);
-
     if ServerFiltered then
       Db.PrepareStatement(Fcursor,sqltr,AddFilter(FSQLBuf),FParams)
     else