Re: [PATCHES] is not distinct from

2005-12-11 Thread Neil Conway
On Fri, 2005-11-25 at 17:01 +0100, Pavel Stehule wrote:
> small patch, add form is not distinct from expression (sql2003)

Applied to HEAD -- thanks for the patch.

-Neil



---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


[PATCHES] is not distinct from

2005-11-25 Thread Pavel Stehule

Hello

small patch, add form is not distinct from expression (sql2003)

regards
Pavel Stehule

_
Emotikony a pozadi programu MSN Messenger ozivi vasi konverzaci. 
http://messenger.msn.cz/
diff -c -r pgsql.old/doc/src/sgml/func.sgml pgsql/doc/src/sgml/func.sgml
*** pgsql.old/doc/src/sgml/func.sgml	2005-11-19 20:44:54.0 +0100
--- pgsql/doc/src/sgml/func.sgml	2005-11-25 16:47:42.0 +0100
***
*** 345,350 
--- 345,353 
  
   IS DISTINCT FROM
  
+ 
+  IS NOT DISTINCT FROM
+ 
  The ordinary comparison operators yield null (signifying unknown)
  when either input is null.  Another way to do comparisons is with the
  IS DISTINCT FROM construct:
***
*** 356,362 
  one input is null it will return true.  Thus it effectively acts as though
  null were a normal data value, rather than unknown.
 
! 
 
  
   IS TRUE
--- 359,371 
  one input is null it will return true.  Thus it effectively acts as though
  null were a normal data value, rather than unknown.
 
!
!
!IS NOT DISTINCT FROM is equal construct:
! 
! NOT(expression IS DISTINCT FROM expression)
! 
!
 
  
   IS TRUE
diff -c -r pgsql.old/src/backend/parser/gram.y pgsql/src/backend/parser/gram.y
*** pgsql.old/src/backend/parser/gram.y	2005-11-22 16:24:17.0 +0100
--- pgsql/src/backend/parser/gram.y	2005-11-25 16:39:45.0 +0100
***
*** 6715,6720 
--- 6715,6726 
  {
  	$$ = (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);
***
*** 6898,6903 
--- 6904,6914 
  {
  	$$ = (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);
diff -c -r pgsql.old/src/test/regress/sql/select_distinct.sql pgsql/src/test/regress/sql/select_distinct.sql
*** pgsql.old/src/test/regress/sql/select_distinct.sql	2002-12-13 21:16:11.0 +0100
--- pgsql/src/test/regress/sql/select_distinct.sql	2005-11-25 16:49:20.0 +0100
***
*** 56,58 
--- 56,64 
  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 "yes";
+ SELECT 2 IS NOT DISTINCT FROM 2 as "no";
+ SELECT 2 IS NOT DISTINCT FROM null as "yes";
+ SELECT null IS NOT DISTINCT FROM null as "no";


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq