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

From Henrik Kuhn
Subject CREATE RULE fails with 'ERROR: SELECT rule's target list has too many entries'
Date
Msg-id 50BF4626.2030102@origenis.de
Whole thread Raw
Responses Re: CREATE RULE fails with 'ERROR: SELECT rule's target list has too many entries'
List 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




pgsql-general by date:

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