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

Re: Problem in AlterTableAddConstraint?

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Problem in AlterTableAddConstraint?
Date: 2000-11-29 02:40:21
Message-ID: 3.0.5.32.20001129134021.022af930@mail.rhyme.com.au (view raw or flat)
Thread:
Lists: pgsql-hackers
Assuming the silence is agreement, does this look like the right solution
(I assume looping through the index is the only way to count the segments):

    if (indexStruct->indisunique)
    {
        List       *attrl;

        /* go through the fkconstraint->pk_attrs list */
        foreach(attrl, fkconstraint->pk_attrs)
        {
            Ident *attr=lfirst(attrl);
            found = false;
            for (i = 0; i < INDEX_MAX_KEYS && indexStruct->indkey[i] != 0;
i++)
            {
                int pkattno = indexStruct->indkey[i];
                if (pkattno>0)
                {
                    char *name = NameStr(rel_attrs[pkattno-1]->attname);
                    if (strcmp(name, attr->name)==0)
                    {
                        found = true;
                        break;
                    }
                }
            }

            if (!found)
+           {
                break;
+           } else {
+
+               /* Require same number of segments */ 
+               if (i != length(fkconstraint->pk_attrs))
+               {
+                   found = false;
+                   break;
+               }
+           }
        }
    }


At 02:49 29/11/00 +1100, Philip Warner wrote:
>
>    create table c2(f1 integer, f2 integer, unique(f1,f2));
>    create table c1(f1 integer, f2 integer, 
>                    foreign key(f1) references c2(f1));
>
> is allowed with current sources.
>

----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.B.N. 75 008 659 498)          |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|
                                 |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/

In response to

pgsql-hackers by date

Next:From: Sandeep JoshiDate: 2000-11-29 03:30:33
Subject: redundancy and disk i/o
Previous:From: Nathan MyersDate: 2000-11-29 02:26:30
Subject: Re: beta testing version

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