Re: [GENERAL] Alternative to psql -c ?

2014-06-27 Thread James Le Cuirot
On Thu, 26 Jun 2014 15:00:56 -0700 Tom Lane wrote: > James Le Cuirot writes: > > Tom Lane wrote: > >> 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

Re: [GENERAL] Alternative to psql -c ?

2014-06-26 Thread Tom Lane
James Le Cuirot writes: > Tom Lane wrote: >> 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: PQsendQu

Re: [GENERAL] Alternative to psql -c ?

2014-06-26 Thread James Le Cuirot
On Thu, 26 Jun 2014 11:02:09 -0700 Tom Lane wrote: > James Le Cuirot 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 > > di

Re: [GENERAL] Alternative to psql -c ?

2014-06-26 Thread Tom Lane
James Le Cuirot 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 c

Re: [GENERAL] Alternative to psql -c ?

2014-06-26 Thread Merlin Moncure
On Thu, Jun 26, 2014 at 7:59 AM, James Le Cuirot wrote: > On Thu, 26 Jun 2014 07:23:02 -0500 > Merlin Moncure wrote: >> To be clear, Tom was advising not to rely on some of the quirky >> aspects of -c. psql as it stands right now has a some limitations: >> single transaction mode does not work w

Re: [GENERAL] Alternative to psql -c ?

2014-06-26 Thread James Le Cuirot
On Thu, 26 Jun 2014 07:23:02 -0500 Merlin Moncure wrote: > On Thu, Jun 26, 2014 at 4:30 AM, James Le Cuirot > wrote: > > On Wed, 25 Jun 2014 13:21:44 -0500 > > Merlin Moncure wrote: > > > >> > The cookbook currently uses PQexec so multiple SQL commands are > >> > wrapped in a transaction unless

Re: [GENERAL] Alternative to psql -c ?

2014-06-26 Thread Merlin Moncure
On Thu, Jun 26, 2014 at 4:30 AM, James Le Cuirot wrote: > On Wed, 25 Jun 2014 13:21:44 -0500 > Merlin Moncure wrote: > >> > The cookbook currently uses PQexec so multiple SQL commands are >> > wrapped in a transaction unless an explicit transaction >> > instruction appears. I don't want to change

Re: [GENERAL] Alternative to psql -c ?

2014-06-26 Thread James Le Cuirot
On Wed, 25 Jun 2014 17:30:15 +0200 hubert depesz lubaczewski wrote: > On Wed, Jun 25, 2014 at 5:18 PM, James Le Cuirot > wrote: > > > > Also - I have no idea what "peer authentication" has to do with Pg > > > gem - care to elaborate? The gem is for client, and authentication > > > happens in se

Re: [GENERAL] Alternative to psql -c ?

2014-06-26 Thread James Le Cuirot
On Wed, 25 Jun 2014 10:34:57 -0500 Jerry Sievers wrote: > > The cookbook currently uses PQexec so multiple SQL commands are > > wrapped in a transaction unless an explicit transaction > > instruction appears. I don't want to change this behaviour but > > the only way to get exactly the same effec

Re: [GENERAL] Alternative to psql -c ?

2014-06-26 Thread James Le Cuirot
On Wed, 25 Jun 2014 13:21:44 -0500 Merlin Moncure wrote: > > The cookbook currently uses PQexec so multiple SQL commands are > > wrapped in a transaction unless an explicit transaction > > instruction appears. I don't want to change this behaviour but > > the only way to get exactly the same effe

Re: [GENERAL] Alternative to psql -c ?

2014-06-26 Thread James Le Cuirot
On Wed, 25 Jun 2014 09:04:44 -0700 Tom Lane wrote: > James Le Cuirot writes: > > hubert depesz lubaczewski 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 tr

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread Merlin Moncure
On Wed, Jun 25, 2014 at 8:43 AM, James Le Cuirot wrote: > Hello, > > I've been using the Chef database cookbook and found it > frustrating because it doesn't allow you to use peer > authentication. The client process generally runs as root and > connects to PostgreSQL using the Ruby pg gem. > > I

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread Tom Lane
James Le Cuirot writes: > hubert depesz lubaczewski 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

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread Jerry Sievers
James Le Cuirot writes: > Hello, > > I've been using the Chef database cookbook and found it > frustrating because it doesn't allow you to use peer > authentication. The client process generally runs as root and > connects to PostgreSQL using the Ruby pg gem. > > I have patched it to shell out to

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread Christoph Berg
Re: James Le Cuirot 2014-06-25 <20140625144325.49d1124d@red.yakaraplc.local> > Hello, > > I've been using the Chef database cookbook and found it > frustrating because it doesn't allow you to use peer > authentication. The client process generally runs as root and > connects to PostgreSQL using th

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread hubert depesz lubaczewski
On Wed, Jun 25, 2014 at 5:18 PM, James Le Cuirot wrote: > > Also - I have no idea what "peer authentication" has to do with Pg > > gem - care to elaborate? The gem is for client, and authentication > > happens in server, so ... ? > Right but peer authentication is all to do with the operating sys

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread James Le Cuirot
On Wed, 25 Jun 2014 16:42:53 +0200 hubert depesz lubaczewski wrote: > On Wed, Jun 25, 2014 at 4:37 PM, James Le Cuirot > wrote: > > > On Wed, 25 Jun 2014 10:24:53 -0400 > > Andrew Sullivan wrote: > > > > > On Wed, Jun 25, 2014 at 03:16:19PM +0100, James Le Cuirot wrote: > > > > Same problem as

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread hubert depesz lubaczewski
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? Also - I have no idea what "peer authentication" has to do with Pg gem - care to elaborate? The gem is for client, and authentication happens in server, so ...

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread Andrew Sullivan
On Wed, Jun 25, 2014 at 03:37:11PM +0100, James Le Cuirot wrote: > Sorry, you're missing the point. I'm trying not to alter the existing > behaviour of the Chef database cookbook Ah, got it. Sorry, I'm clueless. No, I don't think I have a suggestion, then. A -- Andrew Sullivan a...@crankycan

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread James Le Cuirot
On Wed, 25 Jun 2014 10:24:53 -0400 Andrew Sullivan wrote: > On Wed, Jun 25, 2014 at 03:16:19PM +0100, James Le Cuirot wrote: > > Same problem as stdin, the transactional behaviour is different. > > There is the --single-transaction option but as the man page says... > > > > "If the script itself

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread Andrew Sullivan
On Wed, Jun 25, 2014 at 03:16:19PM +0100, James Le Cuirot wrote: > Same problem as stdin, the transactional behaviour is different. There > is the --single-transaction option but as the man page says... > > "If the script itself uses BEGIN, COMMIT, or ROLLBACK, this option will > not have the desi

Re: [GENERAL] Alternative to psql -c ?

2014-06-25 Thread James Le Cuirot
On Wed, 25 Jun 2014 10:09:18 -0400 Andrew Sullivan wrote: > On Wed, Jun 25, 2014 at 02:43:25PM +0100, James Le Cuirot wrote: > > > The cookbook currently uses PQexec so multiple SQL commands are > > wrapped in a transaction unless an explicit transaction > > instruction appears. I don't want to c

[GENERAL] Alternative to psql -c ?

2014-06-25 Thread James Le Cuirot
Hello, I've been using the Chef database cookbook and found it frustrating because it doesn't allow you to use peer authentication. The client process generally runs as root and connects to PostgreSQL using the Ruby pg gem. I have patched it to shell out to psql instead. This has the added benefi