Skip to content

Conversation

@dyemanov
Copy link
Member

@dyemanov dyemanov commented Nov 29, 2025

The order of field ID generation inside DFW is not reliable, because it joins two system tables and generally the retrieval order would depend on the query plan. The added SORTED BY clause fixes it for CREATE/ALTER TABLE, but the resulting order does not match the order of insertions into RDB$RELATION_FIELDS anymore. However, gbak does its best to optimize the record layout and it relies on the ID generation being performed in the storage order. Thus I moved the ID generation to the gbak side to ensure the record format is created with the expected (optimized) layout.

… 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.
@dyemanov
Copy link
Member Author

Before this patch:

        Fields:
         id offset type           length sub_type flags
        --- ------ -------------- ------ -------- -----
          0      8 19 BIGINT           8        0  0x00
          1     16  3 VARCHAR         33       52  0x00
          2     56 17 BLOB             8        1  0x00

Format length = 64 bytes

After this patch:

        Fields:
         id offset type           length sub_type flags
        --- ------ -------------- ------ -------- -----
          0      8 17 BLOB             8        1  0x00
          1     16 19 BIGINT           8        0  0x00
          2     24  3 VARCHAR         33       52  0x00

Format length = 57 bytes

@dyemanov dyemanov merged commit 579ff5c into master Dec 3, 2025
44 of 46 checks passed
@dyemanov dyemanov deleted the work/burp-record-layout branch December 3, 2025 05:27
dyemanov added a commit that referenced this pull request Dec 3, 2025
…o 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants