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
a4e1304e
Commit
a4e1304e
authored
Jan 16, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add check that inherited constraints and defaults work.
parent
47a895fe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
6 deletions
+45
-6
src/test/regress/input/constraints.source
src/test/regress/input/constraints.source
+21
-3
src/test/regress/output/constraints.source
src/test/regress/output/constraints.source
+24
-3
No files found.
src/test/regress/input/constraints.source
View file @
a4e1304e
...
@@ -84,7 +84,8 @@ SELECT '' AS two, * from CHECK2_TBL;
...
@@ -84,7 +84,8 @@ SELECT '' AS two, * from CHECK2_TBL;
CREATE SEQUENCE INSERT_SEQ;
CREATE SEQUENCE INSERT_SEQ;
CREATE TABLE INSERT_TBL (x INT DEFAULT nextval('insert_seq'),
CREATE TABLE INSERT_TBL (x INT DEFAULT nextval('insert_seq'),
y TEXT DEFAULT '-NULL-', z INT DEFAULT -1 * currval('insert_seq'),
y TEXT DEFAULT '-NULL-',
z INT DEFAULT -1 * currval('insert_seq'),
CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
CHECK (x + z = 0));
CHECK (x + z = 0));
...
@@ -118,6 +119,23 @@ INSERT INTO INSERT_TBL(y) VALUES ('Y');
...
@@ -118,6 +119,23 @@ INSERT INTO INSERT_TBL(y) VALUES ('Y');
SELECT 'eight' AS one, currval('insert_seq');
SELECT 'eight' AS one, currval('insert_seq');
--
-- Check inheritance of defaults and constraints
--
CREATE TABLE INSERT_CHILD (cx INT default 42,
cy INT CHECK (cy > x))
INHERITS (INSERT_TBL);
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,11);
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,6);
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (6,-7,7);
INSERT INTO INSERT_CHILD(x,y,z,cy) VALUES (6,'check failed',-6,7);
SELECT * FROM INSERT_CHILD;
DROP TABLE INSERT_CHILD;
--
--
-- Check constraints on INSERT INTO
-- Check constraints on INSERT INTO
--
--
...
...
src/test/regress/output/constraints.source
View file @
a4e1304e
...
@@ -102,7 +102,8 @@ SELECT '' AS two, * from CHECK2_TBL;
...
@@ -102,7 +102,8 @@ SELECT '' AS two, * from CHECK2_TBL;
--
--
CREATE SEQUENCE INSERT_SEQ;
CREATE SEQUENCE INSERT_SEQ;
CREATE TABLE INSERT_TBL (x INT DEFAULT nextval('insert_seq'),
CREATE TABLE INSERT_TBL (x INT DEFAULT nextval('insert_seq'),
y TEXT DEFAULT '-NULL-', z INT DEFAULT -1 * currval('insert_seq'),
y TEXT DEFAULT '-NULL-',
z INT DEFAULT -1 * currval('insert_seq'),
CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
CHECK (x + z = 0));
CHECK (x + z = 0));
INSERT INTO INSERT_TBL VALUES (null, null, null);
INSERT INTO INSERT_TBL VALUES (null, null, null);
...
@@ -170,6 +171,26 @@ SELECT 'eight' AS one, currval('insert_seq');
...
@@ -170,6 +171,26 @@ SELECT 'eight' AS one, currval('insert_seq');
eight | 8
eight | 8
(1 row)
(1 row)
--
-- Check inheritance of defaults and constraints
--
CREATE TABLE INSERT_CHILD (cx INT default 42,
cy INT CHECK (cy > x))
INHERITS (INSERT_TBL);
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,11);
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,6);
ERROR: ExecAppend: rejected due to CHECK constraint insert_child_cy
INSERT INTO INSERT_CHILD(x,z,cy) VALUES (6,-7,7);
ERROR: ExecAppend: rejected due to CHECK constraint $1
INSERT INTO INSERT_CHILD(x,y,z,cy) VALUES (6,'check failed',-6,7);
ERROR: ExecAppend: rejected due to CHECK constraint insert_con
SELECT * FROM INSERT_CHILD;
x | y | z | cx | cy
---+--------+----+----+----
7 | -NULL- | -7 | 42 | 11
(1 row)
DROP TABLE INSERT_CHILD;
--
--
-- Check constraints on INSERT INTO
-- Check constraints on INSERT INTO
--
--
...
...
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