Help: fmgr_info: function 0: cache lookup failed - Mailing list pgsql-hackers

From darcy@druid.net ("D'Arcy" "J.M." Cain)
Subject Help: fmgr_info: function 0: cache lookup failed
Date
Msg-id m10mcUJ-0000bIC@druid.net
Whole thread Raw
Responses Re: [HACKERS] Help: fmgr_info: function 0: cache lookup failed
Re: [HACKERS] Help: fmgr_info: function 0: cache lookup failed
List 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 opaqueas '/usr/local/pgsql/modules/glaccount.so'language 'c';

create function glaccount_out(opaque)returns opaqueas '/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 intas '/usr/local/pgsql/modules/glaccount.so'language 'c';

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

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

--
--    The various boolean tests:
--

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

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

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

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

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

create function glaccount_ge(glaccount, glaccount)returns boolas '/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.oprnameINTO TEMP TABLE glaccount_ops_tmpFROM pg_operator o, pg_type tWHERE 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'::regprocFROM pg_am am, pg_opclass opcl, glaccount_ops_tmp cWHERE
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'::regprocFROM pg_am am, pg_opclass opcl, glaccount_ops_tmp cWHERE
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'::regprocFROM pg_am am, pg_opclass opcl, glaccount_ops_tmp cWHERE
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'::regprocFROM pg_am am, pg_opclass opcl, glaccount_ops_tmp cWHERE
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'::regprocFROM pg_am am, pg_opclass opcl, glaccount_ops_tmp cWHERE
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_procc    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'::regprocFROM pg_am am, pg_opclass opcl, glaccount_ops_tmp cWHERE
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@{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.


pgsql-hackers by date:

Previous
From: "D'Arcy" "J.M." Cain
Date:
Subject: Help: fmgr_info: function 0: cache lookup failed
Next
From: Peter T Mount
Date:
Subject: Memory leak in large objects (was Re: Postgreqsl Large Objects)