Skip to content

Compile the module against the installed MEOS umbrella header - #12

Open
estebanzimanyi wants to merge 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/compile-against-installed-meos-header
Open

Compile the module against the installed MEOS umbrella header#12
estebanzimanyi wants to merge 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/compile-against-installed-meos-header

Conversation

@estebanzimanyi

@estebanzimanyi estebanzimanyi commented Aug 15, 2026

Copy link
Copy Markdown
Member

The C wrappers compile against an installed MEOS prefix rather than the MobilityDB source tree, which is the header MEOS actually publishes.

MEOS assembles the installed <meos.h>: it splices its PostgreSQL-compat definitions into it under #ifndef POSTGRES_H, and that block supplies Datum, DateADT, TimestampTz, Interval and the de-prefixed base I/O — interval_in, date_in, timestamptz_in and siblings, named without a meos_ prefix so they do not collide with a real PostgreSQL. None of it appears in the source copy, so calls to those functions are implicitly declared and C99 rejects them.

  • the build installs MEOS and compiles against that prefix;
  • the preamble stops including the vendored <postgres.h>, which defines POSTGRES_H first and makes <meos.h> skip the entire spliced block, leaving even DateADT undefined, and takes <string.h> directly rather than through it;
  • the Datum accessors the spliced block leaves out are defined in the preamble, keyed on the pointer width exactly as PostgreSQL keys USE_FLOAT8_BYVAL on SIZEOF_VOID_P >= 8.

That last point decides behaviour, not just compilation. With -sMEMORY64=1 a Datum is 8 bytes, so a TimestampTz or an int64 span bound rides inside the Datum rather than behind a pointer. Reading one through a pointer returns whatever the value addresses, which makes BigIntSpan [1,5) and [6,10) report as adjacent. Keying on the width keeps both models correct.

docker build --target wasm exits 0 with no errors.

Under Node 24 the suite runs and fails 13 tests, the same 13 as a module built from the commit before this branch. Node 22 raises CompileError: invalid table elements limits flags before any test runs, since V8 12.4 does not accept the 64-bit tables -sMEMORY64=1 emits and V8 13.6 does.

The module compiled against MobilityDB's source tree, where meos.h is not the
header MEOS publishes. MEOS assembles the installed <meos.h>: it splices its
PostgreSQL-compat definitions into it under #ifndef POSTGRES_H, which supplies
Datum, DateADT, TimestampTz, Interval and the de-prefixed base I/O --
interval_in, date_in, timestamptz_in and their siblings, named without a meos_
prefix so they do not collide with a real PostgreSQL. None of that is in the
source copy, so calls to those functions were implicitly declared and C99
rejects them.

The build installs MEOS and compiles against that prefix. The preamble stops
including the vendored <postgres.h>, which defined POSTGRES_H first and made
<meos.h> skip the whole spliced block, and takes <string.h> directly rather
than through it.

The Datum accessors the spliced block leaves out are defined here, keyed on the
pointer width exactly as PostgreSQL keys USE_FLOAT8_BYVAL on SIZEOF_VOID_P >= 8.
With -sMEMORY64=1 a Datum is 8 bytes, so a TimestampTz or an int64 span bound
rides inside it rather than behind a pointer; reading one through a pointer
returns whatever the value addresses, which makes a bigint span report a
neighbour it does not touch as adjacent. Both widths stay correct.
@estebanzimanyi
estebanzimanyi force-pushed the fix/compile-against-installed-meos-header branch from 3a39dc9 to 577284e Compare August 15, 2026 15:52
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