Closed Hoverbear closed 1 year ago
This is the last missing feature I'd need for my company to start migrating our c->pgx! A zero copy implementation like pgx::Array<T>
would be awesome. Even just exposing these functions (and their multirange counterparts) for manual use would be a great workaround.
RangeType* range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, bool empty)
void range_deserialize(TypeCacheEntry *typcache, const RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
TypeCacheEntry *range_get_typcache(FunctionCallInfo fcinfo, Oid rngtypid)
@johnrballard there's a yet-to-be PR'd task I'm working on for +/- infinity Timestamps which Range would also depend on for tsrange/tstzrange
This draft PR is rather old and @workingjubilee has illuminated many subjects to me and your newer best practices, (rather than me mimicking older pgx data type approaches) so once those dependent tasks are done I'll likely restart this PR from scratch.
@mhov I attached it here as a mental prompt. My strikethrough was my attempt as saying that we are not doing this but here it is for reference.
We'd like PGX to support Postgres Ranges (and to provide clean ways to pass ranges between Rust and PostgreSQL).
PostgreSQL has several builtin range types:
int4range
(andint4multirange
)int8range
(andint8multirange
)numrange
(andnummultirange
)tsrange
(andtsmultirange
)tstzrange
(andtstzmultirange
)daterange
(anddatemultirange
)We'd like to provide equivalent types and mappings in PGX for these.
Both Rust and Postgres support inclusive/exclusive ranges, as well as unbounded ranges. Both also support empty ranges.
User defined ranges
Users can define a new range type like:
pgx
does not currently support user defined types, so it also doesn't support user defined range types.