Put a CHECK_FOR_INTERRUPTS call into the loops that try to find a unique new
authorTom Lane <[email protected]>
Wed, 20 Feb 2008 17:44:26 +0000 (17:44 +0000)
committerTom Lane <[email protected]>
Wed, 20 Feb 2008 17:44:26 +0000 (17:44 +0000)
OID or new relfilenode.  If the existing OIDs are sufficiently densely
populated, this could take a long time (perhaps even be an infinite loop),
so it seems wise to allow the system to respond to a cancel interrupt here.
Per a gripe from Jacky Leng.

Backpatch as far as 8.1.  Older versions just fail on OID collision,
instead of looping.

src/backend/catalog/catalog.c

index 0f94fc6227797bf21048538bc3079ca2a3ef5c5a..0c8d636f4eb9ad213247ff650849247bbeba9294 100644 (file)
@@ -301,6 +301,8 @@ GetNewOidWithIndex(Relation relation, Relation indexrel)
        /* Generate new OIDs until we find one not in the table */
        do
        {
+               CHECK_FOR_INTERRUPTS();
+
                newOid = GetNewObjectId();
 
                ScanKeyInit(&key,
@@ -349,6 +351,8 @@ GetNewRelFileNode(Oid reltablespace, bool relisshared, Relation pg_class)
 
        do
        {
+               CHECK_FOR_INTERRUPTS();
+
                /* Generate the OID */
                if (pg_class)
                        rnode.relNode = GetNewOid(pg_class);