Re: regclass and search_path

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Abbate <jma(at)freedomcircle(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: regclass and search_path
Date: 2011-03-18 04:17:36
Message-ID: 2858.1300421856@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Joe Abbate <jma(at)freedomcircle(dot)com> writes:
> I'm using this to validate a tool I'm building and I get an error on the
> following query:

> autodoc=> SELECT conname::regclass FROM pg_constraint
> autodoc-> WHERE contype = 'u';
> ERROR: relation "product_product_code_key" does not exist

Ummm ... pg_constraint.conname contains a constraint name, not a table
name, so casting it to regclass is highly likely to fail. This hasn't
got anything to do with search_path AFAICS, it's just a thinko.

Depending on what it is that you're hoping to do, any of conrelid,
confrelid, or conindid might be what you're after. All of those columns
would contain pg_class OIDs that could usefully be cast to regclass.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-03-18 04:29:02 Re: Re: [GENERAL] Re: [GENERAL] Different encoding for string values and identifier strings? Or (select 'tést' as tést) returns different values for string and identifier...
Previous Message bubba postgres 2011-03-18 00:05:32 why does extract ( HOUR FROM TIMESTAMP '2010-01-01 00:00:00' at time zone 'utc' ) == 16?