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

From Christophe Pettus
Subject Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE
Date
Msg-id EA15C040-8E94-45B7-88AA-F46DFB9A13E2@thebuild.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 Oct 5, 2022, at 17:16, Bryn Llewellyn <bryn@yugabyte.com> wrote:
> B.t.w, the value of "quote_ident()" rests on the distinction between a name (what you provide with the function's
actualargument) and an identifier (what it returns). 

There is no first-class "identifier" type in PostgreSQL, so a function can't "return an identifier."  It returns a
stringwhich might, when placed into a larger string and processed as SQL, be lexically correct as an identifier. 

To be useful, quote_ident() can't fail to quote a string in such a way that it's not a valid identifier to PostgreSQL.
Ifit quotes some strings that PostgreSQL would accept as identifiers without quotes, that's interesting, I guess, but
I'mnot sure I see how it is a bug. 

Pragmatically, what this function is for it to assemble SQL statements as strings.  Any review of its correctness needs
tobe based on a situation where it can't be used for that. 


pgsql-general by date:

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