Re: Trouble with FETCH_COUNT and combined queries in psql - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: Trouble with FETCH_COUNT and combined queries in psql
Date
Msg-id alpine.DEB.2.21.1904232201260.3407@lancre
Whole thread Raw
In response to Re: Trouble with FETCH_COUNT and combined queries in psql  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-hackers
>> 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.



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Calling PrepareTempTablespaces in BufFileCreateTemp
Next
From: Tom Lane
Date:
Subject: Re: How and at what stage to stop FDW to generate plan with JOIN.