Unix Technical Forum

reading an oidvector field error

This is a discussion on reading an oidvector field error within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hi: I need to read from the database a oidvector field, I'm using this code snipped to do this: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 11:52 PM
Takeichi Kanzaki Cabrera
 
Posts: n/a
Default reading an oidvector field error

Hi:
I need to read from the database a oidvector field, I'm using this
code snipped to do this:

Array argsList = rsFunc.getArray("field");
ResultSet rsArgs = argsList.getResultSet();
while (rsArgs.next()) {
String s = rsArgs.getInt(2); //get an error here.
PgDataType type = this.getDataType(s);
args.add(type);
}
rsFunc: is the ResultSet to read the data.
argsList: is and java.sql.Array.

but I get an error of execution time on the line signed, I'm check the
driver source code and I find that this kind of vector is not
supported and I can't change the data type of the field.
Could some one help me to solve this.

--
My regards,
Takeichi Kanzaki Cabrera
Profesor of Computer Programming Techniques and Database Systems
University of Holguin
Cuba

---------------------------(end of broadcast)---------------------------
TIP 1: 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
  #2 (permalink)  
Old 04-15-2008, 11:52 PM
Oliver Jowett
 
Posts: n/a
Default Re: reading an oidvector field error

Takeichi Kanzaki Cabrera wrote:

> but I get an error of execution time on the line signed,


What is the exact error that you get?

-O

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 11:52 PM
Takeichi Kanzaki Cabrera
 
Posts: n/a
Default Re: reading an oidvector field error

Here is the exception and the stack trace that I get:
org.postgresql.util.PSQLException: Method
org.postgresql.jdbc3.Jdbc3Array.getArrayImpl(long, int,Map) is not yet
implemented.
at org.postgresql.Driver.notImplemented(Driver.java:5 80)
at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayIm pl(AbstractJdbc2Array.java:232)
at org.postgresql.jdbc2.AbstractJdbc2Array.getResultS etImpl(AbstractJdbc2Array.java:291)
at org.postgresql.jdbc2.AbstractJdbc2Array.getResultS et(AbstractJdbc2Array.java:252)
at pgObjects.PgDatabase.loadFunctionsFromDatabase(PgD atabase.java:893)
at test.Test.showFunctions(Test.java:134)
at test.Test.main(Test.java:166)

Takeichi.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-15-2008, 11:52 PM
Oliver Jowett
 
Posts: n/a
Default Re: reading an oidvector field error

Takeichi Kanzaki Cabrera wrote:
> Here is the exception and the stack trace that I get:
> org.postgresql.util.PSQLException: Method
> org.postgresql.jdbc3.Jdbc3Array.getArrayImpl(long, int,Map) is not yet
> implemented.
> at org.postgresql.Driver.notImplemented(Driver.java:5 80)
> at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayIm pl(AbstractJdbc2Array.java:232)
> at org.postgresql.jdbc2.AbstractJdbc2Array.getResultS etImpl(AbstractJdbc2Array.java:291)
> at org.postgresql.jdbc2.AbstractJdbc2Array.getResultS et(AbstractJdbc2Array.java:252)
> at pgObjects.PgDatabase.loadFunctionsFromDatabase(PgD atabase.java:893)


This stacktrace doesn't match the line in your code you claim throws an
exception. You originally said:

> Array argsList = rsFunc.getArray("field");
> ResultSet rsArgs = argsList.getResultSet();
> while (rsArgs.next()) {
> String s = rsArgs.getInt(2); //get an error here.
> PgDataType type = this.getDataType(s);
> args.add(type);
> }


but the code path your stacktrace shows is throwing an exception on
getResultSet().

Can you clarify what the code that actually causes the error is?

However the most likely cause is that the array code just does not
understand the OID type -- there is this code in getArrayImpl when an
unsupported array element type is encountered:

>> default:
>> if (conn.getLogger().logDebug())
>> conn.getLogger().debug("getArrayImpl(long,int,Map) with "+getBaseTypeName());
>> throw org.postgresql.Driver.notImplemented(this.getClass (), "getArrayImpl(long,int,Map)");


(this should really throw a more informative exception..)

You could use getString() and parse the array representation yourself as
a workaround, or teach the driver's array code about oids.

-O

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-15-2008, 11:52 PM
Tom Lane
 
Posts: n/a
Default Re: reading an oidvector field error

Oliver Jowett <oliver@opencloud.com> writes:
> However the most likely cause is that the array code just does not
> understand the OID type -- there is this code in getArrayImpl when an
> unsupported array element type is encountered:


Another problem is that oidvector is not the same as oid[] --- for what
are now entirely historical reasons, they have different external
representations, which is certainly going to confuse any client-side
code trying to parse the data. You'd really need some single-purpose
code in the driver to handle oidvector at all.

In very recent PG releases, you could cast oidvector to oid[] (or maybe
better int8[]) in your query, but unless the JDBC array code copes with
nondefault subscripts, it'll still have trouble:

regression=# select '1 2 3':idvector::int8[];
int8
---------------
[0:2]={1,2,3}
(1 row)

regression=#

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-15-2008, 11:53 PM
Kris Jurka
 
Posts: n/a
Default Re: reading an oidvector field error



On Mon, 16 Jan 2006, Tom Lane wrote:

> In very recent PG releases, you could cast oidvector to oid[] (or maybe
> better int8[]) in your query, but unless the JDBC array code copes with
> nondefault subscripts, it'll still have trouble:
>


The JDBC array code throws away nondefault subscripts because the JDBC
spec says that all arrays are 1-indexed. For the most part people don't
want non-default subscripts and only get them via prepending operations
that they didn't expect to alter the indexing (of course these are now
gone in 8.2).

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-15-2008, 11:53 PM
Tom Lane
 
Posts: n/a
Default Re: reading an oidvector field error

Kris Jurka <books@ejurka.com> writes:
> On Mon, 16 Jan 2006, Tom Lane wrote:
>> In very recent PG releases, you could cast oidvector to oid[] (or maybe
>> better int8[]) in your query, but unless the JDBC array code copes with
>> nondefault subscripts, it'll still have trouble:


> The JDBC array code throws away nondefault subscripts because the JDBC
> spec says that all arrays are 1-indexed.


OK, so casting to int8[] in the query should be a usable workaround.
(You want int8 not int4 because OIDs are unsigned and won't necessarily
fit in an int4.)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

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 08:44 AM.


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