Search Postgresql Archives

Re: CREATE RULE fails with 'ERROR: SELECT rule's target list has too many entries'

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

 



Henrik Kuhn <henrik.kuhn@xxxxxxxxxxx> writes:
> On 12/05/2012 04:07 PM, Tom Lane wrote:
>> Henrik Kuhn <henrik.kuhn@xxxxxxxxxxx> writes:
>>> can somebody give me some insights why the creation of this rule fails
>> > with 'ERROR:  SELECT rule's target list has too many entries'?

>> Probably that history_relation has fewer than three columns?  But if
>> you want something more than guessing, you'd have to provide more
>> context, such as the definitions of the underlying tables.  Why are
>> you trying to execute this command anyway?

> The history_relatio-DDL is quite simple:

> CREATE TABLE history_relation (
>      id                  UUID NOT NULL DEFAULT uuid_generate_v4()
>    , relname        name NOT NULL CHECK ( relname::regclass IS NOT NULL 
> ) -- use regclass to validate

>    , PRIMARY KEY (id)
> );

> But are your really sure, that the error is thrown just because of there 
> are not more than 3 cols in history_relation?

Yes.  I think you misunderstand what that command is for: it's going to
convert the table into a view, and as a safety check it is not allowed
for the resulting view to have a different column set than the table
did.

I think what you need to do is create the underlying table with some
other name, create history_relation as a plain view, and then perhaps
you want some INSTEAD OF triggers on the view to convert insertions
etc into updates of the underlying table.

			regards, tom lane


-- 
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