db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-5525) Precision for UPPER function is wrong if the returned value is longer than the literal argument
Date Thu, 08 Dec 2011 17:05:39 GMT

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

Knut Anders Hatlen commented on DERBY-5525:

Moving the constant folding earlier, so that it happens before the bind phase, seems to do
the trick:

ij> values upper('Straße');

1 row selected

Currently, constant folding happens in the beginning of the optimize phase. I vaguely recall
there was a reason to put it exactly there, but I don't remember now.

Even if constant folding would solve the case with a string literal argument, there's still
the general problem with "select ucase(a) from ...", mentioned by Rick. Unless we have some
knowledge about the locale that we could use to come up with a better estimate, I think we'll
have to set the precision to the maximum varchar length. (I also wonder what happens if we
have a string close to the maximum length, and converting it to upper case makes it longer
than the maximum length. Might run into problems similar to DERBY-4793.)
> Precision for UPPER function is wrong if the returned value is longer than the literal
> -----------------------------------------------------------------------------------------------
>                 Key: DERBY-5525
>                 URL: https://issues.apache.org/jira/browse/DERBY-5525
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions:
>            Reporter: Knut Anders Hatlen
> Seen in ij in a database with territory based collation and German locale:
> ij> VALUES UCASE('Straßenbahn');
> 1
> -----------
> 1 Zeile ausgewählt
> ==================================
> And with JDBC calls:
>     Connection c = DriverManager.getConnection(
>             "jdbc:derby:memory:db;create=true;territory=de_DE;" +
>             "collation=TERRITORY_BASED");
>     Statement s = c.createStatement();
>     ResultSet rs = s.executeQuery("values upper('Straße')");
>     System.out.println(rs.getMetaData().getPrecision(1));
>     rs.next();
>     System.out.println(rs.getString(1));
> This prints
> 6
> The precision is wrong, since the returned value is 7 characters long.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message