Re: [PATCHES] dollar quoting - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCHES] dollar quoting
Date
Msg-id 10105.1076307910@sss.pgh.pa.us
Whole thread Raw
In response to Re: dollar quoting  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: [PATCHES] dollar quoting  (Andrew Dunstan <andrew@dunslane.net>)
Re: [PATCHES] dollar quoting  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> Comments welcome. Reviewers: I am not sure I got multi-byte stuff right
> in psql/mainloop.c - please pay close attention to that.

The i-1 stuff should generally be i-prevlen.  Not sure if there are any
other pitfalls.

A bigger problem here:

> +             else if (!dol_quote && line[i] == '$' &&
> +                      !isdigit(line[i + thislen]) &&
> +                      (dol_end = strchr(line+i+1,'$')) != NULL &&
> +                      (i == 0 ||
> +                       ! ((line[i-1] & 0x80) != 0 || isalnum(line[i-1]) ||
> +                          line[i-1] == '_')))
> +             {

is that you aren't checking that what comes between the two dollar signs
looks like empty-or-an-identifier.  The check for
next-char-isn't-a-digit is part of that but not the only part.

Also I'm not sure about the positioning of these tests relative to the
in_quote and in_xcomment tests.  As you have it, $foo$ will be
recognized within an xcomment, which I think is at variance with the
proposed backend lexing behavior.

Also, the strdup should be pg_strdup.

            regards, tom lane

pgsql-hackers by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: Linking the previously separated documentation
Next
From: Tom Lane
Date:
Subject: Re: psql variables