Home Explore Blog CI



postgresql

14th chunk of `doc/src/sgml/brin.sgml`
a0a1b07f29b404d474cc011e444ee60ee79730d7b03aa6990000000100000fa0
 Consolidates two index tuples. Given two index tuples, modifies the
      indicated attribute of the first of them so that it represents both tuples.
      The second tuple is not modified.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>

  An operator class for <acronym>BRIN</acronym> can optionally specify the
  following method:

  <variablelist>
    <varlistentry>
     <term><function>void options(local_relopts *relopts)</function></term>
     <listitem>
      <para>
       Defines a set of user-visible parameters that control operator class
       behavior.
      </para>

      <para>
       The <function>options</function> function is passed a pointer to a
       <structname>local_relopts</structname> struct, which needs to be
       filled with a set of operator class specific options.  The options
       can be accessed from other support functions using the
       <literal>PG_HAS_OPCLASS_OPTIONS()</literal> and
       <literal>PG_GET_OPCLASS_OPTIONS()</literal> macros.
      </para>

      <para>
       Since both key extraction of indexed values and representation of the
       key in <acronym>BRIN</acronym> are flexible, they may depend on
       user-specified parameters.
      </para>
     </listitem>
    </varlistentry>
  </variablelist>

  The core distribution includes support for four types of operator classes:
  minmax, minmax-multi, inclusion and bloom.  Operator class definitions
  using them are shipped for in-core data types as appropriate.  Additional
  operator classes can be defined by the user for other data types using
  equivalent definitions, without having to write any source code;
  appropriate catalog entries being declared is enough.  Note that
  assumptions about the semantics of operator strategies are embedded in the
  support functions' source code.
 </para>

 <para>
  Operator classes that implement completely different semantics are also
  possible, provided implementations of the four main support functions
  described above are written.  Note that backwards compatibility across major
  releases is not guaranteed: for example, additional support functions might
  be required in later releases.
 </para>

 <para>
  To write an operator class for a data type that implements a totally
  ordered set, it is possible to use the minmax support functions
  alongside the corresponding operators, as shown in
  <xref linkend="brin-extensibility-minmax-table"/>.
  All operator class members (functions and operators) are mandatory.
 </para>

 <table id="brin-extensibility-minmax-table">
  <title>Function and Support Numbers for Minmax Operator Classes</title>
  <tgroup cols="2">
   <colspec colname="col1" colwidth="1*"/>
   <colspec colname="col2" colwidth="2*"/>
   <thead>
    <row>
     <entry>Operator class member</entry>
     <entry>Object</entry>
    </row>
   </thead>
   <tbody>
    <row>
     <entry>Support Function 1</entry>
     <entry>internal function <function>brin_minmax_opcinfo()</function></entry>
    </row>
    <row>
     <entry>Support Function 2</entry>
     <entry>internal function <function>brin_minmax_add_value()</function></entry>
    </row>
    <row>
     <entry>Support Function 3</entry>
     <entry>internal function <function>brin_minmax_consistent()</function></entry>
    </row>
    <row>
     <entry>Support Function 4</entry>
     <entry>internal function <function>brin_minmax_union()</function></entry>
    </row>
    <row>
     <entry>Operator Strategy 1</entry>
     <entry>operator less-than</entry>
    </row>
    <row>
     <entry>Operator Strategy 2</entry>
     <entry>operator less-than-or-equal-to</entry>
    </row>
    <row>
     <entry>Operator Strategy 3</entry>
     <entry>operator equal-to</entry>
    </row>
    <row>
     <entry>Operator Strategy 4</entry>
     <entry>operator greater-than-or-equal-to</entry>
    </row>
    <row>
     <entry>Operator Strategy 5</entry>
     <entry>operator greater-than</entry>
    </row>
   </tbody>
  </tgroup>

Title: Defining BRIN Operator Classes
Summary
To define a BRIN operator class, four main support functions must be implemented, and an optional options function can be specified to control operator class behavior. The core distribution includes support for several types of operator classes, and users can define additional classes for other data types without writing source code. Custom operator classes can also be implemented with different semantics by writing the four main support functions.