Re: bug regclass::oid

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: John Mikel <blpmftat(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: bug regclass::oid
Date: 2019-06-17 14:11:32
Message-ID: 66c3ca92-8276-669f-6f9e-d20a6f32ee10@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 6/17/19 1:58 AM, John Mikel wrote:
>
> hi again
>
>
> here is my query
> *select   A.table_name  as "table_name",A.domain_name as "domain",*
> * format_type(c.atttypid, c.atttypmod)  AS data_type ,A.column_name as
> "column_name",*
> *  A.is_nullable as "nullable",A.column_default as "default"*
> *  from information_schema.columns A inner  join pg_attribute c  on
>  a.table_name::regclass::oid=c.attrelid*
> *  where  a.table_schema in (select current_schema()) and  a.column_name
> =c.attname ;*
>
> if i run this query in any database contain at least one table with
> space in their name , an error will occur
> if i run this query in other database will work fine
> I tested this on pg 11.1  , pg 10.3, pg 9.6
>
> PS:Sorry if this message is duplicated i canceled the previous message
> by mistake by clicking on link
>

The previous message came through, see the replies. The basic issue is
that a table name with a space in it will need to be quoted. So use
quote_ident() per Peter and Tom's suggestions.

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Leandro Guimarães 2019-06-17 15:14:14 Re: Copy Bulk Ignore Duplicated
Previous Message Dave Cramer 2019-06-17 14:00:30 Re: Async client libraries - not worth it?