mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 21:23:03 +01:00
Backport sub-task CORE-1647 : Close external table's file even if it used by some cached (inactive) requests.
It also fixed bug CORE-2475 : External table data not visible to other sessions in Classic.
This commit is contained in:
parent
b1e58c9bbf
commit
915429e5fe
@ -601,3 +601,43 @@ void EXT_trans_start(jrd_tra* transaction)
|
||||
**************************************/
|
||||
}
|
||||
|
||||
void EXT_tra_attach(ExternalFile* file, jrd_tra*)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* E X T _ t r a _ a t t a c h
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Transaction going to use external table.
|
||||
* Increment transactions use count.
|
||||
*
|
||||
**************************************/
|
||||
|
||||
file->ext_tra_cnt++;
|
||||
}
|
||||
|
||||
void EXT_tra_detach(ExternalFile* file, jrd_tra*)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* E X T _ t r a _ d e t a c h
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Transaction used external table is finished.
|
||||
* Decrement transactions use count and close
|
||||
* external file if count is zero.
|
||||
*
|
||||
**************************************/
|
||||
|
||||
file->ext_tra_cnt--;
|
||||
if (!file->ext_tra_cnt && file->ext_ifi)
|
||||
{
|
||||
fclose(file->ext_ifi);
|
||||
file->ext_ifi = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ class ExternalFile : public pool_alloc_rpt<SCHAR, type_ext>
|
||||
#endif
|
||||
//UCHAR* ext_stuff; // Random stuff
|
||||
USHORT ext_flags; /* Misc and cruddy flags */
|
||||
USHORT ext_tra_cnt; // How many transactions used file
|
||||
#ifdef VMS
|
||||
int ext_ifi; /* Internal file identifier */
|
||||
int ext_isi; /* Internal stream (default) */
|
||||
|
@ -55,5 +55,8 @@ void EXT_trans_prepare(Jrd::jrd_tra*);
|
||||
void EXT_trans_rollback(Jrd::jrd_tra*);
|
||||
void EXT_trans_start(Jrd::jrd_tra*);
|
||||
|
||||
void EXT_tra_attach(Jrd::ExternalFile*, Jrd::jrd_tra*);
|
||||
void EXT_tra_detach(Jrd::ExternalFile*, Jrd::jrd_tra*);
|
||||
|
||||
#endif // JRD_EXT_PROTO_H
|
||||
|
||||
|
@ -819,6 +819,9 @@ void TRA_post_resources(thread_db* tdbb, jrd_tra* transaction, ResourceList& res
|
||||
switch (rsc->rsc_type) {
|
||||
case Resource::rsc_relation:
|
||||
MET_post_existence(tdbb, rsc->rsc_rel);
|
||||
if (rsc->rsc_rel->rel_file) {
|
||||
EXT_tra_attach(rsc->rsc_rel->rel_file, transaction);
|
||||
}
|
||||
break;
|
||||
case Resource::rsc_procedure:
|
||||
rsc->rsc_prc->prc_use_count++;
|
||||
@ -1077,6 +1080,12 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction)
|
||||
rsc < transaction->tra_resources.end(); rsc++)
|
||||
{
|
||||
switch (rsc->rsc_type) {
|
||||
case Resource::rsc_relation:
|
||||
MET_release_existence(rsc->rsc_rel);
|
||||
if (rsc->rsc_rel->rel_file) {
|
||||
EXT_tra_detach(rsc->rsc_rel->rel_file, transaction);
|
||||
}
|
||||
break;
|
||||
case Resource::rsc_procedure:
|
||||
CMP_decrement_prc_use_count(tdbb, rsc->rsc_prc);
|
||||
break;
|
||||
@ -1084,8 +1093,7 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction)
|
||||
rsc->rsc_coll->decUseCount(tdbb);
|
||||
break;
|
||||
default:
|
||||
MET_release_existence(rsc->rsc_rel);
|
||||
break;
|
||||
fb_assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user