The SQLdb framework has the same problem. I've made a workaround when firebird TField requires UTF-8 to devide the fieldsize with 4.
The real problem relies on writing back to a table. If your fieldsize on Lazarus is 12 and your charsize is 3, an error occurred. The modifications can't be saved
There is however a difference - when you create the TField object for such a firebird field, TIBConnection will create it with Size and DisplayWidth of 12. IBX for lazarus, on the other hand, will create the field with the correct Size and DisplayWidth of 3. And then, both of them will actually return the data in the AsString property as up to 12, padded with spaces to the length of 12 bytes.You have highlighted an interesting problem with Firebird CHAR types versus VARCHAR types.
Yes! It seems this really has been fixed in FPC 3.2. I will probably re-create my datasets and fields just to be sure that everything is OK now.Well, actually I had to recreate the fields, otherwise strange things started happening - AVs and all that. So it would really have been nice if there were some documentation about the [breaking] changes to the FCL packages with the new FPC version. A quick look showed there were really quite some changes to both IBConnection.pp and Fields.inc, didn't look at others.
... and I'll make that change for the next release.Any idea when that next release will be? Or any chance to to preview and test the changes before that?
Now, how could I have known that? I couldn't find anything about the changes in FCL in the FPC 3.2 release notes. Are these documented somewhere separately?
No formal release planned at present. However, you can always access up-to-date fixes at... and I'll make that change for the next release.Any idea when that next release will be? Or any chance to to preview and test the changes before that?
I had a look at the updates, especially FBIntf, but I fail to understand the approach.My mistake. I had it in my head that Firebird returned the character width rather than the byte length in the column metadata. Testing then gave the result I expected rather what I should have expected.
The way I see it, if I have a field defined in the database as CHAR(8), I should get always a string of 8 characters. If the connection charset is UTF8, then UTF8Length(AsString) should be 8.
The released version used to trim these char values, so value of '123' had length 3. Now with the changes, value of '123' in the field produces a string with Length/UTF8Length of 32 - padded with spaces.
Am I missing something?
I now have another question - is there a specific reason why IBQuery parameters are not created when the SQL text is changed at runtime? (IBQuery, lines 240-244)TIBQuery was modified in January 2016 (looking back over the svn revision logs) to change the run time behaviour so that if the SQL was updated, the params were re-created after the statement was prepared rather than as soon as the statement was updated. If you change the SQL at run time, you thus have to call TIBQuery.Prepare before setting any parameter values. I do not have a note of why this change was made, however, the changelog does record:
Complete ignorance. In a database (storage) the UTF8 really needs to store four bytes.Correct. That is what Firebird does. The issue under discussion is the byte length of a Pascal AnsiString.
Do you have a specific problem in mind as a result of the change?No.