I would love to see Tom's version in the docs! It is only slightly longer than the current one, but absolutely clear of the purpose of both, and the behaviour when used in tandem.
"David G. Johnston" <david.g.johnston@gmail.com> writes: >>> .. But pragmatically it doesn't matter, so why not >>> reclassify this as a "warning" or a "notice"?
> Because pg_restore is just a client and it is repeating back what the > server tells it. And for the server it is an error to drop an object that > doesn’t exist. > psql and pg_restore, as clients, can choose to ignore the errors they see, > regardless of what kind of error it is, but they don’t take on the added > burden of trying to reclassify errors into something else.
If you actually try this, you'll get output like
... pg_restore: error: could not execute query: ERROR: schema "fkpart6" does not exist Command was: DROP SCHEMA fkpart6; pg_restore: error: could not execute query: ERROR: schema "fkpart5" does not exist Command was: DROP SCHEMA fkpart5; pg_restore: error: could not execute query: ERROR: schema "fkpart4" does not exist Command was: DROP SCHEMA fkpart4; pg_restore: error: could not execute query: ERROR: schema "fkpart3" does not exist Command was: DROP SCHEMA fkpart3; ... pg_restore: warning: errors ignored on restore: 1488
so the only real problem is that there are (typically) enough of these to obscure any errors that might be of greater significance. Still, genuine restore errors would come out after the blizzard of failed DROPs, so I don't think there's a big problem in practice.
If we actually wanted to change any behavior here, I think what would be most profitable to discuss is making --if-exists the default. Not sure if we want to go there, but if we'd had the DROP IF EXISTS option all along I bet it would have been done that way.
In any case, it's fair to complain about the documentation. How about
--clean
Before restoring database objects, issue commands to DROP all the objects that will be restored. This option is useful for overwriting an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported, unless --if-exists is also specified.
--if-exists
Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses "does not exist" errors that might otherwise be reported. This option is not valid unless --clean is also specified.