Search Postgresql Archives

Re: Redirect sequence access to different schema

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jul 25, 2010, at 23:13 , Joe Conway wrote:
> On 07/25/2010 12:01 PM, Magnus Reftel wrote:
>> create view myseq as select * from other_schema.foo_id_seq;
>> 
>> but when I run "select nextval('myseq');" I get an error saying that
>> myseq "is not a sequence". What other options are there?
> 
> It isn't clear (to me, at least) what you are trying to accomplish, but
> does this do what you want?

Thanks for the reply! Sorry for not being clear. What I'm after is being able to have some code run on the database without having to modify the application or its database schema. The way I'm trying to achieve this is by setting it up to access a different schema than it usually would, and have that schema act as a proxy for the real schema using views and rules that perform the alterations I want. It works fine for tables, but I had trouble with getting ti work with sequences.

One solution I came up with is to not try to emulate the sequence, but the functions accessing the sequence, as in:

alter function currval(regclass) rename to real_currval;
create function inject.currval(unknown) returns bigint as 'select real_currval(''actual.'' || CAST($1 as text));' language sql security definer;

Best Regards
Magnus Reftel
-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux