function currval(character varying) does not exist, PostgreSQL 8.1 beta3

Started by Jean-Pierre Pelletierover 20 years ago2 messagesbugs
Jump to latest
#1Jean-Pierre Pelletier
pelletier_32@sympatico.ca

Hi,

pstmt = connection.prepareStatement("select currval(?)"); throws "function currval(character varying) does not exist"

Using pgAdmin, I could see that currval() now takes a regclass parameter, so
I got it to work using

pstmt = connection.prepareStatement("select currval(cast(cast(? as text) as regclass))");

Is currval(text) gone for good or is this an oversight?
If it's gone for good, is cast(cast(? as text) as regclass) the recommended way of handling this?

I am using PostgreSQL 8.1 beta3 under Windows XP Service Pack 2 with JDBC3 8.1 Build 402.
It worked fine with PostgreSQL 8.1 beta2 and with 8.0.*

Thanks,
Jean-Pierre Pelletier
e-djuster

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jean-Pierre Pelletier (#1)
Re: function currval(character varying) does not exist, PostgreSQL 8.1 beta3

"Jean-Pierre Pelletier" <pelletier_32@sympatico.ca> writes:

pstmt = connection.prepareStatement("select currval(?)"); throws =
"function currval(character varying) does not exist"

Is currval(text) gone for good or is this an oversight?

currval(text) is gone for good; the oversight is that we stuck in an
implicit cast from text to regclass, but not one from varchar to
regclass (and the lookup is stupid, there has to be an exact match in
pg_cast).

I think we probably should add an implicit varchar cast. To completely
duplicate the cases in which previous versions would work quietly,
we might need casts from bpchar and name as well, but I'm less excited
about adding those (especially since they would require additional
actual functions, rather than just one more row in pg_cast).

Comments anyone? Do we need to force initdb for this (I suppose so if
we want to be perfectly clean :-()

regards, tom lane