Tom Lane 写道:
> Michael Fuhr <[EMAIL PROTECTED]> 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



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to