Primary Key Constraint on inheritance table not getting route to child tables

Поиск
Список
Период
Сортировка
От Rushabh Lathia
Тема Primary Key Constraint on inheritance table not getting route to child tables
Дата
Msg-id CAGPqQf2Mx-B0kwejftWckzCEpAfzfkCNhvd+qp3nZ0hbwEMFdA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Primary Key Constraint on inheritance table not getting route to child tables
Re: Primary Key Constraint on inheritance table not getting route to child tables
Список pgsql-hackers
Hi,

ALTER TABLE ADD Constraints PRIMARY KEY on inheritance table not getting route to child table.

But when we do ALTER TABLE DROP Constraint on the same, it complains about constraint does not
exists on child table.

Consider the following example

psql=# CREATE TABLE measurement (
psql(#     city_id         int not null,
psql(#     logdate         date not null,
psql(#     peaktemp        int,
psql(#     unitsales       int
psql(# );
CREATE TABLE
psql=# CREATE TABLE measurement_y2006m02 (
psql(#     CHECK ( logdate >= DATE '2006-02-01' AND logdate < DATE '2006-03-01' )
psql(# ) INHERITS (measurement);
CREATE TABLE
psql=# CREATE TABLE measurement_y2006m03 (
psql(#     CHECK ( logdate >= DATE '2006-03-01' AND logdate < DATE '2006-04-01' )
psql(# ) INHERITS (measurement);
CREATE TABLE
psql=# 
psql=# 
psql=# ALTER TABLE measurement
ADD CONSTRAINT con1 PRIMARY KEY (city_id);
ALTER TABLE
psql=# 
psql=# 

-- Don't have primary key on child table
psql=# desc measurement_y2006m02
         Table "public.measurement_y2006m02"
  Column   |            Type             | Modifiers 
-----------+-----------------------------+-----------
 city_id   | integer                     | not null
 logdate   | timestamp without time zone | not null
 peaktemp  | integer                     | 
 unitsales | integer                     | 
Check constraints:
    "measurement_y2006m02_logdate_check" CHECK (logdate >= '01-FEB-06 00:00:00'::timestamp without time zone AND logdate < '01-MAR-06 00:00:00'::timestamp without time zone)
Inherits: measurement

-- Primary key on parent table
psql=# desc measurement
             Table "public.measurement"
  Column   |            Type             | Modifiers 
-----------+-----------------------------+-----------
 city_id   | integer                     | not null
 logdate   | timestamp without time zone | not null
 peaktemp  | integer                     | 
 unitsales | integer                     | 
Indexes:
    "con1" PRIMARY KEY, btree (city_id)
Number of child tables: 2 (Use \d+ to list them.)

psql=# ALTER TABLE measurement
DROP CONSTRAINT con1;
ERROR:  constraint "con1" of relation "measurement_y2006m02" does not exist

I am not sure whether PRIMARY KEY not getting route is a expected behavior or not, but if its expected behavior
then obviously DROP CONSTRAINT should not complain about constraint doesn't exists on child table.

Inputs/Comments ?

Thanks,
Rushabh Lathia

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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: New WAL code dumps core trivially on replay of bad data
Следующее
От: "Albe Laurenz"
Дата:
Сообщение: Re: State of the on-disk bitmap index