Re: regclass and format('%I')

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Jason Dusek <jason(dot)dusek(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: regclass and format('%I')
Date: 2015-03-14 16:17:11
Message-ID: CAKFQuwaJ-h=STiSka6M7Rnk46g_1Tm5Z=BQxEA9iFXF5UQHmOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Saturday, March 14, 2015, Jason Dusek <jason(dot)dusek(at)gmail(dot)com> wrote:

> It honestly seems far more reasonable to me that %s and %I should do
> the exact same thing with regclass. My reasoning is as follows:
>
> ‘%I’ formats a something such that it is a valid identifier,
>
> regclass is already a valid identifier,
>
> therefore, do nothing.
>
> Another line of reasoning:
>
> If you format with ‘%s’ you are saying: I don’t care whether it’s a
> valid identifier or literal or whatever, just put the string there,
>
> but when we sub a regclass into a string, we want it to be a valid
> identifier,
>
> therefore we should write ‘%I’ when subbing it, so as not to confuse
> our readers,
>
> therefore ‘%I’ should do nothing.
>
>
I agree with the theory but adding type specific logic to format is going
to be difficult. The first thing the system does is convert all of the
inputs to text. Inside format() everything is text and so it has no way to
know that the type was regclass and should not be quoted again.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Seref Arikan 2015-03-14 18:09:37 is there a relationship between indexes and temporary file creation?
Previous Message Tom Lane 2015-03-14 15:29:11 Re: regclass and format('%I')