regclass and format('%I') - Mailing list pgsql-general

From Jason Dusek
Subject regclass and format('%I')
Date
Msg-id CAO3NbwM3b+K7vvwrRSu3J+PFd60Da8N3_ou3DsNJPyf-2cAySA@mail.gmail.com
Whole thread Raw
Responses Re: regclass and format('%I')  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
Hi All,

The difference in how format handles `regclass` and `name` seems like an
inconsistency:

    WITH conversions(casts, format, result) AS (
    VALUES (ARRAY['name']::regtype[],             '%I', format('%I',
name('select'))),
           (ARRAY['name']::regtype[],             '%L', format('%L',
name('select'))),
           (ARRAY['name']::regtype[],             '%s', format('%s',
name('select'))),
           (ARRAY['regclass']::regtype[],         '%I', format('%I',
regclass('select'))),
           (ARRAY['regclass']::regtype[],         '%L', format('%L',
regclass('select'))),
           (ARRAY['regclass']::regtype[],         '%s', format('%s',
regclass('select'))),
           (ARRAY['regclass', 'name']::regtype[], '%I', format('%I',
name(regclass('select')))),
           (ARRAY['regclass', 'name']::regtype[], '%L', format('%L',
name(regclass('select')))),
           (ARRAY['regclass', 'name']::regtype[], '%s', format('%s',
name(regclass('select'))))
    ) SELECT * FROM conversions;
          casts      | format |    result
    -----------------+--------+--------------
     {name}          | %I     | "select"
     {name}          | %L     | 'select'
     {name}          | %s     | select
     {regclass}      | %I     | """select"""
     {regclass}      | %L     | '"select"'
     {regclass}      | %s     | "select"
     {regclass,name} | %I     | """select"""
     {regclass,name} | %L     | '"select"'
     {regclass,name} | %s     | "select"

My assumption is that they both represent valid SQL identifiers, so it stands
to reason that `%I` should result in a valid identifier for both of them (or
neither one).

Kind Regards,
  Jason Dusek


pgsql-general by date:

Previous
From: Dara Unglaube
Date:
Subject: Re: Rebuild streaming replication
Next
From: Steve Boyle
Date:
Subject: bdr replication latency monitoring