Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/5/22 17:16, Bryn Llewellyn 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.
»

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). Some of you flatly reject (borrowing a phrase from Tom) the distinction between these two terms of art. Oh well…

What it returns is text, quoted if needed:

create table "$dog"(n int);

select  pg_typeof(quote_ident('$dog')), quote_ident('$dog');
 pg_typeof | quote_ident
-----------+-------------
 text      | "$dog"

The way I see is if it where an actual identifier then this:

select * from quote_ident('$dog');
 quote_ident
-------------
 "$dog"

would be equal to this:

select * from "$dog";
 n
---



--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux