Re: queries against CIDR fail against 8.0.3?

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: queries against CIDR fail against 8.0.3?
Дата
Msg-id 433C7725.1040707@opencloud.com
обсуждение исходный текст
Ответ на queries against CIDR fail against 8.0.3?  (Russell Francis <rfrancis@ev.net>)
Ответы Re: queries against CIDR fail against 8.0.3?
Список pgsql-jdbc
Russell Francis wrote:

> PreparedStatement s = dbConn.prepareStatement(
> "SELECT * FROM institution WHERE ( institution.network >>=  ? ) LIMIT 1" );
> s.setObject( 1, (String)request.getRemoteAddr() );

> net.ev.dao.DAOException: ERROR: operator does not exist: cidr >>=
> character varying

You will need to either create a PGobject subclass that returns the
correct typename (cidr), or explicitly cast to cidr in your query:

SELECT * FROM institution WHERE ( institution.network >>= ?::cidr )
LIMIT 1

> Does anyone have any ideas on how to address this issue?  Or at least an
> explanation as to why it works in 7.3.9 but not 8.0.3?

The 8.0 drivers type parameters more strongly than earlier drivers due
to a change in the protocol used, so setObject(String) is passing the
parameter explicitly as a 'text' value not as an untyped literal that
gets implicitly casted to cidr. See the archives for more details.

-O

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: "Conversion of interval failed" on PGInterval with
Следующее
От: Oliver Jowett
Дата:
Сообщение: Re: Intermittent I/O error?