pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
reading an oidvector field error
8+ messages / 4 participants
[nested] [flat]

* reading an oidvector field error
@ 2006-01-12 14:29 Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-13 03:19 ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Takeichi Kanzaki Cabrera @ 2006-01-12 14:29 UTC (permalink / raw)
  To: pgsql-jdbc

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



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

* Re: reading an oidvector field error
  2006-01-12 14:29 reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
@ 2006-01-13 03:19 ` Oliver Jowett <oliver@opencloud.com>
  2006-01-16 18:06   ` Re: reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Oliver Jowett @ 2006-01-13 03:19 UTC (permalink / raw)
  To: Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>; +Cc: pgsql-jdbc

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



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

* Re: reading an oidvector field error
  2006-01-12 14:29 reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-13 03:19 ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
@ 2006-01-16 18:06   ` Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-16 21:05     ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Takeichi Kanzaki Cabrera @ 2006-01-16 18:06 UTC (permalink / raw)
  To: pgsql-jdbc

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:580)
        at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(AbstractJdbc2Array.java:232)
        at org.postgresql.jdbc2.AbstractJdbc2Array.getResultSetImpl(AbstractJdbc2Array.java:291)
        at org.postgresql.jdbc2.AbstractJdbc2Array.getResultSet(AbstractJdbc2Array.java:252)
        at pgObjects.PgDatabase.loadFunctionsFromDatabase(PgDatabase.java:893)
        at test.Test.showFunctions(Test.java:134)
        at test.Test.main(Test.java:166)

Takeichi.



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

* Re: reading an oidvector field error
  2006-01-12 14:29 reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-13 03:19 ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
  2006-01-16 18:06   ` Re: reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
@ 2006-01-16 21:05     ` Oliver Jowett <oliver@opencloud.com>
  2006-01-16 21:14       ` Re: reading an oidvector field error Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Oliver Jowett @ 2006-01-16 21:05 UTC (permalink / raw)
  To: Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>; +Cc: pgsql-jdbc

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:580)
>         at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(AbstractJdbc2Array.java:232)
>         at org.postgresql.jdbc2.AbstractJdbc2Array.getResultSetImpl(AbstractJdbc2Array.java:291)
>         at org.postgresql.jdbc2.AbstractJdbc2Array.getResultSet(AbstractJdbc2Array.java:252)
>         at pgObjects.PgDatabase.loadFunctionsFromDatabase(PgDatabase.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



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

* Re: reading an oidvector field error
  2006-01-12 14:29 reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-13 03:19 ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
  2006-01-16 18:06   ` Re: reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-16 21:05     ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
@ 2006-01-16 21:14       ` Tom Lane <tgl@sss.pgh.pa.us>
  2006-01-16 21:54         ` Re: reading an oidvector field error Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2006-01-16 21:14 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>; pgsql-jdbc

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'::oidvector::int8[];
     int8
---------------
 [0:2]={1,2,3}
(1 row)

regression=#

			regards, tom lane



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

* Re: reading an oidvector field error
  2006-01-12 14:29 reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-13 03:19 ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
  2006-01-16 18:06   ` Re: reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-16 21:05     ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
  2006-01-16 21:14       ` Re: reading an oidvector field error Tom Lane <tgl@sss.pgh.pa.us>
@ 2006-01-16 21:54         ` Kris Jurka <books@ejurka.com>
  2006-01-16 22:40           ` Re: reading an oidvector field error Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Kris Jurka @ 2006-01-16 21:54 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Oliver Jowett <oliver@opencloud.com>; Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>; pgsql-jdbc



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



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

* Re: reading an oidvector field error
  2006-01-12 14:29 reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-13 03:19 ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
  2006-01-16 18:06   ` Re: reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-16 21:05     ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
  2006-01-16 21:14       ` Re: reading an oidvector field error Tom Lane <tgl@sss.pgh.pa.us>
  2006-01-16 21:54         ` Re: reading an oidvector field error Kris Jurka <books@ejurka.com>
@ 2006-01-16 22:40           ` Tom Lane <tgl@sss.pgh.pa.us>
  2006-01-17 15:57             ` Re: reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2006-01-16 22:40 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: Oliver Jowett <oliver@opencloud.com>; Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>; pgsql-jdbc

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



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

* Re: reading an oidvector field error
  2006-01-12 14:29 reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-13 03:19 ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
  2006-01-16 18:06   ` Re: reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  2006-01-16 21:05     ` Re: reading an oidvector field error Oliver Jowett <oliver@opencloud.com>
  2006-01-16 21:14       ` Re: reading an oidvector field error Tom Lane <tgl@sss.pgh.pa.us>
  2006-01-16 21:54         ` Re: reading an oidvector field error Kris Jurka <books@ejurka.com>
  2006-01-16 22:40           ` Re: reading an oidvector field error Tom Lane <tgl@sss.pgh.pa.us>
@ 2006-01-17 15:57             ` Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
  0 siblings, 0 replies; 8+ messages in thread

From: Takeichi Kanzaki Cabrera @ 2006-01-17 15:57 UTC (permalink / raw)
  To: pgsql-jdbc

I solve the problem by getting the field as a String and implementing
a simple parser for the result.
All the ways I test the choice of cast the field as a int8[] and get
this exception:

java.sql.SQLException: ERROR: cannot cast type oidvector to bigint[]
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1482)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1267)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:186)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:392)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:314)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:221)
        at pgObjects.PgServer.executeQuery(PgServer.java:372)
        at pgObjects.PgDatabase.loadFunctionsFromDatabase(PgDatabase.java:864)
        at test.Test.showFunctions(Test.java:134)
        at test.Test.main(Test.java:166)

Thanks a lot for all of you,
Takeichi.



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


end of thread, other threads:[~2006-01-17 15:57 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-01-12 14:29 reading an oidvector field error Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
2006-01-13 03:19 ` Oliver Jowett <oliver@opencloud.com>
2006-01-16 18:06   ` Takeichi Kanzaki Cabrera <tkanzakic@gmail.com>
2006-01-16 21:05     ` Oliver Jowett <oliver@opencloud.com>
2006-01-16 21:14       ` Tom Lane <tgl@sss.pgh.pa.us>
2006-01-16 21:54         ` Kris Jurka <books@ejurka.com>
2006-01-16 22:40           ` Tom Lane <tgl@sss.pgh.pa.us>
2006-01-17 15:57             ` Takeichi Kanzaki Cabrera <tkanzakic@gmail.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