[HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Tom Lane
On my way to do something else entirely, I came across a couple of things that are not very nice about psql's lexer: 1. Somebody broke the no-backtracking property back in 9.0 while adding quoted variable substitution. According to the flex manual, use of backtracking creates a performance

Re: [HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Robert Haas
On Thu, Aug 25, 2011 at 12:47 PM, Tom Lane t...@sss.pgh.pa.us wrote: On my way to do something else entirely, I came across a couple of things that are not very nice about psql's lexer: 1. Somebody broke the no-backtracking property back in 9.0 while adding quoted variable substitution.  

Re: [HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Thu, Aug 25, 2011 at 12:47 PM, Tom Lane t...@sss.pgh.pa.us wrote: 1. Somebody broke the no-backtracking property back in 9.0 while adding quoted variable substitution. According to the flex manual, use of backtracking creates a performance penalty.

Re: [HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Alvaro Herrera
Excerpts from Tom Lane's message of jue ago 25 14:00:57 -0300 2011: Robert Haas robertmh...@gmail.com writes: On Thu, Aug 25, 2011 at 12:47 PM, Tom Lane t...@sss.pgh.pa.us wrote: 1. Somebody broke the no-backtracking property back in 9.0 while adding quoted variable substitution. According

Re: [HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Andrew Dunstan
On 08/25/2011 01:16 PM, Alvaro Herrera wrote: Excerpts from Tom Lane's message of jue ago 25 14:00:57 -0300 2011: Robert Haasrobertmh...@gmail.com writes: On Thu, Aug 25, 2011 at 12:47 PM, Tom Lanet...@sss.pgh.pa.us wrote: 1. Somebody broke the no-backtracking property back in 9.0 while

Re: [HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Tom Lane
Andrew Dunstan and...@dunslane.net writes: We could just add -b unconditionally to the flex flags and then count the number of lines in lex.backup. If it's greater that 1 whine loudly, or even fail, otherwise remove lex.backup. Would that avoid locale dependencies? Hm, yeah, seems like

Re: [HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Tom Lane
I wrote: Andrew Dunstan and...@dunslane.net writes: We could just add -b unconditionally to the flex flags and then count the number of lines in lex.backup. If it's greater that 1 whine loudly, or even fail, otherwise remove lex.backup. Would that avoid locale dependencies? Hm, yeah,

Re: [HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Tom Lane
While I'm looking at this ... the current implementation has got a number of very inconsistent behaviors with respect to when it will expand a variable reference within a psql meta-command argument. Observe: regression=# \set foo 'value of foo' regression=# \set bar 'value of bar' regression=#

Re: [HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Robert Haas
On Thu, Aug 25, 2011 at 5:12 PM, Tom Lane t...@sss.pgh.pa.us wrote: While I'm looking at this ... the current implementation has got a number of very inconsistent behaviors with respect to when it will expand a variable reference within a psql meta-command argument. Observe: regression=#

Re: [HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Andrew Dunstan
On 08/25/2011 02:45 PM, Tom Lane wrote: I wrote: Andrew Dunstanand...@dunslane.net writes: We could just add -b unconditionally to the flex flags and then count the number of lines in lex.backup. If it's greater that 1 whine loudly, or even fail, otherwise remove lex.backup. Would that

Re: [HACKERS] A couple of issues with psql variable substitution

2011-08-25 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Thu, Aug 25, 2011 at 5:12 PM, Tom Lane t...@sss.pgh.pa.us wrote: ISTM the general rule ought to be that we attempt to substitute for a colon-construct regardless of where it appears within an argument, as long as it's not within quotes. My main