On Tue, May 20, 2025 at 11:59 AM Michael Paquier <mich...@paquier.xyz> wrote: > > On Tue, May 20, 2025 at 08:38:47AM +0900, Michael Paquier wrote: > > With the semicolon in place, stmt_len gets set for the last query of > > the string. Still digging more.. > > And got it. The problem is that we are failing to update the > statement location in a couple of cases with subqueries, and that we > should handle (p_stmt_len == 0) as of using the remaining bytes in > the string when a location is available, but the code was too > aggressive in thinking that the length = 0 case should be always > discarded. >
I was thinking of using strlen(pstate->p_sourcetext) - qry->stmt_location; in setQueryLocationAndLength, then I saw your changes in the pg_overexplain module. maybe put some comments on top of setQueryLocationAndLength for (qry->stmt_len == 0) case, but i saw the comments on the bottom of setQueryLocationAndLength. Overall, it looks good to me.