Skip to content

Answer the value at a timestamp from the MEOS entry that reports absence - #21

Merged
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/value-at-timestamp-delegates
Sep 3, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/value-at-timestamp-delegates

Conversation

@estebanzimanyi

@estebanzimanyi estebanzimanyi commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

WITNESS: a temporal value holds nothing outside its own span, and MEOS says so
by answering NULL. CreateTemporal reads inner.temptype with no nil test, so
that answer is dereferenced: removing the guard this commit adds takes
ExampleCreateTemporal_absent to

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4]

and 119 call sites reach CreateTemporal with a result that can be NULL.

The five ValueAtTimestamp accessors compose that path -- each one calls
TemporalAtTimestamptz, discards the conversion error with _, and reads the
instant -- where MEOS publishes the question directly:
tbool_value_at_timestamptz(temp, t, strict, &value) reports whether a value
is there and writes it out, with twins for tint, tfloat, ttext and tgeo. The
generated package already wraps all five, so the accessors delegate to them
across the pointer boundary rather than composing a restriction.

THE SHAPE COMES FROM THE SIBLING BINDINGS, WHICH SEPARATE ABSENCE FROM ERROR.
MEOS.NET's generated accessors return a nullable -- public bool? ValueAtTimestamptz(DateTime t, bool strict), and int? / long? / double?
for its siblings -- with Assert.IsNull covering the absent case in its own
test, while errors travel out of band through SafeExecution. PyMEOS-CFFI
agrees: if result: return out_result[0] ... return None, with _check_error()
raising separately. So absence is an optional result, not a failure. Go spells
an optional as a second result, and the generated wrapper here already returns
(found, value, error), so the accessors return (value, ok, error): ok
false leaves the value at its zero and the error nil, and the error is reserved
for a MEOS failure.

MEASURED: the suite reads 121 result lines, 0 skipped, against 118 before. The
three added examples pin the absent case for the boolean and float accessors
and for CreateTemporal itself, and each fails with the guard removed, so they
witness this change rather than accompany it.

WITNESS: a temporal value holds nothing outside its own span, and MEOS says so
by answering NULL. `CreateTemporal` reads `inner.temptype` with no nil test, so
that answer is dereferenced: removing the guard this commit adds takes
`ExampleCreateTemporal_absent` to

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x4]

and 119 call sites reach `CreateTemporal` with a result that can be NULL.

The five `ValueAtTimestamp` accessors compose that path -- each one calls
`TemporalAtTimestamptz`, discards the conversion error with `_`, and reads the
instant -- where MEOS publishes the question directly:
`tbool_value_at_timestamptz(temp, t, strict, &value)` reports whether a value
is there and writes it out, with twins for tint, tfloat, ttext and tgeo. The
generated package already wraps all five, so the accessors delegate to them
across the pointer boundary rather than composing a restriction.

THE SHAPE COMES FROM THE SIBLING BINDINGS, WHICH SEPARATE ABSENCE FROM ERROR.
MEOS.NET's generated accessors return a nullable -- `public bool?
ValueAtTimestamptz(DateTime t, bool strict)`, and `int?` / `long?` / `double?`
for its siblings -- with `Assert.IsNull` covering the absent case in its own
test, while errors travel out of band through `SafeExecution`. PyMEOS-CFFI
agrees: `if result: return out_result[0] ... return None`, with `_check_error()`
raising separately. So absence is an optional result, not a failure. Go spells
an optional as a second result, and the generated wrapper here already returns
`(found, value, error)`, so the accessors return `(value, ok, error)`: `ok`
false leaves the value at its zero and the error nil, and the error is reserved
for a MEOS failure.

MEASURED: the suite reads 121 result lines, 0 skipped, against 118 before. The
three added examples pin the absent case for the boolean and float accessors
and for `CreateTemporal` itself, and each fails with the guard removed, so they
witness this change rather than accompany it.
@estebanzimanyi
estebanzimanyi force-pushed the fix/value-at-timestamp-delegates branch from 49715b9 to 0c70563 Compare September 3, 2026 10:05
@estebanzimanyi
estebanzimanyi merged commit d1504e8 into MobilityDB:main Sep 3, 2026
2 checks passed
@estebanzimanyi
estebanzimanyi deleted the fix/value-at-timestamp-delegates branch September 3, 2026 10:23
estebanzimanyi added a commit that referenced this pull request Sep 3, 2026
GoMEOS ships a generated flat FFI layer and a hand-written idiomatic one, so
every class, method and conversion above the wrappers is written and maintained
by hand. The catalog already states that layer: `objectModel.lattice` carries the
temporal tree, `companions` the Box, Collection and Value hierarchies, and
`classes.<Class>.methods` assigns each public MEOS function to the class it is a
method of, under its canonical camelCase `ooName`. MEOS.NET projects the same
model through its own `tools/objectgen.py`; this is the Go projection of it.

Go spells inheritance as embedding, so `TBool` embeds `TAlpha` embeds `Temporal`
and a parent's methods are promoted. Each instance carries the MEOS pointer, and
the two packages exchange it as an `unsafe.Pointer`, because cgo types are
package-scoped and `*C.Temporal` in `functions` is not the same Go type as one
declared here.

THE SIGNATURES COME FROM `codegen.SIGNATURES`, so the two generators cannot
disagree. MEOS declares `bool tbool_value_at_timestamptz(..., bool *value)` --
four parameters, one of them written through -- while the wrapper takes three and
answers two values. Reading the C signature would reconstruct a shape the wrapper
does not have. The table is filled by RUNNING the flat generator, so which
functions have a wrapper is decided in one place and this file holds no second
copy of what that generator skips.

ABSENCE STAYS AN OPTIONAL, in the shape this repository already merged: where
MEOS answers a flag and writes the value out, the method answers
`(value, ok, error)` with `ok` false leaving the value at its zero and the error
nil. `TBool.ValueAtTimestamptz` is generated to exactly what #21 hand-wrote.

MEASURED against a catalog derived at current master: 115 classes, 1256 methods,
105 deferred, each deferral naming the parameter or result that stopped it rather
than being dropped silently. `go build ./types ./functions` and `go vet ./types`
both exit 0, `gofmt -l` reports 0 of 116 files, and a second run of the generator
reproduces the tree byte for byte.

The layer is ADDITIVE: the root package is untouched, so no published name moves.
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