On Thu, Nov 14, 2019 at 11:20:25AM +0300, Nikolay Shaplov wrote:
> For me there is no mush sense in it, as it does not prevent us from wrong type
> casting. Indexes can use all kinds of structures for reloptions, and checking
> that this is index, will not do much.
It seems to me that if the plan is to have one option structure for
each index AM, which has actually the advantage to reduce the bloat of
each relcache entry currently relying on StdRdOptions, then we could
have those extra assertion checks in the same patch, because the new
macros are introduced.
> Do you know way how to distinguish one index from another? If we can check in
> assertion this is index, and this index is spgist, then assertion will make
> sense for 100%. I just have no idea how to do it. As far as I can see it is
> not possible now.
There is rd_rel->relam. You can for example refer to pgstatindex.c
which has AM-related checks to make sure that the correct index AM is
being used.
--
Michael