[ https://issues.apache.org/jira/browse/DERBY-5933?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461790#comment-13461790 ]
Knut Anders Hatlen commented on DERBY-5933: ------------------------------------------- Another observation: The optimizer knows that the predicate B1=1 means that the results are always ordered on B1 (see FromTable.tellRowOrderingAboutConstantColumns()). Although this fact should have no significance for this query, whose results should be ordered on A1 and not on B1, disabling the optimization makes the rows come out in the correct order. This is consistent with Igor's observation that changing the predicate from IN (5) to IN (5,0) made the results ordered. So maybe the sort avoidance code is confusing the two columns for some reason. > SQL sorting error > ----------------- > > Key: DERBY-5933 > URL: https://issues.apache.org/jira/browse/DERBY-5933 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.0.2.1, 10.1.1.0, 10.2.1.6, 10.3.1.4, 10.4.1.3, > 10.5.1.1, 10.6.1.0, 10.7.1.1, 10.8.1.2, 10.9.1.0 > Environment: Windows 7 Netbeans JDBC GUI > Reporter: Vlasov Igor > Labels: derby_triage10_10 > Attachments: Helpdesk.zip, repro.sql, right_sorting.png, > wrong_sorting.png > > > Hello > I have a simple database with 100 records. > I am running a SQL query from Netbeans GUI though JDBC > This query was generated by Hibernate ORM. > In certain circumstances the result rowset is not sorting. > When I use condition morefld2_.mf_id in (5) the result is unsortable. > When I use condition morefld2_.mf_id in (5,0) the result is sorting properly. > > -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira