db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "V.Narayanan" <V.Naraya...@Sun.COM>
Subject Re: [jira] Commented: (DERBY-796) jdbc 4.0 specific Blob and Clob method support
Date Wed, 15 Feb 2006 12:13:49 GMT
Since derby supports Blobs < 2G right now this causes no problems because
1) when pos <=0 it throws an error
2) when pos > MAX_INT it rolls around to a negative value and again 
throws an exception

since derby supports maximum size of 2G we should throw this exception 
so I will take your second approach.

Thank you for pointing this out
Narayanan

Andreas Korneliussen wrote On 02/15/06 17:01,:

>>       if ((int) pos <= 0) {
>>           throw new SqlException(agent_.logWriter_,
>>               new MessageId(SQLState.BLOB_BAD_POSITION), new Long(pos));
>>       }
>
>
> Is the casting of pos from long to int safe ? Consider the case if pos 
> is > Integer.MAXINT. Is it intentional that pos > Integer.MAXINT gives 
> this exception ?
>
> How about:
>
>  >       if (pos <= 0L) {
>  >           throw new SqlException(agent_.logWriter_,
>  >               new MessageId(SQLState.BLOB_BAD_POSITION), new 
> Long(pos));
>  >       }
>
> or if it is intentional to give an exception if pos is bigger than 
> Integer.MAXINT, one could write it more explicitly:
>
>  >       if (pos <= 0L || pos >= MAXPOS) {
>  >           throw new SqlException(agent_.logWriter_,
>  >               new MessageId(SQLState.BLOB_BAD_POSITION), new 
> Long(pos));
>  >       }
>
>
> Andreas
>

Mime
View raw message