aboutsummaryrefslogtreecommitdiff
path: root/src/test/regress/expected/create_view.out
blob: d37c88234a279cd48286bbaadb7b6f42104a51ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
--
-- CREATE_VIEW
-- Virtual class definitions
--	(this also tests the query rewrite system)
--
CREATE VIEW street AS
   SELECT r.name, r.thepath, c.cname AS cname
   FROM ONLY road r, real_city c
   WHERE c.outline ## r.thepath;
CREATE VIEW iexit AS
   SELECT ih.name, ih.thepath,
	interpt_pp(ih.thepath, r.thepath) AS exit
   FROM ihighway ih, ramp r
   WHERE ih.thepath ## r.thepath;
CREATE VIEW toyemp AS
   SELECT name, age, location, 12*salary AS annualsal
   FROM emp;
-- Test comments
COMMENT ON VIEW noview IS 'no view';
ERROR:  relation "noview" does not exist
COMMENT ON VIEW toyemp IS 'is a view';
COMMENT ON VIEW toyemp IS NULL;
--
-- CREATE OR REPLACE VIEW
--
CREATE TABLE viewtest_tbl (a int, b int);
COPY viewtest_tbl FROM stdin;
CREATE OR REPLACE VIEW viewtest AS
	SELECT * FROM viewtest_tbl;
CREATE OR REPLACE VIEW viewtest AS
	SELECT * FROM viewtest_tbl WHERE a > 10;
SELECT * FROM viewtest;
 a  | b  
----+----
 15 | 20
 20 | 25
(2 rows)

CREATE OR REPLACE VIEW viewtest AS
	SELECT a, b FROM viewtest_tbl WHERE a > 5 ORDER BY b DESC;
SELECT * FROM viewtest;
 a  | b  
----+----
 20 | 25
 15 | 20
 10 | 15
(3 rows)

-- should fail
CREATE OR REPLACE VIEW viewtest AS
	SELECT a FROM viewtest_tbl WHERE a <> 20;
ERROR:  cannot drop columns from view
-- should fail
CREATE OR REPLACE VIEW viewtest AS
	SELECT 1, * FROM viewtest_tbl;
ERROR:  cannot change name of view column "a" to "?column?"
-- should fail
CREATE OR REPLACE VIEW viewtest AS
	SELECT a, b::numeric FROM viewtest_tbl;
ERROR:  cannot change data type of view column "b" from integer to numeric
-- should work
CREATE OR REPLACE VIEW viewtest AS
	SELECT a, b, 0 AS c FROM viewtest_tbl;
DROP VIEW viewtest;
DROP TABLE viewtest_tbl;
-- tests for temporary views
CREATE SCHEMA temp_view_test
    CREATE TABLE base_table (a int, id int)
    CREATE TABLE base_table2 (a int, id int);
SET search_path TO temp_view_test, public;
CREATE TEMPORARY TABLE temp_table (a int, id int);
-- should be created in temp_view_test schema
CREATE VIEW v1 AS SELECT * FROM base_table;
-- should be created in temp object schema
CREATE VIEW v1_temp AS SELECT * FROM temp_table;
NOTICE:  view "v1_temp" will be a temporary view
-- should be created in temp object schema
CREATE TEMP VIEW v2_temp AS SELECT * FROM base_table;
-- should be created in temp_views schema
CREATE VIEW temp_view_test.v2 AS SELECT * FROM base_table;
-- should fail
CREATE VIEW temp_view_test.v3_temp AS SELECT * FROM temp_table;
NOTICE:  view "v3_temp" will be a temporary view
ERROR:  cannot create temporary relation in non-temporary schema
-- should fail
CREATE SCHEMA test_schema
    CREATE TEMP VIEW testview AS SELECT 1;
ERROR:  cannot create temporary relation in non-temporary schema
-- joins: if any of the join relations are temporary, the view
-- should also be temporary
-- should be non-temp
CREATE VIEW v3 AS
    SELECT t1.a AS t1_a, t2.a AS t2_a
    FROM base_table t1, base_table2 t2
    WHERE t1.id = t2.id;
