Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix attach of a previously-detached injection point.
authorNoah Misch <noah@leadboat.com>
Thu, 22 Aug 2024 07:07:04 +0000 (00:07 -0700)
committerNoah Misch <noah@leadboat.com>
Thu, 22 Aug 2024 07:07:09 +0000 (00:07 -0700)
It's normal for the name in a free slot to match the new name.  The
max_inuse mechanism kept simple cases from reaching the problem.  The
problem could appear when index 0 was the previously-detached entry and
index 1 is in use.  Back-patch to v17, where this code first appeared.

src/backend/utils/misc/injection_point.c

index ab327779902faa4b8db9e1d3af3d08c0f4b626b9..1708acee71c3f5dc1e41e5ee7e39bedf4f1ba2ca 100644 (file)
@@ -315,8 +315,7 @@ InjectionPointAttach(const char *name,
            if (free_idx == -1)
                free_idx = idx;
        }
-
-       if (strcmp(entry->name, name) == 0)
+       else if (strcmp(entry->name, name) == 0)
            elog(ERROR, "injection point \"%s\" already defined", name);
    }
    if (free_idx == -1)