Skip to content

Return the MEOS error alongside every generated Go value - #14

Merged
estebanzimanyi merged 2 commits into
MobilityDB:mainfrom
estebanzimanyi:fix/error-projection-go
Aug 15, 2026
Merged

Return the MEOS error alongside every generated Go value#14
estebanzimanyi merged 2 commits into
MobilityDB:mainfrom
estebanzimanyi:fix/error-projection-go

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

The branch carries the pkg-config preamble commit beneath it; the second commit is the one to review.

Every generated wrapper resets the MEOS errno, calls, and returns the error alongside its value, which is Go idiom for an out-of-band failure channel.

A MEOS call reports failure out of band and returns a sentinel that is the maximum of its own return type. The generated surface drops that channel: TemporalNumInstants returns a bare int, so a rejected argument reaches the caller as INT_MAX, a plausible count that arithmetic carries onward. No sentinel answers this by itself — INT_MAX is a count, DBL_MAX is a distance, and a bool has no spare value at all, so its failure is indistinguishable from a definite false. The error state is the only discriminator.

The results are named so one guard shape serves every signature rather than a per-type zero-value expression. All 3314 emitted wrappers carry the error, with no per-function exception: an exception needs a hand-maintained list, and the property stops being checkable. The 30 Inner() accessors and the two error helpers reach no MEOS call and keep their signatures, which is the whole of the difference between the 3346 functions in the package and the 3314 wrappers the generator reports.

The errno accessors join the skip list as the plumbing this is built on: a generated MeosErrno() resets the errno immediately before reading it, and so always reports success. meos_initialize_noexit_error_handler stays exposed, and a caller installs it once per process, on every thread that calls MEOS.

go build ./functions/ against a private prefix exits 0.

The cgo preamble hardcoded /usr/local (and /opt/homebrew) as the place to find
libmeos, plus a hand-kept list of ten -D family macros mirroring the if(ALL)
loop in MobilityDB's CMakeLists. Both are assumptions about a machine rather
than facts about the library, and the -D list is the one that bites: the public
headers gate declarations on those macros, so a list that disagrees with the
installed library either declares a symbol that cannot link or hides a family
the library provides. The macros are not derivable from -DALL either, which
selects families at configure time and never reaches a compiler.

The installed meos.pc now reports both, so the preamble asks for them. This
also makes the binding relocatable: PKG_CONFIG_PATH selects which libmeos to
build against, which is what lets a build target a private prefix instead of
inheriting a machine-wide directory shared with everything else on the host.

H3 ships no pkg-config file, so meos_h3.h's <h3api.h> keeps its include dir
named here; GEOS and GSL resolve from the default include path.
A MEOS call reports failure out of band, and returns a sentinel that is the
maximum of its own return type. The generated wrappers dropped that channel:
TemporalNumInstants returned a bare int, so a rejected argument reached the
caller as INT_MAX, a plausible count. No sentinel can carry the answer by
itself -- INT_MAX is a count, DBL_MAX is a distance, and a bool has no spare
value at all, so its failure is indistinguishable from a definite false.

Each wrapper resets the errno, calls, and returns the error alongside its
value, which is Go's idiom for the channel. The results are named so one guard
shape serves every signature rather than a per-type zero value. All 3314
emitted wrappers carry it, with no per-function exception: an exception would
need a hand-maintained list and the property would stop being checkable. The
30 Inner() accessors and the two error helpers touch no MEOS call and keep
their signatures.

The errno accessors join the skip list, being the plumbing this is built on: a
generated MeosErrno() would reset the errno immediately before reading it and
so always report success.
@estebanzimanyi
estebanzimanyi merged commit b22ec3d into MobilityDB:main Aug 15, 2026
2 checks passed
@estebanzimanyi
estebanzimanyi deleted the fix/error-projection-go branch August 15, 2026 17:34
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