[ 
https://issues.apache.org/jira/browse/DERBY-4442?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dag H. Wanvik updated DERBY-4442:
---------------------------------

    Attachment: insert.diff

Thanks for trying the patch with the DERBY-4 patch. Here is a slightly
modified InsertNode.java which (with your patch + a modified
contribution from DERBY-4) which seems to work.

As you can see, I moved the ORDER BY pulling and binding to happen
before the enhancement (not a problem any longer since we can't sort a
VALUES in the insert context), and dropped the use of the column map.

ij> select * from t4;
I          |J          
-----------------------
1          |200        
2          |100        
3          |300

ij> insert into t3(i) select j from t4 order by j;
ij> select * from t3;
ID         |I          
-----------------------
34         |100        
35         |200        
36         |300        


> Evaluation of default value and identity in an INSERT result set evaluated 
> too early.
> -------------------------------------------------------------------------------------
>
>                 Key: DERBY-4442
>                 URL: https://issues.apache.org/jira/browse/DERBY-4442
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>            Reporter: Dag H. Wanvik
>         Attachments: always_prn.diff, insert.diff
>
>
> In contrast to generated column, which are evaluated when the next row from 
> the result set to be inserted, currently default values and identity columns 
> are generated "early", that is as part of avaluating the subquery (SELECT or 
> VALUES as the case may be). 
> This does not currently cause a user visible bug in Derby, but it lies behind 
> DERBY-3 and the effect Bryan observed in DERBY-4.
> Additionally, "early" computation has given rise to much special handling and 
> ensuing bugs, cf. DERBY-1644, DERBY-4413, DERBY-4419, DERBY-4425 and others.
> DERBY-4397 requires this fix for correct behaviour with INSERT.
> See also
> https://issues.apache.org/jira/browse/DERBY-4413?focusedCommentId=12769532&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_12769532

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to