Re: Killing OIDs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jd(at)commandprompt(dot)com, Steve Crawford <scrawford(at)pinpointresearch(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Killing OIDs
Date: 2009-02-11 18:59:34
Message-ID: 12568.1234378774@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I wrote:
> Sure it will. I'd be a little worried about whether he shouldn't
> be using quote_identifier and/or schema-qualifying the names, but
> SET WITHOUT OIDS is the right command to be issuing.

BTW, the lazy man's way to deal with both of those issues is to cast
the OID to regclass, ie the best way to handle this is

SELECT
'ALTER TABLE ' || oid::regclass || ' SET WITHOUT OIDS;'
FROM pg_class WHERE ...

Observe the following example:

regression=# create schema s1 create table "Foo"(f1 int);
CREATE SCHEMA
regression=# select max(oid)::regclass from pg_class;
max
----------
s1."Foo"
(1 row)

You can similarly use regprocedure, regoperator, etc to get
safely qualified names for functions, operators etc.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2009-02-11 19:40:50 Re: Killing OIDs
Previous Message Steve Crawford 2009-02-11 18:55:31 Re: Killing OIDs