darold/pgtt

How to automate pgtt loading?

YuriKulaghin opened this issue · 4 comments

Hi,

Is the way to automate pgtt loading after session establishing on a server side, without calling LOAD '$libdir/plugins/pgtt' by a client? I know that code of pgtt prevents using session_preload_libraries and shared_preload_libraries.

Unfortunately there is no other way.

I encountered the same need,and tried some modifications both in postgresql and pgtt plugin,it works!
The basic idea is executing the statement "LOAD 'pgtt';" in the new session progress;
in the PostgresMain()-> InitPostgres() interface,add "LOAD 'pgtt';" execute interface implement by SPI

create extension login_hook;
CREATE OR REPLACE FUNCTION login_hook.login() RETURNS VOID LANGUAGE PLPGSQL AS $$
DECLARE
ex_state TEXT;
ex_message TEXT;
ex_detail TEXT;
ex_hint TEXT;
ex_context TEXT;
BEGIN
LOAD '$libdir/plugins/pgtt';
END
$$;
GRANT EXECUTE ON FUNCTION login_hook.login() TO PUBLIC;

Thanks to @rjuju commit 513b416 allow to use pgtt without having to load the extension at client side but by setting session_preload_libraries in postgresql.conf