Re: psql: add \pset true/false

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: michael(dot)paquier(at)gmail(dot)com
Cc: Jim(dot)Nasby(at)bluetreble(dot)com, peter_e(at)gmx(dot)net, tgl(at)sss(dot)pgh(dot)pa(dot)us, marko(at)joh(dot)to, daniel(at)manitou-mail(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: psql: add \pset true/false
Date: 2015-12-03 05:53:30
Message-ID: 20151203.145330.216602814.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello, the attched is an example implement of output filter
dynamic loading feature of psql.

At Thu, 3 Dec 2015 10:41:11 +0900, Michael Paquier <michael(dot)paquier(at)gmail(dot)com> wrote in <CAB7nPqSuLVD0m8GWkL2bar4SuxrwY2+YBYmTBm0UT4At7jg_8Q(at)mail(dot)gmail(dot)com>
> > How about plugins on psql side? Calling hooked function in
> > printQuery could do that on psql. Impact on psql itself is
> > minimized. (Of course code for loading is omitted in the below
> > but it would also small...)
>
> That's interesting, and crazy. You would basically need to have the
> equivalent of \load, or an environment variable like PSQL_SHARED_LIBS
> that is similar to shared_preload_libraries on client-side. In short I
> guess that's actually a clone of LD_PRELOAD.

It is bothersome to share the server-side preload feature so I
made this as a minimal implement. Some safety meature should be
added but not so severe than backend. I home this is an
acceptable mess.

The attached patch adds a function to load output filter DLL.
The second file is an example filter module. The following
commandline with the file can create a test filter module. I
suppose preload feature only needs additional few lines.

gcc -I<pgsql_include> -fPIC -shared outfunctest.c -o /tmp/outfunctest.so

Then, on psql command line.

=# select 't'::bool;
bool
------
t
=# \load_dll /tmp/outfunctest.so
=# select 't'::bool;
bool
-----------
TRRRRUEEE
(1 row)

Anyone can tweak any type of output by this.

Opinions, suggestions or rejections are welcome.

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
0001-Test-implement-of-dynamic-loadable-output-filter.patch text/x-patch 2.4 KB
unknown_filename text/plain 405 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Catalin Iacob 2015-12-03 06:04:13 Re: proposal: PL/Pythonu - function ereport
Previous Message Amit Langote 2015-12-03 05:18:50 Re: [PROPOSAL] VACUUM Progress Checker.