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