Re: New developer TODO suggestions

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: New developer TODO suggestions
Дата
Msg-id 20140918095820.GD17265@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: New developer TODO suggestions  (Craig Ringer <craig@2ndquadrant.com>)
Ответы Re: detect custom-format dumps in psql and emit a useful error  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers
On 2014-09-18 17:30:38 +0800, Craig Ringer wrote:
> On 07/29/2014 10:43 PM, Bruce Momjian wrote:
> >> > * When a user tries to run "psql -f some_custom_format_backup", detect
> >> > this and emit a useful error message. Ditto stdin.
> >
> > Uh, good idea, but can we really do that in psql?
> 
> Where stdin is a file, or an explicit -f is given, then yes.
> 
> Just look for PGDMP as the first five bytes and complain.
> 
> To do it more generally we'd need to look at each statement and see if
> it seems to begin with PGDMP. I'm not sure that's worth it; handling the
> simple cases of
> 
> psql -f mydb.dump
> 
> and
> 
> psql < mydb.dump
> 
> would be quite sufficient.
> 
> I'm not 100% sure if we can easily differentiate the second case from
> "pg_dump | psql"; I know there's isatty(...) to test if stdin is a
> terminal, but I'm not sure how easy/possible it is to tell if it's a
> file not a pipe.

I don't think we need to make any discinction between psql -f mydb.dump,
psql < mydb.dump, and whatever | psql. Just check, when noninteractively
reading the first line in mainloop.c:MainLoop(), whether it starts with
the magic header. That'd also trigger the warning on \i pg_restore_file,
but that's hardly a problem.

> pg_restore already knows to tell you to use psql if it sees an SQL file
> as input. Having something similar for pg_dump would be really useful.

Agreed.

We could additionally write out a hint whenever a directory is fed to
psql -f that psql can't be used to read directory type dumps.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: New developer TODO suggestions
Следующее
От: Kyotaro HORIGUCHI
Дата:
Сообщение: Re: [TODO] Process pg_hba.conf keywords as case-insensitive