-- should be temp (one join rel is temp)
CREATE VIEW v4_temp AS
    SELECT t1.a AS t1_a, t2.a AS t2_a
    FROM base_table t1, temp_table t2
    WHERE t1.id = t2.id;
NOTICE:  view "v4_temp" will be a temporary view
-- should be temp
CREATE VIEW v5_temp AS
    SELECT t1.a AS t1_a, t2.a AS t2_a, t3.a AS t3_a
    FROM base_table t1, base_table2 t2, temp_table t3
    WHERE t1.id = t2.id and t2.id = t3.id;
NOTICE:  view "v5_temp" will be a temporary view
-- subqueries
CREATE VIEW v4 AS SELECT * FROM base_table WHERE id IN (SELECT id FROM base_table2);
CREATE VIEW v5 AS SELECT t1.id, t2.a FROM base_table t1, (SELECT * FROM base_table2) t2;
CREATE VIEW v6 AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM base_table2);
CREATE VIEW v7 AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM base_table2);
CREATE VIEW v8 AS SELECT * FROM base_table WHERE EXISTS (SELECT 1);
CREATE VIEW v6_temp AS SELECT * FROM base_table WHERE id IN (SELECT id FROM temp_table);
NOTICE:  view "v6_temp" will be a temporary view
CREATE VIEW v7_temp AS SELECT t1.id, t2.a FROM base_table t1, (SELECT * FROM temp_table) t2;
NOTICE:  view "v7_temp" will be a temporary view
CREATE VIEW v8_temp AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM temp_table);
NOTICE:  view "v8_temp" will be a temporary view
CREATE VIEW v9_temp AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM temp_table);
NOTICE:  view "v9_temp" will be a temporary view
-- a view should also be temporary if it references a temporary view
CREATE VIEW v10_temp AS SELECT * FROM v7_temp;
NOTICE:  view "v10_temp" will be a temporary view
CREATE VIEW v11_temp AS SELECT t1.id, t2.a FROM base_table t1, v10_temp t2;
NOTICE:  view "v11_temp" will be a temporary view
CREATE VIEW v12_temp AS SELECT true FROM v11_temp;
NOTICE:  view "v12_temp" will be a temporary view
-- a view should also be temporary if it references a temporary sequence
CREATE SEQUENCE seq1;
CREATE TEMPORARY SEQUENCE seq1_temp;
CREATE VIEW v9 AS SELECT seq1.is_called FROM seq1;
CREATE VIEW v13_temp AS SELECT seq1_temp.is_called FROM seq1_temp;
NOTICE:  view "v13_temp" will be a temporary view
SELECT relname FROM pg_class
    WHERE relname LIKE 'v_'
    AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'temp_view_test')
    ORDER BY relname;
 relname 
---------
 v1
 v2
 v3
 v4
 v5
 v6
 v7
 v8
 v9
(9 rows)

SELECT relname FROM pg_class
    WHERE relname LIKE 'v%'
    AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg_temp%')
    ORDER BY relname;
 relname  
----------
 v10_temp
 v11_temp
 v12_temp
 v13_temp
 v1_temp
 v2_temp
 v4_temp
 v5_temp
 v6_temp
 v7_temp
 v8_temp
 v9_temp
(12 rows)

CREATE SCHEMA testviewschm2;
SET search_path TO testviewschm2, public;
CREATE TABLE t1 (num int, name text);
CREATE TABLE t2 (num2 int, value text);
CREATE TEMP TABLE tt (num2 int, value text);
CREATE VIEW nontemp1 AS SELECT * FROM t1 CROSS JOIN t2;
CREATE VIEW temporal1 AS SELECT * FROM t1 CROSS JOIN tt;
NOTICE:  view "temporal1" will be a temporary view
CREATE VIEW nontemp2 AS SELECT * FROM t1 INNER JOIN t2 ON t1.num = t2.num2;
CREATE VIEW temporal2 AS SELECT * FROM t1 INNER JOIN tt ON t1.num = tt.num2;
NOTICE:  view "temporal2" will be a temporary view
CREATE VIEW nontemp3 AS SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num2;
CREATE VIEW temporal3 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2;
NOTICE:  view "temporal3" will be a temporary view
CREATE VIEW nontemp4 AS SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num2 AND t2.value = 'xxx';
CREATE VIEW temporal4 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2 AND tt.value = 'xxx';
NOTICE:  view "temporal4" will be a temporary view
SELECT relname FROM pg_class
    WHERE relname LIKE 'nontemp%'
    AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'testviewschm2')
    ORDER BY relname;
 relname  
----------
 nontemp1
 nontemp2
 nontemp3
 nontemp4
(4 rows)

SELECT relname FROM pg_class
    WHERE relname LIKE 'temporal%'
    AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg_temp%')
    ORDER BY relname;
  relname  
-----------
 temporal1
 temporal2
 temporal3
 temporal4
(4 rows)

CREATE TABLE tbl1 ( a int, b int);
CREATE TABLE tbl2 (c int, d int);
CREATE TABLE tbl3 (e int, f int);
CREATE TABLE tbl4 (g int, h int);
CREATE TEMP TABLE tmptbl (i int, j int);
--Should be in testviewschm2
CREATE   VIEW  pubview AS SELECT * FROM tbl1 WHERE tbl1.a
BETWEEN (SELECT d FROM tbl2 WHERE c = 1) AND (SELECT e FROM tbl3 WHERE f = 2)
AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f);
SELECT count(*) FROM pg_class where relname = 'pubview'
AND relnamespace IN (SELECT OID FROM pg_namespace WHERE nspname = 'testviewschm2');
 count 
-------
     1
(1 row)

--Should be in temp object schema
CREATE   VIEW  mytempview AS SELECT * FROM tbl1 WHERE tbl1.a
BETWEEN (SELECT d FROM tbl2 WHERE c = 1) AND (SELECT e FROM tbl3 WHERE f = 2)
AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f)
AND NOT EXISTS (SELECT g FROM tbl4 LEFT JOIN tmptbl ON tbl4.h = tmptbl.j);
NOTICE:  view "mytempview" will be a temporary view
SELECT count(*) FROM pg_class where relname LIKE 'mytempview'
And relnamespace IN (SELECT OID FROM pg_namespace WHERE nspname LIKE 'pg_temp%');
 count 
-------
     1
(1 row)

--
-- CREATE VIEW and WITH(...) clause
--
CREATE VIEW mysecview1
       AS SELECT * FROM tbl1 WHERE a = 0;
CREATE VIEW mysecview2 WITH (security_barrier=true)
       AS SELECT * FROM tbl1 WHERE a > 0;
CREATE VIEW mysecview3 WITH (security_barrier=false)
       AS SELECT * FROM tbl1 WHERE a < 0;
CREATE VIEW mysecview4 WITH (security_barrier)
       AS SELECT * FROM tbl1 WHERE a <> 0;
CREATE VIEW mysecview5 WITH (security_barrier=100)	-- Error
       AS SELECT * FROM tbl1 WHERE a > 100;
ERROR:  invalid value for boolean option "security_barrier": 100
CREATE VIEW mysecview6 WITH (invalid_option)		-- Error
       AS SELECT * FROM tbl1 WHERE a < 100;
ERROR:  unrecognized parameter "invalid_option"
SELECT relname, relkind, reloptions FROM pg_class
       WHERE oid in ('mysecview1'::regclass, 'mysecview2'::regclass,
                     'mysecview3'::regclass, 'mysecview4'::regclass)
       ORDER BY relname;
  relname   | relkind |        reloptions        
