pl/proxy and sequence generation

From: Igor Katson <descentspb(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: pl/proxy and sequence generation
Date: 2008-12-24 15:18:14
Message-ID: 495252B6.5090702@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello!

The problem, i'm going to describe is about pl/proxy usage. I'll call
the bases, which are proxied to, the node-based and the base, which
contains pl/proxy the proxy-base.

The task, I need to accomplish, is to make an insert into node-bases,
using the sequence, generated inside the proxy-base, as the primary key.

As far as I understand, this is not a good idea to generate the keys
inside the node-bases, simply because the values will not be unique,
cause they will have different sequence generators. So I decided to make
a sequence in the proxy-base. And the sequence number should be passed
to the node-bases as a fucntion argument. As far as I know, you should
have the same number and types of arguments for this function both in
the node-bases and the proxy-base. So I should have a sequence number as
an argument in the proxy-base too.

Usually, the application calls the function in the proxy-base, and this
function calls the same ones in the node-bases. But the application
should not generate the sequence, and it should not pass it as an
argument to the function.

So, should I make a wrapper in e.g. PL/pgsql for every insert function
writen in PL/Proxy to remove the sequence from the argument list and to
call the sequence generator?
Is there a better way to do that?

Thanks in advance,
Igor Katson.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jonah H. Harris 2008-12-24 15:44:33 Re: pl/proxy and sequence generation
Previous Message Roderick A. Anderson 2008-12-24 15:17:34 Multi-tenant cluster