Skip to content

Text and binary forms of the range types - #276

Merged
tamnd merged 1 commit into
mainfrom
rng1
Oct 13, 2026
Merged

tamnd merged 1 commit into
mainfrom
rng1

Conversation

@tamnd

@tamnd tamnd commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

This adds the range types int4range, int8range, numrange, tsrange, tstzrange and daterange. A range value keeps its flags and its two bounds as values of the subtype, as rangetypes.c does.

Changes

  • rupg-types has the new Range value with range_parse, range_deparse, range_recv and range_send. The parse gives the details of PostgreSQL for a malformed literal.
  • The input, the output, the receive and the send functions of a range call the functions of the subtype for each bound. An error of the input is a soft error, so pg_input_is_valid and pg_input_error_info work.
  • make_range checks the order of the bounds, makes a range empty when the bounds are equal and one bound is exclusive, and applies the canonical form of int4range, int8range and daterange. The overflow errors of the canonical form are the errors of PostgreSQL.
  • New kernels: range_constructor2, range_constructor3, lower, upper, isempty, lower_inc, upper_inc, lower_inf, upper_inf and range_cmp. The comparison operators, ORDER BY, DISTINCT, GROUP BY, GREATEST and LEAST use the order of range_cmp.
  • The analyzer resolves anyrange, anymultirange, anycompatiblerange and anycompatiblemultirange with the rules and the errors of enforce_generic_type_consistency.
  • GREATEST and LEAST find the < of a type through its default btree operator class when the type has no < of its own.
  • The stored form of a node tree has range constants.

Tests

  • The session test range is the output of PostgreSQL 19 for the same script in a new database. It has the text forms, the errors, the constructors, the functions of the bounds, the order, arrays of ranges, a parameter and the text and binary forms of COPY.
  • Unit tests for the text and binary forms, the canonical form, the order and the resolution of the range families.
  • fmt, clippy, the workspace tests and the checks of xtask pass on server1.

@tamnd tamnd added this to the M2: Connect and introspect milestone Oct 13, 2026
@tamnd tamnd added kind/feature It does not do something that it must do. gate/G1 G1: 7 clients connect and show the schema (L1, L2). area/types Types, type I/O, casts and collations. labels Oct 13, 2026
@tamnd tamnd self-assigned this Oct 13, 2026
@tamnd
tamnd merged commit 1db243e into main Oct 13, 2026
5 checks passed
@tamnd
tamnd deleted the rng1 branch October 13, 2026 08:24
@tamnd tamnd mentioned this pull request Oct 13, 2026
4 of 15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/types Types, type I/O, casts and collations. gate/G1 G1: 7 clients connect and show the schema (L1, L2). kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant