SIMILAR TO does not return result when invalid pattern is used (with two 
adjacent special characters that should be escaped but aren't)
---------------------------------------------------------------------------------------------------------------------------------------

                 Key: CORE-5931
                 URL: http://tracker.firebirdsql.org/browse/CORE-5931
             Project: Firebird Core
          Issue Type: Bug
    Affects Versions: 3.0.3, 2.5.8, 4.0 Alpha 1
            Reporter: Pavel Zotov
         Attachments: difference-on-patterns-that-leads-to-POOR-SIMILAR-TO.png, 
firebird_1820.20181001_012003.stack_trc.txt.7z, 
firebird_1820.20181001_012034.stack_trc.txt.7z

(yes, i know about tickets CORE-3858, CORE-4893 & CORE-5664 that also relate to 
SIMILAR TO performance; perhaps this new sample can help to solve them so i 
decided to create separate ticket).

Consider following command:

set count on;
set list on;
select 1 from rdb$database where
'
group by
f01,
f02,
f03,
f04,
f05,
f06,
f07,
f08,
f09,
f10,
f11,
f12,
f13,
'
    similar to
'%group[[:WHITESPACE:]]+by[[:WHITESPACE:]]+([[:ALNUM:]])+([[:WHITESPACE:]]*,[[:WHITESPACE:]]*[[:ALNUM:]]+){12,}[[:WHITESPACE:]]*%'
;

It will issue result instantly:
===
CONSTANT                        1

Records affected: 1
===

Now let change pattern by adding characters "|" and "_" (PIPE and UNDERSCORE) 
after 1st ALNUM, but with missed escaping (and this means that pattern will be 
INVALID):

select 1 from rdb$database where
'
group by
f01,
f02,
f03,
f04,
f05,
f06,
f07,
f08,
f09,
f10,
f11,
f12,
f13
'
    similar to
'%group[[:WHITESPACE:]]+by[[:WHITESPACE:]]+([[:ALNUM:]]|_)+([[:WHITESPACE:]]*,[[:WHITESPACE:]]*[[:ALNUM:]]+){12,}[[:WHITESPACE:]]*%'
;


This statement will HANGS on 2.5, 3.0 and 4.0.
Difference between patterns - see in attached .pgn
Two stack traces (for WI-V3.0.4.33054 ) are also attached.

NB: This trouble with SIMILAR TO seems to be CRITICAL: no new attachment can be 
established while engine "does something inside itself" while working with 
parsing such statement!




-- 
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

        


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to