Re: constraints & tableoid [pgsql8.1] - Mailing list pgsql-bugs

From 姜维
Subject Re: constraints & tableoid [pgsql8.1]
Date
Msg-id 443BB9AF.1080505@sduept.com
Whole thread Raw
In response to Re: constraints & tableoid [pgsql8.1]  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Tom Lane 写道:
> Michael Fuhr <mike@fuhr.org> writes:
>
>> Apparently a new row's tableoid isn't set until the row is actually
>> inserted.
>>
>
> I believe that's true of all the system columns.  If you're using oid,
> for example, that's not assigned either until heap_insert().
>
> This behavior doesn't seem unreasonable to me.  A candidate row is not a
> member of the table until *after* it's passed its constraint checks ---
> until then, it's just some values sitting in memory.
>
>             regards, tom lane
>
>
jw=# ALTER TABLE base DROP CONSTRAINT base_tableoid_check;
ALTER TABLE
jw=# ALTER TABLE base ADD CHECK (tableoid = 0);
ALTER TABLE
jw=# INSERT INTO base DEFAULT VALUES ;
INSERT 0 1
jw=# INSERT INTO base DEFAULT VALUES ;
INSERT 0 1
jw=# INSERT INTO base DEFAULT VALUES ;
INSERT 0 1
jw=# select *,tableoid from base;
tableoid
----------
301146
301146
301146
(3 rows)
jw=# \d+ base
Table "public.base"
Column | Type | Modifiers | Description
--------+------+-----------+-------------
Check constraints:
"base_tableoid_check" CHECK (tableoid = 0::oid)
Has OIDs: no




pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: constraints & tableoid [pgsql8.1]
Next
From: "Peter Brant"
Date:
Subject: Re: right sibling is not next child