~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/expected/truncate.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
-- Test basic TRUNCATE functionality.
 
2
CREATE TABLE truncate_a (col1 integer primary key);
 
3
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "truncate_a_pkey" for table "truncate_a"
 
4
INSERT INTO truncate_a VALUES (1);
 
5
INSERT INTO truncate_a VALUES (2);
 
6
SELECT * FROM truncate_a;
 
7
 col1 
 
8
------
 
9
    1
 
10
    2
 
11
(2 rows)
 
12
 
 
13
-- Roll truncate back
 
14
BEGIN;
 
15
TRUNCATE truncate_a;
 
16
ROLLBACK;
 
17
SELECT * FROM truncate_a;
 
18
 col1 
 
19
------
 
20
    1
 
21
    2
 
22
(2 rows)
 
23
 
 
24
-- Commit the truncate this time
 
25
BEGIN;
 
26
TRUNCATE truncate_a;
 
27
COMMIT;
 
28
SELECT * FROM truncate_a;
 
29
 col1 
 
30
------
 
31
(0 rows)
 
32
 
 
33
-- Test foreign constraint check
 
34
CREATE TABLE truncate_b(col1 integer references truncate_a);
 
35
INSERT INTO truncate_a VALUES (1);
 
36
SELECT * FROM truncate_a;
 
37
 col1 
 
38
------
 
39
    1
 
40
(1 row)
 
41
 
 
42
TRUNCATE truncate_a;
 
43
ERROR:  cannot truncate a table referenced in a foreign key constraint
 
44
DETAIL:  Table "truncate_b" references "truncate_a" via foreign key constraint "truncate_b_col1_fkey".
 
45
SELECT * FROM truncate_a;
 
46
 col1 
 
47
------
 
48
    1
 
49
(1 row)
 
50
 
 
51
DROP TABLE truncate_b;
 
52
DROP TABLE truncate_a;