Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8d90736

Browse files
committed
Improve BRIN documentation somewhat
This removes some info about support procedures being used, which was obsoleted by commit db5f98a, as well as add some more documentation on how to create new opclasses using the Minmax infrastructure. (Hopefully we can get something similar for Inclusion as well.) In passing, fix some obsolete mentions of "mmtuples" in source code comments. Backpatch to 9.5, where BRIN was introduced.
1 parent b7ca57a commit 8d90736

File tree

3 files changed

+77
-12
lines changed

3 files changed

+77
-12
lines changed

doc/src/sgml/brin.sgml

+73-8
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,79 @@ typedef struct BrinOpcInfo
529529
</varlistentry>
530530
</variablelist>
531531

532-
To implement these methods in a generic way, the operator class
533-
defines its own internal support functions.
534-
(For instance, the <quote>min/max</> operator classes implement
535-
support functions for the four inequality operators for their data type.)
536-
Additionally, the operator class must supply appropriate
537-
operator entries,
538-
to enable the optimizer to use the index when those operators are
539-
used in queries.
532+
The core distribution includes support for two types of operator classes:
533+
minmax and inclusion. Operator class definitions using them are shipped for
534+
in-core data types as appropriate. Additional operator classes can be
535+
defined by the user for other datatypes using equivalent definitions,
536+
without having to write any source code; appropriate catalog entries being
537+
declared is enough. Note that assumptions about the semantics of operator
538+
strategies are embedded in the support procedures's source code.
540539
</para>
540+
541+
<para>
542+
Operator classes that implement completely different semantics are also
543+
possible, provided implementations of the four main support procedures
544+
described above are written. Note that backwards compatibility across major
545+
releases is not guaranteed: for example, additional support procedures might
546+
be required in later releases.
547+
</para>
548+
549+
<para>
550+
To write an operator class for a datatype that implements a totally
551+
ordered set, it is possible to use the Minmax support procedures
552+
alongside the corresponding operators, as shown in
553+
<xref linkend="brin-extensibility-minmax-table">.
554+
All operator class members (procedures and operators) are mandatory.
555+
</para>
556+
557+
<table id="brin-extensibility-minmax-table">
558+
<title>Procedure and Support Numbers for Minmax Operator Classes</title>
559+
<tgroup cols="2">
560+
<thead>
561+
<row>
562+
<entry>Operator class member</entry>
563+
<entry>Object</entry>
564+
</row>
565+
</thead>
566+
<tbody>
567+
<row>
568+
<entry>Support Procedure 1</entry>
569+
<entry>function <function>brin_minmax_opcinfo()</function></entry>
570+
</row>
571+
<row>
572+
<entry>Support Procedure 2</entry>
573+
<entry>function <function>brin_minmax_add_value()</function></entry>
574+
</row>
575+
<row>
576+
<entry>Support Procedure 3</entry>
577+
<entry>function <function>brin_minmax_consistent()</function></entry>
578+
</row>
579+
<row>
580+
<entry>Support Procedure 4</entry>
581+
<entry>function <function>brin_minmax_union()</function></entry>
582+
</row>
583+
<row>
584+
<entry>Operator Strategy 1</entry>
585+
<entry>operator less-than</entry>
586+
</row>
587+
<row>
588+
<entry>Operator Strategy 2</entry>
589+
<entry>operator less-than-or-equal-to</entry>
590+
</row>
591+
<row>
592+
<entry>Operator Strategy 3</entry>
593+
<entry>operator equal-to</entry>
594+
</row>
595+
<row>
596+
<entry>Operator Strategy 4</entry>
597+
<entry>operator greater-than-or-equal-to</entry>
598+
</row>
599+
<row>
600+
<entry>Operator Strategy 5</entry>
601+
<entry>operator greater-than</entry>
602+
</row>
603+
</tbody>
604+
</tgroup>
605+
</table>
541606
</sect1>
542607
</chapter>

src/backend/access/brin/brin.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ brinbuildempty(PG_FUNCTION_ARGS)
688688
*
689689
* XXX we could mark item tuples as "dirty" (when a minimum or maximum heap
690690
* tuple is deleted), meaning the need to re-run summarization on the affected
691-
* range. Need to an extra flag in mmtuples for that.
691+
* range. Need to an extra flag in brintuples for that.
692692
*/
693693
Datum
694694
brinbulkdelete(PG_FUNCTION_ARGS)

src/backend/access/brin/brin_xlog.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ brin_xlog_samepage_update(XLogReaderState *record)
180180
if (action == BLK_NEEDS_REDO)
181181
{
182182
Size tuplen;
183-
BrinTuple *mmtuple;
183+
BrinTuple *brintuple;
184184
Page page;
185185
OffsetNumber offnum;
186186

187-
mmtuple = (BrinTuple *) XLogRecGetBlockData(record, 0, &tuplen);
187+
brintuple = (BrinTuple *) XLogRecGetBlockData(record, 0, &tuplen);
188188

189189
page = (Page) BufferGetPage(buffer);
190190

@@ -193,7 +193,7 @@ brin_xlog_samepage_update(XLogReaderState *record)
193193
elog(PANIC, "brin_xlog_samepage_update: invalid max offset number");
194194

195195
PageIndexDeleteNoCompact(page, &offnum, 1);
196-
offnum = PageAddItem(page, (Item) mmtuple, tuplen, offnum, true, false);
196+
offnum = PageAddItem(page, (Item) brintuple, tuplen, offnum, true, false);
197197
if (offnum == InvalidOffsetNumber)
198198
elog(PANIC, "brin_xlog_samepage_update: failed to add tuple");
199199

0 commit comments

Comments
 (0)