Thread: view column defaults not displayed
Hello, I am using ALTER VIEW x ALTER COLUMN y SET DEFAULT defaultclause, but the defaults do not seem to appear in the pgadmingenerated SQL for the view. Is this a deliberate omission? psql does display view column defaults: test=# CREATE VIEW test.trash AS SELECT 1 AS a; CREATE VIEW test=# ALTER VIEW test.trash ALTER COLUMN a SET DEFAULT 5; ALTER VIEW test=# \d+ test.trash View "test.trash"Column | Type | Modifiers | Storage | Description --------+---------+-----------+---------+-------------a | integer | default 5 | plain | View definition:SELECT 1 AS a; Cheers, M
Le 14/02/2011 21:51, A.M. a écrit : > [...] > I am using ALTER VIEW x ALTER COLUMN y SET DEFAULT defaultclause, but the defaults do not seem to appear in the pgadmingenerated SQL for the view. Is this a deliberate omission? psql does display view column defaults: > Mainly because it was forgotten. I checked, it's available since 8.4. Should be an easy patch (once someone found the time to work on it :) ). -- Guillaumehttp://www.postgresql.frhttp://dalibo.com
Le 14/02/2011 22:28, Guillaume Lelarge a écrit : > Le 14/02/2011 21:51, A.M. a écrit : >> [...] >> I am using ALTER VIEW x ALTER COLUMN y SET DEFAULT defaultclause, but the defaults do not seem to appear in the pgadmingenerated SQL for the view. Is this a deliberate omission? psql does display view column defaults: >> > > Mainly because it was forgotten. I checked, it's available since 8.4. > Should be an easy patch (once someone found the time to work on it :) ). > Seems I was totally wrong. pgAdmin supports default values for columns in views since quite some time (at least 1.12). It doesn't use the ALTER VIEW statement, but the ALTER TABLE one. I don't think we really need to change this right now. It works and that's good enough for me. Can you check your release and see if you have the ALTER TABLE statement? it should be after the ALTER TABLE that sets the owner. -- Guillaumehttp://www.postgresql.frhttp://dalibo.com
On Mar 6, 2011, at 9:29 AM, Guillaume Lelarge wrote: > Le 14/02/2011 22:28, Guillaume Lelarge a écrit : >> Le 14/02/2011 21:51, A.M. a écrit : >>> [...] >>> I am using ALTER VIEW x ALTER COLUMN y SET DEFAULT defaultclause, but the defaults do not seem to appear in the pgadmingenerated SQL for the view. Is this a deliberate omission? psql does display view column defaults: >>> >> >> Mainly because it was forgotten. I checked, it's available since 8.4. >> Should be an easy patch (once someone found the time to work on it :) ). >> > > Seems I was totally wrong. pgAdmin supports default values for columns > in views since quite some time (at least 1.12). It doesn't use the ALTER > VIEW statement, but the ALTER TABLE one. I don't think we really need to > change this right now. It works and that's good enough for me. > > Can you check your release and see if you have the ALTER TABLE > statement? it should be after the ALTER TABLE that sets the owner. I can confirm that is indeed the case- thanks for pointing that out. The column defaults appear between the ACLs and rules. Cheers, M