mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 16:03:03 +01:00
Added dedicated method to close Batch interface with errors check
This commit is contained in:
parent
2967e353a6
commit
d46b5182b2
File diff suppressed because it is too large
Load Diff
@ -296,7 +296,7 @@ int main()
|
||||
print_cs(status, cs, utl);
|
||||
|
||||
// close batch
|
||||
batch->release();
|
||||
batch->close(&status);
|
||||
batch = NULL;
|
||||
|
||||
//
|
||||
@ -366,7 +366,7 @@ int main()
|
||||
print_cs(status, cs, utl);
|
||||
|
||||
// close batch
|
||||
batch->release();
|
||||
batch->close(&status);
|
||||
batch = NULL;
|
||||
|
||||
//
|
||||
@ -493,7 +493,7 @@ int main()
|
||||
print_cs(status, cs, utl);
|
||||
|
||||
// cleanup
|
||||
batch->release();
|
||||
batch->close(&status);
|
||||
batch = NULL;
|
||||
tra->commit(&status);
|
||||
tra = NULL;
|
||||
|
@ -516,6 +516,9 @@ interface Batch : ReferenceCounted
|
||||
uint getBlobAlignment(Status status);
|
||||
MessageMetadata getMetadata(Status status);
|
||||
void setDefaultBpb(Status status, uint parLength, const uchar* par);
|
||||
|
||||
version: // added after FB4 RC1
|
||||
void close(Status status);
|
||||
}
|
||||
|
||||
interface BatchCompletionState : Disposable
|
||||
|
@ -1864,6 +1864,7 @@ namespace Firebird
|
||||
unsigned (CLOOP_CARG *getBlobAlignment)(IBatch* self, IStatus* status) throw();
|
||||
IMessageMetadata* (CLOOP_CARG *getMetadata)(IBatch* self, IStatus* status) throw();
|
||||
void (CLOOP_CARG *setDefaultBpb)(IBatch* self, IStatus* status, unsigned parLength, const unsigned char* par) throw();
|
||||
void (CLOOP_CARG *close)(IBatch* self, IStatus* status) throw();
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -1877,7 +1878,7 @@ namespace Firebird
|
||||
}
|
||||
|
||||
public:
|
||||
static const unsigned VERSION = 3;
|
||||
static const unsigned VERSION = 4;
|
||||
|
||||
static const unsigned char VERSION1 = 1;
|
||||
static const unsigned char TAG_MULTIERROR = 1;
|
||||
@ -1963,6 +1964,19 @@ namespace Firebird
|
||||
static_cast<VTable*>(this->cloopVTable)->setDefaultBpb(this, status, parLength, par);
|
||||
StatusType::checkException(status);
|
||||
}
|
||||
|
||||
template <typename StatusType> void close(StatusType* status)
|
||||
{
|
||||
if (cloopVTable->version < 4)
|
||||
{
|
||||
StatusType::setVersionError(status, "IBatch", cloopVTable->version, 4);
|
||||
StatusType::checkException(status);
|
||||
return;
|
||||
}
|
||||
StatusType::clearException(status);
|
||||
static_cast<VTable*>(this->cloopVTable)->close(this, status);
|
||||
StatusType::checkException(status);
|
||||
}
|
||||
};
|
||||
|
||||
class IBatchCompletionState : public IDisposable
|
||||
@ -9785,6 +9799,7 @@ namespace Firebird
|
||||
this->getBlobAlignment = &Name::cloopgetBlobAlignmentDispatcher;
|
||||
this->getMetadata = &Name::cloopgetMetadataDispatcher;
|
||||
this->setDefaultBpb = &Name::cloopsetDefaultBpbDispatcher;
|
||||
this->close = &Name::cloopcloseDispatcher;
|
||||
}
|
||||
} vTable;
|
||||
|
||||
@ -9934,6 +9949,20 @@ namespace Firebird
|
||||
}
|
||||
}
|
||||
|
||||
static void CLOOP_CARG cloopcloseDispatcher(IBatch* self, IStatus* status) throw()
|
||||
{
|
||||
StatusType status2(status);
|
||||
|
||||
try
|
||||
{
|
||||
static_cast<Name*>(self)->Name::close(&status2);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
StatusType::catchException(&status2);
|
||||
}
|
||||
}
|
||||
|
||||
static void CLOOP_CARG cloopaddRefDispatcher(IReferenceCounted* self) throw()
|
||||
{
|
||||
try
|
||||
@ -9983,6 +10012,7 @@ namespace Firebird
|
||||
virtual unsigned getBlobAlignment(StatusType* status) = 0;
|
||||
virtual IMessageMetadata* getMetadata(StatusType* status) = 0;
|
||||
virtual void setDefaultBpb(StatusType* status, unsigned parLength, const unsigned char* par) = 0;
|
||||
virtual void close(StatusType* status) = 0;
|
||||
};
|
||||
|
||||
template <typename Name, typename StatusType, typename Base>
|
||||
|
@ -355,6 +355,7 @@ type
|
||||
IBatch_getBlobAlignmentPtr = function(this: IBatch; status: IStatus): Cardinal; cdecl;
|
||||
IBatch_getMetadataPtr = function(this: IBatch; status: IStatus): IMessageMetadata; cdecl;
|
||||
IBatch_setDefaultBpbPtr = procedure(this: IBatch; status: IStatus; parLength: Cardinal; par: BytePtr); cdecl;
|
||||
IBatch_closePtr = procedure(this: IBatch; status: IStatus); cdecl;
|
||||
IBatchCompletionState_getSizePtr = function(this: IBatchCompletionState; status: IStatus): Cardinal; cdecl;
|
||||
IBatchCompletionState_getStatePtr = function(this: IBatchCompletionState; status: IStatus; pos: Cardinal): Integer; cdecl;
|
||||
IBatchCompletionState_findErrorPtr = function(this: IBatchCompletionState; status: IStatus; pos: Cardinal): Cardinal; cdecl;
|
||||
@ -1508,10 +1509,11 @@ type
|
||||
getBlobAlignment: IBatch_getBlobAlignmentPtr;
|
||||
getMetadata: IBatch_getMetadataPtr;
|
||||
setDefaultBpb: IBatch_setDefaultBpbPtr;
|
||||
close: IBatch_closePtr;
|
||||
end;
|
||||
|
||||
IBatch = class(IReferenceCounted)
|
||||
const VERSION = 3;
|
||||
const VERSION = 4;
|
||||
const VERSION1 = Byte(1);
|
||||
const TAG_MULTIERROR = Byte(1);
|
||||
const TAG_RECORD_COUNTS = Byte(2);
|
||||
@ -1534,6 +1536,7 @@ type
|
||||
function getBlobAlignment(status: IStatus): Cardinal;
|
||||
function getMetadata(status: IStatus): IMessageMetadata;
|
||||
procedure setDefaultBpb(status: IStatus; parLength: Cardinal; par: BytePtr);
|
||||
procedure close(status: IStatus);
|
||||
end;
|
||||
|
||||
IBatchImpl = class(IBatch)
|
||||
@ -1551,6 +1554,7 @@ type
|
||||
function getBlobAlignment(status: IStatus): Cardinal; virtual; abstract;
|
||||
function getMetadata(status: IStatus): IMessageMetadata; virtual; abstract;
|
||||
procedure setDefaultBpb(status: IStatus; parLength: Cardinal; par: BytePtr); virtual; abstract;
|
||||
procedure close(status: IStatus); virtual; abstract;
|
||||
end;
|
||||
|
||||
BatchCompletionStateVTable = class(DisposableVTable)
|
||||
@ -6419,6 +6423,12 @@ begin
|
||||
FbException.checkException(status);
|
||||
end;
|
||||
|
||||
procedure IBatch.close(status: IStatus);
|
||||
begin
|
||||
BatchVTable(vTable).close(Self, status);
|
||||
FbException.checkException(status);
|
||||
end;
|
||||
|
||||
function IBatchCompletionState.getSize(status: IStatus): Cardinal;
|
||||
begin
|
||||
Result := BatchCompletionStateVTable(vTable).getSize(Self, status);
|
||||
@ -10106,6 +10116,15 @@ begin
|
||||
end
|
||||
end;
|
||||
|
||||
procedure IBatchImpl_closeDispatcher(this: IBatch; status: IStatus); cdecl;
|
||||
begin
|
||||
try
|
||||
IBatchImpl(this).close(status);
|
||||
except
|
||||
on e: Exception do FbException.catchException(status, e);
|
||||
end
|
||||
end;
|
||||
|
||||
var
|
||||
IBatchImpl_vTable: BatchVTable;
|
||||
|
||||
@ -14942,7 +14961,7 @@ initialization
|
||||
IStatementImpl_vTable.createBatch := @IStatementImpl_createBatchDispatcher;
|
||||
|
||||
IBatchImpl_vTable := BatchVTable.create;
|
||||
IBatchImpl_vTable.version := 3;
|
||||
IBatchImpl_vTable.version := 4;
|
||||
IBatchImpl_vTable.addRef := @IBatchImpl_addRefDispatcher;
|
||||
IBatchImpl_vTable.release := @IBatchImpl_releaseDispatcher;
|
||||
IBatchImpl_vTable.add := @IBatchImpl_addDispatcher;
|
||||
@ -14955,6 +14974,7 @@ initialization
|
||||
IBatchImpl_vTable.getBlobAlignment := @IBatchImpl_getBlobAlignmentDispatcher;
|
||||
IBatchImpl_vTable.getMetadata := @IBatchImpl_getMetadataDispatcher;
|
||||
IBatchImpl_vTable.setDefaultBpb := @IBatchImpl_setDefaultBpbDispatcher;
|
||||
IBatchImpl_vTable.close := @IBatchImpl_closeDispatcher;
|
||||
|
||||
IBatchCompletionStateImpl_vTable := BatchCompletionStateVTable.create;
|
||||
IBatchCompletionStateImpl_vTable.version := 3;
|
||||
|
@ -201,6 +201,7 @@ public:
|
||||
unsigned getBlobAlignment(Firebird::CheckStatusWrapper* status) override;
|
||||
Firebird::IMessageMetadata* getMetadata(Firebird::CheckStatusWrapper* status) override;
|
||||
void setDefaultBpb(Firebird::CheckStatusWrapper* status, unsigned parLength, const unsigned char* par) override;
|
||||
void close(Firebird::CheckStatusWrapper* status) override;
|
||||
|
||||
public:
|
||||
JBatch(DsqlBatch* handle, JStatement* aStatement, Firebird::IMessageMetadata* aMetadata);
|
||||
|
@ -5877,6 +5877,13 @@ int JBatch::release()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void JBatch::close(CheckStatusWrapper* user_status)
|
||||
{
|
||||
freeEngineData(user_status);
|
||||
}
|
||||
|
||||
|
||||
void JBatch::freeEngineData(Firebird::CheckStatusWrapper* user_status)
|
||||
{
|
||||
try
|
||||
@ -5890,6 +5897,7 @@ void JBatch::freeEngineData(Firebird::CheckStatusWrapper* user_status)
|
||||
if (att)
|
||||
att->deregisterBatch(this);
|
||||
delete batch;
|
||||
batch = nullptr;
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
|
@ -339,6 +339,7 @@ public:
|
||||
unsigned getBlobAlignment(Firebird::CheckStatusWrapper* status) override;
|
||||
void setDefaultBpb(Firebird::CheckStatusWrapper* status, unsigned parLength, const unsigned char* par) override;
|
||||
Firebird::IMessageMetadata* getMetadata(Firebird::CheckStatusWrapper* status) override;
|
||||
void close(Firebird::CheckStatusWrapper* status) override;
|
||||
|
||||
private:
|
||||
void freeClientData(CheckStatusWrapper* status, bool force = false);
|
||||
@ -2809,6 +2810,13 @@ void Batch::freeClientData(CheckStatusWrapper* status, bool force)
|
||||
}
|
||||
|
||||
|
||||
void Batch::close(CheckStatusWrapper* status)
|
||||
{
|
||||
reset(status);
|
||||
freeClientData(status);
|
||||
}
|
||||
|
||||
|
||||
void Batch::releaseStatement()
|
||||
{
|
||||
if (tmpStatement)
|
||||
|
@ -383,6 +383,7 @@ public:
|
||||
Firebird::IBatchCompletionState* execute(Firebird::CheckStatusWrapper* status, Firebird::ITransaction* transaction);
|
||||
void cancel(Firebird::CheckStatusWrapper* status);
|
||||
void setDefaultBpb(Firebird::CheckStatusWrapper* status, unsigned parLength, const unsigned char* par);
|
||||
void close(Firebird::CheckStatusWrapper* status);
|
||||
|
||||
public:
|
||||
AtomicAttPtr attachment;
|
||||
|
@ -5028,6 +5028,25 @@ void YBatch::cancel(CheckStatusWrapper* status)
|
||||
}
|
||||
|
||||
|
||||
void YBatch::close(CheckStatusWrapper* status)
|
||||
{
|
||||
try
|
||||
{
|
||||
YEntry<YBatch> entry(status, this, CHECK_WARN_ZERO_HANDLE);
|
||||
|
||||
if (entry.next())
|
||||
entry.next()->close(status);
|
||||
|
||||
if (!(status->getState() & IStatus::STATE_ERRORS))
|
||||
destroy(DF_RELEASE);
|
||||
}
|
||||
catch (const Exception& e)
|
||||
{
|
||||
e.stuffException(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user