New procedural language

Started by Massimo Fidanzaalmost 9 years ago5 messages
#1Massimo Fidanza
malix0@gmail.com

Hello,

what it means to add a new procedural language such as Go or Rust?

Thanks
Massimo

#2Michael Paquier
michael.paquier@gmail.com
In reply to: Massimo Fidanza (#1)
Re: New procedural language

On Wed, Mar 15, 2017 at 11:08 AM, Massimo Fidanza <malix0@gmail.com> wrote:

what it means to add a new procedural language such as Go or Rust?

If you are willing to allow functions defined in Postgres to be
written in such languages, you are likely looking some answers in the
documentation first on how to implement that:
https://www.postgresql.org/docs/9.6/static/plhandler.html
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Amit Langote
Langote_Amit_f8@lab.ntt.co.jp
In reply to: Massimo Fidanza (#1)
Re: New procedural language

Hi,

On 2017/03/15 11:08, Massimo Fidanza wrote:

Hello,

what it means to add a new procedural language such as Go or Rust?

I think you're looking for how to write a "PL function call handler", most
likely in C. See for example how plpython_call_handler() is defined in
src/pl/plpython/plpy_main.c. Also read:

https://www.postgresql.org/docs/devel/static/plhandler.html

Beside the call handler, there are couple of other auxiliary functions
that must be provided viz. validator and inline_handler (again, see
plpython_validator and plpython_inline_handler).

Thanks,
Amit

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Massimo Fidanza
malix0@gmail.com
In reply to: Amit Langote (#3)
Re: New procedural language

But there is a difference between python and Go or Rust that the first is
interpreted and the seconds are compiled like C. All PL instead of C and
Java (also byte code interpreted) are interpreted

Il 15 mar 2017 3:52 AM, "Amit Langote" <Langote_Amit_f8@lab.ntt.co.jp> ha
scritto:

Show quoted text

Hi,

On 2017/03/15 11:08, Massimo Fidanza wrote:

Hello,

what it means to add a new procedural language such as Go or Rust?

I think you're looking for how to write a "PL function call handler", most
likely in C. See for example how plpython_call_handler() is defined in
src/pl/plpython/plpy_main.c. Also read:

https://www.postgresql.org/docs/devel/static/plhandler.html

Beside the call handler, there are couple of other auxiliary functions
that must be provided viz. validator and inline_handler (again, see
plpython_validator and plpython_inline_handler).

Thanks,
Amit

#5Amit Langote
Langote_Amit_f8@lab.ntt.co.jp
In reply to: Massimo Fidanza (#4)
Re: New procedural language

Hi,

On 2017/03/15 16:20, Massimo Fidanza wrote:

Il 15 mar 2017 3:52 AM, "Amit Langote" <Langote_Amit_f8@lab.ntt.co.jp> ha
scritto:

On 2017/03/15 11:08, Massimo Fidanza wrote:

Hello,

what it means to add a new procedural language such as Go or Rust?

I think you're looking for how to write a "PL function call handler", most
likely in C. See for example how plpython_call_handler() is defined in
src/pl/plpython/plpy_main.c. Also read:

https://www.postgresql.org/docs/devel/static/plhandler.html

Beside the call handler, there are couple of other auxiliary functions
that must be provided viz. validator and inline_handler (again, see
plpython_validator and plpython_inline_handler).

But there is a difference between python and Go or Rust that the first is
interpreted and the seconds are compiled like C. All PL instead of C and
Java (also byte code interpreted) are interpreted

I think you might want to take a look at how PL/Java is implemented then:

https://github.com/tada/pljava

Call handler function I mentioned seems to be implemented in this file:

https://github.com/tada/pljava/blob/master/pljava-so/src/main/c/Backend.c

Just like writing and deploying C functions, functions written in PL/Java
seem to require manual compilation and elaborate installation steps.

Thanks,
Amit

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers