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

FK constraints "NOT VALID" by default?

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: FK constraints "NOT VALID" by default?
Date: 2011-03-17 21:22:10
Message-ID: 1300396759-sup-3063@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-hackers
I just ran this quick test in HEAD:

alvherre=# create table study (id int primary key);
NOTICE:  CREATE TABLE / PRIMARY KEY creará el índice implícito «study_pkey» para la tabla «study»
CREATE TABLE
alvherre=# insert into study select a from generate_series(1, 1000000) as a;
INSERT 0 1000000
alvherre=# create table studyform (id int primary key, study_id int not null references study);
NOTICE:  CREATE TABLE / PRIMARY KEY creará el índice implícito «studyform_pkey» para la tabla «studyform»
CREATE TABLE
alvherre=# insert into studyform select a, 1 + a * random() from generate_series(1, 100000) a;
INSERT 0 100000

and was very surprised to see that the foreign key is marked as NOT
VALID:

alvherre=# \d studyform
      Tabla «public.studyform»
 Columna  │  Tipo   │ Modificadores 
──────────┼─────────┼───────────────
 id       │ integer │ not null
 study_id │ integer │ not null
Índices:
    "studyform_pkey" PRIMARY KEY, btree (id)
Restricciones de llave foránea:
    "studyform_study_id_fkey" FOREIGN KEY (study_id) REFERENCES study(id) NOT VALID


Is this really intended?

-- 
Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2011-03-17 21:23:45
Subject: Re: really lazy vacuums?
Previous:From: Kevin GrittnerDate: 2011-03-17 21:02:18
Subject: Re: 2nd Level Buffer Cache

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