BUG(fixed) in CREATE TABLE ADD CONSTRAINT...

Поиск
Список
Период
Сортировка
Искать
От
jozzano
Тема
BUG(fixed) in CREATE TABLE ADD CONSTRAINT...
Дата
Msg-id
17765721.995448221111.JavaMail.webmail@mail.exa.unicen.edu.ar
Список
Дерево обсуждения
BUG(fixed) in CREATE TABLE ADD CONSTRAINT... jozzano <jozzano@exa.unicen.edu.ar>
Re: BUG(fixed) in CREATE TABLE ADD CONSTRAINT... Bruce Momjian <pgman@candle.pha.pa.us>
--
jozzano@exa.unicen.edu.ar

Hi !
My system is  i686/Linux Mandrake 7.0/Postgresql v-7.0.2.
I found a bug in the sql command ALTER TABLE ADD CONSTRAINT..., when I trie=
d to add a composite foreign key constraint=20
(a FK with more than one attribute). The problem is in the file identified =
by=20
$Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/commands/command.c,=
v 1.71 2000/04/12 17:14:57 momjian Exp $=20
in the code lines #1139 to #1150, when the function AlterTableAddConstraint=
() tries to construct the vector of the trigger=B4s tgargs.
From the position 4 and forward, it must collect the pairs of fk_attrs and =
pk_attrs (interleaved), but the current code put first all=20
fk_attrs and then all the pk_attrs, leading to an error.
I fixed the bug and tested the update and now it works well. I send you a "=
diff -c command.c command.fixed.c" (with the diff :=20
GNU diffutils version 2.7) and the output is:

*** command.c		Sun May  6 21:13:06 2001
--- command.fixed.c	Mon Jul  9 19:58:21 2001
***************
*** 19,24 ****
--- 19,25 ----
   *	  manipulating code in the commands/ directory, should go
   *	  someplace closer to the lib/catalog code.
   *
+  *
   *-----------------------------------------------------------------------=
--
   */
  #include "postgres.h"
***************
*** 1138,1152 ****
  				{
  					Ident	   *fk_at =3D lfirst(list);
=20=20
! 					trig.tgargs[count++] =3D fk_at->name;
  				}
  				foreach(list, fkconstraint->pk_attrs)
  				{
  					Ident	   *pk_at =3D lfirst(list);
=20=20
! 					trig.tgargs[count++] =3D pk_at->name;
  				}
! 				trig.tgnargs =3D count;
=20=20
  				scan =3D heap_beginscan(rel, false, SnapshotNow, 0, NULL);
  				AssertState(scan !=3D NULL);
--- 1139,1156 ----
  				{
  					Ident	   *fk_at =3D lfirst(list);
=20=20
! 					trig.tgargs[count] =3D fk_at->name;
! 					count+=3D2;
  				}
+ 				count =3D 5;
  				foreach(list, fkconstraint->pk_attrs)
  				{
  					Ident	   *pk_at =3D lfirst(list);
=20=20
! 					trig.tgargs[count] =3D pk_at->name;
! 					count+=3D2;
  				}
! 				trig.tgnargs =3D (count-1);
=20=20
  				scan =3D heap_beginscan(rel, false, SnapshotNow, 0, NULL);
  				AssertState(scan !=3D NULL);
***************
*** 1220,1223 ****
  	LockRelation(rel, lockstmt->mode);
=20=20
  	heap_close(rel, NoLock);	/* close rel, keep lock */
! }
--- 1224,1227 ----
  	LockRelation(rel, lockstmt->mode);
=20=20
  	heap_close(rel, NoLock);	/* close rel, keep lock */
! }=20


I wish it would help you. If it=B4s necessary, drop me a line.  Regards
                                               Jose Luis Ozzano.
В списке pgsql-bugs по дате отправления
От: Reinhard Max
Дата:
От: Bruce Momjian
Дата:
FAQ