pg_dump bug - problems along the way

Started by Oliver Elphickabout 27 years ago5 messages
#1Oliver Elphick
olly@lfix.co.uk

Still trying to fix the bug with inherited check constraints...

I have tried to create a min(oid) aggregate, but when I use it, I get
the message `ERROR: fmgr_info: function 108994: cache lookup failed'.

What is the problem, please?

I created it thus:

create function oid4smaller (oid, oid) returns oid as
'/home/olly/cprogs/oidcompare.so' language 'c';

create aggregate min (basetype = oid, sfunc1 = oid4smaller,
stype1 = oid, stype2 = oid);

The C file is compiled and linked thus (for Linux x86):

$ gcc -o oidcompare.o -c -I/usr/include/postgresql oidcompare.c
$ gcc -shared -o oidcompare.so oidcompare.o

and it says:
#include <postgresql/postgres.h>

Oid oid4smaller(Oid o1, Oid o2) {
return (o1 < o2 ? o1 : o2);
}

Oid oid4larger(Oid o1, Oid o2) {
return (o1 > o2 ? o1 : o2);
}

--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP key from public servers; key ID 32B8FAA1
========================================
"If my people, which are called by my name, shall
humble themselves, and pray, and seek my face, and
turn from their wicked ways; then will I hear from
heaven, and will forgive their sin, and will heal
their land." II Chronicles 7:14

#2Sferacarta Software
sferac@bo.nettuno.it
In reply to: Oliver Elphick (#1)
Re: [HACKERS] pg_dump bug - problems along the way

Hello Oliver,

sabato, 21 novembre 98, you wrote:

OE> Still trying to fix the bug with inherited check constraints...

OE> I have tried to create a min(oid) aggregate, but when I use it, I get
OE> the message `ERROR: fmgr_info: function 108994: cache lookup failed'.

OE> What is the problem, please?

OE> I created it thus:

OE> create function oid4smaller (oid, oid) returns oid as
OE> '/home/olly/cprogs/oidcompare.so' language 'c';

OE> create aggregate min (basetype = oid, sfunc1 = oid4smaller,
OE> stype1 = oid, stype2 = oid);

Try this...it works...

create function oid4smaller (oid, oid) returns oid as
'
begin
if $1 > $2 then
return $2;
else
return $1;
end if;
end;
' language 'plpgsql';

create aggregate m (basetype = oid, sfunc1 = oid4smaller,
stype1 = oid, stype2 = oid);

prova=> select oid from a;
oid
------
376064
376065
380064
380065
380066
380067
(6 rows)

prova=> select min(oid) from a;
min
------
376064
(1 row)

-Jose'-

#3Oliver Elphick
olly@lfix.co.uk
In reply to: Sferacarta Software (#2)
Re: [HACKERS] pg_dump bug - problems along the way

Sferacarta Software wrote:

Try this...it works...

create function oid4smaller (oid, oid) returns oid as
'
begin
if $1 > $2 then
return $2;
else
return $1;
end if;
end;
' language 'plpgsql';

I'm afraid it doesn't work for me; clearly the problem is elsewhere:

bray=> select min(oid) from europe;
ERROR: fmgr_info: function 108994: cache lookup failed

**Idea** - try in another database -- it works, so it must be a database
corruption of some kind.

Thanks for your help.

--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP key from public servers; key ID 32B8FAA1
========================================
"The LORD is nigh unto all them that call upon him, to
all that call upon him in truth."
Psalms 145:18

#4Noname
jwieck@debis.com
In reply to: Oliver Elphick (#3)
Re: [HACKERS] pg_dump bug - problems along the way

Sferacarta Software wrote:

Try this...it works...

create function oid4smaller (oid, oid) returns oid as
'
begin
if $1 > $2 then
return $2;
else
return $1;
end if;
end;
' language 'plpgsql';

I'm afraid it doesn't work for me; clearly the problem is elsewhere:

bray=> select min(oid) from europe;
ERROR: fmgr_info: function 108994: cache lookup failed

**Idea** - try in another database -- it works, so it must be a database
corruption of some kind.

Looks like you dropped and recreated the function used in the
min(oid) aggregate without dropping and recreating the
aggregate itself.

Note that the functions used in an aggregate are referenced
by OID, not by name. In pg_aggregate the pg_proc tuple with
the old OID is still referenced and cannot be found (cache
lookup failed). Drop the agg and recreate it.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #

#5Oliver Elphick
olly@lfix.co.uk
In reply to: Noname (#4)
Re: [HACKERS] pg_dump bug - problems along the way

Jan Wieck wrote:

bray=> select min(oid) from europe;
ERROR: fmgr_info: function 108994: cache lookup failed

**Idea** - try in another database -- it works, so it must be a database
corruption of some kind.

Looks like you dropped and recreated the function used in the
min(oid) aggregate without dropping and recreating the
aggregate itself.

Note that the functions used in an aggregate are referenced
by OID, not by name. In pg_aggregate the pg_proc tuple with
the old OID is still referenced and cannot be found (cache
lookup failed). Drop the agg and recreate it.

Yes; that is what I did, which explains why it works in another
database where I hadn't been playing. Thank you.

May I suggest that the error message be changed from

`ERROR: fmgr_info: function 108994: cache lookup failed'

to:

`ERROR: fmgr_info: function 108994 not found in pg_proc'

which would be a better explanation of what was wrong, and would have
let me diagnose the problem for myself (I hope!). The existing message
suggests that the function itself is present but somehow faulty.

(src/backend/utils/fmgr/fmgr.c in fmgr_info())

In general, is it not better to say as explicitly as possible what is
wrong, rather than to use terms like "cache lookup" which are only
meaningful to someone who knows the program internals? There are several
other error messages in that same file which could do with similar
clarification.

--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP key from public servers; key ID 32B8FAA1
========================================
"The LORD is nigh unto all them that call upon him, to
all that call upon him in truth."
Psalms 145:18