Query parameters limit in postgres jdbc driver?

Поиск
Список
Период
Сортировка
Искать

Query parameters limit in postgres jdbc driver?

От:
olafos <olafoos@wp.pl>
Дата:

Hi,

I'm using Toplink JPA with Postgresql JDBC driver in my application and I
encountered the following problem. I'm creating a query with IN clause
containing a couple of thousand of parameters. When the query is sent to the
jdbc driver the following error occurs:

Local Exception Stack: 
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build 09d
(12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: An I/O error occured
while sending to the backend.
Error Code: 0
	...
Caused by: org.postgresql.util.PSQLException: An I/O error occured while
sending to the backend.
	at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:217)
	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
oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:726)
	at
oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:501)
	... 40 more
Caused by: java.io.IOException: Tried to send an out-of-range integer as a
2-byte value: 40000
	at org.postgresql.core.PGStream.SendInteger2(PGStream.java:194)
	at
org.postgresql.core.v3.QueryExecutorImpl.sendParse(QueryExecutorImpl.java:769)
	at
org.postgresql.core.v3.QueryExecutorImpl.sendOneQuery(QueryExecutorImpl.java:1036)
	at
org.postgresql.core.v3.QueryExecutorImpl.sendQuery(QueryExecutorImpl.java:643)
	at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:189)
	... 45 more

Seems like the driver is trying to send the number 40,000 (which is actually
the number of query parameters) as a 2-byte integer. Is there any limit to
the number of jdbc query parameters in postgresql?

Thanks,
Olaf Tomcak



-- 
View this message in context: http://www.nabble.com/Query-parameters-limit-in-postgres-jdbc-driver--tp16832734p16832734.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.

Re: Query parameters limit in postgres jdbc driver?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
olafos  writes:
> Seems like the driver is trying to send the number 40,000 (which is actually
> the number of query parameters) as a 2-byte integer. Is there any limit to
> the number of jdbc query parameters in postgresql?

Yeah, 2^16, as you already noticed.

40000 parameters is far beyond the bounds of sanity anyway.  Try sending
them as a single array parameter, ie "foo = any (?::int[])"

			regards, tom lane

Re: Query parameters limit in postgres jdbc driver?

От:
Olaf Tomczak <olafoos@wp.pl>
Дата:
Tom Lane writes:
> olafos  writes:
>   
>> Seems like the driver is trying to send the number 40,000 (which is actually
>> the number of query parameters) as a 2-byte integer. Is there any limit to
>> the number of jdbc query parameters in postgresql?
>>     
>
> Yeah, 2^16, as you already noticed.
>
> 40000 parameters is far beyond the bounds of sanity anyway.  Try sending
> them as a single array parameter, ie "foo = any (?::int[])"
>
> 			regards, tom lane
>
>
>   

Yeah, well that would be much more sensible I guess, although it won't 
be easy to convince Toplink to do so;). Anyway, thanks a lot for 
clearing this up for me.

regards, Olaf Tomczak
FAQ