Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5RPc-0008Ff-ER for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Feb 2013 01:45:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U5RPb-0006AD-RO for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Feb 2013 01:45:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5ItV-0004he-0Y for pgsql-bugs@postgresql.org; Tue, 12 Feb 2013 16:39:45 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5ItT-0000YJ-PZ for pgsql-bugs@postgresql.org; Tue, 12 Feb 2013 16:39:44 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5ItS-0003SC-VM for pgsql-bugs@postgresql.org; Tue, 12 Feb 2013 16:39:43 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1U5ItS-0003HY-NQ for pgsql-bugs@postgresql.org; Tue, 12 Feb 2013 16:39:42 +0000 Date: Tue, 12 Feb 2013 16:39:42 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #7869: Expressions in a view for rows that are not part of the view result set are still evaluated To: pgsql-bugs@postgresql.org From: bernardjech@yahoo.com X-Pg-Spam-Score: 0.6 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 7869 Logged by: Bernard Jech Email address: bernardjech@yahoo.com PostgreSQL version: 9.2.3 Operating system: Mac OS X 10.6.8 Description:=20=20=20=20=20=20=20=20 -- Create the tables: CREATE TABLE netblock ( id INTEGER, ip_address inet NOT NULL ); CREATE TABLE ipv4 ( netblock_id integer ); -- Insert data: INSERT INTO netblock VALUES(1, '2605:ee00::/32'); INSERT INTO netblock VALUES(2, '68.67.181.7/26'); INSERT INTO ipv4 VALUES(2); -- Create the view: CREATE OR REPLACE VIEW subnet AS SELECT ipv4.netblock_id AS id, set_masklen(n.ip_address, 32) - inet '0.0.0.0' AS cidr_address FROM ipv4 JOIN netblock n ON ipv4.netblock_id =3D n.id; If you select all rows from the view subnet, you get the expected result: pokus=3D> select * from subnet; id | cidr_address=20 ----+-------------- 2 | 1145287943 (1 row) The surprising part comes when you add a WHERE clause to the SELECT statement to select only this one row: pokus=3D> select * from subnet where cidr_address =3D 1145287943; ERROR: cannot subtract inet values of different sizes This is apparently caused by the IPv6 entry in the netblock table but this row should be excluded by the inner JOIN in the VIEW definition. --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs