Skip to content

State every scalar type by its definition, never by the platform's - #155

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:catalog/scalar-types-from-their-definitions
Oct 1, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:catalog/scalar-types-from-their-definitions

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

A slot declared by a scalar typedef states what MEOS defines it as, read
from the typedef chain of the unit the catalog parses: the parser records
every typedef one step down, the C library's and libh3's included. A type
PostgreSQL declares in MobilityDB's vendored pgtypes keeps its name:
TimestampTz, DateADT, TimeADT, Oid, Datum. Any other integer typedef is
stated by the C standard type its chain reaches: int32 is int32_t, int16
is int16_t, H3Index, Quadbin and S2CellId are uint64_t. A chain meeting
neither ends at the C scalar it names, float8 at double. libclang's
resolution on the host is never the answer: it states TimeADT as long,
32 bits on Windows, and int32 as int.

A name defined as its own <stdint.h> name, as PostgreSQL 18's c.h
defines the historical names for types in <stdint.h> (typedef int32_t
int32), and a name for a C floating type (typedef double float8) name a
width and not a type of their own, so the chain goes on through them,
whichever header defines them. The other typedefs keep the spelling
_TYPE_MAP gives them (Jsonb, GSERIALIZED), and _TYPE_MAP still recovers a
name the preprocessor erased to int.

The service projection reads the C standard's integer types as integers,
as it reads int and long: a parameter or result spelled int64_t, uint64_t,
uint32_t, uint8_t or size_t is a JSON integer.

Why. Bindings key on canonical. A binding that read TimeADT as long read
32 bits on Windows, one that read uint64_t never met the int32 of the
same header spelled the same way, and every typedef missing from a hand
list reached the bindings as whatever libclang made of it on the host.
The chain leaves no list to complete: a new typedef is stated by its
definition.

Measured. Over MobilityDB 72abdf86c2, whose pg_basetypes.h defines int8
to uint64 as PostgreSQL 18's c.h does, 557 slots change:
258 int32, 111 int16 and 77 int32_t slots read int32_t and int16_t for
int and short, 35 uint8_t read uint8_t for unsigned char, 73 TimeADT read
TimeADT for long, and 3 Oid read Oid for unsigned int. 368 functions
taking or returning a C standard integer enter the service projection,
2516 exposable becoming 2860; 23 time functions and text_cmp leave it,
TimeADT and Oid joining the TimestampTz and DateADT the projection maps
to no wire type.

Witness. tests/test_typerecover.py follows the chains of a width name, a
cell, a PostgreSQL type, Datum over uintptr_t, a width name spelled as no
<stdint.h> type, a float and a name no scalar; reads PostgreSQL's names
from every scalar typedef of a pgtypes tree, whichever header declares
it, without its structs and pointers; and states a slot by its chain.
Over the catalog, no slot declared by a typedef reads as a C integer, and
TimeADT, DateADT, int32 and uint8_t slots read their definition.
tests/test_enrich.py reads int64_t, int32_t and uint32_t as JSON
integers. The suite floor goes from 343 to 354.

A slot declared by a scalar typedef states what MEOS defines it as, read
from the typedef chain of the unit the catalog parses: the parser records
every typedef one step down, the C library's and libh3's included. A type
PostgreSQL declares in MobilityDB's vendored pgtypes keeps its name:
TimestampTz, DateADT, TimeADT, Oid, Datum. Any other integer typedef is
stated by the C standard type its chain reaches: int32 is int32_t, int16
is int16_t, H3Index, Quadbin and S2CellId are uint64_t. A chain meeting
neither ends at the C scalar it names, float8 at double. libclang's
resolution on the host is never the answer: it states TimeADT as long,
32 bits on Windows, and int32 as int.

A name defined as its own <stdint.h> name, as PostgreSQL 18's c.h
defines the historical names for types in <stdint.h> (typedef int32_t
int32), and a name for a C floating type (typedef double float8) name a
width and not a type of their own, so the chain goes on through them,
whichever header defines them. The other typedefs keep the spelling
_TYPE_MAP gives them (Jsonb, GSERIALIZED), and _TYPE_MAP still recovers a
name the preprocessor erased to int.

The service projection reads the C standard's integer types as integers,
as it reads int and long: a parameter or result spelled int64_t, uint64_t,
uint32_t, uint8_t or size_t is a JSON integer.

Why. Bindings key on canonical. A binding that read TimeADT as long read
32 bits on Windows, one that read uint64_t never met the int32 of the
same header spelled the same way, and every typedef missing from a hand
list reached the bindings as whatever libclang made of it on the host.
The chain leaves no list to complete: a new typedef is stated by its
definition.

Measured. Over MobilityDB 72abdf86c2, whose pg_basetypes.h defines int8
to uint64 as PostgreSQL 18's c.h does, 557 slots change:
258 int32, 111 int16 and 77 int32_t slots read int32_t and int16_t for
int and short, 35 uint8_t read uint8_t for unsigned char, 73 TimeADT read
TimeADT for long, and 3 Oid read Oid for unsigned int. 368 functions
taking or returning a C standard integer enter the service projection,
2516 exposable becoming 2860; 23 time functions and text_cmp leave it,
TimeADT and Oid joining the TimestampTz and DateADT the projection maps
to no wire type.

Witness. tests/test_typerecover.py follows the chains of a width name, a
cell, a PostgreSQL type, Datum over uintptr_t, a width name spelled as no
<stdint.h> type, a float and a name no scalar; reads PostgreSQL's names
from every scalar typedef of a pgtypes tree, whichever header declares
it, without its structs and pointers; and states a slot by its chain.
Over the catalog, no slot declared by a typedef reads as a C integer, and
TimeADT, DateADT, int32 and uint8_t slots read their definition.
tests/test_enrich.py reads int64_t, int32_t and uint32_t as JSON
integers. The suite floor goes from 343 to 354.
@estebanzimanyi
estebanzimanyi merged commit 8563994 into MobilityDB:master Oct 1, 2026
3 checks passed
@estebanzimanyi
estebanzimanyi deleted the catalog/scalar-types-from-their-definitions branch October 1, 2026 09:23
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