~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/expected/sequence.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
--- test creation of SERIAL column
 
3
---
 
4
 
 
5
CREATE TABLE serialTest (f1 text, f2 serial);
 
6
NOTICE:  CREATE TABLE will create implicit sequence "serialtest_f2_seq" for serial column "serialtest.f2"
 
7
 
 
8
INSERT INTO serialTest VALUES ('foo');
 
9
INSERT INTO serialTest VALUES ('bar');
 
10
INSERT INTO serialTest VALUES ('force', 100);
 
11
INSERT INTO serialTest VALUES ('wrong', NULL);
 
12
ERROR:  null value in column "f2" violates not-null constraint
 
13
 
 
14
SELECT * FROM serialTest;
 
15
  f1   | f2  
 
16
-------+-----
 
17
 foo   |   1
 
18
 bar   |   2
 
19
 force | 100
 
20
(3 rows)
 
21
 
 
22
 
 
23
CREATE SEQUENCE sequence_test;
 
24
 
 
25
BEGIN;
 
26
SELECT nextval('sequence_test');
 
27
 nextval 
 
28
---------
 
29
       1
 
30
(1 row)
 
31
 
 
32
DROP SEQUENCE sequence_test;
 
33
END;
 
34
-- renaming sequences
 
35
CREATE SEQUENCE foo_seq;
 
36
ALTER TABLE foo_seq RENAME TO foo_seq_new;
 
37
SELECT * FROM foo_seq_new;
 
38
 sequence_name | last_value | increment_by |      max_value      | min_value | cache_value | log_cnt | is_cycled | is_called 
 
39
---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
 
40
 foo_seq       |          1 |            1 | 9223372036854775807 |         1 |           1 |       1 | f         | f
 
41
(1 row)
 
42
 
 
43
DROP SEQUENCE foo_seq_new;
 
44
--
 
45
-- Alter sequence
 
46
--
 
47
CREATE SEQUENCE sequence_test2 START WITH 32;
 
48
SELECT nextval('sequence_test2');
 
49
 nextval 
 
50
---------
 
51
      32
 
52
(1 row)
 
53
 
 
54
ALTER SEQUENCE sequence_test2 RESTART WITH 16
 
55
         INCREMENT BY 4 MAXVALUE 22 MINVALUE 5 CYCLE;
 
56
SELECT nextval('sequence_test2');
 
57
 nextval 
 
58
---------
 
59
      16
 
60
(1 row)
 
61
 
 
62
SELECT nextval('sequence_test2');
 
63
 nextval 
 
64
---------
 
65
      20
 
66
(1 row)
 
67
 
 
68
SELECT nextval('sequence_test2');
 
69
 nextval 
 
70
---------
 
71
       5
 
72
(1 row)
 
73
 
 
74
-- Test comments
 
75
COMMENT ON SEQUENCE asdf IS 'won''t work';
 
76
ERROR:  relation "asdf" does not exist
 
77
COMMENT ON SEQUENCE sequence_test2 IS 'will work';
 
78
COMMENT ON SEQUENCE sequence_test2 IS NULL;