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

From: Henrik Kuhn <henrik(dot)kuhn(at)origenis(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: CREATE RULE fails with 'ERROR: SELECT rule's target list has too many entries'
Date: 2012-12-05 13:03:34
Message-ID: 50BF4626.2030102@origenis.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

can somebody give me some insights why the creation of this rule fails
with 'ERROR: SELECT rule's target list has too many entries'?

CREATE RULE "_RETURN" AS
ON SELECT TO history_relation
DO INSTEAD
SELECT
history_relation.id,
history_relation.relname,
pg_attribute.attname AS keyname
FROM
history_relation, pg_index, pg_class, pg_attribute
WHERE
pg_class.oid = history_relation.relname::regclass AND
indrelid = pg_class.oid AND
pg_attribute.attrelid = pg_class.oid AND
pg_attribute.attnum = any(pg_index.indkey)
AND indisprimary;

The purpose of this rule is to retrieve the primary key name upon the
given table name (relname) stored in the table 'history_relation' upon
SELECT only.

Kind regards,
Henrik

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Edson Richter 2012-12-05 13:11:44 Re: Table with million rows - and PostgreSQL 9.1 is not using the index
Previous Message Gauthier, Dave 2012-12-05 13:00:24 Re: how do I grant select to one user for all tables in a DB?