pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Bryn Llewellyn <bryn@yugabyte.com>
To: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE
Date: Wed, 5 Oct 2022 21:31:44 -0700
Message-ID: <4fc877f4-14c1-9753-ff42-10c16baa4076@aklaver.com> (raw)
In-Reply-To: <CA4667FA-A71E-4ECD-B9EE-4A2F8929CB22@yugabyte.com>
References: <CA4667FA-A71E-4ECD-B9EE-4A2F8929CB22@yugabyte.com>

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@aklaver.com






view thread (16+ messages)  latest in thread

Message-ID: <4fc877f4-14c1-9753-ff42-10c16baa4076@aklaver.com>
Permalink:  ../4fc877f4-14c1-9753-ff42-10c16baa4076@aklaver.com/
Also on:    postgresql.org/message-id/4fc877f4-14c1-9753-ff42-10c16baa4076@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, bryn@yugabyte.com
  Subject: Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE
  In-Reply-To: <4fc877f4-14c1-9753-ff42-10c16baa4076@aklaver.com>
  References: <CA4667FA-A71E-4ECD-B9EE-4A2F8929CB22@yugabyte.com> <4fc877f4-14c1-9753-ff42-10c16baa4076@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox