Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE - Mailing list pgsql-general

From David G. Johnston
Subject Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE
Date
Msg-id CAKFQuwbJhEdos8S4ea0hJXfAToGL1y8qFsOeCPzZzu+NkixcXA@mail.gmail.com
Whole thread Raw
In response to ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE  (Bryn Llewellyn <bryn@yugabyte.com>)
Responses Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE
List pgsql-general
On Wed, Oct 5, 2022 at 5:17 PM Bryn Llewellyn <bryn@yugabyte.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."


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.

pgsql-general by date:

Previous
From: Bryn Llewellyn
Date:
Subject: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE
Next
From: Tom Lane
Date:
Subject: Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE