On Wed, 2023-09-20 at 17:59 +0000, Harry Green wrote: > I have done a complete pg_dump and complete restore, and tried all forms of complete > pg_dumps and restores (i.e. the different formats). There is no partial or tables only > or data only dumping or restoring. Further, you refer to a 'check constraint' but > this is just a function that we wrote with the 'create function...' command, whose > name if memory serves correctly happens to begin by 'check...' because that happens > to be the most descriptive word for what it does. > > The pg_restore is actually correctly recreating the function using the 'create function...' > command, but it is doing so on line 95, ahead of the 'create table ... accounts ...' > which appears on line 510. The trouble is that in the function itself, we refer to > the accounts table, and if I am not mistaken, the whole point of pl/pgsql is that > you can refer to tables, etc. so I don't think I have done anything 'illegal'. Ok, so my conjecture about check constraints was wrong. The fact remains that you have to restore the dump into an empty database. Then these errors should not occur. Yours, Laurenz Albe