Re: Alternative to psql -c ?

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: James Le Cuirot <chewi(at)aura-online(dot)co(dot)uk>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Alternative to psql -c ?
Date: 2014-06-26 13:20:18
Message-ID: CAHyXU0xrhGc+qsmAT1mZ3SKwqGh0SuKSTfWMp-cqnt-YVtp_rQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jun 26, 2014 at 7:59 AM, James Le Cuirot
<chewi(at)aura-online(dot)co(dot)uk> wrote:
> On Thu, 26 Jun 2014 07:23:02 -0500
> Merlin Moncure <mmoncure(at)gmail(dot)com> 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 with stdin and there is no
>> reasonable way to pass multiple scripts through the command line.
>> Adding it up this means that for generic multiple .sql passing you
>> have to wrap psql with a script.
>
> I never said that I wanted to pass multiple scripts, just singular
> scripts who's contents might be too large for the command line limit,
> and that they might contain transaction statements.

yup. Passing huge scripts via -c is definitely not a good practice.
-c is designed for things like firing off a stored procedure from cron
or bash variable assignment (for example: FOO=`psql -tXAqc"select
bar()"`)

> These scripts come from a Ruby string buffer so passing them via stdin
> would be preferable to having to dump them out to a file first. You say
> that single transaction mode doesn't work with stdin but it looks like
> this was fixed in 9.3.

yup -- i keep forgetting that. too many years of not having it i suppose.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Karthik Iyer 2014-06-26 14:44:46 Re: DATA corruption after promoting slave to master
Previous Message Adrian Klaver 2014-06-26 13:18:10 Re: python modul pre-import to avoid importing each time