[
https://issues.apache.org/jira/browse/DERBY-5525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13166145#comment-13166145
]
Knut Anders Hatlen commented on DERBY-5525:
-------------------------------------------
My reading of the standard is that UPPER('Straße') should return
'STRASS' and give a truncation warning. I'm basing this on section
6.29 <string value function>:
> Syntax Rules:
>
> 8) If <fold> is specified, then the declared type of the result of
> <fold> is that of the <character value expression>.
The <character value expression> is 'Straße', which has the declared
type CHAR(6) (see 5.3 <literal>, syntax rule 13, which defines the
declared type of a character string literal). This means that the
declared type of the result of <fold> is also CHAR(6).
Furthermore, general rule 6) c) says:
> Let FRML be the length or maximum length in characters of the
> declared type of <fold>.
Since the declared type of <fold> is CHAR(6), FRML must be 6.
Finally, general rule 6) g) ii), mentioned by Dag, says:
> If FRL is greater than FRML, then the result of the <fold> is the
> first FRML characters of FR with length FRML. If any of the
> right-most (FRL – FRML) characters of FR are not <space> characters,
> then a completion condition is raised: warning — string data, right
> truncation.
FRL is the character length of the upper-case representation (which is
7), which is greater than FRML (which is 6). So this rule says that we
should return the first 6 characters of the upper-case representation,
that is 'STRASS', and raise a warning because the removed character is
not a space.
> Precision for UPPER function is wrong if the returned value is longer than
> the literal argument
> -----------------------------------------------------------------------------------------------
>
> Key: DERBY-5525
> URL: https://issues.apache.org/jira/browse/DERBY-5525
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.8.2.2
> Reporter: Knut Anders Hatlen
>
> Seen in ij in a database with territory based collation and German locale:
> ==vv= COPIED FROM IJ CONSOLE =vv==
> ij> VALUES UCASE('Straßenbahn');
> 1
> -----------
> STRASSENBA&
> 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
> STRASSE
> 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