Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group