mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-27 09:53:09 +02:00
TBufDataset.inc:
- replaced Freemem by Reallocmem, Free by FreeAndNil Database.inc: - Moved Active property from TSQLTransaction to TDBTransaction - Gives an error if the database of an active transaction is changed Dataset.inc - Don't distribute events if FDisableControlsCount > 0 - Replaced FActive by FState<>dsInactive - Set EOF after append db.pp: - Removed duplicate definition of TAlignment - Moved Active property from TSQLTransaction to TDBTransaction - Replaced FActive by FState<>dsInactive - Gives an error if the database of an active transaction is changed sqldb: - Moved Active property from TSQLTransaction to TDBTransaction - replaced Freemem by Reallocmem, Free by FreeAndNil IBConnection: - Moved FSQLDAAllocated to the cursor PQConnection: - Don't try to free the statement if a fatal error occured
This commit is contained in:
parent
0909db20ec
commit
cae7e81d73
@ -46,7 +46,7 @@ end;
|
|||||||
|
|
||||||
procedure TBufDataset.FreeRecordBuffer(var Buffer: PChar);
|
procedure TBufDataset.FreeRecordBuffer(var Buffer: PChar);
|
||||||
begin
|
begin
|
||||||
FreeMem(Buffer);
|
ReAllocMem(Buffer,0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBufDataset.InternalOpen;
|
procedure TBufDataset.InternalOpen;
|
||||||
@ -65,7 +65,7 @@ var i : integer;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
for i := 0 to FBRecordCount-1 do FreeRecord(FBBuffers[i]);
|
for i := 0 to FBRecordCount-1 do FreeRecord(FBBuffers[i]);
|
||||||
If FBRecordCount > 0 then freemem(FBBuffers);
|
If FBRecordCount > 0 then ReAllocMem(FBBuffers,0);
|
||||||
FBRecordcount := 0;
|
FBRecordcount := 0;
|
||||||
FBBuffercount := 0;
|
FBBuffercount := 0;
|
||||||
FBCurrentrecord := -1;
|
FBCurrentrecord := -1;
|
||||||
|
@ -287,10 +287,58 @@ end;
|
|||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
TDBTransaction
|
TDBTransaction
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
procedure TDBTransaction.SetActive(Value : boolean);
|
||||||
|
begin
|
||||||
|
if FActive and (not Value) then
|
||||||
|
EndTransaction
|
||||||
|
else if (not FActive) and Value then
|
||||||
|
if csLoading in ComponentState then
|
||||||
|
begin
|
||||||
|
FOpenAfterRead := true;
|
||||||
|
exit;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
StartTransaction;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDBTransaction.Loaded;
|
||||||
|
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
if FOpenAfterRead then SetActive(true);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Procedure TDBTransaction.CheckActive;
|
||||||
|
|
||||||
|
begin
|
||||||
|
If not FActive Then
|
||||||
|
DatabaseError(STransNotActive,Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure TDBTransaction.CheckInActive;
|
||||||
|
|
||||||
|
begin
|
||||||
|
If FActive Then
|
||||||
|
DatabaseError(STransActive,Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure TDBTransaction.CloseTrans;
|
||||||
|
|
||||||
|
begin
|
||||||
|
FActive := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure TDBTransaction.OpenTrans;
|
||||||
|
|
||||||
|
begin
|
||||||
|
FActive := true;
|
||||||
|
end;
|
||||||
|
|
||||||
Procedure TDBTransaction.SetDatabase (Value : TDatabase);
|
Procedure TDBTransaction.SetDatabase (Value : TDatabase);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// CheckInactive;
|
CheckInactive;
|
||||||
If Value<>FDatabase then
|
If Value<>FDatabase then
|
||||||
begin
|
begin
|
||||||
If Assigned(FDatabase) then
|
If Assigned(FDatabase) then
|
||||||
@ -390,7 +438,36 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.7 2004-10-27 07:23:13 michael
|
Revision 1.8 2004-11-05 08:32:02 michael
|
||||||
|
TBufDataset.inc:
|
||||||
|
- replaced Freemem by Reallocmem, Free by FreeAndNil
|
||||||
|
|
||||||
|
Database.inc:
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- Gives an error if the database of an active transaction is changed
|
||||||
|
|
||||||
|
Dataset.inc
|
||||||
|
- Don't distribute events if FDisableControlsCount > 0
|
||||||
|
- Replaced FActive by FState<>dsInactive
|
||||||
|
- Set EOF after append
|
||||||
|
|
||||||
|
db.pp:
|
||||||
|
- Removed duplicate definition of TAlignment
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- Replaced FActive by FState<>dsInactive
|
||||||
|
- Gives an error if the database of an active transaction is changed
|
||||||
|
|
||||||
|
sqldb:
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- replaced Freemem by Reallocmem, Free by FreeAndNil
|
||||||
|
|
||||||
|
IBConnection:
|
||||||
|
- Moved FSQLDAAllocated to the cursor
|
||||||
|
|
||||||
|
PQConnection:
|
||||||
|
- Don't try to free the statement if a fatal error occured
|
||||||
|
|
||||||
|
Revision 1.7 2004/10/27 07:23:13 michael
|
||||||
+ Patch from Joost Van der Sluis to fix transactions
|
+ Patch from Joost Van der Sluis to fix transactions
|
||||||
|
|
||||||
Revision 1.6 2004/09/26 16:55:24 michael
|
Revision 1.6 2004/09/26 16:55:24 michael
|
||||||
|
@ -187,8 +187,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// Distribute event to datasets;
|
// Distribute event to datasets;
|
||||||
for I := 0 to FDataSources.Count - 1 do
|
if FDisableControlsCount = 0 then
|
||||||
TDataSource(FDataSources[I]).ProcessEvent(Event, Info);
|
for I := 0 to FDataSources.Count - 1 do
|
||||||
|
TDataSource(FDataSources[I]).ProcessEvent(Event, Info);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TDataset.DestroyFields;
|
Procedure TDataset.DestroyFields;
|
||||||
@ -652,21 +653,27 @@ begin
|
|||||||
dec(FDisableControlsCount);
|
dec(FDisableControlsCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDataset.GetActive : boolean;
|
||||||
|
|
||||||
|
begin
|
||||||
|
result := FState <> dsInactive;
|
||||||
|
end;
|
||||||
|
|
||||||
Procedure TDataset.SetActive (Value : Boolean);
|
Procedure TDataset.SetActive (Value : Boolean);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Value<>Factive then
|
if value and (Fstate = dsInactive) then
|
||||||
If Value then
|
begin
|
||||||
if csLoading in ComponentState then
|
if csLoading in ComponentState then
|
||||||
begin
|
begin
|
||||||
FOpenAfterRead := true;
|
FOpenAfterRead := true;
|
||||||
exit;
|
exit;
|
||||||
end
|
end
|
||||||
else
|
|
||||||
DoInternalOpen
|
|
||||||
else
|
else
|
||||||
DoInternalClose(True);
|
DoInternalOpen;
|
||||||
FActive:=Value;
|
end
|
||||||
|
else if not value and (Fstate <> dsinactive) then
|
||||||
|
DoInternalClose(True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDataset.Loaded;
|
procedure TDataset.Loaded;
|
||||||
@ -1126,7 +1133,8 @@ begin
|
|||||||
GetPriorRecords;
|
GetPriorRecords;
|
||||||
FActiveRecord:=FRecordCount-1;
|
FActiveRecord:=FRecordCount-1;
|
||||||
DoInsert;
|
DoInsert;
|
||||||
SetBookmarkFlag(ActiveBuffer,bfEOF)
|
SetBookmarkFlag(ActiveBuffer,bfEOF);
|
||||||
|
FEOF := true;
|
||||||
end;
|
end;
|
||||||
SetState(dsInsert);
|
SetState(dsInsert);
|
||||||
try
|
try
|
||||||
@ -1733,7 +1741,36 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.27 2004-10-27 07:23:13 michael
|
Revision 1.28 2004-11-05 08:32:02 michael
|
||||||
|
TBufDataset.inc:
|
||||||
|
- replaced Freemem by Reallocmem, Free by FreeAndNil
|
||||||
|
|
||||||
|
Database.inc:
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- Gives an error if the database of an active transaction is changed
|
||||||
|
|
||||||
|
Dataset.inc
|
||||||
|
- Don't distribute events if FDisableControlsCount > 0
|
||||||
|
- Replaced FActive by FState<>dsInactive
|
||||||
|
- Set EOF after append
|
||||||
|
|
||||||
|
db.pp:
|
||||||
|
- Removed duplicate definition of TAlignment
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- Replaced FActive by FState<>dsInactive
|
||||||
|
- Gives an error if the database of an active transaction is changed
|
||||||
|
|
||||||
|
sqldb:
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- replaced Freemem by Reallocmem, Free by FreeAndNil
|
||||||
|
|
||||||
|
IBConnection:
|
||||||
|
- Moved FSQLDAAllocated to the cursor
|
||||||
|
|
||||||
|
PQConnection:
|
||||||
|
- Don't try to free the statement if a fatal error occured
|
||||||
|
|
||||||
|
Revision 1.27 2004/10/27 07:23:13 michael
|
||||||
+ Patch from Joost Van der Sluis to fix transactions
|
+ Patch from Joost Van der Sluis to fix transactions
|
||||||
|
|
||||||
Revision 1.26 2004/10/16 09:27:23 michael
|
Revision 1.26 2004/10/16 09:27:23 michael
|
||||||
|
52
fcl/db/db.pp
52
fcl/db/db.pp
@ -171,8 +171,6 @@ type
|
|||||||
TFieldSetTextEvent = procedure(Sender: TField; const Text: string) of object;
|
TFieldSetTextEvent = procedure(Sender: TField; const Text: string) of object;
|
||||||
TFieldRef = ^TField;
|
TFieldRef = ^TField;
|
||||||
TFieldChars = set of Char;
|
TFieldChars = set of Char;
|
||||||
{ TAlignment may need to come from somewhere else }
|
|
||||||
TAlignMent = (taLeftjustify,taCenter,taRightJustify);
|
|
||||||
|
|
||||||
TField = class(TComponent)
|
TField = class(TComponent)
|
||||||
Private
|
Private
|
||||||
@ -773,7 +771,6 @@ type
|
|||||||
|
|
||||||
TDataSet = class(TComponent)
|
TDataSet = class(TComponent)
|
||||||
Private
|
Private
|
||||||
FActive: Boolean;
|
|
||||||
FOpenAfterRead : boolean;
|
FOpenAfterRead : boolean;
|
||||||
FActiveRecord: Longint;
|
FActiveRecord: Longint;
|
||||||
FAfterCancel: TDataSetNotifyEvent;
|
FAfterCancel: TDataSetNotifyEvent;
|
||||||
@ -841,6 +838,7 @@ type
|
|||||||
Procedure ShiftBuffersForward;
|
Procedure ShiftBuffersForward;
|
||||||
Procedure ShiftBuffersBackward;
|
Procedure ShiftBuffersBackward;
|
||||||
Function TryDoing (P : TDataOperation; Ev : TDatasetErrorEvent) : Boolean;
|
Function TryDoing (P : TDataOperation; Ev : TDatasetErrorEvent) : Boolean;
|
||||||
|
Function GetActive : boolean;
|
||||||
Procedure UnRegisterDataSource(ADatasource : TDatasource);
|
Procedure UnRegisterDataSource(ADatasource : TDatasource);
|
||||||
Procedure UpdateFieldDefs;
|
Procedure UpdateFieldDefs;
|
||||||
protected
|
protected
|
||||||
@ -1023,7 +1021,7 @@ type
|
|||||||
property Filter: string read FFilterText write SetFilterText;
|
property Filter: string read FFilterText write SetFilterText;
|
||||||
property Filtered: Boolean read FFiltered write SetFiltered default False;
|
property Filtered: Boolean read FFiltered write SetFiltered default False;
|
||||||
property FilterOptions: TFilterOptions read FFilterOptions write FFilterOptions;
|
property FilterOptions: TFilterOptions read FFilterOptions write FFilterOptions;
|
||||||
property Active: Boolean read FActive write SetActive default False;
|
property Active: Boolean read GetActive write SetActive default False;
|
||||||
property AutoCalcFields: Boolean read FAutoCalcFields write FAutoCalcFields;
|
property AutoCalcFields: Boolean read FAutoCalcFields write FAutoCalcFields;
|
||||||
property BeforeOpen: TDataSetNotifyEvent read FBeforeOpen write FBeforeOpen;
|
property BeforeOpen: TDataSetNotifyEvent read FBeforeOpen write FBeforeOpen;
|
||||||
property AfterOpen: TDataSetNotifyEvent read FAfterOpen write FAfterOpen;
|
property AfterOpen: TDataSetNotifyEvent read FAfterOpen write FAfterOpen;
|
||||||
@ -1201,22 +1199,33 @@ type
|
|||||||
TDBTransactionClass = Class of TDBTransaction;
|
TDBTransactionClass = Class of TDBTransaction;
|
||||||
TDBTransaction = Class(TComponent)
|
TDBTransaction = Class(TComponent)
|
||||||
Private
|
Private
|
||||||
FDatabase : TDatabase;
|
FActive : boolean;
|
||||||
FDataSets : TList;
|
FDatabase : TDatabase;
|
||||||
|
FDataSets : TList;
|
||||||
|
FOpenAfterRead : boolean;
|
||||||
Procedure SetDatabase (Value : TDatabase);
|
Procedure SetDatabase (Value : TDatabase);
|
||||||
Function GetDataSetCount : Longint;
|
Function GetDataSetCount : Longint;
|
||||||
Function GetDataset(Index : longint) : TDBDataset;
|
Function GetDataset(Index : longint) : TDBDataset;
|
||||||
procedure RegisterDataset (DS : TDBDataset);
|
procedure RegisterDataset (DS : TDBDataset);
|
||||||
procedure UnRegisterDataset (DS : TDBDataset);
|
procedure UnRegisterDataset (DS : TDBDataset);
|
||||||
procedure RemoveDataSets;
|
procedure RemoveDataSets;
|
||||||
|
procedure SetActive(Value : boolean);
|
||||||
Protected
|
Protected
|
||||||
|
procedure CloseTrans;
|
||||||
|
procedure openTrans;
|
||||||
Procedure CheckDatabase;
|
Procedure CheckDatabase;
|
||||||
|
Procedure CheckActive;
|
||||||
|
Procedure CheckInactive;
|
||||||
procedure EndTransaction; virtual; abstract;
|
procedure EndTransaction; virtual; abstract;
|
||||||
|
procedure StartTransaction; virtual; abstract;
|
||||||
|
procedure Loaded; override;
|
||||||
Public
|
Public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
Destructor destroy; override;
|
Destructor destroy; override;
|
||||||
procedure CloseDataSets;
|
procedure CloseDataSets;
|
||||||
Property DataBase : TDatabase Read FDatabase Write SetDatabase;
|
Property DataBase : TDatabase Read FDatabase Write SetDatabase;
|
||||||
|
published
|
||||||
|
property Active : boolean read FActive write setactive;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TDatabase }
|
{ TDatabase }
|
||||||
@ -1583,7 +1592,36 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.27 2004-10-27 07:23:13 michael
|
Revision 1.28 2004-11-05 08:32:02 michael
|
||||||
|
TBufDataset.inc:
|
||||||
|
- replaced Freemem by Reallocmem, Free by FreeAndNil
|
||||||
|
|
||||||
|
Database.inc:
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- Gives an error if the database of an active transaction is changed
|
||||||
|
|
||||||
|
Dataset.inc
|
||||||
|
- Don't distribute events if FDisableControlsCount > 0
|
||||||
|
- Replaced FActive by FState<>dsInactive
|
||||||
|
- Set EOF after append
|
||||||
|
|
||||||
|
db.pp:
|
||||||
|
- Removed duplicate definition of TAlignment
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- Replaced FActive by FState<>dsInactive
|
||||||
|
- Gives an error if the database of an active transaction is changed
|
||||||
|
|
||||||
|
sqldb:
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- replaced Freemem by Reallocmem, Free by FreeAndNil
|
||||||
|
|
||||||
|
IBConnection:
|
||||||
|
- Moved FSQLDAAllocated to the cursor
|
||||||
|
|
||||||
|
PQConnection:
|
||||||
|
- Don't try to free the statement if a fatal error occured
|
||||||
|
|
||||||
|
Revision 1.27 2004/10/27 07:23:13 michael
|
||||||
+ Patch from Joost Van der Sluis to fix transactions
|
+ Patch from Joost Van der Sluis to fix transactions
|
||||||
|
|
||||||
Revision 1.26 2004/10/10 14:45:51 michael
|
Revision 1.26 2004/10/10 14:45:51 michael
|
||||||
|
@ -34,6 +34,8 @@ Const
|
|||||||
SErrNoStatement = 'SQL statement not set';
|
SErrNoStatement = 'SQL statement not set';
|
||||||
SErrTransAlreadyActive = 'Transaction already active';
|
SErrTransAlreadyActive = 'Transaction already active';
|
||||||
SErrTransactionnSet = 'Transaction not set';
|
SErrTransactionnSet = 'Transaction not set';
|
||||||
|
STransNotActive = 'Operation cannot be performed on an inactive transaction';
|
||||||
|
STransActive = 'Operation cannot be performed on an active transaction';
|
||||||
SFieldNotFound = 'Field not found : "%s"';
|
SFieldNotFound = 'Field not found : "%s"';
|
||||||
SInactiveDataset = 'Operation cannot be performed on an inactive dataset';
|
SInactiveDataset = 'Operation cannot be performed on an inactive dataset';
|
||||||
SInvalidDisplayValues = '"%s" are not valid boolean displayvalues';
|
SInvalidDisplayValues = '"%s" are not valid boolean displayvalues';
|
||||||
@ -66,7 +68,36 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 2004-10-27 07:23:13 michael
|
Revision 1.4 2004-11-05 08:32:02 michael
|
||||||
|
TBufDataset.inc:
|
||||||
|
- replaced Freemem by Reallocmem, Free by FreeAndNil
|
||||||
|
|
||||||
|
Database.inc:
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- Gives an error if the database of an active transaction is changed
|
||||||
|
|
||||||
|
Dataset.inc
|
||||||
|
- Don't distribute events if FDisableControlsCount > 0
|
||||||
|
- Replaced FActive by FState<>dsInactive
|
||||||
|
- Set EOF after append
|
||||||
|
|
||||||
|
db.pp:
|
||||||
|
- Removed duplicate definition of TAlignment
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- Replaced FActive by FState<>dsInactive
|
||||||
|
- Gives an error if the database of an active transaction is changed
|
||||||
|
|
||||||
|
sqldb:
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- replaced Freemem by Reallocmem, Free by FreeAndNil
|
||||||
|
|
||||||
|
IBConnection:
|
||||||
|
- Moved FSQLDAAllocated to the cursor
|
||||||
|
|
||||||
|
PQConnection:
|
||||||
|
- Don't try to free the statement if a fatal error occured
|
||||||
|
|
||||||
|
Revision 1.3 2004/10/27 07:23:13 michael
|
||||||
+ Patch from Joost Van der Sluis to fix transactions
|
+ Patch from Joost Van der Sluis to fix transactions
|
||||||
|
|
||||||
Revision 1.2 2004/10/16 09:20:25 michael
|
Revision 1.2 2004/10/16 09:20:25 michael
|
||||||
|
@ -17,9 +17,10 @@ type
|
|||||||
|
|
||||||
TIBCursor = Class(TSQLHandle)
|
TIBCursor = Class(TSQLHandle)
|
||||||
protected
|
protected
|
||||||
Status : array [0..19] of ISC_STATUS;
|
Status : array [0..19] of ISC_STATUS;
|
||||||
Statement : pointer;
|
Statement : pointer;
|
||||||
SQLDA : PXSQLDA;
|
FSQLDAAllocated : integer;
|
||||||
|
SQLDA : PXSQLDA;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TIBTrans = Class(TSQLHandle)
|
TIBTrans = Class(TSQLHandle)
|
||||||
@ -35,7 +36,6 @@ type
|
|||||||
|
|
||||||
TIBConnection = class (TSQLConnection)
|
TIBConnection = class (TSQLConnection)
|
||||||
private
|
private
|
||||||
FSQLDAAllocated : integer;
|
|
||||||
FSQLDatabaseHandle : pointer;
|
FSQLDatabaseHandle : pointer;
|
||||||
FStatus : array [0..19] of ISC_STATUS;
|
FStatus : array [0..19] of ISC_STATUS;
|
||||||
FFieldFlag : array [0..1023] of shortint;
|
FFieldFlag : array [0..1023] of shortint;
|
||||||
|
@ -300,6 +300,7 @@ procedure TPQConnection.FreeStatement(cursor : TSQLHandle);
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
with cursor as TPQCursor do
|
with cursor as TPQCursor do
|
||||||
|
if (PQresultStatus(res) <> PGRES_FATAL_ERROR) then //Don't try to do anything if the transaction has already encountered an error.
|
||||||
begin
|
begin
|
||||||
if StatementType = stselect then
|
if StatementType = stselect then
|
||||||
begin
|
begin
|
||||||
@ -307,7 +308,7 @@ begin
|
|||||||
if (PQresultStatus(res) <> PGRES_COMMAND_OK) then
|
if (PQresultStatus(res) <> PGRES_COMMAND_OK) then
|
||||||
begin
|
begin
|
||||||
pqclear(res);
|
pqclear(res);
|
||||||
DatabaseError(SErrClearSelection + ' (PostgreSQL: ' + PQerrorMessage(tr) + ')',self);
|
DatabaseError(SErrClearSelection + ' (PostgreSQL: ' + PQerrorMessage(tr) + ')',self)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
pqclear(baseres);
|
pqclear(baseres);
|
||||||
@ -335,7 +336,7 @@ begin
|
|||||||
if (PQresultStatus(res) <> PGRES_COMMAND_OK) then
|
if (PQresultStatus(res) <> PGRES_COMMAND_OK) then
|
||||||
begin
|
begin
|
||||||
pqclear(res);
|
pqclear(res);
|
||||||
DatabaseError(SErrExecuteFailed + ' (PostgreSQL: ' + PQerrorMessage(tr) + ')',self)
|
DatabaseError(SErrExecuteFailed + ' (PostgreSQL: ' + PQerrorMessage(tr) + ')',self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -111,26 +111,20 @@ type
|
|||||||
private
|
private
|
||||||
FTrans : TSQLHandle;
|
FTrans : TSQLHandle;
|
||||||
FAction : TCommitRollbackAction;
|
FAction : TCommitRollbackAction;
|
||||||
FActive : boolean;
|
|
||||||
FOpenAfterRead : boolean;
|
|
||||||
|
|
||||||
procedure SetActive(Value : boolean);
|
|
||||||
protected
|
protected
|
||||||
function GetHandle : Pointer; virtual;
|
function GetHandle : Pointer; virtual;
|
||||||
procedure Loaded; override;
|
|
||||||
public
|
public
|
||||||
procedure Commit; virtual;
|
procedure Commit; virtual;
|
||||||
procedure CommitRetaining; virtual;
|
procedure CommitRetaining; virtual;
|
||||||
procedure Rollback; virtual;
|
procedure Rollback; virtual;
|
||||||
procedure RollbackRetaining; virtual;
|
procedure RollbackRetaining; virtual;
|
||||||
procedure StartTransaction; virtual;
|
procedure StartTransaction; override;
|
||||||
constructor Create(AOwner : TComponent); override;
|
constructor Create(AOwner : TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
property Handle: Pointer read GetHandle;
|
property Handle: Pointer read GetHandle;
|
||||||
procedure EndTransaction; override;
|
procedure EndTransaction; override;
|
||||||
published
|
published
|
||||||
property Action : TCommitRollbackAction read FAction write FAction;
|
property Action : TCommitRollbackAction read FAction write FAction;
|
||||||
property Active : boolean read FActive write setactive;
|
|
||||||
property Database;
|
property Database;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -275,28 +269,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ TSQLTransaction }
|
{ TSQLTransaction }
|
||||||
|
|
||||||
procedure TSQLTransaction.SetActive(Value : boolean);
|
|
||||||
begin
|
|
||||||
if FActive and (not Value) then
|
|
||||||
EndTransaction
|
|
||||||
else if (not FActive) and Value then
|
|
||||||
if csLoading in ComponentState then
|
|
||||||
begin
|
|
||||||
FOpenAfterRead := true;
|
|
||||||
exit;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
StartTransaction;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSQLTransaction.Loaded;
|
|
||||||
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
if FOpenAfterRead then SetActive(true);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSQLTransaction.EndTransaction;
|
procedure TSQLTransaction.EndTransaction;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -310,35 +282,35 @@ end;
|
|||||||
|
|
||||||
procedure TSQLTransaction.Commit;
|
procedure TSQLTransaction.Commit;
|
||||||
begin
|
begin
|
||||||
if not FActive then Exit;
|
checkactive;
|
||||||
closedatasets;
|
closedatasets;
|
||||||
if (Database as tsqlconnection).commit(FTrans) then
|
if (Database as tsqlconnection).commit(FTrans) then
|
||||||
begin
|
begin
|
||||||
FActive := false;
|
closeTrans;
|
||||||
FTrans.free;
|
FreeAndNil(FTrans);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSQLTransaction.CommitRetaining;
|
procedure TSQLTransaction.CommitRetaining;
|
||||||
begin
|
begin
|
||||||
if not FActive then Exit;
|
CheckActive;
|
||||||
(Database as tsqlconnection).commitRetaining(FTrans);
|
(Database as tsqlconnection).commitRetaining(FTrans);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSQLTransaction.Rollback;
|
procedure TSQLTransaction.Rollback;
|
||||||
begin
|
begin
|
||||||
if not FActive then Exit;
|
CheckActive;
|
||||||
closedatasets;
|
closedatasets;
|
||||||
if (Database as tsqlconnection).RollBack(FTrans) then
|
if (Database as tsqlconnection).RollBack(FTrans) then
|
||||||
begin
|
begin
|
||||||
FActive := false;
|
CloseTrans;
|
||||||
FTrans.free;
|
FreeAndNil(FTrans);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSQLTransaction.RollbackRetaining;
|
procedure TSQLTransaction.RollbackRetaining;
|
||||||
begin
|
begin
|
||||||
if not FActive then Exit;
|
CheckActive;
|
||||||
(Database as tsqlconnection).RollBackRetaining(FTrans);
|
(Database as tsqlconnection).RollBackRetaining(FTrans);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -359,7 +331,7 @@ begin
|
|||||||
Db.Open;
|
Db.Open;
|
||||||
if not assigned(FTrans) then FTrans := Db.AllocateTransactionHandle;
|
if not assigned(FTrans) then FTrans := Db.AllocateTransactionHandle;
|
||||||
|
|
||||||
if Db.StartdbTransaction(FTrans) then FActive := true;
|
if Db.StartdbTransaction(FTrans) then OpenTrans;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TSQLTransaction.Create(AOwner : TComponent);
|
constructor TSQLTransaction.Create(AOwner : TComponent);
|
||||||
@ -393,7 +365,7 @@ begin
|
|||||||
if assigned(FCursor) then
|
if assigned(FCursor) then
|
||||||
begin
|
begin
|
||||||
(Database as tsqlconnection).FreeStatement(FCursor);
|
(Database as tsqlconnection).FreeStatement(FCursor);
|
||||||
FCursor.free;
|
FreeAndNil(FCursor);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -415,7 +387,7 @@ begin
|
|||||||
sqltr := (transaction as tsqltransaction);
|
sqltr := (transaction as tsqltransaction);
|
||||||
if not sqltr.Active then sqltr.StartTransaction;
|
if not sqltr.Active then sqltr.StartTransaction;
|
||||||
|
|
||||||
if assigned(fcursor) then FCursor.free;
|
if assigned(fcursor) then FreeAndNil(fcursor);
|
||||||
FCursor := Db.AllocateCursorHandle;
|
FCursor := Db.AllocateCursorHandle;
|
||||||
|
|
||||||
for x := 0 to FSQL.Count - 1 do
|
for x := 0 to FSQL.Count - 1 do
|
||||||
@ -501,7 +473,7 @@ begin
|
|||||||
if DefaultFields then
|
if DefaultFields then
|
||||||
DestroyFields;
|
DestroyFields;
|
||||||
FIsEOF := False;
|
FIsEOF := False;
|
||||||
FRecordSize := 0;
|
// FRecordSize := 0;
|
||||||
FOpen:=False;
|
FOpen:=False;
|
||||||
inherited internalclose;
|
inherited internalclose;
|
||||||
end;
|
end;
|
||||||
@ -595,7 +567,7 @@ destructor TSQLQuery.Destroy;
|
|||||||
begin
|
begin
|
||||||
if Active then Close;
|
if Active then Close;
|
||||||
// if assigned(FCursor) then FCursor.destroy;
|
// if assigned(FCursor) then FCursor.destroy;
|
||||||
FSQL.Free;
|
FreeAndNil(FSQL);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -658,7 +630,36 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.6 2004-10-27 07:23:13 michael
|
Revision 1.7 2004-11-05 08:32:02 michael
|
||||||
|
TBufDataset.inc:
|
||||||
|
- replaced Freemem by Reallocmem, Free by FreeAndNil
|
||||||
|
|
||||||
|
Database.inc:
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- Gives an error if the database of an active transaction is changed
|
||||||
|
|
||||||
|
Dataset.inc
|
||||||
|
- Don't distribute events if FDisableControlsCount > 0
|
||||||
|
- Replaced FActive by FState<>dsInactive
|
||||||
|
- Set EOF after append
|
||||||
|
|
||||||
|
db.pp:
|
||||||
|
- Removed duplicate definition of TAlignment
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- Replaced FActive by FState<>dsInactive
|
||||||
|
- Gives an error if the database of an active transaction is changed
|
||||||
|
|
||||||
|
sqldb:
|
||||||
|
- Moved Active property from TSQLTransaction to TDBTransaction
|
||||||
|
- replaced Freemem by Reallocmem, Free by FreeAndNil
|
||||||
|
|
||||||
|
IBConnection:
|
||||||
|
- Moved FSQLDAAllocated to the cursor
|
||||||
|
|
||||||
|
PQConnection:
|
||||||
|
- Don't try to free the statement if a fatal error occured
|
||||||
|
|
||||||
|
Revision 1.6 2004/10/27 07:23:13 michael
|
||||||
+ Patch from Joost Van der Sluis to fix transactions
|
+ Patch from Joost Van der Sluis to fix transactions
|
||||||
|
|
||||||
Revision 1.5 2004/10/10 14:45:52 michael
|
Revision 1.5 2004/10/10 14:45:52 michael
|
||||||
|
Loading…
Reference in New Issue
Block a user