Remove bogus Assert in foreign key cloning code
authorDavid Rowley <drowley@postgresql.org>
Wed, 22 Apr 2020 10:12:19 +0000 (22:12 +1200)
committerDavid Rowley <drowley@postgresql.org>
Wed, 22 Apr 2020 10:12:19 +0000 (22:12 +1200)
This Assert was trying to ensure that the number of columns in the foreign
key being cloned was the same number of attributes in the parentRel.  Of
course, it's perfectly valid to have columns in the table which are not
part of the foreign key constraint. It appears that this Assert was
misunderstanding that.

Reported-by: Rajkumar Raghuwanshi
Reviewed-by: amul sul
Discussion: https://postgr.es/m/CAKcux6=z1dtiWw5BOpqDx-U6KTiq+zD0Y2m810zUtWL+giVXWA@mail.gmail.com

src/backend/commands/tablecmds.c

index 794ff30fac74a6cfafa31f756c9849b4dc6032fa..5745cd648a68be1f56144fd50d4c66beb3a0f42e 100644 (file)
@@ -9043,7 +9043,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
                                   conpfeqop,
                                   conppeqop,
                                   conffeqop);
-       Assert(numfks == attmap->maplen);
+
        for (int i = 0; i < numfks; i++)
            mapped_confkey[i] = attmap->attnums[confkey[i] - 1];