cat > script <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
create t set a, b, c, d;
select from t;
create view g as select a, b from t group by a, b;
select from g;
select from g where a = 1;
select from g group by a;
select from g having sum (a) = 1;
select from g having a = 1;
create view g1 as select from g where a = 1;
create view g2 as select from g group by a;
create view g3 as select from g having sum (a) = 1;
create view g4 as select from g having a = 1;
create view g5 (a,b) as select g.a, t.a from g, t;
create view g6 (a,b) as select t.a, g.a from t, g;
select from g, t;
select from t, g;
create view vg as select from g;
select from vg, t;
select from t, vg;
create view g7(a,b) as select vg.a, t.a from vg, t;
create view g8(a,b) as select t.a, vg.a from t, vg;
select from t group by a having b = 2;
select from t group by a, b having b = 2;
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 script
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
* create t set a, b, c, d;
* select from t;
     a       b       c       d

* create view g as select a, b from t group by a, b;
* select from g;
     a       b

* select from g where a = 1;
     a       b

* select from g group by a;
     a       b

* select from g having sum (a) = 1;

*** Error: invalid select list with having clause
* select from g having a = 1;

*** Error: attribute 'a' not allowed in having clause
* create view g1 as select from g where a = 1;
* create view g2 as select from g group by a;
* create view g3 as select from g having sum (a) = 1;

*** Error: invalid select list with having clause
* create view g4 as select from g having a = 1;

*** Error: attribute 'a' not allowed in having clause
* create view g5 (a,b) as select g.a, t.a from g, t;
* create view g6 (a,b) as select t.a, g.a from t, g;
* select from g, t;
     a       b       a       b       c       d

* select from t, g;
     a       b       c       d       a       b

* create view vg as select from g;
* select from vg, t;
     a       b       a       b       c       d

* select from t, vg;
     a       b       c       d       a       b

* create view g7(a,b) as select vg.a, t.a from vg, t;
* create view g8(a,b) as select t.a, vg.a from t, vg;
* select from t group by a having b = 2;

*** Error: attribute 'b' not allowed in having clause
* select from t group by a, b having b = 2;

*** Error: invalid select list with having clause
* 
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Test for invalid operation on grouped view.
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
cat > stdout.jp_euc <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
* create t set a, b, c, d;
* select from t;
     a       b       c       d

* create view g as select a, b from t group by a, b;
* select from g;
     a       b

* select from g where a = 1;
     a       b

* select from g group by a;
     a       b

* select from g having sum (a) = 1;

*** Error: ̵ HAVING ʸդ SELECT ꥹȤǤ
* select from g having a = 1;

*** Error: HAVING ʸǥȥӥ塼 'a' λϤǤޤ
* create view g1 as select from g where a = 1;
* create view g2 as select from g group by a;
* create view g3 as select from g having sum (a) = 1;

*** Error: ̵ HAVING ʸդ SELECT ꥹȤǤ
* create view g4 as select from g having a = 1;

*** Error: HAVING ʸǥȥӥ塼 'a' λϤǤޤ
* create view g5 (a,b) as select g.a, t.a from g, t;
* create view g6 (a,b) as select t.a, g.a from t, g;
* select from g, t;
     a       b       a       b       c       d

* select from t, g;
     a       b       c       d       a       b

* create view vg as select from g;
* select from vg, t;
     a       b       a       b       c       d

* select from t, vg;
     a       b       c       d       a       b

* create view g7(a,b) as select vg.a, t.a from vg, t;
* create view g8(a,b) as select t.a, vg.a from t, vg;
* select from t group by a having b = 2;

*** Error: HAVING ʸǥȥӥ塼 'b' λϤǤޤ
* select from t group by a, b having b = 2;

*** Error: ̵ HAVING ʸդ SELECT ꥹȤǤ
* 
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout.jp_euc
