| From: | Bruce Momjian <bruce(at)momjian(dot)us> | 
|---|---|
| To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> | 
| Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> | 
| Subject: | Re: proposal: doc: simplify examples of dynamic SQL | 
| Date: | 2015-03-20 20:56:09 | 
| Message-ID: | 20150320205609.GQ6317@momjian.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On Fri, Mar 20, 2015 at 05:47:49PM -0300, Alvaro Herrera wrote:
> Bruce Momjian wrote:
> > On Fri, Mar 20, 2015 at 08:54:24AM -0700, David G. Johnston wrote:
> 
> > > 1. The layout of the format version is different, with respect to newlines,
> > > than the quote version; but while using newlines for the mandatory
> > > concatenation is good having an excessively long format string isn't desirable
> > > and so maybe we should show something like:
> > > 
> > > EXECUTE format('SELECT count(*) FROM %I '
> > > || 'WHERE inserted_by = $1 AND insert <= $2', tabname)
> > > INTO c
> > > USING checked_user, checked_date
> > 
> > I think that is very confusing --- the idea is that we don't need to use
> > || with format, but you are then using || to span multiple lines.
> 
> That || seems fine, since it's only used for a line continuation; having
> || scattered all over the query string to interpolate each variable is
> much more unreadable.
> 
> That said, the || there is unnecessary because per standard two literals 'lit1'
> 'lit2' 
> are concatenated if they are separated by a newline.  So this
> 
>  EXECUTE format('SELECT count(*) FROM %I '
>   'WHERE inserted_by = $1 AND insert <= $2', tabname)
>  INTO c
>  USING checked_user, checked_date
> 
> should suffice.
OK, I used your idea, patch attached.
> BTW very long lines are undesirable because they are truncated in the
> PDF output.
True, but the length was only 95 characters --- is that too long for our
PDFs?
-- 
  Bruce Momjian  <bruce(at)momjian(dot)us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com
  + Everyone has their own god. +
| Attachment | Content-Type | Size | 
|---|---|---|
| format.diff | text/x-diff | 8.5 KB | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2015-03-20 20:58:29 | Re: Typos in CREATE TABLE doc | 
| Previous Message | Alvaro Herrera | 2015-03-20 20:47:49 | Re: proposal: doc: simplify examples of dynamic SQL |