Skip to content

Commit 579ff5c

Browse files
authored
Restore the broken record layout optimization by gbak and extend it to the new datatypes (#8815)
* Add new 128-bit types to the record layout optimization attempted by gbak * Given the backup file already contains fields in the optimized order, insist on it and prevent the engine from generating field IDs in a different order. This restores the original record layout optimization accidentally broken by my commit #2ed48a6.
1 parent 56dfbc2 commit 579ff5c

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/burp/backup.epp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,7 @@ void put_relation( burp_rel* relation)
19401940
burp_fld* unaligned = NULL;
19411941
burp_fld* aligned4 = NULL;
19421942
burp_fld* aligned8 = NULL;
1943+
burp_fld* aligned16 = NULL;
19431944

19441945
burp_fld* fields = get_fields(relation);
19451946

@@ -1951,7 +1952,13 @@ void put_relation( burp_rel* relation)
19511952
USHORT l = field->fld_length;
19521953
if (field->fld_type == blr_varying)
19531954
l += sizeof(USHORT);
1954-
if (!(l & 7))
1955+
1956+
if (!(l & 15))
1957+
{
1958+
field->fld_next = aligned16;
1959+
aligned16 = field;
1960+
}
1961+
else if (!(l & 7))
19551962
{
19561963
field->fld_next = aligned8;
19571964
aligned8 = field;
@@ -2005,6 +2012,13 @@ void put_relation( burp_rel* relation)
20052012
relation->rel_fields = field;
20062013
}
20072014

2015+
while ((field = aligned16))
2016+
{
2017+
aligned16 = field->fld_next;
2018+
field->fld_next = relation->rel_fields;
2019+
relation->rel_fields = field;
2020+
}
2021+
20082022
// Now write the fields in what will become physical backup order
20092023

20102024
for (field = relation->rel_fields; field; field = field->fld_next)

src/burp/restore.epp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ bool get_collation(BurpGlobals* tdgbl);
132132
SLONG get_compressed(BurpGlobals* tdgbl, UCHAR* buffer, SLONG length);
133133
void get_data(BurpGlobals* tdgbl, burp_rel*, WriteRelationReq* req);
134134
bool get_exception(BurpGlobals* tdgbl);
135-
burp_fld* get_field(BurpGlobals* tdgbl, burp_rel*);
135+
burp_fld* get_field(BurpGlobals* tdgbl, burp_rel*, USHORT id);
136136
bool get_field_dimensions(BurpGlobals* tdgbl);
137137
bool get_files(BurpGlobals* tdgbl);
138138
bool get_filter(BurpGlobals* tdgbl);
@@ -3806,7 +3806,7 @@ bool get_exception(BurpGlobals* tdgbl)
38063806
}
38073807

38083808

3809-
burp_fld* get_field(BurpGlobals* tdgbl, burp_rel* relation)
3809+
burp_fld* get_field(BurpGlobals* tdgbl, burp_rel* relation, USHORT id)
38103810
{
38113811
/**************************************
38123812
*
@@ -3865,6 +3865,9 @@ burp_fld* get_field(BurpGlobals* tdgbl, burp_rel* relation)
38653865
// ODS 14
38663866
X.RDB$FIELD_SOURCE_SCHEMA_NAME.NULL = TRUE;
38673867

3868+
X.RDB$FIELD_ID.NULL = FALSE;
3869+
X.RDB$FIELD_ID = id;
3870+
38683871
if (relation->rel_name.schema.hasData())
38693872
{
38703873
strcpy(X.RDB$SCHEMA_NAME, relation->rel_name.schema.c_str());
@@ -4084,6 +4087,9 @@ burp_fld* get_field(BurpGlobals* tdgbl, burp_rel* relation)
40844087
X.RDB$NULL_FLAG.NULL = TRUE;
40854088
X.RDB$COLLATION_ID.NULL = TRUE;
40864089

4090+
X.RDB$FIELD_ID.NULL = FALSE;
4091+
X.RDB$FIELD_ID = id;
4092+
40874093
skip_init(&scan_next_attr);
40884094
while (get_attribute(&attribute, tdgbl) != att_end)
40894095
{
@@ -8249,6 +8255,7 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t
82498255
// Eat up misc. records
82508256
burp_fld* field = NULL;
82518257
burp_fld** ptr = &relation->rel_fields;
8258+
USHORT id = 0;
82528259

82538260
rec_type record;
82548261
while (get_record(&record, tdgbl) != rec_data)
@@ -8277,7 +8284,7 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t
82778284
return true;
82788285

82798286
case rec_field:
8280-
*ptr = field = get_field (tdgbl, relation);
8287+
*ptr = field = get_field(tdgbl, relation, id++);
82818288
if (!field)
82828289
return false;
82838290
ptr = &field->fld_next;

0 commit comments

Comments
 (0)