Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbea7a88

Browse files
committed
I have modifed heap.c so that it won't automatically generate duplicate
constraint names.> > A reasonable interpretation of DROP CONSTRAINT "foo" is to drop *all*> > constraints named "foo" on the target table.>> Then it should probably be a good thing to avoid the automatic> generation of> duplicate names? I might take a look at that, actually...>Christopher Kings-Lynne
1 parent999a4d4 commitbea7a88

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

‎src/backend/catalog/heap.c

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.163 2001/05/07 00:43:17 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.164 2001/05/09 21:13:35 momjian Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1832,8 +1832,47 @@ AddRelationRawConstraints(Relation rel,
18321832
}
18331833
else
18341834
{
1835+
inti;
1836+
intj;
1837+
boolsuccess;
1838+
List*listptr2;
18351839
ccname= (char*)palloc(NAMEDATALEN);
1836-
snprintf(ccname,NAMEDATALEN,"$%d",numchecks+1);
1840+
1841+
/* Loop until we find a non-conflicting constraint name */
1842+
/* What happens if this loops forever? */
1843+
j=numchecks+1;
1844+
do {
1845+
success= true;
1846+
snprintf(ccname,NAMEDATALEN,"$%d",j);
1847+
1848+
/* Check against old constraints */
1849+
for (i=0;i<numoldchecks;i++)
1850+
{
1851+
if (strcmp(oldchecks[i].ccname,ccname)==0) {
1852+
success= false;
1853+
break;
1854+
}
1855+
}
1856+
/* Check against other new constraints, if the check hasn't already failed */
1857+
if (success) {
1858+
foreach(listptr2,rawConstraints)
1859+
{
1860+
Constraint*cdef2= (Constraint*)lfirst(listptr2);
1861+
1862+
if (cdef2==cdef||
1863+
cdef2->contype!=CONSTR_CHECK||
1864+
cdef2->raw_expr==NULL||
1865+
cdef2->name==NULL)
1866+
continue;
1867+
if (strcmp(cdef2->name,ccname)==0) {
1868+
success= false;
1869+
break;
1870+
}
1871+
}
1872+
}
1873+
1874+
++j;
1875+
}while (!success);
18371876
}
18381877

18391878
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp