Re: Alternative to psql -c ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: James Le Cuirot <chewi(at)aura-online(dot)co(dot)uk>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Alternative to psql -c ?
Date: 2014-06-26 18:02:09
Message-ID: 42493.1403805729@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

James Le Cuirot <chewi(at)aura-online(dot)co(dot)uk> writes:
> 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?

PG is not capable of executing queries that are not in transactions,
so yes, PQsendQuery will create a single-statement transaction if you
haven't sent BEGIN. However, there's a huge difference for the
purposes we're discussing here: PQsendQuery does not allow more than
one SQL command in the string. So most of this discussion is irrelevant
when you're going through that API.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2014-06-26 18:16:53 Re: python modul pre-import to avoid importing each time
Previous Message Karthik Iyer 2014-06-26 17:37:02 Re: DATA corruption after promoting slave to master