Skip to content

Commit a75ec4f

Browse files
committed
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 b2b7063 commit a75ec4f

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
@@ -1915,6 +1915,7 @@ void put_relation( burp_rel* relation)
19151915
burp_fld* unaligned = NULL;
19161916
burp_fld* aligned4 = NULL;
19171917
burp_fld* aligned8 = NULL;
1918+
burp_fld* aligned16 = NULL;
19181919

19191920
burp_fld* fields = get_fields(relation);
19201921

@@ -1926,7 +1927,13 @@ void put_relation( burp_rel* relation)
19261927
USHORT l = field->fld_length;
19271928
if (field->fld_type == blr_varying)
19281929
l += sizeof(USHORT);
1929-
if (!(l & 7))
1930+
1931+
if (!(l & 15))
1932+
{
1933+
field->fld_next = aligned16;
1934+
aligned16 = field;
1935+
}
1936+
else if (!(l & 7))
19301937
{
19311938
field->fld_next = aligned8;
19321939
aligned8 = field;
@@ -1980,6 +1987,13 @@ void put_relation( burp_rel* relation)
19801987
relation->rel_fields = field;
19811988
}
19821989

1990+
while ((field = aligned16))
1991+
{
1992+
aligned16 = field->fld_next;
1993+
field->fld_next = relation->rel_fields;
1994+
relation->rel_fields = field;
1995+
}
1996+
19831997
// Now write the fields in what will become physical backup order
19841998

19851999
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
@@ -131,7 +131,7 @@ bool get_collation(BurpGlobals* tdgbl);
131131
SLONG get_compressed(BurpGlobals* tdgbl, UCHAR* buffer, SLONG length);
132132
void get_data(BurpGlobals* tdgbl, burp_rel*, WriteRelationReq* req);
133133
bool get_exception(BurpGlobals* tdgbl);
134-
burp_fld* get_field(BurpGlobals* tdgbl, burp_rel*);
134+
burp_fld* get_field(BurpGlobals* tdgbl, burp_rel*, USHORT id);
135135
bool get_field_dimensions(BurpGlobals* tdgbl);
136136
bool get_files(BurpGlobals* tdgbl);
137137
bool get_filter(BurpGlobals* tdgbl);
@@ -3703,7 +3703,7 @@ bool get_exception(BurpGlobals* tdgbl)
37033703
}
37043704

37053705

3706-
burp_fld* get_field(BurpGlobals* tdgbl, burp_rel* relation)
3706+
burp_fld* get_field(BurpGlobals* tdgbl, burp_rel* relation, USHORT id)
37073707
{
37083708
/**************************************
37093709
*
@@ -3759,6 +3759,9 @@ burp_fld* get_field(BurpGlobals* tdgbl, burp_rel* relation)
37593759
X.RDB$GENERATOR_NAME.NULL = TRUE;
37603760
X.RDB$IDENTITY_TYPE.NULL = TRUE;
37613761

3762+
X.RDB$FIELD_ID.NULL = FALSE;
3763+
X.RDB$FIELD_ID = id;
3764+
37623765
skip_init(&scan_next_attr);
37633766
while (get_attribute(&attribute, tdgbl) != att_end)
37643767
{
@@ -3963,6 +3966,9 @@ burp_fld* get_field(BurpGlobals* tdgbl, burp_rel* relation)
39633966
X.RDB$NULL_FLAG.NULL = TRUE;
39643967
X.RDB$COLLATION_ID.NULL = TRUE;
39653968

3969+
X.RDB$FIELD_ID.NULL = FALSE;
3970+
X.RDB$FIELD_ID = id;
3971+
39663972
skip_init(&scan_next_attr);
39673973
while (get_attribute(&attribute, tdgbl) != att_end)
39683974
{
@@ -7976,6 +7982,7 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t
79767982
// Eat up misc. records
79777983
burp_fld* field = NULL;
79787984
burp_fld** ptr = &relation->rel_fields;
7985+
USHORT id = 0;
79797986

79807987
rec_type record;
79817988
while (get_record(&record, tdgbl) != rec_data)
@@ -8004,7 +8011,7 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t
80048011
return true;
80058012

80068013
case rec_field:
8007-
*ptr = field = get_field (tdgbl, relation);
8014+
*ptr = field = get_field(tdgbl, relation, id++);
80088015
if (!field)
80098016
return false;
80108017
ptr = &field->fld_next;

0 commit comments

Comments
 (0)