From: | needthistool(at)gmail(dot)com |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #13775: CREATE RULE documentation seems to be wrong under ON SELECT TO <table> DO INSTEAD SELECT |
Date: | 2015-11-13 21:08:00 |
Message-ID: | 20151113210800.615.72954@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 13775
Logged by: Seldom
Email address: needthistool(at)gmail(dot)com
PostgreSQL version: 9.2.14
Operating system: Linux 4.1.10-17.31.amzn1.x86_64 #1 (~RHEL 4.8.3-9)
Description:
>From the docs:
"Thus, an ON SELECT rule **effectively** turns the table into a view, whose
visible contents are the rows returned by the rule's SELECT command **rather
than whatever had been stored in the table** (if anything). It is
**considered better style** to write a CREATE VIEW command than to create a
real table and define an ON SELECT rule for it." {'**' emphases added}
As far as I can tell, the above is no longer correct whatsoever; at least on
my own server, the CREATE RULE "_RETURN" syntax **actually** turns the table
into a view, dropping the table in question and creating a new view which
has the same name and columns as the table (undocumented-ly possible only if
there are no indexes, triggers, or foreign-key constraints on the current
table, in addition to no rows, which makes the "if anything" remark pretty
misleading).
The documentation /suggests/ that CREATE VIEW ... be used in place of ON
SELECT TO <table> DO INSTEAD SELECT ... however unless I'm mistaken, this is
actually not a **choice**, merely obfuscated sugar for CREATE VIEW. It does
not appear possible to shadow a table with an alternate selection-clause
which makes the real contents of the table appear different in some way (for
instance, adding a default sorting or if one wasn't specified or such).
I don't know what the consensus is with regard to what this syntax may do in
future, but right now, it appears the docs simply do not relate to the
actual behavior of the codebase.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-11-13 23:23:09 | Re: BUG #13775: CREATE RULE documentation seems to be wrong under ON SELECT TO <table> DO INSTEAD SELECT |
Previous Message | Jaime Casanova | 2015-11-13 19:53:51 | Re: postgresql downgrade issue |