Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 16B0B90656D for ; Sat, 19 Nov 2011 12:20:56 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RRnew-0001Bb-9n for pgsql-bugs@postgresql.org; Sat, 19 Nov 2011 16:20:55 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pAJGKdAX017806; Sat, 19 Nov 2011 11:20:39 -0500 (EST) To: Josh Kupershmidt cc: M , pgsql-bugs@postgresql.org Subject: Re: BUG #6301: extra space in psql variable expansion In-reply-to: References: <201111181812.pAIICbGk056384@wwwmaster.postgresql.org> Comments: In-reply-to Josh Kupershmidt message dated "Fri, 18 Nov 2011 15:48:18 -0500" Date: Sat, 19 Nov 2011 11:20:39 -0500 Message-ID: <17805.1321719639@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 201111/147 X-Sequence-Number: 31742 Josh Kupershmidt writes: > On Fri, Nov 18, 2011 at 1:12 PM, M wrote: >> When psql expands a :variable into a string it appends a space to the >> expansion string. It doesn't actually do that, but rather splits the argument into two arguments. \echo makes it look like there's spaces between arguments... > I don't see the exact commit which fixed this, but I do see some fixes > to psql's lexer done recently, such as > 928311a463d480ca566e2905a369ac6aa0c3e210, so maybe this case got fixed > as a nice side-effect. I think the description of that commit addresses the point exactly: ... we considered an argument completed as soon as we'd processed one backtick, variable reference, or quoted substring. A string like 'FOO'BAR was thus taken as two arguments not one, not exactly what one would expect. In the new coding, an argument is considered terminated only by unquoted whitespace or backslash. regards, tom lane