mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 08:43:03 +01:00
Backport fix for CORE-4145 - Memory leak when preparing Execute Block which uses domains.
This commit is contained in:
parent
31bdfdbac4
commit
c62e9cfbf5
@ -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,25 +217,17 @@ 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;
|
||||
|
||||
MemoryPool* csb_pool = dbb->createPool();
|
||||
Jrd::ContextPoolHolder context(tdbb, csb_pool);
|
||||
try
|
||||
{
|
||||
if (FLD.RDB$DEFAULT_VALUE.NULL)
|
||||
fieldInfo->defaultValue = NULL;
|
||||
else
|
||||
fieldInfo->defaultValue = parse_field_blr(tdbb, &FLD.RDB$DEFAULT_VALUE);
|
||||
Jrd::ContextPoolHolder context(tdbb, &csbPool);
|
||||
|
||||
if (FLD.RDB$VALIDATION_BLR.NULL)
|
||||
fieldInfo->validation = NULL;
|
||||
else
|
||||
fieldInfo->validation = parse_field_blr(tdbb, &FLD.RDB$VALIDATION_BLR, name);
|
||||
}
|
||||
catch (const Firebird::Exception&)
|
||||
{
|
||||
dbb->deletePool(csb_pool);
|
||||
throw;
|
||||
}
|
||||
if (FLD.RDB$DEFAULT_VALUE.NULL)
|
||||
fieldInfo->defaultValue = NULL;
|
||||
else
|
||||
fieldInfo->defaultValue = parse_field_blr(tdbb, &FLD.RDB$DEFAULT_VALUE);
|
||||
|
||||
if (FLD.RDB$VALIDATION_BLR.NULL)
|
||||
fieldInfo->validation = NULL;
|
||||
else
|
||||
fieldInfo->validation = parse_field_blr(tdbb, &FLD.RDB$VALIDATION_BLR, name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,11 +243,9 @@ void MET_get_domain(thread_db* tdbb, const Firebird::MetaName& name, dsc* desc,
|
||||
}
|
||||
|
||||
|
||||
Firebird::MetaName MET_get_relation_field(thread_db* tdbb,
|
||||
const Firebird::MetaName& relationName,
|
||||
const Firebird::MetaName& fieldName,
|
||||
dsc* desc,
|
||||
FieldInfo* fieldInfo)
|
||||
Firebird::MetaName MET_get_relation_field(thread_db* tdbb, MemoryPool& csbPool,
|
||||
const Firebird::MetaName& relationName, const Firebird::MetaName& fieldName, dsc* desc,
|
||||
FieldInfo* fieldInfo)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -300,32 +291,23 @@ Firebird::MetaName MET_get_relation_field(thread_db* tdbb,
|
||||
fieldInfo->nullable = RFL.RDB$NULL_FLAG.NULL ?
|
||||
(FLD.RDB$NULL_FLAG.NULL || FLD.RDB$NULL_FLAG == 0) : RFL.RDB$NULL_FLAG == 0;
|
||||
|
||||
MemoryPool* csb_pool = dbb->createPool();
|
||||
Jrd::ContextPoolHolder context(tdbb, csb_pool);
|
||||
try
|
||||
{
|
||||
bid* defaultId = NULL;
|
||||
Jrd::ContextPoolHolder context(tdbb, &csbPool);
|
||||
bid* defaultId = NULL;
|
||||
|
||||
if (!RFL.RDB$DEFAULT_VALUE.NULL)
|
||||
defaultId = &RFL.RDB$DEFAULT_VALUE;
|
||||
else if (!FLD.RDB$DEFAULT_VALUE.NULL)
|
||||
defaultId = &FLD.RDB$DEFAULT_VALUE;
|
||||
if (!RFL.RDB$DEFAULT_VALUE.NULL)
|
||||
defaultId = &RFL.RDB$DEFAULT_VALUE;
|
||||
else if (!FLD.RDB$DEFAULT_VALUE.NULL)
|
||||
defaultId = &FLD.RDB$DEFAULT_VALUE;
|
||||
|
||||
if (defaultId)
|
||||
fieldInfo->defaultValue = parse_field_blr(tdbb, defaultId);
|
||||
else
|
||||
fieldInfo->defaultValue = NULL;
|
||||
if (defaultId)
|
||||
fieldInfo->defaultValue = parse_field_blr(tdbb, defaultId);
|
||||
else
|
||||
fieldInfo->defaultValue = NULL;
|
||||
|
||||
if (!FLD.RDB$VALIDATION_BLR.NULL)
|
||||
fieldInfo->validation = parse_field_blr(tdbb, &FLD.RDB$VALIDATION_BLR, RFL.RDB$FIELD_SOURCE);
|
||||
else
|
||||
fieldInfo->validation = NULL;
|
||||
}
|
||||
catch (const Firebird::Exception&)
|
||||
{
|
||||
dbb->deletePool(csb_pool);
|
||||
throw;
|
||||
}
|
||||
if (!FLD.RDB$VALIDATION_BLR.NULL)
|
||||
fieldInfo->validation = parse_field_blr(tdbb, &FLD.RDB$VALIDATION_BLR, RFL.RDB$FIELD_SOURCE);
|
||||
else
|
||||
fieldInfo->validation = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,9 +123,10 @@ 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_update_shadow(Jrd::thread_db*, Jrd::Shadow*, USHORT);
|
||||
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*);
|
||||
Firebird::MetaName MET_get_relation_field(Jrd::thread_db*, const Firebird::MetaName&,
|
||||
const Firebird::MetaName&, dsc*, Jrd::FieldInfo*);
|
||||
void MET_get_domain(Jrd::thread_db*, MemoryPool&, const Firebird::MetaName&, dsc*,
|
||||
Jrd::FieldInfo*);
|
||||
Firebird::MetaName MET_get_relation_field(Jrd::thread_db*, MemoryPool&, const Firebird::MetaName&,
|
||||
const Firebird::MetaName&, dsc*, Jrd::FieldInfo*);
|
||||
void MET_update_partners(Jrd::thread_db*);
|
||||
|
||||
#endif // JRD_MET_PROTO_H
|
||||
|
@ -377,7 +377,7 @@ USHORT PAR_desc(thread_db* tdbb, CompilerScratch* csb, DSC* desc, ItemInfo* item
|
||||
|
||||
FieldInfo 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)
|
||||
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;
|
||||
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)
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user