pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rich Shepard <rshepard@appl-ecosys.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Escape parentheses in aggregate function
Date: Fri, 30 Aug 2019 12:58:39 -0400
Message-ID: <30961.1567184319@sss.pgh.pa.us> (raw)
In-Reply-To: <alpine.LNX.2.20.1908300918100.22705@salmo.appl-ecosys.com>
References: <alpine.LNX.2.20.1908300805200.22705@salmo.appl-ecosys.com>
	<26321.1567178286@sss.pgh.pa.us>
	<alpine.LNX.2.20.1908300918100.22705@salmo.appl-ecosys.com>

Rich Shepard <rshepard@appl-ecosys.com> writes:
> On Fri, 30 Aug 2019, Tom Lane wrote:
>> I think your problem is the line break, not the parentheses. psql knows
>> how to count parens, but it has no concept of letting backslash commands
>> continue across lines.

> Interesting. I've adopted separating select statements by their expressions
> as it makes it easier for me to get it right, or fix it. However, I can put
> it all on a single line once I know the syntax is correct and I add the
> \copy() function.

FWIW, if you're running a current release then there's a reasonable
alternative for writing multi-line COPY-from-query commands; see commit
log below.

			regards, tom lane


Author: Tom Lane <tgl@sss.pgh.pa.us>
Branch: master Release: REL_12_BR [6d3ede5f1] 2019-01-26 14:15:42 -0500
Branch: REL_11_STABLE Release: REL_11_2 [2c50c9f23] 2019-01-26 14:15:42 -0500
Branch: REL_10_STABLE Release: REL_10_7 [8e97a97b3] 2019-01-26 14:15:42 -0500
Branch: REL9_6_STABLE Release: REL9_6_12 [ae4c7d5ab] 2019-01-26 14:15:42 -0500
Branch: REL9_5_STABLE Release: REL9_5_16 [cda1e27fb] 2019-01-26 14:15:42 -0500

    Fix psql's "\g target" meta-command to work with COPY TO STDOUT.
    
    Previously, \g would successfully execute the COPY command, but
    the target specification if any was ignored, so that the data was
    always dumped to the regular query output target.  This seems like
    a clear bug, so let's not just fix it but back-patch it.
    
    While at it, adjust the documentation for \copy to recommend
    "COPY ... TO STDOUT \g foo" as a plausible alternative.
    
    Back-patch to 9.5.  The problem exists much further back, but the
    code associated with \g was refactored enough in 9.5 that we'd
    need a significantly different patch for 9.4, and it doesn't
    seem worth the trouble.
    
    Daniel Vérité, reviewed by Fabien Coelho
    
    Discussion: https://postgr.es/m/15dadc39-e050-4d46-956b-dcc4ed098753@manitou-mail.org





view thread (5+ messages)  latest in thread

Message-ID: <30961.1567184319@sss.pgh.pa.us>
Permalink:  ../30961.1567184319@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/30961.1567184319@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rshepard@appl-ecosys.com
  Subject: Re: Escape parentheses in aggregate function
  In-Reply-To: <30961.1567184319@sss.pgh.pa.us>
  References: <alpine.LNX.2.20.1908300805200.22705@salmo.appl-ecosys.com> <26321.1567178286@sss.pgh.pa.us> <alpine.LNX.2.20.1908300918100.22705@salmo.appl-ecosys.com> <30961.1567184319@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox