Skip site navigation (1) Skip section navigation (2)

Re: constraints & tableoid [pgsql8.1]

From: 姜维 <jw(dot)pgsql(at)sduept(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: constraints & tableoid [pgsql8.1]
Date: 2006-04-11 14:14:07
Message-ID: 443BB9AF.1080505@sduept.com (view raw or flat)
Thread:
Lists: pgsql-bugs
Tom Lane 写道:
> Michael Fuhr <mike(at)fuhr(dot)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



In response to

pgsql-bugs by date

Next:From: julienDate: 2006-04-11 14:37:24
Subject: problem with kill script
Previous:From: Tom LaneDate: 2006-04-11 13:55:02
Subject: Re: constraints & tableoid [pgsql8.1]

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group