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
ca454128
Commit
ca454128
authored
Feb 18, 1998
by
Thomas G. Lockhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new subselect test.
parent
ca38b10c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
214 additions
and
0 deletions
+214
-0
src/test/regress/expected/subselect.out
src/test/regress/expected/subselect.out
+142
-0
src/test/regress/sql/subselect.sql
src/test/regress/sql/subselect.sql
+71
-0
src/test/regress/sql/tests
src/test/regress/sql/tests
+1
-0
No files found.
src/test/regress/expected/subselect.out
0 → 100644
View file @
ca454128
QUERY: SELECT 1 AS one WHERE 1 IN (SELECT 1);
one
---
1
(1 row)
QUERY: SELECT 1 AS zero WHERE 1 NOT IN (SELECT 1);
zero
----
(0 rows)
QUERY: SELECT 1 AS zero WHERE 1 IN (SELECT 2);
zero
----
(0 rows)
QUERY: CREATE TABLE SUBSELECT_TBL (
f1 integer,
f2 integer,
f3 float
);
QUERY: INSERT INTO SUBSELECT_TBL VALUES (1, 2, 3);
QUERY: INSERT INTO SUBSELECT_TBL VALUES (2, 3, 4);
QUERY: INSERT INTO SUBSELECT_TBL VALUES (3, 4, 5);
QUERY: INSERT INTO SUBSELECT_TBL VALUES (1, 1, 1);
QUERY: INSERT INTO SUBSELECT_TBL VALUES (2, 2, 2);
QUERY: INSERT INTO SUBSELECT_TBL VALUES (3, 3, 3);
QUERY: INSERT INTO SUBSELECT_TBL VALUES (6, 7, 8);
QUERY: INSERT INTO SUBSELECT_TBL VALUES (8, 9, NULL);
QUERY: SELECT '' AS eight, * FROM SUBSELECT_TBL;
eight|f1|f2|f3
-----+--+--+--
| 1| 2| 3
| 2| 3| 4
| 3| 4| 5
| 1| 1| 1
| 2| 2| 2
| 3| 3| 3
| 6| 7| 8
| 8| 9|
(8 rows)
QUERY: SELECT '' AS two, f1 AS "Constant Select" FROM SUBSELECT_TBL
WHERE f1 IN (SELECT 1);
two|Constant Select
---+---------------
| 1
| 1
(2 rows)
QUERY: SELECT '' AS six, f1 AS "Uncorrelated Field" FROM SUBSELECT_TBL
WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL);
six|Uncorrelated Field
---+------------------
| 1
| 2
| 3
| 1
| 2
| 3
(6 rows)
QUERY: SELECT '' AS six, f1 AS "Uncorrelated Field" FROM SUBSELECT_TBL
WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL WHERE
f2 IN (SELECT f1 FROM SUBSELECT_TBL));
six|Uncorrelated Field
---+------------------
| 1
| 2
| 3
| 1
| 2
| 3
(6 rows)
QUERY: SELECT '' AS six, f1 AS "Correlated Field", f3 AS "Second Field"
FROM SUBSELECT_TBL
WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL WHERE f2 = f1);
six|Correlated Field|Second Field
---+----------------+------------
| 1| 3
| 2| 4
| 3| 5
| 1| 1
| 2| 2
| 3| 3
(6 rows)
QUERY: SELECT '' AS six, f1 AS "Correlated Field", f3 AS "Second Field"
FROM SUBSELECT_TBL
WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL WHERE CAST(f2 AS float) = f3);
six|Correlated Field|Second Field
---+----------------+------------
| 1| 3
| 2| 4
| 3| 5
| 1| 1
| 2| 2
| 3| 3
(6 rows)
QUERY: SELECT '' AS six, f1 AS "Correlated Field", f3 AS "Second Field"
FROM SUBSELECT_TBL
WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL WHERE f2 = CAST(f3 AS integer));
ERROR: dtoi4: unable to convert null
QUERY: SELECT '' AS five, f1 AS "Correlated Field"
FROM SUBSELECT_TBL
WHERE (f1, f2) IN (SELECT f2, CAST(f3 AS int4) FROM SUBSELECT_TBL WHERE f3 IS NOT NULL);
five|Correlated Field
----+----------------
| 2
| 3
| 1
| 2
| 3
(5 rows)
QUERY: SELECT '' AS three, f1 AS "Correlated Field"
FROM SUBSELECT_TBL
WHERE (f1, f2) NOT IN (SELECT f2, CAST(f3 AS int4) FROM SUBSELECT_TBL WHERE f3 IS NOT NULL);
three|Correlated Field
-----+----------------
| 1
| 6
| 8
(3 rows)
QUERY: SELECT '' AS eight, ss.f1 AS "Correlated Field", ss.f3 AS "Second Field"
FROM SUBSELECT_TBL ss
WHERE f1 NOT IN (SELECT f1 FROM INT4_TBL WHERE f1 != ss.f1);
eight|Correlated Field|Second Field
-----+----------------+------------
| 1| 3
| 2| 4
| 3| 5
| 1| 1
| 2| 2
| 3| 3
| 6| 8
| 8|
(8 rows)
src/test/regress/sql/subselect.sql
0 → 100644
View file @
ca454128
--
-- Subselects
--
SELECT
1
AS
one
WHERE
1
IN
(
SELECT
1
);
SELECT
1
AS
zero
WHERE
1
NOT
IN
(
SELECT
1
);
SELECT
1
AS
zero
WHERE
1
IN
(
SELECT
2
);
-- Set up some simple test tables
CREATE
TABLE
SUBSELECT_TBL
(
f1
integer
,
f2
integer
,
f3
float
);
INSERT
INTO
SUBSELECT_TBL
VALUES
(
1
,
2
,
3
);
INSERT
INTO
SUBSELECT_TBL
VALUES
(
2
,
3
,
4
);
INSERT
INTO
SUBSELECT_TBL
VALUES
(
3
,
4
,
5
);
INSERT
INTO
SUBSELECT_TBL
VALUES
(
1
,
1
,
1
);
INSERT
INTO
SUBSELECT_TBL
VALUES
(
2
,
2
,
2
);
INSERT
INTO
SUBSELECT_TBL
VALUES
(
3
,
3
,
3
);
INSERT
INTO
SUBSELECT_TBL
VALUES
(
6
,
7
,
8
);
INSERT
INTO
SUBSELECT_TBL
VALUES
(
8
,
9
,
NULL
);
SELECT
''
AS
eight
,
*
FROM
SUBSELECT_TBL
;
-- Uncorrelated subselects
SELECT
''
AS
two
,
f1
AS
"Constant Select"
FROM
SUBSELECT_TBL
WHERE
f1
IN
(
SELECT
1
);
SELECT
''
AS
six
,
f1
AS
"Uncorrelated Field"
FROM
SUBSELECT_TBL
WHERE
f1
IN
(
SELECT
f2
FROM
SUBSELECT_TBL
);
SELECT
''
AS
six
,
f1
AS
"Uncorrelated Field"
FROM
SUBSELECT_TBL
WHERE
f1
IN
(
SELECT
f2
FROM
SUBSELECT_TBL
WHERE
f2
IN
(
SELECT
f1
FROM
SUBSELECT_TBL
));
-- Correlated subselects
SELECT
''
AS
six
,
f1
AS
"Correlated Field"
,
f3
AS
"Second Field"
FROM
SUBSELECT_TBL
WHERE
f1
IN
(
SELECT
f2
FROM
SUBSELECT_TBL
WHERE
f2
=
f1
);
SELECT
''
AS
six
,
f1
AS
"Correlated Field"
,
f3
AS
"Second Field"
FROM
SUBSELECT_TBL
WHERE
f1
IN
(
SELECT
f2
FROM
SUBSELECT_TBL
WHERE
CAST
(
f2
AS
float
)
=
f3
);
SELECT
''
AS
six
,
f1
AS
"Correlated Field"
,
f3
AS
"Second Field"
FROM
SUBSELECT_TBL
WHERE
f1
IN
(
SELECT
f2
FROM
SUBSELECT_TBL
WHERE
f2
=
CAST
(
f3
AS
integer
));
SELECT
''
AS
five
,
f1
AS
"Correlated Field"
FROM
SUBSELECT_TBL
WHERE
(
f1
,
f2
)
IN
(
SELECT
f2
,
CAST
(
f3
AS
int4
)
FROM
SUBSELECT_TBL
WHERE
f3
IS
NOT
NULL
);
SELECT
''
AS
three
,
f1
AS
"Correlated Field"
FROM
SUBSELECT_TBL
WHERE
(
f1
,
f2
)
NOT
IN
(
SELECT
f2
,
CAST
(
f3
AS
int4
)
FROM
SUBSELECT_TBL
WHERE
f3
IS
NOT
NULL
);
--
-- Use some existing tables in the regression test
--
SELECT
''
AS
eight
,
ss
.
f1
AS
"Correlated Field"
,
ss
.
f3
AS
"Second Field"
FROM
SUBSELECT_TBL
ss
WHERE
f1
NOT
IN
(
SELECT
f1
FROM
INT4_TBL
WHERE
f1
!=
ss
.
f1
);
src/test/regress/sql/tests
View file @
ca454128
...
...
@@ -48,6 +48,7 @@ select
select_into
select_distinct
select_distinct_on
subselect
aggregates
transactions
random
...
...
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