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
47e506fb
Commit
47e506fb
authored
Dec 04, 1998
by
Thomas G. Lockhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include test for CASE expression.
parent
bedd04a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
173 additions
and
0 deletions
+173
-0
src/test/regress/expected/case.out
src/test/regress/expected/case.out
+94
-0
src/test/regress/sql/case.sql
src/test/regress/sql/case.sql
+78
-0
src/test/regress/sql/tests
src/test/regress/sql/tests
+1
-0
No files found.
src/test/regress/expected/case.out
0 → 100644
View file @
47e506fb
QUERY: SELECT '' AS "One",
CASE
WHEN 1 < 2 THEN 3
END AS "One only = 3";
One|One only = 3
---+------------
| 3
(1 row)
QUERY: SELECT '' AS "One",
CASE
WHEN 1 > 2 THEN 3
END AS "One only = Null";
One|One only = Null
---+---------------
|
(1 row)
QUERY: SELECT '' AS "One",
CASE
WHEN 1 < 2 THEN 3
ELSE 4
END AS "One with default = 3";
One|One with default = 3
---+--------------------
| 3
(1 row)
QUERY: SELECT '' AS "One",
CASE
WHEN 1 > 2 THEN 3
ELSE 4
END AS "One with default = 4";
One|One with default = 4
---+--------------------
| 4
(1 row)
QUERY: SELECT '' AS "One",
CASE
WHEN 1 > 2 THEN 3
WHEN 4 < 5 THEN 6
ELSE 7
END AS "Two with default = 6";
One|Two with default = 6
---+--------------------
| 6
(1 row)
QUERY: SELECT '' AS "Five",
CASE
WHEN f1 >= 0 THEN f1
END AS ">= 0 or Null"
FROM INT4_TBL;
Five|>= 0 or Null
----+------------
| 0
| 123456
|
| 2147483647
|
(5 rows)
QUERY: SELECT '' AS "Five",
CASE WHEN f1 >= 0 THEN (f1 - f1)
ELSE f1
END AS "Simplest Math"
FROM INT4_TBL;
Five|Simplest Math
----+-------------
| 0
| 0
| -123456
| 0
| -2147483647
(5 rows)
QUERY: SELECT '' AS "Five", f1 AS "Value",
CASE WHEN (f1 < 0) THEN 'small'
WHEN (f1 = 0) THEN 'zero'
WHEN (f1 = 1) THEN 'one'
WHEN (f1 = 2) THEN 'two'
ELSE 'big'
END AS "Category"
FROM INT4_TBL;
Five| Value|Category
----+-----------+--------
| 0|zero
| 123456|big
| -123456|small
| 2147483647|big
|-2147483647|small
(5 rows)
src/test/regress/sql/case.sql
0 → 100644
View file @
47e506fb
--
-- case.sql
--
-- Test the case statement
--
-- Simplest examples without involving tables
--
SELECT
''
AS
"One"
,
CASE
WHEN
1
<
2
THEN
3
END
AS
"One only = 3"
;
SELECT
''
AS
"One"
,
CASE
WHEN
1
>
2
THEN
3
END
AS
"One only = Null"
;
SELECT
''
AS
"One"
,
CASE
WHEN
1
<
2
THEN
3
ELSE
4
END
AS
"One with default = 3"
;
SELECT
''
AS
"One"
,
CASE
WHEN
1
>
2
THEN
3
ELSE
4
END
AS
"One with default = 4"
;
SELECT
''
AS
"One"
,
CASE
WHEN
1
>
2
THEN
3
WHEN
4
<
5
THEN
6
ELSE
7
END
AS
"Two with default = 6"
;
--
-- Examples of targets involving tables
--
SELECT
''
AS
"Five"
,
CASE
WHEN
f1
>=
0
THEN
f1
END
AS
">= 0 or Null"
FROM
INT4_TBL
;
SELECT
''
AS
"Five"
,
CASE
WHEN
f1
>=
0
THEN
(
f1
-
f1
)
ELSE
f1
END
AS
"Simplest Math"
FROM
INT4_TBL
;
SELECT
''
AS
"Five"
,
f1
AS
"Value"
,
CASE
WHEN
(
f1
<
0
)
THEN
'small'
WHEN
(
f1
=
0
)
THEN
'zero'
WHEN
(
f1
=
1
)
THEN
'one'
WHEN
(
f1
=
2
)
THEN
'two'
ELSE
'big'
END
AS
"Category"
FROM
INT4_TBL
;
/*
SELECT '' AS "Five",
CASE WHEN ((f1 < 0) or (i < 0)) THEN 'small'
WHEN ((f1 = 0) or (i = 0)) THEN 'zero'
WHEN ((f1 = 1) or (i = 1)) THEN 'one'
WHEN ((f1 = 2) or (i = 2)) THEN 'two'
ELSE 'big'
END AS "Category"
FROM INT4_TBL;
*/
--
-- Examples of qualifications involving tables
--
src/test/regress/sql/tests
View file @
47e506fb
...
...
@@ -49,6 +49,7 @@ select_implicit
select_having
subselect
union
case
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