Thread

  1. views containing aggregates

    PostgreSQL Bugs List <pgsql-bugs@postgresql.org> — 2000-08-27T03:31:16Z

    NAGY Andras (nagya@inf.elte.hu) reports a bug with a severity of 2
    The lower the number the more severe it is.
    
    Short Description
    views containing aggregates
    
    Long Description
    Not sure, whether the `Views containing aggregates sometimes fail' and `Allow views of aggregate columns' entries from the TODO cover this, therefore the bug report.  An aggregate select from a view containing aggregates behaves differently as expected.  Even if the support for this is on TODO, until fixing this, postgres should print a warning or otherwise reject such use of views.
    
    Sample Code
    create table example (
       name  text
    );
    insert into example values('alpha');
    insert into example values('alpha');
    insert into example values('alpha');
    insert into example values('alpha');
    insert into example values('beta');
    insert into example values('beta');
    insert into example values('gamma');
    
    -- the following should always return the number
    -- of rows a simple `select * from relation' would return
    
    select count(*) from example;
     count 
    -------
         7
    (1 row)
    
    
    create view example_view as select name from example group by name;
    select * from example_view;
     name  
    -------
     alpha
     beta
     gamma
    (3 rows)
    
    -- however, it is not the case here
    
    select count(*) from example_view;
     count 
    -------
         4
         2
         1
    (3 rows)
    
    
    
    No file was uploaded with this report