pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
getObject(<oid>) returns integer instead of LargeObject handle ?
4+ messages / 3 participants
[nested] [flat]

* getObject(<oid>) returns integer instead of LargeObject handle ?
@ 2005-07-22 13:56  Marc Herbert <Marc.Herbert@emicnetworks.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Marc Herbert @ 2005-07-22 13:56 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

 Is there some good reason for getObject(<some oid column>) to return the
bare oid integer instead of the actual LargeObject handle ?

 I slightly modified the driver as below and it fixed my Blob issues
without any other side-effects. Would have some extensive testing
shown some problems I missed ?  Sorry for not being very familiar with
Postgres' oids.

Thanks in advance.

Cheers,

Marc.


inline patch 1: postgresql/jdbc2/TypeInfoCache.java (+1/-1 lines) download inline-1.patchIndex: postgresql/jdbc2/TypeInfoCache.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/TypeInfoCache.java,v retrieving revision 1.1 diff -u -r1.1 TypeInfoCache.java --- postgresql/jdbc2/TypeInfoCache.java 10 Apr 2005 21:54:16 -0000 1.1 +++ postgresql/jdbc2/TypeInfoCache.java 22 Jul 2005 13:45:35 -0000 @@ -51,7 +51,7 @@ private static Object types[][] = { {"int2", new Integer(Oid.INT2), new Integer(Types.SMALLINT), "java.lang.Short"}, {"int4", new Integer(Oid.INT4), new Integer(Types.INTEGER), "java.lang.Integer"}, - {"oid", new Integer(Oid.OID), new Integer(Types.INTEGER), "java.lang.Integer"}, + {"oid", new Integer(Oid.OID), new Integer(Types.BLOB), "java.sql.Blob"}, {"int8", new Integer(Oid.INT8), new Integer(Types.BIGINT), "java.lang.Long"}, {"money", new Integer(Oid.MONEY), new Integer(Types.DOUBLE), "java.lang.Double"}, {"numeric", new Integer(Oid.NUMERIC), new Integer(Types.NUMERIC), "java.math.BigDecimal"},
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: getObject(<oid>) returns integer instead of LargeObject
@ 2005-07-22 18:41  Kris Jurka <books@ejurka.com>
  parent: Marc Herbert <Marc.Herbert@emicnetworks.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Kris Jurka @ 2005-07-22 18:41 UTC (permalink / raw)
  To: Marc Herbert <Marc.Herbert@emicnetworks.com>; +Cc: pgsql-jdbc



On Fri, 22 Jul 2005, Marc Herbert wrote:

>  Is there some good reason for getObject(<some oid column>) to return the
> bare oid integer instead of the actual LargeObject handle ?

This makes the assumption that the only use of oids is for large objects.  
What if someone wrote SELECT oid,relname FROM pg_class?

Kris Jurka



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: getObject(<oid>) returns integer instead of LargeObject
@ 2005-07-26 10:20  Marc Herbert <Marc.Herbert@emicnetworks.com>
  parent: Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Marc Herbert @ 2005-07-26 10:20 UTC (permalink / raw)
  To: pgsql-jdbc

On Fri, Jul 22, 2005 at 01:41:19PM -0500, Kris Jurka wrote:
> 
> 
> On Fri, 22 Jul 2005, Marc Herbert wrote:
> 
> >  Is there some good reason for getObject(<some oid column>) to return the
> > bare oid integer instead of the actual LargeObject handle ?
> 
> This makes the assumption that the only use of oids is for large objects.  
> What if someone wrote SELECT oid,relname FROM pg_class?

Thanks for answering.

What would you recommend to unambiguously identify a Blob column in a
arbitrary ResultSet, using only JDBC?

For instance could you trust
Types.BLOB == rs.getMetaData.getColumnType() in every case?
Is there any other way?

Would it depend on the latest version of the driver/database?

Thanks in advance for you help!


PS: why do LOBs seem to use regular oids instead of some other less
ambiguous say, "loid" ?




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: getObject(<oid>) returns integer instead of LargeObject
@ 2005-07-26 10:42  Oliver Jowett <oliver@opencloud.com>
  parent: Marc Herbert <Marc.Herbert@emicnetworks.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Oliver Jowett @ 2005-07-26 10:42 UTC (permalink / raw)
  To: Marc Herbert <Marc.Herbert@emicnetworks.com>; +Cc: pgsql-jdbc

Marc Herbert wrote:

> What would you recommend to unambiguously identify a Blob column in a
> arbitrary ResultSet, using only JDBC?

I don't think there is any way to do this in general, via JDBC or any 
other interface; you need schema-specific knowledge to work out which 
oid columns refer to LOs and which refer to a different sort of oid 
somewhere else.

The actual LO interface itself just looks like "create LO" -> "ok, 
here's an oid identifying it"; there's nothing that ties the column you 
happen to use to store that oid to the LO itself. See 
http://www.postgresql.org/docs/8.0/static/largeobjects.html for more 
details.

For comparison, contrib/vacuumlo assumes that any (non-system-generated) 
oid column in the system could potentially reference a LO (in GC-speak 
it's a conservative collector).

> PS: why do LOBs seem to use regular oids instead of some other less
> ambiguous say, "loid" ?

It's just an artifact of the implementation AFAIK.

-O



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2005-07-26 10:42 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-22 13:56 getObject(<oid>) returns integer instead of LargeObject handle ? Marc Herbert <Marc.Herbert@emicnetworks.com>
2005-07-22 18:41 ` Re: getObject(<oid>) returns integer instead of LargeObject Kris Jurka <books@ejurka.com>
2005-07-26 10:20   ` Re: getObject(<oid>) returns integer instead of LargeObject Marc Herbert <Marc.Herbert@emicnetworks.com>
2005-07-26 10:42     ` Re: getObject(<oid>) returns integer instead of LargeObject Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox