On Tue, Feb 17, 2026 at 10:05 AM Zsolt Parragi <[email protected]> wrote: > The patch looks good, but I think there's an edge case where it causes > a performance regression with a negative start and long strings, > because of the removal of this condition: > > - /* > - * Ending at position 1, exclusive, obviously yields an empty > - * string. A zero or negative value can happen if the start was > - * negative or one. SQL99 says to return a zero-length string. > - */ > - if (E <= 1) > - return cstring_to_text(""); > -
Thanks Zsolt. Huh. Is it wasting time actually detoasting when it doesn't need to? I had peeked perhaps too briefly at that and figured it would skip the work for slicelength == 0 (see comment "/* Can save a lot of work at this point! */")... Maybe we need that check after all, but the duplication is annoying. Perhaps we should figure out how to hoist all the length computations up to the top so they're not duplicated in the eml == 1 and eml > 1 branches. Previously I'd written this as a proposal for the bugfix and was deliberately touching only the eml > 1 branch, but I guess we can aim a bit higher now and try to improve that aspect of the function too...
