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

Поиск
Список
Период
Сортировка
От Bryn Llewellyn
Тема ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE
Дата
Msg-id CA4667FA-A71E-4ECD-B9EE-4A2F8929CB22@yugabyte.com
обсуждение исходный текст
Ответы Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE  (Christophe Pettus <xof@thebuild.com>)
Список pgsql-general
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
ifnecessary (i.e., if the string contains non-identifier characters or would be case-folded). Embedded quotes are
properlydoubled. 
»

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

Try this:

create table dog$(n int); -- OK
create table $dog(n int); -- Bad
create table "$dog"(n int); -- OK

These outcomes are consistent with the rules that say when a proposed name needs to be double-quoted to form its
identifierin a SQL statement (or PL/pgSQL source text). 

So it's correct for this to return FALSE:

select '$dog' = quote_ident('$dog');

But it's incorrect w.r.t. "quotes are added only if necessary" for this to return FALSE:

select 'dog$' = quote_ident('dog$');

"format()" shows the same error when you use the %I placeholder. I suppose that "format()" and "quote_ident()" share
thesame underlying implementation. 

select format('What happens with %I?', 'dog'); -- double quotes are not added
select format('What happens with %I?', 'dog$'); -- double quotes are added




В списке pgsql-general по дате отправления:

Предыдущее
От: Josef Šimánek
Дата:
Сообщение: Re: Postgres calendar?
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE