Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE
Date: 2022-10-06 00:31:48
Message-ID: CAKFQuwbJhEdos8S4ea0hJXfAToGL1y8qFsOeCPzZzu+NkixcXA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Oct 5, 2022 at 5:17 PM Bryn Llewellyn <bryn(at)yugabyte(dot)com> wrote:

> The doc for "quote_ident()" says this:
>
> «
> https://www.postgresql.org/docs/14/functions-string.html
> Returns the given string suitably quoted to be used as an identifier in an
> SQL statement string. Quotes are added only if necessary (i.e., if the
> string contains non-identifier characters or would be case-folded).
> Embedded quotes are properly doubled.
> »
>
But it's incorrect w.r.t. "quotes are added only if necessary" for this to
> return FALSE:
>
> select 'dog$' = quote_ident('dog$');
>

The documentation also says:

"Note that dollar signs are not allowed in identifiers according to the
letter of the SQL standard, so their use might render applications less
portable."

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

So I can see an argument for the existing behavior. It doesn't seem worth
changing in any case. And I don't really see the documentation being
improved by covering this corner case in detail when the current behavior
is at least intuitive.
David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2022-10-06 01:20:26 Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE
Previous Message Bryn Llewellyn 2022-10-06 00:16:51 ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE