Re: [HACKERS] dollar quoting

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] dollar quoting
Date: 2004-02-09 06:25:10
Message-ID: 10105.1076307910@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan <andrew(at)dunslane(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Slavisa Garic 2004-02-09 06:34:37 Timestamps
Previous Message Michael Glaesemann 2004-02-09 05:57:13 Re: [HACKERS] Linking the previously separated documentation

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2004-02-09 07:05:02 Re: [HACKERS] dollar quoting
Previous Message Neil Conway 2004-02-09 02:06:26 Re: win32 inode fix