>> Keep in mind that a large part of the reason why the \cset patch got
>> bounced was exactly that its detection of \; was impossibly ugly
>> and broken. Don't expect another patch using the same logic to
>> get looked on more favorably.
>
> Looking at the end of the discussion about \cset, it seems what
> you were against was not much how the detection was done rather
> than how and why it was used thereafter.
>
> In the case of the present bug, we just need to know whether there
> are any \; query separators in the command string.
> If yes, then SendQuery() doesn't get to use the cursor technique to
> avoid any risk with that command string, despite FETCH_COUNT>0.
>
> PFA a simple POC patch implementing this.
Indeed it does not look that bad.
Note a side effect of simply counting: "SELECT 1 \; ;" is detected as
compound, but internal misplaced optimization would result in only one
result as the empty one is removed, so the cursor trick would work.
In some earlier version, not sure whether I sent it, I tried to keep their
position with some int array and detect empty queries, which was a lot of
(ugly) efforts.
--
Fabien.