Prevent stack overflow in exprLocation while parsing long queries

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Prevent stack overflow in exprLocation while parsing long queries
Date: 2026-11-24 17:36:01
Message-ID: CAN4CZFOJzyQ73OxeyRs2QCh7FfBDWqEAsNDiKm1G0hB9Cn6fhw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

In a thread about repack [1] Alvaro pointed out that the parser
support for psql is a hack, and since I was already interested in
making the parser available as a library for different projects I
decided to take a look into that.

Shortly after starting, Claude pointed out a trivial bug where a long
chain can cause a stack overflow crash during error reporting.

Since this requires a 1 line fix, I attached a patch for it.

I'm not sure if we want to add a test case for something like this,
but since it doesn't take much time to run or isn't too complex, the
patch includes one.

[1]: https://postgr.es/m/awVFP-EHuqyMYv51%40alvherre.pgsql

Attachment Content-Type Size
v1-0001-Prevent-stack-overflow-in-exprLocation.patch application/octet-stream 3.1 KB

Browse pgsql-hackers by date

  From Date Subject
Previous Message David Geier 2026-11-24 16:30:14 Re: Reducing relcache memory usage 2: shrink sizeof(RelationData)