-----BEGIN PGP SIGNED MESSAGE-----
The attached patch resolves the bug reported by Kaloyan Iliev  on -general.
The problem occurred when executing ALTER TABLE ... ADD COLUMN ...
PRIMARY KEY with no default clause, on a table with rows already
present. The NOT NULL constraint was not enforced. The bug has been
observed on (at least) 8.2, 8.3 and CVS HEAD.
The fix was to force evaluation of the NOT NULL constraint in
ATExecAddColumn in all cases where the parser indicated that the
column ought to be NOT NULL.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
-----END PGP SIGNATURE-----
On Fri, Apr 25, 2008 at 3:46 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> 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
I realised that there's no reason for preparing a separate SetNotNull
subcommand anymore, now that ATExecAddColumn takes care of enforcing
the constraint, so I removed this special case.
I've also added a regression test for ADD COLUMN PRIMARY KEY.
pgsql-patches by date
|Next:||From: Tom Lane||Date: 2008-04-24 19:13:42|
|Subject: Re: ADD COLUMN with PRIMARY KEY bug (was: I think this is a BUG?) |
|Previous:||From: Gregory Stark||Date: 2008-04-24 18:58:20|
|Subject: Re: Proposed patch - psql wraps at window width|