Function not working check_foreign_key().
Function not working check_foreign_key().
От:
Luke Tudor - RSG <ltt@pml.ac.uk>
Дата:
Dear Postgres Team, I have now spent a number of months, working on a postgres problem that I have encountered. Finding a solution to my problem is fairly important, as it holds all information for the company. I would be extremely grateful if anyone who has been in a similar position, and has any ideas if they could share them with me! The problem started one day months ago when suddenly, pg_dump stopped working! I don't have an explanation as to why, because Im not sure what changed. Anyway; I started getting the error message 'getTables(): relation 'genuser': cannot find function with oid 773217 for trigger check_user'. Well, after some helpful information from Tom, I now understand Oid's and how to look them up. When I searched the pg_proc table, I found that there is an entry for check_foreign_key with that oid. It also provides me with the probin as '/users/pgsql/postgres/lib/refint.so'. The trigger check_user does indeed call the check_foreign_key function, and if the trigger is dropped, the pg_dump program continues backing up until it reaches another trigger referencing the check_foreign_key function. As far as I can tell, if the file '/users/pgsql/postgres/lib/refint.so' exists (which it does), and there is an entry for the function in pg_proc, why is there a problem with the trigger/function? Re-creating the database is not a possibility because it's massive, and the data is extremely important. I need to some how reinstall or make check_foreign_key work again. What could have gone wrong? and how should I go about fixing the problem? Should I try just replacing the '/users/rsg8/pgsql/postgres/lib/refint.so' file? I don't mind deleting and recreating the triggers, but without fixing the function, this won't help. Any help appreciated. Many Thanks Luke. Extra Information: This is how I am calling pg_dump; pg_dump -u -f rsgbase.backup rsgbase rsgbase = database name, rsgbase.backup = backup of database (to create) I then enter username and password. --- The erroneous trigger code (it has been working, but this is how it was created along time ago) CREATE TRIGGER check_user ON genUser ON DELETE FOR EACH ROW EXECUTE PROCEDURE check_foreign_key (1,'cascade','userid','webuser','userid'); ---
Re: Function not working check_foreign_key().
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Luke Tudor - RSG writes:
> The problem started one day months ago when suddenly, pg_dump stopped
> working! I don't have an explanation as to why, because Im not sure what
> changed. Anyway;
> I started getting the error message 'getTables(): relation 'genuser':
> cannot find function with oid 773217 for trigger check_user'.
After some digging, I find that pg_dump hasn't emitted an error message
spelled like that since version 6.5. You really ought to upgrade.
It also appears that the 6.5 pg_dump will give that error message for
several reasons other than not finding the OID:
(a) there is no pg_shadow entry matching the trigger function's
proowner field in pg_proc;
(b) the function is not declared to take zero arguments;
(c) the function is not declared to return OPAQUE.
Offhand I will bet that (a) is your problem. Create a new user with
the right usesysid and you'll be OK again.
regards, tom lane