summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authormichael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-11-30 17:13:07 +0000
committermichael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-11-30 17:13:07 +0000
commit25c2246be37e98406da07ee991117e61421b4891 (patch)
tree953e2936bd1ce1e1e3b37e50a8e14eecfc4f0753 /packages
parentc2f368b23470a908cc039b1d88299d50bddf7627 (diff)
downloadfpc-25c2246be37e98406da07ee991117e61421b4891.tar.gz
* Only set cursor name for selectable queries
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@47643 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages')
-rw-r--r--packages/fcl-db/src/sqldb/interbase/ibconnection.pp34
1 files changed, 28 insertions, 6 deletions
diff --git a/packages/fcl-db/src/sqldb/interbase/ibconnection.pp b/packages/fcl-db/src/sqldb/interbase/ibconnection.pp
index 985594d081..35fa20d25a 100644
--- a/packages/fcl-db/src/sqldb/interbase/ibconnection.pp
+++ b/packages/fcl-db/src/sqldb/interbase/ibconnection.pp
@@ -49,6 +49,7 @@ type
in_SQLDA : PXSQLDA;
ParamBinding : array of integer;
FieldBinding : array of integer;
+ CursorName : String;
end;
TIBTrans = Class(TSQLHandle)
@@ -70,6 +71,7 @@ type
FBlobSegmentSize : word; //required for backward compatibilty; not used
FUseConnectionCharSetIfNone: Boolean;
FWireCompression : Boolean;
+ FCursorCount : Integer;
procedure ConnectFB;
procedure AllocSQLDA(var aSQLDA : PXSQLDA;Count : integer);
@@ -773,6 +775,7 @@ begin
curs.sqlda := nil;
curs.StatementHandle := nil;
curs.FPrepared := False;
+ curs.CursorName:='';
AllocSQLDA(curs.SQLDA,0);
result := curs;
end;
@@ -809,6 +812,7 @@ begin
begin
DatabaseHandle := GetHandle;
TransactionHandle := aTransaction.Handle;
+ CursorName:='';
if isc_dsql_allocate_statement(@Status[0], @DatabaseHandle, @StatementHandle) <> 0 then
CheckError('PrepareStatement', Status);
@@ -908,6 +912,7 @@ begin
CheckError('FreeStatement', Status);
StatementHandle := nil;
FPrepared := False;
+ CursorName:='';
end;
FreeSQLDABuffer(SQLDA);
FreeSQLDABuffer(in_SQLDA);
@@ -950,21 +955,29 @@ begin
FieldNameQuoteChars := NoQuotes
else
FieldNameQuoteChars := DoubleQuotes;
+ FCursorCount:=0;
end;
procedure TIBConnection.FreeFldBuffers(cursor : TSQLCursor);
+
begin
with cursor as TIBCursor do
begin
- if isc_dsql_free_statement(@Status, @StatementHandle, DSQL_close)<>0 then
- CheckError('Close Cursor', Status);
+ if FSelectable and (CursorName<>'') then
+ begin
+ if isc_dsql_free_statement(@Status, @StatementHandle, DSQL_close)<>0 then
+ CheckError('Close Cursor', Status); // Ignore this, it can already be closed.
+ end;
end;
end;
procedure TIBConnection.Execute(cursor: TSQLCursor;atransaction:tSQLtransaction; AParams : TParams);
-var TransactionHandle : pointer;
- out_SQLDA : PXSQLDA;
+var
+ TransactionHandle : pointer;
+ out_SQLDA : PXSQLDA;
+ S: String;
+
begin
TransactionHandle := aTransaction.Handle;
if Assigned(APArams) and (AParams.count > 0) then SetParameters(cursor, atransaction, AParams);
@@ -978,8 +991,17 @@ begin
out_SQLDA := nil;
if isc_dsql_execute2(@Status[0], @TransactionHandle, @StatementHandle, 1, in_SQLDA, out_SQLDA) <> 0 then
CheckError('Execute', Status);
- if isc_dsql_set_cursor_name(@Status[0], @StatementHandle, 'sqldbcursor', 0) <> 0 then
- CheckError('Open Cursor', Status);
+ if FSelectable then
+ begin
+ if CursorName='' then
+ begin
+ Inc(FCursorCount);
+ CursorName:='sqldbcursor'+IntToStr(FCursorCount);
+ end;
+ if isc_dsql_set_cursor_name(@Status[0], @StatementHandle, PChar(CursorName) , 0) <> 0 then
+ CheckError('Open Cursor', Status);
+ end
+ else
end;
end;