Mark, CHAR_TO_UUID is a very special function as it declares how it wants to receive its parameter based in nothing else.
Now imagine this, when user connects with UTF-8: select char_length(?) from rdb$database; That is not valid because the parameter has no type, but suppose it's valid. Now imagine the client passing this: SQL_TEXT length: 40 charset: utf-8 data: 1234567890<30 spaces> What char_length should return? That is the architectural problem. It's what I tried in r62766. I'd want to divide 40 by 4 (max length of a single utf-8 character) and then the char_length would be 10. That's how things works internally. But seems IBExpert and libraries thinks different. They may pass this: SQL_TEXT length: 10 charset: utf-8 data: 1234567890 And wants this to have a char_length of 10 as well. Who is correct? Nobody knows, it's not intuitive in both ways. And as I said, CHAR_TO_UUID is something special. Imagine the parameter is passed for a procedure procedure p(c char(10) character set ascii) ... The procedure receives C as it's declared. But that doesn't happen with system functions. System functions just say I would like to receive my parameter as that (Is this good or bad? For now, I don't know). CHAR_TO_UUID says: CHAR(36) CHARACTER SET ASCII But since the user connected with UTF-8, it become: SQL_TEXT length: 144 (36 * 4) When it enters in evlCharToUuid, it's data, just 144 bytes in UTF-8 that we don't know how to interpret. Now about your chr(0) thing, and TEXT UUID in OCTETS, makes no sense. And that commands validates the way I did to check only spaces in a string pretended to be in ASCII: select char_length(trim(cast(_octets '123' || ascii_char(0) as varchar(50) character set ascii))) from rdb$database; returns 4 And: SQL> select char_length(trim(cast(_octets '123' || ascii_char(0) as varchar(3) character set ascii))) from rdb$database; CHAR_LENGTH ============ Statement failed, SQLSTATE = 22001 arithmetic exception, numeric overflow, or string truncation -string right truncation -expected length 3, actual 4 So basically, the code now in evlCharToUuid is asking to convert the user string to a CHAR(36) ASCII, not with the standard convert (slow) way, but just checking it. Adriano ------------------------------------------------------------------------------ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel