Re: A couple of issues with psql variable substitution

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: A couple of issues with psql variable substitution
Date: 2011-08-25 17:00:57
Message-ID: 17405.1314291657@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Thu, Aug 25, 2011 at 12:47 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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. We once measured the
>> backend's lexer as being about a third faster with backtrack avoidance,
>> and presumably it's about the same for psql's. This is not hard to fix,
>> but should I consider it a bug fix and back-patch? We've not had
>> complaints about psql getting slower as of 9.0.

> That may well have been me.

[ checks "git blame" ] Well, you commmitted the patch anyway: d0cfc018.

> How would I have known that I broke it?

Per the header comments in the backend lexer, you should run flex with
"-b" switch and verify that the resulting lex.backup file says "no
backing up". I've occasionally thought about automating that, but I'm
not sure if the output is entirely locale- and flex-version-independent.

> Also, how invasive is the fix?

We need to add a couple more rules that will match an unterminated
quoted variable and do something reasonable (probably just throw back
everything but the colon with yyless). I've not coded it but I think
it can't be more than a dozen lines or so.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2011-08-25 17:16:06 Re: A couple of issues with psql variable substitution
Previous Message Robert Haas 2011-08-25 16:51:16 Re: A couple of issues with psql variable substitution