------------+---------+--------------------------
 mysecview1 | v       | 
 mysecview2 | v       | {security_barrier=true}
 mysecview3 | v       | {security_barrier=false}
 mysecview4 | v       | {security_barrier=true}
(4 rows)

CREATE OR REPLACE VIEW mysecview1
       AS SELECT * FROM tbl1 WHERE a = 256;
CREATE OR REPLACE VIEW mysecview2
       AS SELECT * FROM tbl1 WHERE a > 256;
CREATE OR REPLACE VIEW mysecview3 WITH (security_barrier=true)
       AS SELECT * FROM tbl1 WHERE a < 256;
CREATE OR REPLACE VIEW mysecview4 WITH (security_barrier=false)
       AS SELECT * FROM tbl1 WHERE a <> 256;
SELECT relname, relkind, reloptions FROM pg_class
       WHERE oid in ('mysecview1'::regclass, 'mysecview2'::regclass,
                     'mysecview3'::regclass, 'mysecview4'::regclass)
       ORDER BY relname;
  relname   | relkind |        reloptions        
------------+---------+--------------------------
 mysecview1 | v       | 
 mysecview2 | v       | 
 mysecview3 | v       | {security_barrier=true}
 mysecview4 | v       | {security_barrier=false}
(4 rows)

-- Test view decompilation in the face of renaming conflicts
CREATE TABLE tt1 (f1 int, f2 int, f3 text);
CREATE TABLE tx1 (x1 int, x2 int, x3 text);
CREATE TABLE temp_view_test.tt1 (y1 int, f2 int, f3 text);
CREATE VIEW aliased_view_1 AS
  select * from tt1
    where exists (select 1 from tx1 where tt1.f1 = tx1.x1);
CREATE VIEW aliased_view_2 AS
  select * from tt1 a1
    where exists (select 1 from tx1 where a1.f1 = tx1.x1);
CREATE VIEW aliased_view_3 AS
  select * from tt1
    where exists (select 1 from tx1 a2 where tt1.f1 = a2.x1);
CREATE VIEW aliased_view_4 AS
  select * from temp_view_test.tt1
    where exists (select 1 from tt1 where temp_view_test.tt1.y1 = tt1.f1);
\d+ aliased_view_1
          View "testviewschm2.aliased_view_1"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tt1.f1, tt1.f2, tt1.f3
   FROM tt1
  WHERE (EXISTS ( SELECT 1
           FROM tx1
          WHERE tt1.f1 = tx1.x1));

\d+ aliased_view_2
          View "testviewschm2.aliased_view_2"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT a1.f1, a1.f2, a1.f3
   FROM tt1 a1
  WHERE (EXISTS ( SELECT 1
           FROM tx1
          WHERE a1.f1 = tx1.x1));

\d+ aliased_view_3
          View "testviewschm2.aliased_view_3"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tt1.f1, tt1.f2, tt1.f3
   FROM tt1
  WHERE (EXISTS ( SELECT 1
           FROM tx1 a2
          WHERE tt1.f1 = a2.x1));

\d+ aliased_view_4
          View "testviewschm2.aliased_view_4"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 y1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tt1.y1, tt1.f2, tt1.f3
   FROM temp_view_test.tt1
  WHERE (EXISTS ( SELECT 1
           FROM tt1 tt1_1
          WHERE tt1.y1 = tt1_1.f1));

ALTER TABLE tx1 RENAME TO a1;
\d+ aliased_view_1
          View "testviewschm2.aliased_view_1"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tt1.f1, tt1.f2, tt1.f3
   FROM tt1
  WHERE (EXISTS ( SELECT 1
           FROM a1
          WHERE tt1.f1 = a1.x1));

\d+ aliased_view_2
          View "testviewschm2.aliased_view_2"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT a1.f1, a1.f2, a1.f3
   FROM tt1 a1
  WHERE (EXISTS ( SELECT 1
           FROM a1 a1_1
          WHERE a1.f1 = a1_1.x1));

