mirror of
https://github.com/postgres/postgres.git
synced 2025-10-24 01:29:19 +03:00
This patch reduces pg_am to just two columns, a name and a handler function. All the data formerly obtained from pg_am is now provided in a C struct returned by the handler function. This is similar to the designs we've adopted for FDWs and tablesample methods. There are multiple advantages. For one, the index AM's support functions are now simple C functions, making them faster to call and much less error-prone, since the C compiler can now check function signatures. For another, this will make it far more practical to define index access methods in installable extensions. A disadvantage is that SQL-level code can no longer see attributes of index AMs; in particular, some of the crosschecks in the opr_sanity regression test are no longer possible from SQL. We've addressed that by adding a facility for the index AM to perform such checks instead. (Much more could be done in that line, but for now we're content if the amvalidate functions more or less replace what opr_sanity used to do.) We might also want to expose some sort of reporting functionality, but this patch doesn't do that. Alexander Korotkov, reviewed by Petr Jelínek, and rather heavily editorialized on by me.
40 lines
948 B
C
40 lines
948 B
C
/*
|
|
* AM-callable functions for BRIN indexes
|
|
*
|
|
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* IDENTIFICATION
|
|
* src/include/access/brin.h
|
|
*/
|
|
#ifndef BRIN_H
|
|
#define BRIN_H
|
|
|
|
#include "fmgr.h"
|
|
#include "nodes/execnodes.h"
|
|
#include "utils/relcache.h"
|
|
|
|
|
|
/*
|
|
* prototypes for functions in brin.c (external entry points for BRIN)
|
|
*/
|
|
extern Datum brinhandler(PG_FUNCTION_ARGS);
|
|
extern Datum brin_summarize_new_values(PG_FUNCTION_ARGS);
|
|
|
|
/*
|
|
* Storage type for BRIN's reloptions
|
|
*/
|
|
typedef struct BrinOptions
|
|
{
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
|
BlockNumber pagesPerRange;
|
|
} BrinOptions;
|
|
|
|
#define BRIN_DEFAULT_PAGES_PER_RANGE 128
|
|
#define BrinGetPagesPerRange(relation) \
|
|
((relation)->rd_options ? \
|
|
((BrinOptions *) (relation)->rd_options)->pagesPerRange : \
|
|
BRIN_DEFAULT_PAGES_PER_RANGE)
|
|
|
|
#endif /* BRIN_H */
|