Обсуждение: about function overload,a bug?

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

about function overload,a bug?

От
"cncinfo@126.com"
Дата:
My English is bad.
I write two functions with plpgsql:

1. user_chgpasswd(character varying, character varying, timestamp
without time zone)
Note:content of the function is just "return 0;"
2.user_chgpasswd(character varying, character varying, character
varying)

Both of them return integer.
I invoke the first one in pgadmin,returns 0;but in my
application(setString(),setString(),setTimestamp()),the result is not 0.
I tried postgresql-8.2-506.jdbc3.jar and
postgresql-8.2-506.jdbc4.jar,both wrong.
I check my code for a long time,no wrong.I delete the second function in
postgresql and run my application again,returns 0.
It seems "timestamp without time zone" is same as "character varying" in
jdbc,so jdbc invoke wrong function.



Re: about function overload,a bug?

От
Oliver Jowett
Дата:
cncinfo@126.com wrote:

> It seems "timestamp without time zone" is same as "character varying" in
> jdbc,so jdbc invoke wrong function.

Unfortunately the JDBC driver must pass timestamp parameters without
type data and let the server infer the correct type to use (this is
necessary to have both "timestamp with time zone" and "timestamp without
time zone" operate correctly).

In your case the server is inferring the wrong type for what you want.

An explicit cast in your query may fix it.

-O

Re: about function overload,a bug?

От
"cncinfo@126.com"
Дата:
to


Oliver Jowett
Thanks for your help.
> Unfortunately the JDBC driver must pass timestamp parameters without
> type data and let the server infer the correct type to use
"server infer the correct type to use",is there any rule?
I change the function name,then ok.