On 28/10/2026 21:27, Manu wrote:
So v2 keeps a counter per base name. Names are never released, so
every smaller suffix is taken and the counter gives today's name. A
suffixed name determines its base and suffix, split at the last
underscore, so suffixed names can't collide with each other; only names
used as given (CTE names, subquery aliases) can, and those are checked.
No existing expected output changes, and a test-only build running the
old algorithm alongside found no mismatch. check-world passes with
cassert; REL_19_STABLE takes the patch as is.
One small suggestion: the suffix parsing in subplan_name_in_use() scans
the digits
multiple times across strspn, strlen, and strtoul. It might be a bit cleaner
to fold the validation and conversion together into a single pass.
Something like
- if (suffix != NULL && suffix[1] >= '1' && suffix[1] <= '9' &&
- strspn(suffix + 1, "0123456789") == strlen(suffix + 1) &&
- strlen(suffix + 1) <= 10)
+ if (suffix != NULL && suffix[1] >= '1' && suffix[1] <= '9')
{
- char *base = pnstrdup(name, suffix - name);
- SubplanNameSuffix *entry = subplan_name_suffix(glob, base, false);
+ char *endptr;
+ unsigned long val = strtoul(suffix + 1, &endptr, 10);
- pfree(base);
- if (entry != NULL && strtoul(suffix + 1, NULL, 10) <
entry->next_suffix)
- return true;
+ if (*endptr == '\0')
+ {
+ char *base = pnstrdup(name, suffix - name);
+ SubplanNameSuffix *entry = subplan_name_suffix(glob, base,
false);
+
+ pfree(base);
+ if (entry != NULL && val < entry->next_suffix)
+ return true;
+ }
}
Not a big deal though...
Regards,
Ayoub