Subject | Re: Important RE: [IBO] IBOQuery and Refresh |
---|---|
Author | Helen Borrie |
Post date | 2007-09-20T01:18:58Z |
At 06:24 PM 13/09/2007, I wrote:
to test it, the fix is copied below. A new sub-release will follow soon.
Helen
==========================================================
The fix is in IB_Components.pas
function TIB_BDataset.SysLookupKeyForBufferFields(
ANodeRef: TIB_NodeRef ): boolean;
var
tmpNode: PIB_Node;
procedure DoScrollFailed;
begin
with NodeList, KeyFields do
begin
Result := false;
with tmpNode^ do
begin
if RecordData <> nil then
FreeMem( RecordData, RecordLen );
FreeMem( KeyData, BufferLength );
end;
FreeMem( tmpNode, SizEof( tmpNode ));
end;
end;
procedure GetSeekCursor;
var
ii: integer;
LookupSQL: string;
FPrmCnt: integer;
incAdj: integer;
SPrmCnt: integer;
SPrmAdj: integer;
MonitorText: string;
tmpOldParamOrder: boolean;
begin
tmpOldParamOrder := false;
if Assigned( IB_Connection ) then
tmpOldParamOrder := IB_Connection.OldParameterOrder;
FPrmCnt := MakeLookupSQL( ServerSQL,
KeySQLSelect,
KeyLinks,
LookupSQL,
SPrmCnt,
tmpOldParamOrder );
if @FSeekCursor^ = nil then
IB_Connection.AllocateStmtHandle( @FSeekCursor );
incAdj := 0;
if {( not Refined ) and} Assigned( OrderingParam ) then
incAdj := 1;
if Assigned( PSeekDA ) then
begin
FreeMem( PSeekDA );
PSeekDA := nil;
end;
PSeekDA := AllocMem( XSQLDA_LENGTH( KeyFields.PSQLDA.SQLn +
Params.PSQLDA.SQLn - incAdj ));
PSeekDA.version := SQLDA_VERSION1;
PSeekDA.sqld := KeyFields.PSQLDA.SQLn + Params.PSQLDA.SQLn - incAdj - SPrmCnt;
PSeekDA.sqln := KeyFields.PSQLDA.SQLn + Params.PSQLDA.SQLn - incAdj - SPrmCnt;
with IB_Session do
begin
errcode := isc_dsql_prepare( @status,
PtrHandle,
@FSeekCursor,
Length( LookupSQL ),
pchar( LookupSQL ),
IB_Connection.SQLDialect,
KeyFields.PSQLDA );
if ( errcode = 0 ) then
begin
FSeekCursorPrepared := true;
if ClientMonitorHooksIn then
begin
MonitorText :=
'//>>> STATEMENT PREPARED <<<//'#13#10 +
'TIB_BDataset.SysLookupKeyForBufferFields.GetSeekCursor()'#13#10 +
Self.ClassName + ': "';
if Assigned( Self.Owner ) and ( Self.Owner.Name <> '' ) then
MonitorText := MonitorText + Self.Owner.Name + '.';
MonitorText := MonitorText + Self.Name +
'" stHandle=' + IntToStr(Integer(@FSeekCursor^)) + ' #SC';
OutputToMonitor( MonitorText );
end;
end
else
HandleException( Self );
end;
for ii := 0 to FPrmCnt - 1 do
PSeekDA.SQLVAR[ii] := Params.PSQLDA.SQLVAR[ii];
for ii := 0 to KeyFields.PSQLDA.SQLn - 1 do
PSeekDA.SQLVAR[ii + FPrmCnt] := KeyFields.PSQLDA.SQLVAR[ii];
SPrmAdj := SPrmCnt;
if tmpOldParamOrder then
SPrmAdj := 0;
for ii := 0 to Params.PSQLDA.SQLn - 1 - FPrmCnt - incAdj - SPrmCnt do
PSeekDA.SQLVAR[ii + FPrmCnt + KeyFields.PSQLDA.SQLn] :=
Params.PSQLDA.SQLVAR[ii + FPrmCnt {jlw} + SPrmAdj {jlw}];
end;
>In fact, Petr really has discovered a regression bug. I've set upJason has done a fix for this bug. For Petr Hartman and others who would like
>some test cases for Jason using Petr's sample database but, in the
>meantime, ParameterOrder support in IBO 4.8.x is not working safely
>for TDataset components. You will need to configure
>OldParameterOrdering=1 in firebird.conf for both Fb 1.5.x and 2.x.
>
>NOTE There is no sign of the problem in the native TIB_ data access.
to test it, the fix is copied below. A new sub-release will follow soon.
Helen
==========================================================
The fix is in IB_Components.pas
function TIB_BDataset.SysLookupKeyForBufferFields(
ANodeRef: TIB_NodeRef ): boolean;
var
tmpNode: PIB_Node;
procedure DoScrollFailed;
begin
with NodeList, KeyFields do
begin
Result := false;
with tmpNode^ do
begin
if RecordData <> nil then
FreeMem( RecordData, RecordLen );
FreeMem( KeyData, BufferLength );
end;
FreeMem( tmpNode, SizEof( tmpNode ));
end;
end;
procedure GetSeekCursor;
var
ii: integer;
LookupSQL: string;
FPrmCnt: integer;
incAdj: integer;
SPrmCnt: integer;
SPrmAdj: integer;
MonitorText: string;
tmpOldParamOrder: boolean;
begin
tmpOldParamOrder := false;
if Assigned( IB_Connection ) then
tmpOldParamOrder := IB_Connection.OldParameterOrder;
FPrmCnt := MakeLookupSQL( ServerSQL,
KeySQLSelect,
KeyLinks,
LookupSQL,
SPrmCnt,
tmpOldParamOrder );
if @FSeekCursor^ = nil then
IB_Connection.AllocateStmtHandle( @FSeekCursor );
incAdj := 0;
if {( not Refined ) and} Assigned( OrderingParam ) then
incAdj := 1;
if Assigned( PSeekDA ) then
begin
FreeMem( PSeekDA );
PSeekDA := nil;
end;
PSeekDA := AllocMem( XSQLDA_LENGTH( KeyFields.PSQLDA.SQLn +
Params.PSQLDA.SQLn - incAdj ));
PSeekDA.version := SQLDA_VERSION1;
PSeekDA.sqld := KeyFields.PSQLDA.SQLn + Params.PSQLDA.SQLn - incAdj - SPrmCnt;
PSeekDA.sqln := KeyFields.PSQLDA.SQLn + Params.PSQLDA.SQLn - incAdj - SPrmCnt;
with IB_Session do
begin
errcode := isc_dsql_prepare( @status,
PtrHandle,
@FSeekCursor,
Length( LookupSQL ),
pchar( LookupSQL ),
IB_Connection.SQLDialect,
KeyFields.PSQLDA );
if ( errcode = 0 ) then
begin
FSeekCursorPrepared := true;
if ClientMonitorHooksIn then
begin
MonitorText :=
'//>>> STATEMENT PREPARED <<<//'#13#10 +
'TIB_BDataset.SysLookupKeyForBufferFields.GetSeekCursor()'#13#10 +
Self.ClassName + ': "';
if Assigned( Self.Owner ) and ( Self.Owner.Name <> '' ) then
MonitorText := MonitorText + Self.Owner.Name + '.';
MonitorText := MonitorText + Self.Name +
'" stHandle=' + IntToStr(Integer(@FSeekCursor^)) + ' #SC';
OutputToMonitor( MonitorText );
end;
end
else
HandleException( Self );
end;
for ii := 0 to FPrmCnt - 1 do
PSeekDA.SQLVAR[ii] := Params.PSQLDA.SQLVAR[ii];
for ii := 0 to KeyFields.PSQLDA.SQLn - 1 do
PSeekDA.SQLVAR[ii + FPrmCnt] := KeyFields.PSQLDA.SQLVAR[ii];
SPrmAdj := SPrmCnt;
if tmpOldParamOrder then
SPrmAdj := 0;
for ii := 0 to Params.PSQLDA.SQLn - 1 - FPrmCnt - incAdj - SPrmCnt do
PSeekDA.SQLVAR[ii + FPrmCnt + KeyFields.PSQLDA.SQLn] :=
Params.PSQLDA.SQLVAR[ii + FPrmCnt {jlw} + SPrmAdj {jlw}];
end;