Help: fmgr_info: function 0: cache lookup failed

From: "D'Arcy" "J(dot)M(dot)" Cain <darcy(at)druid(dot)net>
To: hackers(at)PostgreSQL(dot)org
Subject: Help: fmgr_info: function 0: cache lookup failed
Date: 1999-05-26 12:08:47
Message-ID: m10mcUJ-0000bIC@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I still can't get this type creation working. I get the subject error
whenever I try to select on the new type if it is indexed. Here is a sample.

darcy=> create table x (g glaccount, i int);
CREATE
darcy=> insert into x values ('12345-0000', 1);
INSERT 29124 1
darcy=> select * from x where g = '12345-0000';
g|i
----------+-
12345-0000|1
(1 row)

darcy=> create unique index y on x (g);
CREATE
darcy=> select * from x where g = '12345-0000';
ERROR: fmgr_info: function 0: cache lookup failed

As you can see, the select worked until I added the index. Here is the
SQL that created the glaccount type. I hope to rewrite the documentation
based on this but I need to get it working first. Any ideas?

--
-- PostgreSQL code for GLACCOUNTs.
--
-- $Id$
--

load '/usr/local/pgsql/modules/glaccount.so';

--
-- Input and output functions and the type itself:
--

create function glaccount_in(opaque)
returns opaque
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

create function glaccount_out(opaque)
returns opaque
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

create type glaccount (
internallength = 16,
externallength = 13,
input = glaccount_in,
output = glaccount_out
);

--
-- Some extra functions
--

create function glaccount_major(glaccount)
returns int
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

create function glaccount_minor(glaccount)
returns int
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

create function glaccount_cmp(glaccount, glaccount)
returns int
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

--
-- The various boolean tests:
--

create function glaccount_eq(glaccount, glaccount)
returns bool
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

create function glaccount_ne(glaccount, glaccount)
returns bool
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

create function glaccount_lt(glaccount, glaccount)
returns bool
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

create function glaccount_gt(glaccount, glaccount)
returns bool
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

create function glaccount_le(glaccount, glaccount)
returns bool
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

create function glaccount_ge(glaccount, glaccount)
returns bool
as '/usr/local/pgsql/modules/glaccount.so'
language 'c';

--
-- Now the operators. Note how some of the parameters to some
-- of the 'create operator' commands are commented out. This
-- is because they reference as yet undefined operators, and
-- will be implicitly defined when those are, further down.
--

create operator < (
leftarg = glaccount,
rightarg = glaccount,
-- negator = >=,
procedure = glaccount_lt
);

create operator <= (
leftarg = glaccount,
rightarg = glaccount,
-- negator = >,
procedure = glaccount_le
);

create operator = (
leftarg = glaccount,
rightarg = glaccount,
commutator = =,
-- negator = <>,
procedure = glaccount_eq
);

create operator >= (
leftarg = glaccount,
rightarg = glaccount,
negator = <,
procedure = glaccount_ge
);

create operator > (
leftarg = glaccount,
rightarg = glaccount,
negator = <=,
procedure = glaccount_gt
);

create operator <> (
leftarg = glaccount,
rightarg = glaccount,
negator = =,
procedure = glaccount_ne
);

-- Now, let's see if we can set it up for indexing

INSERT INTO pg_opclass (opcname, opcdeftype)
SELECT 'glaccount_ops', oid FROM pg_type WHERE typname = 'glaccount';

SELECT o.oid AS opoid, o.oprname
INTO TEMP TABLE glaccount_ops_tmp
FROM pg_operator o, pg_type t
WHERE o.oprleft = t.oid AND
o.oprright = t.oid AND
t.typname = 'glaccount';

INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy,
amopselect, amopnpages)
SELECT am.oid, opcl.oid, c.opoid, 1,
'btreesel'::regproc, 'btreenpage'::regproc
FROM pg_am am, pg_opclass opcl, glaccount_ops_tmp c
WHERE amname = 'btree' AND
opcname = 'glaccount_ops' AND
c.oprname = '<';

INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy,
amopselect, amopnpages)
SELECT am.oid, opcl.oid, c.opoid, 2,
'btreesel'::regproc, 'btreenpage'::regproc
FROM pg_am am, pg_opclass opcl, glaccount_ops_tmp c
WHERE amname = 'btree' AND
opcname = 'glaccount_ops' AND
c.oprname = '<=';

INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy,
amopselect, amopnpages)
SELECT am.oid, opcl.oid, c.opoid, 3,
'btreesel'::regproc, 'btreenpage'::regproc
FROM pg_am am, pg_opclass opcl, glaccount_ops_tmp c
WHERE amname = 'btree' AND
opcname = 'glaccount_ops' AND
c.oprname = '=';

INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy,
amopselect, amopnpages)
SELECT am.oid, opcl.oid, c.opoid, 4,
'btreesel'::regproc, 'btreenpage'::regproc
FROM pg_am am, pg_opclass opcl, glaccount_ops_tmp c
WHERE amname = 'btree' AND
opcname = 'glaccount_ops' AND
c.oprname = '>=';

INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy,
amopselect, amopnpages)
SELECT am.oid, opcl.oid, c.opoid, 5,
'btreesel'::regproc, 'btreenpage'::regproc
FROM pg_am am, pg_opclass opcl, glaccount_ops_tmp c
WHERE amname = 'btree' AND
opcname = 'glaccount_ops' AND
c.oprname = '>';

INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
SELECT a.oid, b.oid, c.oid, 1
FROM pg_am a, pg_opclass b, pg_proc c
WHERE a.amname = 'btree' AND
b.opcname = 'glaccount_ops' AND
c.proname = 'glaccount_cmp';

INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy,
amopselect, amopnpages)
SELECT am.oid, opcl.oid, c.opoid, 1,
'hashsel'::regproc, 'hashnpage'::regproc
FROM pg_am am, pg_opclass opcl, glaccount_ops_tmp c
WHERE amname = 'hash' AND
opcname = 'glaccount_ops' AND
c.oprname = '=';

INSERT INTO pg_description (objoid, description)
SELECT oid, 'Two part G/L account'
FROM pg_type WHERE typname = 'glaccount';

--
-- eof
--

--
D'Arcy J.M. Cain <darcy(at){druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter T Mount 1999-05-26 13:10:15 Memory leak in large objects (was Re: Postgreqsl Large Objects)
Previous Message ZEUGSWETTER Andreas IZ5 1999-05-26 10:02:48 AW: [HACKERS] Call for updates!