8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 20:43:04 +01:00

Backport fix for CORE-4145 - Memory leak when preparing Execute Block which uses domains.

This commit is contained in:
asfernandes 2013-09-26 15:37:21 +00:00
parent 31bdfdbac4
commit c62e9cfbf5
3 changed files with 37 additions and 53 deletions

View File

@ -178,7 +178,8 @@ static void post_used_procedures(trig_vec* vector)
} }
void MET_get_domain(thread_db* tdbb, const Firebird::MetaName& name, dsc* desc, FieldInfo* fieldInfo) void MET_get_domain(thread_db* tdbb, MemoryPool& csbPool, const Firebird::MetaName& name, dsc* desc,
FieldInfo* fieldInfo)
{ {
/************************************** /**************************************
* *
@ -216,10 +217,8 @@ void MET_get_domain(thread_db* tdbb, const Firebird::MetaName& name, dsc* desc,
{ {
fieldInfo->nullable = FLD.RDB$NULL_FLAG.NULL || FLD.RDB$NULL_FLAG == 0; fieldInfo->nullable = FLD.RDB$NULL_FLAG.NULL || FLD.RDB$NULL_FLAG == 0;
MemoryPool* csb_pool = dbb->createPool(); Jrd::ContextPoolHolder context(tdbb, &csbPool);
Jrd::ContextPoolHolder context(tdbb, csb_pool);
try
{
if (FLD.RDB$DEFAULT_VALUE.NULL) if (FLD.RDB$DEFAULT_VALUE.NULL)
fieldInfo->defaultValue = NULL; fieldInfo->defaultValue = NULL;
else else
@ -230,12 +229,6 @@ void MET_get_domain(thread_db* tdbb, const Firebird::MetaName& name, dsc* desc,
else else
fieldInfo->validation = parse_field_blr(tdbb, &FLD.RDB$VALIDATION_BLR, name); fieldInfo->validation = parse_field_blr(tdbb, &FLD.RDB$VALIDATION_BLR, name);
} }
catch (const Firebird::Exception&)
{
dbb->deletePool(csb_pool);
throw;
}
}
} }
END_FOR; END_FOR;
@ -250,10 +243,8 @@ void MET_get_domain(thread_db* tdbb, const Firebird::MetaName& name, dsc* desc,
} }
Firebird::MetaName MET_get_relation_field(thread_db* tdbb, Firebird::MetaName MET_get_relation_field(thread_db* tdbb, MemoryPool& csbPool,
const Firebird::MetaName& relationName, const Firebird::MetaName& relationName, const Firebird::MetaName& fieldName, dsc* desc,
const Firebird::MetaName& fieldName,
dsc* desc,
FieldInfo* fieldInfo) FieldInfo* fieldInfo)
{ {
/************************************** /**************************************
@ -300,10 +291,7 @@ Firebird::MetaName MET_get_relation_field(thread_db* tdbb,
fieldInfo->nullable = RFL.RDB$NULL_FLAG.NULL ? fieldInfo->nullable = RFL.RDB$NULL_FLAG.NULL ?
(FLD.RDB$NULL_FLAG.NULL || FLD.RDB$NULL_FLAG == 0) : RFL.RDB$NULL_FLAG == 0; (FLD.RDB$NULL_FLAG.NULL || FLD.RDB$NULL_FLAG == 0) : RFL.RDB$NULL_FLAG == 0;
MemoryPool* csb_pool = dbb->createPool(); Jrd::ContextPoolHolder context(tdbb, &csbPool);
Jrd::ContextPoolHolder context(tdbb, csb_pool);
try
{
bid* defaultId = NULL; bid* defaultId = NULL;
if (!RFL.RDB$DEFAULT_VALUE.NULL) if (!RFL.RDB$DEFAULT_VALUE.NULL)
@ -321,12 +309,6 @@ Firebird::MetaName MET_get_relation_field(thread_db* tdbb,
else else
fieldInfo->validation = NULL; fieldInfo->validation = NULL;
} }
catch (const Firebird::Exception&)
{
dbb->deletePool(csb_pool);
throw;
}
}
} }
END_FOR; END_FOR;

View File

@ -123,8 +123,9 @@ void MET_scan_relation(Jrd::thread_db*, Jrd::jrd_rel*);
void MET_trigger_msg(Jrd::thread_db*, Firebird::string&, const Firebird::MetaName&, USHORT); void MET_trigger_msg(Jrd::thread_db*, Firebird::string&, const Firebird::MetaName&, USHORT);
void MET_update_shadow(Jrd::thread_db*, Jrd::Shadow*, USHORT); void MET_update_shadow(Jrd::thread_db*, Jrd::Shadow*, USHORT);
void MET_update_transaction(Jrd::thread_db*, Jrd::jrd_tra*, const bool); void MET_update_transaction(Jrd::thread_db*, Jrd::jrd_tra*, const bool);
void MET_get_domain(Jrd::thread_db*, const Firebird::MetaName&, dsc*, Jrd::FieldInfo*); void MET_get_domain(Jrd::thread_db*, MemoryPool&, const Firebird::MetaName&, dsc*,
Firebird::MetaName MET_get_relation_field(Jrd::thread_db*, const Firebird::MetaName&, Jrd::FieldInfo*);
Firebird::MetaName MET_get_relation_field(Jrd::thread_db*, MemoryPool&, const Firebird::MetaName&,
const Firebird::MetaName&, dsc*, Jrd::FieldInfo*); const Firebird::MetaName&, dsc*, Jrd::FieldInfo*);
void MET_update_partners(Jrd::thread_db*); void MET_update_partners(Jrd::thread_db*);

View File

@ -377,7 +377,7 @@ USHORT PAR_desc(thread_db* tdbb, CompilerScratch* csb, DSC* desc, ItemInfo* item
FieldInfo fieldInfo; FieldInfo fieldInfo;
bool exist = csb->csb_map_field_info.get(namePair, fieldInfo); bool exist = csb->csb_map_field_info.get(namePair, fieldInfo);
MET_get_domain(tdbb, *name, desc, (exist ? NULL : &fieldInfo)); MET_get_domain(tdbb, csb->csb_pool, *name, desc, (exist ? NULL : &fieldInfo));
if (!exist) if (!exist)
csb->csb_map_field_info.put(namePair, fieldInfo); csb->csb_map_field_info.put(namePair, fieldInfo);
@ -440,7 +440,8 @@ USHORT PAR_desc(thread_db* tdbb, CompilerScratch* csb, DSC* desc, ItemInfo* item
FieldInfo fieldInfo; FieldInfo fieldInfo;
bool exist = csb->csb_map_field_info.get(namePair, fieldInfo); bool exist = csb->csb_map_field_info.get(namePair, fieldInfo);
MET_get_relation_field(tdbb, *relationName, *fieldName, desc, (exist ? NULL : &fieldInfo)); MET_get_relation_field(tdbb, csb->csb_pool, *relationName, *fieldName, desc,
(exist ? NULL : &fieldInfo));
if (!exist) if (!exist)
csb->csb_map_field_info.put(namePair, fieldInfo); csb->csb_map_field_info.put(namePair, fieldInfo);
@ -1289,7 +1290,7 @@ static jrd_nod* par_field(thread_db* tdbb, CompilerScratch* csb, SSHORT blr_oper
node->nod_count = 0; node->nod_count = 0;
dsc* desc = (dsc*) (node->nod_arg + e_domval_desc); dsc* desc = (dsc*) (node->nod_arg + e_domval_desc);
MET_get_domain(tdbb, csb->csb_domain_validation, desc, NULL); MET_get_domain(tdbb, csb->csb_pool, csb->csb_domain_validation, desc, NULL);
return node; return node;
} }