Read a structure from its definition, not from a declaration before it - #154
Merged
estebanzimanyi merged 1 commit intoOct 1, 2026
Conversation
A structure the headers declare before they define it is read from its definition: its record keeps the place where the parse first meets the structure, and its fields, offsets and file are those of the definition. A structure the headers only declare, an opaque one such as NumericData, keeps its declaration and states no field. Why. A binding laying a structure out reads its fields and offsets from the catalog. meos.h declares MeosArray and SkipList, which meos_internal.h defines; read from the first record the parse meets, the declaration, they carry no field, and neither would varlena once pg_basetypes.h declares struct varlena ahead of the splice defining it, which MobilityDB #2893 does. Measured. Over MobilityDB d5e3e9946e, three structures gain their fields and nothing else changes: MeosArray five, read in meos_internal.h for meos.h, SkipList fourteen, read in meos_internal.h for meos.h, and PCSCHEMA eleven, read in pc_api.h for meos_pointcloud.h. Over MobilityDB #2893 (dd0426728b) varlena keeps its two fields, and that catalog differs from master's only in where its structures and typedefs sit: NumericData is found in pg_basetypes.h instead of pg_numeric.h, so it no longer reads as vendored, and the structures come in another order. Witness. tests/test_struct_layout.py reads MeosArray, SkipList and varlena with their fields from the catalog, and parses a header declaring one structure before a second header defines it, beside one only declared: the first carries its fields and the second none. The suite floor goes from 341 to 343.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A structure the headers declare before they define it is read from its
definition: its record keeps the place where the parse first meets the
structure, and its fields, offsets and file are those of the definition.
A structure the headers only declare, an opaque one such as NumericData,
keeps its declaration and states no field.
Why. A binding laying a structure out reads its fields and offsets from
the catalog. meos.h declares MeosArray and SkipList, which
meos_internal.h defines; read from the first record the parse meets, the
declaration, they carry no field, and neither would varlena once
pg_basetypes.h declares struct varlena ahead of the splice defining it,
which MobilityDB #2893 does.
Measured. Over MobilityDB d5e3e9946e, three structures gain their
fields and nothing else changes: MeosArray five, read in meos_internal.h
for meos.h, SkipList fourteen, read in meos_internal.h for meos.h, and
PCSCHEMA eleven, read in pc_api.h for meos_pointcloud.h. Over MobilityDB
#2893 (dd0426728b) varlena keeps its two fields, and that catalog differs
from master's only in where its structures and typedefs sit: NumericData
is found in pg_basetypes.h instead of pg_numeric.h, so it no longer reads
as vendored, and the structures come in another order.
Witness. tests/test_struct_layout.py reads MeosArray, SkipList and
varlena with their fields from the catalog, and parses a header
declaring one structure before a second header defines it, beside one
only declared: the first carries its fields and the second none. The
suite floor goes from 341 to 343.