Re: Alternative to psql -c ? - Mailing list pgsql-general

From Tom Lane
Subject Re: Alternative to psql -c ?
Date
Msg-id 75889.1403712284@sss.pgh.pa.us
Whole thread Raw
In response to Re: Alternative to psql -c ?  (James Le Cuirot <chewi@aura-online.co.uk>)
Responses Re: Alternative to psql -c ?
List pgsql-general
James Le Cuirot <chewi@aura-online.co.uk> writes:
> hubert depesz lubaczewski <depesz@gmail.com> wrote:
>> Perhaps you can explain what is the functionality you want to
>> achieve, as I, for one, don't understand. Do you want transactions?
>> Or not?

> I want an implicit transaction around the whole script if no explicit
> transactions are present in the script. This is what psql's -c option
> does and this is also what the pg gem does because both use PQexec.

Well, psql -c (and also multiple commands in PQexec) have more odd
behaviors than that.  Notably, any error causes abandonment of the *whole*
string, even if it's got begin/end commands in it.

Most people think that psql -c's behavior is a legacy thing that we ought
to change someday; if backwards compatibility weren't such a big deal
around here, we might've done it already.  You can find multiple bugs in
the pgsql-bugs archives that amount to complaints that psql -c ought to
work more like reading from stdin or a file.  I don't think it's a good
idea for you to try to arrange things so that untold amounts of code is
depending on that behavior never changing.

In short, I think it would be good to push back on the way Chef is doing
things now, not perpetuate a dependency on a legacy behavior.

            regards, tom lane


pgsql-general by date:

Previous
From: Jerry Sievers
Date:
Subject: Re: Alternative to psql -c ?
Next
From: Karthik Iyer
Date:
Subject: DATA corruption after promoting slave to master