mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 02:03:04 +01:00
Fixed CORE-4145 - Memory leak when preparing Execute Block which uses domains.
This commit is contained in:
parent
b14c9245c9
commit
0b51caa5f4
@ -5536,7 +5536,7 @@ void RelationNode::defineField(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch
|
||||
if (clause->identity)
|
||||
{
|
||||
dsc desc;
|
||||
MET_get_domain(tdbb, fieldDefinition.fieldSource, &desc, NULL);
|
||||
MET_get_domain(tdbb, *tdbb->getDefaultPool(), fieldDefinition.fieldSource, &desc, NULL);
|
||||
|
||||
if (!desc.isExact() || desc.dsc_scale != 0)
|
||||
{
|
||||
|
@ -4576,7 +4576,7 @@ DmlNode* FieldNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* cs
|
||||
}
|
||||
|
||||
DomainValidationNode* domNode = FB_NEW(pool) DomainValidationNode(pool);
|
||||
MET_get_domain(tdbb, csb->csb_domain_validation, &domNode->domDesc, NULL);
|
||||
MET_get_domain(tdbb, csb->csb_pool, csb->csb_domain_validation, &domNode->domDesc, NULL);
|
||||
|
||||
// Cast to the target type - see CORE-3545.
|
||||
CastNode* castNode = FB_NEW(pool) CastNode(pool);
|
||||
|
@ -211,7 +211,7 @@ public:
|
||||
typeOfName(pool),
|
||||
collate(pool, aCollate),
|
||||
charSet(pool),
|
||||
subTypeName(NULL),
|
||||
subTypeName(pool, NULL),
|
||||
flags(0),
|
||||
elementDtype(0),
|
||||
elementLength(0),
|
||||
|
@ -91,7 +91,8 @@ namespace
|
||||
|
||||
FieldInfo fieldInfo;
|
||||
bool exist = csb->csb_map_field_info.get(namePair, fieldInfo);
|
||||
MET_get_domain(tdbb, param->prm_field_source, desc, (exist ? NULL : &fieldInfo));
|
||||
MET_get_domain(tdbb, csb->csb_pool, param->prm_field_source, desc,
|
||||
(exist ? NULL : &fieldInfo));
|
||||
|
||||
if (!exist)
|
||||
csb->csb_map_field_info.put(namePair, fieldInfo);
|
||||
|
@ -182,7 +182,8 @@ static void post_used_procedures(trig_vec* vector)
|
||||
}
|
||||
|
||||
|
||||
void MET_get_domain(thread_db* tdbb, const MetaName& name, dsc* desc, FieldInfo* fieldInfo)
|
||||
void MET_get_domain(thread_db* tdbb, MemoryPool& csbPool, const MetaName& name, dsc* desc,
|
||||
FieldInfo* fieldInfo)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -217,27 +218,19 @@ void MET_get_domain(thread_db* tdbb, const MetaName& name, dsc* desc, FieldInfo*
|
||||
{
|
||||
fieldInfo->nullable = FLD.RDB$NULL_FLAG.NULL || FLD.RDB$NULL_FLAG == 0;
|
||||
|
||||
MemoryPool* csb_pool = attachment->createPool();
|
||||
Jrd::ContextPoolHolder context(tdbb, csb_pool);
|
||||
try
|
||||
{
|
||||
if (FLD.RDB$DEFAULT_VALUE.NULL)
|
||||
fieldInfo->defaultValue = NULL;
|
||||
else
|
||||
fieldInfo->defaultValue = parse_field_default_blr(tdbb, &FLD.RDB$DEFAULT_VALUE);
|
||||
Jrd::ContextPoolHolder context(tdbb, &csbPool);
|
||||
|
||||
if (FLD.RDB$VALIDATION_BLR.NULL)
|
||||
fieldInfo->validationExpr = NULL;
|
||||
else
|
||||
{
|
||||
fieldInfo->validationExpr = parse_field_validation_blr(tdbb,
|
||||
&FLD.RDB$VALIDATION_BLR, name);
|
||||
}
|
||||
}
|
||||
catch (const Exception&)
|
||||
if (FLD.RDB$DEFAULT_VALUE.NULL)
|
||||
fieldInfo->defaultValue = NULL;
|
||||
else
|
||||
fieldInfo->defaultValue = parse_field_default_blr(tdbb, &FLD.RDB$DEFAULT_VALUE);
|
||||
|
||||
if (FLD.RDB$VALIDATION_BLR.NULL)
|
||||
fieldInfo->validationExpr = NULL;
|
||||
else
|
||||
{
|
||||
attachment->deletePool(csb_pool);
|
||||
throw;
|
||||
fieldInfo->validationExpr = parse_field_validation_blr(tdbb,
|
||||
&FLD.RDB$VALIDATION_BLR, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -251,11 +244,8 @@ void MET_get_domain(thread_db* tdbb, const MetaName& name, dsc* desc, FieldInfo*
|
||||
}
|
||||
|
||||
|
||||
MetaName MET_get_relation_field(thread_db* tdbb,
|
||||
const MetaName& relationName,
|
||||
const MetaName& fieldName,
|
||||
dsc* desc,
|
||||
FieldInfo* fieldInfo)
|
||||
MetaName MET_get_relation_field(thread_db* tdbb, MemoryPool& csbPool, const MetaName& relationName,
|
||||
const MetaName& fieldName, dsc* desc, FieldInfo* fieldInfo)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -298,34 +288,25 @@ 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 = attachment->createPool();
|
||||
Jrd::ContextPoolHolder context(tdbb, csb_pool);
|
||||
try
|
||||
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 (defaultId)
|
||||
fieldInfo->defaultValue = parse_field_default_blr(tdbb, defaultId);
|
||||
else
|
||||
fieldInfo->defaultValue = NULL;
|
||||
|
||||
if (FLD.RDB$VALIDATION_BLR.NULL)
|
||||
fieldInfo->validationExpr = NULL;
|
||||
else
|
||||
{
|
||||
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 (defaultId)
|
||||
fieldInfo->defaultValue = parse_field_default_blr(tdbb, defaultId);
|
||||
else
|
||||
fieldInfo->defaultValue = NULL;
|
||||
|
||||
if (FLD.RDB$VALIDATION_BLR.NULL)
|
||||
fieldInfo->validationExpr = NULL;
|
||||
else
|
||||
{
|
||||
fieldInfo->validationExpr = parse_field_validation_blr(tdbb,
|
||||
&FLD.RDB$VALIDATION_BLR, RFL.RDB$FIELD_SOURCE);
|
||||
}
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
attachment->deletePool(csb_pool);
|
||||
throw;
|
||||
fieldInfo->validationExpr = parse_field_validation_blr(tdbb,
|
||||
&FLD.RDB$VALIDATION_BLR, RFL.RDB$FIELD_SOURCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,9 +124,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& csbPool, const Firebird::MetaName&, dsc*,
|
||||
Jrd::FieldInfo*);
|
||||
Firebird::MetaName MET_get_relation_field(Jrd::thread_db*, MemoryPool& csbPool,
|
||||
const Firebird::MetaName&, const Firebird::MetaName&, dsc*, Jrd::FieldInfo*);
|
||||
void MET_update_partners(Jrd::thread_db*);
|
||||
|
||||
#endif // JRD_MET_PROTO_H
|
||||
|
@ -480,7 +480,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);
|
||||
@ -541,7 +541,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);
|
||||
|
Loading…
Reference in New Issue
Block a user