Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
a4e1304e
Commit
a4e1304e
authored
25 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Add check that inherited constraints and defaults work.
parent
47a895fe
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/test/regress/input/constraints.source
+21
-3
21 additions, 3 deletions
src/test/regress/input/constraints.source
src/test/regress/output/constraints.source
+24
-3
24 additions, 3 deletions
src/test/regress/output/constraints.source
with
45 additions
and
6 deletions
src/test/regress/input/constraints.source
+
21
−
3
View file @
a4e1304e
...
@@ -84,9 +84,10 @@ SELECT '' AS two, * from CHECK2_TBL;
...
@@ -84,9 +84,10 @@ 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-',
CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
z INT DEFAULT -1 * currval('insert_seq'),
CHECK (x + z = 0));
CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
CHECK (x + z = 0));
INSERT INTO INSERT_TBL VALUES (null, null, null);
INSERT INTO INSERT_TBL VALUES (null, null, null);
INSERT INTO INSERT_TBL(x,z) VALUES (2, -2);
INSERT INTO INSERT_TBL(x,z) VALUES (2, -2);
...
@@ -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
--
--
...
...
This diff is collapsed.
Click to expand it.
src/test/regress/output/constraints.source
+
24
−
3
View file @
a4e1304e
...
@@ -102,9 +102,10 @@ SELECT '' AS two, * from CHECK2_TBL;
...
@@ -102,9 +102,10 @@ 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-',
CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
z INT DEFAULT -1 * currval('insert_seq'),
CHECK (x + z = 0));
CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8),
CHECK (x + z = 0));
INSERT INTO INSERT_TBL VALUES (null, null, null);
INSERT INTO INSERT_TBL VALUES (null, null, null);
ERROR: ExecAppend: rejected due to CHECK constraint $2
ERROR: ExecAppend: rejected due to CHECK constraint $2
INSERT INTO INSERT_TBL(x,z) VALUES (2, -2);
INSERT INTO INSERT_TBL(x,z) VALUES (2, -2);
...
@@ -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
--
--
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment