Skip to content

Read a structure from its definition, not from a declaration before it - #154

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:catalog/structs-from-their-definition
Oct 1, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:catalog/structs-from-their-definition

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

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.

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.
@estebanzimanyi
estebanzimanyi merged commit c698258 into MobilityDB:master Oct 1, 2026
3 checks passed
@estebanzimanyi
estebanzimanyi deleted the catalog/structs-from-their-definition branch October 1, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant