db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-3341) TABLE FUNCTION returning CHAR values does not return a correct value if the Java ResultSet class returns a value less than the length of the defined CHAR.
Date Mon, 03 Mar 2008 18:54:50 GMT

    [ https://issues.apache.org/jira/browse/DERBY-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574666#action_12574666
] 

Rick Hillegas commented on DERBY-3341:
--------------------------------------

The bind tree looks correct to me. The compiler has the correct understanding of what SQL
types are supposed to correspond to the columns in the user-coded ResultSet. From one point
of view, you could say that the problem is that the user has lied: At DDL time the user declared
that a string column in a table function has a maximum length, but the actual user-coded implementation
of the ResultSet does not obey this contract. I think that, technically, the behavior is undefined
right now because ANSI does not have rules about what happens if a Derby-style table function
returns an oversized string.

The current behavior is unattractive. We are free to define what we think the correct behavior
should be--and then we should document that correct behavior. One approach would be to throw
a SQLException if the ResultSet does not fulfill the declared contract. However, I think that
silently truncating oversized strings would be more useful. The current proposal seems fine:

If the customer declares that a string column in a Table Function has a maximum length, and
the underlying user-coded ResultSet returns oversized strings, then Derby should silently
truncate those strings to the declared maximum length by chopping off trailing characters.

> TABLE FUNCTION returning CHAR values does not return a correct value if the Java ResultSet
class returns a value less than the length of the defined CHAR.
> ----------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3341
>                 URL: https://issues.apache.org/jira/browse/DERBY-3341
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>            Reporter: Daniel John Debrunner
>             Fix For: 10.4.0.0
>
>         Attachments: derby_3341_test.txt
>
>
> Defining a column in the returned type as CHAR(10) requires that the returned value be
of length 10 characters.
> Defining a table function with a return type of:
>    returns TABLE  column0 char( 10 ), column1 char( 10 ))
> seems to just return whatever the Java ResultSet implementation handed it.
> My guess this is true for all variable length types, no casting of the value occurs when
it is returned to the SQL domain.
> Java single value functions and procedure out parameters do perform any required casting
to ensure the value is of the declared type.

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


Mime
View raw message