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

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-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

pgsql-hackers by date

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

pgsql-general by date

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

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