Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C78FDD95 for ; Sat, 4 Aug 2012 17:40:03 +0000 (UTC) Received: (qmail 3069 invoked by uid 500); 4 Aug 2012 17:40:02 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 3039 invoked by uid 500); 4 Aug 2012 17:40:02 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 3031 invoked by uid 99); 4 Aug 2012 17:40:02 -0000 Received: from issues-vm.apache.org (HELO issues-vm) (140.211.11.160) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Aug 2012 17:40:02 +0000 Received: from isssues-vm.apache.org (localhost [127.0.0.1]) by issues-vm (Postfix) with ESMTP id B2F26142823 for ; Sat, 4 Aug 2012 17:40:02 +0000 (UTC) Date: Sat, 4 Aug 2012 17:40:02 +0000 (UTC) From: "Lukas Eder (JIRA)" To: derby-dev@db.apache.org Message-ID: <1962703553.13538.1344102002736.JavaMail.jiratomcat@issues-vm> In-Reply-To: <2005706336.13394.1344093062876.JavaMail.jiratomcat@issues-vm> Subject: [jira] [Commented] (DERBY-5893) Add support for the SQL:2008 standard IS [ NOT ] DISTINCT FROM predicate MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-5893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13428647#comment-13428647 ] Lukas Eder commented on DERBY-5893: ----------------------------------- Yes, it's different in the way it handles NULLs. For example: - (1 != NULL) yields NULL, whereas (1 IS DISTINCT FROM NULL) yields TRUE - (NULL != NULL) yields NULL, whereas (NULL IS DISTINCT FROM NULL) yields FALSE Here's how you could translate IS [ NOT ] DISTINCT FROM into a equivalent CASE expressions: {code} -- A IS DISTINCT FROM B: CASE WHEN A IS NULL AND B IS NULL THEN 0 WHEN A IS NULL AND B IS NOT NULL THEN 1 WHEN A IS NOT NULL AND B IS NULL THEN 1 WHEN A = B THEN 0 ELSE 1 END -- A IS NOT DISTINCT FROM B: CASE WHEN A IS NULL AND B IS NULL THEN 1 WHEN A IS NULL AND B IS NOT NULL THEN 0 WHEN A IS NOT NULL AND B IS NULL THEN 0 WHEN A = B THEN 1 ELSE 0 END {code} Alternatively, replace 1 and 0 by TRUE and FALSE. > Add support for the SQL:2008 standard IS [ NOT ] DISTINCT FROM predicate > ------------------------------------------------------------------------ > > Key: DERBY-5893 > URL: https://issues.apache.org/jira/browse/DERBY-5893 > Project: Derby > Issue Type: Improvement > Components: SQL > Affects Versions: 10.9.1.0 > Reporter: Lukas Eder > Priority: Minor > Labels: features > > The SQL:1999 standard specifies the IS [ NOT ] DISTINCT FROM predicate in chapter 8.15 : > ::= > > ::= > IS [ NOT ] DISTINCT FROM > ::= > > ::= > > This predicate is supported by at least these databases: > - http://www.postgresql.org/docs/9.1/static/functions-comparison.html > - http://www.h2database.com/html/grammar.html#condition_right_hand_side > - http://hsqldb.org/doc/guide/ch05.html#N11BB0 > - http://dev.mysql.com/doc/refman/5.6/en/comparison-operators.html#operator_equal-to (with a different syntax) > - http://dcx.sybase.com/1200/en/dbreference/is-distinct-from-search-condition.html > It would probably make sense for the Derby database to implement it as well. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira