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
be8100d6
Commit
be8100d6
authored
Dec 11, 2005
by
Neil Conway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement IS NOT DISTINCT FROM, update the regression tests and docs.
Patch from Pavel Stehule, minor fixups by myself.
parent
c1059314
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
6 deletions
+57
-6
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+13
-5
src/backend/parser/gram.y
src/backend/parser/gram.y
+13
-1
src/test/regress/expected/select_distinct.out
src/test/regress/expected/select_distinct.out
+25
-0
src/test/regress/sql/select_distinct.sql
src/test/regress/sql/select_distinct.sql
+6
-0
No files found.
doc/src/sgml/func.sgml
View file @
be8100d6
<!--
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.29
7 2005/12/03 16:45:05 momjian
Exp $
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.29
8 2005/12/11 10:54:27 neilc
Exp $
PostgreSQL documentation
-->
...
...
@@ -345,16 +345,24 @@ PostgreSQL documentation
<indexterm>
<primary>IS DISTINCT FROM</primary>
</indexterm>
<indexterm>
<primary>IS NOT DISTINCT FROM</primary>
</indexterm>
The ordinary comparison operators yield null (signifying <quote>unknown</>)
when either input is null. Another way to do comparisons is with the
<literal>IS DISTINCT FROM</literal> construct:
<synopsis>
<replaceable>expression</replaceable> IS DISTINCT FROM <replaceable>expression</replaceable>
<replaceable>expression</replaceable> IS NOT DISTINCT FROM <replaceable>expression</replaceable>
</synopsis>
For non-null inputs this is the same as the <literal><></> operator.
However, when both inputs are null it will return false, and when just
one input is null it will return true. Thus it effectively acts as though
null were a normal data value, rather than <quote>unknown</>.
For non-null inputs, <literal>IS DISTINCT FROM</literal> this is
the same as the <literal><></> operator. However, when both
inputs are null it will return false, and when just one input is
null it will return true. Similarly, <literal>IS NOT DISTINCT
FROM</literal> is identical to <literal>=</literal> for non-null
inputs, returns true when both inputs are null, and false
otherwise. Thus, these constructs effectively act as though null
were a normal data value, rather than <quote>unknown</>.
</para>
<para>
...
...
src/backend/parser/gram.y
View file @
be8100d6
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.51
6 2005/11/28 04:35:31 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.51
7 2005/12/11 10:54:27 neilc
Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
...
...
@@ -6715,6 +6715,13 @@ a_expr: c_expr { $$ = $1; }
{
$$ = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $5);
}
| a_expr IS NOT DISTINCT FROM a_expr %prec IS
{
$$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL,
(Node *) makeSimpleA_Expr(AEXPR_DISTINCT,
"=", $1, $6));
}
| a_expr IS OF '(' type_list ')' %prec IS
{
$$ = (Node *) makeSimpleA_Expr(AEXPR_OF, "=", $1, (Node *) $5);
...
...
@@ -6880,6 +6887,11 @@ b_expr: c_expr
{
$$ = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $5);
}
| b_expr IS NOT DISTINCT FROM b_expr %prec IS
{
$$ = (Node *) makeA_Expr(AEXPR_NOT, NIL,
NULL, (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $6));
}
| b_expr IS OF '(' type_list ')' %prec IS
{
$$ = (Node *) makeSimpleA_Expr(AEXPR_OF, "=", $1, (Node *) $5);
...
...
src/test/regress/expected/select_distinct.out
View file @
be8100d6
...
...
@@ -195,3 +195,28 @@ SELECT null IS DISTINCT FROM null as "no";
f
(1 row)
-- ANSI SQL 2003 form
SELECT 1 IS NOT DISTINCT FROM 2 as "no";
no
----
f
(1 row)
SELECT 2 IS NOT DISTINCT FROM 2 as "yes";
yes
-----
t
(1 row)
SELECT 2 IS NOT DISTINCT FROM null as "no";
no
----
f
(1 row)
SELECT null IS NOT DISTINCT FROM null as "yes";
yes
-----
t
(1 row)
src/test/regress/sql/select_distinct.sql
View file @
be8100d6
...
...
@@ -56,3 +56,9 @@ SELECT 1 IS DISTINCT FROM 2 as "yes";
SELECT
2
IS
DISTINCT
FROM
2
as
"no"
;
SELECT
2
IS
DISTINCT
FROM
null
as
"yes"
;
SELECT
null
IS
DISTINCT
FROM
null
as
"no"
;
-- ANSI SQL 2003 form
SELECT
1
IS
NOT
DISTINCT
FROM
2
as
"no"
;
SELECT
2
IS
NOT
DISTINCT
FROM
2
as
"yes"
;
SELECT
2
IS
NOT
DISTINCT
FROM
null
as
"no"
;
SELECT
null
IS
NOT
DISTINCT
FROM
null
as
"yes"
;
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