ERROR: cache lookup failed for function 0

Started by David E. Wheelerover 17 years ago4 messagesbugs
Jump to latest
#1David E. Wheeler
david@kineticode.com

Howdy,

I ran into this error on 8.2 a while ago, and just figured out what
was causing it. Here's a quick example on 8.2:

BEGIN;

-- Compare name[]s more or less like 8.3 does.
CREATE OR REPLACE FUNCTION namearray_text(name[])
RETURNS TEXT AS 'SELECT textin(array_out($1));'
LANGUAGE sql IMMUTABLE STRICT;

CREATE CAST (name[] AS text) WITH FUNCTION namearray_text(name[]) AS
IMPLICIT;

CREATE OR REPLACE FUNCTION namearray_eq( name[], name[] )
RETURNS bool
AS 'SELECT $1::text = $2::text;'
LANGUAGE sql IMMUTABLE STRICT;

CREATE OPERATOR = (
LEFTARG = name[],
RIGHTARG = name[],
NEGATOR = <>,
PROCEDURE = namearray_eq
);

SELECT '{foo}'::name[] <> '{bar}'::name[];

ROLLBACK;

If you comment out the NEGATOR line, the error is changed to the more
useful

ERROR: operator is not unique: name[] <> name[]

I'm assuming that, if you did this for 8.3 (which has name[]
comparison operators in core, so it'd have to be an operator with some
other type), you'd get the same useless error.

Ideally, in the situation where a NEGATOR (or commutator, too?) is
specified but has not actually been defined, you'd get an error such as:

ERROR: operator not defined: name[] <> name[]

Thanks,

David

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: David E. Wheeler (#1)
Re: ERROR: cache lookup failed for function 0

"David E. Wheeler" <david@kineticode.com> writes:

I ran into this error on 8.2 a while ago, and just figured out what
was causing it. Here's a quick example on 8.2:

Seems to be fixed in HEAD:

regression=# SELECT '{foo}'::name[] <> '{bar}'::name[];
ERROR: operator is only a shell: name[] <> name[]
LINE 1: SELECT '{foo}'::name[] <> '{bar}'::name[];
^

regards, tom lane

#3David E. Wheeler
david@kineticode.com
In reply to: Tom Lane (#2)
Re: ERROR: cache lookup failed for function 0

On Oct 25, 2008, at 05:35, Tom Lane wrote:

Seems to be fixed in HEAD:

regression=# SELECT '{foo}'::name[] <> '{bar}'::name[];
ERROR: operator is only a shell: name[] <> name[]
LINE 1: SELECT '{foo}'::name[] <> '{bar}'::name[];

Great. Is it something that could be backported, or is it not worth it?

Thanks,

David

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: David E. Wheeler (#3)
Re: ERROR: cache lookup failed for function 0

"David E. Wheeler" <david@kineticode.com> writes:

Great. Is it something that could be backported, or is it not worth it?

Not worth it IMO.

regards, tom lane