Skip to content

Operators of the multirange types - #280

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

tamnd merged 1 commit into
mainfrom
mr2

Conversation

@tamnd

@tamnd tamnd commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

This adds the operators of the multirange types, as multirangetypes.c has them. Each operator takes a multirange on one side and a multirange, a range or a value on the other side.

Changes

  • multirange_union (+), multirange_minus (-) and multirange_intersect (*). The difference and the intersection go through the two multiranges in one pass, as multirange_minus_internal and multirange_intersect_internal do.
  • The set function multirange_minus_multi, which gives no row for an empty difference.
  • &&, @> and <@ with a multirange or a range on each side, and @> and <@ with a value. Each side is a list of ranges in order, so one pass finds the answer.
  • <<, >>, &<, &> and -|-. These compare only the lower bound of the first range and the upper bound of the last range, so {[1,5),[7,8)} -|- {[5,7)} is false, as in PostgreSQL.
  • range_split_internal in the range module gives the two parts of a range that another range cuts.

Tests

  • The session test multirange_ops is the output of PostgreSQL 19 for the same script in a new database. It has each operator with empty, infinite and discrete multiranges, the errors of the types that do not match, a cross join of multiranges and a query with parameters.
  • A unit test for the difference, the intersection, the overlap and the containment.
  • 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 f0c5118 into main Oct 13, 2026
5 checks passed
@tamnd
tamnd deleted the mr2 branch October 13, 2026 09:20
@tamnd tamnd mentioned this pull request Oct 13, 2026
8 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