Subject Re: Problem with field length
Author haug22
--- In ib-support@y..., Helen Borrie <helebor@d...> wrote:
> At 11:09 AM 11-12-01 +0100, you wrote:
> >Hi
> >
> >I have a table where I declare a char(10) field and then in an insert
> >statement I insert a string which is to long (maybe 30 chars).
Surprisingly
> >this works fine. Also when I do a select in isql on this table I am
getting
> >the whole string and not just the first 10 chars. But if I do a select
> >using interclient I am getting an exception:
> >
> >SQL error code = -303
> >arithmetic exception, numeric overflow, or string truncation
> >
> >Here is the script I am using to reproduce this behavior:
> >
> > CREATE DATABASE 'db:/dbs/error.gdb'
> > DEFAULT CHARACTER SET UNICODE_FSS;
> >
> > create table test(
> > text CHAR(10) <-- this column has 30 bytes
> > );
> >
> > insert into test VALUES('This text is much too long');
>
>
>
>
> Just for interest, try
> insert into test VALUES(_UNICODE_FSS'This text is much too long');
>
> I think this should throw an error, even in 0.9.4.
>

It does not throw an error.
Could someone try the same with FB 1 RC 1?

>
> > Exit;
> >
> >the Java code looks like this:
> >
> > database.setConnection(new
com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:interbase://db/dbs/error.gdb",
"sysdba", null, true,
> >"interbase.interclient.Driver"));
> > database.setDatabaseName("");
> > Statement statement = database.createStatement();
> > try {
> > ResultSet results = statement.executeQuery("select text from
test"); // the exception happens here
> > statement.close();
> > }
> > catch (Exception ex) {ex.printStackTrace();}
> > }
> >
> >I am using Firebird super server on Linux.
> >The version of firebird is 0.9-4 Firebird Test1.
> >Interserver is running on the same box
> >JDK: 1.3.0-C
> >
> >Too me this look like a bug. What I expect would either be an error
while
> >executing the insert statement or a truncation of the inserted
string, but
> >never an exception on a select statement. This would case invalid
data to
> >be inserted into the DB and then it breaks the application and
maybe even
> >the DB get inconsistent?
> >
> >Is this addressed in Firebird 1 RC1?
>
> That's a very old beta you have there...I seem to recall that
Claudio fixed something in DSQL (a long time ago), so that the length
in characters would be read, rather than the length in bytes.

Yes, it's old, but I've got three production servers out there running
it, so an update takes quite some time and organisation...

I though, it interprets CHAR(30) like a field that can hold up to 30
bytes, which would -- in worst case -- lead to 15 unicode chars that
the field can hold. In our case it is very unlikely to have unicode
chars in the field and if it does, only one or two...

Herbert