SUBSTRING startposition < 1 should be allowed and handled as 1.
---------------------------------------------------------------

                 Key: CORE-5480
                 URL: http://tracker.firebirdsql.org/browse/CORE-5480
             Project: Firebird Core
          Issue Type: Bug
          Components: Engine
    Affects Versions: 3.0.1, 2.5.6
            Reporter: Mark Rotteveel


The following use of SUBSTRING is currently not allowed

select substring('abcdef' from 0) from rdb$database

It results in error "Invalid offset parameter -1 to SUBSTRING. Only positive 
integers are allowed."

However SQL:2011 says (6.30 <string value function>):

"""
3) If <character substring function> is specified, then:
[..]
b) Let C be the value of the <character value expression>, let LC be the length 
in characters of C, and let S be the value of the <start position>.
[..]
f) Case:
[..]
ii) Otherwise,
1) Let S1 be the larger of S and 1 (one). Let E1 be the smaller of E and LC+1. 
Let L1 be E1-S1.
2) The result of the <character substring function> is a character string 
containing the L1 characters of C starting at character number S1 in the same 
order that the characters appear in C.
"""

In other words, if <start position> < 1, then it should be handled as if it is 
1.

Test case:

select substring('abcdef' from 0) from rdb$database

Expected result: 'abcdef'

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to