New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIMILAR TO can raise 'INVALID PATTERN' when 1) connection charset = UTF8 and console is narrow one (dos866 or win1251) and 2) running two separate statements without COMMIT between them [CORE4749] #5054
Comments
Commented by: Sean Leyne (seanleyne) There are several aspects of this case which trouble me: 1- The OS is XP. I realize that this OS is commonly used in some markets, but IMO the project should only be working on/testing against OS which are still supported by MS. Would like to see this case reproduced with later OS. 2- It seems inconsistent for us to be concerned about such an extreme example where their is no attempt at consistent charset environment (i.e. the charset most have some consistency). |
Commented by: @asfernandes Pavel, please replace your two: select substring( 'eiavieieav' similar '%\"(ie){2,}\"%' escape '\' ) from rdb$database; by: select cast('eiavieieav' as varchar(10) character set octets), cast('%\"(ie){2,}\"%' as varchar(14) character set octets) from rdb$database; And put here the results. |
Commented by: @pavel-zotov Console charset = win1251. I do the following: C:\MIX\firebird\QA\fbt-repo\tmp>C:\MIX\firebird\fb30\isql.exe localhost/3330:e30 -ch utf8 CAST CAST -- PS. Check database default charset: RDB$CHARACTER_SET_NAME UTF8 |
Commented by: @asfernandes Same as for me. And I cannot reproduce the "Invalid SIMILAR TO pattern" error. |
Commented by: @pavel-zotov > I cannot reproduce the "Invalid SIMILAR TO pattern" error. I still can, do it running TEST-2 from start post, and also trying like this: C:\MIX\firebird\QA\fbt-repo\tmp>isql E30.fdb -n -ch utf8 SUBSTRINGStatement failed, SQLSTATE = 42000 SQL> select substring( cast('aaxyaaxyaaaaxyaaaxyaa' as varchar(50) character set octets) similar cast('%\"(aaxy|aaax){2,}\"%' as varch SUBSTRINGStatement failed, SQLSTATE = 42000 |
Commented by: @asfernandes What if you save this command to a file encoded in DOS866 and load it with "input" in isql? |
Commented by: @pavel-zotov Adriano, I've done following: CHECK-1.1) created SQL script "tmp-c4749-dos866.sql" with following lines: -- set names dos866; -- works FINE 2) run cmd.exe and verified result of CHCP command - it is 866 on my machine. 3.1) opened file tmp-c4749-dos866.sql and UNCOMMENTED line #1: `set names dos866;` C:\MIX\firebird\QA\fbt-repo\tmp>C:\MIX\firebird\fb30\isql -q -i tmp-c4749-dos866.sql Result: works fine. Output:
|
Submitted by: @pavel-zotov
OS: Windows XP
Console charset: DOS866
Database charset: NONE
Connection charset: UTF8 (should be dos866 but was occasionally selected = UTF8)
TEST-1: verify results of old good `SIMILAR TO` rather than `SUBSTRING( ... SIMILAR ... )`:
C:\MIX\firebird\QA\fbt-repo\tmp>C:\MIX\firebird\fb30\isql.exe localhost/3333:e30 -ch utf8
Database: localhost/3333:e30
SQL> select iif( 'aaxyaaxyaaaaxyaaaxyaa' similar to '%(aaxy|aaax){2,}%', 1, 0 ) is_matching from rdb$database;
IS_MATCHING
SQL> select iif( 'eiavieieav' similar to '%(ie){2,}%', 1, 0 ) is_matching from rdb$database;
IS_MATCHING
// OK
TEST-2: verify results of `SUBSTRING( ... SIMILAR ...)` with the same arguments:
C:\MIX\firebird\QA\fbt-repo\tmp>C:\MIX\firebird\fb30\isql.exe localhost/3333:e30 -ch utf8
Database: localhost/3333:e30
SQL> select substring( 'aaxyaaxyaaaaxyaaaxyaa' similar '%\"(aaxy|aaax){2,}\"%' escape '\' ) from rdb$database;
SUBSTRING
aaxyaaxy
SQL> select substring( 'eiavieieav' similar '%\"(ie){2,}\"%' escape '\' ) from rdb$database;
SUBSTRING
Statement failed, SQLSTATE = 42000
Invalid SIMILAR TO pattern
TEST-3: same as test-2 but note that between two statements `COMMIT;` present:
C:\MIX\firebird\QA\fbt-repo\tmp>C:\MIX\firebird\fb30\isql.exe localhost/3333:e30 -ch utf8
Database: localhost/3333:e30
SQL> select substring( 'aaxyaaxyaaaaxyaaaxyaa' similar '%\"(aaxy|aaax){2,}\"%' escape '\' ) from rdb$database;
SUBSTRING
aaxyaaxy
SQL> commit; ------------------------------------ <<<<<<<<<<< !! <<<<<<<<<<<<<<
SQL>
SQL> select substring( 'eiavieieav' similar '%\"(ie){2,}\"%' escape '\' ) from rdb$database;
SUBSTRING
ieie
No error.
Q-1: If test-2 failed because of mismatch charset of console and connection then message should be more relevant (may be 'malformed string') - ?
Q-2: Why issuing of `COMMIT;` in test-3 solved this trouble ?
The text was updated successfully, but these errors were encountered: