pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #8698: cast and view
3+ messages / 3 participants
[nested] [flat]

* BUG #8698: cast and view
@ 2013-12-23 18:43  balazs@obiserver.hu
  0 siblings, 1 reply; 3+ messages in thread

From: balazs@obiserver.hu @ 2013-12-23 18:43 UTC (permalink / raw)
  To: pgsql-bugs

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #8698: cast and view
@ 2013-12-23 21:40  Tom Lane <tgl@sss.pgh.pa.us>
  parent: balazs@obiserver.hu
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2013-12-23 21:40 UTC (permalink / raw)
  To: balazs@obiserver.hu; +Cc: pgsql-bugs

balazs@obiserver.hu writes:
> Whats wrong? Why need recreate the view??

Because it contains a call to the original cast function.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #8698: cast and view
@ 2014-01-05 13:59  Ódor Balázs Péter <balazs@obiserver.hu>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Ódor Balázs Péter @ 2014-01-05 13:59 UTC (permalink / raw)
  To: pgsql-bugs

Hi,

Please create a full pg_dump before recreate the view, drop the 
database, and recreate it from the full dump.

This procedure (dump and restore) isn't represent the original state!

Regards,
Balazs



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2014-01-05 13:59 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-12-23 18:43 BUG #8698: cast and view balazs@obiserver.hu
2013-12-23 21:40 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-01-05 13:59   ` Ódor Balázs Péter <balazs@obiserver.hu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox