Skip to content

Commit dceddf6

Browse files
committed
Postfix for #9166: A failed COMMIT of a transaction containing ALTER TABLE ... ADD leaves the RDB$FORMATS record of the next format number; clear vector of cached formats
1 parent 094b435 commit dceddf6

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎src/jrd/Database.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,20 @@ class vec_base : protected pool_alloc<TYPE>
130130

131131
void operator delete(void* mem) { MemoryPool::globalFree(mem); }
132132

133+
// strip unused nulls in the end
134+
void trimNulls()
135+
{
136+
auto* e = v.end();
137+
for (; e != v.begin(); --e)
138+
{
139+
if (e[-1])
140+
break;
141+
}
142+
143+
if (e != v.end())
144+
v.resize(e - v.begin());
145+
}
146+
133147
protected:
134148
vec_base(MemoryPool& p, int len)
135149
: v(p, len)

‎src/jrd/dfw.epp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5915,6 +5915,21 @@ static bool make_version(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
59155915
ERASE F;
59165916
}
59175917
END_FOR
5918+
5919+
relation = MET_lookup_relation(tdbb, work->dfw_name);
5920+
if (relation)
5921+
{
5922+
vec<Format*>* vector = relation->rel_formats;
5923+
if (arg->dfw_id < vector->count())
5924+
{
5925+
Format* format = (*vector)[arg->dfw_id];
5926+
(*vector)[arg->dfw_id] = NULL;
5927+
5928+
vector->trimNulls();
5929+
5930+
delete format;
5931+
}
5932+
}
59185933
}
59195934
break;
59205935

0 commit comments

Comments
 (0)