From: Nikita Glukhov <n.gluhov@postgrespro.ru>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Nikolay Shaplov <dhyan@nataraj.su>
Cc: Oleg Bartunov <obartunov@gmail.com>
Subject: Re: [PATCH] Opclass parameters
Date: Wed, 11 Sep 2019 01:44:28 +0300
Message-ID: <0807f67b-c1bd-3760-7fc5-89900ae65408@postgrespro.ru> (raw)
In-Reply-To: <20190910220358.6tj37k4v6vyaqac7@development>
References: <20190903220254.GA22389@alvherre.pgsql>
<dcb740af-2a93-8785-eb26-a4273029f2fb@postgrespro.ru>
<20190910220358.6tj37k4v6vyaqac7@development>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: n.gluhov@postgrespro.ru, tomas.vondra@2ndquadrant.com, alvherre@2ndquadrant.com, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, dhyan@nataraj.su, obartunov@gmail.com
Subject: Re: [PATCH] Opclass parameters
In-Reply-To: <0807f67b-c1bd-3760-7fc5-89900ae65408@postgrespro.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox