mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +03:00
Add geometry/range functions to support BRIN inclusion
This commit adds the following functions: box(point) -> box bound_box(box, box) -> box inet_same_family(inet, inet) -> bool inet_merge(inet, inet) -> cidr range_merge(anyrange, anyrange) -> anyrange The first of these is also used to implement a new assignment cast from point to box. These functions are the first part of a base to implement an "inclusion" operator class for BRIN, for multidimensional data types. Author: Emre Hasegeli Reviewed by: Andreas Karlsson
This commit is contained in:
@@ -4227,6 +4227,45 @@ box_div(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_BOX_P(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert point to empty box
|
||||
*/
|
||||
Datum
|
||||
point_box(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Point *pt = PG_GETARG_POINT_P(0);
|
||||
BOX *box;
|
||||
|
||||
box = (BOX *) palloc(sizeof(BOX));
|
||||
|
||||
box->high.x = pt->x;
|
||||
box->low.x = pt->x;
|
||||
box->high.y = pt->y;
|
||||
box->low.y = pt->y;
|
||||
|
||||
PG_RETURN_BOX_P(box);
|
||||
}
|
||||
|
||||
/*
|
||||
* Smallest bounding box that includes both of the given boxes
|
||||
*/
|
||||
Datum
|
||||
boxes_bound_box(PG_FUNCTION_ARGS)
|
||||
{
|
||||
BOX *box1 = PG_GETARG_BOX_P(0),
|
||||
*box2 = PG_GETARG_BOX_P(1),
|
||||
*container;
|
||||
|
||||
container = (BOX *) palloc(sizeof(BOX));
|
||||
|
||||
container->high.x = Max(box1->high.x, box2->high.x);
|
||||
container->low.x = Min(box1->low.x, box2->low.x);
|
||||
container->high.y = Max(box1->high.y, box2->high.y);
|
||||
container->low.y = Min(box1->low.y, box2->low.y);
|
||||
|
||||
PG_RETURN_BOX_P(container);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
**
|
||||
|
Reference in New Issue
Block a user