Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lmESf-00031f-9L for pgsql-hackers@arkaria.postgresql.org; Thu, 27 May 2021 11:46:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lmESd-0002c5-SZ for pgsql-hackers@arkaria.postgresql.org; Thu, 27 May 2021 11:45:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lmESd-0002Z9-Hl for pgsql-hackers@lists.postgresql.org; Thu, 27 May 2021 11:45:59 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lmESW-0001Tm-Ma for pgsql-hackers@lists.postgresql.org; Thu, 27 May 2021 11:45:58 +0000 Received: from mail.postgrespro.ru (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 3C8E621C79B8; Thu, 27 May 2021 14:45:50 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1622115950; bh=Nq4dK4LVK/071Bxq88F0P6BHIkWYLwBXQPEnNvxZU0I=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=DSZXC9WB0g01gDGGo3JC0P9aV3f/BtGPtx7Vet86O6CCJ+AqiNKFsSPyc7rVn9zf7 8E/l2KpPPpP6sRW9NxJ5o+NPcGK5vX2oCTswPA6a4Q/mSuFKIEf3m/fmsEEuoJNAiS EgbFRJKR25r7Xnjicv5jOe3r32vnmqgnLjn86xME= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Thu, 27 May 2021 14:45:50 +0300 From: Yura Sokolov To: Alvaro Herrera Cc: Tom Lane , pgsql-hackers@lists.postgresql.org Subject: Re: Add PortalDrop in exec_execute_message In-Reply-To: <202105262059.dnf27qpnccuv@alvherre.pgsql> References: <202105262059.dnf27qpnccuv@alvherre.pgsql> User-Agent: Roundcube Webmail/1.4.0 Message-ID: <349ddd1e838c30b5efd3b14eb9345ccd@postgrespro.ru> X-Sender: y.sokolov@postgrespro.ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera писал 2021-05-26 23:59: > On 2021-May-25, Yura Sokolov wrote: > >> Tom Lane писал 2021-05-21 21:23: >> > Yura Sokolov writes: >> > > I propose to add PortalDrop at the 'if (completed)' branch of >> > > exec_execute_message. >> > >> > This violates our wire protocol specification, which >> > specifically says >> > >> > If successfully created, a named portal object lasts till the end of >> > the current transaction, unless explicitly destroyed. An unnamed >> > portal is destroyed at the end of the transaction, or as soon as the >> > next Bind statement specifying the unnamed portal as destination is >> > issued. (Note that a simple Query message also destroys the unnamed >> > portal.) >> > >> > I'm inclined to think that your complaint would be better handled >> > by having the client send a portal-close command, if it's not >> > going to do something else immediately. >> >> I thought about it as well. Then, if I understand correctly, >> PQsendQueryGuts and PQsendQueryInternal in pipeline mode should send >> "close portal" (CP) message after "execute" message, right? > > I don't think they should do that. The portal remains open, and the > libpq interface does that. The portal gets closed at end of > transaction > without the need for any client message. I think if the client wanted > to close the portal ahead of time, it would need a new libpq entry > point > to send the message to do that. - PQsendQuery issues Query message, and exec_simple_query closes its portal. - people doesn't expect PQsendQueryParams to be different from PQsendQuery aside of parameter sending. The fact that the portal remains open is a significant, unexpected and undesired difference. - PQsendQueryGuts is used in PQsendQueryParams and PQsendQueryPrepared. It is always sends empty portal name and always "send me all rows" limit (zero). Both usages are certainly to just perform query and certainly no one expects portal remains open. > (I didn't add a Close Portal message to PQsendQueryInternal in pipeline > mode precisely because there is no such message in PQsendQueryGuts. But PQsendQueryInternal should replicate behavior of PQsendQuery and not PQsendQueryParams. Despite it has to use new protocol, it should be indistinguishable to user, therefore portal should be closed. > I think it would be wrong to unconditionally add a Close Portal message > to any of those places.) Why? If you foresee problems, please share your mind. regards, Sokolov Yura aka funny_falcon