ERROR: cache lookup failed for function 0

From: David E(dot) Wheeler <david(at)kineticode(dot)com>
To: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: ERROR: cache lookup failed for function 0
Date: 2008-10-25 04:54:58
Message-ID: 0754B64F-743C-428B-873E-1BD0E1E7BAFD@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

[Re-sending to hackers, since the original message to pgsql-bugs has
not been approved for delivery in the last four days…apologies for any
duplicates.]

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

Browse pgsql-hackers by date

  From Date Subject
Next Message Decibel! 2008-10-25 05:00:23 Re: Handling NULL records in plpgsql
Previous Message Tom Lane 2008-10-25 00:57:17 Re: SPI cursor functions