Re: [rfc,patch] PL/Proxy in core

From: Hannu Krosing <hannu(at)krosing(dot)net>
To: Marko Kreen <markokr(at)gmail(dot)com>
Cc: Postgres Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [rfc,patch] PL/Proxy in core
Date: 2008-05-20 11:30:47
Message-ID: 1211283047.8174.45.camel@huvostro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 2008-05-14 at 23:29 +0300, Marko Kreen wrote:

> There are few code beautification ideas on which I'd like to
> get feedback from wider audience:
>
> - Drop CONNECT statement. This was added to make creating
> simple dblink style calls easier, but actually its not
> maintainable compared to CLUSTER, it can be used only
> for occasional hacks. OTOH, if we want to deprecate
> dblink and replace it with PL/Proxy, it should probably stay.
>
> - Drop SELECT statement. This was added as it was simple to do
> and also to be straightforward replacement for dblink. But
> it's conceptually ugly. Also it gives impression that there
> will be UPDATE, DELETE and IF... which will not happen.

I'd also suggest one feature request

- Add COPY FROM/TO support

The way It could be done is similar to (now deprecated) SELECT

CREATE FUNCTION copy_users_to_partitions()
RETURNS VOID AS $$
CLUSTER 'userdb';
RUN ON hashtext(text::$1);
COPY users FROM stdin;
$$ LANGUAGE plproxy;

and it should be used like COPY is currently

proxydb# SELECT copy_users_to_partitions();
bob bobspwd bob(at)email(dot)com
ben benspwd ben(at)email(dot)com
...
amy amyspwd amy(at)email(dot)com
.
copy_users_to_partitions
--------------------------

(1 row)

I am not sure how easy it is to get access to "stdin" from inside a function,
but the version of COPY which copies from filesystem can surely be done.

On slaves it will always be plain COPY with STDIN/STDOUT.

As this reintroduces "direct access to partition tables" feature removed with
SELECT, it should be a feature that can be used by superusers only.

Notice that field type should be given, as it can't be deduced from arguments.

COPY .. TO would usually (but not neccessarily) be RUN ON ALL

--------------------
Hannu

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2008-05-20 11:36:17 Re: triggers on prepare, commit, rollback... ?
Previous Message Hannu Krosing 2008-05-20 11:09:26 Re: triggers on prepare, commit, rollback... ?