*** analyze.c.orig Sat Aug 14 16:40:36 1999 --- analyze.c Sat Aug 14 23:38:14 1999 *************** *** 579,584 **** --- 579,587 ---- columns = NIL; dlist = NIL; + /* + * Run through each primary element in the table creation clause + */ while (elements != NIL) { element = lfirst(elements); *************** *** 588,593 **** --- 591,597 ---- column = (ColumnDef *) element; columns = lappend(columns, column); + /* Special case SERIAL type? */ if (column->is_sequence) { char *sname; *************** *** 625,630 **** --- 629,635 ---- blist = lcons(sequence, NIL); } + /* Check for column constraints, if any... */ if (column->constraints != NIL) { clist = column->constraints; *************** *** 815,842 **** * or if a SERIAL column was defined along with a table PRIMARY KEY constraint. * - thomas 1999-05-11 */ ! if ((pkey != NULL) && (length(lfirst(pkey->indexParams)) == 1)) { dlist = ilist; ilist = NIL; while (dlist != NIL) { ! int keep = TRUE; index = lfirst(dlist); ! /* ! * has a single column argument, so might be a conflicting ! * index... ! */ ! if ((index != pkey) ! && (length(index->indexParams) == 1)) { ! char *pname = ((IndexElem *) lfirst(index->indexParams))->name; ! char *iname = ((IndexElem *) lfirst(index->indexParams))->name; ! /* same names? then don't keep... */ ! keep = (strcmp(iname, pname) != 0); } if (keep) --- 820,862 ---- * or if a SERIAL column was defined along with a table PRIMARY KEY constraint. * - thomas 1999-05-11 */ ! if (pkey != NULL) { dlist = ilist; ilist = NIL; while (dlist != NIL) { ! List *pcols, *icols; ! int plen, ilen; ! int keep = TRUE; index = lfirst(dlist); + pcols = pkey->indexParams; + icols = index->indexParams; ! plen = length(pcols); ! ilen = length(icols); ! ! /* Not the same as the primary key? Then we should look... */ ! if ((index != pkey) && (ilen == plen)) { ! keep = FALSE; ! while ((pcols != NIL) && (icols != NIL)) ! { ! IndexElem *pcol = lfirst(pcols); ! IndexElem *icol = lfirst(icols); ! char *pname = pcol->name; ! char *iname = icol->name; ! /* different names? then no match... */ ! if (strcmp(iname, pname) != 0) ! { ! keep = TRUE; ! break; ! } ! pcols = lnext(pcols); ! icols = lnext(icols); ! } } if (keep)