Unix Technical Forum

Blob .getBytes position should start at 1

This is a discussion on Blob .getBytes position should start at 1 within the Pgsql Patches forums, part of the PostgreSQL category; --> From the Javadoc of java.sql.Blob byte[] getBytes(long pos, int length) throws SQLException; * @param pos the ordinal position of ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 12:17 AM
Emmanuel Bernard
 
Posts: n/a
Default Blob .getBytes position should start at 1

From the Javadoc of java.sql.Blob byte[] getBytes(long pos, int length)
throws SQLException;

* @param pos the ordinal position of the first byte in the
* <code>BLOB</code> value to be extracted; the first byte is at
* position 1

pqsql driver assumes the position starts from 0

Patch attached

--
Emmanuel Bernard
http://www.hibernate.org
callto://emmanuelbernard

Index: org/postgresql/jdbc2/AbstractJdbc2BlobClob.java
================================================== =================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2BlobClob.java,v
retrieving revision 1.1
diff -u -r1.1 AbstractJdbc2BlobClob.java
--- org/postgresql/jdbc2/AbstractJdbc2BlobClob.java 28 Mar 2005 08:52:35 -0000 1.1
+++ org/postgresql/jdbc2/AbstractJdbc2BlobClob.java 6 May 2005 09:59:42 -0000
@@ -46,7 +46,8 @@

public byte[] getBytes(long pos, int length) throws SQLException
{
- lo.seek((int)pos, LargeObject.SEEK_SET);
+ //throw an appropriate exception if pos < 1
+ lo.seek((int)pos-1, LargeObject.SEEK_SET);
return lo.read(length);
}



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 12:18 AM
Kris Jurka
 
Posts: n/a
Default Re: Blob .getBytes position should start at 1



On Fri, 6 May 2005, Emmanuel Bernard wrote:

> From the Javadoc of java.sql.Blob byte[] getBytes(long pos, int length)
> throws SQLException;
>
> * @param pos the ordinal position of the first byte in the
> * <code>BLOB</code> value to be extracted; the first byte is at
> * position 1
>
> pqsql driver assumes the position starts from 0
>


Indeed. I've put a fix in 7.4, 8.0, and HEAD branches.

Thanks.

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:55 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com