Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id DF78E632DFE for ; Sat, 7 Feb 2009 17:57:38 -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 78924-08 for ; Sat, 7 Feb 2009 17:57:35 -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 41379632C17 for ; Sat, 7 Feb 2009 17:57:35 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mail.televork.ee (Postfix) with ESMTP id 847A114E11D; Sat, 7 Feb 2009 23:57:37 +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 AXe1mUvSOeiZ; Sat, 7 Feb 2009 23:57:35 +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 00763CE33; Sat, 7 Feb 2009 23:57:32 +0200 (EET) Subject: Re: jdbc refuses to pass array argument using ARRAY[...] syntax From: Hannu Krosing To: Kris Jurka Cc: pgsql-jdbc@postgresql.org In-Reply-To: References: <1234023235.9180.19.camel@huvostro> Content-Type: text/plain Date: Sat, 07 Feb 2009 23:57:24 +0200 Message-Id: <1234043844.6818.1.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/19 X-Sequence-Number: 19294 On Sat, 2009-02-07 at 11:28 -0500, Kris Jurka wrote: > > On Sat, 7 Feb 2009, Hannu Krosing wrote: > > > org.postgresql.util.PSQLException: org.postgresql.util.PSQLException: > > ERROR: array value must start with "{" or dimension information > > This is a server error message, not a JDBC driver message. > > > 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(# ] ) > > Since you're using a prepared statement, this isn't the same thing. The > equivalent is really: > > PREPARE myplan ( mytype[] ) AS SELECT * FROM > mytypearraryfunc($1); > > EXECUTE myplan ( 'ARRAY[..]'::mytype[] ); > > ARRAY is a grammar construct and cannot be part of the parameter. weird, since this works too m3=# prepare myplan(mytype[]) as SELECT * FROM mytypearraryfunc(1,$1); PREPARE m3=# execute myplan(ARRAY[ m3(# ROW(10, '{1,2,3}','{7,8,9}')::mytype, m3(# ROW(11, '{1}','{3,4,5,6,7}')::mytype, m3(# ROW(10, '{}','{7}')::mytype m3(# ]); status | file_id | delete_heirs | add_heirs --------+---------+--------------+------------- 200 | 10 | {1,2,3} | {7,8,9} 200 | 11 | {1} | {3,4,5,6,7} 200 | 10 | {} | {7} (3 rows) m3=# > Kris Jurka -- ------------------------------------------ Hannu Krosing http://www.2ndQuadrant.com PostgreSQL Scalability and Availability Services, Consulting and Training