Re: [PATCH] Opclass parameters

Поиск
Список
Период
Сортировка
От Nikita Glukhov
Тема Re: [PATCH] Opclass parameters
Дата
Msg-id 0807f67b-c1bd-3760-7fc5-89900ae65408@postgrespro.ru
обсуждение исходный текст
Ответ на Re: [PATCH] Opclass parameters  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Ответы Re: [PATCH] Opclass parameters  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Список pgsql-hackers

On 11.09.2019 1:03, Tomas Vondra wrote:

On Tue, Sep 10, 2019 at 04:30:41AM +0300, Nikita Glukhov wrote:

2. New AM method amattoptions().

  amattoptions() is used to specify per-column AM-specific options.
  The example is signature length for bloom indexes (patch #3).


I'm somewhat confused how am I supposed to use this, considering the patch
set only defines this for the contrib/bloom index AM. So let's say I want
to create a custom BRIN opclass with per-attribute options (like the two
BRIN opclasses I work on in the other thread). Clearly, I can't tweak the
IndexAmRoutine from the extension. ISTM the patch series should modify all
existing index AMs to have a valid amattoptions() implementation, calling
the new amproc if defined.

Or what is the correct way to define custom opclass for existing index AM
(e.g. BRIN) with attribute options?

Per-attribute opclass options are implemented independently from per-attribute 
AM options.  amattoptions() is optional and needs to be defined only if AM has 
per-attribute options.  amproc #0 is called regardless of whether amattoptions
is defined or not.  That was the main reason why uniform procnum 0 was picked.
You should simply define function like that and use it as amproc #0:
Datum
brin_bloom_options(PG_FUNCTION_ARGS)
{   local_relopts *relopts = (local_relopts *) PG_GETARG_POINTER(0);   BloomOptions *blopts = NULL;
   extend_local_reloptions(relopts, blopts, sizeof(*blopts));
   add_local_real_reloption(relopts, "n_distinct_per_range", "desc",                            -0.1, -1.0, INT_MAX, &blopts->nDistinctPerRange);
   add_local_real_reloption(relopts, "false_positive_rate", "desc",                            0.01, 0.001, 1.0, &blopts->falsePositiveRate);
   PG_RETURN_VOID();
}
--
Nikita Glukhov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Julien Rouhaud
Дата:
Сообщение: Re: Planning counters in pg_stat_statements (using pgss_store)
Следующее
От: Julien Rouhaud
Дата:
Сообщение: Re: Planning counters in pg_stat_statements (using pgss_store)