Re: [GENERAL] I think this is a BUG?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] I think this is a BUG?
Date: 2008-04-24 17:46:22
Message-ID: 1424.1209059182@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

I wrote:
> So somehow the constraint-validation code isn't getting applied in
> this case. I suspect you'll find it's a pretty localized fix.

I traced through this and found that for

alter table t1 add column f2 int not null;

transformAlterTableStmt will produce an AT_AddColumn subcommand
containing a ColumnDef with is_not_null = false, followed by an
AT_SetNotNull subcommand. But for

alter table t1 add column f2 int primary key;

it produces an AT_AddColumn subcommand containing a ColumnDef with
is_not_null = true, followed by an AT_AddIndex subcommand.

This is not super consistent, and maybe should be cleaned up;
but the intent is perfectly clear in both cases so I think tablecmds.c
should be able to do the right thing with either.

It looks to me that the appropriate fix involves doing

tab->new_notnull |= colDef->is_not_null;

somewhere in ATExecAddColumn; but I haven't tested this much.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Helm 2008-04-24 17:52:39 Adding notes against fields
Previous Message Harald Armin Massa 2008-04-24 16:59:32 Re: Which Python library - psycopg2 or pygresql?

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-04-24 17:49:19 Re: Proposed patch - psql wraps at window width
Previous Message Gregory Stark 2008-04-24 17:34:31 Re: Proposed patch - psql wraps at window width