Bug 126262 - FIREBIRD: Query with LIKE doesn't work with special characters
Summary: FIREBIRD: Query with LIKE doesn't work with special characters
Status: RESOLVED NOTOURBUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
6.2.5.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-07 07:47 UTC by Robert Großkopf
Modified: 2021-12-21 16:32 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Try the query with a special character - won't work (86.28 KB, application/vnd.oasis.opendocument.database)
2019-07-07 07:47 UTC, Robert Großkopf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Großkopf 2019-07-07 07:47:49 UTC
Created attachment 152611 [details]
Try the query with a special character - won't work

Open the attached database.
open the query.
Input 'e' as parameter.
Query will work.
Now input something like 'ä' or 'ö' or some special characters of your language.
The query won't work.
An error appears:
*Malformed String

This is the query:
SELECT "ID", "Forename", "Surname" FROM "Table1" WHERE "ID" LIKE '%' || :search || '%' OR "Forename" LIKE '%' || :search || '%' OR "Surname" LIKE '%' || :search || '%'
Field "ID" is INTEGER. Without searching "ID" it will work. LIKE works with every field-type (DATE, number-fields ...) if the content hasn't special characters. LIKE won't work with special characters in filed-types, which aren't fields for characters.
Queries like the query above will work well in internal HSQLDB with special characters.

My system: LO 6.2.5.2 on OpenSUSE 15 64bit rpm Linux
Comment 1 Alex Thurgood 2019-07-18 07:52:43 UTC
Confirmed with

Version: 6.4.0.0.alpha0+
Build ID: 75d35ef8df1936dd93d5919b688abcaddb58bee8
CPU threads: 4; OS: Mac OS X 10.14.5; UI render: default; VCL: osx; 
Locale: fr-FR (fr_FR.UTF-8); UI-Language: en-US
Calc: threaded
Comment 2 Robert Großkopf 2019-07-20 06:50:42 UTC
Have tested it with LO 6.3.0.2 now. The query doesn't work, but the errorcode has been changed:

Error LO 6.3.0.2 →

firebird_sdbc error:
*arithmetic exception, numeric overflow, or string truncation
*Cannot transliterate character between character sets
caused by
'isc_dsql_fetch'

Error LO 6.2.5.2 →

firebird_sdbc error:
*Malformed string
caused by
'isc_dsql_fetch' 

Tested with OpenSUSE 15 64bit rpm Linux.
Comment 3 QA Administrators 2021-07-20 03:38:08 UTC Comment hidden (obsolete)
Comment 4 Robert Großkopf 2021-07-23 15:38:53 UTC
Bug is still the same with LO 7.2.0.1 on OpenSUSE 15.2 64bit rpm Linux.
Comment 5 Julien Nabet 2021-12-21 12:22:21 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.
It's indeed related to ID part since it works for the rest.

I also noticed I could reproduce this too when using "Execute SQL statement" with or without "Run SQL command directly" enabled.
Just wonder if it could be Firebird bug?
Comment 6 Lionel Elie Mamane 2021-12-21 12:37:15 UTC
Looks like a character encoding issue. Try aligning the character set of the column / database and the one of the connection?
Comment 7 Julien Nabet 2021-12-21 12:41:44 UTC
(In reply to Lionel Elie Mamane from comment #6)
> Looks like a character encoding issue. Try aligning the character set of the
> column / database and the one of the connection?

SELECT a.RDB$CHARACTER_SET_NAME FROM RDB$DATABASE a
returns UTF8
For column, I don't know what's the SQL command.

Again, it works with Forename and Surname, just fails with ID.
Perhaps converting UTF8 from ASCII part into INTEGER is ok but not UTF8 from outside ASCII?
Comment 8 Lionel Elie Mamane 2021-12-21 13:33:03 UTC
(In reply to Julien Nabet from comment #7)
> Again, it works with Forename and Surname, just fails with ID.
> Perhaps converting UTF8 from ASCII part into INTEGER is ok but not UTF8 from
> outside ASCII?

Ah, I had missed that the problem is with an INTEGER variable. Try something like

 CAST("ID" AS VARCHAR CHARACTER SET utf8) LIKE '%'
Comment 9 Julien Nabet 2021-12-21 13:47:26 UTC
(In reply to Lionel Elie Mamane from comment #8)
> (In reply to Julien Nabet from comment #7)
> > Again, it works with Forename and Surname, just fails with ID.
> > Perhaps converting UTF8 from ASCII part into INTEGER is ok but not UTF8 from
> > outside ASCII?
> 
> Ah, I had missed that the problem is with an INTEGER variable. Try something
> like
> 
>  CAST("ID" AS VARCHAR CHARACTER SET utf8) LIKE '%'

This:
SELECT "ID", "Forename", "Surname" FROM "Table1" WHERE CAST("ID" AS VARCHAR(10) CHARACTER SET utf8) LIKE '%é%'
worked indeed in running direct SQL!
VARCHAR(10) or whatever not just "VARCHAR".

Putting it in the query adds quotes to UTF8
and so it becomes:
SELECT "ID", "Forename", "Surname" FROM "Table1" WHERE CAST( "ID" AS VARCHAR ( 10 ) CHARACTER SET "UTF8" ) LIKE '%' || :search || '%' OR "Forename" LIKE '%' || :search || '%' OR "Surname" LIKE '%' || :search || '%'

but it worked too.
Comment 10 Julien Nabet 2021-12-21 15:08:23 UTC
IMHO perhaps we could consider this one as NOTABUG our NOTOURBUG?

Robert/Lionel: what do you think?