| From: | Julien Rouhaud <rjuju123(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Missing CFI() in SplitIdentifierString |
| Date: | 2026-12-02 07:26:43 |
| Message-ID: | aw_IMw25wIEauMLe@jrouhaud |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Wed, Dec 02, 2026 at 01:47:23AM -0500, Tom Lane wrote:
> Julien Rouhaud <rjuju123(at)gmail(dot)com> writes:
> > SplitIdentifierString can run pretty much forever without hitting a CFI. This
> > is mostly due to scan_quoted_identifier having O(n2) complexity, but the same
> > problem exists to a lesser degree in SplitIdentifierString.
>
> > I hit that problem by setting by mistake (bug in a some client app) search_path
> > to a big list of double quotes.
>
> > Simple patch attached, adding a couple of CFI in the mentioned functions.
>
> This seems like a pretty bad idea, because it will inject the
> possibility of elog() into GUC callbacks that aren't supposed to
> do that.
Ah right I forgot about that.
> Why is this O(N^2), and can't we fix that?
This is because the previous code moved the whole rest of the string when
collasping two consecutive double quotes into one, calling strlen and memmove
each time.
Attached patch does the same processing in-place, which brings back the
processing of unreasonable values in acceptable time.
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-quadratic-complexity-in-scan_quoted_identifie.patch | text/plain | 2.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2026-12-02 07:44:28 | executor startup doesn't skip sub-partitions of a pruned partition |
| Previous Message | solai v | 2026-12-02 07:26:37 | Re: [PATCH] Add planner support function to two-argument regexp_like() |