Lists: | pgsql-jdbc |
---|
From: | Marc Herbert <Marc(dot)Herbert(at)emicnetworks(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | getObject(<oid>) returns integer instead of LargeObject handle ? |
Date: | 2005-07-22 13:56:40 |
Message-ID: | 20050722135640.GM7394@emicnetworks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | 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.
Index: 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"},
From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Marc Herbert <Marc(dot)Herbert(at)emicnetworks(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: getObject(<oid>) returns integer instead of LargeObject |
Date: | 2005-07-22 18:41:19 |
Message-ID: | Pine.BSO.4.56.0507221340260.3242@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | 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
From: | Marc Herbert <Marc(dot)Herbert(at)emicnetworks(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: getObject(<oid>) returns integer instead of LargeObject |
Date: | 2005-07-26 10:20:09 |
Message-ID: | 20050726102009.GB17905@emicnetworks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | 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" ?
From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | Marc Herbert <Marc(dot)Herbert(at)emicnetworks(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: getObject(<oid>) returns integer instead of LargeObject |
Date: | 2005-07-26 10:42:26 |
Message-ID: | 42E61392.8030005@opencloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | 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