Skip to content
Snippets Groups Projects
Commit 972bf7d6 authored by Alvaro Herrera's avatar Alvaro Herrera
Browse files

Tweak BRIN minmax operator class

In the union support proc, we were not checking the hasnulls flag of
value A early enough, so it could be skipped if the "allnulls" flag in
value B is set.  Also, a check on the allnulls flag of value "B" was
redundant, so remove it.

Also change inet_minmax_ops to not be the default opclass for type inet,
as a future inclusion operator class would be more useful and it's
pretty difficult to change default opclass for a datatype later on.
(There is no catversion bump for this catalog change; this shouldn't be
a problem.)

Extracted from a larger patch to add an "inclusion" operator class.

Author: Emre Hasegeli
parent b04d6916
No related branches found
No related tags found
No related merge requests found
......@@ -256,23 +256,24 @@ brin_minmax_union(PG_FUNCTION_ARGS)
Assert(col_a->bv_attno == col_b->bv_attno);
/* If there are no values in B, there's nothing to do */
/* Adjust "hasnulls" */
if (!col_a->bv_hasnulls && col_b->bv_hasnulls)
col_a->bv_hasnulls = true;
/* If there are no values in B, there's nothing left to do */
if (col_b->bv_allnulls)
PG_RETURN_VOID();
attno = col_a->bv_attno;
attr = bdesc->bd_tupdesc->attrs[attno - 1];
/* Adjust "hasnulls" */
if (col_b->bv_hasnulls && !col_a->bv_hasnulls)
col_a->bv_hasnulls = true;
/*
* Adjust "allnulls". If B has values but A doesn't, just copy the values
* from B into A, and we're done. (We cannot run the operators in this
* case, because values in A might contain garbage.)
* Adjust "allnulls". If A doesn't have values, just copy the values
* from B into A, and we're done. We cannot run the operators in this
* case, because values in A might contain garbage. Note we already
* established that B contains values.
*/
if (!col_b->bv_allnulls && col_a->bv_allnulls)
if (col_a->bv_allnulls)
{
col_a->bv_allnulls = false;
col_a->bv_values[0] = datumCopy(col_b->bv_values[0],
......
......@@ -252,7 +252,7 @@ DATA(insert ( 3580 float8_minmax_ops PGNSP PGUID 4070 701 t 0 ));
DATA(insert ( 3580 abstime_minmax_ops PGNSP PGUID 4072 702 t 0 ));
DATA(insert ( 3580 reltime_minmax_ops PGNSP PGUID 4073 703 t 0 ));
DATA(insert ( 3580 macaddr_minmax_ops PGNSP PGUID 4074 829 t 0 ));
DATA(insert ( 3580 inet_minmax_ops PGNSP PGUID 4075 869 t 0 ));
DATA(insert ( 3580 inet_minmax_ops PGNSP PGUID 4075 869 f 0 ));
DATA(insert ( 3580 bpchar_minmax_ops PGNSP PGUID 4076 1042 t 0 ));
DATA(insert ( 3580 time_minmax_ops PGNSP PGUID 4077 1083 t 0 ));
DATA(insert ( 3580 date_minmax_ops PGNSP PGUID 4059 1082 t 0 ));
......
......@@ -65,7 +65,7 @@ CREATE INDEX brinidx ON brintest USING brin (
float4col,
float8col,
macaddrcol,
inetcol,
inetcol inet_minmax_ops,
bpcharcol,
datecol,
timecol,
......
......@@ -68,7 +68,7 @@ CREATE INDEX brinidx ON brintest USING brin (
float4col,
float8col,
macaddrcol,
inetcol,
inetcol inet_minmax_ops,
bpcharcol,
datecol,
timecol,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment