Issue Details (XML | Word | Printable)

Key: CORE-2615
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Adriano dos Santos Fernandes
Reporter: Bill Oliver
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Silent truncation when using utf8 parameters and utf8 client character set encoding

Created: 03/Sep/09 08:21 AM   Updated: 04/Sep/09 05:44 AM
Return to search
Component/s: Charsets/Collation
Affects Version/s: 2.5 Beta 2
Fix Version/s: 2.5 RC1

Time Tracking:
Not Specified

File Attachments: 1. Text File utftest.cpp (10 kB)

Environment: all, found on solaris

Planning Status: Unspecified


 Description  « Hide
Inserting a too-long string value using an input parameter, with UTF8 client character set encoding, produces silent truncation. Should produce a truncation error. Confirmed by Adriano.

I'm connecting to database using client character set of UTF8. I have one
table, TEST, created like this:

CREATE TABLE test (c CHAR(10) CHARACTER SET UTF8);

I prepare this statement:

INSERT INTO test VALUES (?)

I attempt to insert a value of '012345679012345' into the column. There are
15 characters, so I expect a truncation error and no data inserted.

If I connect with client character set of NONE, I get the error, as I
expect.

If I connect with client character set of UTF8, then I get no error. But the
data *is* truncated. Why no error? That does not seem right, but maybe it is
something I forget to do??


Here is problem using encoding of UTF8

bb04s6401:/r/sanyo.unx.sas.com/vol/vol10/u101/bioliv> ./utftest UTF8

beginning test ./utftest..., encoding is UTF8

done!
bb04s6401:/r/sanyo.unx.sas.com/vol/vol10/u101/bioliv> isql fbtest.fdb
Database: fbtest.fdb
SQL> select * from test;

C
========================================
1234567890

SQL>



Here it is with encoding of NONE (no records are inserted)


bb04s6401:/r/sanyo.unx.sas.com/vol/vol10/u101/bioliv> ./utftest NONE

beginning test ./utftest..., encoding is NONE

arithmetic exception, numeric overflow, or string truncation
-string right truncation
bb04s6401:/r/sanyo.unx.sas.com/vol/vol10/u101/bioliv> isql fbtest.fdb
Database: fbtest.fdb
SQL> select * from test;
SQL>

To reproduce this, (1) create a database "fbtest.fdb" in current directory,
(2) create table test as above, (3) run "utftest UTF8" for UTF8 encoding,
and "utftest NONE" for NONE.

Here is my compilation line on S64

CC -g -m64 -I/u/bioliv/firebird2h1/gen/firebird/include
tftest.cpp -L$FIREBIRD/lib -lfbembed -o utftest


test case attached.


 All   Comments   Work Log   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Bill Oliver added a comment - 03/Sep/09 08:22 AM
test case demonstrating the problem