Re: `pg_restore --if-exists` clarification

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: `pg_restore --if-exists` clarification
Дата
Msg-id CAKFQuwbM2s5Naeb4SZted17zM=r_-C8w07-Bw-SyYd1b8a4LRA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: `pg_restore --if-exists` clarification  (Gulyás Attila <toraritte@gmail.com>)
Ответы Re: `pg_restore --if-exists` clarification  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-docs
On Thursday, September 28, 2023, Gulyás Attila <toraritte@gmail.com> wrote:
So `--if-exists` simply suppresses any notice / warning that would occur?

That switch causes the drop DDL produced by pg_restore to include if exists clauses.  The server then simply treats the DDL as a no-op if said object being dropped cannot be found.



But "failure" is not what happens.  If you read the part regarding --clean, you will see that it says:

(Unless --if-exists is used, this might generate some harmless error messages, if any objects were not present in the destination database.) [emphasis added]

with extra emphasis on the word "harmless" --  no failure is caused; the restore proceeds just fine.  

If anything were to change in this regard, it might be better to reconsider what we call the message (i.e.what language pg_restore emits in this scenario.)  It's true, I suppose, in a literal sense that it's an error in that pg_restore couldn't drop a table when instructed to, where no such table exists.  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.

David J.

В списке pgsql-docs по дате отправления:

Предыдущее
От: Gulyás Attila
Дата:
Сообщение: Re: `pg_restore --if-exists` clarification
Следующее
От: Tom Lane
Дата:
Сообщение: Re: `pg_restore --if-exists` clarification