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

From: Christophe Pettus <xof(at)thebuild(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 04:51:54
Message-ID: EA15C040-8E94-45B7-88AA-F46DFB9A13E2@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Oct 5, 2022, at 17:16, Bryn Llewellyn <bryn(at)yugabyte(dot)com> wrote:
> B.t.w, the value of "quote_ident()" rests on the distinction between a name (what you provide with the function's actual argument) 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 string which 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. If it quotes some strings that PostgreSQL would accept as identifiers without quotes, that's interesting, I guess, but I'm not 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 to be based on a situation where it can't be used for that.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bryn Llewellyn 2022-10-06 05:04:35 Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE
Previous Message Adrian Klaver 2022-10-06 04:31:44 Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE