~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/expected/create_view.out

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--
 
2
-- CREATE_VIEW
 
3
-- Virtual class definitions
 
4
--      (this also tests the query rewrite system)
 
5
--
 
6
CREATE VIEW street AS
 
7
   SELECT r.name, r.thepath, c.cname AS cname 
 
8
   FROM ONLY road r, real_city c
 
9
   WHERE c.outline ## r.thepath;
 
10
CREATE VIEW iexit AS
 
11
   SELECT ih.name, ih.thepath, 
 
12
        interpt_pp(ih.thepath, r.thepath) AS exit
 
13
   FROM ihighway ih, ramp r
 
14
   WHERE ih.thepath ## r.thepath;
 
15
CREATE VIEW toyemp AS
 
16
   SELECT name, age, location, 12*salary AS annualsal
 
17
   FROM emp;
 
18
-- Test comments
 
19
COMMENT ON VIEW noview IS 'no view';
 
20
ERROR:  relation "noview" does not exist
 
21
COMMENT ON VIEW toyemp IS 'is a view';
 
22
COMMENT ON VIEW toyemp IS NULL;
 
23
--
 
24
-- CREATE OR REPLACE VIEW
 
25
--
 
26
CREATE TABLE viewtest_tbl (a int, b int);
 
27
COPY viewtest_tbl FROM stdin;
 
28
CREATE OR REPLACE VIEW viewtest AS
 
29
        SELECT * FROM viewtest_tbl;
 
30
CREATE OR REPLACE VIEW viewtest AS
 
31
        SELECT * FROM viewtest_tbl WHERE a > 10;
 
32
SELECT * FROM viewtest;
 
33
 a  | b  
 
34
----+----
 
35
 15 | 20
 
36
 20 | 25
 
37
(2 rows)
 
38
 
 
39
CREATE OR REPLACE VIEW viewtest AS
 
40
        SELECT a, b FROM viewtest_tbl WHERE a > 5 ORDER BY b DESC;
 
41
SELECT * FROM viewtest;
 
42
 a  | b  
 
43
----+----
 
44
 20 | 25
 
45
 15 | 20
 
46
 10 | 15
 
47
(3 rows)
 
48
 
 
49
-- should fail
 
50
CREATE OR REPLACE VIEW viewtest AS
 
51
        SELECT a FROM viewtest_tbl WHERE a <> 20;
 
52
ERROR:  cannot change number of columns in view
 
53
-- should fail
 
54
CREATE OR REPLACE VIEW viewtest AS
 
55
        SELECT 1, * FROM viewtest_tbl;
 
56
ERROR:  cannot change number of columns in view
 
57
-- should fail
 
58
CREATE OR REPLACE VIEW viewtest AS
 
59
        SELECT a, b::numeric FROM viewtest_tbl;
 
60
ERROR:  cannot change data type of view column "b"
 
61
DROP VIEW viewtest;
 
62
DROP TABLE viewtest_tbl;