Re: [HACKERS] ALTER TABLE parent SET WITHOUT OIDS and the oid column

Поиск
Список
Период
Сортировка
От Amit Langote
Тема Re: [HACKERS] ALTER TABLE parent SET WITHOUT OIDS and the oid column
Дата
Msg-id 30d84106-0f7c-3dcf-998e-4cc000eb714f@lab.ntt.co.jp
обсуждение исходный текст
Ответ на Re: [HACKERS] ALTER TABLE parent SET WITHOUT OIDS and the oid column  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Ответы Re: [HACKERS] ALTER TABLE parent SET WITHOUT OIDS and the oid column  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Список pgsql-hackers
On 2016/12/27 22:24, Ashutosh Bapat wrote:
> On Mon, Dec 26, 2016 at 3:36 PM, Amit Langote
> <Langote_Amit_f8@lab.ntt.co.jp> wrote:
>> Attached patches modifies MergeAttributesIntoExisting() such that we
>> increment attinhcount not only for user attributes, but also for the oid
>> system column if one exists.
>>
>> Thoughts?
> 
> Yes, if a child inherits from a parent with OID, child gets OID column
> and its inhcount is set to 1.

[ ... ]

> So, I think your patch is on the right track.
> 
> We allow creating user attribute with name "oid" so you do not want to
> search system attribute oid by name. Instead search by attribute id
> ObjectIdAttributeNumber.

Good point.  Although, there can only be one of the two in a table at any
given time - either the "oid" system column or user-defined column named
"oid".  I was afraid that with the patch, the attinhcount of a
user-defined oid column may get incremented twice, but before that could
happen, one would get the error: "child table without OIDs cannot
inherited from table with OIDs"

create table foo (a int) with oids;
create table bar (a int, oid int);
alter table bar inherit foo;
ERROR:  table "bar" without OIDs cannot inherit from table "foo" with OIDs

And then:

alter table bar set with oids;
ERROR:  column "oid" of relation "bar" already exists

Thanks,
Amit





В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Tsunakawa, Takayuki"
Дата:
Сообщение: Re: [HACKERS] Hooks
Следующее
От: David Fetter
Дата:
Сообщение: Re: [HACKERS] Hooks