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

Kathey Marsden updated DERBY-3310:
----------------------------------

    Attachment: derby-3310_try1_diff.txt

Attached is my initial attempt at fixing this issue.  I am not quite sure this 
is the right approach.  The fix removes the line call setType on the underlying 
expressions from  copyTypesAndLengthsToSource, to avoid changing the type of 
the source column of VirtualColumnNodes.

I haven't been able to find any cases that this change affects adversely, but 
perhaps this is not the right approach.  Maybe the problem is that 
genNormalizeResultSetNode puts the VirtualColumnNodes in the normalized 
resultset in the first place.  Perhaps they should be CastNodes? 
Then perhaps copyTypesAndLengthsToSource wouldn't be necessary.
Anyway I would appreciate comments on the patch and possible alternatives.


Just for some historical background, I traced copyLengthsAndTypesToSource back 
to its origin.
It was put in to address a case that is no longer valid with Derby, but I'll 
put it here just in case it helps:

-- the following gets an exception trying to convert '11.4' to 
an integer
create table trash(c1 real check(c1 > 2));
insert into trash values '11.4';


Thanks 

Kathey




> ASSERT in MergeSort.checkColumnTypes() disallow legal type conversions
> ----------------------------------------------------------------------
>
>                 Key: DERBY-3310
>                 URL: https://issues.apache.org/jira/browse/DERBY-3310
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.4.0.0
>            Reporter: Dyre Tjeldvoll
>            Priority: Minor
>         Attachments: cast-repro.sql, derby-3310_try1_diff.txt
>
>
> The following code 
> CREATE TABLE U (SNAME VARCHAR(32000), TNAME VARCHAR(32000), C1 BIGINT);
> -- This triggers an ASSERT (because 2 is INTEGER and not BIGINT)
> INSERT INTO U(SNAME, TNAME, C1) SELECT DISTINCT SCHEMANAME, TABLENAME, 2
>  FROM SYS.SYSTABLES T JOIN SYS.SYSSCHEMAS S ON T.SCHEMAID = S.SCHEMAID;
> gives
> ERROR XJ001: Java exception: 'ASSERT FAILED col1.getClass() (class 
> org.apache.derby.iapi.types.SQLInteger) expected to be the same as 
> col2.getClass() (class org.apache.derby.iapi.types.SQLLongint): 
> org.apache.derby.shared.common.sanity.AssertFailure'.

-- 
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