Skip to content

Operators of the range types - #277

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

tamnd merged 1 commit into
mainfrom
rng2

Conversation

@tamnd

@tamnd tamnd commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

This adds the operators of the range types and the functions that use them, as rangetypes.c has them. It also makes an integer literal that fits int4 after the parser negates it, such as -2147483648, an int4, as make_const does.

Changes

  • New kernels: range_overlaps (&&), range_contains and range_contains_elem (@>), range_contained_by and elem_contained_by_range (<@), range_before (<<), range_after (>>), range_overleft (&<), the function of &> and range_adjacent (-|-).
  • New kernels that give a range: range_union (+), range_merge, range_intersect (*) and range_minus (-). A union of two ranges with a gap and a difference with two parts give the 22000 errors of PostgreSQL.
  • The set function range_minus_multi gives no row, one row or two rows.
  • The subtype difference functions int4range_subdiff, int8range_subdiff, numrange_subdiff, daterange_subdiff, tsrange_subdiff and tstzrange_subdiff.
  • Adjacency of discrete ranges makes the range between the two bounds and looks for an empty range, as bounds_adjacent does.
  • make_const gives int4 for a literal of the Float node that fits int4. Before, int4range(NULL,10) @> -2147483648 did not find the operator.

Tests

  • The session test range_ops is the output of PostgreSQL 19 for the same script in a new database. It has each operator with empty, infinite, inclusive and exclusive bounds, the errors, range_minus_multi in FROM and in the target list, the subtype difference functions, a cross join of ranges and a query with parameters.
  • A unit test for adjacency, union, intersection and difference.
  • 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 9f39c5d into main Oct 13, 2026
5 checks passed
@tamnd
tamnd deleted the rng2 branch October 13, 2026 08:42
@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