Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 99696 invoked from network); 15 Apr 2010 17:36:12 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 15 Apr 2010 17:36:12 -0000 Received: (qmail 5321 invoked by uid 500); 15 Apr 2010 17:36:12 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 5293 invoked by uid 500); 15 Apr 2010 17:36:12 -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 5285 invoked by uid 99); 15 Apr 2010 17:36:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Apr 2010 17:36:12 +0000 X-ASF-Spam-Status: No, hits=-1294.7 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Apr 2010 17:36:11 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o3FHZo8Q023938 for ; Thu, 15 Apr 2010 13:35:50 -0400 (EDT) Message-ID: <28794151.145521271352950583.JavaMail.jira@thor> Date: Thu, 15 Apr 2010 13:35:50 -0400 (EDT) From: "Lily Wei (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-4406) Wrong order when using ORDER BY on non-deterministic function In-Reply-To: <1093343113.1255361491709.JavaMail.jira@brutus> 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-4406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857424#action_12857424 ] Lily Wei commented on DERBY-4406: --------------------------------- If the goal is for Derby to recognize OrderByColumn is referencing an expression which is equivalent to ResultColumn that is already present in the SELECT and yet follow SQL standard as much as we can. I agree (+1) we must make sure that if we change OrderByColumn behavior for use case (1) and/or (2) and we don't change the behavior for use case (3). > Wrong order when using ORDER BY on non-deterministic function > ------------------------------------------------------------- > > Key: DERBY-4406 > URL: https://issues.apache.org/jira/browse/DERBY-4406 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.5.3.0, 10.6.0.0 > Reporter: Knut Anders Hatlen > Assignee: C.S. Nirmal J. Fernando > > If I read the SQL standard correctly, a statement such as "select random() as r from t order by random()" should be treated as "select random() as r from t order by r". Derby does however generate a second, hidden random() column by which the rows are ordered. > ij> create table t(x int); > 0 rows inserted/updated/deleted > ij> insert into t values 1,2,3,4,5; > 5 rows inserted/updated/deleted > ij> -- wrong result, not ordered by r > ij> select random() as r from t order by random(); > R > ---------------------- > 0.1285512465366495 > 0.5116860880915798 > 0.21060042130229073 > 0.2506706923680875 > 0.6378857329935494 > 5 rows selected > ij> -- correct result, ordered by r > ij> select random() as r from t order by r; > R > ---------------------- > 0.0749025910679918 > 0.07694931688380491 > 0.1724114605785414 > 0.2268758969382877 > 0.31900450349277965 > 5 rows selected -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira