Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
431ab0e8
Commit
431ab0e8
authored
Jun 21, 2011
by
Robert Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some regression tests for serial pseudotypes.
Josh Kupershmidt
parent
61307dcc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
162 additions
and
6 deletions
+162
-6
src/test/regress/expected/sequence.out
src/test/regress/expected/sequence.out
+103
-5
src/test/regress/sql/sequence.sql
src/test/regress/sql/sequence.sql
+59
-1
No files found.
src/test/regress/expected/sequence.out
View file @
431ab0e8
...
...
@@ -16,6 +16,84 @@ SELECT * FROM serialTest;
force | 100
(3
rows)
-- test smallserial / bigserial
CREATE TABLE serialTest2 (f1 text, f2 serial, f3 smallserial, f4 serial2,
f5 bigserial, f6 serial8);
NOTICE: CREATE TABLE will create implicit sequence "serialtest2_f2_seq" for serial column "serialtest2.f2"
NOTICE: CREATE TABLE will create implicit sequence "serialtest2_f3_seq" for serial column "serialtest2.f3"
NOTICE: CREATE TABLE will create implicit sequence "serialtest2_f4_seq" for serial column "serialtest2.f4"
NOTICE: CREATE TABLE will create implicit sequence "serialtest2_f5_seq" for serial column "serialtest2.f5"
NOTICE: CREATE TABLE will create implicit sequence "serialtest2_f6_seq" for serial column "serialtest2.f6"
INSERT INTO serialTest2 (f1)
VALUES ('test_defaults');
INSERT INTO serialTest2 (f1, f2, f3, f4, f5, f6)
VALUES ('test_max_vals', 2147483647, 32767, 32767, 9223372036854775807,
9223372036854775807),
('test_min_vals', -2147483648, -32768, -32768, -9223372036854775808,
-9223372036854775808);
-- All these INSERTs should fail:
INSERT INTO serialTest2 (f1, f3)
VALUES ('bogus', -32769);
ERROR: smallint out of range
INSERT INTO serialTest2 (f1, f4)
VALUES ('bogus', -32769);
ERROR: smallint out of range
INSERT INTO serialTest2 (f1, f3)
VALUES ('bogus', 32768);
ERROR: smallint out of range
INSERT INTO serialTest2 (f1, f4)
VALUES ('bogus', 32768);
ERROR: smallint out of range
INSERT INTO serialTest2 (f1, f5)
VALUES ('bogus', -9223372036854775809);
ERROR: bigint out of range
INSERT INTO serialTest2 (f1, f6)
VALUES ('bogus', -9223372036854775809);
ERROR: bigint out of range
INSERT INTO serialTest2 (f1, f5)
VALUES ('bogus', 9223372036854775808);
ERROR: bigint out of range
INSERT INTO serialTest2 (f1, f6)
VALUES ('bogus', 9223372036854775808);
ERROR: bigint out of range
SELECT * FROM serialTest2 ORDER BY f2 ASC;
f1 | f2 | f3 | f4 | f5 | f6
---------------+-------------+--------+--------+----------------------+----------------------
test_min_vals | -2147483648 | -32768 | -32768 | -9223372036854775808 | -9223372036854775808
test_defaults | 1 | 1 | 1 | 1 | 1
test_max_vals | 2147483647 | 32767 | 32767 | 9223372036854775807 | 9223372036854775807
(3
rows)
SELECT nextval('serialTest2_f2_seq');
nextval
---------
2
(1
row)
SELECT nextval('serialTest2_f3_seq');
nextval
---------
2
(1
row)
SELECT nextval('serialTest2_f4_seq');
nextval
---------
2
(1
row)
SELECT nextval('serialTest2_f5_seq');
nextval
---------
2
(1
row)
SELECT nextval('serialTest2_f6_seq');
nextval
---------
2
(1
row)
-- basic sequence operations using both text and oid references
CREATE SEQUENCE sequence_test;
SELECT nextval('sequence_test'::text);
...
...
@@ -221,11 +299,19 @@ SELECT nextval('sequence_test2');
(1
row)
-- Information schema
SELECT * FROM information_schema.sequences WHERE sequence_name IN ('sequence_test2');
sequence_catalog | sequence_schema | sequence_name | data_type | numeric_precision | numeric_precision_radix | numeric_scale | start_value | minimum_value | maximum_value | increment | cycle_option
------------------+-----------------+----------------+-----------+-------------------+-------------------------+---------------+-------------+---------------+---------------+-----------+--------------
regression | public | sequence_test2 | bigint | 64 | 2 | 0 | 32 | 5 | 36 | 4 | YES
(1
row)
SELECT * FROM information_schema.sequences WHERE sequence_name IN
('sequence_test2', 'serialtest2_f2_seq', 'serialtest2_f3_seq',
'serialtest2_f4_seq', 'serialtest2_f5_seq', 'serialtest2_f6_seq')
ORDER BY sequence_name ASC;
sequence_catalog | sequence_schema | sequence_name | data_type | numeric_precision | numeric_precision_radix | numeric_scale | start_value | minimum_value | maximum_value | increment | cycle_option
------------------+-----------------+--------------------+-----------+-------------------+-------------------------+---------------+-------------+---------------+---------------------+-----------+--------------
regression | public | sequence_test2 | bigint | 64 | 2 | 0 | 32 | 5 | 36 | 4 | YES
regression | public | serialtest2_f2_seq | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO
regression | public | serialtest2_f3_seq | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO
regression | public | serialtest2_f4_seq | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO
regression | public | serialtest2_f5_seq | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO
regression | public | serialtest2_f6_seq | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO
(6
rows)
-- Test comments
COMMENT ON SEQUENCE asdf IS 'won''t work';
...
...
@@ -289,5 +375,17 @@ REVOKE ALL ON seq3 FROM seq_user;
SELECT lastval();
ERROR: permission denied for sequence seq3
ROLLBACK;
-- Sequences should get wiped out as well:
DROP TABLE serialTest, serialTest2;
-- Make sure sequences are gone:
SELECT * FROM information_schema.sequences WHERE sequence_name IN
('sequence_test2', 'serialtest2_f2_seq', 'serialtest2_f3_seq',
'serialtest2_f4_seq', 'serialtest2_f5_seq', 'serialtest2_f6_seq')
ORDER BY sequence_name ASC;
sequence_catalog | sequence_schema | sequence_name | data_type | numeric_precision | numeric_precision_radix | numeric_scale | start_value | minimum_value | maximum_value | increment | cycle_option
------------------+-----------------+----------------+-----------+-------------------+-------------------------+---------------+-------------+---------------+---------------+-----------+--------------
regression | public | sequence_test2 | bigint | 64 | 2 | 0 | 32 | 5 | 36 | 4 | YES
(1
row)
DROP USER seq_user;
DROP SEQUENCE seq;
src/test/regress/sql/sequence.sql
View file @
431ab0e8
...
...
@@ -11,6 +11,52 @@ INSERT INTO serialTest VALUES ('wrong', NULL);
SELECT
*
FROM
serialTest
;
-- test smallserial / bigserial
CREATE
TABLE
serialTest2
(
f1
text
,
f2
serial
,
f3
smallserial
,
f4
serial2
,
f5
bigserial
,
f6
serial8
);
INSERT
INTO
serialTest2
(
f1
)
VALUES
(
'test_defaults'
);
INSERT
INTO
serialTest2
(
f1
,
f2
,
f3
,
f4
,
f5
,
f6
)
VALUES
(
'test_max_vals'
,
2147483647
,
32767
,
32767
,
9223372036854775807
,
9223372036854775807
),
(
'test_min_vals'
,
-
2147483648
,
-
32768
,
-
32768
,
-
9223372036854775808
,
-
9223372036854775808
);
-- All these INSERTs should fail:
INSERT
INTO
serialTest2
(
f1
,
f3
)
VALUES
(
'bogus'
,
-
32769
);
INSERT
INTO
serialTest2
(
f1
,
f4
)
VALUES
(
'bogus'
,
-
32769
);
INSERT
INTO
serialTest2
(
f1
,
f3
)
VALUES
(
'bogus'
,
32768
);
INSERT
INTO
serialTest2
(
f1
,
f4
)
VALUES
(
'bogus'
,
32768
);
INSERT
INTO
serialTest2
(
f1
,
f5
)
VALUES
(
'bogus'
,
-
9223372036854775809
);
INSERT
INTO
serialTest2
(
f1
,
f6
)
VALUES
(
'bogus'
,
-
9223372036854775809
);
INSERT
INTO
serialTest2
(
f1
,
f5
)
VALUES
(
'bogus'
,
9223372036854775808
);
INSERT
INTO
serialTest2
(
f1
,
f6
)
VALUES
(
'bogus'
,
9223372036854775808
);
SELECT
*
FROM
serialTest2
ORDER
BY
f2
ASC
;
SELECT
nextval
(
'serialTest2_f2_seq'
);
SELECT
nextval
(
'serialTest2_f3_seq'
);
SELECT
nextval
(
'serialTest2_f4_seq'
);
SELECT
nextval
(
'serialTest2_f5_seq'
);
SELECT
nextval
(
'serialTest2_f6_seq'
);
-- basic sequence operations using both text and oid references
CREATE
SEQUENCE
sequence_test
;
...
...
@@ -86,7 +132,10 @@ SELECT nextval('sequence_test2');
SELECT
nextval
(
'sequence_test2'
);
-- Information schema
SELECT
*
FROM
information_schema
.
sequences
WHERE
sequence_name
IN
(
'sequence_test2'
);
SELECT
*
FROM
information_schema
.
sequences
WHERE
sequence_name
IN
(
'sequence_test2'
,
'serialtest2_f2_seq'
,
'serialtest2_f3_seq'
,
'serialtest2_f4_seq'
,
'serialtest2_f5_seq'
,
'serialtest2_f6_seq'
)
ORDER
BY
sequence_name
ASC
;
-- Test comments
COMMENT
ON
SEQUENCE
asdf
IS
'won
''
t work'
;
...
...
@@ -118,5 +167,14 @@ REVOKE ALL ON seq3 FROM seq_user;
SELECT
lastval
();
ROLLBACK
;
-- Sequences should get wiped out as well:
DROP
TABLE
serialTest
,
serialTest2
;
-- Make sure sequences are gone:
SELECT
*
FROM
information_schema
.
sequences
WHERE
sequence_name
IN
(
'sequence_test2'
,
'serialtest2_f2_seq'
,
'serialtest2_f3_seq'
,
'serialtest2_f4_seq'
,
'serialtest2_f5_seq'
,
'serialtest2_f6_seq'
)
ORDER
BY
sequence_name
ASC
;
DROP
USER
seq_user
;
DROP
SEQUENCE
seq
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment