I just looked at the git commit, iirc the implementation assumed start to be
zero-based (I believe in parse.y 1 is subtracted from the start to match that
expectation), in your implementation on 10350 in ExprNodes you set sStart to 1,
that should be 0, if I'm not mistaken.
Mark
----- Bericht beantwoorden -----
Van: "Adriano dos Santos Fernandes (JIRA)" <trac...@firebirdsql.org>
Aan: <m...@lawinegevaar.nl>
Onderwerp: [FB-Tracker] Resolved: (CORE-5480) SUBSTRING startposition smaller
than 1 should be allowed
Datum: wo, mrt. 1, 2017 17:20
[
http://tracker.firebirdsql.org/browse/CORE-5480?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Adriano dos Santos Fernandes resolved CORE-5480.
------------------------------------------------
Fix Version/s: 4.0 Beta 1
Resolution: Fixed
> SUBSTRING startposition smaller than 1 should be allowed
> --------------------------------------------------------
>
> Key: CORE-5480
> URL: http://tracker.firebirdsql.org/browse/CORE-5480
> Project: Firebird Core
> Issue Type: Bug
> Components: Engine
> Affects Versions: 2.5.6, 3.0.1
> Reporter: Mark Rotteveel
> Assignee: Adriano dos Santos Fernandes
> Fix For: 4.0 Beta 1
>
>
> 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>.
> c) If <string length> is specified, then let L be the value of <string
> length> and let E be S+L. Otherwise, let E be the larger of LC + 1 and S.
> [..]
> e) If E is less than S, then an exception condition is raised: data exception
> — substring error.
> f) Case:
> i) If S is greater than LC or if E is less than 1 (one), then the result of
> the <character substring function> is a zero-length string.
> 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 a <start position> < 1 it should still be allowed, and
> should be taken into account for determining the end of string value.
> Test cases:
> select substring('abcdef' from 0) from rdb$database
> Expected result: 'abcdef'
> select substring('abcdef' from 0 for 2) from rdb$database
> Expected result: 'a' (and NOT 'ab')
> select substring('abcdef' from -5 for 2) from rdb$database
> Expected result: ''
--
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