Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VvAvI-00082k-GN for pgsql-bugs@arkaria.postgresql.org; Mon, 23 Dec 2013 19:12:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VvAvH-0001uF-On for pgsql-bugs@arkaria.postgresql.org; Mon, 23 Dec 2013 19:12:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VvATj-0004uK-0m for pgsql-bugs@postgresql.org; Mon, 23 Dec 2013 18:43:47 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VvATg-00086w-C5 for pgsql-bugs@postgresql.org; Mon, 23 Dec 2013 18:43:46 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by mahout.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VvATe-0003xU-Nm for pgsql-bugs@postgresql.org; Mon, 23 Dec 2013 18:43:43 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.80) (envelope-from ) id 1VvATZ-0004mC-B4 for pgsql-bugs@postgresql.org; Mon, 23 Dec 2013 18:43:37 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: BUG #8698: cast and view To: pgsql-bugs@postgresql.org From: balazs@obiserver.hu Message-Id: Date: Mon, 23 Dec 2013 18:43:37 +0000 X-Pg-Spam-Score: -2.5 (--) 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: 8698 Logged by: Balazs Peter Odor Email address: balazs@obiserver.hu PostgreSQL version: 9.3.2 Operating system: Debian Linux Description: CREATE SCHEMA test; CREATE TYPE test.customcompositetype AS ( x text, y text ); CREATE TABLE test.customtable ( compositetype test.customcompositetype ); INSERT INTO test.customtable (compositetype) VALUES ('(x1,y1)'), ('(x2,y2)'); SELECT * FROM test.customtable; compositetype --------------- (x1,y1) (x2,y2) (2 rows) CREATE VIEW test.customview as SELECT compositetype, compositetype::text AS compositetype_text FROM test.customtable; SELECT * FROM test.customview; compositetype | compositetype_text ---------------+-------------------- (x1,y1) | (x1,y1) (x2,y2) | (x2,y2) (2 rows) Ok, lets create a cast to customcompositetype to text: CREATE FUNCTION test.customcompositetype_text(test.customcompositetype) RETURNS text AS $$SELECT ($1).x || ' ' || ($1).y;$$ IMMUTABLE LANGUAGE SQL ; CREATE CAST (test.customcompositetype AS text) WITH FUNCTION test.customcompositetype_text(test.customcompositetype); SELECT * FROM test.customview; compositetype | compositetype_text ---------------+-------------------- (x1,y1) | (x1,y1) (x2,y2) | (x2,y2) (2 rows) What?? :( Refresh the view: CREATE OR REPLACE VIEW test.customview as SELECT compositetype, compositetype::text AS compositetype_text FROM test.customtable; SELECT * FROM test.customview; compositetype | compositetype_text ---------------+-------------------- (x1,y1) | x1 y1 (x2,y2) | x2 y2 (2 rows) Whats wrong? Why need recreate the view?? -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs