Skip to content

Read and write PostgreSQL's time types through their own functions - #160

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:catalog/pg-scalar-codecs
Oct 1, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:catalog/pg-scalar-codecs

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

A PostgreSQL type passed by value, TimestampTz, Timestamp, TimeADT and
DateADT, is a class of typeEncodings like a pointer type, its decoder
returning it and its encoder taking it without a pointer
(timestamptz_in / timestamptz_out). A function taking or returning one
states it on the wire through that codec. PostgreSQL's spelling pg_X
yields to the name MEOS states it under, X, when both serve a class:
timetz_in calls pg_timetz_in, and TimeTzADT and TimeADT read and write
through timetz_in/timetz_out and time_in/time_out. A type passed by value
that has no codec, Datum, states none.

Why. The codec scan read pointer types alone, so every function taking
or returning a timestamp, a date or a time had no wire form, and
TimeTzADT read through pg_timetz_in, which MEOS does not publish.

Measured. Over MobilityDB 72abdf86c2: TimestampTz, Timestamp, TimeADT
and DateADT join typeEncodings, their readers taking typmod -1;
TimeTzADT moves to timetz_in and timetz_out and every other class keeps
its codec; 368 public functions become exposable, 2860 to 3228, and none
stops being exposable. The wire of 527 functions changes, each through
one of the five types. Read through libmeos with the trailing inputs the
catalog states, each type returns its text unchanged: timestamptz_in
'2026-10-01 12:34:56.789+02' writes back
'2026-10-01 12:34:56.789+02', likewise the other four.

Witness. tests/test_enrich.py reads and writes a type passed by value
through its functions, states its parameter and result on the wire,
prefers timetz_in over pg_timetz_in, registers nothing for a value type
without a codec, and over the catalog finds the five codecs; four of
the five fail on the code without this change. The suite floor goes
from 390 to 395.

A PostgreSQL type passed by value, TimestampTz, Timestamp, TimeADT and
DateADT, is a class of typeEncodings like a pointer type, its decoder
returning it and its encoder taking it without a pointer
(timestamptz_in / timestamptz_out). A function taking or returning one
states it on the wire through that codec. PostgreSQL's spelling pg_X
yields to the name MEOS states it under, X, when both serve a class:
timetz_in calls pg_timetz_in, and TimeTzADT and TimeADT read and write
through timetz_in/timetz_out and time_in/time_out. A type passed by value
that has no codec, Datum, states none.

Why. The codec scan read pointer types alone, so every function taking
or returning a timestamp, a date or a time had no wire form, and
TimeTzADT read through pg_timetz_in, which MEOS does not publish.

Measured. Over MobilityDB 72abdf86c2: TimestampTz, Timestamp, TimeADT
and DateADT join typeEncodings, their readers taking typmod -1;
TimeTzADT moves to timetz_in and timetz_out and every other class keeps
its codec; 368 public functions become exposable, 2860 to 3228, and none
stops being exposable. The wire of 527 functions changes, each through
one of the five types. Read through libmeos with the trailing inputs the
catalog states, each type returns its text unchanged: timestamptz_in
'2026-10-01 12:34:56.789+02' writes back
'2026-10-01 12:34:56.789+02', likewise the other four.

Witness. tests/test_enrich.py reads and writes a type passed by value
through its functions, states its parameter and result on the wire,
prefers timetz_in over pg_timetz_in, registers nothing for a value type
without a codec, and over the catalog finds the five codecs; four of
the five fail on the code without this change. The suite floor goes
from 390 to 395.
@estebanzimanyi
estebanzimanyi merged commit 2044363 into MobilityDB:master Oct 1, 2026
3 checks passed
@estebanzimanyi
estebanzimanyi deleted the catalog/pg-scalar-codecs branch October 1, 2026 12:50
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