mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 20:09:27 +02:00
* Patches from Joost van der Sluis
interbase.pp: * Removed unused Fprepared * Changed the error message 'database connect string not filled in' to 'database connect string (databasename) not filled in' * Preparestatement and execute now checks if transaction is assigned (in stead of crashing if it isn't) and if the transaction isn't started, it calls starttransaction. dataset.inc: * In DoInternalOpen the buffers are now initialised before the dataset is set into browse-state database.inc and db.pp: * If the dataset is created from a stream, the database is opened after the dataset is read completely
This commit is contained in:
parent
54d1baf9ec
commit
c1e1d4f8d8
@ -36,7 +36,8 @@ end;
|
|||||||
procedure TDataBase.Loaded;
|
procedure TDataBase.Loaded;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//!! To be implemented.
|
inherited;
|
||||||
|
if FOpenAfterRead then SetConnected(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDataBase.SetConnected (Value : boolean);
|
procedure TDataBase.SetConnected (Value : boolean);
|
||||||
@ -45,11 +46,21 @@ begin
|
|||||||
If Value<>FConnected then
|
If Value<>FConnected then
|
||||||
begin
|
begin
|
||||||
If Value then
|
If Value then
|
||||||
DoInternalConnect
|
begin
|
||||||
|
if csLoading in ComponentState then
|
||||||
|
begin
|
||||||
|
FOpenAfterRead := true;
|
||||||
|
exit;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
DoInternalConnect;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Closedatasets;
|
Closedatasets;
|
||||||
DoInternalDisConnect;
|
DoInternalDisConnect;
|
||||||
|
if csloading in ComponentState then
|
||||||
|
FOpenAfterRead := false;
|
||||||
end;
|
end;
|
||||||
FConnected:=Value;
|
FConnected:=Value;
|
||||||
end;
|
end;
|
||||||
@ -193,7 +204,25 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.4 2003-08-16 16:42:21 michael
|
Revision 1.5 2004-07-25 11:32:40 michael
|
||||||
|
* Patches from Joost van der Sluis
|
||||||
|
interbase.pp:
|
||||||
|
* Removed unused Fprepared
|
||||||
|
* Changed the error message 'database connect string not filled
|
||||||
|
in' to 'database connect string (databasename) not filled in'
|
||||||
|
* Preparestatement and execute now checks if transaction is
|
||||||
|
assigned (in stead of crashing if it isn't) and if the
|
||||||
|
transaction isn't started, it calls starttransaction.
|
||||||
|
|
||||||
|
dataset.inc:
|
||||||
|
* In DoInternalOpen the buffers are now initialised before the
|
||||||
|
dataset is set into browse-state
|
||||||
|
|
||||||
|
database.inc and db.pp:
|
||||||
|
* If the dataset is created from a stream, the database is opened
|
||||||
|
after the dataset is read completely
|
||||||
|
|
||||||
|
Revision 1.4 2003/08/16 16:42:21 michael
|
||||||
+ Fixes in TDBDataset etc. Changed MySQLDb to use database as well
|
+ Fixes in TDBDataset etc. Changed MySQLDb to use database as well
|
||||||
|
|
||||||
Revision 1.3 2002/09/07 15:15:22 peter
|
Revision 1.3 2002/09/07 15:15:22 peter
|
||||||
|
@ -323,9 +323,8 @@ begin
|
|||||||
InternalOpen;
|
InternalOpen;
|
||||||
FBOF:=True;
|
FBOF:=True;
|
||||||
{$ifdef dsdebug}
|
{$ifdef dsdebug}
|
||||||
Writeln ('Setting state to browse');
|
Writeln ('Setting buffer size');
|
||||||
{$endif}
|
{$endif}
|
||||||
SetState(dsBrowse);
|
|
||||||
{$ifdef dsdebug}
|
{$ifdef dsdebug}
|
||||||
Writeln ('Setting buffer size');
|
Writeln ('Setting buffer size');
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -338,6 +337,10 @@ begin
|
|||||||
*)
|
*)
|
||||||
RecalcBufListSize;
|
RecalcBufListSize;
|
||||||
//SetBufferCount(DefaultBufferCount);
|
//SetBufferCount(DefaultBufferCount);
|
||||||
|
{$ifdef dsdebug}
|
||||||
|
Writeln ('Setting state to browse');
|
||||||
|
{$endif}
|
||||||
|
SetState(dsBrowse);
|
||||||
DoAfterOpen;
|
DoAfterOpen;
|
||||||
DoAfterScroll;
|
DoAfterScroll;
|
||||||
except
|
except
|
||||||
@ -573,7 +576,7 @@ Var Shifted : boolean;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
{$ifdef dsdebug}
|
{$ifdef dsdebug}
|
||||||
Writeln ('Getting previous record');
|
Writeln ('GetPriorRecord: Getting previous record');
|
||||||
{$endif}
|
{$endif}
|
||||||
Shifted:=FRecordCount>0;
|
Shifted:=FRecordCount>0;
|
||||||
If Shifted Then
|
If Shifted Then
|
||||||
@ -1076,7 +1079,7 @@ begin
|
|||||||
SetBookMarkFlag(Buffer,bfEOF);
|
SetBookMarkFlag(Buffer,bfEOF);
|
||||||
FRecordCount:=1;
|
FRecordCount:=1;
|
||||||
{$ifdef dsdebug}
|
{$ifdef dsdebug}
|
||||||
Writeln ('getting prior records');
|
Writeln ('DoInsertAppend: getting prior records');
|
||||||
{$endif}
|
{$endif}
|
||||||
GetPriorRecords;
|
GetPriorRecords;
|
||||||
// update active record.
|
// update active record.
|
||||||
@ -1535,25 +1538,37 @@ Var Count,ShiftCount : Longint;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
// See if we can find the requested record.
|
// See if we can find the requested record.
|
||||||
|
{$ifdef dsdebug}
|
||||||
|
Writeln ('Resync called');
|
||||||
|
{$endif}
|
||||||
If rmExact in Mode then
|
If rmExact in Mode then
|
||||||
begin
|
begin
|
||||||
|
{$ifdef dsdebug}
|
||||||
|
Writeln ('Exact resync');
|
||||||
|
{$endif}
|
||||||
{ throw an exception if not found.
|
{ throw an exception if not found.
|
||||||
Normally the descendant should do this if DoCheck is true. }
|
Normally the descendant should do this if DoCheck is true. }
|
||||||
If GetRecord(Fbuffers[FRecordCount],gmcurrent,True)<>grOk Then
|
If GetRecord(Fbuffers[FRecordCount-1],gmcurrent,True)<>grOk Then
|
||||||
DatabaseError(SNoSuchRecord,Self);
|
DatabaseError(SNoSuchRecord,Self);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{ Can we find a record in the neighbourhood ?
|
{ Can we find a record in the neighbourhood ?
|
||||||
Use Shortcut evaluation for this, or we'll have some funny results. }
|
Use Shortcut evaluation for this, or we'll have some funny results. }
|
||||||
If (GetRecord(Fbuffers[FRecordCount],gmcurrent,True)<>grOk) and
|
If (GetRecord(Fbuffers[FRecordCount-1],gmcurrent,True)<>grOk) and
|
||||||
(GetRecord(Fbuffers[FRecordCount],gmprior,True)<>grOk) and
|
(GetRecord(Fbuffers[FRecordCount-1],gmprior,True)<>grOk) and
|
||||||
(GetRecord(Fbuffers[FRecordCount],gmprior,True)<>grOk) then
|
(GetRecord(Fbuffers[FRecordCount-1],gmprior,True)<>grOk) then
|
||||||
begin
|
begin
|
||||||
|
{$ifdef dsdebug}
|
||||||
|
Writeln ('Resync: fuzzy resync');
|
||||||
|
{$endif}
|
||||||
// nothing found, invalidate buffer and bail out.
|
// nothing found, invalidate buffer and bail out.
|
||||||
ClearBuffers;
|
ClearBuffers;
|
||||||
DataEvent(deDatasetChange,0);
|
DataEvent(deDatasetChange,0);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
{$ifdef dsdebug}
|
||||||
|
Writeln ('Resync: Center in resync: ',(rmCenter in Mode));
|
||||||
|
{$endif}
|
||||||
If (rmCenter in Mode) then
|
If (rmCenter in Mode) then
|
||||||
ShiftCount:=FbufferCount div 2
|
ShiftCount:=FbufferCount div 2
|
||||||
else
|
else
|
||||||
@ -1561,17 +1576,23 @@ begin
|
|||||||
ShiftCount:=FActiveRecord;
|
ShiftCount:=FActiveRecord;
|
||||||
// Reposition on 0
|
// Reposition on 0
|
||||||
ShiftBuffers(0,FRecordCount-1);
|
ShiftBuffers(0,FRecordCount-1);
|
||||||
|
{$ifdef dsdebug}
|
||||||
|
Writeln ('Resync: activating buffers');
|
||||||
|
{$endif}
|
||||||
ActivateBuffers;
|
ActivateBuffers;
|
||||||
try
|
try
|
||||||
Count:=0;
|
Count:=0;
|
||||||
{$ifdef dsdebug}
|
{$ifdef dsdebug}
|
||||||
Writeln ('Getting previous',ShiftCount,' records');
|
Writeln ('Resync: Getting previous ',ShiftCount,' records');
|
||||||
{$endif}
|
{$endif}
|
||||||
While (Count<ShiftCount) and GetPriorRecord do
|
While (Count<ShiftCount) and GetPriorRecord do
|
||||||
Inc(Count);
|
Inc(Count);
|
||||||
FActiveRecord:=Count;
|
FActiveRecord:=Count;
|
||||||
// fill rest of buffers, adjust ActiveBuffer.
|
// fill rest of buffers, adjust ActiveBuffer.
|
||||||
SetCurrentRecord(FRecordCount);
|
{$ifdef dsdebug}
|
||||||
|
Writeln ('Resync: Set current record to ',FRecordCount,' records');
|
||||||
|
{$endif}
|
||||||
|
SetCurrentRecord(FRecordCount-1);
|
||||||
GetNextRecords;
|
GetNextRecords;
|
||||||
Inc(FActiveRecord,GetPriorRecords);
|
Inc(FActiveRecord,GetPriorRecords);
|
||||||
finally
|
finally
|
||||||
@ -1719,8 +1740,23 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.14 2004-07-16 19:37:40 michael
|
Revision 1.15 2004-07-25 11:32:40 michael
|
||||||
+ Fix in resync for empty table
|
* Patches from Joost van der Sluis
|
||||||
|
interbase.pp:
|
||||||
|
* Removed unused Fprepared
|
||||||
|
* Changed the error message 'database connect string not filled
|
||||||
|
in' to 'database connect string (databasename) not filled in'
|
||||||
|
* Preparestatement and execute now checks if transaction is
|
||||||
|
assigned (in stead of crashing if it isn't) and if the
|
||||||
|
transaction isn't started, it calls starttransaction.
|
||||||
|
|
||||||
|
dataset.inc:
|
||||||
|
* In DoInternalOpen the buffers are now initialised before the
|
||||||
|
dataset is set into browse-state
|
||||||
|
|
||||||
|
database.inc and db.pp:
|
||||||
|
* If the dataset is created from a stream, the database is opened
|
||||||
|
after the dataset is read completely
|
||||||
|
|
||||||
Revision 1.13 2004/05/02 21:23:18 peter
|
Revision 1.13 2004/05/02 21:23:18 peter
|
||||||
* use ptrint
|
* use ptrint
|
||||||
|
21
fcl/db/db.pp
21
fcl/db/db.pp
@ -1207,6 +1207,7 @@ type
|
|||||||
FOnLogin : TLoginEvent;
|
FOnLogin : TLoginEvent;
|
||||||
FParams : TStrings;
|
FParams : TStrings;
|
||||||
FSQLBased : Boolean;
|
FSQLBased : Boolean;
|
||||||
|
FOpenAfterRead : boolean;
|
||||||
Function GetDataSetCount : Longint;
|
Function GetDataSetCount : Longint;
|
||||||
Function GetDataset(Index : longint) : TDBDataset;
|
Function GetDataset(Index : longint) : TDBDataset;
|
||||||
procedure SetConnected (Value : boolean);
|
procedure SetConnected (Value : boolean);
|
||||||
@ -1499,7 +1500,25 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.18 2004-07-19 20:27:28 michael
|
Revision 1.19 2004-07-25 11:32:40 michael
|
||||||
|
* Patches from Joost van der Sluis
|
||||||
|
interbase.pp:
|
||||||
|
* Removed unused Fprepared
|
||||||
|
* Changed the error message 'database connect string not filled
|
||||||
|
in' to 'database connect string (databasename) not filled in'
|
||||||
|
* Preparestatement and execute now checks if transaction is
|
||||||
|
assigned (in stead of crashing if it isn't) and if the
|
||||||
|
transaction isn't started, it calls starttransaction.
|
||||||
|
|
||||||
|
dataset.inc:
|
||||||
|
* In DoInternalOpen the buffers are now initialised before the
|
||||||
|
dataset is set into browse-state
|
||||||
|
|
||||||
|
database.inc and db.pp:
|
||||||
|
* If the dataset is created from a stream, the database is opened
|
||||||
|
after the dataset is read completely
|
||||||
|
|
||||||
|
Revision 1.18 2004/07/19 20:27:28 michael
|
||||||
+ Fixes from Jesus Reyes to implement DisplayWith, DisplayLabel, Visibility
|
+ Fixes from Jesus Reyes to implement DisplayWith, DisplayLabel, Visibility
|
||||||
|
|
||||||
Revision 1.17 2004/07/18 13:16:50 michael
|
Revision 1.17 2004/07/18 13:16:50 michael
|
||||||
|
@ -204,7 +204,6 @@ type
|
|||||||
FRecordSize : word;
|
FRecordSize : word;
|
||||||
FCurrentRecord : integer;
|
FCurrentRecord : integer;
|
||||||
FSQL : TStrings;
|
FSQL : TStrings;
|
||||||
FPrepared : boolean;
|
|
||||||
FIsEOF : boolean;
|
FIsEOF : boolean;
|
||||||
FStatementType : TStatementType;
|
FStatementType : TStatementType;
|
||||||
FLoadingFieldDefs : boolean;
|
FLoadingFieldDefs : boolean;
|
||||||
@ -416,7 +415,7 @@ begin
|
|||||||
DPB := DPB + Chr(isc_dpb_lc_ctype) + Chr(Length(CharSet)) + CharSet;
|
DPB := DPB + Chr(isc_dpb_lc_ctype) + Chr(Length(CharSet)) + CharSet;
|
||||||
|
|
||||||
if (DatabaseName = '') then
|
if (DatabaseName = '') then
|
||||||
raise EInterBaseError.Create('TIBDatabase.Open: Database connect string not filled in!');
|
raise EInterBaseError.Create('TIBDatabase.Open: Database connect string (DatabaseName) not filled in!');
|
||||||
FIBDatabaseHandle := nil;
|
FIBDatabaseHandle := nil;
|
||||||
if isc_attach_database(@FStatus, Length(DatabaseName), @DatabaseName[1], @FIBDatabaseHandle,
|
if isc_attach_database(@FStatus, Length(DatabaseName), @DatabaseName[1], @FIBDatabaseHandle,
|
||||||
Length(DPB), @DPB[1]) <> 0 then
|
Length(DPB), @DPB[1]) <> 0 then
|
||||||
@ -635,6 +634,11 @@ var
|
|||||||
x : integer;
|
x : integer;
|
||||||
tr : pointer;
|
tr : pointer;
|
||||||
begin
|
begin
|
||||||
|
if FTransaction = nil then
|
||||||
|
raise EDatabaseError.Create('TIBQuery.Execute: Transaction not set');
|
||||||
|
if not FTransaction.Active then
|
||||||
|
FTransaction.StartTransaction;
|
||||||
|
|
||||||
tr := FTransaction.GetHandle;
|
tr := FTransaction.GetHandle;
|
||||||
|
|
||||||
for x := 0 to FSQL.Count - 1 do
|
for x := 0 to FSQL.Count - 1 do
|
||||||
@ -861,6 +865,10 @@ procedure TIBQuery.Execute;
|
|||||||
var
|
var
|
||||||
tr : pointer;
|
tr : pointer;
|
||||||
begin
|
begin
|
||||||
|
if FTransaction = nil then
|
||||||
|
raise EDatabaseError.Create('TIBQuery.Execute: Transaction not set');
|
||||||
|
if not FTransaction.Active then
|
||||||
|
FTransaction.StartTransaction;
|
||||||
tr := FTransaction.GetHandle;
|
tr := FTransaction.GetHandle;
|
||||||
if isc_dsql_execute(@FStatus, @tr, @FStatement, 1, nil) <> 0 then
|
if isc_dsql_execute(@FStatus, @tr, @FStatement, 1, nil) <> 0 then
|
||||||
CheckError('TIBQuery.Execute', FStatus);
|
CheckError('TIBQuery.Execute', FStatus);
|
||||||
@ -1200,7 +1208,25 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.12 2004-05-01 23:56:59 michael
|
Revision 1.13 2004-07-25 11:32:40 michael
|
||||||
|
* Patches from Joost van der Sluis
|
||||||
|
interbase.pp:
|
||||||
|
* Removed unused Fprepared
|
||||||
|
* Changed the error message 'database connect string not filled
|
||||||
|
in' to 'database connect string (databasename) not filled in'
|
||||||
|
* Preparestatement and execute now checks if transaction is
|
||||||
|
assigned (in stead of crashing if it isn't) and if the
|
||||||
|
transaction isn't started, it calls starttransaction.
|
||||||
|
|
||||||
|
dataset.inc:
|
||||||
|
* In DoInternalOpen the buffers are now initialised before the
|
||||||
|
dataset is set into browse-state
|
||||||
|
|
||||||
|
database.inc and db.pp:
|
||||||
|
* If the dataset is created from a stream, the database is opened
|
||||||
|
after the dataset is read completely
|
||||||
|
|
||||||
|
Revision 1.12 2004/05/01 23:56:59 michael
|
||||||
+ Published TDataset properties
|
+ Published TDataset properties
|
||||||
|
|
||||||
Revision 1.11 2003/12/07 23:13:34 sg
|
Revision 1.11 2003/12/07 23:13:34 sg
|
||||||
|
Loading…
Reference in New Issue
Block a user