Re: unexpected psql "feature"
От | Alvaro Herrera |
---|---|
Тема | Re: unexpected psql "feature" |
Дата | |
Msg-id | 20160713224526.GA944483@alvherre.pgsql обсуждение исходный текст |
Ответ на | Re: unexpected psql "feature" ("David G. Johnston" <david.g.johnston@gmail.com>) |
Ответы |
Re: unexpected psql "feature"
|
Список | pgsql-hackers |
David G. Johnston wrote: > On Wed, Jul 13, 2016 at 5:44 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote: > > > Although "\;" behavior is not documented, I would have expected both > >>> results to be shown one after the other, or having a an error, but not a > >>> quiet discard. > >> > >> See the documentation for PQexec(): all but the last query result is > >> discarded. > > > > Sure. That is developer-level answer to "why", although it does not really > > say why the developer chose PQexex over PQsendQuery. At the user-level the > > behavior is still pretty surprising. > > Lets try putting it this way... > > As a psql user I want some way to choose whether I send my query via > "PQexec" or "PQsendQuery". I'm not sure why the "PQexec" access point is > undocumented but this "\;" syntax, vis-a-vis ";" provides me that choice. psql splits the input string on semicolons and submits each resulting part separately using PQexec. Since \; defeats the splitting efforts, what happens is that the whole tihng is submitted via PQexec() as a single unit instead. PQsendQuery is never used by psql. Now PQexec is documented to return only the last resultset if you send more than one query through it; so that part seems okay since it's been documented this way forever. However, psql is not documented to use PQexec, it just happens to use it. Now, I think requesting psql not to split query strings is a good feature, but having it depend on using \; instead of ; seems way too obscure. If we want to offer that choice, I propose we do it via some properly designed mechanism rather than being a random emergent characteristic falling out of a bunch of historical coincidences. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
В списке pgsql-hackers по дате отправления: