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

From James Le Cuirot
Subject Re: Alternative to psql -c ?
Date
Msg-id 20140626102204.36ced4dd@red.yakaraplc.local
Whole thread Raw
In response to Re: Alternative to psql -c ?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Alternative to psql -c ?
List pgsql-general
On Wed, 25 Jun 2014 09:04:44 -0700
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> 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.

> 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.

The mention of "legacy behaviour" and "unexpected results" in the
psql man page hadn't gone unnoticed but I didn't think I would be able
to convince the Chef guys to change their approach based on that. I
think I stand a much better chance now that you of all people have said
it though so thanks. :)

This got me wondering what Rails uses. I dug into ActiveRecord and
found that apart from the odd call to PQexec with hardcoded single
statements, it uses PQsendQuery. The libpq docs state a few of the
differences but don't mention whether PQsendQuery automatically creates
a transaction like PQexec does. Please could you clarify this?

Regards,
James


pgsql-general by date:

Previous
From: Rémi Cura
Date:
Subject: Re: python modul pre-import to avoid importing each time
Next
From: Tim Uckun
Date:
Subject: Fast data, slow data