\d+ aliased_view_3
          View "testviewschm2.aliased_view_3"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tt1.f1, tt1.f2, tt1.f3
   FROM tt1
  WHERE (EXISTS ( SELECT 1
           FROM a1 a2
          WHERE tt1.f1 = a2.x1));

\d+ aliased_view_4
          View "testviewschm2.aliased_view_4"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 y1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tt1.y1, tt1.f2, tt1.f3
   FROM temp_view_test.tt1
  WHERE (EXISTS ( SELECT 1
           FROM tt1 tt1_1
          WHERE tt1.y1 = tt1_1.f1));

ALTER TABLE tt1 RENAME TO a2;
\d+ aliased_view_1
          View "testviewschm2.aliased_view_1"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT a2.f1, a2.f2, a2.f3
   FROM a2
  WHERE (EXISTS ( SELECT 1
           FROM a1
          WHERE a2.f1 = a1.x1));

\d+ aliased_view_2
          View "testviewschm2.aliased_view_2"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT a1.f1, a1.f2, a1.f3
   FROM a2 a1
  WHERE (EXISTS ( SELECT 1
           FROM a1 a1_1
          WHERE a1.f1 = a1_1.x1));

\d+ aliased_view_3
          View "testviewschm2.aliased_view_3"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT a2.f1, a2.f2, a2.f3
   FROM a2
  WHERE (EXISTS ( SELECT 1
           FROM a1 a2_1
          WHERE a2.f1 = a2_1.x1));

\d+ aliased_view_4
          View "testviewschm2.aliased_view_4"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 y1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tt1.y1, tt1.f2, tt1.f3
   FROM temp_view_test.tt1
  WHERE (EXISTS ( SELECT 1
           FROM a2
          WHERE tt1.y1 = a2.f1));

ALTER TABLE a1 RENAME TO tt1;
\d+ aliased_view_1
          View "testviewschm2.aliased_view_1"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT a2.f1, a2.f2, a2.f3
   FROM a2
  WHERE (EXISTS ( SELECT 1
           FROM tt1
          WHERE a2.f1 = tt1.x1));

\d+ aliased_view_2
          View "testviewschm2.aliased_view_2"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT a1.f1, a1.f2, a1.f3
   FROM a2 a1
  WHERE (EXISTS ( SELECT 1
           FROM tt1
          WHERE a1.f1 = tt1.x1));

\d+ aliased_view_3
          View "testviewschm2.aliased_view_3"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT a2.f1, a2.f2, a2.f3
   FROM a2
  WHERE (EXISTS ( SELECT 1
           FROM tt1 a2_1
          WHERE a2.f1 = a2_1.x1));

\d+ aliased_view_4
          View "testviewschm2.aliased_view_4"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 y1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tt1.y1, tt1.f2, tt1.f3
   FROM temp_view_test.tt1
  WHERE (EXISTS ( SELECT 1
           FROM a2
          WHERE tt1.y1 = a2.f1));

ALTER TABLE a2 RENAME TO tx1;
ALTER TABLE tx1 SET SCHEMA temp_view_test;
\d+ aliased_view_1
          View "testviewschm2.aliased_view_1"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tx1.f1, tx1.f2, tx1.f3
   FROM temp_view_test.tx1
  WHERE (EXISTS ( SELECT 1
           FROM tt1
          WHERE tx1.f1 = tt1.x1));

\d+ aliased_view_2
          View "testviewschm2.aliased_view_2"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT a1.f1, a1.f2, a1.f3
   FROM temp_view_test.tx1 a1
  WHERE (EXISTS ( SELECT 1
           FROM tt1
          WHERE a1.f1 = tt1.x1));

\d+ aliased_view_3
          View "testviewschm2.aliased_view_3"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tx1.f1, tx1.f2, tx1.f3
   FROM temp_view_test.tx1
  WHERE (EXISTS ( SELECT 1
           FROM tt1 a2
          WHERE tx1.f1 = a2.x1));

\d+ aliased_view_4
          View "testviewschm2.aliased_view_4"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 y1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tt1.y1, tt1.f2, tt1.f3
   FROM temp_view_test.tt1
  WHERE (EXISTS ( SELECT 1
           FROM temp_view_test.tx1
          WHERE tt1.y1 = tx1.f1));

ALTER TABLE temp_view_test.tt1 RENAME TO tmp1;
ALTER TABLE temp_view_test.tmp1 SET SCHEMA testviewschm2;
ALTER TABLE tmp1 RENAME TO tx1;
\d+ aliased_view_1
          View "testviewschm2.aliased_view_1"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tx1.f1, tx1.f2, tx1.f3
   FROM temp_view_test.tx1
  WHERE (EXISTS ( SELECT 1
           FROM tt1
          WHERE tx1.f1 = tt1.x1));

\d+ aliased_view_2
          View "testviewschm2.aliased_view_2"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT a1.f1, a1.f2, a1.f3
   FROM temp_view_test.tx1 a1
  WHERE (EXISTS ( SELECT 1
           FROM tt1
          WHERE a1.f1 = tt1.x1));

\d+ aliased_view_3
          View "testviewschm2.aliased_view_3"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 f1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tx1.f1, tx1.f2, tx1.f3
   FROM temp_view_test.tx1
  WHERE (EXISTS ( SELECT 1
           FROM tt1 a2
          WHERE tx1.f1 = a2.x1));

\d+ aliased_view_4
          View "testviewschm2.aliased_view_4"
 Column |  Type   | Modifiers | Storage  | Description 
--------+---------+-----------+----------+-------------
 y1     | integer |           | plain    | 
 f2     | integer |           | plain    | 
 f3     | text    |           | extended | 
View definition:
 SELECT tx1.y1, tx1.f2, tx1.f3
   FROM tx1
  WHERE (EXISTS ( SELECT 1
           FROM temp_view_test.tx1 tx1_1
          WHERE tx1.y1 = tx1_1.f1));

DROP SCHEMA temp_view_test CASCADE;
NOTICE:  drop cascades to 27 other objects
DETAIL:  drop cascades to table temp_view_test.base_table
drop cascades to view v7_temp
drop cascades to view v10_temp
drop cascades to view v11_temp
drop cascades to view v12_temp
drop cascades to view v2_temp
drop cascades to view v4_temp
drop cascades to view v6_temp
drop cascades to view v8_temp
drop cascades to view v9_temp
drop cascades to table temp_view_test.base_table2
drop cascades to view v5_temp
drop cascades to view temp_view_test.v1
drop cascades to view temp_view_test.v2
drop cascades to view temp_view_test.v3
drop cascades to view temp_view_test.v4
drop cascades to view temp_view_test.v5
drop cascades to view temp_view_test.v6
drop cascades to view temp_view_test.v7
drop cascades to view temp_view_test.v8
drop cascades to sequence temp_view_test.seq1
drop cascades to view temp_view_test.v9
drop cascades to table temp_view_test.tx1
drop cascades to view aliased_view_1
drop cascades to view aliased_view_2
drop cascades to view aliased_view_3
drop cascades to view aliased_view_4
DROP SCHEMA testviewschm2 CASCADE;
NOTICE:  drop cascades to 22 other objects
DETAIL:  drop cascades to table t1
drop cascades to view temporal1
drop cascades to view temporal2
drop cascades to view temporal3
drop cascades to view temporal4
drop cascades to table t2
drop cascades to view nontemp1
drop cascades to view nontemp2
drop cascades to view nontemp3
drop cascades to view nontemp4
drop cascades to table tbl1
drop cascades to table tbl2
drop cascades to table tbl3
drop cascades to table tbl4
drop cascades to view mytempview
drop cascades to view pubview
drop cascades to view mysecview1
drop cascades to view mysecview2
drop cascades to view mysecview3
drop cascades to view mysecview4
drop cascades to table tt1
drop cascades to table tx1
SET search_path to public;