Re: Replacing plpgsql's lexer - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Replacing plpgsql's lexer
Date
Msg-id 23254.1239984732@sss.pgh.pa.us
Whole thread Raw
In response to Replacing plpgsql's lexer  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Replacing plpgsql's lexer  (David Fetter <david@fetter.org>)
Re: Replacing plpgsql's lexer  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I wrote:
> I had earlier speculated semi-facetiously about ripping out the plpgsql
> lexer altogether, but the more I think about it the less silly the idea
> looks.

This little project crashed and burned upon remembering that plpgsql
invokes raw_parser() to syntax-check each chunk of SQL that it extracts.
If plpgsql were using the main lexer, that would mean recursive use of
the lexer --- and it's not re-entrant.

We could think about making the main lexer re-entrant, but that would
involve a bump in the minimum required flex version (I don't know when
%option reentrant got added, but it's not in 2.5.4).  And it definitely
doesn't seem like something to be doing during beta.

Getting rid of the requirement for recursion doesn't look palatable
either.  We don't want to delay the syntax check for reasons explained
in check_sql_expr()'s comments; and that's not the only source of
recursion anyway --- plpgsql_parse_datatype does it too, and there could
be other places.

So I think we are down to a choice of doing nothing for 8.4, or teaching
the existing plpgsql lexer about standard_conforming_strings.  Assuming
the current proposal for U& literals holds up, it should not be
necessary for plpgsql to know about those explicitly as long as it obeys
standard_conforming_strings, so this might not be too horrid a project.
I'll take a look at that next.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Marko Kreen
Date:
Subject: Re: [rfc] unicode escapes for extended strings
Next
From: Alberto J. Castiñeira P.
Date:
Subject: oid in a where