Re: proposal: doc: simplify examples of dynamic SQL
От | Alvaro Herrera |
---|---|
Тема | Re: proposal: doc: simplify examples of dynamic SQL |
Дата | |
Msg-id | 20150320204749.GZ3636@alvh.no-ip.org обсуждение исходный текст |
Ответ на | Re: proposal: doc: simplify examples of dynamic SQL (Bruce Momjian <bruce@momjian.us>) |
Ответы |
Re: proposal: doc: simplify examples of dynamic SQL
Re: proposal: doc: simplify examples of dynamic SQL |
Список | pgsql-hackers |
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 cUSING checked_user, checked_date should suffice. BTW very long lines are undesirable because they are truncated in the PDF output. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
В списке pgsql-hackers по дате отправления: