Re: detect custom-format dumps in psql and emit a useful error

Поиск
Список
Период
Сортировка
От Jeevan Chalke
Тема Re: detect custom-format dumps in psql and emit a useful error
Дата
Msg-id CAM2+6=W7QWPe_yuTOKPSJj5+3deO9=Kg6ZHAQV1iv=3-ZM529Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: detect custom-format dumps in psql and emit a useful error  (Craig Ringer <craig@2ndquadrant.com>)
Ответы Re: detect custom-format dumps in psql and emit a useful error
Список pgsql-hackers
<div dir="ltr">Hi,<br /><br />Regarding Loading Custom Format Dump:<br />===<br />When we supply plain sql file to
pg_restore,we get following error:<br />$ ./install/bin/pg_restore a.sql <br />pg_restore: [archiver] input file does
notappear to be a valid archive<br /><br />So I would expect similar kind of message when we provide non-plain sql<br
/>fileto psql. Something like:<br />"input file does not appear to be a valid sql script file<br />(use pg_restore
instead)"<br/><br />I have added additional details in parenthesis as we correctly identified<br />it as a custom dump
fileand user wanted it to restore.<br /><br />However I do not see any issue with the patch.<br /><br /><br />Regarding
DirectoryError:<br />===<br />I strongly against the proposal. This patch changing error message to<br />something like
this:<br/>"psql:blah:0: Input path is a directory. Use pg_restore to restore<br />directory-format database dumps."<br
/><br/>So even though I accidentally provide a directory instead of a sql script<br />file when I have NO intention of
restoringa dump, above message looks<br />weired. Instead current message looks perfectly fine here. i.e.<br />"could
notread from input file: Is a directory"<br /><br />psql always expect a file and NOT directory. Also it is not
necessarily<br/>working on restoring a dump.<br /><br /><br />Thanks<br /></div><div class="gmail_extra"><br /><div
class="gmail_quote">OnFri, Oct 17, 2014 at 9:41 AM, Craig Ringer <span dir="ltr"><<a
href="mailto:craig@2ndquadrant.com"target="_blank">craig@2ndquadrant.com</a>></span> wrote:<br /><blockquote
class="gmail_quote"style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 09/18/2014 05:58 PM, Andres
Freundwrote:<br /> > I don't think we need to make any discinction between psql -f mydb.dump,<br /> > psql <
mydb.dump,and whatever | psql. Just check, when noninteractively<br /> > reading the first line in
mainloop.c:MainLoop(),whether it starts with<br /> > the magic header. That'd also trigger the warning on \i
pg_restore_file,<br/> > but that's hardly a problem.<br /><br /> Done, patch attached.<br /><br /> If psql sees that
thefirst line begins with PGDMP it'll emit:<br /><br />   The input is a PostgreSQL custom-format dump. Use the
pg_restore<br/>   command-line client to restore this dump to a database.<br /><br /> then discard the rest of the
currentinput source.<br /><br /> >> pg_restore already knows to tell you to use psql if it sees an SQL file<br />
>>as input. Having something similar for pg_dump would be really useful.<br /> ><br /> > Agreed.<br />
><br/> > We could additionally write out a hint whenever a directory is fed to<br /> > psql -f that psql can't
beused to read directory type dumps.<br /><br /> Unlike the confusion between pg_restore and psql for custom file
format<br/> dumps I haven't seen people getting this one muddled. Perhaps directory<br /> format dumps are just a bit
moreniche, or perhaps it's just more<br /> obvious that:<br /><br /> psql:sometump:0: could not read from input file:
Isa directory<br /><br /> ... means psql is the wrong tool.<br /><br /> Still, separate patch attached. psql will now
emit:<br/><br /> psql:blah:0: Input path is a directory. Use pg_restore to restore<br /> directory-format database
dumps.<br/><br /> I'm less sure that this is a worthwhile improvement than the check for<br /> PGDMP and custom format
dumpsthough.<br /><span class="HOEnZb"><font color="#888888"><br /> --<br />  Craig Ringer                   <a
href="http://www.2ndQuadrant.com/"target="_blank">http://www.2ndQuadrant.com/</a><br />  PostgreSQL Development, 24x7
Support,Training & Services<br /></font></span><br /><br /> --<br /> Sent via pgsql-hackers mailing list (<a
href="mailto:pgsql-hackers@postgresql.org">pgsql-hackers@postgresql.org</a>)<br/> To make changes to your
subscription:<br/><a href="http://www.postgresql.org/mailpref/pgsql-hackers"
target="_blank">http://www.postgresql.org/mailpref/pgsql-hackers</a><br/><br /></blockquote></div><br /><br clear="all"
/><br/>-- <br /><div dir="ltr">Jeevan B Chalke<br />Principal Software Engineer, Product Development<br />EnterpriseDB
Corporation<br/>The Enterprise PostgreSQL Company<br /><br />Phone: +91 20 30589500<br /><br />Website: <a
href="http://www.enterprisedb.com"target="_blank">www.enterprisedb.com</a><br />EnterpriseDB Blog: <a
href="http://blogs.enterprisedb.com/"target="_blank">http://blogs.enterprisedb.com/</a><br />Follow us on Twitter: <a
href="http://www.twitter.com/enterprisedb"target="_blank">http://www.twitter.com/enterprisedb</a><br /><br />This
e-mailmessage (and any attachment) is intended for the use of the individual or entity to whom it is addressed. This
messagecontains information from EnterpriseDB Corporation that may be privileged, confidential, or exempt from
disclosureunder applicable law. If you are not the intended recipient or authorized to receive this for the intended
recipient,any use, dissemination, distribution, retention, archiving, or copying of this communication is strictly
prohibited.If you have received this e-mail in error, please notify the sender immediately by reply e-mail and delete
thismessage.</div></div> 

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

Предыдущее
От: Etsuro Fujita
Дата:
Сообщение: Re: Improve automatic analyze messages for inheritance trees
Следующее
От: Dag-Erling Smørgrav
Дата:
Сообщение: [PATCH] add ssl_protocols configuration option