first add newly loaded plugin to the list then invoke _PG_init

From: mickiewicz(at)syncad(dot)com
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: first add newly loaded plugin to the list then invoke _PG_init
Date: 2021-03-11 11:29:49
Message-ID: 26843fb96fc947da1cbad17906793f9a@syncad.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi All,
I'm working on C plugin for Postgres (ver. 10). One of the thing which I
need is to automatically add some SQL functions from the plugin during
its initialization ( inside _PG_init method ). It means that during
loading libmyplugin.so _PG_init calls SPI_execute( "CREATE FUNCTION
fun() RETURNING void() AS '$libdir/libmyplugin.so', 'fun' LANGUAGE C"
), what leads to recursive call of _PG_init. It seems that the problem
is with adding a plugin to the list after the execution of _PG_init, not
before:
https://github.com/postgres/postgres/blob/2c0cefcd18161549e9e8b103f46c0f65fca84d99/src/backend/utils/fmgr/dfmgr.c#L287
. What do You think about changing this and add a newly loaded plugin to
the list and then execute its _PG_init ? This change will help to keep
consistency between plugin expectation about database structure (about
tables, functions, etc.) without delivery additional SQL scripts -
plugin itself will be able to prepare all the required things.

Best Regards,
Marcin

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2021-03-11 11:31:44 A micro-optimisation for ProcSendSignal()
Previous Message Dilip Kumar 2021-03-11 10:51:38 Re: [HACKERS] Custom compression methods