The following bug has been logged on the website:
Bug reference: 8408
Logged by: Maxim Boguk
Email address: maxim.boguk@gmail.com
PostgreSQL version: 9.2.4
Operating system: Any
Description:
There are simple test case:
create table test_columns (id serial primary key, value int
check(value<10));
NOTICE: CREATE TABLE will create implicit sequence "test_columns_id_seq"
for serial column "test_columns.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"test_columns_pkey" for table "test_columns"
CREATE TABLE
insert into test_columns(value) values (100);
ERROR: new row for relation "test_columns" violates check constraint
"test_columns_value_check"
DETAIL: Failing row contains (1, 100).
--it's ok...
--now let drop value column and add new one
alter table test_columns drop column value;
ALTER TABLE
alter table test_columns add column "value" int check (value < 10);
ALTER TABLE
insert into test_columns(value) values (100);
ERROR: new row for relation "test_columns" violates check constraint
"test_columns_value_check"
DETAIL: Failing row contains (2, null, 100).
-- now (2, null, 100) sound weird...
And yes I completely understand where this NULL came from and why this
happened.
However, I think error message should filter dropped column and strange null
values (because if a table has a lot dropped column this error message
quickly become completely unreadable).
Regards,
Maksym