Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 76D4F632E3C for ; Sat, 7 Feb 2009 12:14:25 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 23501-01 for ; Sat, 7 Feb 2009 12:14:22 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.televork.ee (mail.televork.ee [81.21.241.190]) by mail.postgresql.org (Postfix) with ESMTP id ABF73632E39 for ; Sat, 7 Feb 2009 12:14:21 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mail.televork.ee (Postfix) with ESMTP id D3DC2CE33 for ; Sat, 7 Feb 2009 18:14:07 +0200 (EET) X-Virus-Scanned: at mail.televork.ee Received: from mail.televork.ee ([81.21.241.190]) by localhost (mail.televork.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GFO027ylnqmJ for ; Sat, 7 Feb 2009 18:14:00 +0200 (EET) Received: from [127.0.0.1] (81-21-242-98.televork.ee [81.21.242.98]) by mail.televork.ee (Postfix) with ESMTP id 4374A95B1 for ; Sat, 7 Feb 2009 18:14:00 +0200 (EET) Subject: jdbc refuses to pass array argument using ARRAY[...] syntax From: Hannu Krosing To: pgsql-jdbc@postgresql.org Content-Type: text/plain Date: Sat, 07 Feb 2009 18:13:55 +0200 Message-Id: <1234023235.9180.19.camel@huvostro> Mime-Version: 1.0 X-Mailer: Evolution 2.24.3 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200902/17 X-Sequence-Number: 19292 Hallo, I am trying to get JDBC to pass an array of user_defined types to a pl/pgsql function, via a preparedStatement and setObject() function is defined thus: CREATE FUNCTION mytypearrayfunc( long id_in, mytype[] typaarray_in) RETURNS SETOF RECORD AS $$ ... $$ LANGUAGE plpgsql ; And I did define my own list_of_objects class public class MyTypeList extends PGobject { ... public MyTypeList() { setType("_mytype"); } ... public getValue() { ... } } which returns representation in form ARRAY[ ROW(7,'{5,6,7}','{4}')::mytype, ROW(2,'{2}','{3,4}')::mytype, ROW(1,'{1}','{}')::mytype ] which is absolutely OK if I pass it to function in plpgsql but java gets paranoid and demands me to start ARRAY[] argument with "{" : Traceback (innermost last): File "", line 1, in ? File "/home/hannu/work/M1/javatest/jythontest_func.py", line 62, in ? at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1316) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:191) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:255) at java.lang.reflect.Method.invoke(libgcj.so.90) org.postgresql.util.PSQLException: org.postgresql.util.PSQLException: ERROR: array value must start with "{" or dimension information Can anyone point me where to look for this check ? grepping for the error message in driver source gives me nothing , probably it is some internationalised string that is not present in source ? and yes, the full query string returned from myPrepared Statement.toString() is valid SQL and does produce desired results when I paste it in psql, so the problem is very likely overly paranoid checks in PG jdbc driver. m3=# select * from mytypearrayfunc( 1, ARRAY[ m3(# ROW(7,'{5,6,7}','{4}')::mytype, m3(# ROW(2,'{2}','{3,4}')::mytype, m3(# ROW(1,'{1}','{}')::mytype m3(# ] ) m3-# ; status | my_id | friends | foes --------+-------+--------------+----------- 200 | 7 | {5,6,7} | {4} 200 | 2 | {2} | {3,4} 200 | 1 | {1} | {} (3 rows) and I get different error message when i do setType("somethingelse"); so most of the PGObject machinery is working. If really needed, I can prepare a full sample code ( a shell script, a jython file, a java file and an sql file) but hopefully someone can tell me the location of this check right away. -- ------------------------------------------ Hannu Krosing http://www.2ndQuadrant.com PostgreSQL Scalability and Availability Services, Consulting and Training